Adds parameterized test cases to the worktree-liveness test to exercise different configured `worktreesDir` paths, improving coverage of the worktree escape/isolation path. Fusion-Task-Id: FN-4737 Fusion-Task-Lineage: 40e262ea-2507-461e-b9f5-940b3b4490f9
72 lines
2.2 KiB
TypeScript
72 lines
2.2 KiB
TypeScript
import { build } from "esbuild";
|
|
import { cp, mkdir, rm, stat } from "node:fs/promises";
|
|
import { join, resolve } from "node:path";
|
|
import { buildDashboardClient, packageRoot, workspaceRoot } from "./workspace-tools";
|
|
const dashboardClientDir = join(workspaceRoot, "packages", "dashboard", "dist", "client");
|
|
const desktopDistDir = join(packageRoot, "dist");
|
|
const desktopClientDistDir = join(desktopDistDir, "client");
|
|
const externalMainProcessPackages = ["electron", "@fusion/core", "@fusion/dashboard"];
|
|
|
|
async function ensureDashboardBuild(): Promise<void> {
|
|
console.log("[desktop:build] Building dashboard client...");
|
|
await buildDashboardClient();
|
|
|
|
try {
|
|
await stat(dashboardClientDir);
|
|
} catch {
|
|
throw new Error(`Dashboard client assets not found: ${dashboardClientDir}`);
|
|
}
|
|
}
|
|
|
|
async function buildElectronEntrypoints(): Promise<void> {
|
|
console.log("[desktop:build] Bundling Electron main/preload with esbuild...");
|
|
|
|
await Promise.all([
|
|
build({
|
|
entryPoints: [join(packageRoot, "src", "main.ts")],
|
|
outfile: join(desktopDistDir, "main.js"),
|
|
bundle: true,
|
|
format: "esm",
|
|
platform: "node",
|
|
target: "node22",
|
|
sourcemap: true,
|
|
packages: "external",
|
|
external: externalMainProcessPackages,
|
|
logLevel: "info",
|
|
}),
|
|
build({
|
|
entryPoints: [join(packageRoot, "src", "preload.ts")],
|
|
outfile: join(desktopDistDir, "preload.js"),
|
|
bundle: true,
|
|
format: "esm",
|
|
platform: "node",
|
|
target: "node22",
|
|
sourcemap: true,
|
|
packages: "external",
|
|
external: externalMainProcessPackages,
|
|
logLevel: "info",
|
|
}),
|
|
]);
|
|
}
|
|
|
|
async function copyDashboardClient(): Promise<void> {
|
|
console.log("[desktop:build] Copying dashboard client into desktop dist/client...");
|
|
await cp(dashboardClientDir, desktopClientDistDir, { recursive: true });
|
|
}
|
|
|
|
async function main(): Promise<void> {
|
|
await rm(desktopDistDir, { recursive: true, force: true });
|
|
await mkdir(desktopDistDir, { recursive: true });
|
|
|
|
await ensureDashboardBuild();
|
|
await buildElectronEntrypoints();
|
|
await copyDashboardClient();
|
|
|
|
console.log("[desktop:build] Desktop build complete");
|
|
}
|
|
|
|
void main().catch((error) => {
|
|
console.error("[desktop:build] Build failed", error);
|
|
process.exitCode = 1;
|
|
});
|