Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ name = "toolchain_json"
vp = "global"
steps = [
{ argv = ["vp", "toolchain", "vite", "--json", "--global"], tty = false, comment = "JSON contains one node per ID and no CLI header" },
{ argv = ["vp", "toolchain", "vite", "--json", "-g"], tty = false, comment = "the short global flag supports filters and JSON output" },
]

[[case]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,110 @@ JSON contains one node per ID and no CLI header
]
}
```

## `vp toolchain vite --json -g`

the short global flag supports filters and JSON output

```
{
"schemaVersion": 1,
"source": {
"scope": "global",
"path": "<home>/.vite-plus/current/node_modules/vite-plus",
"vitePlusVersion": "<version>"
},
"nodes": [
{
"id": "vite-plus",
"name": "vite-plus",
"version": "<version>",
"kind": "package",
"delivery": [
"dependency"
],
"aliases": []
},
{
"id": "vite-plus-core",
"name": "@voidzero-dev/vite-plus-core",
"version": "<version>",
"kind": "package",
"delivery": [
"dependency"
],
"aliases": [
"vite-plus-core"
]
},
{
"id": "vite",
"name": "vite",
"version": "<version>",
"kind": "tool",
"delivery": [
"bundled"
],
"aliases": []
},
{
"id": "rolldown",
"name": "rolldown",
"version": "<version>",
"kind": "tool",
"delivery": [
"bundled",
"compiled"
],
"aliases": []
},
{
"id": "oxc",
"name": "oxc",
"version": "<version>",
"kind": "engine",
"delivery": [
"compiled"
],
"aliases": []
},
{
"id": "oxc-resolver",
"name": "oxc-resolver",
"version": "<version>",
"kind": "engine",
"delivery": [
"compiled"
],
"aliases": []
}
],
"edges": [
{
"from": "vite-plus",
"to": "vite-plus-core",
"relationship": "depends-on"
},
{
"from": "vite-plus-core",
"to": "vite",
"relationship": "bundles"
},
{
"from": "vite",
"to": "rolldown",
"relationship": "uses"
},
{
"from": "rolldown",
"to": "oxc",
"relationship": "compiles"
},
{
"from": "rolldown",
"to": "oxc-resolver",
"relationship": "compiles"
}
]
}
```
16 changes: 15 additions & 1 deletion crates/vp_global_cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ pub enum Commands {
json: bool,

/// Use the global Vite+ toolchain
#[arg(long)]
#[arg(short = 'g', long)]
global: bool,
},

Expand Down Expand Up @@ -1344,6 +1344,20 @@ mod tests {
assert_eq!(raw_subcommand(&argv(&["vp", "--version"])), None);
}

#[test]
fn parses_toolchain_global_flags() {
for flag in ["--global", "-g"] {
let parsed = try_parse_args_from(argv(&["vp", "toolchain", "vite", "--json", flag]))
.expect("toolchain global flag should parse");
let Some(Commands::Toolchain { tools, json, global }) = parsed.command else {
panic!("expected toolchain command");
};
assert_eq!(tools, vec!["vite"]);
assert!(json);
assert!(global);
}
}

#[test]
fn parses_sync_versions_as_machine_readable_global_command() {
let parsed = try_parse_args_from(argv(&["vp", "sync-versions", "--json"]))
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ vp toolchain vite rolldown oxc
vp toolchain --json
```

The command uses the local `vite-plus` package when the project has one. Use `--global` to show the release for the global `vp` command:
The command uses the local `vite-plus` package when the project has one. Use `--global` or `-g` to show the release for the global `vp` command:

```bash
vp toolchain --global
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/binding/src/cli/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ pub struct ToolchainArgs {
pub json: bool,

/// Use the global Vite+ toolchain
#[arg(long)]
#[arg(short = 'g', long)]
pub global: bool,
}

Expand Down
2 changes: 1 addition & 1 deletion rfcs/toolchain-command.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ Arguments:

Options:
--json Print the graph as JSON
--global Use the global Vite+ toolchain
-g, --global Use the global Vite+ toolchain
-h, --help Print help
```

Expand Down
Loading