#!/usr/bin/env node /** * Build the Fabric web frontend with a relative asset base and copy the * static bundle into Fabric.Desktop/renderer/ so the packaged Electron app * is self-contained (loaded via file://, no separate web server needed). * * Fabric.Frontend is the sibling submodule under the parent Fabric repo. */ import { execSync } from 'node:child_process' import fs from 'node:fs' import path from 'node:path' import { fileURLToPath } from 'node:url' const __dirname = path.dirname(fileURLToPath(import.meta.url)) const DESKTOP = path.resolve(__dirname, '..') const FRONTEND = path.resolve(DESKTOP, '..', 'Fabric.Frontend') const SRC = path.join(FRONTEND, 'dist-desktop') const DEST = path.join(DESKTOP, 'renderer') if (!fs.existsSync(FRONTEND)) { console.error(`[build-renderer] Fabric.Frontend not found at ${FRONTEND}`) process.exit(1) } console.log('[build-renderer] building frontend (relative base)…') execSync('npm install --no-audit --no-fund', { cwd: FRONTEND, stdio: 'inherit' }) execSync('npm run build:desktop', { cwd: FRONTEND, stdio: 'inherit' }) if (!fs.existsSync(path.join(SRC, 'index.html'))) { console.error(`[build-renderer] expected ${SRC}/index.html after build`) process.exit(1) } fs.rmSync(DEST, { recursive: true, force: true }) fs.cpSync(SRC, DEST, { recursive: true }) console.log(`[build-renderer] copied ${SRC} -> ${DEST}`)