Skip to content

feat(cli): sideshow --version with update check#154

Merged
elucid merged 2 commits into
mainfrom
cli-version
Jun 26, 2026
Merged

feat(cli): sideshow --version with update check#154
elucid merged 2 commits into
mainfrom
cli-version

Conversation

@elucid

@elucid elucid commented Jun 26, 2026

Copy link
Copy Markdown
Member

What

Adds sideshow --version, sideshow -V, and sideshow version — all three behave identically: print the installed version and check the npm registry for a newer release.

$ sideshow --version
sideshow 0.8.0

Update available: 0.8.0 → 0.9.1
Run: npm install -g sideshow

The update hint only appears when a newer version exists.

How the update check works

  • Fetches https://registry.npmjs.org/sideshow/latest directly — no running sideshow server required
  • 3 second timeout so a flaky network never makes the command feel slow
  • 24 hour disk cache ($TMPDIR/sideshow-<user>/update-check.json) so repeated calls don't hit the registry
  • Failures silently swallowed — offline or rate-limited? You still get your version, just no update hint

This mirrors the pattern used by npm, gh, brew, and cargo. The server already does the same registry check for the viewer's update notice (with a 6 h in-memory cache); the CLI reuses the same registry endpoint but caches to disk since it's a short-lived process.

Tests

4 new tests in test/cli.test.ts:

  • --version, -V, and version all print the version
  • version runs end-to-end without errors (update check is best-effort)

`sideshow --version`, `sideshow -V`, and `sideshow version` all print the
current version and check the npm registry for a newer release. The check
is best-effort: 3 s timeout, 24 h disk cache, failures silently swallowed.
When a newer version exists the output shows the available update and the
install command.

Reuses the same registry lookup the server already does for the viewer
update notice, but runs it directly from the CLI — no running server
required.
@benvinegar

Copy link
Copy Markdown
Member

Good call

@elucid elucid merged commit 138dafe into main Jun 26, 2026
9 checks passed
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.

2 participants