feat(cli): non-blocking upgrade check with rate-limited notice#1173
Draft
feat(cli): non-blocking upgrade check with rate-limited notice#1173
Conversation
Show a one-line upgrade notice on stderr when a newer version of vp is available. The check runs as a background async task concurrently with the command, cached to ~/.vite-plus/.upgrade-check.json (24h TTL), and suppressed in CI, test mode, non-TTY, or via VP_NO_UPDATE_CHECK=1.
✅ Deploy Preview for viteplus-preview canceled.
|
Member
Author
How to use the Graphite Merge QueueAdd the label auto-merge to this PR to add it to the merge queue. You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
…e current version - Replace atomic temp+rename with direct overwrite in write_cache - Move current_version into display_upgrade_notice (callers don't need to pass it) - Update RFC to match
Skip the background upgrade check when: - Command has --silent or --json flag (respects quiet/machine output) - Command is `vp lint` or `vp fmt` (too fast to benefit)
…ractive Add prompted_at to cache so the notice shows at most once per day (like Deno/gh), not on every run. Skip the entire upgrade check when stderr is not a TTY.
…x naming - Remove redundant new_version field from UpgradeCheckResult (use cache.latest) - Carry cache through UpgradeCheckResult to avoid re-reading from disk - Remove unnecessary latest.clone() — move ownership directly - Rename update_handle → upgrade_handle for consistency with module name - Remove comments that restate what the code does
Split resolve_version into resolve_version_string (1 HTTP call, resolves tag to version) and resolve_platform_package (1 HTTP call, fetches platform tarball metadata). The upgrade check now uses only resolve_version_string for a single lightweight HTTP request. Also record checked_at on failed registry calls so offline users back off for 24h instead of retrying on every command.
…lease downgrades Replace string equality check with semver-aware is_newer_version() that only prompts when the latest stable version is strictly newer. Prevents prerelease/alpha users from being prompted to downgrade to stable, and skips dev builds (0.0.0) entirely.
…e flags Replace raw argv string scan with parsed command variant matching via is_quiet_or_machine_readable() methods on Commands and nested enums. Now correctly handles -s (short silent), --parseable, --format json/list, and --json on nested subcommands (pm, env, config, token).
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
vpversion~/.vite-plus/.upgrade-check.jsonSuppression
The check is skipped entirely when:
VP_NO_UPDATE_CHECK=1,CI, orVITE_PLUS_CLI_TESTis setupgrade,implode,lint, orfmt--silentor--jsonflagRFC
See
rfcs/upgrade-check.mdfor full design rationale.Test plan
cargo test -p vite_global_cli -- upgrade_check(16 tests)rm ~/.vite-plus/.upgrade-check.json && vp build— shows notice if behind latestvp buildagain — no notice (prompted_at within 24h)VP_NO_UPDATE_CHECK=1 vp build— no noticevp install --silent— no notice