49 lines
1.5 KiB
JavaScript
49 lines
1.5 KiB
JavaScript
import { readFile, writeFile } from "node:fs/promises";
|
|
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
const projectRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
|
|
const slug = process.argv[2];
|
|
|
|
if (!slug || !/^[a-z0-9-]+$/.test(slug)) {
|
|
throw new Error("Usage: node scripts/dungeon-pipeline/compact-conversion-fallback-warnings.mjs <slug>");
|
|
}
|
|
|
|
const reportPath = path.join(
|
|
projectRoot,
|
|
"dungeon-pipeline",
|
|
"work",
|
|
slug,
|
|
"staging",
|
|
"environment",
|
|
"conversion-report.json",
|
|
);
|
|
const report = JSON.parse(await readFile(reportPath, "utf8"));
|
|
const aliases = (report.sourceFallbacks ?? []).filter(
|
|
(fallback) => fallback.provenance === "client-extension-alias",
|
|
);
|
|
const warnings = (report.warnings ?? []).filter(
|
|
(warning) => !(
|
|
warning.startsWith("Installed-client extraction fallback:")
|
|
&& warning.includes("canonical installed-client asset uses the M2 extension")
|
|
) && !warning.startsWith("Resolved ")
|
|
&& !warning.includes("legacy MDX placement reference(s)"),
|
|
);
|
|
|
|
if (aliases.length) {
|
|
warnings.push(
|
|
`Resolved ${aliases.length} legacy MDX placement reference(s) to canonical installed-client M2 paths; `
|
|
+ "exact alias provenance is retained in sourceFallbacks.",
|
|
);
|
|
}
|
|
|
|
report.warnings = warnings;
|
|
await writeFile(reportPath, `${JSON.stringify(report, null, 2)}\n`, "utf8");
|
|
console.log(JSON.stringify({
|
|
status: "green",
|
|
slug,
|
|
aliases: aliases.length,
|
|
warnings: warnings.length,
|
|
report: path.relative(projectRoot, reportPath).replace(/\\/g, "/"),
|
|
}, null, 2));
|