Skip to content

Commit e50937c

Browse files
Brooooooklynclaude
andcommitted
fix(migration): preapprove vitest family in generated .yarnrc.yml
Yarn 4 hardened mode (auto-enabled for public-PR installs) quarantines packages younger than `npmMinimalAgeGate`, so a freshly published vitest pin makes `yarn install` fail for projects Vite+ creates/migrates — the four `vp create … (yarn)` CI jobs hit this on the same-day 4.1.9 release. Add `npmPreapprovedPackages: [vitest, '@vitest/*']` to the generated `.yarnrc.yml` (rewriteYarnrcYml, shared by create + migrate) so the Vite+-managed vitest family is exempt from the age gate regardless of release age. The `@vitest/*` glob also covers the optional `@vitest/browser-*` peers that are not in the override set. Guarded by `!doc.has(...)` so it never clobbers a user's existing list. Regenerates the migration-monorepo-yarn4 global snap (only fixture that captures `.yarnrc.yml`). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 7ed01a5 commit e50937c

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

packages/cli/snap-tests-global/migration-monorepo-yarn4/snap.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ export default defineConfig({
8181

8282
> cat .yarnrc.yml # check .yarnrc.yml
8383
nodeLinker: node-modules
84+
npmPreapprovedPackages:
85+
- vitest
86+
- '@vitest/*'
8487
catalog:
8588
vite: npm:@voidzero-dev/vite-plus-core@latest
8689
vitest: <semver>

packages/cli/src/migration/migrator.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2261,6 +2261,16 @@ function rewriteYarnrcYml(projectPath: string): void {
22612261
if (!doc.has('nodeLinker')) {
22622262
doc.set('nodeLinker', 'node-modules');
22632263
}
2264+
// Vite+ pins the vitest family to exact, sometimes freshly published,
2265+
// versions. Yarn 4 hardened mode (auto-enabled for public-PR installs)
2266+
// quarantines packages younger than `npmMinimalAgeGate`, which makes
2267+
// `yarn install` fail on a just-released vitest pin. Preapprove the family
2268+
// so the Vite+-managed versions install regardless of release age; the
2269+
// `@vitest/*` glob also covers the optional `@vitest/browser-*` peers that
2270+
// are not in the override set.
2271+
if (!doc.has('npmPreapprovedPackages')) {
2272+
doc.set('npmPreapprovedPackages', ['vitest', '@vitest/*']);
2273+
}
22642274
// catalog
22652275
rewriteCatalog(doc);
22662276
});

0 commit comments

Comments
 (0)