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
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ vp = "global"
cwd = "yarn"
steps = [
{ argv = ["vp", "dedupe", "--", "--silent"], comment = "Yarn Classic falls back to install because install already deduplicates dependencies" },
{ argv = ["vp", "dedupe", "--check", "--", "--silent"], comment = "warns about unsupported --check and still falls back to install" },
{ argv = ["vpt", "print-file", "package.json"], comment = "verify Yarn Classic completed" },
]

Expand All @@ -41,6 +42,7 @@ vp = "global"
cwd = "bun"
steps = [
{ argv = ["vp", "dedupe", "--", "--silent"], comment = "Bun falls back to install because it does not support dedupe" },
{ argv = ["vp", "dedupe", "--check", "--", "--silent"], comment = "warns about unsupported --check and still falls back to install" },
{ argv = ["vpt", "print-file", "package.json"], comment = "verify Bun completed" },
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ Bun falls back to install because it does not support dedupe
warn: bun dedupe requires bun >= 1.4, falling back to bun install
```

## `vp dedupe --check -- --silent`

warns about unsupported --check and still falls back to install

```
warn: bun <1.4 does not support --check.
warn: bun dedupe requires bun >= 1.4, falling back to bun install
```

## `vpt print-file package.json`

verify Bun completed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ Yarn Classic falls back to install because install already deduplicates dependen
warn: Yarn Classic dedupes during install, falling back to yarn install
```

## `vp dedupe --check -- --silent`

warns about unsupported --check and still falls back to install

```
warn: yarn <2 does not support --check.
warn: Yarn Classic dedupes during install, falling back to yarn install
```

## `vpt print-file package.json`

verify Yarn Classic completed
Expand Down
30 changes: 26 additions & 4 deletions crates/vp_pm_cli/src/resolution/commands/dedupe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::resolution::{
#[derive(clap::Args, Clone, Debug, Default, PartialEq, Eq)]
pub struct DedupeArgs {
/// Check if deduplication would make changes
#[arg(long)]
#[arg(long, not_supported(yarn < "2", bun < "1.4"))]
Comment thread
fengmk2 marked this conversation as resolved.
pub(crate) check: bool,

/// Additional arguments to pass through to the package manager
Expand Down Expand Up @@ -126,6 +126,7 @@ mod tests {

assert_eq!(command.program, "yarn");
assert_eq!(command.args, vec!["dedupe", "--check"]);
assert!(resolution.diagnostics.is_empty());
}

#[test]
Expand All @@ -135,12 +136,14 @@ mod tests {

assert_eq!(command.program, "yarn");
assert_eq!(command.args, vec!["install"]);
assert_eq!(resolution.diagnostics.len(), 1);
assert_eq!(resolution.diagnostics.len(), 2);
assert_eq!(resolution.diagnostics[0].message, "yarn <2 does not support --check.");
assert_eq!(resolution.diagnostics[0].kind, DiagnosticKind::UnsupportedOptionDropped);
assert_eq!(
resolution.diagnostics[0].message,
resolution.diagnostics[1].message,
"Yarn Classic dedupes during install, falling back to yarn install"
);
assert_eq!(resolution.diagnostics[0].kind, DiagnosticKind::FallbackCommand);
assert_eq!(resolution.diagnostics[1].kind, DiagnosticKind::FallbackCommand);
}

#[test]
Expand All @@ -158,6 +161,24 @@ mod tests {
assert_eq!(resolution.diagnostics[0].kind, DiagnosticKind::FallbackCommand);
}

#[test]
fn test_bun_dedupe_check_warns_and_falls_back_to_install() {
let resolution = resolve(&bun("1.3.11"), DedupeArgs { check: true, ..Default::default() });
let command = expect_run(resolution.outcome);

assert_eq!(command.program, "bun");
assert_eq!(command.args, vec!["install"]);
let messages =
resolution.diagnostics.iter().map(|entry| entry.message.as_str()).collect::<Vec<_>>();
assert_eq!(
messages,
vec![
"bun <1.4 does not support --check.",
"bun dedupe requires bun >= 1.4, falling back to bun install"
]
);
}

#[test]
fn test_bun_dedupe_basic() {
let resolution = resolve(&bun("1.4.0"), DedupeArgs::default());
Expand All @@ -175,6 +196,7 @@ mod tests {

assert_eq!(command.program, "bun");
assert_eq!(command.args, vec!["dedupe", "--check"]);
assert!(resolution.diagnostics.is_empty());
}

#[test]
Expand Down
Loading