41 lines
1.0 KiB
TypeScript
41 lines
1.0 KiB
TypeScript
import { mkdir, writeFile } from "node:fs/promises";
|
|
import path from "node:path";
|
|
|
|
import { scanRealtimeBoundaries } from "./lib/realtime-boundaries.ts";
|
|
|
|
const sourceRoot = argument("--source-root") ?? "src";
|
|
const artifact =
|
|
argument("--artifact") ??
|
|
"artifacts/quality/realtime-boundaries.json";
|
|
const violations = await scanRealtimeBoundaries(sourceRoot);
|
|
const report = Object.freeze({
|
|
schemaVersion: 1,
|
|
sourceRoot,
|
|
violations,
|
|
passed: violations.length === 0,
|
|
});
|
|
|
|
await mkdir(path.dirname(artifact), { recursive: true });
|
|
await writeFile(
|
|
artifact,
|
|
`${JSON.stringify(report, null, 2)}\n`,
|
|
);
|
|
|
|
if (violations.length > 0) {
|
|
for (const violation of violations) {
|
|
process.stderr.write(
|
|
`${violation.file}:${violation.line} ${violation.ruleId}\n`,
|
|
);
|
|
}
|
|
process.exit(1);
|
|
}
|
|
|
|
process.stdout.write(
|
|
`Realtime boundaries: PASS (${sourceRoot})\n`,
|
|
);
|
|
|
|
function argument(name: string): string | undefined {
|
|
const index = process.argv.indexOf(name);
|
|
return index >= 0 ? process.argv[index + 1] : undefined;
|
|
}
|