Summary:
Thanks for submitting a PR! Please read these instructions carefully:
- [x] Explain the **motivation** for making this change.
- [x] Provide a **test plan** demonstrating that the code is solid.
- [x] Match the **code formatting** of the rest of the codebase.
- [x] Target the `master` branch, NOT a "stable" branch.
Fixes#14081. Prevents unnecessary error output on check for yarn package manager on Windows systems.
Can't find existing tests for the CLI and JavaScript doesn't have much knowledge about this change anyhow.
Example behavior with and without the fix:
![image](https://cloud.githubusercontent.com/assets/4138357/26280348/2baeace0-3d95-11e7-9e5e-5042fb61203e.png)
Note that on master, the output contains the line "'yarn' is not recognized as an internal or external command, operable program or batch file." and on my branch, it does not.
Sign the [CLA][2], if you haven't already.
Small pull requests are much easier to review and more likely to get merged. Make sure the PR does only one thing, otherwise please split it.
Make sure all **tests pass** on both [Travis][3] and [Circle CI][4]. PRs that break tests are unlikely to be merged.
For more info, see the ["Pull Requests"][5] section of our "Contributing" guidelines.
[1]: https://medium.com/martinkonicek/what-is-a-test-plan-8bfc840ec171#.y9lcuqqi9
[2]: https://code.facebook.com/cla
[3]: https://travis-ci.org/facebook/react-native
[4]: http://circleci.com/gh/facebook/react-native
[5]: https://github.com/facebook/react-native/blob/master/CONTRIBUTING.md#pull-requests
Closes https://github.com/facebook/react-native/pull/14082
Differential Revision: D5141387
Pulled By: shergin
fbshipit-source-id: 80f9aa9ecb7d8943f0b3b87b8ebbe7828c317bbd
Summary:
PR for issue #12444
In `validateProjectName` in `react-native-cli` `name.match` is called but it's not certain that `name`is a String. This casts `name`to a String before doing the match.
I didn't find any tests for this file so I didn't add any.
Reproduce:
```
cd react-native-cli
npm install
node index.js init 123
```
Before this PR the code throws an exception, after this PR the intended `console.error` is printed.
Closes https://github.com/facebook/react-native/pull/12447
Differential Revision: D4584041
fbshipit-source-id: 117e76570aa9975ac851192b030c5a77daf19bcc
Summary:
Currently it is not trivial for people to get started with React Native. `react-native init MyApp` just creates a simple app with a single screen. People have to spend time figuring out how to add more screens, or how to accomplish very basic tasks such as rendering a list of data or handling text input.
Let's add an option: `react-native init --template navigation` - this creates a "starter" app which can be easily tweaked into the actual app the person wants to build.
**Test plan (required)**
- Checked that 'react-native init MyApp' still works as before:
<img width="487" alt="screenshot 2017-02-02 16 56 28" src="https://cloud.githubusercontent.com/assets/346214/22559344/b2348ebe-e968-11e6-9032-d1c33216f490.png">
<img width="603" alt="screenshot 2017-02-02 16 58 04" src="https://cloud.githubusercontent.com/assets/346214/22559370/c96a2ca6-e968-11e6-91f7-7afb967920fc.png">
- Ran 'react-native init MyNavApp --template'. This prints the available templates:
```
$ react-native init MyNavApp
Closes https://github.com/facebook/react-native/pull/12170
Differential Revision: D4516241
Pulled By: mkonicek
fbshipit-source-id: 8ac081157919872e92947ed64ea64fb48078614d
Summary:
**Motivation:**
According to the meeting notes published by mkonicek yesterday, RN should support `yarn run ios` and `yarn run android` commands.
**Test plan (required)**
- [x] Generate a new project and start scaffolded app using `yarn(npm) run ios(android)`
Closes https://github.com/facebook/react-native/pull/12004
Differential Revision: D4441837
Pulled By: mkonicek
fbshipit-source-id: 250f7a9e1efc59e0caa5c2c071b59b97e14e939b
Summary:
Small renaming after https://github.com/facebook/react-native/pull/11464
**Test plan**
Ran 'react-native init' and 'react-native -v' inside and outside a RN project.
Reviewed By: mkonicek
Differential Revision:
D4339481
Ninja: OSS only
fbshipit-source-id: b23daaee55907761ed0820a707f36ad70d1f1d09
Summary:
The `checkForVersionArgument` function tries to call `REACT_NATIVE_PACKAGE_JSON_PATH` which isn't defined yet prior to this change. This means that `react-native -v` never reports the version of react-native used in the current project, and in fact never detects the current project.
Fixes#11463
Closes https://github.com/facebook/react-native/pull/11464
Differential Revision: D4339279
Pulled By: mkonicek
fbshipit-source-id: 324d96c97bb06b6156e5582f889bc30b28ca68b2
Summary: We now show the npm progress bar.
Reviewed By: mkonicek
Differential Revision:
D4307964
Ninja: OSS only, nit
fbshipit-source-id: 7338ab08abe8cf6354f9a9c6d36c51b0cffc69ee
Summary:
- Added an option to override the install command in CI environments (see comment in code)
- Simplify the verbose mode
- Simplify how options are passed round
Test plan (only tested on Mac OS):
react-native init TestApp
react-native init TestApp --version 0.36
In both cases the app was generated, package.json contained the correct version (latest, or 0.36).
react-native init TestApp --verbose
Saw progress bar.
react-native init InstallCommandTest --installCommand "npm install bad-package-doesnt-exist"
404 error is printed to stdout correctly.
react-native init TestApp --installCommand "npm install react-native"
The app was generated.
react-native init InstallCommandTest --installCommand "npm install react-native --verbose" --verbose
Saw verbose output from npm.
Reviewed By: bestander
Differential Revision: D4284642
fbshipit-source-id: f2cdee52ab64831ae3ca064d50f23c5f73a0301f
Summary:
This is the manually imported version of https://github.com/facebook/react-native/pull/10786
This was mostly straigthforward by replacing the local-cli folder with the version I had in my local git checkout,
plus a few other files I listed with git diff --name-only.
Reviewed By: hramos
Differential Revision: D4201118
fbshipit-source-id: 4d0fb54b0edda9de1abba427958e420fd2ac105c
Summary:
This PR fixes#10784 by adding a `--help` and a `-h` option to `react-native-cli`.
**Test plan:**
Publish to sinopia and then outside of `react-native` project:
```
$ react-native --help #same goes for -h
Usage: react-native [command] [options]
Commands:
init <ProjectName> [options] generates a new project and installs its dependencies
Options:
-h, --help output usage information
-v, --version output the version number
```
```
$ react-native
You did not pass any commands, run `react-native --help` to see a list of all available commands.
```
**Notes:**
- There is no real consistency in the UX for `react-native-cli` and `local-cli` and even is no real consistency between the UI of `react-native [command] --help` and `react-native --help` in `local-cli` either. I tried to resemble the UX of `react-native --help` as close as possible since it's kind of the nearest neighbour.
- This *doesn't* add support for `react-native init --help` in `react-na
Closes https://github.com/facebook/react-native/pull/10828
Differential Revision: D4168266
Pulled By: hramos
fbshipit-source-id: 079917622bf5b22a3cd6414f13865c1b9c01da01
Summary:
I, like many before me, had to Google why react-native init appeared to hang the first time I tried it.
It turns out it can just take a really long time, but does not give any warning of this fact.
This patch provides such a warning.
Closes https://github.com/facebook/react-native/pull/9406
Differential Revision: D3716357
Pulled By: bestander
fbshipit-source-id: 6a460c881a20b9edb1bd1c8c5df09e5a7e5020ed
Summary:
React@15.1.0 is incompatible with React-Native@0.26.
This PR was cherry-picked to 0.26-stable branch now.
What this change does:
- react-native-cli (major release bump) saves exact versions of react-native and react (only in npm2) dependencies into package.json
- local-cli saves exact version of react (only npm3) dependency into package.json
Closes https://github.com/facebook/react-native/pull/7879
Differential Revision: D3384705
Pulled By: davidaurelio
fbshipit-source-id: d4dff418f9659bd083ae8826433a4e7c0355d03b
Summary:
Thanks for submitting a pull request! Please provide enough information so that others can review your pull request:
(You can skip this if you're fixing a typo or adding an app to the Showcase.)
Kevin: This isn't quite a typo, but it's a change to an error message.
In my experience, frequently when this error message is displayed, the command is unrecognized because I haven't run npm install, I just checked out a repo of someone else's. We could just update this error message a bit, and I think it would improve the developer experience.
Closes https://github.com/facebook/react-native/pull/7859
Differential Revision: D3379234
fbshipit-source-id: 4fb6e5bae20904871c9c4f7504013dc18b1fe707
It caused problems on Windows unfortunately and when we tried to
fix it we got: https://github.com/facebook/react-native/issues/5159
Reverting to unblock people. In the future we'll do careful rc
releases of the CLI. We should try to make the change again without
breaking anyone, regardless of OS (OSX, Linux, Windows) or npm version.
To release a new version with the fix for Windows:
https://github.com/facebook/react-native/pull/5171
Thanks a lot @tdzl2003!
Tweaked the platform check to use `process.platform`
as that's more common in the codebase. No strong preference,
just for consistency.
`npm install` prints a lot of junk like gyp warnings
and the rest of the output is not super useful for
tracking progress.
Supress the output by default, show the output with
--debug, and show verbose output with --verbose.
We get a bunch of bugs because people are running old versions of Node that don't support modern JS. We have "engines" entries in the package.json files to catch this earlier but printing an explicit error message will also make this clear.
Test Plan: Changed react-native's package.json to require Node >= 5 and got an error message when running the CLI with Node 4.
Before:
> Command `foo` unrecognized.Did you mean to run this inside a react-native project?
After:
> Command `foo` unrecognized. Did you mean to run this inside a react-native project?