Files
2026-10-11 07:55:36 -07:00

49 lines
2.4 KiB
JavaScript
Executable File

#!/usr/bin/env node
'use strict'
// Build a self-contained app with DevTools enabled and the renderer left
// un-obfuscated (readable code + real line numbers in DevTools). Sets CS_DEBUG so
// electron-forge's generateAssets hook runs the debug asset build instead of the
// obfuscated release build.
//
// Usage: node scripts/make-debug.js [win32|darwin|linux] (default: win32)
// Output: win32 → out/make/squirrel.windows/
// darwin → out/make/{CrossSound.dmg, zip/darwin/...}
// Electron's makers can't cross-compile, so build each platform ON that platform.
process.env.CS_DEBUG = '1'
// Also minify the first-party renderer JS so the packaged debug app is smaller
// and launches faster. build-prod.js reads CS_DEBUG_MIN (inherited through the
// forge generateAssets hook). DevTools stay on.
process.env.CS_DEBUG_MIN = '1'
const { execSync } = require('child_process')
const path = require('path')
// Default win32 so `npm run win:debug` behaves exactly as before.
const PLATFORMS = ['win32', 'darwin', 'linux']
const platform = process.argv.slice(2).find((a) => !a.startsWith('-')) || 'win32'
if (!PLATFORMS.includes(platform)) {
console.error(`make-debug: unknown platform "${platform}" — expected one of ${PLATFORMS.join(', ')}`)
process.exit(1)
}
// macOS: ship the debug build as CrossSoundDebugging.app so it can live alongside
// the release app and is identifiable in the Dock / Applications. forge.config.js
// reads CS_APP_NAME. Windows keeps the plain name — its Squirrel update identity
// depends on it (see forge.config.js packagerConfig.name).
if (platform === 'darwin') process.env.CS_APP_NAME = 'CrossSoundDebugging'
// Wipe any stale packaged output first, or electron-packager reuses it and ships
// the previous version's app.asar (see scripts/clean-out.js).
require('./clean-out.js')
// Pull the Electron binary down FIRST, with a visible progress bar. Once forge's
// listr spinner takes over the terminal its download is invisible and the build
// looks frozen for minutes (see scripts/prefetch-electron.js). Best-effort: if
// this fails, forge downloads it itself.
try {
execSync(`node "${path.join(__dirname, 'prefetch-electron.js')}" ${platform}`, { stdio: 'inherit', env: process.env })
} catch (e) {
console.warn(`[make-debug] Electron prefetch skipped: ${(e && e.message) || e}`)
}
execSync(`npx electron-forge make --platform ${platform}`, { stdio: 'inherit', env: process.env })