react-native/react-native-git-upgrade
Aaron Brager 4fbd244b9a Suggest git apply --reject for failed upgrades
Summary:
The upgrade script uses `git apply --3way`:

4906f8d28c/react-native-git-upgrade/cliEntry.js (L368-L369)

If you've already upgraded something that React Native upgraded, this will silently fail. For example if you have already upgraded Gradle to the version available in the new version of React Native, the 3-way patch will fail. In this case, the upgraded version is installed into `node_modules` but `package.json` is not updated. More context, discussion, and information is in https://github.com/facebook/react-native/issues/12112#issuecomment-292619346.

Until a more robust solution is implemented, this PR proposes to mitigate the effects of the problem by informing the user of the possible issue and instructing them of a workaround.

In an affected project, I ran `react-native-git-upgrade` after applying my patch.

As expected, I now receive the following output:

![image](https://user-images.githubusercontent.com/789577/38165770-6209ac68-34de-11e8-9d96-7c782e9ef7ce.png)

After running the suggested command, `git status` now shows me the two rejections:

![image](https://user-images.githubusercontent.com/789577/38165796-d10ca7c8-34de-11e8-9037-8427513e3a84.png)

And I can now [manually apply](https://stackoverflow.com/a/28569128/1445366) these changes.

[CLI] [ENHANCEMENT] [react-native-git-upgrade/cliEntry.js] - Provide instructions for upgrading React Native when 3-way merges don't apply
Closes https://github.com/facebook/react-native/pull/18636

Differential Revision: D7603073

Pulled By: hramos

fbshipit-source-id: 32d387e1ee67d8b182d248c585cd33ba94808357
2018-04-12 11:57:25 -07:00
..
README.md Fix documentation links 2018-01-09 15:46:47 -08:00
checks.js Update license headers for MIT license 2018-02-16 18:31:53 -08:00
cli.js Update license headers for MIT license 2018-02-16 18:31:53 -08:00
cliEntry.js Suggest git apply --reject for failed upgrades 2018-04-12 11:57:25 -07:00
index.js Update license headers for MIT license 2018-02-16 18:31:53 -08:00
package.json Update to MIT license 2018-02-16 18:31:53 -08:00
yarn.js Update license headers for MIT license 2018-02-16 18:31:53 -08:00

README.md

React Native Git Upgrade

This tool makes upgrading your apps to a new version of React Native easier than the stock react-native upgrade command.

It uses Git under the hood to automatically resolve merge conflicts in project templates (native iOS and Android files, .flowconfig etc.). These conflicts happen when a new React Native version introduces changes to those files and you have local changes in those files too, which is quite common.

Usage

See the Upgrading docs on the React Native website.

Basic usage:

$ npm install -g react-native-git-upgrade
$ cd MyReactNativeApp
$ react-native-git-upgrade