Easier Upgrades Thanks to Git

  • As a conclusion, I would say, enjoy the feature and feel free to suggest improvements, report issues and especially send pull requests .
  • If we had embedded the implementation in the local-cli, you wouldn’t be able to enjoy this feature when using old versions of React Native.
  • $ npm install – g react – native – git – upgrade $ cd MyProject $ react – native – git – upgrade 0.38 .
  • The react-native-git-upgrade is provided so anyone can enjoy this improved experience today while using older versions of React Native.
  • The patch contains all the changes made in the React Native templates between the version your app is using and the new version.

None of those options is ideal. By overwriting the file we lose our local changes. By not overwriting we don’t get the latest updates.

@ncuillery: No more “Keep or override” dilemma while upgrading #reactnative. A new upgrading process is born!

Upgrading to new versions of React Native has been difficult. You might have seen something like this before:

None of those options is ideal. By overwriting the file we lose our local changes. By not overwriting we don’t get the latest updates.

and uses Git behind the scenes to resolve conflicts automatically whenever possible.

globally and run it inside your project directory:

$ npm install -g react-native-git-upgrade $ cd MyProject $ react-native-git-upgrade 0.38 . 0

Example output:

with no arguments to upgrade to the latest version of React Native.

after an upgrade.

We have designed the implementation to be as little intrusive as possible. It is entirely based on a local Git repository created on-the-fly in a temporary directory. It won’t interfere with your project repository (no matter what VCS you use: Git, SVN, Mercurial, … or none). Your sources are restored in case of unexpected errors.

How does it work? #

The key step is generating a Git patch. The patch contains all the changes made in the React Native templates between the version your app is using and the new version.

commands uses). Then, after the native apps have been generated from the templates in both the current version and the new version, Git is able to produce a patch that is adapted to your project (i.e. containing your app name):

process would have prompted you for any small difference, Git is able to merge most of the changes automatically using its 3-way merge algorithm and eventually leave us with familiar conflict delimiters:

These conflicts are generally easy to reason about. The delimiter ours stands for “your team” whereas theirs could be seen as “the React Native team”.

directory.

As we mentioned above, the process has to be started from your current React Native version. If we had embedded the implementation in the local-cli, you wouldn’t be able to enjoy this feature when using old versions of React Native. For example, you wouldn’t be able to upgrade from 0.29.2 to 0.38.0 if this new upgrade code was only released in 0.38.0.

Upgrading based on Git is a big improvement in developer experience and it is important to make it available to everyone. By using a separate package react-native-git-upgrade installed globally you can use this new code today no matter what version of React Native your project is using.

package to be able to evaluate the old template in order to create the patch.

starting with React Native version 0.40.0.

is provided so anyone can enjoy this improved experience today while using older versions of React Native.

As a conclusion, I would say, enjoy the feature and feel free to suggest improvements, report issues and especially send pull requests. Each environment is a bit different and each React Native project is different, and we need your feedback to make this work well for everyone.

I would like to thank the awesome companies Zenika and M6 Web without whom none of this would have been possible!

Easier Upgrades Thanks to Git