hermes-agent/apps/desktop/scripts
emozilla 2d206a3a42 fix(desktop): stop hermes desktop from clobbering tracked main.cjs (#52735)
`npm run build` ended with `bundle-electron-main.mjs`, which esbuild-bundled
electron/main.cjs and renamed the bundle on top of the tracked source file.
Because every `hermes desktop` runs `npm run build`, each launch rewrote a
checked-in source file (~7.5k-line source -> ~14.8k-line bundle), dirtying the
working tree with a build artifact that `git restore` couldn't keep (the next
launch re-clobbered it) and forcing autostash/restore conflicts on update.

The bundle only existed to inline `simple-git` so the packaged app.asar (which
ships no node_modules) wouldn't crash at launch with "Cannot find module
'simple-git'". Replace it with the mechanism the repo already uses for the
other hoisted runtime dep (node-pty): stage the dependency closure and resolve
it from process.resourcesPath at runtime.

- stage-native-deps.cjs: resolve simple-git's runtime closure (walking
  dependencies + optionalDependencies, so a version bump that adds a transitive
  dep can't silently reintroduce the crash) and stage it under
  build/native-deps/vendor/node_modules/. The `vendor/` nesting is load-bearing:
  electron-builder drops a node_modules dir at the ROOT of an extraResources
  copy but keeps a nested one.
- git-review-ops.cjs: fall back to the staged
  native-deps/vendor/node_modules/simple-git when the hoisted require() fails;
  dev runs resolve the hoisted copy and never hit the fallback.
- package.json: drop the bundler from the `build` script so main.cjs is never a
  build target again.
- nix/desktop.nix: drop the direct bundler call (the closure rides the existing
  `cp -rn native-deps` into $out) and patch process.resourcesPath in
  git-review-ops.cjs alongside main.cjs.
- delete scripts/bundle-electron-main.mjs.

Verified: electron-builder's own file filter keeps the full staged closure
(0 dropped), and a packaged win-unpacked build launches with the git-review
pane resolving simple-git from the staged vendor path.
2026-06-28 01:30:09 -04:00
..
after-pack.cjs Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
assert-dist-built.cjs fix(desktop): fail loudly instead of blank-paging when the renderer bundle is missing (#41729) 2026-06-07 22:04:39 -07:00
assert-dist-built.test.cjs fix(desktop): fail loudly instead of blank-paging when the renderer bundle is missing (#41729) 2026-06-07 22:04:39 -07:00
assert-root-install.cjs Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
before-build.cjs Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
before-pack.cjs fix(desktop): recover from corrupt cached Electron download on build 2026-06-04 07:17:33 -07:00
before-pack.test.cjs fix(desktop): recover from corrupt cached Electron download on build 2026-06-04 07:17:33 -07:00
click-session.mjs Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
dev-no-hmr.mjs Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
diag-jump.mjs Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
diag-scroll-reset.mjs fix(desktop): stop chat scroll jumping by disabling native scroll anchoring 2026-06-02 23:08:01 -05:00
eval.mjs Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
leak-typing.mjs Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
measure-jump.mjs Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
measure-latency.mjs Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
measure-real-stream.mjs Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
measure-submit.mjs Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
measure-synthetic-stream.mjs Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
notarize-artifact.cjs Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
notarize.cjs Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
patch-electron-builder-mac-binary.cjs fix(desktop): resolve electronDist to the actual electron install location (#48081) 2026-06-17 18:08:01 -05:00
probe-renderer.mjs Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
probe-thread.mjs Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
profile-long-stream.mjs Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
profile-real-stream.mjs Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
profile-synth-stream.mjs Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
profile-typing-lag.md Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
profile-typing.mjs Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
reload-renderer.mjs Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
reload.mjs Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
run-electron-builder.cjs fix(desktop): resolve electronDist dynamically + self-heal blocked installs (supersedes #48081/#48082) (#48091) 2026-06-17 18:48:35 -05:00
set-exe-identity.cjs Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
stage-native-deps.cjs fix(desktop): stop hermes desktop from clobbering tracked main.cjs (#52735) 2026-06-28 01:30:09 -04:00
test-desktop.mjs Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
write-build-stamp.cjs Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00