Files
thinkrail/scripts/check-spec-surface.ts
Andrey Markinanddanyaberezun 1a2087f327 build: typecheck with TypeScript 7 and drop TypeScript 6 (#1232)
Move the catalog `typescript` to 7.1.0-beta, the official native compiler. Package typecheck scripts keep
`tsc`. The spec-surface and check:i18n scripts move to the TypeScript 7 async API, and the website
replaces `astro check` (TypeScript 6 API only) with `tsc --runExternalCode` over
`@astrojs/ts-content-mapper`, which needs Astro 7.4.4 and therefore Node >= 22.23.4 for contributors.

Co-authored-by: danyaberezun <danya.berezun@gmail.com>
2026-11-09 14:05:40 +00:00

44 lines
1.3 KiB
TypeScript

#!/usr/bin/env bun
import { join, resolve } from "node:path";
import { checkSpecSurfaces } from "./specSurface";
export interface SpecSurfaceRunOptions {
listSkipped?: boolean;
stdout?: (line: string) => void;
stderr?: (line: string) => void;
}
export async function runSpecSurfaceCheck(
inputRoot: string,
options: SpecSurfaceRunOptions = {},
): Promise<0 | 1> {
const root = resolve(inputRoot);
const stdout = options.stdout ?? console.log;
const stderr = options.stderr ?? console.error;
const report = await checkSpecSurfaces(root);
const summary = `${report.enrolled} enrolled, ${report.checked} compared; ${report.skipped.length} not enrolled`;
if (options.listSkipped) {
for (const entry of report.skipped) stdout(` ${entry.path}: ${entry.reason}`);
}
if (report.violations.length > 0) {
stderr("Spec surface drift:");
for (const violation of report.violations) stderr(` - ${violation}`);
stderr(`\n${summary}. Run with --list-skipped to see every unenrolled spec.`);
return 1;
}
stdout(
`check-spec-surface: OK (${summary}). Run with --list-skipped to see every unenrolled spec.`,
);
return 0;
}
if (import.meta.main) {
process.exitCode = await runSpecSurfaceCheck(join(import.meta.dir, ".."), {
listSkipped: process.argv.includes("--list-skipped"),
});
}