Skip to content

Commit

Permalink
Adjust test manual e2e script to work with new init (#24583)
Browse files Browse the repository at this point in the history
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: #24583

Differential Revision: D15062374

Pulled By: cpojer

fbshipit-source-id: 8110597b27056570784439362f12963154460613
  • Loading branch information
Esemesek authored and facebook-github-bot committed Apr 25, 2019
1 parent c87de76 commit 421ffb0
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
4 changes: 1 addition & 3 deletions scripts/bump-oss-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
30 changes: 30 additions & 0 deletions scripts/set-rn-template-version.js
Original file line number Diff line number Diff line change
@@ -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',
);
5 changes: 4 additions & 1 deletion scripts/test-manual-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 421ffb0

Please sign in to comment.