skybet / shonkwrap

npm shrinkwrap with the noise removed
27 stars 4 forks source link

package.json URL dependencies are not preserved #2

Closed elliottsj closed 9 years ago

elliottsj commented 9 years ago

For example, jsdoc depends on a URL for taffydb:

"taffydb": "https://github.com/hegemonic/taffydb/tarball/7d100bcee0e997ee4977e273cdce60bd8933050e"

However the resulting npm-shrinkwrap.json omits the URL:

"taffydb": {
  "version": "2.6.2"
},

And since v2.6.2 is not available on npm, this error occurs:

npm ERR! Linux 3.14.28-031428-generic
npm ERR! argv "node" "/home/ubuntu/nvm/v0.10.21/bin/npm" "install"
npm ERR! node v0.10.21
npm ERR! npm  v2.13.5

npm ERR! version not found: taffydb@2.6.2
npm ERR! 
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>
glenjamin commented 9 years ago

Well, that's quite annoying - I wish we had tests for this now.

What does the normal shrinkwrap look like for that? Can you tell the difference between that and a normal dependency from the shrinkwrap?

elliottsj commented 9 years ago

Yep, here's a snippet from a normal shrinkwrap using jsdoc:

"strip-json-comments": {
  "version": "1.0.4",
  "from": "strip-json-comments@>=1.0.2 <1.1.0",
  "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-1.0.4.tgz"
},
"taffydb": {
  "version": "2.6.2",
  "from": "https://github.com/hegemonic/taffydb/tarball/7d100bcee0e997ee4977e273cdce60bd8933050e",
  "resolved": "https://github.com/hegemonic/taffydb/tarball/7d100bcee0e997ee4977e273cdce60bd8933050e"
},

In the case of taffydb, it looks like shrinkwrap just copies the URL exactly from package.json to the "from" and "resolved" fields.

glenjamin commented 9 years ago

Cool, I reckon the fix is to retain "resolved" if it is equal to "from".

Will accept a pull request, or if not I'll fix myself soonish.

glenjamin commented 9 years ago

Released as 1.2.0

elliottsj commented 9 years ago

Awesome, thanks!