// This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at https://mozilla.org/MPL/2.0/. // The Windows Server release zip (Caddy mode, T4): ianitor-control.exe (release build without // the test hooks), the built web UI and deploy/windows/install.ps1, in // target/dist/ianitor--windows-x86_64.zip. Caddy is not in it: install.ps1 fetches the // pinned version and checks its SHA-512. // // cargo build --release -p ianitor-control --no-default-features // pnpm --filter web build // node scripts/package-windows.mjs import { cpSync, existsSync, mkdirSync, readFileSync, rmSync } from "node:fs"; import { join } from "node:path"; import { execFileSync } from "node:child_process"; const root = new URL("..", import.meta.url).pathname.replace(/^\/([A-Za-z]:)/, "$1"); const version = /^version = "([^"]+)"/m.exec(readFileSync(join(root, "Cargo.toml"), "utf8"))?.[1]; if (!version) throw new Error("no version in Cargo.toml"); const target = process.env.CARGO_TARGET_DIR || join(root, "target"); const exe = join(target, "release", "ianitor-control.exe"); const web = join(root, "apps", "web", "dist"); for (const p of [exe, web]) if (!existsSync(p)) throw new Error(`missing ${p}: build it first`); const name = `ianitor-${version}-windows-x86_64`; const out = join(root, "target", "dist"); const stage = join(out, name); rmSync(stage, { recursive: true, force: true }); mkdirSync(stage, { recursive: true }); cpSync(exe, join(stage, "ianitor-control.exe")); cpSync(web, join(stage, "web"), { recursive: true }); cpSync(join(root, "deploy", "windows", "install.ps1"), join(stage, "install.ps1")); cpSync(join(root, "LICENSE"), join(stage, "LICENSE")); const zip = join(out, `${name}.zip`); rmSync(zip, { force: true }); execFileSync("powershell", ["-NoProfile", "-Command", `Compress-Archive -Path '${stage}\\*' -DestinationPath '${zip}'`], { stdio: "inherit" }); rmSync(stage, { recursive: true, force: true }); console.log(zip);