From f2436753451054fcba44ebbd8ac3aa5970d16584 Mon Sep 17 00:00:00 2001 From: Antonis Lilis Date: Thu, 2 Oct 2025 17:22:13 +0200 Subject: [PATCH 1/3] fix(e2e): Temporarily hardcode Metro 0.83.2 for E2E tests --- dev-packages/e2e-tests/cli.mjs | 13 +++++++ .../patch-scripts/rn.patch.package.json.js | 39 +++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100755 dev-packages/e2e-tests/patch-scripts/rn.patch.package.json.js diff --git a/dev-packages/e2e-tests/cli.mjs b/dev-packages/e2e-tests/cli.mjs index 9d8f958b80..ce0fd03351 100755 --- a/dev-packages/e2e-tests/cli.mjs +++ b/dev-packages/e2e-tests/cli.mjs @@ -125,6 +125,19 @@ if (actions.includes('create')) { // yarn v3 won't install dependencies in a sub project without a yarn.lock file present fs.writeFileSync(`${appDir}/yarn.lock`, ''); + // Only apply the package.json patch for newer RN versions + const versionNumber = parseFloat(RNVersion.replace(/[^\d.]/g, '')); + if (versionNumber >= 0.80) { + execSync(`${patchScriptsDir}/rn.patch.package.json.js --path package.json`, { + stdio: 'inherit', + cwd: appDir, + env: env, + }); + } else { + console.log(`Skipping rn.patch.package.json.js for RN ${RNVersion} (< 0.80)`); + } + + execSync(`yarn install`, { stdio: 'inherit', cwd: appDir, diff --git a/dev-packages/e2e-tests/patch-scripts/rn.patch.package.json.js b/dev-packages/e2e-tests/patch-scripts/rn.patch.package.json.js new file mode 100755 index 0000000000..93ea473374 --- /dev/null +++ b/dev-packages/e2e-tests/patch-scripts/rn.patch.package.json.js @@ -0,0 +1,39 @@ +#!/usr/bin/env node + +const fs = require('fs'); +const path = require('path'); +const { argv, cwd } = require('process'); +const parseArgs = require('minimist'); +const { debug } = require('@sentry/core'); +debug.enable(); + +const args = parseArgs(argv.slice(2), { string: ['app','path','file'], alias: { path: ['file'] } }); + +function resolvePkgPath() { + if (args.path) { + const p = path.resolve(args.path); + if (!p.endsWith('package.json')) throw new Error(`--path must point to package.json, got: ${p}`); + return p; + } + if (args.app) return path.join(path.resolve(args.app), 'package.json'); + return path.join(cwd(), 'package.json'); +} + +const pkgPath = resolvePkgPath(); +if (!fs.existsSync(pkgPath)) throw new Error(`package.json not found at: ${pkgPath}`); + +const raw = fs.readFileSync(pkgPath, 'utf8'); +let pkg; +try { pkg = JSON.parse(raw); } catch (e) { throw new Error(`Invalid JSON: ${e.message}`); } + +const METRO = '0.83.2'; + +pkg.overrides = pkg.overrides || {}; +pkg.overrides.metro = METRO; +pkg.resolutions = pkg.resolutions || {}; +pkg.resolutions['metro'] = METRO; + +fs.writeFileSync(pkgPath + '.bak', raw); +fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n'); + +debug.log('Patched package.json: overrides.metro and resolutions.metro set to', METRO); From d0604b0e593e0da175b42b4485959958e20e54b6 Mon Sep 17 00:00:00 2001 From: Antonis Lilis Date: Thu, 2 Oct 2025 17:46:37 +0200 Subject: [PATCH 2/3] Patch earlier --- dev-packages/e2e-tests/cli.mjs | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/dev-packages/e2e-tests/cli.mjs b/dev-packages/e2e-tests/cli.mjs index ce0fd03351..383391a079 100755 --- a/dev-packages/e2e-tests/cli.mjs +++ b/dev-packages/e2e-tests/cli.mjs @@ -103,6 +103,18 @@ if (actions.includes('create')) { env: env, }); + // Only apply the package.json patch for newer RN versions + const versionNumber = parseFloat(RNVersion.replace(/[^\d.]/g, '')); + if (versionNumber >= 0.80) { + execSync(`${patchScriptsDir}/rn.patch.package.json.js --path package.json`, { + stdio: 'inherit', + cwd: appDir, + env: env, + }); + } else { + console.log(`Skipping rn.patch.package.json.js for RN ${RNVersion} (< 0.80)`); + } + // Install dependencies // yalc add doesn't fail if the package is not found - it skips silently. let yalcAddOutput = execSync(`yalc add @sentry/react-native`, { cwd: appDir, env: env, encoding: 'utf-8' }); @@ -125,19 +137,6 @@ if (actions.includes('create')) { // yarn v3 won't install dependencies in a sub project without a yarn.lock file present fs.writeFileSync(`${appDir}/yarn.lock`, ''); - // Only apply the package.json patch for newer RN versions - const versionNumber = parseFloat(RNVersion.replace(/[^\d.]/g, '')); - if (versionNumber >= 0.80) { - execSync(`${patchScriptsDir}/rn.patch.package.json.js --path package.json`, { - stdio: 'inherit', - cwd: appDir, - env: env, - }); - } else { - console.log(`Skipping rn.patch.package.json.js for RN ${RNVersion} (< 0.80)`); - } - - execSync(`yarn install`, { stdio: 'inherit', cwd: appDir, From d9259f4cae42bfb339f10553b76b2d2bcbd48213 Mon Sep 17 00:00:00 2001 From: Antonis Lilis Date: Fri, 3 Oct 2025 10:59:57 +0200 Subject: [PATCH 3/3] Also pin metro config --- .../patch-scripts/rn.patch.package.json.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/dev-packages/e2e-tests/patch-scripts/rn.patch.package.json.js b/dev-packages/e2e-tests/patch-scripts/rn.patch.package.json.js index 93ea473374..a36d7693c4 100755 --- a/dev-packages/e2e-tests/patch-scripts/rn.patch.package.json.js +++ b/dev-packages/e2e-tests/patch-scripts/rn.patch.package.json.js @@ -26,14 +26,25 @@ const raw = fs.readFileSync(pkgPath, 'utf8'); let pkg; try { pkg = JSON.parse(raw); } catch (e) { throw new Error(`Invalid JSON: ${e.message}`); } -const METRO = '0.83.2'; +const METRO_VERSION = '0.83.2'; + +// List of Metro packages that need to be pinned +const METRO_PACKAGES = [ + 'metro', + 'metro-config' +]; pkg.overrides = pkg.overrides || {}; -pkg.overrides.metro = METRO; +METRO_PACKAGES.forEach(pkgName => { + pkg.overrides[pkgName] = METRO_VERSION; +}); + pkg.resolutions = pkg.resolutions || {}; -pkg.resolutions['metro'] = METRO; +METRO_PACKAGES.forEach(pkgName => { + pkg.resolutions[pkgName] = METRO_VERSION; +}); fs.writeFileSync(pkgPath + '.bak', raw); fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n'); -debug.log('Patched package.json: overrides.metro and resolutions.metro set to', METRO); +debug.log('Patched package.json: Metro packages set to', METRO_VERSION);