Skip to content

Commit 3af4839

Browse files
committed
refactor: remove PM fallback from vp run, always delegate to vite-plus
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 8616f4e commit 3af4839

File tree

12 files changed

+26
-667
lines changed

12 files changed

+26
-667
lines changed

crates/vite_global_cli/src/cli.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1929,7 +1929,7 @@ pub async fn run_command_with_options(
19291929
return Ok(ExitStatus::default());
19301930
}
19311931
print_runtime_header(render_options.show_header);
1932-
commands::run_or_delegate::execute(cwd, &args).await
1932+
commands::delegate::execute(cwd, "run", &args).await
19331933
}
19341934

19351935
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: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,15 @@ Filter Patterns:
3131
Documentation: https://viteplus.dev/guide/run
3232

3333

34-
> vpr hello # should fall back to pnpm run when no vite-plus dependency
35-
36-
> command-vpr@<semver> hello <cwd>
37-
> echo hello from script
38-
34+
> vpr hello # should execute via global vite-plus task runner
35+
$ echo hello from script ⊘ cache disabled
3936
hello from script
4037

41-
> vpr greet --arg1 value1 # should pass through args to pnpm run
42-
43-
> command-vpr@<semver> greet <cwd>
44-
> echo greet --arg1 value1
4538

39+
> vpr greet --arg1 value1 # should pass through args
40+
$ echo greet --arg1 value1 ⊘ cache disabled
4641
greet --arg1 value1
4742

48-
[1]> vpr nonexistent # should show pnpm missing script error
49-
 ERR_PNPM_NO_SCRIPT  Missing script: nonexistent
5043

51-
Command "nonexistent" not found.
44+
[1]> vpr nonexistent # should show task not found error
45+
Task "nonexistent" not found.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"commands": [
33
"vpr -h # should show vp run help",
4-
"vpr hello # should fall back to pnpm run when no vite-plus dependency",
5-
"vpr greet --arg1 value1 # should pass through args to pnpm run",
6-
"vpr nonexistent # should show pnpm missing script error"
4+
"vpr hello # should execute via global vite-plus task runner",
5+
"vpr greet --arg1 value1 # should pass through args",
6+
"vpr nonexistent # should show task not found error"
77
]
88
}

0 commit comments

Comments
 (0)