Skip to content

Commit b04d0d0

Browse files
cipolleschifacebook-github-bot
authored andcommitted
Port Update the testing script to run with the community template (facebook#45064)
Summary: Pull Request resolved: facebook#45064 This changes port back in main the changes we made in the Stable branch with facebook@b236f9b ## Changelog: [Internal] - Update release testing to work with the new template Reviewed By: cortinico Differential Revision: D58782241 fbshipit-source-id: be9f6d4310d3a83e6cc0df4bb690c746229c7ae3
1 parent bb886d7 commit b04d0d0

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

scripts/release-testing/test-e2e-local.js

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
const {REPO_ROOT} = require('../consts');
2121
const {initNewProjectFromSource} = require('../e2e/init-template-e2e');
22-
const updateTemplatePackage = require('../releases/update-template-package');
2322
const {
2423
checkPackagerRunning,
2524
launchPackagerInSeparateWindow,
@@ -245,6 +244,11 @@ async function testRNTestProject(
245244
const buildType = 'dry-run';
246245

247246
const reactNativePackagePath = `${REPO_ROOT}/packages/react-native`;
247+
const templateRepoFolder = '/tmp/template';
248+
const pathToTemplate = path.join(templateRepoFolder, 'template');
249+
250+
// Cleanup template clone folder
251+
exec(`rm -rf ${templateRepoFolder}`);
248252
const localNodeTGZPath = `${reactNativePackagePath}/react-native-${releaseVersion}.tgz`;
249253

250254
const mavenLocalPath =
@@ -282,18 +286,32 @@ async function testRNTestProject(
282286
}
283287
}
284288

285-
updateTemplatePackage({
286-
'react-native': `file://${newLocalNodeTGZ}`,
287-
});
289+
// Cloning the template repo
290+
// TODO: handle versioning of the template to make sure that we are downloading the right version of
291+
// the template, given a specific React Native version
292+
exec(
293+
`git clone https://github.com/react-native-community/template ${templateRepoFolder} --depth=1`,
294+
);
295+
296+
// Update template version.
297+
const appPackageJsonPath = path.join(pathToTemplate, 'package.json');
298+
const appPackageJson = JSON.parse(
299+
fs.readFileSync(appPackageJsonPath, 'utf8'),
300+
);
301+
appPackageJson.dependencies['react-native'] = `file:${newLocalNodeTGZ}`;
302+
fs.writeFileSync(appPackageJsonPath, JSON.stringify(appPackageJson, null, 2));
288303

289304
pushd('/tmp/');
290305

291306
debug('Creating RNTestProject from template');
292307

308+
// Cleanup RNTestProject folder. This makes it easier to rerun the script when it fails
309+
exec('rm -rf /tmp/RNTestProject');
310+
293311
await initNewProjectFromSource({
294312
projectName: 'RNTestProject',
295313
directory: '/tmp/RNTestProject',
296-
templatePath: reactNativePackagePath,
314+
templatePath: templateRepoFolder,
297315
});
298316

299317
cd('RNTestProject');

0 commit comments

Comments
 (0)