Skip to content

Update from GitHub Releases without npm - #63

Merged
dibin666 merged 1 commit into
masterfrom
update-without-npm
Oct 3, 2026
Merged

dibin666 merged 1 commit into
masterfrom
update-without-npm

Conversation

@dibin666

@dibin666 dibin666 commented Oct 3, 2026

Copy link
Copy Markdown
Owner

Last of three PRs (image ✅ #61 → unified release ✅ #62, shipped as 0.3.31 → npm-free update).

What

  • Check: asks only GitHub's latest.json. The npm registries (configured, npmjs, npmmirror) are asked only when GitHub cannot be reached, all at once, and the newest answer wins.

  • Install: since 0.3.31 a release tarball carries all of its JavaScript bundled; node-pty is the only dependency npm installs. updater/release-install.ts therefore:

    1. downloads the tarball from GitHub
    2. unpacks it beside the package (updater/tarball.ts, a small gzip+ustar/pax reader that refuses links and paths escaping the package)
    3. moves the installed node-pty, and whatever npm nested under it, into the new tree
    4. swaps the two directories by renaming them

    If renaming fails on Windows because the folder is held, the files are copied over in place, keeping node-pty.

  • npm is only a fallback: when a release asks for a different node-pty or changes bin (it then installs the same GitHub tarball), when the download fails (npm's registry), or when only a registry could answer the check.

  • Registry discovery moved to updater/sources.ts. ~160 of the added lines are that verbatim move, so the real diff is under 800 lines. The TUI's "mirror is behind" note is gone, since mirrors are no longer asked alongside GitHub. i18n strings (en + zh) and docs updated.

Tested

  • Unit tests for the swap: the dependency is carried over and stale packages dropped, needsNpm leaves the install untouched, a wrong version or HTTP error changes nothing, path escape and links are refused, pax long paths are handled.
  • The extractor's output is byte-identical to tar -x on a real npm pack release tarball.
  • End to end against a real global install: swapped in 81 ms; herdr-remote on PATH reports the new version; node-pty still spawns a pty.

Note: installs at 0.3.31 or older still run the old update code, so their next update goes through npm once. Updates after that skip npm.

`herdr-remote update` asked GitHub and every npm registry at once on each
check, and always installed through `npm install -g`, which resolves the
whole dependency tree and takes a minute where it works at all. A release now
carries all of its JavaScript bundled, with node-pty the only dependency npm
installs, so the update downloads the release tarball from GitHub, unpacks it
beside the package, carries the installed node-pty over and swaps the
directories: no npm, under a second once downloaded.

npm remains the fallback: for a release that asks for a different node-pty
or adds commands, for a download that fails, and, in the check, registries
are asked only when GitHub cannot be reached.
@dibin666
dibin666 merged commit 878abb7 into master Oct 3, 2026
2 checks passed
@dibin666
dibin666 deleted the update-without-npm branch October 3, 2026 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant