vigour-io / turbolink

Links all your projects together, where npm link fails.
ISC License
1 stars 0 forks source link

Turbolink v2 #13

Open youzi opened 8 years ago

youzi commented 8 years ago

Biggest need atm is versioning. We should link in a way that mimics a "npm clean install".

Another issue is updating the .turbolink file constantly. I propose passing a github key and turbolink will clone any dependency it can find on your user/organisation.

.turbolink file:

exports.key = <githubkey> // key to check deps on github
exports.update = true / false // always update npm modules and github modules
exports.global = true / false // install all (non gh available )dependencies globally and link them

Challenges:

/cc @nfrade @marcusbesjes @jimdebeer

youzi commented 8 years ago

When having:

tl in adm-app should check out all tags/versions according to adm-app/package.json and tl in sbs-app should check out all tags/versions according to sbs-app/package.json

youzi commented 8 years ago

Find common dependency versions between semver modules. eg.

project A needs vigour-observable@^1.0.0 project B needs vigour-observable@^1.2.0

Get available versions:

List npm dependencies:

youzi commented 8 years ago

folder

/dir
  /projectA
  /projectB
  /projectC
  /shared_modules
    /depFromAandB
    /depFromBandC
youzi commented 8 years ago

shared dependency tree:

{
  projectA: {
    depA: '^2.0.0',
  },
  projectB: {
    depA: '<=2.0.9'
  },
  shared_node_modules: {
    depA: [ '2.0.6', '2.0.5', '2.0.4', '2.0.3', '2.0.2', '2.0.1', '2.0.0' ]
  }
}

Is there a need to account for all possible versions? Or do we just use the latest in the possible range?

{
  depA: '2.0.6'
  depB: '1.1.1'
}
youzi commented 8 years ago

Could be an idea to create a package.json and let npm i handle the installation of the shared node_modules.

/dir
  /projectA
  /projectB
  /projectC
  /node_modules
    /depFromAandB
    /depFromBandC
  /package.json // has all shared dependencies in dependencies folder (devDependecies in devDependencies

npm iwould the install all shared dependencies. Advantage being that npm will handle all shared node_modules

youzi commented 8 years ago

Other potential issue:

youzi commented 8 years ago

Another way of handling shared dependencies is to have them live in the local node_modules:

/dir
  /projectA
    /node_modules
      /depA
  /projectB
    /node_modules
      /depA linked from projectA
  /projectC
  /projectB
    /node_modules
      /depA linked from projectA
youzi commented 8 years ago

Or let's install everything in shared_modules and link local projects to shared_modules as well. Then link accordingly to all projects.

/dir
  /projectA
    /node_modules // everything in here is a link to /shared_modules/something
  /projectB
    /node_modules
  /projectC
    /node_modules
  /shared_modules/
    /depA@1.2.0
      /node_modules // everything in here is a link to /shared_modules/something
    /depA@2.1.3
    /projectA@1.0.0
    /projectB@1.3.0
    ...

For this to work well we need to be able to install modules without their dependencies. Option? http://stackoverflow.com/questions/28382773/install-npm-package-without-dependencies

Let's use: https://www.npmjs.com/package/download-tarball

youzi commented 8 years ago

So:

1. npm view every dependency to find all dependencies with semver range
2. find the most common versions => list all dependencies (with version)
3. download every dependency@version into shared_modules:
  a. download from npm
  b. link from projects
4. link modules to correct node_modules in all modules
youzi commented 8 years ago

In order to link all modules most efficiently, we are downloading npm modules vs installing them: --> we can't do this for private modules ==> as a work around I'm cloning the git repo instead (this is no standard fallback for failed npm download)