Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions crates/vite_install/src/commands/why.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ pub struct WhyCommandOptions<'a> {
pub dev: bool,
pub depth: Option<u32>,
pub no_optional: bool,
pub global: bool,
pub exclude_peers: bool,
pub find_by: Option<&'a str>,
pub pass_through_args: Option<&'a [String]>,
Expand Down Expand Up @@ -101,10 +100,6 @@ impl PackageManager {
args.push("--no-optional".into());
}

if options.global {
args.push("--global".into());
}

if options.exclude_peers {
args.push("--exclude-peers".into());
}
Expand Down
7 changes: 1 addition & 6 deletions crates/vite_pm_cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,10 +425,6 @@ pub enum PackageManagerCommand {
#[arg(long)]
no_optional: bool,

/// Check globally installed packages
#[arg(short = 'g', long)]
global: bool,

/// Exclude peer dependencies
#[arg(long)]
exclude_peers: bool,
Comment thread
liangmiQwQ marked this conversation as resolved.
Expand Down Expand Up @@ -529,8 +525,7 @@ impl PackageManagerCommand {
/// Whether this invocation hits the vite-plus-managed-global flow on the
/// global CLI. The local CLI binding refuses these cases (it has no
/// managed package store of its own); pass-through `-g` cases like
/// `outdated -g`, `why -g`, and `pm config get -g` return `false` and
/// keep working on both CLIs.
/// `pm config get -g` return `false` and keep working on both CLIs.
pub fn is_managed_global(&self) -> bool {
match self {
Self::Install { global, .. }
Expand Down
2 changes: 0 additions & 2 deletions crates/vite_pm_cli/src/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,6 @@ pub async fn dispatch(
dev,
depth,
no_optional,
global,
exclude_peers,
find_by,
pass_through_args,
Expand All @@ -269,7 +268,6 @@ pub async fn dispatch(
dev,
depth,
no_optional,
global,
exclude_peers,
find_by: find_by.as_deref(),
pass_through_args: pass_through_args.as_deref(),
Expand Down
11 changes: 2 additions & 9 deletions crates/vite_pm_cli/src/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,7 @@ use vite_path::AbsolutePath;
use crate::{
cli::{ConfigCommands, DistTagCommands, OwnerCommands, PmCommands, TokenCommands},
error::Error,
helpers::{
build_package_manager, build_package_manager_or_npm_default, default_npm_package_manager,
ensure_package_json,
},
helpers::{build_package_manager, build_package_manager_or_npm_default, ensure_package_json},
};

pub async fn run_add(
Expand Down Expand Up @@ -104,11 +101,7 @@ pub async fn run_why(
cwd: &AbsolutePath,
options: &WhyCommandOptions<'_>,
) -> Result<ExitStatus, Error> {
let pm = if options.global {
default_npm_package_manager(cwd)
} else {
build_package_manager(cwd).await?
};
let pm = build_package_manager(cwd).await?;
Ok(pm.run_why_command(options, cwd).await?)
}

Expand Down
1 change: 0 additions & 1 deletion packages/cli/snap-tests-global/cli-helper-message/snap.txt
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,6 @@ Options:
-D, --dev Only dev dependencies
--depth <DEPTH> Limit tree depth
--no-optional Exclude optional dependencies
-g, --global Check globally installed packages
--exclude-peers Exclude peer dependencies
--find-by <FINDER_NAME> Use a finder function defined in .pnpmfile.cjs
-h, --help Print help
Expand Down
1 change: 0 additions & 1 deletion packages/cli/snap-tests-global/command-why-bun/snap.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ Options:
-D, --dev Only dev dependencies
--depth <DEPTH> Limit tree depth
--no-optional Exclude optional dependencies
-g, --global Check globally installed packages
--exclude-peers Exclude peer dependencies
--find-by <FINDER_NAME> Use a finder function defined in .pnpmfile.cjs
-h, --help Print help
Expand Down
1 change: 0 additions & 1 deletion packages/cli/snap-tests-global/command-why-pnpm10/snap.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ Options:
-D, --dev Only dev dependencies
--depth <DEPTH> Limit tree depth
--no-optional Exclude optional dependencies
-g, --global Check globally installed packages
--exclude-peers Exclude peer dependencies
--find-by <FINDER_NAME> Use a finder function defined in .pnpmfile.cjs
-h, --help Print help
Expand Down
1 change: 0 additions & 1 deletion packages/cli/snap-tests-global/command-why-pnpm11/snap.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ Options:
-D, --dev Only dev dependencies
--depth <DEPTH> Limit tree depth
--no-optional Exclude optional dependencies
-g, --global Check globally installed packages
--exclude-peers Exclude peer dependencies
--find-by <FINDER_NAME> Use a finder function defined in .pnpmfile.cjs
-h, --help Print help
Expand Down
10 changes: 0 additions & 10 deletions packages/cli/snap-tests/command-pm-no-package-json/snap.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,3 @@ No package.json found.

[1]> vp why lodash # should show friendly error
No package.json found.

[1]> vp why definitely-not-installed-vite-plus-snap-pkg -g --json # should not require package.json for global why
npm error No dependencies found matching definitely-not-installed-vite-plus-snap-pkg
{
"error": {
"summary": "No dependencies found matching definitely-not-installed-vite-plus-snap-pkg",
"detail": ""
}
}
npm error A complete log of this run can be found in: <homedir>/.npm/_logs/<timestamp>-debug.log
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"vp pm ls # should show friendly error",
"vp pm prune # should show friendly error",
"vp outdated # should show friendly error",
"vp why lodash # should show friendly error",
"vp why definitely-not-installed-vite-plus-snap-pkg -g --json # should not require package.json for global why"
"vp why lodash # should show friendly error"
]
}
1 change: 0 additions & 1 deletion packages/cli/snap-tests/command-why-pnpm10/snap.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ Options:
-D, --dev Only dev dependencies
--depth <DEPTH> Limit tree depth
--no-optional Exclude optional dependencies
-g, --global Check globally installed packages
--exclude-peers Exclude peer dependencies
--find-by <FINDER_NAME> Use a finder function defined in .pnpmfile.cjs
-h, --help Print help
Expand Down
22 changes: 1 addition & 21 deletions rfcs/why-package-command.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,22 +101,11 @@ vp why react --no-optional # Exclude optional dependencies
# Depth control
vp why react --depth 3 # Limit tree depth to 3 levels

# Global packages
vp why typescript -g # Check globally installed packages

# Custom finder (pnpm only)
vp why react --find-by myFinder # Use finder function from .pnpmfile.cjs
```

### Global Packages Checking

Only use `npm` to check globally installed packages, because `vp install -g` uses `npm` cli to install global packages.

```bash
vp why typescript -g # Check globally installed packages

-> npm why typescript -g
```
We do not provide `why` feature for global packages managed by Vite+.

### Command Mapping

Expand Down Expand Up @@ -151,7 +140,6 @@ vp why typescript -g # Check globally installed packages
| `-D, --dev` | `-D, --dev` | N/A | N/A | N/A | N/A | Only dev dependencies (pnpm only) |
| `--depth <number>` | `--depth <number>` | N/A | N/A | N/A | `--depth` | Limit tree depth (pnpm/bun) |
| `--no-optional` | `--no-optional` | N/A | `--ignore-optional` | N/A | N/A | Exclude optional dependencies (pnpm only) |
| `-g, --global` | `-g, --global` | N/A | N/A | N/A | N/A | Check globally installed packages |
| `--exclude-peers` | `--exclude-peers` | N/A | N/A | Removes `--peers` flag | N/A | Exclude peer dependencies (yarn@2+ defaults to including peers) |
| `--find-by <finder_name>` | `--find-by <finder_name>` | N/A | N/A | N/A | N/A | Use finder function from .pnpmfile.cjs |

Expand Down Expand Up @@ -181,7 +169,6 @@ vp why typescript -g # Check globally installed packages
- Supports workspace filtering with `--filter`
- Can filter by dependency type (prod, dev, optional)
- Supports depth limiting
- Can check global packages with `-g`

**Output format:**

Expand Down Expand Up @@ -469,10 +456,6 @@ impl PackageManager {
args.push("--no-optional".into());
}

if options.global {
args.push("--global".into());
}

if options.exclude_peers {
args.push("--exclude-peers".into());
}
Expand Down Expand Up @@ -1122,7 +1105,6 @@ Options:
-D, --dev Only dev dependencies (pnpm-specific)
--depth <NUMBER> Limit tree depth (pnpm-specific)
--no-optional Exclude optional dependencies (pnpm-specific)
-g, --global Check globally installed packages
--exclude-peers Exclude peer dependencies (pnpm/yarn@2+-specific)
--find-by <FINDER_NAME> Use a finder function defined in .pnpmfile.cjs (pnpm-specific)
-h, --help Print help
Expand All @@ -1143,7 +1125,6 @@ Examples:
vp why react --filter app # Check in specific workspace (pnpm)
vp why react --prod # Only production deps (pnpm)
vp why react --depth 3 # Limit tree depth (pnpm)
vp why typescript -g # Check global packages
vp why react --find-by myFinder # Use custom finder (pnpm)
```

Expand Down Expand Up @@ -1268,7 +1249,6 @@ vp why package --prod --json
| Workspace filter | ✅ `--filter` | ✅ `--workspace` | ❌ Not supported | ❌ Not supported | ❌ Not supported | pnpm and npm |
| Dep type filter | ✅ `--prod/--dev` | ❌ Not supported | ❌ Not supported | ❌ Not supported | ❌ Not supported | pnpm only |
| Depth limit | ✅ `--depth` | ❌ Not supported | ❌ Not supported | ❌ Not supported | ✅ `--depth` | pnpm and bun |
| Global check | ✅ `-g` | ❌ Not supported | ❌ Not supported | ❌ Not supported | ❌ Not supported | pnpm only |
| Tree view | ❌ Not supported | ❌ Not supported | ❌ Not supported | ❌ Not supported | ✅ Built-in | bun shows tree view |

## Future Enhancements
Expand Down
Loading