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

36 lines
1.7 KiB
JavaScript
Executable File

// VMP-signs the dev Electron package with castLabs EVS so Widevine (Go+ / DRM) works
// under `npm run dev`. Was inline in package.json as:
// cd node_modules/electron && python -m castlabs_evs.vmp sign-pkg dist
// …which is Windows-only in practice: macOS ships no `python` on PATH (only python3),
// so `npm run start` failed at this step before Electron was ever launched.
//
// `sign-pkg dist` itself is already cross-platform — it globs dist/ for Electron.app
// (macOS, signing the Electron Framework inside the bundle) or electron.exe
// (Windows/Linux). Only the interpreter name differs.
const { spawnSync } = require('child_process')
const path = require('path')
const cwd = path.join(__dirname, '..', 'node_modules', 'electron')
const isWin = process.platform === 'win32'
const candidates = isWin ? ['python', 'py', 'python3'] : ['python3', 'python']
let ran = null
for (const py of candidates) {
const r = spawnSync(py, ['-m', 'castlabs_evs.vmp', 'sign-pkg', 'dist'], { cwd, stdio: 'inherit' })
if (r.error && r.error.code === 'ENOENT') continue // interpreter not installed — try the next
ran = { py, status: r.status }
break
}
if (ran && ran.status === 0) process.exit(0)
console.warn('[vmp] Widevine signing failed:',
ran ? `${ran.py} exited ${ran.status}` : `no Python found (tried ${candidates.join(', ')})`)
console.warn('[vmp] Set it up with: pip3 install castlabs-evs && python3 -m castlabs_evs.account signup')
// Windows is the primary dev platform and signing is known-good there, so a failure is
// a real regression — keep it fatal and loud. Elsewhere, warn and let the app start:
// everything except DRM tracks works unsigned, which beats not launching at all.
process.exit(isWin ? 1 : 0)