Skip to content

Commit 91eec75

Browse files
committed
fix(cli): create empty yarn.lock for yarn projects in migration
Yarn Berry's hardened mode on public PRs forbids lockfile creation but allows updating an existing one. The YARN_ENABLE_HARDENED_MODE env var cannot override this auto-detection. Instead, create an empty yarn.lock during migration so yarn install treats it as an update.
1 parent 174331e commit 91eec75

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

.github/workflows/test-vp-create.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,6 @@ jobs:
144144
# Force full dependency rewriting so the library template's existing
145145
# vite-plus dep gets overridden with the local tgz
146146
VP_FORCE_MIGRATE: '1'
147-
# Yarn Berry enables hardened mode on public PRs, blocking lockfile creation
148-
YARN_ENABLE_HARDENED_MODE: false
149147
steps:
150148
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
151149

packages/cli/src/migration/migrator.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,6 +1126,14 @@ function rewriteYarnrcYml(projectPath: string): void {
11261126
// catalog
11271127
rewriteCatalog(doc);
11281128
});
1129+
1130+
// Ensure yarn.lock exists so yarn install can update it in CI.
1131+
// Yarn Berry's hardened mode on public PRs forbids lockfile *creation*
1132+
// but allows *updating* an existing one.
1133+
const yarnLockPath = path.join(projectPath, 'yarn.lock');
1134+
if (!fs.existsSync(yarnLockPath)) {
1135+
fs.writeFileSync(yarnLockPath, '');
1136+
}
11291137
}
11301138

11311139
/**

0 commit comments

Comments
 (0)