Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cli][upgrade] Use Yarn if available #11225

Closed
wants to merge 2 commits into from

Conversation

mkonicek
Copy link
Contributor

@mkonicek mkonicek commented Nov 30, 2016

Motivation

If the project is using yarn to manage its dependencies, we should be running 'yarn add' to upgrade the React Native dependency, rather than 'npm install'.

Test plan (required)

Running in a project that's in a bad state:

Error: react-native version in "package.json" (0.29.2) doesn't match the installed version in "node_modules" (0.38.0).
Try running "yarn" to fix this.

Removed yarn.lock file, ran again:

Error: react-native version in "package.json" (0.29.2) doesn't match the installed version in "node_modules" (0.38.0).
Try running "npm install" to fix this.

Running inside a folder that doesn't contain a package.json file:

Error: Unable to find "/Users/mkonicek/Zero29App/package.json" or "/Users/mkonicek/Zero29App/node_modules/react-native/package.json". Make sure you ran "yarn" and that you are inside a React Native project.

Removed yarn.lock file, ran again:

Error: Unable to find "/Users/mkonicek/Zero29App/package.json" or "/Users/mkonicek/Zero29App/node_modules/react-native/package.json". Make sure you ran "npm install" and that you are inside a React Native project.

Success case:

Before, package.json contains:

"dependencies": {
  "react": "15.2.1",
  "react-native": "0.29.2"
}

Ran react-native-git-upgrade in project folder:

The app iupgr
Logs:

git-upgrade info Check for updates
git-upgrade info Using yarn 0.17.8
...
git-upgrade info Install the new version 
...
git-upgrade info Upgrade done

package.json contains:

"dependencies": {
  "react": "15.2.1",
  "react-native": "^0.38.0"
}

node_modules/react-native/package.json contains "version": "0.38.0".

Removed .yarn.lock file, the react-native-git-upgrade tool worked as before (without this PR).

Ran react-native-git-upgrade --help:

Usage: react-native-git-upgrade [version] [options]


Commands:

[Version]     upgrades React Native and app templates to the desired version
              (latest, if not specified)

Options:

-h, --help    output usage information
-v, --version output the version number
--verbose output debugging info
--npm force using the npm client even if your project uses yarn

The app upgraded from v0.29 to v0.38 runs:

screenshot 2016-12-01 21 05 23

@facebook-github-bot
Copy link
Contributor

By analyzing the blame information on this pull request, we identified @ncuillery to be a potential reviewer.

@ncuillery
Copy link
Contributor

LGTM

@mkonicek mkonicek force-pushed the upgrade_use_yarn branch 3 times, most recently from 93ce547 to a7b4dd2 Compare December 1, 2016 21:37
@mkonicek
Copy link
Contributor Author

mkonicek commented Dec 1, 2016

@facebook-github-bot shipit-ninja

@facebook-github-bot
Copy link
Contributor

Normally, mkonicek, someone else should review and ship your pull request. However, we will trust that you know what you are doing. Shipping!

@facebook-github-bot facebook-github-bot added the Import Started This pull request has been imported. This does not imply the PR has been approved. label Dec 1, 2016
@facebook-github-bot
Copy link
Contributor

@mkonicek has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

robclouth pushed a commit to robclouth/react-native that referenced this pull request Dec 7, 2016
Summary:
**Motivation**

If the project is using yarn to manage its dependencies, we should be running 'yarn add' to upgrade the React Native dependency, rather than 'npm install'.

**Test plan (required)**

Running in a project that's in a bad state:

    Error: react-native version in "package.json" (0.29.2) doesn't match the installed version in "node_modules" (0.38.0).
    Try running "yarn" to fix this.

Removed yarn.lock file, ran again:

    Error: react-native version in "package.json" (0.29.2) doesn't match the installed version in "node_modules" (0.38.0).
    Try running "npm install" to fix this.

Running inside a folder that doesn't contain a `package.json` file:

    Error: Unable to find "/Users/mkonicek/Zero29App/package.json" or "/Users/mkonicek/Zero29App/node_modules/react-native/package.json". Make sure you ran "yarn" and that you are inside a React Native project.

Removed yarn.lock file, ran again:

    Error: Unable to find "/Users/mkonicek/Zero29App/package.json" or "/Users/
Closes facebook#11225

Differential Revision: D4261102

Pulled By: mkonicek

fbshipit-source-id: b44ae91fe46f2c81b14616ca2868cc171692c895
mkonicek pushed a commit that referenced this pull request Dec 12, 2016
Summary:
**Motivation**

If the project is using yarn to manage its dependencies, we should be running 'yarn add' to upgrade the React Native dependency, rather than 'npm install'.

**Test plan (required)**

Running in a project that's in a bad state:

    Error: react-native version in "package.json" (0.29.2) doesn't match the installed version in "node_modules" (0.38.0).
    Try running "yarn" to fix this.

Removed yarn.lock file, ran again:

    Error: react-native version in "package.json" (0.29.2) doesn't match the installed version in "node_modules" (0.38.0).
    Try running "npm install" to fix this.

Running inside a folder that doesn't contain a `package.json` file:

    Error: Unable to find "/Users/mkonicek/Zero29App/package.json" or "/Users/mkonicek/Zero29App/node_modules/react-native/package.json". Make sure you ran "yarn" and that you are inside a React Native project.

Removed yarn.lock file, ran again:

    Error: Unable to find "/Users/mkonicek/Zero29App/package.json" or "/Users/
Closes #11225

Differential Revision: D4261102

Pulled By: mkonicek

fbshipit-source-id: b44ae91fe46f2c81b14616ca2868cc171692c895
DanielMSchmidt pushed a commit to DanielMSchmidt/react-native that referenced this pull request Jan 4, 2017
Summary:
**Motivation**

If the project is using yarn to manage its dependencies, we should be running 'yarn add' to upgrade the React Native dependency, rather than 'npm install'.

**Test plan (required)**

Running in a project that's in a bad state:

    Error: react-native version in "package.json" (0.29.2) doesn't match the installed version in "node_modules" (0.38.0).
    Try running "yarn" to fix this.

Removed yarn.lock file, ran again:

    Error: react-native version in "package.json" (0.29.2) doesn't match the installed version in "node_modules" (0.38.0).
    Try running "npm install" to fix this.

Running inside a folder that doesn't contain a `package.json` file:

    Error: Unable to find "/Users/mkonicek/Zero29App/package.json" or "/Users/mkonicek/Zero29App/node_modules/react-native/package.json". Make sure you ran "yarn" and that you are inside a React Native project.

Removed yarn.lock file, ran again:

    Error: Unable to find "/Users/mkonicek/Zero29App/package.json" or "/Users/
Closes facebook#11225

Differential Revision: D4261102

Pulled By: mkonicek

fbshipit-source-id: b44ae91fe46f2c81b14616ca2868cc171692c895
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Import Started This pull request has been imported. This does not imply the PR has been approved.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants