Skip to content

Commit 76e557f

Browse files
antonisclaude
andauthored
build: Migrate Yarn from Berry v3.6.4 to v4.17.0 (#6417)
* build: Migrate Yarn from Berry v3.6.4 to v4.17.0 Yarn Berry v3 is end-of-life (last release 3.8.6, 2024). Bumping to the intermediate 3.8.6 is not viable: its bundled compat/typescript patch fails to apply to the modern TypeScript versions used across the workspaces (Cannot apply hunk). Yarn 4 ships an up-to-date patch that applies cleanly, so v4 is the working path. - Bump packageManager to yarn@4.17.0 (corepack-managed) - Pin downlevel-dts's TypeScript to a stable 5.9.3 via resolutions; its typescript@npm:next dependency froze to a nightly build that no yarn compat patch (v3 or v4) can patch - Add enableScripts: true to .yarnrc.yml to preserve prior behavior; yarn 4 flipped this default to false, which would otherwise disable dependency build scripts (geckodriver, nx, pmd-bin, sharp) Dev-tooling only: the published @sentry/react-native package carries no yarn config, so there is no consumer impact. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(e2e): Disable yarn 4 release-age gate for generated test app The e2e CLI creates a throwaway RN app with an empty yarn.lock and runs a fresh install. Under yarn 4 (this branch's package manager), the install auto-enables hardened mode on public-PR CI and quarantines any package newer than npmMinimalAgeGate (default 1 day). A just-published first-party @sentry/* version — e.g. right after a JS SDK bump — is therefore rejected and fails the install. Write enableHardenedMode: false and npmMinimalAgeGate: 0 into the generated app's .yarnrc.yml. The release-age gate is inappropriate for an ephemeral e2e app that must install freshly-published SDK packages. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(e2e): Disable yarn 4 release-age gate only on yarn-4 test apps The previous fix wrote npmMinimalAgeGate/enableHardenedMode unconditionally into the generated app's .yarnrc.yml. That broke RN versions whose app pins yarn 3 (e.g. 0.71.19): yarn 3 hard-errors on the unknown settings, and it has no release-age gate to begin with. enableHardenedMode isn't even a valid setting on the yarn the older apps use. Probe whether the app's yarn supports npmMinimalAgeGate (yarn 4 exits 0, yarn 3 exits 1) and only append npmMinimalAgeGate: 0 when supported. Verified against yarn 3.6.4 and 4.17.0: the yarn-4 app clears the quarantine, the yarn-3 app installs with a minimal yarnrc and no unknown-setting error. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(e2e): Disable yarn 4 release-age gate for ts3.8 type-check install Same root cause as the e2e app fix, different location. run-type-check.sh does a fresh `yarn install` after yalc-adding @sentry/react-native, which re-resolves transitive @sentry/* deps. Under yarn 4, a just-published SDK version (e.g. right after a JS SDK bump) is quarantined by npmMinimalAgeGate (default 1 day, auto-enabled by hardened mode on public-PR CI) and fails the install. This workspace always runs on the repo's yarn 4, so pass YARN_NPM_MINIMAL_AGE_GATE=0 inline to the install. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 4acd4e9 commit 76e557f

6 files changed

Lines changed: 7215 additions & 7207 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,4 @@ samples/*/.env
107107
# Auto-generated by dotagents — do not commit these files.
108108
agents.lock
109109
.agents/.gitignore
110+
tsconfig.tsbuildinfo

.yarnrc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
enableScripts: true
2+
13
nmHoistingLimits: workspaces
24

35
nodeLinker: node-modules

dev-packages/e2e-tests/cli.mjs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,25 @@ if (actions.includes('create')) {
160160
fs.writeFileSync(appPackageJsonPath, JSON.stringify(appPackageJson, null, 2) + '\n');
161161

162162
// original yarnrc contains the exact yarn version which causes corepack to fail to install yarn v3
163-
fs.writeFileSync(`${appDir}/.yarnrc.yml`, 'nodeLinker: node-modules', { encoding: 'utf-8' });
163+
fs.writeFileSync(`${appDir}/.yarnrc.yml`, 'nodeLinker: node-modules\n', { encoding: 'utf-8' });
164+
165+
// The generated app pins its own yarn version (varies by RN version: e.g. v3 for
166+
// older RN, v4 for newer). yarn 4 quarantines any package newer than
167+
// npmMinimalAgeGate (default 1 day) — and auto-enables that gate on public-PR CI —
168+
// so a just-published first-party @sentry/* version (e.g. right after a JS SDK bump)
169+
// resolved fresh from this app's empty lockfile fails the install. Disable the gate,
170+
// but only when the app's yarn supports the setting: yarn 3 hard-errors on unknown
171+
// settings, and it has no age gate to begin with. Probe support rather than guess a
172+
// version threshold.
173+
const appYarnSupportsAgeGate =
174+
execSync(`yarn config npmMinimalAgeGate > /dev/null 2>&1; echo $?`, {
175+
cwd: appDir,
176+
env: env,
177+
encoding: 'utf-8',
178+
}).trim() === '0';
179+
if (appYarnSupportsAgeGate) {
180+
fs.appendFileSync(`${appDir}/.yarnrc.yml`, 'npmMinimalAgeGate: 0\n', { encoding: 'utf-8' });
181+
}
164182
// yarn v3 won't install dependencies in a sub project without a yarn.lock file present
165183
fs.writeFileSync(`${appDir}/yarn.lock`, '');
166184

dev-packages/type-check/run-type-check.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@ cd "${__dirpath}/ts3.8-test"
1818
yalc add @sentry/expo-upload-sourcemaps
1919
yalc add @sentry/react-native
2020

21-
yarn install
21+
# Disable yarn 4's release-age gate for this fresh install. The yalc-linked
22+
# @sentry/react-native pulls transitive @sentry/* deps that get resolved fresh, so a
23+
# just-published SDK version (e.g. right after a JS SDK bump) would be quarantined
24+
# (default npmMinimalAgeGate is 1 day, and hardened mode auto-enables on public-PR CI)
25+
# and fail the install. This workspace always runs on the repo's yarn 4, so the
26+
# setting is always valid here.
27+
YARN_NPM_MINIMAL_AGE_GATE=0 yarn install
2228

2329
# Re-add yalc packages to ensure they are in node_modules (yarn might have removed them)
2430
yalc add @sentry/expo-upload-sourcemaps

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,10 @@
134134
"socks": "^2.8.8",
135135
"@appium/support@npm:7.0.6/uuid": "^13.0.1",
136136
"node-simctl@npm:8.1.6/uuid": "^13.0.1",
137-
"shell-quote": "^1.8.4"
137+
"shell-quote": "^1.8.4",
138+
"downlevel-dts@npm:0.11.0/typescript": "5.9.3"
138139
},
139140
"version": "0.0.0",
140141
"name": "sentry-react-native",
141-
"packageManager": "yarn@3.6.4+sha512.e70835d4d6d62c07be76b3c1529cb640c7443f0fe434ef4b6478a5a399218cbaf1511b396b3c56eb03bc86424cff2320f6167ad2fde273aa0df6e60b7754029f"
142+
"packageManager": "yarn@4.17.0+sha512.c2957de2f9025ab14d63b24d0d8be1f1655810e22c341042c27f7ecd017b180ec12db73d69ac366d71b304ef9f069349ce462de96f04f8f1da317f4f762c95ae"
142143
}

0 commit comments

Comments
 (0)