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,16 +3,17 @@ name = "command_update_yarn4_with_workspace"
vp = "global"
skip-platforms = ["windows"]
steps = [
{ argv = ["vp", "update", "testnpm2"], comment = "should update all testnpm2 versions" },
{ argv = ["vpt", "print-file", "package.json", "packages/utils/package.json"], continue-on-failure = true },
{ argv = ["vp", "update", "testnpm2", "--latest", "--filter", "app"], comment = "should update in specific package" },
{ argv = ["vpt", "print-file", "packages/app/package.json"], continue-on-failure = true },
{ argv = ["vp", "up", "-D", "--filter", "app"], comment = "should update dev dependencies in app" },
{ argv = ["vpt", "print-file", "packages/app/package.json"], continue-on-failure = true },
{ argv = ["vp", "update", "--filter", "*"], comment = "should update in all packages" },
{ argv = ["vpt", "print-file", "packages/app/package.json", "packages/utils/package.json"], continue-on-failure = true },
{ argv = ["vp", "update", "-r", "--no-save"], comment = "should update recursively without saving" },
{ argv = ["vp", "update", "testnpm2", "--latest", "--filter", "app"], comment = "Berry filtered update fails instead of updating every workspace", continue-on-failure = true },
{ argv = ["vp", "up", "-D", "--filter", "app"], comment = "the up alias rejects filters without a package argument", continue-on-failure = true },
{ argv = ["vp", "update", "--filter", "*"], comment = "wildcard filters are also unsupported", continue-on-failure = true },
{ argv = ["vp", "update", "--workspace", "--filter", "app", "@vite-plus-test/utils"], comment = "workspace dependency updates reject filters", continue-on-failure = true },
{ argv = ["vp", "update", "testnpm2", "--filter", "app", "--filter", "@vite-plus-test/utils", "--recursive"], comment = "recursive update must not silently discard workspace filters", continue-on-failure = true },
{ argv = ["vpt", "print-file", "package.json", "packages/app/package.json", "packages/utils/package.json"], comment = "root, selected, and unselected workspace manifests remain unchanged", continue-on-failure = true },
["vpt", "stat-file", "yarn.lock", "--assert", "missing"],
["vpt", "stat-file", ".pnp.cjs", "--assert", "missing"],
["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 = ["vpt", "print-file", "package.json", "packages/app/package.json"], continue-on-failure = true },
{ argv = ["vp", "update", "--workspace", "--filter", "app", "@vite-plus-test/utils"], comment = "should update workspace dependency" },
{ argv = ["vpt", "print-file", "packages/app/package.json"], continue-on-failure = true },
]
Original file line number Diff line number Diff line change
@@ -1,149 +1,140 @@
# command_update_yarn4_with_workspace

## `vp update testnpm2`
## `vp update testnpm2 --latest --filter app`

should update all testnpm2 versions
Berry filtered update fails instead of updating every workspace

**Exit code:** 1

```
➤ YN0000: · Yarn <version>
➤ YN0000: ┌ Resolution step
➤ YN0085: │ + test-vite-plus-install@npm:1.0.0, test-vite-plus-package@npm:1.0.0, testnpm2@npm:1.0.1
➤ YN0000: └ Completed
➤ YN0000: ┌ Fetch step
➤ YN0013: │ 3 packages were added to the project (+ <size> KiB).
➤ YN0000: └ Completed
➤ YN0000: ┌ Link step
➤ YN0000: └ Completed
➤ YN0000: · Done in <duration> <duration>
Invalid argument: `--filter` is not supported by Yarn Berry `update`.
```

## `vpt print-file package.json packages/utils/package.json`
## `vp up -D --filter app`

the up alias rejects filters without a package argument

**Exit code:** 1

```
{
"name": "command-update-yarn4-with-workspace",
"version": "1.0.0",
"workspaces": [
"packages/*"
],
"dependencies": {
"testnpm2": "^1.0.1"
},
"packageManager": "yarn@4.10.3"
}
{
"name": "@vite-plus-test/utils",
"version": "1.0.0",
"dependencies": {
"testnpm2": "^1.0.1"
}
}
Invalid argument: `--filter` is not supported by Yarn Berry `update`.
```

## `vp update testnpm2 --latest --filter app`
## `vp update --filter *`

should update in specific package
wildcard filters are also unsupported

```
[app]: Process started
[app]: ➤ YN0000: · Yarn <version>
[app]: ➤ YN0000: ┌ Resolution step
[app]: ➤ YN0085: │ + testnpm2@npm:1.0.1
[app]: ➤ YN0000: └ Completed
[app]: ➤ YN0000: ┌ Fetch step
[app]: ➤ YN0000: └ Completed
[app]: ➤ YN0000: ┌ Link step
[app]: ➤ YN0000: └ Completed
[app]: ➤ YN0000: · Done in <duration> <duration>
[app]: Process exited (exit code 0), completed in <duration> <duration>
**Exit code:** 1

Done in <duration> <duration>
```
Invalid argument: `--filter` is not supported by Yarn Berry `update`.
```

## `vp update --workspace --filter app @vite-plus-test/utils`

## `vpt print-file packages/app/package.json`
workspace dependency updates reject filters

**Exit code:** 1

```
{
"name": "app",
"dependencies": {
"@vite-plus-test/utils": "workspace:*",
"test-vite-plus-install": "*",
"testnpm2": "^1.0.1"
},
"devDependencies": {
"test-vite-plus-package": "*"
}
}
Invalid argument: `--filter` is not supported by Yarn Berry `update`.
```

## `vp up -D --filter app`
## `vp update testnpm2 --filter app --filter @vite-plus-test/utils --recursive`

should update dev dependencies in app
recursive update must not silently discard workspace filters

```
[app]: Process started
[app]: ➤ YN0000: · Yarn <version>
[app]: ➤ YN0000: ┌ Resolution step
[app]: ➤ YN0000: └ Completed
[app]: ➤ YN0000: ┌ Fetch step
[app]: ➤ YN0000: └ Completed
[app]: ➤ YN0000: ┌ Link step
[app]: ➤ YN0000: └ Completed
[app]: ➤ YN0000: · Done in <duration> <duration>
[app]: Process exited (exit code 0), completed in <duration> <duration>
**Exit code:** 1

Done in <duration> <duration>
```
Invalid argument: `--filter` is not supported by Yarn Berry `update`.
```

## `vpt print-file package.json packages/app/package.json packages/utils/package.json`

## `vpt print-file packages/app/package.json`
root, selected, and unselected workspace manifests remain unchanged

```
{
"name": "command-update-yarn4-with-workspace",
"version": "1.0.0",
"workspaces": [
"packages/*"
],
"dependencies": {
"testnpm2": "*"
},
"packageManager": "yarn@4.10.3"
}
{
"name": "app",
"dependencies": {
"@vite-plus-test/utils": "workspace:*",
"test-vite-plus-install": "*",
"testnpm2": "^1.0.1"
"testnpm2": "*"
},
"devDependencies": {
"test-vite-plus-package": "*"
}
}
{
"name": "@vite-plus-test/utils",
"version": "1.0.0",
"dependencies": {
"testnpm2": "*"
}
}
```

## `vp update --filter *`
## `vpt stat-file yarn.lock --assert missing`

```
yarn.lock: missing
```

## `vpt stat-file .pnp.cjs --assert missing`

```
.pnp.cjs: missing
```

should update in all packages
## `vpt stat-file node_modules --assert missing`

```
[command-update-yarn4-with-workspace]: Process started
[command-update-yarn4-with-workspace]: ➤ YN0000: · Yarn <version>
[command-update-yarn4-with-workspace]: ➤ YN0000: ┌ Resolution step
[command-update-yarn4-with-workspace]: ➤ YN0000: └ Completed
[command-update-yarn4-with-workspace]: ➤ YN0000: ┌ Fetch step
[command-update-yarn4-with-workspace]: ➤ YN0000: └ Completed
[command-update-yarn4-with-workspace]: ➤ YN0000: ┌ Link step
[command-update-yarn4-with-workspace]: ➤ YN0000: └ Completed
[command-update-yarn4-with-workspace]: ➤ YN0000: · Done in <duration> <duration>
[command-update-yarn4-with-workspace]: Process exited (exit code 0), completed in <duration> <duration>
node_modules: missing
```

## `vp update testnpm2`

[app]: Process started
[app]: ➤ YN0000: · Yarn <version>
[app]: ➤ YN0000: ┌ Resolution step
[app]: ➤ YN0000: └ Completed
[app]: ➤ YN0000: ┌ Fetch step
[app]: ➤ YN0000: └ Completed
[app]: ➤ YN0000: ┌ Link step
[app]: ➤ YN0000: └ Completed
[app]: ➤ YN0000: · Done in <duration> <duration>
[app]: Process exited (exit code 0), completed in <duration> <duration>
unfiltered update still updates all testnpm2 versions

Done in <duration> <duration>
```
➤ YN0000: · Yarn <version>
➤ YN0000: ┌ Resolution step
➤ YN0085: │ + test-vite-plus-install@npm:1.0.0, test-vite-plus-package@npm:1.0.0, testnpm2@npm:1.0.1
➤ YN0000: └ Completed
➤ YN0000: ┌ Fetch step
➤ YN0013: │ 3 packages were added to the project (+ <size> KiB).
➤ YN0000: └ Completed
➤ YN0000: ┌ Link step
➤ YN0000: └ Completed
➤ YN0000: · Done in <duration> <duration>
```

## `vpt print-file packages/app/package.json packages/utils/package.json`
## `vpt print-file package.json packages/app/package.json packages/utils/package.json`

```
{
"name": "command-update-yarn4-with-workspace",
"version": "1.0.0",
"workspaces": [
"packages/*"
],
"dependencies": {
"testnpm2": "^1.0.1"
},
"packageManager": "yarn@4.10.3"
}
{
"name": "app",
"dependencies": {
Expand All @@ -166,7 +157,7 @@ Done in <duration> <duration>

## `vp update -r --no-save`

should update recursively without saving
unfiltered recursive update remains supported

```
➤ YN0000: · Yarn <version>
Expand Down Expand Up @@ -205,38 +196,3 @@ should update recursively without saving
}
}
```

## `vp update --workspace --filter app @vite-plus-test/utils`

should update workspace dependency

```
[app]: Process started
[app]: ➤ YN0000: · Yarn <version>
[app]: ➤ YN0000: ┌ Resolution step
[app]: ➤ YN0000: └ Completed
[app]: ➤ YN0000: ┌ Fetch step
[app]: ➤ YN0000: └ Completed
[app]: ➤ YN0000: ┌ Link step
[app]: ➤ YN0000: └ Completed
[app]: ➤ YN0000: · Done in <duration> <duration>
[app]: Process exited (exit code 0), completed in <duration> <duration>

Done in <duration> <duration>
```

## `vpt print-file packages/app/package.json`

```
{
"name": "app",
"dependencies": {
"@vite-plus-test/utils": "workspace:^",
"test-vite-plus-install": "*",
"testnpm2": "^1.0.1"
},
"devDependencies": {
"test-vite-plus-package": "*"
}
}
```
52 changes: 25 additions & 27 deletions crates/vp_pm_cli/src/resolution/commands/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,10 @@ impl Yarn {
fn resolve_berry_update(args: &UpdateArgs) -> CommandResolution {
let mut cmd = CommandBuilder::new("yarn");
if !args.filter.is_empty() {
cmd.arg("workspaces").arg("foreach").arg("--all");
cmd.repeated("--include", args.filter.iter());
// `yarn up` updates the whole project, even when run through `foreach`.
return CommandResolution::InvalidArgument(
"Invalid argument: `--filter` is not supported by Yarn Berry `update`.".to_string(),
);
}
cmd.arg("up")
.arg_if("--recursive", args.recursive)
Expand Down Expand Up @@ -367,17 +369,18 @@ mod tests {
}

#[test]
fn test_yarn_v4_update_with_filter() {
fn test_yarn_berry_update_rejects_filter() {
let mut options = update_args(&["react"]);
options.filter = vec!["app".to_string()];
let resolution = resolve(&yarn("4.0.0"), options);
let command = expect_run(resolution.outcome);

assert_eq!(command.program, "yarn");
assert_eq!(
command.args,
vec!["workspaces", "foreach", "--all", "--include", "app", "up", "react"]
resolution.outcome,
CommandResolution::InvalidArgument(
"Invalid argument: `--filter` is not supported by Yarn Berry `update`.".to_string()
)
);
assert!(resolution.diagnostics.is_empty());
}

#[test]
Expand Down Expand Up @@ -519,27 +522,22 @@ mod tests {
}

#[test]
fn test_yarn_v4_update_multiple_filters() {
let mut options = update_args(&["lodash"]);
options.filter = vec!["app".to_string(), "web".to_string()];
let resolution = resolve(&yarn("4.0.0"), options);
let command = expect_run(resolution.outcome);
fn test_yarn_berry_update_rejects_multiple_filters() {
for recursive in [false, true] {
let mut options = update_args(&["lodash"]);
options.filter = vec!["app".to_string(), "web".to_string()];
options.recursive = recursive;
let resolution = resolve(&yarn("4.0.0"), options);

assert_eq!(command.program, "yarn");
assert_eq!(
command.args,
vec![
"workspaces",
"foreach",
"--all",
"--include",
"app",
"--include",
"web",
"up",
"lodash"
]
);
assert_eq!(
resolution.outcome,
CommandResolution::InvalidArgument(
"Invalid argument: `--filter` is not supported by Yarn Berry `update`."
.to_string()
)
);
assert!(resolution.diagnostics.is_empty());
}
}

#[test]
Expand Down
Loading