aboutsummaryrefslogtreecommitdiffstats
path: root/packaging/win/build-win-light.ps1
blob: 8b2d807ed502377addd3ef77647b2be21cf4e233 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<#
.SYNOPSIS
    Build the Windows "Light" installer: Electron client + UI only, no
    bundled node.

.DESCRIPTION
    The counterpart of build-win.ps1 (Full) for anyone who only wants to
    *use* MeshBay -- join groups, chat, browse, download, stream, cast --
    without ever hosting content from this machine. A member never needs a
    local node to begin with (identity keys are per node -- the *host's*
    node, not the joiner's), so Light is the existing browser-only usage
    pattern wrapped in the Electron shell, minus the frozen
    meshbay-node.exe / ffmpeg / autostart bundle.

    Steps 1-4 are identical to build-win.ps1 (build-win-common.ps1). Step 5,
    PyInstaller freezing a node runtime, does not happen at all -- that is
    the entire point of this target. Step 6 hands electron-builder a
    standalone config (electron-builder.light.yml) instead of package.json's
    `build` field: passing --config makes electron-builder read ONLY that
    file (see app-builder-lib/out/util/config/load.js's getConfig -- when a
    config path is given, package.json's own `build` field is never loaded,
    so there is no array-merge ambiguity to worry about between the two
    targets' very different extraResources).

    Output: packages/meshbay-client/dist-light/MeshBay Light-Setup-<version>.exe
    (a different output directory from Full's dist/, so the two builds never
    race on the same files).

.PARAMETER NoElectronBump
    Keep the pinned Electron instead of upgrading to the latest release.
#>
[CmdletBinding()]
param(
    [switch]$NoElectronBump
)

$ErrorActionPreference = "Stop"
Set-StrictMode -Version Latest

$WinDir  = $PSScriptRoot
$Repo    = (Resolve-Path (Join-Path $WinDir "..\..")).Path
$Client  = Join-Path $Repo "packages\meshbay-client"
$Config  = Join-Path $WinDir "electron-builder.light.yml"

. (Join-Path $WinDir "build-win-common.ps1")

if (-not (Test-Path $Config)) { throw "missing $Config" }

# --- 1. Node -------------------------------------------------------------
Assert-NodeVersion

Push-Location $Client
try {
    # --- 2. deps ------------------------------------------------------
    Invoke-NpmCi

    # --- 3. Electron: build against the latest release --------------
    Invoke-ElectronBump -NoElectronBump:$NoElectronBump -WinDir $WinDir

    # --- 4. UI -----------------------------------------------------
    Invoke-SyncUi

    # --- 5. (no node runtime -- that is what makes this "Light") -----

    # --- 6. installer ---------------------------------------
    Step "electron-builder --win nsis --config electron-builder.light.yml"
    & npx electron-builder --win nsis --config $Config
    if ($LASTEXITCODE -ne 0) { throw "electron-builder failed" }
}
finally {
    Pop-Location
}

$setup = Get-ChildItem (Join-Path $Client "dist-light") -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-light" -ForegroundColor Red
    exit 1
}