From 49291dbfd41c5b8a45d43de1854c28fbf792ca15 Mon Sep 17 00:00:00 2001 From: JongKyung Lee Date: Mon, 21 Sep 2026 11:51:37 +0900 Subject: [PATCH] fix(pm): warn about unsupported --no-save for yarn update --- .../command_update_yarn4/snapshots.toml | 2 +- .../snapshots/command_update_yarn4.md | 5 +++-- .../snapshots.toml | 2 +- .../command_update_yarn4_with_workspace.md | 3 ++- .../src/resolution/commands/update.rs | 18 +++++++++++++++++- 5 files changed, 24 insertions(+), 6 deletions(-) diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_update_yarn4/snapshots.toml b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_update_yarn4/snapshots.toml index b4a9f62937..ef7dd6182b 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_update_yarn4/snapshots.toml +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_update_yarn4/snapshots.toml @@ -3,7 +3,7 @@ name = "command_update_yarn4" vp = "global" skip-platforms = ["windows"] steps = [ - { argv = ["vp", "update", "testnpm2"], comment = "should update package within semver range" }, + { argv = ["vp", "update", "testnpm2", "--no-save"], comment = "warn that --no-save is unsupported and continue with yarn up" }, { argv = ["vpt", "print-file", "package.json"], continue-on-failure = true }, { argv = ["vp", "rm", "testnpm2"], comment = "should to absolute latest version" }, ["vp", "add", "testnpm2@1.0.0", "-D"], diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_update_yarn4/snapshots/command_update_yarn4.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_update_yarn4/snapshots/command_update_yarn4.md index f2720d8611..d230a72b11 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_update_yarn4/snapshots/command_update_yarn4.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_update_yarn4/snapshots/command_update_yarn4.md @@ -1,10 +1,11 @@ # command_update_yarn4 -## `vp update testnpm2` +## `vp update testnpm2 --no-save` -should update package within semver range +warn that --no-save is unsupported and continue with yarn up ``` +warn: yarn does not support --no-save. ➤ YN0000: · Yarn ➤ YN0000: ┌ Resolution step ➤ YN0085: │ + test-vite-plus-package-optional@npm:1.0.0, test-vite-plus-package@npm:1.0.0, testnpm2@npm:1.0.1 diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_update_yarn4_with_workspace/snapshots.toml b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_update_yarn4_with_workspace/snapshots.toml index f6b4b677b6..e097025206 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_update_yarn4_with_workspace/snapshots.toml +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_update_yarn4_with_workspace/snapshots.toml @@ -14,6 +14,6 @@ steps = [ ["vpt", "stat-file", "node_modules", "--assert", "missing"], { argv = ["vp", "update", "testnpm2"], comment = "unfiltered update still updates all testnpm2 versions" }, { argv = ["vpt", "print-file", "package.json", "packages/app/package.json", "packages/utils/package.json"], continue-on-failure = true }, - { argv = ["vp", "update", "-r", "--no-save"], comment = "unfiltered recursive update remains supported" }, + { argv = ["vp", "update", "-r", "--no-save"], comment = "warn that --no-save is unsupported while preserving recursive update" }, { argv = ["vpt", "print-file", "package.json", "packages/app/package.json"], continue-on-failure = true }, ] diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_update_yarn4_with_workspace/snapshots/command_update_yarn4_with_workspace.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_update_yarn4_with_workspace/snapshots/command_update_yarn4_with_workspace.md index ddecffc904..442d2408e9 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_update_yarn4_with_workspace/snapshots/command_update_yarn4_with_workspace.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_update_yarn4_with_workspace/snapshots/command_update_yarn4_with_workspace.md @@ -157,9 +157,10 @@ unfiltered update still updates all testnpm2 versions ## `vp update -r --no-save` -unfiltered recursive update remains supported +warn that --no-save is unsupported while preserving recursive update ``` +warn: yarn does not support --no-save. ➤ YN0000: · Yarn ➤ YN0000: ┌ Resolution step ➤ YN0000: └ Completed diff --git a/crates/vp_pm_cli/src/resolution/commands/update.rs b/crates/vp_pm_cli/src/resolution/commands/update.rs index ffabcd8010..c9e49e2616 100644 --- a/crates/vp_pm_cli/src/resolution/commands/update.rs +++ b/crates/vp_pm_cli/src/resolution/commands/update.rs @@ -57,7 +57,7 @@ pub struct UpdateArgs { pub(crate) no_optional: bool, /// Update lockfile only, don't modify package.json - #[arg(long)] + #[arg(long, not_supported(yarn))] pub(crate) no_save: bool, /// Only update if package exists in workspace (pnpm-specific) @@ -358,6 +358,22 @@ mod tests { assert_eq!(command.args, vec!["up", "react"]); } + #[test] + fn test_yarn_update_drops_no_save_with_warning() { + for (version, subcommand) in + [("1.22.0", "upgrade"), ("2.0.0", "up"), ("3.0.0", "up"), ("4.0.0", "up")] + { + let args = parse_args::(["react", "--no-save"]).unwrap(); + let resolution = resolve(&yarn(version), args); + let command = expect_run(resolution.outcome); + + assert_eq!(command.program, "yarn"); + assert_eq!(command.args, vec![subcommand, "react"]); + assert_eq!(resolution.diagnostics.len(), 1); + assert_eq!(resolution.diagnostics[0].message, "yarn does not support --no-save."); + } + } + #[test] fn test_yarn_v4_update_interactive() { let options = UpdateArgs { interactive: true, ..Default::default() };