From 4fe1c3e7f20651f63f5e2660c6b72844a934b468 Mon Sep 17 00:00:00 2001 From: JongKyung Lee Date: Wed, 16 Sep 2026 10:20:10 +0900 Subject: [PATCH] fix(pm): warn on unsupported dedupe check options Diagnose --check on Yarn Classic and Bun before 1.4 while preserving existing install fallbacks. Cover the warnings in resolver tests and CLI snapshots. --- .../fixtures/pm_dedupe/snapshots.toml | 2 ++ .../pm_dedupe/snapshots/pm_dedupe_bun.md | 9 ++++++ .../pm_dedupe/snapshots/pm_dedupe_yarn.md | 9 ++++++ .../src/resolution/commands/dedupe.rs | 30 ++++++++++++++++--- 4 files changed, 46 insertions(+), 4 deletions(-) diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/pm_dedupe/snapshots.toml b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/pm_dedupe/snapshots.toml index 0df76a16f2..4753663ea9 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/pm_dedupe/snapshots.toml +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/pm_dedupe/snapshots.toml @@ -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" }, ] @@ -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" }, ] diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/pm_dedupe/snapshots/pm_dedupe_bun.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/pm_dedupe/snapshots/pm_dedupe_bun.md index 2c6bc54184..e29fc26b1a 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/pm_dedupe/snapshots/pm_dedupe_bun.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/pm_dedupe/snapshots/pm_dedupe_bun.md @@ -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 diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/pm_dedupe/snapshots/pm_dedupe_yarn.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/pm_dedupe/snapshots/pm_dedupe_yarn.md index cab7b4208e..87c6561078 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/pm_dedupe/snapshots/pm_dedupe_yarn.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/pm_dedupe/snapshots/pm_dedupe_yarn.md @@ -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 diff --git a/crates/vp_pm_cli/src/resolution/commands/dedupe.rs b/crates/vp_pm_cli/src/resolution/commands/dedupe.rs index 4d31b3104e..7598f997cf 100644 --- a/crates/vp_pm_cli/src/resolution/commands/dedupe.rs +++ b/crates/vp_pm_cli/src/resolution/commands/dedupe.rs @@ -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"))] pub(crate) check: bool, /// Additional arguments to pass through to the package manager @@ -126,6 +126,7 @@ mod tests { assert_eq!(command.program, "yarn"); assert_eq!(command.args, vec!["dedupe", "--check"]); + assert!(resolution.diagnostics.is_empty()); } #[test] @@ -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] @@ -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::>(); + 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()); @@ -175,6 +196,7 @@ mod tests { assert_eq!(command.program, "bun"); assert_eq!(command.args, vec!["dedupe", "--check"]); + assert!(resolution.diagnostics.is_empty()); } #[test]