Skip to content

feat(cli): add version check hook to prompt for updates#106

Merged
mcclurejt merged 4 commits intomasterfrom
mcclurejt/feat/version-check-hook
Mar 20, 2026
Merged

feat(cli): add version check hook to prompt for updates#106
mcclurejt merged 4 commits intomasterfrom
mcclurejt/feat/version-check-hook

Conversation

@mcclurejt
Copy link
Copy Markdown
Contributor

@mcclurejt mcclurejt commented Mar 19, 2026

Summary

  • Add an init hook that checks the npm registry for newer versions of ecloud-cli and prompts the user to upgrade
  • Cache version check results in global config (last_version_check / last_known_version) so the npm registry is only hit once every 24 hours
  • Handle prerelease version strings (e.g. 1.0.0-dev.1) correctly in version comparison, following semver ordering rules
  • Snooze the update prompt for 24 hours when the user declines, so it doesn't repeat on every command invocation

Details

Aspect Detail
Hook type init (runs before every command)
Cache TTL 24 hours
Fetch timeout 3 seconds
Skipped commands upgrade, version
Skipped versions 0.0.0, 0.0.0-development
Dist tag dev for dev builds, latest otherwise
Decline behavior Updates last_version_check to snooze prompt for 24h

Test plan

  • pnpm vitest run src/hooks/init/__tests__/version-check.test.ts — 21 tests passing
  • pnpm run build — build succeeds
  • Manual: run any CLI command, verify version check prompt appears when outdated
  • Manual: decline the update, run another command, verify prompt does not reappear
  • Manual: run a second command within 24h, verify no fetch occurs (cached)

🤖 Generated with Claude Code

Adds an oclif init hook that checks the npm registry for a newer
version before every command. If outdated, prompts the user to
update with current and latest versions displayed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mcclurejt mcclurejt marked this pull request as ready for review March 19, 2026 16:02
@mcclurejt mcclurejt requested a review from solimander March 19, 2026 16:09
mcclurejt and others added 3 commits March 19, 2026 14:35
Skip npm registry fetch when last check was within 24 hours, using
last_version_check and last_known_version fields from GlobalConfig.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
isNewerVersion now correctly parses prerelease suffixes (e.g.
"1.0.0-dev.1") instead of producing NaN from split/map(Number).
Compares prerelease segments per semver rules: release > prerelease,
and numeric segments compared numerically.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When the user declines the update prompt, save the current timestamp to
last_version_check so the prompt is suppressed for the remainder of the
24-hour cache window.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mcclurejt mcclurejt merged commit a63fb9c into master Mar 20, 2026
3 checks passed
@mcclurejt mcclurejt deleted the mcclurejt/feat/version-check-hook branch March 20, 2026 16:26
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