-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
Merge rnpm cli
into react-native
#7899
Conversation
By analyzing the blame information on this pull request, we identified @janicduplessis and @mroswald to be potential reviewers. |
@grabbou updated the pull request. |
4 similar comments
@grabbou updated the pull request. |
@grabbou updated the pull request. |
@grabbou updated the pull request. |
@grabbou updated the pull request. |
'init': [printInitWarning, ''], | ||
const handleError = (err) => { | ||
console.error(); | ||
console.error(err.message || err); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally I'd like to reject promises with an error, not a plain string. But since this is a common catch-all handler, it should support both.
@grabbou updated the pull request. |
const isPackagerRunning = require('../util/isPackagerRunning'); | ||
const Promise = require('promise'); | ||
const adb = require('./adb'); | ||
|
||
// Verifies this is an Android project | ||
function checkAndroid(root) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc: @Kureev I can see lots of things for rnpm to do here :)
|
||
if (!checkAndroid(args)) { | ||
function runAndroid(argv, config, args) { | ||
if (!checkAndroid(args.root)) { | ||
console.log(chalk.red('Android project not found. Maybe run react-native android first?')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mkonicek in next PR, what I would like to see is to move these all chalk.red calls (errors) to be just Promise.reject / throw new Error so that we have a centralised error reported in the cliEntry.js
file. That would also stay consistent with other commands (like runIOS) where we throw errors instead of logging & swallowing them. Might be also a bit easier to work with in case one is debugging and doesn't know where the error is coming from. What you think? :) Was there any specific motivation for doing it that way?
@grabbou updated the pull request. |
Something wrong about generated bundle for instrumentation tests |
Yeah @bestander, bundle wasn't being generated at all (I've disabled that command). Last commit brings it back, maybe it will go green now :) |
@grabbou updated the pull request. |
Wrap everything in a promise so that we not only print out on rejections, but also on other errors that were thrown (e.g. in a assertRequiredOptions or in a new-library command). Note: command itself doesn't need to return a promise.
@facebook-github-bot import |
I'll give it a try tomorrow morning, thanks, Michal |
Thanks for importing. If you are an FB employee go to Phabricator to review internal test results. |
@grabbou, I was able to get a shim for bundle/unbundle/dependencies
But I have a feeling that Also we plan to opensource this internal CLI code soon. |
Ok, today I was able to get a bit further. |
@bestander I believe it would be much simpler to just call the functions itself directly, though I don't want to introduce extra mess here w/o having an access to the code you are trying to shim. Hoping we can get it merged sooner than the CLI wrappers being open sourced, otherwise we'll have to wait. |
Good news, I was able to get the wrappers working. A few rnpm Jest tests are failing
Any ideas? |
Seems you don't have a proper package.json in the folder, where you run CLI |
Thanks, I'll copy the changes On Saturday, 30 July 2016, Alexey notifications@github.com wrote:
|
@grabbou updated the pull request. |
1 similar comment
@grabbou updated the pull request. |
Ok, I decided to disable rnpm tests from running at FB CI for now. @grabbou, @Kureev, could you think of a way to decouple rnpm from CWD in the next few releases? Brace yourselves, this PR is going to be landed now |
Summary: This is an initial step of rewriting the CLI interface to use `rnpm` one (commander, plugins etc.). It's scope is to move all existing commands to use rnpm CLI interface, so that we get plugins, flags and our existing ecosystem working out of the box. <s>This is still WIP and some of the commands are left commented out.</s> For the `config` of `rnpm` (functions get info about project and dependency), <s>I am thinking we can merge them with</s> we decided to merge it with [`default.config.js`](https://github.com/grabbou/react-native/blob/e57683e420210749a5a6b802b4e70adb69675786/local-cli/default.config.js#L33), so they are available on the `new Config()` [instance](https://github.com/grabbou/react-native/blob/e57683e420210749a5a6b802b4e70adb69675786/local-cli/cliEntry.js#L59) (which means we don't have to change anything and current plugins, like runIOS and runAndroid can just start using it [w/o depending on any extra argument](https://github.com/grabbou/react-native/blob/e57683e420210749a5a6b802b4e Closes #7899 Differential Revision: D3613193 Pulled By: bestander fbshipit-source-id: 09a072f3b21e5239dfcd8da88a205bd28dc5d037
Summary: This is an initial step of rewriting the CLI interface to use `rnpm` one (commander, plugins etc.). It's scope is to move all existing commands to use rnpm CLI interface, so that we get plugins, flags and our existing ecosystem working out of the box. <s>This is still WIP and some of the commands are left commented out.</s> For the `config` of `rnpm` (functions get info about project and dependency), <s>I am thinking we can merge them with</s> we decided to merge it with [`default.config.js`](https://github.com/grabbou/react-native/blob/e57683e420210749a5a6b802b4e70adb69675786/local-cli/default.config.js#L33), so they are available on the `new Config()` [instance](https://github.com/grabbou/react-native/blob/e57683e420210749a5a6b802b4e70adb69675786/local-cli/cliEntry.js#L59) (which means we don't have to change anything and current plugins, like runIOS and runAndroid can just start using it [w/o depending on any extra argument](https://github.com/grabbou/react-native/blob/e57683e420210749a5a6b802b4e Closes facebook#7899 Differential Revision: D3613193 Pulled By: bestander fbshipit-source-id: 09a072f3b21e5239dfcd8da88a205bd28dc5d037
Summary: This is an initial step of rewriting the CLI interface to use `rnpm` one (commander, plugins etc.). It's scope is to move all existing commands to use rnpm CLI interface, so that we get plugins, flags and our existing ecosystem working out of the box. <s>This is still WIP and some of the commands are left commented out.</s> For the `config` of `rnpm` (functions get info about project and dependency), <s>I am thinking we can merge them with</s> we decided to merge it with [`default.config.js`](https://github.com/grabbou/react-native/blob/e57683e420210749a5a6b802b4e70adb69675786/local-cli/default.config.js#L33), so they are available on the `new Config()` [instance](https://github.com/grabbou/react-native/blob/e57683e420210749a5a6b802b4e70adb69675786/local-cli/cliEntry.js#L59) (which means we don't have to change anything and current plugins, like runIOS and runAndroid can just start using it [w/o depending on any extra argument](https://github.com/grabbou/react-native/blob/e57683e420210749a5a6b802b4e Closes facebook#7899 Differential Revision: D3613193 Pulled By: bestander fbshipit-source-id: 09a072f3b21e5239dfcd8da88a205bd28dc5d037
Summary: This is an initial step of rewriting the CLI interface to use `rnpm` one (commander, plugins etc.). It's scope is to move all existing commands to use rnpm CLI interface, so that we get plugins, flags and our existing ecosystem working out of the box. <s>This is still WIP and some of the commands are left commented out.</s> For the `config` of `rnpm` (functions get info about project and dependency), <s>I am thinking we can merge them with</s> we decided to merge it with [`default.config.js`](https://github.com/grabbou/react-native/blob/e57683e420210749a5a6b802b4e70adb69675786/local-cli/default.config.js#L33), so they are available on the `new Config()` [instance](https://github.com/grabbou/react-native/blob/e57683e420210749a5a6b802b4e70adb69675786/local-cli/cliEntry.js#L59) (which means we don't have to change anything and current plugins, like runIOS and runAndroid can just start using it [w/o depending on any extra argument](https://github.com/grabbou/react-native/blob/e57683e420210749a5a6b802b4e Closes facebook#7899 Differential Revision: D3613193 Pulled By: bestander fbshipit-source-id: 09a072f3b21e5239dfcd8da88a205bd28dc5d037
Restores feature introduced in facebook#7961 after it's been paved partially by facebook#7899
Restores feature introduced in facebook#7961 after it's been paved partially by facebook#7899
Summary: Restores feature introduced in #7961 after it's been paved partially by #7899 **Test Plan:** ran example in https://github.com/philikon/ReactNativify against a React Native with and without this patch Closes #9799 Differential Revision: D3852601 Pulled By: mkonicek fbshipit-source-id: fc3c80bdb254145fefa870eea1828b4ef33f9297
Summary: Restores feature introduced in facebook#7961 after it's been paved partially by facebook#7899 **Test Plan:** ran example in https://github.com/philikon/ReactNativify against a React Native with and without this patch Closes facebook#9799 Differential Revision: D3852601 Pulled By: mkonicek fbshipit-source-id: fc3c80bdb254145fefa870eea1828b4ef33f9297
Summary: This is an initial step of rewriting the CLI interface to use `rnpm` one (commander, plugins etc.). It's scope is to move all existing commands to use rnpm CLI interface, so that we get plugins, flags and our existing ecosystem working out of the box. <s>This is still WIP and some of the commands are left commented out.</s> For the `config` of `rnpm` (functions get info about project and dependency), <s>I am thinking we can merge them with</s> we decided to merge it with [`default.config.js`](https://github.com/grabbou/react-native/blob/e57683e420210749a5a6b802b4e70adb69675786/local-cli/default.config.js#L33), so they are available on the `new Config()` [instance](https://github.com/grabbou/react-native/blob/e57683e420210749a5a6b802b4e70adb69675786/local-cli/cliEntry.js#L59) (which means we don't have to change anything and current plugins, like runIOS and runAndroid can just start using it [w/o depending on any extra argument](https://github.com/grabbou/react-native/blob/e57683e420210749a5a6b802b4e Closes facebook/react-native#7899 Differential Revision: D3613193 Pulled By: bestander fbshipit-source-id: 09a072f3b21e5239dfcd8da88a205bd28dc5d037
This is an initial step of rewriting the CLI interface to use
rnpm
one (commander, plugins etc.).It's scope is to move all existing commands to use rnpm CLI interface, so that we get plugins, flags and our existing ecosystem working out of the box.
This is still WIP and some of the commands are left commented out.For the
config
ofrnpm
(functions get info about project and dependency),I am thinking we can merge them withwe decided to merge it withdefault.config.js
, so they are available on thenew Config()
instance (which means we don't have to change anything and current plugins, like runIOS and runAndroid can just start using it w/o depending on any extra argument).Roadmap:
Test plan:
npm install
node ./local-cli/cli.js --help
?w=0
to ignore indentsBreaking changes for current
rnpm
developers:command
did change to align with what is currently in React Native (partially to reduce the diff). See the flow definition for a final list of options allowed,default
option for a flag can now be a function that receives an instance of a Config. I found it a common pattern, e.g. here. If we decide to merge rnpm config intoConfig
, then e.g. here we can just swap default value fromios
to(config) => config.getProjectConfig().ios.sourceDir
argv
, the 2nd one isconfig
, which means they are swapped.There's plenty of stuff yet to be done, but we are trying to keep the diff small. We still have to post new docs and developers guide. @bestander @vjeux since the local-cli is now extensible and supports custom configs (either through rn-cli or via package.json), can we think of an extra section on the website to describe it?