Skip to content

Commit c682cb1

Browse files
committed
refactor: remove PM fallback from vp run, always delegate to vite-plus (#1179)
The `run_or_delegate` module previously fell back to `<pm> run <script>` when vite-plus was not a project dependency. This is no longer needed because the global CLI ships with its own vite-plus installation, and `delegate::execute()` already resolves local vite-plus first then falls back to the global one. Now `vp run` and `vpr` always delegate through the vite-plus task runner, regardless of whether the project has vite-plus as a dependency. Closes #1132
1 parent acee8b6 commit c682cb1

11 files changed

Lines changed: 22 additions & 663 deletions

File tree

crates/vite_global_cli/src/cli.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2041,7 +2041,7 @@ pub async fn run_command_with_options(
20412041
return Ok(ExitStatus::default());
20422042
}
20432043
print_runtime_header(render_options.show_header);
2044-
commands::run_or_delegate::execute(cwd, &args).await
2044+
commands::delegate::execute(cwd, "run", &args).await
20452045
}
20462046

20472047
Commands::Exec { args } => {

crates/vite_global_cli/src/commands/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ pub mod upgrade;
182182

183183
// Category C: Local CLI Delegation
184184
pub mod delegate;
185-
pub mod run_or_delegate;
186185

187186
// Re-export command structs for convenient access
188187
pub use add::AddCommand;

crates/vite_global_cli/src/commands/run_or_delegate.rs

Lines changed: 0 additions & 23 deletions
This file was deleted.

crates/vite_global_cli/src/commands/vpr.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
//! `vpr` command implementation.
22
//!
3-
//! Standalone shorthand for `vp run`. Executes tasks via the same
4-
//! run-or-delegate logic: delegates to local vite-plus CLI when
5-
//! vite-plus is a dependency, otherwise falls back to `<pm> run`.
3+
//! Standalone shorthand for `vp run`. Delegates to the local or global
4+
//! vite-plus CLI to execute tasks.
65
76
use vite_path::AbsolutePath;
87
use vite_shared::output;
@@ -16,7 +15,7 @@ pub async fn execute_vpr(args: &[String], cwd: &AbsolutePath) -> i32 {
1615
}
1716

1817
let cwd_buf = cwd.to_absolute_path_buf();
19-
match super::run_or_delegate::execute(cwd_buf, args).await {
18+
match super::delegate::execute(cwd_buf, "run", args).await {
2019
Ok(status) => status.code().unwrap_or(1),
2120
Err(e) => {
2221
output::error(&e.to_string());

crates/vite_install/src/commands/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ pub mod prune;
2020
pub mod publish;
2121
pub mod rebuild;
2222
pub mod remove;
23-
pub mod run;
2423
pub mod search;
2524
pub mod token;
2625
pub mod unlink;

crates/vite_install/src/commands/run.rs

Lines changed: 0 additions & 117 deletions
This file was deleted.
Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,18 @@
1-
> vp run hello # should fall back to pnpm run when no vite-plus dependency
1+
> vp run hello # should execute via global vite-plus task runner
22
VITE+ - The Unified Toolchain for the Web
33

4-
5-
> command-run-without-vite-plus@<semver> hello <cwd>
6-
> echo hello from script
7-
4+
$ echo hello from script ⊘ cache disabled
85
hello from script
96

10-
> vp run greet --arg1 value1 # should pass through args to pnpm run
11-
VITE+ - The Unified Toolchain for the Web
12-
137

14-
> command-run-without-vite-plus@<semver> greet <cwd>
15-
> echo greet --arg1 value1
8+
> vp run greet --arg1 value1 # should pass through args
9+
VITE+ - The Unified Toolchain for the Web
1610

11+
$ echo greet --arg1 value1 ⊘ cache disabled
1712
greet --arg1 value1
1813

19-
[1]> vp run nonexistent # should show pnpm missing script error
20-
VITE+ - The Unified Toolchain for the Web
2114

22-
 ERR_PNPM_NO_SCRIPT  Missing script: nonexistent
15+
[1]> vp run nonexistent # should show task not found error
16+
VITE+ - The Unified Toolchain for the Web
2317

24-
Command "nonexistent" not found.
18+
Task "nonexistent" not found.
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
{
2-
"ignoredPlatforms": ["win32"],
32
"commands": [
4-
"vp run hello # should fall back to pnpm run when no vite-plus dependency",
5-
"vp run greet --arg1 value1 # should pass through args to pnpm run",
6-
"vp run nonexistent # should show pnpm missing script error"
3+
"vp run hello # should execute via global vite-plus task runner",
4+
"vp run greet --arg1 value1 # should pass through args",
5+
"vp run nonexistent # should show task not found error"
76
]
87
}

packages/cli/snap-tests-global/command-vpr/snap.txt

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,18 @@ Documentation: https://viteplus.dev/guide/run
3232

3333

3434
> vpr hello # should run script via vpr shorthand
35-
36-
> command-vpr@<semver> hello <cwd>
37-
> node args.mjs hello from script
38-
35+
$ node args.mjs hello from script ⊘ cache disabled
3936
hello
4037
from
4138
script
4239

43-
> vpr greet --arg1 value1 # should pass through additional args
44-
45-
> command-vpr@<semver> greet <cwd>
46-
> node args.mjs greet --arg1 value1
4740

41+
> vpr greet --arg1 value1 # should pass through additional args
42+
$ node args.mjs greet --arg1 value1 ⊘ cache disabled
4843
greet
4944
--arg1
5045
value1
5146

52-
[1]> vpr nonexistent # should show pnpm missing script error
53-
 ERR_PNPM_NO_SCRIPT  Missing script: nonexistent
5447

55-
Command "nonexistent" not found.
48+
[1]> vpr nonexistent # should show pnpm missing script error
49+
Task "nonexistent" not found.

packages/cli/snap-tests-global/delegate-respects-default-node-version/snap.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@ VITE+ - The Unified Toolchain for the Web
66
> vp run check-node # Should also use 22.12.0
77
VITE+ - The Unified Toolchain for the Web
88

9-
10-
> delegate-respects-default-node-version@<semver> check-node <cwd>
11-
> node -e "console.log(process.version)"
12-
9+
$ node -e "console.log(process.version)" ⊘ cache disabled
1310
v<semver>
1411

12+
1513
> vp exec node -e "console.log(process.version)" # Should also use 22.12.0
1614
VITE+ - The Unified Toolchain for the Web
1715

0 commit comments

Comments
 (0)