// Copies the pkg-packaged backend (dist/backend/backend.exe) into // src-tauri/binaries/ under the name Tauri expects for an external binary: // backend-[.exe]. // // Build the backend first: cd backend && npm run package import { execSync } from "node:child_process"; import { copyFileSync, existsSync, mkdirSync } from "node:fs"; import { dirname, join, resolve } from "node:path"; import { fileURLToPath } from "node:url"; const here = dirname(fileURLToPath(import.meta.url)); const repoRoot = resolve(here, "..", ".."); const ext = process.platform === "win32" ? ".exe" : ""; const source = join(repoRoot, "dist", "backend", `backend${ext}`); const triple = execSync("rustc -vV", { encoding: "utf8" }) .split("\n") .find((line) => line.startsWith("host:")) ?.slice("host:".length) .trim(); if (!triple) { console.error("Could not read the Rust host triple from `rustc -vV`."); process.exit(1); } if (!existsSync(source)) { console.error(`Backend executable not found: ${source}`); console.error("Build it first: cd backend && npm run package"); process.exit(1); } const targetDir = resolve(here, "..", "src-tauri", "binaries"); mkdirSync(targetDir, { recursive: true }); const target = join(targetDir, `backend-${triple}${ext}`); copyFileSync(source, target); console.log(`Copied ${source} -> ${target}`);