Files
fusion/packages/cli/tsup.config.ts
gsxdsm f68a5f0565 fix(FN-1243): add build-time dashboard stub fallback for CLI bundles
- Add resilient client asset staging in packages/cli/build.ts with automatic dist/client/index.html stub generation when dashboard assets are missing
- Update packages/cli/tsup.config.ts onSuccess hook to clear stale client output and emit the same minimal stub fallback in clean checkout builds
- Make bundle-output test build-aware by running pnpm build in beforeAll when bundle artifacts are absent, then assert client assets are present
- Preserve build output visibility by reporting whether real or stub client assets were staged
2026-04-08 09:44:42 -07:00

51 lines
1.7 KiB
TypeScript

import { defineConfig } from "tsup";
import { cpSync, existsSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
const __dirname = dirname(fileURLToPath(import.meta.url));
const dashboardClientSrc = join(__dirname, "..", "dashboard", "dist", "client");
const dashboardClientDest = join(__dirname, "dist", "client");
const dashboardClientStub = `<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Fusion Dashboard</title>
</head>
<body>
<main>
<h1>Fusion Dashboard</h1>
<p>Dashboard assets not built — run \`pnpm build\` to generate full client assets.</p>
</main>
</body>
</html>
`;
export default defineConfig({
entry: ["src/bin.ts", "src/extension.ts"],
format: ["esm"],
platform: "node",
target: "node22",
noExternal: [/^@fusion\//],
splitting: false,
clean: true,
onSuccess: async () => {
if (existsSync(dashboardClientDest)) {
rmSync(dashboardClientDest, { recursive: true, force: true });
}
if (existsSync(dashboardClientSrc)) {
cpSync(dashboardClientSrc, dashboardClientDest, { recursive: true });
console.log("Copied dashboard client assets to dist/client/");
return;
}
mkdirSync(dashboardClientDest, { recursive: true });
writeFileSync(join(dashboardClientDest, "index.html"), dashboardClientStub, "utf-8");
console.warn(
`WARNING: Dashboard client assets not found at ${dashboardClientSrc}. Generated minimal stub at ${join(dashboardClientDest, "index.html")}.`,
);
},
});