Skip to content

feat(env): mark installed/current/default versions in vp env list-remote#1907

Open
semimikoh wants to merge 3 commits into
voidzero-dev:mainfrom
semimikoh:feat/env-list-remote-installed-markers
Open

feat(env): mark installed/current/default versions in vp env list-remote#1907
semimikoh wants to merge 3 commits into
voidzero-dev:mainfrom
semimikoh:feat/env-list-remote-installed-markers

Conversation

@semimikoh

Copy link
Copy Markdown
Contributor

Description

Implements #1881: annotate vp env list-remote so installed/current/default Node.js versions are easy to spot in the registry listing.

This follows the direction discussed in the issue: list-remote still primarily lists registry versions, but now annotates the version resolved for the current project/cwd (same logic as vp env current) and the global default as a separate marker.

What changed

  • Installed versions are highlighted in green (blue for the current project-resolved version) when stdout supports color, and prefixed with * when colors are disabled (piped / NO_COLOR) so the distinction survives non-TTY output.
  • Current (project-resolved, via config::resolve_version) and default (global default_node_version) versions are annotated with trailing current / default labels. They can differ, so each gets its own label.
  • --json output gains installed, current, and default boolean fields.
  • All local lookups degrade gracefully — if any fail, the registry listing still renders.

Example

# TTY (color)
v24.2.0
v22.13.0 (Jod)   current     # blue + label (project-resolved)
v20.18.0 (Iron)  default     # green (installed) + label (global default)

# piped / NO_COLOR
  v24.2.0
* v22.13.0 (Jod) current
* v20.18.0 (Iron) default

Testing

  • cargo test -p vite_global_cli list_remote (added coverage for installed and current/default marking)
  • cargo clippy -p vite_global_cli — clean
  • cargo fmt --check

…mote`

Annotate the registry listing with locally-derived markers so it is easy
to see which versions are already available:

- installed versions are highlighted (green; blue for the current
  project-resolved version), and prefixed with `*` when colors are
  disabled so the distinction survives piped/`NO_COLOR` output
- the current project version (same resolution logic as `vp env current`)
  and the global default are annotated with `current` / `default` labels
- `--json` output gains `installed`, `current`, and `default` fields

All local lookups degrade gracefully, so the registry listing still
renders if they fail.
@netlify

netlify Bot commented Jun 22, 2026

Copy link
Copy Markdown

Deploy Preview for viteplus-preview canceled.

Name Link
🔨 Latest commit 0e3621a
🔍 Latest deploy log https://app.netlify.com/projects/viteplus-preview/deploys/6a3944f4ee9f4100085ba3b2

@jong-kyung

Copy link
Copy Markdown
Collaborator

@codex review

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

Copy link
Copy Markdown

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: bc12a3b7ea

ℹ️ 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/commands/env/list_remote.rs Outdated
@jong-kyung

Copy link
Copy Markdown
Collaborator

Could we add a snap test?

`vp env default lts`/`latest` stores the raw alias in config, so comparing
it directly against exact remote versions never matched and the `default`
marker (and JSON `default: true`) was never emitted. Resolve the stored
default via `resolve_version_alias` to a concrete version first.

Also add a global snap test that installs an LTS version, sets it as the
default via the `lts` alias, and asserts the installed/current/default
flags all resolve in `vp env list-remote --json`.
@semimikoh

Copy link
Copy Markdown
Contributor Author

@jong-kyung Added a command-env-list-remote snap test. It also doubles as a regression guard for the alias fix — without it, default marked would be false.

@jong-kyung

jong-kyung commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create an environment for this repo.

@jong-kyung

Copy link
Copy Markdown
Collaborator

@codex review

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

Copy link
Copy Markdown

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: 721927287a

ℹ️ 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 packages/cli/snap-tests-global/command-env-list-remote/steps.json
It writes the shared VP_HOME config via `vp env default`, matching the
existing default-mutating snap tests that run serially.
@semimikoh

Copy link
Copy Markdown
Contributor Author

Good catch — marked the snap case serial: true since it mutates the shared VP_HOME config via vp env default, matching the other default-mutating snap tests.

@jong-kyung jong-kyung left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It looks good to me 👍

> vp env default lts # Set it as the global default (stored as the `lts` alias)
✓ Default Node.js version set to lts (currently <semver>)

> vp env list-remote --lts --json | node -e "const {versions}=JSON.parse(require('fs').readFileSync(0,'utf8')); console.log('installed marked:', versions.some(v=>v.installed)); console.log('current marked:', versions.some(v=>v.current)); console.log('default marked:', versions.some(v=>v.default));" # installed/current/default flags should all resolve, including the `lts` default alias

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just need to execute the command vp env list-remote --lts --json, and the subsequent judgment logic code can be removed. We only need to ensure that the snapshot content is consistent.

@fengmk2 fengmk2 self-assigned this Jun 23, 2026
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.

3 participants