Skip to content

Commit 997c6a0

Browse files
committed
feat(pm): forward --filter to bun update on bun 1.4
bun update previously dropped --filter silently; bun before 1.4 now warns before dropping it, and 1.4 or newer receives the flag. Covered by resolution unit tests and a bun 1.4 workspace PTY snapshot case. Refs #2460
1 parent 1f90c2a commit 997c6a0

5 files changed

Lines changed: 72 additions & 1 deletion

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "command-update-bun-with-workspace",
3+
"version": "1.0.0",
4+
"workspaces": ["packages/*"],
5+
"packageManager": "bun@1.4.0"
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "app",
3+
"dependencies": {
4+
"testnpm2": "^1.0.0"
5+
}
6+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[[case]]
2+
name = "command_update_bun_with_workspace"
3+
vp = "global"
4+
skip-platforms = ["windows"]
5+
steps = [
6+
{ argv = ["vp", "install", "--", "--silent"], comment = "should install packages first", continue-on-failure = true },
7+
{ argv = ["vp", "update", "testnpm2", "--filter", "app", "--", "--silent"], comment = "should update package in packages/app" },
8+
{ argv = ["vpt", "print-file", "packages/app/package.json"], continue-on-failure = true },
9+
]
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# command_update_bun_with_workspace
2+
3+
## `vp install -- --silent`
4+
5+
should install packages first
6+
7+
```
8+
VITE+ - The Unified Toolchain for the Web
9+
```
10+
11+
## `vp update testnpm2 --filter app -- --silent`
12+
13+
should update package in packages/app
14+
15+
```
16+
```
17+
18+
## `vpt print-file packages/app/package.json`
19+
20+
```
21+
{
22+
"name": "app",
23+
"dependencies": {
24+
"testnpm2": "^1.0.1"
25+
}
26+
}
27+
```

crates/vp_pm_cli/src/resolution/commands/update.rs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub struct UpdateArgs {
3333
pub(crate) recursive: bool,
3434

3535
/// Filter packages in monorepo (can be used multiple times)
36-
#[arg(long, value_name = "PATTERN")]
36+
#[arg(long, value_name = "PATTERN", not_supported(bun < "1.4"))]
3737
pub(crate) filter: Vec<String>,
3838

3939
/// Include workspace root
@@ -152,6 +152,7 @@ impl Resolve<UpdateArgs> for Bun {
152152
fn resolve(&self, args: &UpdateArgs, _diag: &mut Diagnostics) -> CommandResolution {
153153
let mut cmd = CommandBuilder::new("bun");
154154
cmd.arg("update")
155+
.repeated("--filter", args.filter.iter())
155156
.arg_if("--latest", args.latest)
156157
.arg_if("--interactive", args.interactive)
157158
.arg_if("--production", args.prod);
@@ -599,4 +600,26 @@ mod tests {
599600
assert_eq!(command.program, "bun");
600601
assert_eq!(command.args, vec!["update", "--recursive"]);
601602
}
603+
604+
#[test]
605+
fn test_bun_update_with_filter() {
606+
let options = UpdateArgs { filter: vec!["web".to_string()], ..Default::default() };
607+
let resolution = resolve(&bun("1.4.0"), options);
608+
let command = expect_run(resolution.outcome);
609+
610+
assert_eq!(command.program, "bun");
611+
assert_eq!(command.args, vec!["update", "--filter", "web"]);
612+
assert!(resolution.diagnostics.is_empty());
613+
}
614+
615+
#[test]
616+
fn test_bun_update_drops_filter_before_1_4() {
617+
let options = UpdateArgs { filter: vec!["web".to_string()], ..Default::default() };
618+
let resolution = resolve(&bun("1.3.11"), options);
619+
let command = expect_run(resolution.outcome);
620+
621+
assert_eq!(command.program, "bun");
622+
assert_eq!(command.args, vec!["update"]);
623+
assert_eq!(resolution.diagnostics[0].message, "bun <1.4 does not support --filter.");
624+
}
602625
}

0 commit comments

Comments
 (0)