1mod actions;
4mod checks;
5mod reporter;
6mod surfaces;
7mod util;
8
9use anyhow::{bail, Result};
10
11use reporter::PatternReporter;
12
13#[derive(Debug, Clone, Copy, Default)]
14pub struct PatternOptions {
15 pub strict: bool,
16 pub json: bool,
17}
18
19pub fn run(options: PatternOptions) -> Result<()> {
20 let mut reporter = PatternReporter::default();
21
22 checks::required_files(&mut reporter);
23 checks::no_mod_rs(&mut reporter);
24 checks::file_sizes(&mut reporter)?;
25 checks::thin_shims(&mut reporter);
26 surfaces::thin_surfaces(&mut reporter)?;
27 actions::action_surfaces(&mut reporter);
28 checks::routes(&mut reporter);
29 checks::plugins(&mut reporter);
30 checks::config_and_auth(&mut reporter);
31 checks::tooling(&mut reporter);
32
33 if options.json {
34 reporter.print_json();
35 } else {
36 reporter.print();
37 }
38 if reporter.has_failures() || (options.strict && reporter.has_warnings()) {
39 if options.strict && reporter.has_warnings() {
40 bail!("PATTERNS.md contract check failed in strict mode");
41 }
42 bail!("PATTERNS.md contract check failed");
43 }
44 Ok(())
45}