Bump react-native version in template in release script (#24262)

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: https://github.com/facebook/react-native/pull/24262

Differential Revision: D14724831

Pulled By: cpojer

fbshipit-source-id: 164d13001a889941398f3db3b9b96eb9d5114cc3
This commit is contained in:
Kacper Wiszczuk
2019-04-02 08:11:28 -07:00
committed by Facebook Github Bot
parent 90c51a8b6f
commit 6df2edeb2a
2 changed files with 12 additions and 7 deletions

View File

@@ -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();
@@ -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',
@@ -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',
);
@@ -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?`,

View File

@@ -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",