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 b236f9bd82

## Changelog:
[Internal] - Update release testing to work with the new template

Reviewed By: cortinico

Differential Revision: D58782241

fbshipit-source-id: be9f6d4310d3a83e6cc0df4bb690c746229c7ae3
This commit is contained in:
Riccardo Cipolleschi 2024-06-20 03:24:29 -07:00 committed by Facebook GitHub Bot
parent bb886d751f
commit b04d0d0c8c

View File

@ -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');