Commit Graph

8 Commits

Author SHA1 Message Date
Eli White 0e5c2633ee Prettier files with shebang
Reviewed By: yungsters

Differential Revision: D7974564

fbshipit-source-id: 00db563ce24868c0fde117e981936b83cec30e48
2018-05-11 13:52:30 -07:00
Sophie Alpert 1490ab12ef Update license headers for MIT license
Summary:
Includes React Native and its dependencies Fresco, Metro, and Yoga. Excludes samples/examples/docs.

find: ^(?:( *)|( *(?:[\*~#]|::))( )? *)?Copyright (?:\(c\) )?(\d{4})\b.+Facebook[\s\S]+?BSD[\s\S]+?(?:this source tree|the same directory)\.$
replace: $1$2$3Copyright (c) $4-present, Facebook, Inc.\n$2\n$1$2$3This source code is licensed under the MIT license found in the\n$1$2$3LICENSE file in the root directory of this source tree.

Reviewed By: TheSavior, yungsters

Differential Revision: D7007050

fbshipit-source-id: 37dd6bf0ffec0923bfc99c260bb330683f35553e
2018-02-16 18:31:53 -08:00
Sean Ballew ca106043fc Fix local-cli's installedGlobally check to work on Windows platforms
Summary:
<!--
Thank you for sending the PR! We appreciate you spending the time to work on these changes.

Help us understand your motivation by explaining why you decided to make this change.

You can learn more about contributing to React Native here: http://facebook.github.io/react-native/docs/contributing.html

Happy contributing!

-->

The react-native local-cli does a check to see if it is being run from a global install or not. If running from a global install, an error is printed and the CLI exits.

This check for a global install does not work on Windows. The check of `process.argv` does not contain the expected `node_modules/.bin/react-native`. It instead contains a direct path to the `wrong-react-native.js` file, as determined by the `node_modules/.bin/react-native.cmd` entry point.

This update will, on Windows platforms, do a global check by instead looking for the existence of a package.json above the node_modules. If not found, we assume a global install and print the error.

In a react-native project, I originally tried running the local react-native cli:

```
> yarn react-native --version
yarn run v1.3.2
$ E:\myproject\node_modules\.bin\react-native --version
Looks like you installed react-native globally, maybe you meant react-native-cli?
To fix the issue, run:
npm uninstall -g react-native
npm install -g react-native-cli
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
```

I replaced the `wrong-react-native.js` with the modified version and reran the command:

```
> yarn react-native --version
yarn run v1.3.2
$ E:\myproject\node_modules\.bin\react-native --version
Scanning folders for symlinks in E:\myproject\node_modules (93ms)
0.50.3
Done in 1.86s.
```

<!--
Help reviewers and the release process by writing your own release notes

**INTERNAL and MINOR tagged notes will not be included in the next version's final release notes.**

  CATEGORY
[----------]        TYPE
[ CLI      ]   [-------------]      LOCATION
[ DOCS     ]   [ BREAKING    ]   [-------------]
[ GENERAL  ]   [ BUGFIX      ]   [-{Component}-]
[ INTERNAL ]   [ ENHANCEMENT ]   [ {File}      ]
[ IOS      ]   [ FEATURE     ]   [ {Directory} ]   |-----------|
[ ANDROID  ]   [ MINOR       ]   [ {Framework} ] - | {Message} |
[----------]   [-------------]   [-------------]   |-----------|

[CATEGORY] [TYPE] [LOCATION] - MESSAGE

 EXAMPLES:

 [IOS] [BREAKING] [FlatList] - Change a thing that breaks other things
 [ANDROID] [BUGFIX] [TextInput] - Did a thing to TextInput
 [CLI] [FEATURE] [local-cli/info/info.js] - CLI easier to do things with
 [DOCS] [BUGFIX] [GettingStarted.md] - Accidentally a thing/word
 [GENERAL] [ENHANCEMENT] [Yoga] - Added new yoga thing/position
 [INTERNAL] [FEATURE] [./scripts] - Added thing to script that nobody will see
-->

[CLI] [BUGFIX] [local-cli/wrong-react-native.js] - Updated local-cli on Windows to check for the absence of a package.json file to determine if being run from a global installation or not.
Closes https://github.com/facebook/react-native/pull/17036

Differential Revision: D6471925

Pulled By: TheSavior

fbshipit-source-id: cc5560d1c102d05f378e5ae537f13d31b5343045
2017-12-04 11:17:10 -08:00
Eli White fc86f25f9a Run eslint on all js files
Reviewed By: zertosh

Differential Revision: D5405047

fbshipit-source-id: 5ade9d8beb3688d8bb08a208709c0dbf1ec671b2
2017-07-12 14:09:53 -07:00
Alex Kotliarskyi 8295d27a90 Fix usage of react-native cli inside package.json scripts
Summary:
IIRC we made `wrong-react-native` to warn people in case they installed `react-native` globally (instead of `react-native-cli` what the guide suggests). To do that we added `bin` entry to React Native's `package.json` that points to `local-cli/wrong-react-native.js`

However, this means that if we have a project that uses `react-native` package and has call to `react-native` CLI inside its package.json, npm will execute *local* override (which just prints a confusing in this context error message).

In fact, the template we generate with `react-native init` has `react-native start` as `start` script, which makes it useless. Let's fix it by making `wrong-react-native` script smarter – it can detect that it has been executed from local `node_modules` and run the actual CLI.

cc vjeux ide
Closes https://github.com/facebook/react-native/pull/7243

Differential Revision: D3226645

Pulled By: frantic

fb-gh-sync-id: be094eb0e70e491da4ebefc2abf11cff56c4c5b7
fbshipit-source-id: be094eb0e70e491da4ebefc2abf11cff56c4c5b7
2016-04-26 15:42:35 -07:00
Alex Kotliarskyi ec76271715 Return non-zero exit code from wrong-react-native
Summary:
When used in automation, `wrong-react-native` can cause problems because it does not
report the issue via exit code.
Closes https://github.com/facebook/react-native/pull/5114

Reviewed By: svcscm

Differential Revision: D2799995

Pulled By: frantic

fb-gh-sync-id: 23c32dac9b0fcdbeaf48b94e9cb220c6c1b344aa
2016-01-05 15:22:59 -08:00
Martín Bigio 2856be9a07 Bring back global cli module check
Summary: public

This was introduced by vjeux on 0a5967d and removed on 0686b01. I guess it was removed accidentally as this this is a nice warning to have that should prevent n00bs from commiting a common mistake

Reviewed By: frantic

Differential Revision: D2563885

fb-gh-sync-id: 9fae145bbec587514f118d1d28d076b1d82f0630
2015-10-26 15:36:29 -07:00
Christopher Chedeau 0a5967dbfe Warn when installing globally react-native instead of react-native-cli
This adds a react-native binary that just output some instructions.
2015-04-08 11:15:56 -07:00