{"name":"npm-shrinkwrap","version":"200.4.0","description":"A consistent shrinkwrap tool","keywords":[],"author":{"name":"Raynos","email":"raynos2@gmail.com"},"repository":{"type":"git","url":"git://github.com/uber/npm-shrinkwrap.git"},"main":"index","homepage":"https://github.com/uber/npm-shrinkwrap","bugs":{"url":"https://github.com/uber/npm-shrinkwrap/issues","email":"raynos2@gmail.com"},"dependencies":{"array-find":"^0.1.1","error":"^4.2.0","json-diff":"^0.3.1","minimist":"^1.1.0","msee":"^0.1.1","npm":"^2.1.10","read-json":"0.1.0","rimraf":"^2.2.8","run-parallel":"^1.0.0","run-series":"^1.0.2","safe-json-parse":"^2.0.0","semver":"^4.0.3","sorted-object":"^1.0.0","string-template":"^0.2.0"},"devDependencies":{"fixtures-fs":"^2.0.0","istanbul":"~0.3.2","jshint":"2.5.6","pre-commit":"0.0.9","tap-spec":"~1.0.0","tape":"^3.0.2"},"scripts":{"test":"npm run jshint -s && NODE_ENV=test node test/index.js | tap-spec","unit-test":"NODE_ENV=test node test/npm-shrinkwrap.js | tap-spec","jshint-pre-commit":"jshint --verbose $(git diff --cached --name-only | grep '\\.js$')","jshint":"jshint --verbose .","cover":"istanbul cover --report none --print detail test/index.js","view-cover":"istanbul report html && open ./coverage/index.html","travis":"npm run cover -s && istanbul report lcov && ((cat coverage/lcov.info | coveralls) || exit 0)"},"pre-commit":["jshint-pre-commit","unit-test"],"bin":{"npm-shrinkwrap":"./bin/cli.js"},"engine":{"node":">= 0.10.x"},"readme":"# npm-shrinkwrap\n\nA consistent shrinkwrap tool\n\n## Usage\n\n`$ npm-shrinkwrap`\n\nThis runs shrinkwrap, which verifies your package.json & \n  node_modules tree are in sync. If they are it runs shrinkwrap\n  then fixes the resolved fields and trims from fields\n\nWhen you run `npm-shrinkwrap` it will either:\n\n - fail because your package.json & node_modules disagree, i.e.\n    you installed something without `--save` or hand edited your\n    package.json\n - succeed, and add all top level dependencies to your\n    npm-shrinkwrap.json file and then runs `npm-shrinkwrap sync`\n    which writes the npm-shrinkwrap.json back into node_modules\n\n## Motivation\n\n### Verify local correct ness\n\nWe need to verify that `package.json`, `npm-shrinkwrap.json` and\n  `node_modules` all have the same content.\n\nCurrently npm verifies most things but doesn't verify git \n  completely. \n\nThe edge case npm doesn't handle is if you change the tag in \n  your package.json. npm happily says that the dependency in\n  your node_modules tree is valid irregardless of what tag it\n  is.\n\n### Consistently set a `resolved` field.\n\nNPM shrinkwrap serializes your node_modules folder. Depending\n  on whether you installed a module from cache or not it will\n  either have or not have a resolved field.\n\n`npm-shrinkwrap` will put a `resolved` field in for everything\n  in your shrinkwrap.\n\n### Reduce diff churn\n\nThere are a few tricks to ensuring there is no unneeded churn\n  in the output of `npm shrinkwrap`.\n\nThis first is to ensure you install with `npm cache clean` so\n  that an `npm ls` output is going to consistently give you the\n  `resolved` and `from` fields.\n\nThe second is to just delete all `from` fields from the \n  generated shrinkwrap file since they change a lot but are \n  never used. However you can only delete some `from` fields, \n  not all.\n\n### Human readable `diff`\n\nWhen you run shrinkwrap and check it into git you have an\n  unreadable git diff.\n\n`npm-shrinkwrap` comes with an `npm-shrinkwrap diff` command.\n\n```sh\nnpm-shrinkwrap diff master HEAD\nnpm-shrinkwrap diff HEAD npm-shrinkwrap.json --short\n```\n\nYou can use this command to print out a readable context \n  specific diff of your shrinkwrap changes.\n\n### Custom shrinkwrap validators\n\n`npm-shrinkwrap` can be programmatically configured with an\n  array of `validators`.\n\nThese `validators` run over every node in the shrinkwrap file\n  and can do assertions.\n\nUseful assertions are things like assertion all dependencies\n  point at your private registry instead of the public one.\n\n## Example\n\n```js\nvar npmShrinkwrap = require(\"npm-shrinkwrap\");\n\nnpmShrinkwrap({\n    dirname: process.cwd()\n}, function (err, optionalWarnings) {\n    if (err) {\n        throw err;\n    }\n\n    optionalWarnings.forEach(function (err) {\n        console.warn(err.message)\n    })\n\n    console.log(\"wrote npm-shrinkwrap.json\")\n})\n```\n\n## Algorithm\n\nnpm-shrinkwrap algorithm\n\n - run `npm ls` to verify that node_modules & package.json\n    agree.\n\n - run `verifyGit()` which has a similar algorithm to \n    `npm ls` and will verify that node_modules & package.json\n    agree for all git links.\n\n - read the old `npm-shrinkwrap.json` into memory\n\n - run `npm shrinkwrap`\n\n - copy over excess non-standard keys from old shrinkwrap\n    into new shrinkwrap and write new shrinkwrap with extra\n    keys to disk.\n\n - run `setResolved()` which will ensure that the new\n    npm-shrinkwrap.json has a `\"resolved\"` field for every\n    package and writes it to disk.\n\n - run `trimFrom()` which normalizes or removes the `\"from\"`\n    field from the new npm-shrinkwrap.json. It also sorts\n    the new npm-shrinkwrap.json deterministically then\n    writes that to disk\n\n - run `trimNested()` which will trim any changes in the\n    npm-shrinkwrap.json to dependencies at depth >=1. i.e.\n    any changes to nested dependencies without changes to\n    the direct parent dependency just get deleted\n\n - run `sync()` to the new `npm-shrinkwrap.json` back into\n    the `node_modules` folder\n\n\nnpm-shrinkwrap NOTES:\n\n - `verifyGit()` only has a depth of 0, where as `npm ls`\n    has depth infinity.\n\n - `verifyGit()` is only sound for git tags. This means that\n    for non git tags it gives warnings / errors instead.\n\n - `trimFrom()` also sorts and rewrites the package.json\n    for consistency\n\n - By default, the npm-shrinkwrap algorithm does not dedupe\n   nested dependencies. This means that the shrinkwrap is\n   closer to the installed dependencies by default. If this\n   is not desired `--keepNested=false` can be passed to the\n   shrinkwrap cli\n\n## Installation\n\n`npm install npm-shrinkwrap`\n\n## Tests\n\n`npm test`\n\n## Contributors\n\n - Raynos\n","readmeFilename":"README.md","_id":"npm-shrinkwrap@200.4.0","_shasum":"e4fefb2bd8b581e66626d486cbef307d77fa4bef","_from":"https://registry.npmjs.org/npm-shrinkwrap/-/npm-shrinkwrap-200.4.0.tgz","_resolved":"https://registry.npmjs.org/npm-shrinkwrap/-/npm-shrinkwrap-200.4.0.tgz"}