smart-check.mjs
1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env node
import childProcess from "node:child_process";
import process from "node:process";
import { requireWorkspaceRoot } from "./workspace-root.mjs";
const repoRoot = requireWorkspaceRoot();
const tier = readFlag("--tier") || "fast";
const commands = [
{ id: "lint", command: "pnpm run lint:changed" },
{ id: "typecheck", command: "pnpm run check:type" },
{ id: "template-contract", command: "pnpm run check:template-contract" },
{ id: "review-trigger", command: "pnpm run review:trigger" },
{ id: "file-budget", command: "pnpm run check:file-budget" },
{ id: "fitness", command: `pnpm run check:fitness -- --tier ${tier}` },
{ id: "capture-pitfalls", command: "pnpm run ai:capture-pitfalls", allowFail: true },
];
for (const step of commands) {
console.log(`[smart-check] ${step.id}`);
const status = childProcess.spawnSync(step.command, {
cwd: repoRoot,
shell: true,
stdio: "inherit",
});
if (status.status !== 0) {
if (step.allowFail) {
console.warn(`[smart-check] ${step.id} exited with ${status.status} (non-blocking)`);
} else {
console.error(`[smart-check] failed at ${step.id}`);
process.exit(status.status ?? 1);
}
}
}
console.log("[smart-check] passed");
function readFlag(name) {
const index = process.argv.indexOf(name);
if (index !== -1 && index + 1 < process.argv.length) {
return process.argv[index + 1];
}
return "";
}