-
Notifications
You must be signed in to change notification settings - Fork 24.6k
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
[RNPM] Add pre/postunlink #9157
Conversation
@geof90 updated the pull request. |
@@ -137,7 +137,7 @@ function run() { | |||
|
|||
commander.parse(process.argv); | |||
|
|||
const isValidCommand = commands.find(cmd => cmd.name === process.argv[2]); | |||
const isValidCommand = commands.find(cmd => cmd.name.split(" ")[0] === process.argv[2]); |
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.
This is needed because the rnpm commands have additional positional arguments, e.g link <packageName>
in their names, therefore a naive full string comparison wouldn't work.
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.
Looks like this might be breaking all usages of link ABCD
with the RC? If yes, that has to be cherry-picked into stable release.
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.
Yep. Any chance you could take this whole change?
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.
Yeah, actually @rozele submitted a PR fixing that particular thing, mind rebasing in like an hour once the merge finishes?
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.
Which PR? I don't think #9173 is related, it only fixes showing the help. When you run the command react-native link react-native-plugin
, you would still see the warning because isValidCommand
fails to find a command with a name that matches. This fixes that.
I noticed you added "needs-revision", what exactly needs revision? Also, given that this is not the main point of this PR, I would appreciate it if you could comment on the addition of the pre/post unlink hooks :).
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.
Yeah, but we have already merged a fix for that here: https://github.com/facebook/react-native/blob/master/local-cli/cliEntry.js#L161
Postlink already exists: https://github.com/rnpm/rnpm#commands |
Post-unlink is nothing else but something you may run after |
@Kureev Sorry I meant preunlink and postunlink in the test plan. Yes, we can do that, but as a user, it will be much more convenient if RNPM would call those hooks for plugin authors instead of having the user do something different for every react native plugin they want to unlink. |
@geof90 updated the pull request. |
@@ -1,5 +1,5 @@ | |||
module.exports = { | |||
func: require('./src/link'), | |||
description: 'links all native dependencies', | |||
name: 'link [packageName]', | |||
name: 'link <packageName>', |
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.
the packageName argument should remain optional shouldn't it?
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.
for link - yes, for unlink it's mandatory
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.
Fixed
@geof90 updated the pull request. |
Any updates on this? |
I am leaving that up to @Kureev since he's been the author of pre/post links. Mind taking a look? |
LGTM, diff is really nice ❤️ (sorry for delay, was on vacation) |
@facebook-github-bot shipit |
That won't ship since there's a conflict with master that I commented on. The |
I tried to merge this pull request into the Facebook internal repo but some checks failed. To unblock yourself please check the following: Does this pull request pass all open source tests on GitHub? If not please fix those. Does the code still apply cleanly on top of GitHub master? If not can please rebase. In all other cases this means some internal test failed, for example a part of a fb app won't work with this pull request. I've added the Import Failed label to this pull request so it is easy for someone at fb to find the pull request and check what failed. If you don't see anyone comment in a few days feel free to comment mentioning one of the core contributors to the project so they get a notification. |
@geof90 updated the pull request - view changes - changes since last import |
I thought I already updated to master before after you told me that :/ I just fixed the conflicts, could you try again? |
@geof90 updated the pull request - view changes - changes since last import |
I'd like to, but there are some errors: https://circleci.com/gh/facebook/react-native/10404 |
@geof90 updated the pull request - view changes - changes since last import |
@Kureev sorry, didn't realize the folder structure was changed |
@bestander this one looks good. Seems that circle fails because of something else (Buck?). Can we ship it? |
Yes, thanks for double checking |
Thus Buck issue will be gone with rebase, no need to do it this time |
@facebook-github-bot shipit |
Thanks for importing.If you are an FB employee go to Phabricator to review internal test results. |
Summary: An attempt to address facebook/react-native#9156. cc grabbou Kureev **Test plan (required)** 1. Added the following to the `package.json` of a `react-native-plugin` ``` "rnpm": { "commands": { "preunlink": "node node_modules/react-native-plugin/scripts/preunlink" "postunlink": "node node_modules/react-native-plugin/scripts/postunlink" } } ``` 2. Added files, `scripts/preunlink.js` and `scripts/postunlink.js` to the plugin. Each of them simply logs a string to the console. 3. Ran `react-native unlink react-native-plugin` to verify that those logs get printed. Closes facebook/react-native#9157 Differential Revision: D3749434 fbshipit-source-id: 40b94c9026db4f11e8f5be4a417a0670e8069be6
An attempt to address #9156.
cc @grabbou @Kureev
Test plan (required)
package.json
of areact-native-plugin
scripts/preunlink.js
andscripts/postunlink.js
to the plugin. Each of them simply logs a string to the console.react-native unlink react-native-plugin
to verify that those logs get printed.