44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
/**
|
|
* CI check: fail if any `<id>.select.ts` has drifted from the content that
|
|
* `gen-crypto-selects.ts` would write given the current `crypto.config.ts`
|
|
* and primitive-id registry.
|
|
*/
|
|
|
|
import { existsSync, readFileSync } from "node:fs";
|
|
import { plan } from "./gen-crypto-selects.js";
|
|
|
|
async function main(): Promise<void> {
|
|
const stale: string[] = [];
|
|
const missing: string[] = [];
|
|
for (const p of plan()) {
|
|
if (!existsSync(p.path)) {
|
|
missing.push(p.path);
|
|
continue;
|
|
}
|
|
const current = readFileSync(p.path, "utf8");
|
|
if (current !== p.contents) {
|
|
stale.push(p.path);
|
|
}
|
|
}
|
|
if (missing.length > 0 || stale.length > 0) {
|
|
console.error("crypto-selects check FAILED");
|
|
if (missing.length > 0) {
|
|
console.error(" missing generated files:");
|
|
for (const m of missing) console.error(` ${m}`);
|
|
}
|
|
if (stale.length > 0) {
|
|
console.error(" stale / out-of-date generated files:");
|
|
for (const s of stale) console.error(` ${s}`);
|
|
}
|
|
console.error(
|
|
"Run `bun scripts/gen-crypto-selects.ts` and commit the result."
|
|
);
|
|
process.exit(1);
|
|
}
|
|
console.log("crypto-selects: OK");
|
|
}
|
|
|
|
if (import.meta.main) {
|
|
await main();
|
|
}
|