ai-chatbot/scripts/postbuild-cleanup.mjs
Codex 9155682238 chore(repo): make the recovered production baseline portable
Record source and release ownership, keep source line endings consistent,
and exclude local build/config backups from version control.

Restore default Next type paths, normalize CI checks across line endings,
and use portable Playwright and postbuild entry points on Windows/Linux.
Align the stale timeout fixture with the existing production timeout policy.

Application runtime files remain identical to production-snapshot-48-20261030.
Production build and focused regressions passed; pre-existing full-repository
lint findings remain documented instead of relaxing lint rules.
2026-10-30 16:19:08 +08:00

44 lines
1.2 KiB
JavaScript

#!/usr/bin/env node
import { readdir, realpath, unlink } from "node:fs/promises";
import { isAbsolute, join, relative, resolve } from "node:path";
const workspace = await realpath(process.cwd());
const distDir = resolve(workspace, process.env.NEXT_DIST_DIR?.trim() || ".next");
function requireInsideWorkspace(path) {
const location = relative(workspace, path);
if (!location || location === ".." || location.startsWith(`..${process.platform === "win32" ? "\\" : "/"}`) || isAbsolute(location)) {
throw new Error("Source map cleanup requires a build directory inside the workspace.");
}
}
requireInsideWorkspace(distDir);
let staticDir;
try {
staticDir = await realpath(join(distDir, "static"));
} catch (error) {
if (error.code !== "ENOENT") throw error;
}
let removed = 0;
async function clean(directory) {
for (const entry of await readdir(directory, { withFileTypes: true })) {
const path = join(directory, entry.name);
if (entry.isDirectory()) {
await clean(path);
} else if (entry.isFile() && entry.name.endsWith(".map")) {
await unlink(path);
removed++;
}
}
}
if (staticDir) {
requireInsideWorkspace(staticDir);
await clean(staticDir);
}
console.log(`Removed ${removed} public source map files.`);