Skip to content

Commit

Permalink
Bump react-native version in template in release script (facebook#24262)
Browse files Browse the repository at this point in the history
Summary:
Since template has a fixed version in `template/package.json`, we want to automate this process.

[General] [Added] - Bump react-native in `template/package.json`
Pull Request resolved: facebook#24262

Differential Revision: D14724831

Pulled By: cpojer

fbshipit-source-id: 164d13001a889941398f3db3b9b96eb9d5114cc3
  • Loading branch information
Esemesek authored and zhongwuzw committed Apr 9, 2019
1 parent 72ec728 commit 6e010f8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
17 changes: 11 additions & 6 deletions scripts/bump-oss-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ let argv = yargs.option('r', {
default: 'origin',
}).argv;

// - check we are in release branch, e.g. 0.33-stable
// Check we are in release branch, e.g. 0.33-stable
let branch = exec('git symbolic-ref --short HEAD', {
silent: true,
}).stdout.trim();
Expand Down Expand Up @@ -100,7 +100,7 @@ let packageJson = JSON.parse(cat('package.json'));
packageJson.version = version;
fs.writeFileSync('package.json', JSON.stringify(packageJson, null, 2), 'utf-8');

// - change ReactAndroid/gradle.properties
// Change ReactAndroid/gradle.properties
if (
sed(
'-i',
Expand All @@ -113,12 +113,17 @@ if (
exit(1);
}

// verify that files changed, we just do a git diff and check how many times version is added across files
// 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');

// Verify that files changed, we just do a git diff and check how many times version is added across files
let numberOfChangedLinesWithNewVersion = exec(
`git diff -U0 | grep '^[+]' | grep -c ${version} `,
{silent: true},
).stdout.trim();
if (+numberOfChangedLinesWithNewVersion !== 2) {
if (+numberOfChangedLinesWithNewVersion !== 3) {
echo(
'Failed to update all the files. package.json and gradle.properties must have versions in them',
);
Expand All @@ -127,13 +132,13 @@ if (+numberOfChangedLinesWithNewVersion !== 2) {
exit(1);
}

// - make commit [0.21.0-rc] Bump version numbers
// Make commit [0.21.0-rc] Bump version numbers
if (exec(`git commit -a -m "[${version}] Bump version numbers"`).code) {
echo('failed to commit');
exit(1);
}

// - add tag v0.21.0-rc
// Add tag v0.21.0-rc
if (exec(`git tag v${version}`).code) {
echo(
`failed to tag the commit with v${version}, are you sure this release wasn't made earlier?`,
Expand Down
2 changes: 1 addition & 1 deletion template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"dependencies": {
"react": "16.8.1",
"react-native": "0.59.3"
"react-native": "1000.0.0"
},
"devDependencies": {
"@babel/core": "^7.3.3",
Expand Down

0 comments on commit 6e010f8

Please sign in to comment.