This repository was archived by the owner on Aug 6, 2026. It is now read-only.
Repository navigation
Commit 4664d32
authored
refactor(code): migrate from electron forge to electron-builder (#2795)
## Problem
Auto-update runs on Electron's native `autoUpdater` (Squirrel via update.electronjs.org) and has been a recurring source of failures we have repeatedly tried and failed to fix:
- Updates that download but never apply (ShipIt fails the macOS bundle swap, leaving users stuck on the old version).
- Users unable to download a new version at all.
It also gives us no control over the update UX: we cannot let users review and confirm an update before it downloads, show byte-level download progress, or surface "what's new" changelogs.
This migrates `apps/code` from Electron Forge to electron-builder + electron-updater, the more stable, production-standard toolchain. It fixes the reliability issues and gives us the primitives (explicit download/install, progress events, release manifests) to build that update UX.
## Changes
Forge 7 to electron-builder 26, landed as small commits:
- **Build/dev**: replaced Forge's Vite plugin with `scripts/build.mjs` and `scripts/dev.mjs` (keeps the CDP `:9222` debug port).
- **Packaging**: `electron-builder.config.cjs` (mac dmg+zip, win NSIS+Squirrel, linux AppImage/deb/rpm). A `before-pack.cjs` hook stages native modules from the hoisted root `node_modules`; `files` drops the deps Vite already inlines (bundle 1.7 GB to 669 MB).
- **Auto-update**: native `autoUpdater` to `electron-updater`, which reads `latest*.yml` from the GitHub release and exposes progress plus explicit download/install.
- **Release CI**: `code-release.yml` builds, signs and publishes via electron-builder (`CSC_LINK` signing, per-arch macOS manifest merge, dual Windows NSIS+Squirrel for the transition).
- **Cleanup**: removed Forge and the dead update.electronjs.org feed code; updated `docs/UPDATES.md`.
## How did you test this?
Locally on macOS arm64, I ran:
- `node scripts/build.mjs` and `electron-builder build --mac --arm64` (dmg + zip + `latest-mac.yml`). `asar list` confirms native JS is in the manifest with `.node` unpacked, the bundle is 669 MB, and artifact filenames match the manifest urls.
- Launched the packaged app: boots in ~2 to 3 s, renderer loads from the production asar, no module/ABI errors (over CDP).
- `pnpm typecheck`, `pnpm lint`, the updates unit tests (`vitest run updates`, 69 passing) and core's full suite (171 files). The PR's CI `unit-test` and `build` jobs pass.
Not validated locally (needs a tagged CI run because these cannot build on macOS): real signing/notarization, the Windows and Linux builds, the finalize manifest merge plus draft promotion, and end-to-end auto-update. Recommend a staging tag (for example `v0.0.0-eb-test.1`) before merge.
## Migration strategy
Per-platform rollout:
- **macOS**: transparent. update.electronjs.org serves the new electron-builder zip to current users, who then move onto the electron-updater feed.
- **Linux**: AppImage/deb/rpm are published for manual download, with no auto-update. This is unchanged from the Forge setup (the updater already supported only macOS and Windows, `isSupported()` is byte-identical to `main`). electron-updater unlocks AppImage auto-update as a later, separate change.
- **Windows**: ships both NSIS and Squirrel for a transition window (detail below). electron-updater requires NSIS, but the live base is installed via Squirrel.Windows and a Squirrel install cannot auto-update across to NSIS, so this avoids stranding those users.
Windows dual installer (temporary):
- `win.target: ["nsis", "squirrel"]` produces the NSIS installer (`*.exe` + `latest.yml`, consumed by electron-updater) and the Squirrel.Windows artifacts (`*.nupkg` + `RELEASES` + Setup, under `out/squirrel-windows/`). CI uploads both to the same GitHub release.
- `squirrelWindows.name: "PostHogCode"` keeps the package identity identical to the old Forge MakerSquirrel build, so `update.electronjs.org` keeps serving the existing Squirrel installs.
- Flow: existing Squirrel users get one more update through the legacy feed, then reinstall once via the NSIS installer (communicated in the release notes). New users install NSIS directly. After that everyone is on NSIS + electron-updater.
- When to remove it: once a release or two have shipped both formats and the Windows base has moved to NSIS (confirm via telemetry, or after a fixed deprecation window), drop `"squirrel"` from `win.target` and delete the `squirrelWindows` block in `electron-builder.config.cjs`, leaving NSIS only.
No UI changes in this PR; the confirm/progress/changelog UX is a follow-up on top of these primitives.
## Automatic notifications
- [ ] Publish to changelog?
- [ ] Alert Sales and Marketing teams?1 parent 0ea73a7 commit 4664d32
31 files changed
Lines changed: 1531 additions & 3039 deletions
File tree
- .github/workflows
- apps/code
- build
- scripts
- src/main
- platform-adapters
- utils
- tests/e2e/fixtures
- docs
- packages
- core/src/updates
- platform/src
- ui/src/features/sidebar/components
- scripts
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
38 | | - | |
39 | | - | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
| 71 | + | |
| 72 | + | |
72 | 73 | | |
73 | 74 | | |
74 | 75 | | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | 76 | | |
79 | 77 | | |
80 | 78 | | |
| |||
145 | 143 | | |
146 | 144 | | |
147 | 145 | | |
148 | | - | |
149 | | - | |
| 146 | + | |
150 | 147 | | |
151 | | - | |
152 | | - | |
153 | | - | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
154 | 151 | | |
155 | | - | |
156 | | - | |
157 | | - | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
158 | 157 | | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | 158 | | |
172 | | - | |
| 159 | + | |
173 | 160 | | |
174 | | - | |
175 | | - | |
176 | | - | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
177 | 192 | | |
178 | 193 | | |
179 | 194 | | |
| |||
192 | 207 | | |
193 | 208 | | |
194 | 209 | | |
195 | | - | |
| 210 | + | |
196 | 211 | | |
| 212 | + | |
197 | 213 | | |
198 | | - | |
199 | | - | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
200 | 226 | | |
201 | 227 | | |
202 | 228 | | |
| |||
274 | 300 | | |
275 | 301 | | |
276 | 302 | | |
277 | | - | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
278 | 313 | | |
| 314 | + | |
279 | 315 | | |
280 | | - | |
281 | | - | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
282 | 332 | | |
283 | 333 | | |
284 | 334 | | |
285 | 335 | | |
286 | 336 | | |
287 | 337 | | |
288 | | - | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
289 | 343 | | |
290 | 344 | | |
291 | 345 | | |
| |||
362 | 416 | | |
363 | 417 | | |
364 | 418 | | |
365 | | - | |
| 419 | + | |
366 | 420 | | |
367 | 421 | | |
368 | | - | |
369 | | - | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
370 | 441 | | |
371 | 442 | | |
372 | 443 | | |
| |||
391 | 462 | | |
392 | 463 | | |
393 | 464 | | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
394 | 506 | | |
395 | 507 | | |
396 | 508 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | 129 | | |
133 | 130 | | |
134 | 131 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
0 commit comments