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
This commit is contained in:
1 parent
2c81d129f9
commit
b32dd24765
2 files changed
+51
No files matched your search
@@ -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();
|
||||
Reference in new issue
Block a user