Skip to content

(feat): adding update command#9

Open
lifeofpavs wants to merge 8 commits intomainfrom
pavs/update-command
Open

(feat): adding update command#9
lifeofpavs wants to merge 8 commits intomainfrom
pavs/update-command

Conversation

@lifeofpavs
Copy link

@lifeofpavs lifeofpavs commented Mar 20, 2026

Summary

Adds jup update — a self-update command that detects how the CLI was installed and acts accordingly:

  • Package manager installs (npm/pnpm/yarn/bun/Volta) — auto-executes the correct update command for the detected package manager
  • Binary installs — downloads the new binary from GitHub Releases, verifies its SHA-256 checksum against checksums.txt, and atomically replaces the current binary

Key implementation details

  • Version detection uses the GitHub API
  • Checksum verification — downloads checksums.txt alongside the binary and validates SHA-256 before replacing
  • Package manager detection — reads npm_config_user_agent env var to determine npm/pnpm/yarn/bun, checks VOLTA_HOME for Volta
  • --check flag — reports whether an update is available without installing
  • Supports both JSON and table output formats, consistent with all other commands

…ksum parsing

- Switch getLatestVersion to GitHub REST API JSON response instead of redirect parsing
- Replace identity maps in getBinaryAssetName with Set-based validation
- Parse checksum line once and reuse; compute Buffer.from(binary) once
ky sends the runtime's default User-Agent automatically; GitHub only
rejects requests with an empty header, not a missing one.
Single-use method with no reuse benefit; inlining reduces indirection.
Fetch checksums before the binary to validate platform support
dynamically instead of hardcoding allowed platforms/archs.
Both npm and binary paths now run automatically. Removes the
manual_update_required status — all updates return status: updated.
@lifeofpavs lifeofpavs marked this pull request as ready for review March 20, 2026 17:33
@lifeofpavs lifeofpavs requested a review from AaronCQL March 20, 2026 17:33
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