You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Document the shared global-only command crate next to the existing
vp_pm_cli notes in merge-global-and-local-cli.md, align the command
category letters with cli.rs, and update the file map in
global-cli-rust-binary.md.
Copy file name to clipboardExpand all lines: rfcs/global-cli-rust-binary.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -405,7 +405,7 @@ impl JsExecutor {
405
405
406
406
-`crates/vp_global_cli/Cargo.toml`
407
407
-`crates/vp_global_cli/src/main.rs`
408
-
-`crates/vp_global_cli/src/cli.rs` # Top-level clap parser; flattens `vp_pm_cli::PackageManagerCommand` for all PM subcommands and intercepts `--global` for managed installs
408
+
-`crates/vp_global_cli/src/cli.rs` # Top-level clap parser; flattens `vp_pm_cli::PackageManagerCommand` for all PM subcommands and `vp_global_only_cli::GlobalOnlyCommand` for `env`/`upgrade`/`implode`, and intercepts `--global` for managed installs
Copy file name to clipboardExpand all lines: rfcs/merge-global-and-local-cli.md
+8-2Lines changed: 8 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -108,7 +108,7 @@ This decouples the `vp` binary from vite-plus's internal file layout.
108
108
109
109
### Command Routing
110
110
111
-
The Rust `vp` binary (`crates/vp_global_cli/`) routes commands in two categories:
111
+
The Rust `vp` binary (`crates/vp_global_cli/`) routes commands in four categories:
112
112
113
113
```
114
114
vp <command>
@@ -160,7 +160,9 @@ The Rust `vp` binary (`crates/vp_global_cli/`) routes commands in two categories
160
160
```
161
161
162
162
-**Category A (Package Manager)**: `install`, `add`, `remove`, `update`, `dedupe`, `outdated`, `why`, `info`, `link`, `unlink`, `dlx`, `pm <subcmd>` — clap definitions and dispatch live in the shared `crates/vp_pm_cli/` crate. Both the global CLI and the local CLI binding flatten `vp_pm_cli::PackageManagerCommand` into their top-level argument parser and call `vp_pm_cli::dispatch` to run the underlying package manager (pnpm/npm/yarn/bun). The global CLI additionally intercepts `--global` for vite-plus-managed installs (`commands::env::global_install`) before delegating.
163
-
-**Category B (JavaScript)**: All other commands (`build`, `test`, `lint`, `create`, `migrate`, `--version`, etc.) — Rust uses `oxc_resolver` to find the project's local `vite-plus/dist/bin.js` and runs it. Falls back to the global installation's `dist/bin.js` if no local installation exists. The unified `bin.ts` entry point then routes to either NAPI bindings (task commands and PM commands, the latter via `vp_pm_cli::dispatch`) or rolldown-bundled modules in `dist/global/` (create, migrate, version).
163
+
-**Category B (JavaScript)**: `create`, `migrate`, `config`, `hooks`, `staged`, `--version` — Rust uses `oxc_resolver` to find the project's local `vite-plus/dist/bin.js` and runs it. Falls back to the global installation's `dist/bin.js` if no local installation exists. The unified `bin.ts` entry point then routes to either NAPI bindings (task commands and PM commands, the latter via `vp_pm_cli::dispatch`) or rolldown-bundled modules in `dist/global/` (create, migrate, version).
164
+
-**Category C (Local CLI Delegation)**: `dev`, `build`, `test`, `lint`, `fmt`, `check`, `pack`, `run`, `exec`, `preview`, `cache` — forwarded to the project-local `vite-plus` CLI through `commands::delegate`, which resolves it the same way as Category B. `lint --init` and `fmt --init`/`--migrate` are forced to the global installation.
165
+
-**Category D (Global-only)**: `env`, `upgrade`, `implode` — clap definitions live in the shared `crates/vp_global_only_cli/` crate as `GlobalOnlyCommand`. The global CLI flattens it into its top-level argument parser and keeps the implementations in `crates/vp_global_cli/src/commands/`. The crate also exposes `is_global_only(name)`, derived from the same enum via clap, so other crates can recognise these names without a separate list.
- Mirrored one representative pnpm10 fixture per command into `packages/cli/snap-tests/` to lock in parity.
277
279
280
+
12.**Extracted global-only commands into a shared `vp_global_only_cli` crate**:
281
+
- Moved the `env`, `upgrade`, and `implode` clap definitions (plus `EnvArgs`, `EnvSubcommands`, `PinTarget`, `SortingMethod`) out of `crates/vp_global_cli/src/cli.rs` into `crates/vp_global_only_cli/` as `GlobalOnlyCommand`. The global CLI flattens it into `Commands` and re-exports the types so `commands/env/*` keep their import paths.
282
+
- Exposed `is_global_only(name)`, computed from the enum through clap's `augment_subcommands`, so command names can be recognised elsewhere without maintaining a list that could drift from the global surface.
283
+
278
284
## Verification
279
285
280
286
-`cargo test -p vp_global_cli` — Rust unit tests pass
0 commit comments