Skip to content

Commit 421ffb0

Browse files
Esemesekfacebook-github-bot
authored andcommittedApr 25, 2019
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: #24583 Differential Revision: D15062374 Pulled By: cpojer fbshipit-source-id: 8110597b27056570784439362f12963154460613
1 parent c87de76 commit 421ffb0

File tree

3 files changed

+35
-4
lines changed

3 files changed

+35
-4
lines changed
 

‎scripts/bump-oss-version.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,7 @@ if (
114114
}
115115

116116
// Change react-native version in the template's package.json
117-
let templatePackageJson = JSON.parse(cat('template/package.json'));
118-
templatePackageJson.dependencies['react-native'] = version;
119-
fs.writeFileSync('./template/package.json', JSON.stringify(templatePackageJson, null, 2) + '\n', 'utf-8');
117+
exec(`node scripts/set-rn-template-version.js ${version}`);
120118

121119
// Verify that files changed, we just do a git diff and check how many times version is added across files
122120
let numberOfChangedLinesWithNewVersion = exec(

‎scripts/set-rn-template-version.js

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @format
8+
*/
9+
10+
'use strict';
11+
12+
const fs = require('fs');
13+
const path = require('path');
14+
15+
const version = process.argv[2];
16+
17+
if (!version) {
18+
console.error('Please provide a react-native version.');
19+
process.exit(1);
20+
}
21+
22+
const jsonPath = path.join(__dirname, '../template/package.json');
23+
24+
let templatePackageJson = require(jsonPath);
25+
templatePackageJson.dependencies['react-native'] = version;
26+
fs.writeFileSync(
27+
jsonPath,
28+
JSON.stringify(templatePackageJson, null, 2) + '\n',
29+
'utf-8',
30+
);

‎scripts/test-manual-e2e.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,14 @@ npm pack
7676
PACKAGE=$(pwd)/react-native-$PACKAGE_VERSION.tgz
7777
success "Package bundled ($PACKAGE)"
7878

79+
node scripts/set-rn-template-version.js "file:$PACKAGE"
80+
success "React Native version changed in the template"
81+
7982
project_name="RNTestProject"
8083

8184
cd /tmp/
8285
rm -rf "$project_name"
83-
react-native init "$project_name" --version $PACKAGE
86+
node "$repo_root/cli.js" init "$project_name" --template "$repo_root"
8487

8588
info "Double checking the versions in package.json are correct:"
8689
grep "\"react-native\": \".*react-native-$PACKAGE_VERSION.tgz\"" "/tmp/${project_name}/package.json" || error "Incorrect version number in /tmp/${project_name}/package.json"

0 commit comments

Comments
 (0)
Please sign in to comment.