|
19 | 19 |
|
20 | 20 | const {REPO_ROOT} = require('../consts');
|
21 | 21 | const {initNewProjectFromSource} = require('../e2e/init-template-e2e');
|
22 |
| -const updateTemplatePackage = require('../releases/update-template-package'); |
23 | 22 | const {
|
24 | 23 | checkPackagerRunning,
|
25 | 24 | launchPackagerInSeparateWindow,
|
@@ -245,6 +244,11 @@ async function testRNTestProject(
|
245 | 244 | const buildType = 'dry-run';
|
246 | 245 |
|
247 | 246 | 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}`); |
248 | 252 | const localNodeTGZPath = `${reactNativePackagePath}/react-native-${releaseVersion}.tgz`;
|
249 | 253 |
|
250 | 254 | const mavenLocalPath =
|
@@ -282,18 +286,32 @@ async function testRNTestProject(
|
282 | 286 | }
|
283 | 287 | }
|
284 | 288 |
|
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)); |
288 | 303 |
|
289 | 304 | pushd('/tmp/');
|
290 | 305 |
|
291 | 306 | debug('Creating RNTestProject from template');
|
292 | 307 |
|
| 308 | + // Cleanup RNTestProject folder. This makes it easier to rerun the script when it fails |
| 309 | + exec('rm -rf /tmp/RNTestProject'); |
| 310 | + |
293 | 311 | await initNewProjectFromSource({
|
294 | 312 | projectName: 'RNTestProject',
|
295 | 313 | directory: '/tmp/RNTestProject',
|
296 |
| - templatePath: reactNativePackagePath, |
| 314 | + templatePath: templateRepoFolder, |
297 | 315 | });
|
298 | 316 |
|
299 | 317 | cd('RNTestProject');
|
|
0 commit comments