Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ steps = [
{ argv = ["vp", "outdated", "--format", "list"], comment = "should support list output", continue-on-failure = true },
{ argv = ["vp", "outdated", "--format", "table"], comment = "should support table output", continue-on-failure = true },
{ argv = ["vp", "outdated", "testnpm2", "--long"], comment = "should support --long", continue-on-failure = true },
{ argv = ["vp", "outdated", "-r"], comment = "should support recursive output", continue-on-failure = true },
{ argv = ["vp", "outdated", "-r"], comment = "should report that no workspaces are configured", continue-on-failure = true },
{ argv = ["vp", "outdated", "-P"], comment = "should support prod output", continue-on-failure = true },
{ argv = ["vp", "outdated", "-D"], envs = [["NODE_ENV", "production"]], comment = "include outdated dev dependencies in a production environment", continue-on-failure = true },
{ argv = ["vp", "outdated", "--no-optional"], comment = "should support no-optional output", continue-on-failure = true },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,13 @@ testnpm2 1.0.0 1.0.0 1.0.1 node_modules/testnpm2 workspace dependenc

## `vp outdated -r`

should support recursive output
should report that no workspaces are configured

**Exit code:** 1

```
Package Current Wanted Latest Location Depended by
test-vite-plus-other-optional 1.0.0 1.0.0 1.1.0 node_modules/test-vite-plus-other-optional workspace
test-vite-plus-top-package 1.0.0 1.0.0 1.1.0 node_modules/test-vite-plus-top-package workspace
testnpm2 1.0.0 1.0.0 1.0.1 node_modules/testnpm2 workspace
npm error No workspaces found!
npm error A complete log of this run can be found in: <home>/.npm/_logs/<timestamp>-debug-0.log
```

## `vp outdated -P`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ steps = [
{ argv = ["vp", "outdated", "testnpm2", "-w"], comment = "should outdated in workspace root", continue-on-failure = true },
{ argv = ["vp", "outdated", "testnpm2", "--filter", "app"], comment = "should outdated in specific package", continue-on-failure = true },
{ argv = ["vp", "outdated", "--filter", "*", "--format", "json"], comment = "should outdated in all packages", continue-on-failure = true },
{ argv = ["vp", "outdated", "-r"], comment = "should outdated recursively", continue-on-failure = true },
{ argv = ["vp", "outdated", "-r"], comment = "should check workspace dependencies without the root", continue-on-failure = true },
{ argv = ["vp", "outdated", "-r", "-w"], comment = "should check root and workspace dependencies", continue-on-failure = true },
{ argv = ["vp", "outdated", "-r", "--filter", "@vite-plus-test/utils"], comment = "should preserve workspace filtering", continue-on-failure = true },
]
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,18 @@ should outdated in all packages

## `vp outdated -r`

should outdated recursively
should check workspace dependencies without the root

**Exit code:** 1

```
Package Current Wanted Latest Location Depended by
test-vite-plus-other-optional 1.0.0 1.0.0 1.1.0 node_modules/test-vite-plus-other-optional app@
```

## `vp outdated -r -w`

should check root and workspace dependencies

**Exit code:** 1

Expand All @@ -57,3 +68,10 @@ Package Current Wanted Latest Location
test-vite-plus-other-optional 1.0.0 1.0.0 1.1.0 node_modules/test-vite-plus-other-optional app@
testnpm2 1.0.0 1.0.0 1.0.1 node_modules/testnpm2 workspace
```

## `vp outdated -r --filter @vite-plus-test/utils`

should preserve workspace filtering

```
```
39 changes: 32 additions & 7 deletions crates/vp_pm_cli/src/resolution/commands/outdated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub struct OutdatedArgs {
pub(crate) format: Option<OutdatedFormat>,

/// Check recursively across all workspaces
#[arg(short = 'r', long, not_supported(yarn))]
#[arg(short = 'r', long, not_supported(npm < "7.14.0", yarn))]
pub(crate) recursive: bool,

/// Filter packages in monorepo
Expand Down Expand Up @@ -145,7 +145,7 @@ impl Npm {
cmd.arg_if("--long", args.long)
.repeated("--workspace", args.filter.iter())
.arg_if("--include-workspace-root", args.workspace_root)
.arg_if("--all", args.recursive)
.arg_if("--workspaces", args.recursive && !args.workspace_root)
.extend(args.packages.iter());
cmd.arg_if("--omit=dev", args.prod)
.arg_if("--include=dev", args.dev)
Expand Down Expand Up @@ -366,12 +366,37 @@ mod tests {

#[test]
fn test_npm_outdated_recursive() {
let command = expect_run(
resolve(&npm("11.0.0"), OutdatedArgs { recursive: true, ..Default::default() }).outcome,
);
for version in ["7.14.0", "10.8.0", "11.0.0"] {
let args = parse_args::<OutdatedArgs>(["-r"]).unwrap();
let command = expect_run(resolve(&npm(version), args).outcome);

assert_eq!(command.program, "npm");
assert_eq!(command.args, vec!["outdated", "--all"]);
assert_eq!(command.program, "npm");
assert_eq!(command.args, vec!["outdated", "--workspaces"]);
}
}

#[test]
fn npm_outdated_recursive_rejects_unsupported_versions() {
for version in ["6.14.18", "7.13.0"] {
let args = parse_args::<OutdatedArgs>(["-r"]).unwrap();
expect_unsupported(
resolve(&npm(version), args),
&["npm < 7.14.0 does not support --recursive."],
);
}
}

#[test]
fn npm_outdated_recursive_preserves_workspace_options() {
for (flags, expected) in [
(vec!["-r", "-w"], vec!["outdated", "--include-workspace-root"]),
(vec!["-r", "--filter", "app"], vec!["outdated", "--workspace", "app", "--workspaces"]),
] {
let args = parse_args::<OutdatedArgs>(flags).unwrap();
let command = expect_run(resolve(&npm("11.0.0"), args).outcome);

assert_eq!(command.args, expected);
}
}

#[test]
Expand Down
Loading