Skip to content

Commit f243675

Browse files
committed
fix(e2e): Temporarily hardcode Metro 0.83.2 for E2E tests
1 parent e74e877 commit f243675

2 files changed

Lines changed: 52 additions & 0 deletions

File tree

dev-packages/e2e-tests/cli.mjs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,19 @@ if (actions.includes('create')) {
125125
// yarn v3 won't install dependencies in a sub project without a yarn.lock file present
126126
fs.writeFileSync(`${appDir}/yarn.lock`, '');
127127

128+
// Only apply the package.json patch for newer RN versions
129+
const versionNumber = parseFloat(RNVersion.replace(/[^\d.]/g, ''));
130+
if (versionNumber >= 0.80) {
131+
execSync(`${patchScriptsDir}/rn.patch.package.json.js --path package.json`, {
132+
stdio: 'inherit',
133+
cwd: appDir,
134+
env: env,
135+
});
136+
} else {
137+
console.log(`Skipping rn.patch.package.json.js for RN ${RNVersion} (< 0.80)`);
138+
}
139+
140+
128141
execSync(`yarn install`, {
129142
stdio: 'inherit',
130143
cwd: appDir,
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env node
2+
3+
const fs = require('fs');
4+
const path = require('path');
5+
const { argv, cwd } = require('process');
6+
const parseArgs = require('minimist');
7+
const { debug } = require('@sentry/core');
8+
debug.enable();
9+
10+
const args = parseArgs(argv.slice(2), { string: ['app','path','file'], alias: { path: ['file'] } });
11+
12+
function resolvePkgPath() {
13+
if (args.path) {
14+
const p = path.resolve(args.path);
15+
if (!p.endsWith('package.json')) throw new Error(`--path must point to package.json, got: ${p}`);
16+
return p;
17+
}
18+
if (args.app) return path.join(path.resolve(args.app), 'package.json');
19+
return path.join(cwd(), 'package.json');
20+
}
21+
22+
const pkgPath = resolvePkgPath();
23+
if (!fs.existsSync(pkgPath)) throw new Error(`package.json not found at: ${pkgPath}`);
24+
25+
const raw = fs.readFileSync(pkgPath, 'utf8');
26+
let pkg;
27+
try { pkg = JSON.parse(raw); } catch (e) { throw new Error(`Invalid JSON: ${e.message}`); }
28+
29+
const METRO = '0.83.2';
30+
31+
pkg.overrides = pkg.overrides || {};
32+
pkg.overrides.metro = METRO;
33+
pkg.resolutions = pkg.resolutions || {};
34+
pkg.resolutions['metro'] = METRO;
35+
36+
fs.writeFileSync(pkgPath + '.bak', raw);
37+
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n');
38+
39+
debug.log('Patched package.json: overrides.metro and resolutions.metro set to', METRO);

0 commit comments

Comments
 (0)