Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions dev-packages/e2e-tests/cli.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@
// yarn v3 won't install dependencies in a sub project without a yarn.lock file present
fs.writeFileSync(`${appDir}/yarn.lock`, '');

execSync(`${patchScriptsDir}/rn.patch.package.json.js --path package.json`, {
Comment thread Fixed
stdio: 'inherit',
cwd: appDir,
env: env,
});

execSync(`yarn install`, {
stdio: 'inherit',
cwd: appDir,
Expand Down
39 changes: 39 additions & 0 deletions dev-packages/e2e-tests/patch-scripts/rn.patch.package.json.js
Original file line number Diff line number Diff line change
@@ -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.1';

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);
Loading