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

Project Structure to enable Github npm dependencies #790

Open
lirbank opened this issue Aug 25, 2016 · 2 comments
Open

Project Structure to enable Github npm dependencies #790

lirbank opened this issue Aug 25, 2016 · 2 comments
Milestone

Comments

@lirbank
Copy link
Contributor

lirbank commented Aug 25, 2016

So, I had this idea it would be nice for contributors/early adopters to be able to depend directly on github repositories. Say I made a hack to fix something for react-native, but it's just a hack so it will never be a PR. Then, if each horizon component (client, server, cli) had their own github repo, so package.json is in the root, it's possible to use a github repo+branch as version in the app package.json. Eg. npm only allows Github dependencies if the package.json is in the root of the repo, and they have no plans of changing that.

Reason? A github dependency will work for testing on staging servers (eg Heroku etc), whereas a filesystem dependency won't, plus it's nice to have the code on Github.

For example, today I have to do something like this (see postinstall), pretty nasty:

{
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "postinstall": "test -d ./node_modules/@horizon || (rm -fR node_modules/@horizon && git clone https://github.com/lirbank/horizon.git node_modules/@horizon --branch react-native-tmp-fix --single-branch && cd node_modules/@horizon/client/ && npm install)"
  },
  "dependencies": {
    "react": "15.2.1",
    "react-native": "0.31.0"
  }
}

In the next example I've created a new branch react-native-client where I deleted everything in the root of the project and moved everything in client/to the root. Now the clients package.json is in the root of the repo and I can use regular dependencies:

{
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
  },
  "dependencies": {
    "@horizon/client": "git://github.com/lirbank/horizon.git#react-native-client",
    "react": "15.2.1",
    "react-native": "0.31.0"
  }
}

I get if you don't want to change the whole project structure just for this, but figured it was worth bringing it up. Are there other approaches? Git submodules?

Just an idea, feel free to close if it doesn't makes any sense.

@lirbank
Copy link
Contributor Author

lirbank commented Aug 25, 2016

@deontologician
Copy link
Contributor

I think the monorepo concept is just incompatible with how npm wants to deal with github packages. Though I think we could do something like publish nightlies. Incidentally, the number of npm packages we have in the repo is about to shoot up a lot in the plugins release, so I think making them individual repositories isn't great for a few reasons. Not the least of which is that issues spread across multiple repositories is a huge pain

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants