From b32dd24765338c6b2a5ea62f9688eab2ee9a34bd Mon Sep 17 00:00:00 2001 From: Gemini Nexus Bot Date: Wed, 22 Apr 2026 05:44:41 -0300 Subject: [PATCH] build: add automated WiX extraction script for Windows builds - Create scripts/build-windows.js that extracts wix314-binaries.zip to tools/wix314/ - Adds extracted dir to PATH so electron-wix-msi can find candle.exe/light.exe - Adds npm script 'make:win' for one-command Windows installer build --- package.json | 1 + scripts/build-windows.js | 50 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 scripts/build-windows.js diff --git a/package.json b/package.json index 7ba5207..17f0c2e 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "dev": "cross-env DEBUG=electron-forge:* electron-forge start", "package": "electron-forge package", "make": "electron-forge make", + "make:win": "node scripts/build-windows.js", "publish": "electron-forge publish", "lint": "eslint .", "format": "prettier --check .", diff --git a/scripts/build-windows.js b/scripts/build-windows.js new file mode 100644 index 0000000..461f5b2 --- /dev/null +++ b/scripts/build-windows.js @@ -0,0 +1,50 @@ +const { execSync, spawn } = require('child_process'); +const fs = require('fs'); +const path = require('path'); + +const WIX_ZIP = path.join(process.cwd(), 'wix314-binaries.zip'); +const WIX_DIR = path.join(process.cwd(), 'tools', 'wix314'); + +function extractWix() { + if (!fs.existsSync(WIX_ZIP)) { + console.error(`WiX zip not found: ${WIX_ZIP}`); + process.exit(1); + } + + if (fs.existsSync(WIX_DIR)) { + console.log(`WiX already extracted at ${WIX_DIR}`); + return; + } + + console.log(`Extracting WiX binaries to ${WIX_DIR}...`); + fs.mkdirSync(WIX_DIR, { recursive: true }); + + // Use PowerShell Expand-Archive (built into Windows) + const psCommand = `Expand-Archive -Path "${WIX_ZIP}" -DestinationPath "${WIX_DIR}" -Force`; + execSync(psCommand, { shell: 'powershell.exe', stdio: 'inherit' }); + + console.log('WiX extraction complete.'); +} + +function setupWixPath() { + // electron-wix-msi's detect-wix.js runs execSync('candle -?') which relies on PATH + process.env.PATH = `${WIX_DIR};${process.env.PATH}`; + console.log(`Added ${WIX_DIR} to PATH`); +} + +function runMake() { + console.log('Running electron-forge make...'); + const make = spawn('npx', ['electron-forge', 'make'], { + stdio: 'inherit', + shell: true, + env: process.env, + }); + + make.on('exit', (code) => { + process.exit(code ?? 0); + }); +} + +extractWix(); +setupWixPath(); +runMake();