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 @@ -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"],
Expand Down
Original file line number Diff line number Diff line change
@@ -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 <version>
➤ 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
]
Original file line number Diff line number Diff line change
Expand Up @@ -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 <version>
➤ YN0000: ┌ Resolution step
➤ YN0000: └ Completed
Expand Down
18 changes: 17 additions & 1 deletion crates/vp_pm_cli/src/resolution/commands/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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::<UpdateArgs>(["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() };
Expand Down
Loading