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
Copy file name to clipboardExpand all lines: rfcs/merge-global-and-local-cli.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -162,7 +162,7 @@ The Rust `vp` binary (`crates/vp_global_cli/`) routes commands in four categorie
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
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
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_commands/` 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 local CLI binding does not flatten it; it calls `vp_global_commands::is_global_only(name)` (derived from the same enum via clap, so there is no separate list) to recognise these names and point users at the global binary.
165
+
-**Category D (Global-only)**: `env`, `upgrade`, `implode` — clap definitions live in the shared `crates/vp_global_commands/` 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.
166
166
167
167
### Global scripts_dir Resolution (Rust)
168
168
@@ -279,7 +279,7 @@ if (command === 'create') {
279
279
280
280
12.**Extracted global-only commands into a shared `vp_global_commands` crate**:
281
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_commands/` 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 the local CLI binding can recognise global-only command names without maintaining its own list that could drift from the global surface.
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.
0 commit comments