<# .SYNOPSIS Build the Windows installer: Electron client + bundled Python node. .DESCRIPTION The Windows counterpart of packaging/build/build-client.sh. Produces a single per-user NSIS installer (MeshBay-Setup-.exe) that lays down the Electron app and, beside it under resources/node-runtime/, the frozen meshbay-node daemon. No hub -- a desktop machine installs client + node (+ common, which is inside the node runtime). This is the "Full" target. See build-win-light.ps1 for "Light" (client + UI only, no bundled node) -- steps 1-4 below live in build-win-common.ps1, shared by both, so they cannot drift apart. Steps: 1. Node >= 22 check 2. npm ci (+ approve Electron's install script, download Chromium) 3. bump Electron to the latest release (Chromium CVE policy -- see build-client.sh; skip with -NoElectronBump) 4. npm run sync-ui (copy the interface from the hub package) 5. build-node-runtime.ps1 (PyInstaller freeze of the daemon) -- Light skips this step entirely, which is the whole difference 6. electron-builder --win nsis .PARAMETER SkipFfmpeg Passed through to build-node-runtime.ps1 -- skip bundling ffmpeg (fetched and verified by default; see fetch-ffmpeg.ps1). Smaller, streaming-less build for local iteration only. .PARAMETER NoElectronBump Keep the pinned Electron instead of upgrading to the latest release. .PARAMETER SkipNodeRuntime Reuse an existing packages/meshbay-client/node-runtime/ (faster iteration on the electron-builder side). #> [CmdletBinding()] param( [switch]$SkipFfmpeg, [switch]$NoElectronBump, [switch]$SkipNodeRuntime ) $ErrorActionPreference = "Stop" Set-StrictMode -Version Latest $WinDir = $PSScriptRoot $Repo = (Resolve-Path (Join-Path $WinDir "..\..")).Path $Client = Join-Path $Repo "packages\meshbay-client" . (Join-Path $WinDir "build-win-common.ps1") # --- 1. Node ------------------------------------------------------------- Assert-NodeVersion Push-Location $Client try { # --- 2. deps ------------------------------------------------------ Invoke-NpmCi # --- 3. Electron: build against the latest release -------------- # Writes package.json + package-lock.json when it bumps something, so the # build leaves the repo dirty on purpose -- commit the new pin. Invoke-ElectronBump -NoElectronBump:$NoElectronBump -WinDir $WinDir # --- 4. UI ----------------------------------------------------- Invoke-SyncUi # --- 5. node runtime --------------------------------------- $rtExe = Join-Path $Client "node-runtime\meshbay-node.exe" if ($SkipNodeRuntime -and (Test-Path $rtExe)) { Step "reusing existing node-runtime/" } else { Step "building the bundled node (PyInstaller)" $rtArgs = @{} if ($SkipFfmpeg) { $rtArgs["SkipFfmpeg"] = $true } & (Join-Path $WinDir "build-node-runtime.ps1") @rtArgs if ($LASTEXITCODE -ne 0) { throw "build-node-runtime.ps1 failed" } } # --- 6. installer --------------------------------------- Step "electron-builder --win nsis" & npx electron-builder --win nsis if ($LASTEXITCODE -ne 0) { throw "electron-builder failed" } } finally { Pop-Location } $setup = Get-ChildItem (Join-Path $Client "dist") -Filter "*Setup*.exe" -ErrorAction SilentlyContinue | Sort-Object LastWriteTime | Select-Object -Last 1 Write-Host "" if ($setup) { Write-Host "OK installer: $($setup.FullName)" -ForegroundColor Green Write-Host (" ({0:N0} MB)" -f ($setup.Length / 1MB)) } else { Write-Host "!! no *Setup*.exe found in $Client\dist" -ForegroundColor Red exit 1 }