Skip to content

Commit 172dc27

Browse files
committed
test(snapshots): cover the Yarn catalog guard on vp up
Mirrors command_update_catalog_protocol_pnpm: migrate a minimal project to the Yarn catalog layout, then `vp up vite vite-plus` must skip both catalog-pinned names with a warning and leave package.json and the .yarnrc.yml catalog untouched.
1 parent fab30ba commit 172dc27

4 files changed

Lines changed: 126 additions & 0 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "command-update-catalog-protocol-yarn",
3+
"devDependencies": {
4+
"vite": "^7.0.0"
5+
},
6+
"packageManager": "yarn@4.12.0"
7+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
[[case]]
2+
name = "command_update_catalog_protocol_yarn"
3+
vp = "global"
4+
skip-platforms = ["windows"]
5+
unset-env = ["CI", "VP_SKIP_INSTALL"]
6+
local-registry = true
7+
steps = [
8+
{ argv = [
9+
"vp",
10+
"migrate",
11+
"--no-interactive",
12+
"--no-hooks",
13+
"--package-manager",
14+
"yarn",
15+
], comment = "migrate pins the toolchain through the Yarn catalog", continue-on-failure = true },
16+
{ argv = [
17+
"vpt",
18+
"print-file",
19+
"package.json",
20+
], comment = "the migrated project references the catalog", continue-on-failure = true },
21+
{ argv = [
22+
"vp",
23+
"up",
24+
"vite",
25+
"vite-plus",
26+
], comment = "#2309 Yarn variant: `yarn up` rewrites `catalog:` specs, so catalog-pinned names are skipped", continue-on-failure = true },
27+
{ argv = [
28+
"vpt",
29+
"print-file",
30+
"package.json",
31+
], comment = "`vite` and `vite-plus` stay `catalog:` instead of concrete ranges", continue-on-failure = true },
32+
{ argv = [
33+
"vpt",
34+
"print-file",
35+
".yarnrc.yml",
36+
], comment = "the catalog keeps owning the resolved toolchain version", continue-on-failure = true },
37+
]
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# command_update_catalog_protocol_yarn
2+
3+
## `vp migrate --no-interactive --no-hooks --package-manager yarn`
4+
5+
migrate pins the toolchain through the Yarn catalog
6+
7+
```
8+
VITE+ - The Unified Toolchain for the Web
9+
10+
⚠ Vite+ does not currently support Yarn Plug'n'Play (PnP).
11+
12+
✔ Switched Yarn to node-modules mode
13+
14+
Formatting code...
15+
16+
Code formatted
17+
◇ Migrated . to Vite+ <version>
18+
• Node <version> yarn <version>
19+
✓ Dependencies installed in <duration>
20+
• 1 config update applied
21+
• Package manager settings configured
22+
```
23+
24+
## `vpt print-file package.json`
25+
26+
the migrated project references the catalog
27+
28+
```
29+
{
30+
"name": "command-update-catalog-protocol-yarn",
31+
"devDependencies": {
32+
"vite": "catalog:",
33+
"vite-plus": "catalog:"
34+
},
35+
"resolutions": {
36+
"vite": "npm:@voidzero-dev/vite-plus-core@<version>"
37+
},
38+
"packageManager": "yarn@4.12.0"
39+
}
40+
```
41+
42+
## `vp up vite vite-plus`
43+
44+
#2309 Yarn variant: `yarn up` rewrites `catalog:` specs, so catalog-pinned names are skipped
45+
46+
```
47+
warn: Skipped vite: the Yarn catalog pins its version, and `yarn up` would overwrite the `catalog:` reference. Edit the catalog entry in .yarnrc.yml, or run `vp migrate` when Vite+ manages the pin.
48+
warn: Skipped vite-plus: the Yarn catalog pins its version, and `yarn up` would overwrite the `catalog:` reference. Edit the catalog entry in .yarnrc.yml, or run `vp migrate` when Vite+ manages the pin.
49+
```
50+
51+
## `vpt print-file package.json`
52+
53+
`vite` and `vite-plus` stay `catalog:` instead of concrete ranges
54+
55+
```
56+
{
57+
"name": "command-update-catalog-protocol-yarn",
58+
"devDependencies": {
59+
"vite": "catalog:",
60+
"vite-plus": "catalog:"
61+
},
62+
"resolutions": {
63+
"vite": "npm:@voidzero-dev/vite-plus-core@<version>"
64+
},
65+
"packageManager": "yarn@4.12.0"
66+
}
67+
```
68+
69+
## `vpt print-file .yarnrc.yml`
70+
71+
the catalog keeps owning the resolved toolchain version
72+
73+
```
74+
nodeLinker: node-modules
75+
npmPreapprovedPackages:
76+
- vitest
77+
- "@vitest/*"
78+
catalog:
79+
vite: npm:@voidzero-dev/vite-plus-core@<version>
80+
vite-plus: <version>
81+
```

0 commit comments

Comments
 (0)