From 421ffb05aeb7ccf7013425bdac6b14372325bb26 Mon Sep 17 00:00:00 2001 From: Kacper Wiszczuk Date: Thu, 25 Apr 2019 01:58:43 -0700 Subject: [PATCH] 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 --- scripts/bump-oss-version.js | 4 +--- scripts/set-rn-template-version.js | 30 ++++++++++++++++++++++++++++++ scripts/test-manual-e2e.sh | 5 ++++- 3 files changed, 35 insertions(+), 4 deletions(-) create mode 100755 scripts/set-rn-template-version.js diff --git a/scripts/bump-oss-version.js b/scripts/bump-oss-version.js index a9acfc52f..e6cf3751f 100755 --- a/scripts/bump-oss-version.js +++ b/scripts/bump-oss-version.js @@ -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( diff --git a/scripts/set-rn-template-version.js b/scripts/set-rn-template-version.js new file mode 100755 index 000000000..228cdb620 --- /dev/null +++ b/scripts/set-rn-template-version.js @@ -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', +); diff --git a/scripts/test-manual-e2e.sh b/scripts/test-manual-e2e.sh index 84affa42d..328f60f21 100755 --- a/scripts/test-manual-e2e.sh +++ b/scripts/test-manual-e2e.sh @@ -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"