From b04d0d0c8cc8912b9f75fc40fb45c0cdc2b1163e Mon Sep 17 00:00:00 2001 From: Riccardo Cipolleschi Date: Thu, 20 Jun 2024 03:24:29 -0700 Subject: [PATCH] Port Update the testing script to run with the community template (#45064) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/45064 This changes port back in main the changes we made in the Stable branch with https://github.com/facebook/react-native/commit/b236f9bd82374e5cf92e1ad622bba3b14f948a04 ## Changelog: [Internal] - Update release testing to work with the new template Reviewed By: cortinico Differential Revision: D58782241 fbshipit-source-id: be9f6d4310d3a83e6cc0df4bb690c746229c7ae3 --- scripts/release-testing/test-e2e-local.js | 28 +++++++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/scripts/release-testing/test-e2e-local.js b/scripts/release-testing/test-e2e-local.js index 0242df6dfa3..a4710c41458 100644 --- a/scripts/release-testing/test-e2e-local.js +++ b/scripts/release-testing/test-e2e-local.js @@ -19,7 +19,6 @@ const {REPO_ROOT} = require('../consts'); const {initNewProjectFromSource} = require('../e2e/init-template-e2e'); -const updateTemplatePackage = require('../releases/update-template-package'); const { checkPackagerRunning, launchPackagerInSeparateWindow, @@ -245,6 +244,11 @@ async function testRNTestProject( const buildType = 'dry-run'; const reactNativePackagePath = `${REPO_ROOT}/packages/react-native`; + const templateRepoFolder = '/tmp/template'; + const pathToTemplate = path.join(templateRepoFolder, 'template'); + + // Cleanup template clone folder + exec(`rm -rf ${templateRepoFolder}`); const localNodeTGZPath = `${reactNativePackagePath}/react-native-${releaseVersion}.tgz`; const mavenLocalPath = @@ -282,18 +286,32 @@ async function testRNTestProject( } } - updateTemplatePackage({ - 'react-native': `file://${newLocalNodeTGZ}`, - }); + // Cloning the template repo + // TODO: handle versioning of the template to make sure that we are downloading the right version of + // the template, given a specific React Native version + exec( + `git clone https://github.com/react-native-community/template ${templateRepoFolder} --depth=1`, + ); + + // Update template version. + const appPackageJsonPath = path.join(pathToTemplate, 'package.json'); + const appPackageJson = JSON.parse( + fs.readFileSync(appPackageJsonPath, 'utf8'), + ); + appPackageJson.dependencies['react-native'] = `file:${newLocalNodeTGZ}`; + fs.writeFileSync(appPackageJsonPath, JSON.stringify(appPackageJson, null, 2)); pushd('/tmp/'); debug('Creating RNTestProject from template'); + // Cleanup RNTestProject folder. This makes it easier to rerun the script when it fails + exec('rm -rf /tmp/RNTestProject'); + await initNewProjectFromSource({ projectName: 'RNTestProject', directory: '/tmp/RNTestProject', - templatePath: reactNativePackagePath, + templatePath: templateRepoFolder, }); cd('RNTestProject');