Skip to content

Commit e440f0d

Browse files
committed
docs(rfcs): record the vp_global_only_cli crate
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.
1 parent 870527f commit e440f0d

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

rfcs/global-cli-rust-binary.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ impl JsExecutor {
405405

406406
- `crates/vp_global_cli/Cargo.toml`
407407
- `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
409409
- `crates/vp_global_cli/src/commands/mod.rs`
410410
- `crates/vp_global_cli/src/commands/new.rs` # Project scaffolding
411411
- `crates/vp_global_cli/src/commands/migrate.rs` # Migration command

rfcs/merge-global-and-local-cli.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ This decouples the `vp` binary from vite-plus's internal file layout.
108108

109109
### Command Routing
110110

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

113113
```
114114
vp <command>
@@ -160,7 +160,9 @@ The Rust `vp` binary (`crates/vp_global_cli/`) routes commands in two categories
160160
```
161161

162162
- **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.
164166

165167
### Global scripts_dir Resolution (Rust)
166168

@@ -275,6 +277,10 @@ if (command === 'create') {
275277
- Deleted per-command modules `crates/vp_global_cli/src/commands/{add,remove,install,update,dedupe,outdated,why,link,unlink,dlx,pm}.rs`.
276278
- Mirrored one representative pnpm10 fixture per command into `packages/cli/snap-tests/` to lock in parity.
277279

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+
278284
## Verification
279285

280286
- `cargo test -p vp_global_cli` — Rust unit tests pass

0 commit comments

Comments
 (0)