Skip to content

fix(global): skip current packages on update#1596

Merged
fengmk2 merged 3 commits into
voidzero-dev:mainfrom
leno23:fix/skip-up-to-date-global-update
May 17, 2026
Merged

fix(global): skip current packages on update#1596
fengmk2 merged 3 commits into
voidzero-dev:mainfrom
leno23:fix/skip-up-to-date-global-update

Conversation

@leno23
Copy link
Copy Markdown
Contributor

@leno23 leno23 commented May 16, 2026

Summary

  • Skip vp update -g installs when the recorded global package version already matches the version resolved from npm.
  • Resolve the target registry version with the package's recorded Node runtime so checks match the package's managed environment.
  • Support npm view ... version --json outputs as strings, plain strings, and version arrays.

Fixes #1477
Related #1476

Test Plan

  • cargo fmt
  • cargo test -p vite_global_cli global_update --no-default-features
  • cargo test -p vite_global_cli updates_global_package_when_registry_version_differs_from_installed_version --no-default-features
  • cargo test -p vite_global_cli parse_npm_view_version --no-default-features
  • cargo test -p vite_global_cli --no-default-features --no-run
  • cargo clippy -p vite_global_cli --no-default-features -- -D warnings

Note: cargo test -p vite_global_cli --no-default-features aborts locally in the existing tests::unknown_argument_detected_with_pass_as_value_hint test with a stack overflow after the targeted tests pass.

@netlify
Copy link
Copy Markdown

netlify Bot commented May 16, 2026

Deploy Preview for viteplus-preview canceled.

Name Link
🔨 Latest commit 44082ff
🔍 Latest deploy log https://app.netlify.com/projects/viteplus-preview/deploys/6a09b6c9beb9d30008ba4a04

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 224dd80228

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/vite_global_cli/src/cli.rs Outdated
@liangmiQwQ
Copy link
Copy Markdown
Contributor

Thank you!

Comment thread crates/vite_global_cli/src/commands/env/global_install.rs
Comment thread crates/vite_global_cli/src/commands/env/global_install.rs
Copy link
Copy Markdown
Contributor

@liangmiQwQ liangmiQwQ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I made up #1477, I actually thought about a question: should we reinstall the packages installed with a different node version.

For example, you installed oxlint globally with node@21.0.0, but now you are running vp update -g with node@25.0.0. For current vp, it will be re-installed.

The reason why I have this question is different nodes can have different installing behaviors, like engine.node compatibility checks or some post-install scripts.

By the way, I'm not the team, and there are several comments I left, please use this as a reference only.

/cc @fengmk2 What do you think of it?

@fengmk2
Copy link
Copy Markdown
Member

fengmk2 commented May 16, 2026

@liangmiQwQ What you mentioned should be a new feature requirement, and you can open a new issue for discussion.

@fengmk2
Copy link
Copy Markdown
Member

fengmk2 commented May 16, 2026

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 224dd80228

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/vite_global_cli/src/cli.rs Outdated
@leno23
Copy link
Copy Markdown
Contributor Author

leno23 commented May 16, 2026

Addressed the review feedback in ac4ed26:

  • vp update -g now falls back to updating a package if the registry version lookup fails, instead of aborting the entire update.
  • Local/path package specs (., ./pkg, ../pkg, file:...) bypass the registry lookup so local global packages keep the previous reinstall behavior.
  • The skip check now compares both package version and the current target Node version. Packages installed with a different Node version are reinstalled under the current resolved Node version.
  • The version lookup/update path now uses the same resolved target Node version as the subsequent install.

Validation run locally:

cargo fmt
cargo test -p vite_global_cli global_update --no-default-features
cargo test -p vite_global_cli updates_global_package_when_registry_version_differs_from_installed_version --no-default-features
cargo test -p vite_global_cli updates_global_package_when_node_version_differs_from_target_version --no-default-features
cargo test -p vite_global_cli parse_npm_view_version --no-default-features
cargo test -p vite_global_cli test_is_local_package_spec --no-default-features
cargo test -p vite_global_cli --no-default-features --no-run
cargo clippy -p vite_global_cli --no-default-features -- -D warnings
git diff --check

@liangmiQwQ
Copy link
Copy Markdown
Contributor

liangmiQwQ commented May 16, 2026

  • The skip check now compares both package version and the current target Node version. Packages installed with a different Node version are reinstalled under the current resolved Node version.

Maybe we need to discuss about it in #1598 first? I'm sorry I didn't explain about it in the original issue.

I agree on how you process this problem in this PR, really thanks for solving my issue!

@leno23
Copy link
Copy Markdown
Contributor Author

leno23 commented May 16, 2026

Agreed that changing the cross-Node reinstall policy should be discussed in #1598. I adjusted the wording/implementation intent here: this PR keeps the existing behavior for packages installed under a different Node version (they still reinstall under the current resolved Node version) and only skips redundant reinstalls when the recorded package version and Node version both match. So #1598 remains the place to decide whether that behavior should change in the future.

Copy link
Copy Markdown
Member

@fengmk2 fengmk2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@leno23 Thanks!

@fengmk2 fengmk2 merged commit 2fd446f into voidzero-dev:main May 17, 2026
38 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.

Skip packages which are up to date in vp update -g

3 participants