Skip to content

Commit c6365b3

Browse files
committed
feat(env): add vp env list (local) and rename old list to vp env list-remote
- `vp env list` (alias `ls`): lists locally installed Node.js versions with current/default markers, fnm-style `* v{version}` format - `vp env list-remote` (alias `ls-remote`): lists remote versions from registry with fnm-style output (v{version} per line, LTS in bright blue) - Add `--sort asc|desc` flag to list-remote (default: asc) - Add `SortingMethod` enum to CLI args
1 parent 0469fb8 commit c6365b3

11 files changed

Lines changed: 524 additions & 362 deletions

File tree

.github/workflows/ci.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,12 @@ jobs:
254254
}
255255
Write-Host "tsc shim removed successfully"
256256
257+
# Test 5: use session
258+
vp env use 18
259+
node --version
260+
vp env use --unset
261+
node --version
262+
257263
- name: Test global package install (cmd)
258264
if: ${{ matrix.os == 'windows-latest' }}
259265
shell: cmd
@@ -292,6 +298,12 @@ jobs:
292298
)
293299
echo tsc shell script removed successfully
294300
301+
:: Test 6: use session
302+
vp env use 18
303+
node --version
304+
vp env use --unset
305+
node --version
306+
295307
- name: Test global package install (bash)
296308
run: |
297309
echo "PATH: $PATH"
@@ -323,6 +335,12 @@ jobs:
323335
fi
324336
echo "tsc shim removed successfully"
325337
338+
# Test 5: use session
339+
vp env use 18
340+
node --version
341+
vp env use --unset
342+
node --version
343+
326344
- name: Install Playwright browsers
327345
run: pnpx playwright install chromium
328346

crates/vite_global_cli/src/cli.rs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,8 +670,17 @@ pub enum EnvSubcommands {
670670
/// Remove the .node-version file from current directory (alias for `pin --unpin`)
671671
Unpin,
672672

673-
/// List available Node.js versions
673+
/// List locally installed Node.js versions
674+
#[command(alias = "ls")]
674675
List {
676+
/// Output as JSON
677+
#[arg(long)]
678+
json: bool,
679+
},
680+
681+
/// List available Node.js versions from the registry
682+
#[command(name = "list-remote", alias = "ls-remote")]
683+
ListRemote {
675684
/// Filter versions by pattern (e.g., "20" for 20.x versions)
676685
pattern: Option<String>,
677686

@@ -686,6 +695,10 @@ pub enum EnvSubcommands {
686695
/// Output as JSON
687696
#[arg(long)]
688697
json: bool,
698+
699+
/// Version sorting order
700+
#[arg(long, value_enum, default_value_t = SortingMethod::Asc)]
701+
sort: SortingMethod,
689702
},
690703

691704
/// Run a command with a specific Node.js version
@@ -748,6 +761,16 @@ pub enum EnvSubcommands {
748761
},
749762
}
750763

764+
/// Version sorting order for list-remote command
765+
#[derive(clap::ValueEnum, Clone, Debug, Default)]
766+
pub enum SortingMethod {
767+
/// Sort versions in ascending order (earliest to latest)
768+
#[default]
769+
Asc,
770+
/// Sort versions in descending order (latest to earliest)
771+
Desc,
772+
}
773+
751774
/// Package manager subcommands
752775
#[derive(Subcommand, Debug, Clone)]
753776
pub enum PmCommands {

0 commit comments

Comments
 (0)