Skip to content

Commit 962694f

Browse files
committed
refactor(migration): move pnpm config into pnpm-workspace.yaml (#1237)
## Summary - For standalone pnpm projects **without** existing `pnpm` config in `package.json`, write overrides, peerDependencyRules, and catalog to `pnpm-workspace.yaml` instead of `package.json`, and use `catalog:` references in devDependencies - For projects **with** existing `pnpm` config in `package.json` (e.g., dify with `pnpm.overrides`), respect the existing location and keep config in `package.json` - Move any remaining non-Vite `pnpm.overrides` from `package.json` to `pnpm-workspace.yaml` to prevent pnpm from ignoring workspace-level overrides - Surgically remove only Vite-managed entries from `peerDependencyRules` instead of deleting the entire object, preserving custom rules - Update migration RFC to document the pnpm-specific behavior Closes #1233 ## Test plan - [x] `pnpm -F vite-plus snap-test-global` -- all 80+ snap tests pass - [x] Standalone pnpm without existing `pnpm` field: creates `pnpm-workspace.yaml` with catalog/overrides/peerDependencyRules, devDependencies use `catalog:` - [x] Standalone pnpm with existing `pnpm` field (dify): keeps config in `package.json`, no `pnpm-workspace.yaml` created, `vp install` succeeds - [x] Monorepo pnpm tests unchanged - [x] Monorepo with remaining non-Vite overrides: moves them to `pnpm-workspace.yaml`, removes `pnpm.overrides` from `package.json` 🤖 Generated with [Claude Code](https://claude.com/claude-code)
1 parent d81a033 commit 962694f

116 files changed

Lines changed: 1599 additions & 1140 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/cli/snap-tests-global/migration-add-git-hooks/snap.txt

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,31 @@ VITE+ - The Unified Toolchain for the Web
1111
{
1212
"name": "migration-add-git-hooks",
1313
"devDependencies": {
14-
"vite": "npm:@voidzero-dev/vite-plus-core@latest",
15-
"vite-plus": "latest"
16-
},
17-
"pnpm": {
18-
"overrides": {
19-
"vite": "npm:@voidzero-dev/vite-plus-core@latest",
20-
"vitest": "npm:@voidzero-dev/vite-plus-test@latest"
21-
},
22-
"peerDependencyRules": {
23-
"allowAny": [
24-
"vite",
25-
"vitest"
26-
],
27-
"allowedVersions": {
28-
"vite": "*",
29-
"vitest": "*"
30-
}
31-
}
14+
"vite": "catalog:",
15+
"vite-plus": "catalog:"
3216
},
3317
"packageManager": "pnpm@<semver>",
3418
"scripts": {
3519
"prepare": "vp config"
3620
}
3721
}
3822

23+
> cat pnpm-workspace.yaml # check pnpm-workspace.yaml has overrides and catalog
24+
catalog:
25+
vite: npm:@voidzero-dev/vite-plus-core@latest
26+
vitest: npm:@voidzero-dev/vite-plus-test@latest
27+
vite-plus: latest
28+
overrides:
29+
vite: 'catalog:'
30+
vitest: 'catalog:'
31+
peerDependencyRules:
32+
allowAny:
33+
- vite
34+
- vitest
35+
allowedVersions:
36+
vite: '*'
37+
vitest: '*'
38+
3939
> cat .vite-hooks/pre-commit # check pre-commit hook
4040
vp staged
4141

packages/cli/snap-tests-global/migration-add-git-hooks/steps.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
{
22
"commands": [
3-
{ "command": "git init", "ignoreOutput": true },
3+
{
4+
"command": "git init",
5+
"ignoreOutput": true
6+
},
47
"vp migrate --no-interactive # migration should add git hooks setup",
58
"cat package.json # check package.json has prepare script and lint-staged config",
9+
"cat pnpm-workspace.yaml # check pnpm-workspace.yaml has overrides and catalog",
610
"cat .vite-hooks/pre-commit # check pre-commit hook",
711
"test -d .vite-hooks/_ && echo 'hook shims exist' || echo 'no hook shims' # check vp config ran",
812
"git config --local core.hooksPath # should be set to .vite-hooks/_",

packages/cli/snap-tests-global/migration-auto-create-vite-config/snap.txt

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,26 @@ export default defineConfig({
3535
> cat package.json # check package.json
3636
{
3737
"devDependencies": {
38-
"vite-plus": "latest"
39-
},
40-
"pnpm": {
41-
"overrides": {
42-
"vite": "npm:@voidzero-dev/vite-plus-core@latest",
43-
"vitest": "npm:@voidzero-dev/vite-plus-test@latest"
44-
},
45-
"peerDependencyRules": {
46-
"allowAny": [
47-
"vite",
48-
"vitest"
49-
],
50-
"allowedVersions": {
51-
"vite": "*",
52-
"vitest": "*"
53-
}
54-
}
38+
"vite-plus": "catalog:"
5539
},
5640
"packageManager": "pnpm@<semver>",
5741
"scripts": {
5842
"prepare": "vp config"
5943
}
6044
}
45+
46+
> cat pnpm-workspace.yaml # check pnpm-workspace.yaml has overrides and catalog
47+
catalog:
48+
vite: npm:@voidzero-dev/vite-plus-core@latest
49+
vitest: npm:@voidzero-dev/vite-plus-test@latest
50+
vite-plus: latest
51+
overrides:
52+
vite: 'catalog:'
53+
vitest: 'catalog:'
54+
peerDependencyRules:
55+
allowAny:
56+
- vite
57+
- vitest
58+
allowedVersions:
59+
vite: '*'
60+
vitest: '*'

packages/cli/snap-tests-global/migration-auto-create-vite-config/steps.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"cat vite.config.ts # check vite.config.ts",
55
"test ! -f .oxlintrc.json # check .oxlintrc.json is removed",
66
"test ! -f .oxfmtrc.json # check .oxfmtrc.json is removed",
7-
"cat package.json # check package.json"
7+
"cat package.json # check package.json",
8+
"cat pnpm-workspace.yaml # check pnpm-workspace.yaml has overrides and catalog"
89
]
910
}

packages/cli/snap-tests-global/migration-baseurl-tsconfig/snap.txt

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,26 +28,26 @@ export default defineConfig({
2828
> cat package.json # check package.json
2929
{
3030
"devDependencies": {
31-
"vite-plus": "latest"
32-
},
33-
"pnpm": {
34-
"overrides": {
35-
"vite": "npm:@voidzero-dev/vite-plus-core@latest",
36-
"vitest": "npm:@voidzero-dev/vite-plus-test@latest"
37-
},
38-
"peerDependencyRules": {
39-
"allowAny": [
40-
"vite",
41-
"vitest"
42-
],
43-
"allowedVersions": {
44-
"vite": "*",
45-
"vitest": "*"
46-
}
47-
}
31+
"vite-plus": "catalog:"
4832
},
4933
"packageManager": "pnpm@<semver>",
5034
"scripts": {
5135
"prepare": "vp config"
5236
}
5337
}
38+
39+
> cat pnpm-workspace.yaml # check pnpm-workspace.yaml has overrides and catalog
40+
catalog:
41+
vite: npm:@voidzero-dev/vite-plus-core@latest
42+
vitest: npm:@voidzero-dev/vite-plus-test@latest
43+
vite-plus: latest
44+
overrides:
45+
vite: 'catalog:'
46+
vitest: 'catalog:'
47+
peerDependencyRules:
48+
allowAny:
49+
- vite
50+
- vitest
51+
allowedVersions:
52+
vite: '*'
53+
vitest: '*'
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
22
"commands": [
33
"vp migrate --no-interactive # migration should skip typeAware/typeCheck when tsconfig has baseUrl",
4-
"cat vite.config.ts # check vite.config.ts should NOT have typeAware or typeCheck",
4+
"cat vite.config.ts # check vite.config.ts \u2014 should NOT have typeAware or typeCheck",
55
"test ! -f .oxlintrc.json # check .oxlintrc.json is removed",
6-
"cat package.json # check package.json"
6+
"cat package.json # check package.json",
7+
"cat pnpm-workspace.yaml # check pnpm-workspace.yaml has overrides and catalog"
78
]
89
}

packages/cli/snap-tests-global/migration-chained-lint-staged-pre-commit/snap.txt

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,28 @@ VITE+ - The Unified Toolchain for the Web
1414
"prepare": "vp config"
1515
},
1616
"devDependencies": {
17-
"vite": "npm:@voidzero-dev/vite-plus-core@latest",
18-
"vite-plus": "latest"
19-
},
20-
"pnpm": {
21-
"overrides": {
22-
"vite": "npm:@voidzero-dev/vite-plus-core@latest",
23-
"vitest": "npm:@voidzero-dev/vite-plus-test@latest"
24-
},
25-
"peerDependencyRules": {
26-
"allowAny": [
27-
"vite",
28-
"vitest"
29-
],
30-
"allowedVersions": {
31-
"vite": "*",
32-
"vitest": "*"
33-
}
34-
}
17+
"vite": "catalog:",
18+
"vite-plus": "catalog:"
3519
},
3620
"packageManager": "pnpm@<semver>"
3721
}
3822

23+
> cat pnpm-workspace.yaml # check pnpm-workspace.yaml has overrides and catalog
24+
catalog:
25+
vite: npm:@voidzero-dev/vite-plus-core@latest
26+
vitest: npm:@voidzero-dev/vite-plus-test@latest
27+
vite-plus: latest
28+
overrides:
29+
vite: 'catalog:'
30+
vitest: 'catalog:'
31+
peerDependencyRules:
32+
allowAny:
33+
- vite
34+
- vitest
35+
allowedVersions:
36+
vite: '*'
37+
vitest: '*'
38+
3939
> cat vite.config.ts # check staged config migrated to vite.config.ts
4040
import { defineConfig } from 'vite-plus';
4141

packages/cli/snap-tests-global/migration-chained-lint-staged-pre-commit/steps.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
{
22
"commands": [
3-
{ "command": "git init", "ignoreOutput": true },
3+
{
4+
"command": "git init",
5+
"ignoreOutput": true
6+
},
47
"vp migrate --no-interactive # migration should preserve chained commands after lint-staged",
58
"cat package.json # check prepare rewritten and husky/lint-staged removed",
9+
"cat pnpm-workspace.yaml # check pnpm-workspace.yaml has overrides and catalog",
610
"cat vite.config.ts # check staged config migrated to vite.config.ts",
711
"cat .vite-hooks/pre-commit # check npx lint-staged replaced but --diff HEAD~1 && npm test preserved"
812
]

packages/cli/snap-tests-global/migration-composed-husky-custom-dir/snap.txt

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,28 @@ VITE+ - The Unified Toolchain for the Web
1414
"prepare": "npm run build && vp config --hooks-dir .config/husky"
1515
},
1616
"devDependencies": {
17-
"vite": "npm:@voidzero-dev/vite-plus-core@latest",
18-
"vite-plus": "latest"
19-
},
20-
"pnpm": {
21-
"overrides": {
22-
"vite": "npm:@voidzero-dev/vite-plus-core@latest",
23-
"vitest": "npm:@voidzero-dev/vite-plus-test@latest"
24-
},
25-
"peerDependencyRules": {
26-
"allowAny": [
27-
"vite",
28-
"vitest"
29-
],
30-
"allowedVersions": {
31-
"vite": "*",
32-
"vitest": "*"
33-
}
34-
}
17+
"vite": "catalog:",
18+
"vite-plus": "catalog:"
3519
},
3620
"packageManager": "pnpm@<semver>"
3721
}
3822

23+
> cat pnpm-workspace.yaml # check pnpm-workspace.yaml has overrides and catalog
24+
catalog:
25+
vite: npm:@voidzero-dev/vite-plus-core@latest
26+
vitest: npm:@voidzero-dev/vite-plus-test@latest
27+
vite-plus: latest
28+
overrides:
29+
vite: 'catalog:'
30+
vitest: 'catalog:'
31+
peerDependencyRules:
32+
allowAny:
33+
- vite
34+
- vitest
35+
allowedVersions:
36+
vite: '*'
37+
vitest: '*'
38+
3939
> cat .config/husky/pre-commit # pre-commit hook should be in custom dir
4040
vp staged
4141

packages/cli/snap-tests-global/migration-composed-husky-custom-dir/steps.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
{
22
"commands": [
3-
{ "command": "git init", "ignoreOutput": true },
3+
{
4+
"command": "git init",
5+
"ignoreOutput": true
6+
},
47
"vp migrate --no-interactive # migration should preserve custom husky dir in composed prepare",
58
"cat package.json # prepare should be 'vp config --hooks-dir .config/husky && npm run build'",
9+
"cat pnpm-workspace.yaml # check pnpm-workspace.yaml has overrides and catalog",
610
"cat .config/husky/pre-commit # pre-commit hook should be in custom dir",
711
"cat .config/husky/_/h # hook dispatcher should resolve repo root correctly for nested dirs"
812
]

0 commit comments

Comments
 (0)