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 @@ -5,6 +5,7 @@
should add package to workspace root

```
warn: yarn >=2 does not support --workspace-root.
➤ YN0000: · Yarn <version>
➤ YN0000: ┌ Resolution step
➤ YN0085: │ + testnpm2@npm:1.0.1
Expand Down Expand Up @@ -46,6 +47,7 @@ should add package to workspace root
should add @vite-plus-test/utils to workspace root

```
warn: yarn >=2 does not support --workspace-root.
warn: yarn does not support --workspace.
➤ YN0000: · Yarn <version>
➤ YN0000: ┌ Resolution step
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ vp = "global"
skip-platforms = ["windows"]
steps = [
{ argv = ["vp", "update", "--help"], comment = "should show help", continue-on-failure = true },
{ argv = ["vp", "update", "testnpm2"], comment = "should update package within semver range" },
{ argv = ["vp", "update", "testnpm2", "--workspace-root"], comment = "warns about unsupported --workspace-root and updates within semver range" },
{ argv = ["vpt", "print-file", "package.json"], continue-on-failure = true },
{ argv = ["vp", "up", "testnpm2", "--latest"], comment = "should update to absolute latest version" },
{ argv = ["vpt", "print-file", "package.json"], continue-on-failure = true },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ Options:
Documentation: https://viteplus.dev/guide/install
```

## `vp update testnpm2`
## `vp update testnpm2 --workspace-root`

should update package within semver range
warns about unsupported --workspace-root and updates within semver range

```
warn: bun does not support --workspace-root.
bun update <version> (<hash>)

test-vite-plus-package@1.0.0
Expand Down
28 changes: 13 additions & 15 deletions crates/vp_pm_cli/src/resolution/commands/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub struct AddArgs {
pub(crate) filter: Vec<String>,

/// Add to workspace root
#[arg(short = 'w', long, not_supported(bun))]
#[arg(short = 'w', long, not_supported(yarn >= "2", bun))]
pub(crate) workspace_root: bool,

/// Only add if package exists in workspace (pnpm-specific)
Expand Down Expand Up @@ -219,7 +219,7 @@ impl Resolve<AddArgs> for Yarn {
cmd.arg("workspaces").arg("foreach").arg("--all");
cmd.repeated("--include", args.filter.iter());
}
cmd.arg("add");
cmd.arg("add").arg_if("-W", args.workspace_root && !self.is_berry());
match args.save_dependency.target() {
Some(SaveDependencyTarget::Dev) => {
cmd.arg("--dev");
Expand Down Expand Up @@ -481,7 +481,7 @@ mod tests {
let command = expect_run(resolution.outcome);

assert_eq!(command.program, "yarn");
assert_eq!(command.args, vec!["add", "--dev", "typescript"]);
assert_eq!(command.args, vec!["add", "-W", "--dev", "typescript"]);
assert!(resolution.diagnostics.is_empty());
}

Expand Down Expand Up @@ -574,21 +574,19 @@ mod tests {
}

#[test]
fn yarn_drops_workspace_root_without_warning() {
fn yarn_berry_drops_unsupported_workspace_root() {
let mut args = add_args(&["react"]);
args.workspace_root = true;
let resolution = resolve(&yarn("4.1.0"), args);
let command = expect_run(resolution.outcome);

let classic = resolve(&yarn("1.22.22"), args.clone());
let classic_command = expect_run(classic.outcome);
let berry = resolve(&yarn("4.1.0"), args);
let berry_command = expect_run(berry.outcome);

assert_eq!(classic_command.program, "yarn");
assert_eq!(classic_command.args, vec!["add", "react"]);
assert_eq!(berry_command.program, "yarn");
assert_eq!(berry_command.args, vec!["add", "react"]);
assert!(classic.diagnostics.is_empty());
assert!(berry.diagnostics.is_empty());
assert_eq!(command.program, "yarn");
assert_eq!(command.args, vec!["add", "react"]);
assert_eq!(resolution.diagnostics.len(), 1);
assert_eq!(
resolution.diagnostics[0].message,
"yarn >=2 does not support --workspace-root."
);
}

#[test]
Expand Down
3 changes: 1 addition & 2 deletions crates/vp_pm_cli/src/resolution/commands/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub struct InstallArgs {
pub(crate) filter: Vec<String>,

/// Install in workspace root only
#[arg(short = 'w', long, not_supported(bun))]
#[arg(short = 'w', long, not_supported(yarn, bun))]
pub(crate) workspace_root: bool,

/// Save exact version (only when adding packages)
Expand Down Expand Up @@ -228,7 +228,6 @@ impl Yarn {
.arg_if("--ignore-scripts", args.ignore_scripts)
.arg_if("--silent", args.silent)
.arg_if("--no-lockfile", args.no_lockfile)
.arg_if("-W", args.workspace_root)
.extend(args.pass_through_args.iter());
cmd.into()
}
Expand Down
2 changes: 1 addition & 1 deletion crates/vp_pm_cli/src/resolution/commands/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub struct UpdateArgs {
pub(crate) filter: Vec<String>,

/// Include workspace root
#[arg(short = 'w', long)]
#[arg(short = 'w', long, not_supported(yarn, bun))]
pub(crate) workspace_root: bool,

/// Update only devDependencies
Expand Down
2 changes: 1 addition & 1 deletion crates/vp_pm_cli/src/resolution/commands/why.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub struct WhyArgs {
pub(crate) filter: Vec<String>,

/// Check in workspace root
#[arg(short = 'w', long, not_supported(bun))]
#[arg(short = 'w', long, not_supported(yarn, bun))]
pub(crate) workspace_root: bool,

/// Only production dependencies
Expand Down
Loading