feat(cli): add version check hook to prompt for updates#106
Merged
feat(cli): add version check hook to prompt for updates#106
Conversation
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>
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>
solimander
approved these changes
Mar 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
inithook that checks the npm registry for newer versions ofecloud-cliand prompts the user to upgradelast_version_check/last_known_version) so the npm registry is only hit once every 24 hours1.0.0-dev.1) correctly in version comparison, following semver ordering rulesDetails
init(runs before every command)upgrade,version0.0.0,0.0.0-developmentdevfor dev builds,latestotherwiselast_version_checkto snooze prompt for 24hTest plan
pnpm vitest run src/hooks/init/__tests__/version-check.test.ts— 21 tests passingpnpm run build— build succeeds🤖 Generated with Claude Code