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

[RNPM] Add pre/postunlink #9157

Closed
wants to merge 7 commits into from
Closed

[RNPM] Add pre/postunlink #9157

wants to merge 7 commits into from

Conversation

geof90
Copy link
Contributor

@geof90 geof90 commented Aug 2, 2016

An attempt to address #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"
    }
  }
  1. Added files, scripts/preunlink.js and scripts/postunlink.js to the plugin. Each of them simply logs a string to the console.
  2. Ran react-native unlink react-native-plugin to verify that those logs get printed.

@ghost
Copy link

ghost commented Aug 2, 2016

@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]);
Copy link
Contributor Author

@geof90 geof90 Aug 2, 2016

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor

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?

Copy link
Contributor Author

@geof90 geof90 Aug 3, 2016

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 :).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@geof90 geof90 changed the title Add pre/postunlink [RNPM] Add pre/postunlink Aug 2, 2016
@Kureev
Copy link
Contributor

Kureev commented Aug 2, 2016

Postlink already exists: https://github.com/rnpm/rnpm#commands

@Kureev
Copy link
Contributor

Kureev commented Aug 2, 2016

Post-unlink is nothing else but something you may run after rnpm unlink: rnpm unlink <packageName> && doSomething

@ghost ghost added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 2, 2016
@geof90
Copy link
Contributor Author

geof90 commented Aug 2, 2016

@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.

@ghost
Copy link

ghost commented Aug 2, 2016

@geof90 updated the pull request.

@ghost ghost added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 2, 2016
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 3, 2016
@@ -1,5 +1,5 @@
module.exports = {
func: require('./src/link'),
description: 'links all native dependencies',
name: 'link [packageName]',
name: 'link <packageName>',
Copy link
Contributor

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?

Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@ghost
Copy link

ghost commented Aug 3, 2016

@geof90 updated the pull request.

@ghost ghost added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 3, 2016
@geof90
Copy link
Contributor Author

geof90 commented Aug 8, 2016

Any updates on this?

@grabbou
Copy link
Contributor

grabbou commented Aug 16, 2016

I am leaving that up to @Kureev since he's been the author of pre/post links. Mind taking a look?

@ghost ghost added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 16, 2016
@Kureev
Copy link
Contributor

Kureev commented Aug 21, 2016

LGTM, diff is really nice ❤️ (sorry for delay, was on vacation)

@Kureev
Copy link
Contributor

Kureev commented Aug 21, 2016

@facebook-github-bot shipit

@ghost ghost added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 21, 2016
@grabbou
Copy link
Contributor

grabbou commented Aug 21, 2016

That won't ship since there's a conflict with master that I commented on. The split(" ") was already merged as a part of another PR so it has to be removed from that one or rebased :)

@Kureev
Copy link
Contributor

Kureev commented Aug 21, 2016

Can you update this PR according to @grabbou's comment, @geof90?

@ghost ghost added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 21, 2016
@ghost
Copy link

ghost commented Aug 22, 2016

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.

@ghost ghost added Import Failed CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. and removed Import Started This pull request has been imported. This does not imply the PR has been approved. labels Aug 22, 2016
@ghost
Copy link

ghost commented Aug 22, 2016

@geof90 updated the pull request - view changes - changes since last import

@geof90
Copy link
Contributor Author

geof90 commented Aug 22, 2016

I thought I already updated to master before after you told me that :/ I just fixed the conflicts, could you try again?

@ghost ghost added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 22, 2016
@ghost
Copy link

ghost commented Aug 22, 2016

@geof90 updated the pull request - view changes - changes since last import

@ghost ghost added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 22, 2016
@Kureev
Copy link
Contributor

Kureev commented Aug 22, 2016

I'd like to, but there are some errors: https://circleci.com/gh/facebook/react-native/10404

@ghost
Copy link

ghost commented Aug 22, 2016

@geof90 updated the pull request - view changes - changes since last import

@geof90
Copy link
Contributor Author

geof90 commented Aug 22, 2016

@Kureev sorry, didn't realize the folder structure was changed

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 22, 2016
@Kureev
Copy link
Contributor

Kureev commented Aug 23, 2016

@bestander this one looks good. Seems that circle fails because of something else (Buck?). Can we ship it?

@ghost ghost added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 23, 2016
@bestander
Copy link
Contributor

Yes, thanks for double checking

@bestander
Copy link
Contributor

Thus Buck issue will be gone with rebase, no need to do it this time

@bestander
Copy link
Contributor

@facebook-github-bot shipit

@ghost ghost added the Import Started This pull request has been imported. This does not imply the PR has been approved. label Aug 24, 2016
@ghost
Copy link

ghost commented Aug 24, 2016

Thanks for importing.If you are an FB employee go to Phabricator to review internal test results.

@ghost ghost added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 24, 2016
@ghost ghost closed this in e7521a1 Aug 24, 2016
grabbou pushed a commit to react-native-community/cli that referenced this pull request Sep 26, 2018
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
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. 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.

6 participants