Skip to content

Project Structure to enable Github npm dependencies #790

Description

@lirbank

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions