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

Npm offline mirror support #60

Merged
merged 1 commit into from
Jun 6, 2016
Merged

Npm offline mirror support #60

merged 1 commit into from
Jun 6, 2016

Conversation

bestander
Copy link
Member

@bestander bestander commented May 13, 2016

t11037039: Integrate kpm with React Native

Offline support mode in kpm as a seamless layer for npm install / tarball download.
The idea is that npm tarballs can be configured per project and checked in fbsource (or some offline file sharing service) and no internet connection will be required to restore node_modules.

How it works:

  • .npmrc can have "kpm-offline-mirror" setting with local path to package mirror
  • when tarballs are downloaded from http:// they are copied to "kpm-offline-mirror" folder and fbkpm.lock saves the path to file in mirror rather than remote url
  • when tarballs are installed second time, fbkpm.lock contains local paths and works offline

Example

$ cat .npmrc
kpm-offline-mirror=./mirror1/npm
$ kpm install left-pad --save
fbkpm install v0.0.0
info No lockfile found.
[1/4] 🚚  Resolving and fetching packages...
[2/4] ✅  Checking package compatibility...
[3/4] 🔗  Linking dependencies...
[4/4] 📃  Running install scripts...
success Saved fbkpm lockfile to fbkpm.lock
✨  Done in 0.49s. Peak memory usage 33.65MB.
$ cat fbkpm.lock
left-pad:
  name left-pad
  version "1.1.0"
  resolved left-pad-1.1.0.tgz#47a2daf581ede454334dee6c6036cae00d912e4d
$ cat package.json
{
  "dependencies": {
    "left-pad": "^1.1.0"
  }
$ ls mirror1/npm
left-pad-1.1.0.tgz
$ rm -rf node_modules/ && rm -rf ~/.fbkpm/
$ kpm install
fbkpm install v0.0.0
info Read lockfile fbkpm.lock
[1/5] ⏩  Rehydrating dependency graph...
[2/5] 📦  Fetching packages...
[3/5] ✅  Checking package compatibility...
[4/5] 🔗  Linking dependencies...
[5/5] 📃  Running install scripts...
✨  Done in 0.08s. Peak memory usage 34.63MB.

}
}
if (this.config['kpm-offline-mirror']) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Double quotes

@bestander bestander changed the title (WIP) Npm offline mirror support Npm offline mirror support May 28, 2016
@bestander
Copy link
Member Author

Known issues:

  • Offline mirror installation of react-native deps throws on Node 4
info Read lockfile fbkpm.lock
[1/5] ⏩  Rehydrating dependency graph...
⠁ Invariant Violation: Resolved package info has no package reference
    at invariant (/Users/bestander/work/fbkpm/node_modules/invariant/invariant.js:42:15)
    at PackageRequest._callee5$ (/Users/bestander/work/fbkpm/lib-legacy/package-request.js:444:17)
    at tryCatch (/Users/bestander/work/fbkpm/node_modules/babel-runtime/regenerator/runtime.js:88:40)
    at GeneratorFunctionPrototype.invoke [as _invoke] (/Users/bestander/work/fbkpm/node_modules/babel-runtime/regenerator/runtime.js:341:22)
    at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/Users/bestander/work/fbkpm/node_modules/babel-runtime/regenerator/runtime.js:121:21)
    at step (/Users/bestander/work/fbkpm/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
    at /Users/bestander/work/fbkpm/node_modules/babel-runtime/helpers/asyncToGenerator.js:28:20
    at run (/Users/bestander/work/fbkpm/node_modules/babel-runtime/node_modules/core-js/library/modules/es6.promise.js:89:22)
    at /Users/bestander/work/fbkpm/node_modules/babel-runtime/node_modules/core-js/library/modules/es6.promise.js:102:28
    at flush (/Users/bestander/work/fbkpm/node_modules/babel-runtime/node_modules/core-js/library/modules/_microtask.js:18:9)
  • if modules are cached in ~/.fbkpm, kpm install --save won't save into mirror because tarball.js is never used

@sebmck
Copy link
Contributor

sebmck commented Jun 3, 2016

👍 PR looks good. Only comments would be on that the code style is a bit different to the one that's used but that doesn't really matter much.

@bestander
Copy link
Member Author

Thanks, I'll match the style, please comment where I missed it

@bestander
Copy link
Member Author

I'll run make lint

@sebmck
Copy link
Contributor

sebmck commented Jun 6, 2016

👍 Woot, awesome! Looks good, merge at will!

@bestander bestander merged commit 1e7a181 into yarnpkg:master Jun 6, 2016
arcanis added a commit that referenced this pull request Sep 13, 2018
Uses symlinks instead of a script for bin indirection to allow callin…
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

Successfully merging this pull request may close these issues.

2 participants