Files
Stirling-PDF/frontend/editor/scripts/build-provisioner.mjs
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

61 lines
1.6 KiB
JavaScript
Raw Normal View History

import { execFileSync } from "node:child_process";
import { existsSync, mkdirSync, copyFileSync } from "node:fs";
2026-05-22 13:40:34 +01:00
import { dirname, join, resolve } from "node:path";
import { fileURLToPath } from "node:url";
2026-02-06 18:06:01 +00:00
if (process.platform !== "win32") {
2026-02-06 18:06:01 +00:00
process.exit(0);
}
2026-05-22 13:40:34 +01:00
// build-provisioner is invoked from the workspace root (frontend/); resolve
// src-tauri relative to this script so it doesn't depend on cwd.
const scriptDir = dirname(fileURLToPath(import.meta.url));
const editorDir = resolve(scriptDir, "..");
const tauriDir = resolve(editorDir, "src-tauri");
const provisionerManifest = join(tauriDir, "provisioner", "Cargo.toml");
2026-02-06 18:06:01 +00:00
2026-04-17 10:50:16 +01:00
execFileSync(
"cargo",
["build", "--release", "--manifest-path", provisionerManifest],
{ stdio: "inherit" },
);
const provisionerExe = join(
tauriDir,
"provisioner",
"target",
"release",
"stirling-provisioner.exe",
);
2026-02-06 18:06:01 +00:00
if (!existsSync(provisionerExe)) {
throw new Error(`Provisioner binary not found at ${provisionerExe}`);
}
const wixDir = join(tauriDir, "windows", "wix");
2026-02-06 18:06:01 +00:00
mkdirSync(wixDir, { recursive: true });
const destExe = join(wixDir, "stirling-provision.exe");
2026-02-06 18:06:01 +00:00
copyFileSync(provisionerExe, destExe);
2026-04-15 23:25:38 +01:00
// --- Thumbnail handler DLL ---
const thumbManifest = join(tauriDir, "thumbnail-handler", "Cargo.toml");
2026-04-17 10:50:16 +01:00
execFileSync(
"cargo",
["build", "--release", "--manifest-path", thumbManifest],
{ stdio: "inherit" },
);
const thumbDll = join(
tauriDir,
"thumbnail-handler",
"target",
"release",
"stirling_thumbnail_handler.dll",
);
2026-04-15 23:25:38 +01:00
if (!existsSync(thumbDll)) {
throw new Error(`Thumbnail handler DLL not found at ${thumbDll}`);
}
copyFileSync(thumbDll, join(wixDir, "stirling_thumbnail_handler.dll"));