Skip to content

Commit 5d981e5

Browse files
committed
fix(workspace): support Bun object-form workspaces in package.json
Bun and Yarn classic support `workspaces` as an object with a `packages` field (e.g., for Bun catalogs), not just an array. Handle both forms in workspace detection, create, and migrate flows. Closes #1247
1 parent 9322199 commit 5d981e5

15 files changed

Lines changed: 323 additions & 30 deletions

File tree

Cargo.lock

Lines changed: 19 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ dunce = "1.0.5"
8585
fast-glob = "1.0.0"
8686
flate2 = { version = "=1.1.9", features = ["zlib-rs"] }
8787
form_urlencoded = "1.2.1"
88-
fspy = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "1ef4e2f6bd783472ffdaa1cae874d142e2f56322" }
88+
fspy = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "f38a70801878f8d704264cdedebc768bfcfc9fae" }
8989
futures = "0.3.31"
9090
futures-util = "0.3.31"
9191
glob = "0.3.2"
@@ -186,15 +186,15 @@ vfs = "0.13.0"
186186
vite_command = { path = "crates/vite_command" }
187187
vite_error = { path = "crates/vite_error" }
188188
vite_js_runtime = { path = "crates/vite_js_runtime" }
189-
vite_glob = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "1ef4e2f6bd783472ffdaa1cae874d142e2f56322" }
189+
vite_glob = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "f38a70801878f8d704264cdedebc768bfcfc9fae" }
190190
vite_install = { path = "crates/vite_install" }
191191
vite_migration = { path = "crates/vite_migration" }
192192
vite_shared = { path = "crates/vite_shared" }
193193
vite_static_config = { path = "crates/vite_static_config" }
194-
vite_path = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "1ef4e2f6bd783472ffdaa1cae874d142e2f56322" }
195-
vite_str = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "1ef4e2f6bd783472ffdaa1cae874d142e2f56322" }
196-
vite_task = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "1ef4e2f6bd783472ffdaa1cae874d142e2f56322" }
197-
vite_workspace = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "1ef4e2f6bd783472ffdaa1cae874d142e2f56322" }
194+
vite_path = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "f38a70801878f8d704264cdedebc768bfcfc9fae" }
195+
vite_str = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "f38a70801878f8d704264cdedebc768bfcfc9fae" }
196+
vite_task = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "f38a70801878f8d704264cdedebc768bfcfc9fae" }
197+
vite_workspace = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "f38a70801878f8d704264cdedebc768bfcfc9fae" }
198198
walkdir = "2.5.0"
199199
wax = "0.6.0"
200200
which = "8.0.0"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "website",
3+
"version": "0.0.0"
4+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "test-bun-monorepo",
3+
"version": "0.0.0",
4+
"private": true,
5+
"workspaces": {
6+
"packages": [
7+
"apps/*",
8+
"packages/*",
9+
"tools/*"
10+
],
11+
"catalog": {
12+
"vite": "npm:@voidzero-dev/vite-plus-core@latest",
13+
"vitest": "npm:@voidzero-dev/vite-plus-test@latest",
14+
"vite-plus": "latest"
15+
}
16+
},
17+
"packageManager": "bun@1.3.11"
18+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "helper",
3+
"version": "0.0.0"
4+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
> cd apps/website && vp create --no-interactive vite:generator # from workspace subdir with object-form workspaces
2+
> test -f tools/vite-plus-generator/package.json && echo 'Created at tools/vite-plus-generator' || echo 'NOT at tools/'
3+
Created at tools/vite-plus-generator
4+
5+
> test ! -f apps/website/tools/vite-plus-generator/package.json && echo 'Not in apps/website/' || echo 'BUG: in apps/website/'
6+
Not in apps/website/
7+
8+
> cd apps && vp create --no-interactive vite:application # from workspace parent dir
9+
> test -f apps/vite-plus-application/package.json && echo 'Created at apps/vite-plus-application' || echo 'NOT at apps/'
10+
Created at apps/vite-plus-application
11+
12+
> cd scripts/helper && vp create --no-interactive vite:library # from non-workspace dir
13+
> test -f packages/vite-plus-library/package.json && echo 'Created at packages/vite-plus-library' || echo 'NOT at packages/'
14+
Created at packages/vite-plus-library
15+
16+
> cat package.json # verify workspaces object form preserved after workspace update
17+
{
18+
"name": "test-bun-monorepo",
19+
"version": "0.0.0",
20+
"private": true,
21+
"workspaces": {
22+
"packages": [
23+
"apps/*",
24+
"packages/*",
25+
"tools/*"
26+
],
27+
"catalog": {
28+
"vite": "npm:@voidzero-dev/vite-plus-core@latest",
29+
"vitest": "npm:@voidzero-dev/vite-plus-test@latest",
30+
"vite-plus": "latest"
31+
}
32+
},
33+
"packageManager": "bun@<semver>"
34+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"ignoredPlatforms": ["win32"],
3+
"commands": [
4+
{
5+
"command": "cd apps/website && vp create --no-interactive vite:generator # from workspace subdir with object-form workspaces",
6+
"ignoreOutput": true
7+
},
8+
"test -f tools/vite-plus-generator/package.json && echo 'Created at tools/vite-plus-generator' || echo 'NOT at tools/'",
9+
"test ! -f apps/website/tools/vite-plus-generator/package.json && echo 'Not in apps/website/' || echo 'BUG: in apps/website/'",
10+
11+
{
12+
"command": "cd apps && vp create --no-interactive vite:application # from workspace parent dir",
13+
"ignoreOutput": true
14+
},
15+
"test -f apps/vite-plus-application/package.json && echo 'Created at apps/vite-plus-application' || echo 'NOT at apps/'",
16+
17+
{
18+
"command": "cd scripts/helper && vp create --no-interactive vite:library # from non-workspace dir",
19+
"ignoreOutput": true
20+
},
21+
"test -f packages/vite-plus-library/package.json && echo 'Created at packages/vite-plus-library' || echo 'NOT at packages/'",
22+
23+
"cat package.json # verify workspaces object form preserved after workspace update"
24+
]
25+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"rules": {
3+
"no-unused-vars": "error"
4+
}
5+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name": "migration-monorepo-bun",
3+
"version": "1.0.0",
4+
"workspaces": {
5+
"packages": [
6+
"packages/*"
7+
],
8+
"catalog": {
9+
"vite": "npm:@voidzero-dev/vite-plus-core@latest",
10+
"vitest": "npm:@voidzero-dev/vite-plus-test@latest",
11+
"vite-plus": "latest"
12+
}
13+
},
14+
"scripts": {
15+
"dev": "vite dev",
16+
"build": "vite build",
17+
"test": "vitest",
18+
"lint": "oxlint",
19+
"fmt": "oxfmt"
20+
},
21+
"dependencies": {
22+
"testnpm2": "1.0.0"
23+
},
24+
"devDependencies": {
25+
"@vitejs/plugin-react": "catalog:",
26+
"oxfmt": "catalog:",
27+
"oxlint": "catalog:",
28+
"vite": "catalog:",
29+
"vitest": "catalog:"
30+
},
31+
"packageManager": "bun@1.3.11"
32+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "app",
3+
"scripts": {
4+
"dev": "vite dev",
5+
"build": "vite build",
6+
"test": "vitest"
7+
},
8+
"dependencies": {
9+
"@migration-bun-test/utils": "workspace:*",
10+
"test-vite-plus-install": "1.0.0",
11+
"testnpm2": "catalog:"
12+
},
13+
"devDependencies": {
14+
"test-vite-plus-package": "1.0.0",
15+
"vite": "catalog:",
16+
"vitest": "catalog:"
17+
}
18+
}

0 commit comments

Comments
 (0)