mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-06-17 06:29:17 +08:00
Adjust test manual e2e script to work with new init (#24583)
Summary: Since initialisation flow changed with default template, we need to adjust the script to make it work properly. [General] [Fixed] - Adjust text manual e2e script to work with new init. Pull Request resolved: https://github.com/facebook/react-native/pull/24583 Differential Revision: D15062374 Pulled By: cpojer fbshipit-source-id: 8110597b27056570784439362f12963154460613
This commit is contained in:
committed by
Facebook Github Bot
parent
c87de765f6
commit
421ffb05ae
@@ -114,9 +114,7 @@ if (
|
||||
}
|
||||
|
||||
// Change react-native version in the template's package.json
|
||||
let templatePackageJson = JSON.parse(cat('template/package.json'));
|
||||
templatePackageJson.dependencies['react-native'] = version;
|
||||
fs.writeFileSync('./template/package.json', JSON.stringify(templatePackageJson, null, 2) + '\n', 'utf-8');
|
||||
exec(`node scripts/set-rn-template-version.js ${version}`);
|
||||
|
||||
// Verify that files changed, we just do a git diff and check how many times version is added across files
|
||||
let numberOfChangedLinesWithNewVersion = exec(
|
||||
|
||||
30
scripts/set-rn-template-version.js
Executable file
30
scripts/set-rn-template-version.js
Executable file
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const version = process.argv[2];
|
||||
|
||||
if (!version) {
|
||||
console.error('Please provide a react-native version.');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const jsonPath = path.join(__dirname, '../template/package.json');
|
||||
|
||||
let templatePackageJson = require(jsonPath);
|
||||
templatePackageJson.dependencies['react-native'] = version;
|
||||
fs.writeFileSync(
|
||||
jsonPath,
|
||||
JSON.stringify(templatePackageJson, null, 2) + '\n',
|
||||
'utf-8',
|
||||
);
|
||||
@@ -76,11 +76,14 @@ npm pack
|
||||
PACKAGE=$(pwd)/react-native-$PACKAGE_VERSION.tgz
|
||||
success "Package bundled ($PACKAGE)"
|
||||
|
||||
node scripts/set-rn-template-version.js "file:$PACKAGE"
|
||||
success "React Native version changed in the template"
|
||||
|
||||
project_name="RNTestProject"
|
||||
|
||||
cd /tmp/
|
||||
rm -rf "$project_name"
|
||||
react-native init "$project_name" --version $PACKAGE
|
||||
node "$repo_root/cli.js" init "$project_name" --template "$repo_root"
|
||||
|
||||
info "Double checking the versions in package.json are correct:"
|
||||
grep "\"react-native\": \".*react-native-$PACKAGE_VERSION.tgz\"" "/tmp/${project_name}/package.json" || error "Incorrect version number in /tmp/${project_name}/package.json"
|
||||
|
||||
Reference in New Issue
Block a user