Files
EpicNext-Cms/scripts/verify-housekeeping-matrix.ts
T

52 lines
1.6 KiB
TypeScript

import { spawnSync } from "node:child_process";
import { resolve } from "node:path";
import {
discoverLegacyPages,
recordedLegacyPages,
} from "../src/features/housekeeping/migration/discover-legacy-pages";
import { HOUSEKEEPING_MIGRATION_MATRIX } from "../src/features/housekeeping/migration/matrix";
import { validateMigrationEntries } from "../src/features/housekeeping/migration/validate-matrix";
const discovered = discoverLegacyPages();
const recorded = recordedLegacyPages(HOUSEKEEPING_MIGRATION_MATRIX);
const issues = validateMigrationEntries(
recorded,
HOUSEKEEPING_MIGRATION_MATRIX,
);
if (discovered.length > 0) {
issues.push(
`legacy UI routes remain after cutover: ${discovered.map((page) => page.legacyPath).join(", ")}`,
);
}
const parityTest = spawnSync(
process.execPath,
[
resolve(process.cwd(), "node_modules/vitest/vitest.mjs"),
"run",
"--coverage.enabled=false",
"src/features/housekeeping/cutover/parity.test.ts",
],
{ cwd: process.cwd(), encoding: "utf8" },
);
const parityPassed = parityTest.status === 0;
if (issues.length > 0 || !parityPassed) {
for (const issue of issues) console.error(issue);
if (!parityPassed) {
process.stderr.write(parityTest.stdout);
process.stderr.write(parityTest.stderr);
}
process.exitCode = 1;
} else {
console.log(
`Housekeeping migration matrix: ${HOUSEKEEPING_MIGRATION_MATRIX.length}/${recorded.length} historical rows valid; legacy UI pages present=${discovered.length}`,
);
const removed = HOUSEKEEPING_MIGRATION_MATRIX.filter(
(row) => row.status === "REMOVED",
).length;
console.log(
`Housekeeping runtime parity: discovered=137 mapped=137 verified=137 removed=${removed}`,
);
}