Analysis
Understanding the issue: The request is for a top-level vp rebuild command as a convenience shortcut for npm rebuild / pnpm rebuild, which is needed for rebuilding native Node.js addons against the current Node version.
Current state: vp pm rebuild (with alias vp pm rb) already exists and is fully implemented in crates/vite_install/src/commands/rebuild.rs. It supports npm, pnpm, and warns gracefully for yarn v1 (which doesn't support rebuild). The underlying RebuildCommandOptions and run_rebuild_command are complete.
Relevant files:
crates/vite_global_cli/src/main.rs — normalize_args() function handles vp list → vp pm list aliasing
crates/vite_global_cli/src/cli.rs — PmCommands::Rebuild (line 1212–1218), top-level Commands enum
crates/vite_install/src/commands/rebuild.rs — Core implementation
crates/vite_global_cli/src/commands/pm.rs — PmCommands::Rebuild handler
Verdict: Yes, fixable — low complexity
The implementation is already done at the vp pm rebuild level. Adding vp rebuild is a matter of wiring the top-level shortcut.
Implementation plan
Option A (preferred — consistent with existing vp list pattern): Extend normalize_args() in crates/vite_global_cli/src/main.rs to map vp rebuild / vp rb → vp pm rebuild:
Some("rebuild" | "rb") => {
let mut normalized = Vec::with_capacity(args.len() + 1);
normalized.push(args[0].clone());
normalized.push("pm".to_string());
normalized.push("rebuild".to_string());
normalized.extend(args[2..].iter().cloned());
normalized
}
Option B (alternative): Add a dedicated Commands::Rebuild variant to the top-level Commands enum in cli.rs, with a handler that calls commands::pm::run(cwd, PmCommands::Rebuild { ... }) directly — more explicit but slightly more code.
Option A is simpler, consistent with how vp list is handled, and requires changes to only one function.
Potential concerns
rb is already a visible_alias on vp pm rebuild — using it as a top-level alias via normalization would shadow it cleanly, but worth verifying there's no conflict.
- Yarn v1 already has a graceful warning in the existing implementation, so that edge case is handled.