Skip to content

feat(cli): non-blocking upgrade check with rate-limited notice#1173

Draft
fengmk2 wants to merge 10 commits intomainfrom
upgrade-tips
Draft

feat(cli): non-blocking upgrade check with rate-limited notice#1173
fengmk2 wants to merge 10 commits intomainfrom
upgrade-tips

Conversation

@fengmk2
Copy link
Copy Markdown
Member

@fengmk2 fengmk2 commented Mar 27, 2026

Summary

  • Add background upgrade check that queries the npm registry for the latest vp version
  • Show a one-line notice on stderr at most once per 24 hours (not on every run)
  • Registry query is also rate-limited to once per 24 hours, cached to ~/.vite-plus/.upgrade-check.json
  • Runs as an async background task concurrently with the command — zero latency impact

Suppression

The check is skipped entirely when:

  • VP_NO_UPDATE_CHECK=1, CI, or VITE_PLUS_CLI_TEST is set
  • Stderr is not a TTY (non-interactive / piped)
  • Command is upgrade, implode, lint, or fmt
  • Command has --silent or --json flag

RFC

See rfcs/upgrade-check.md for full design rationale.

image.png

Test plan

  • cargo test -p vite_global_cli -- upgrade_check (16 tests)
  • Manual: rm ~/.vite-plus/.upgrade-check.json && vp build — shows notice if behind latest
  • Manual: vp build again — no notice (prompted_at within 24h)
  • Manual: VP_NO_UPDATE_CHECK=1 vp build — no notice
  • Manual: vp install --silent — no notice

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.
@netlify
Copy link
Copy Markdown

netlify bot commented Mar 27, 2026

Deploy Preview for viteplus-preview canceled.

Name Link
🔨 Latest commit c2a8b8d
🔍 Latest deploy log https://app.netlify.com/projects/viteplus-preview/deploys/69c77c49559d5600084f7711

@fengmk2 fengmk2 self-assigned this Mar 27, 2026
Copy link
Copy Markdown
Member Author

fengmk2 commented Mar 27, 2026


How to use the Graphite Merge Queue

Add 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.

fengmk2 added 4 commits March 27, 2026 23:07
…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
@fengmk2 fengmk2 changed the title feat(cli): add non-blocking upgrade check with cached registry query feat(cli): non-blocking upgrade check with rate-limited notice Mar 27, 2026
fengmk2 added 5 commits March 28, 2026 00:20
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).
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