├── .gitignore ├── .travis.yml ├── lib ├── config.js ├── index.js └── remote-ls.js ├── LICENSE.md ├── package.json ├── CHANGELOG.md ├── bin └── npm-remote-ls.js ├── README.md └── test ├── fixtures ├── abbrev.json ├── angular-core.json └── nopt.json └── remote-ls-test.js /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | .nyc_output/ 4 | coverage/ 5 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | sudo: false 3 | node_js: 4 | - "0.10" 5 | - "0.12" 6 | - "4" 7 | - "node" 8 | -------------------------------------------------------------------------------- /lib/config.js: -------------------------------------------------------------------------------- 1 | var config = null 2 | 3 | module.exports = function (opts) { 4 | if (!opts && config) { 5 | return config 6 | } else { 7 | config = opts 8 | return config 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /lib/index.js: -------------------------------------------------------------------------------- 1 | exports.RemoteLS = require('./remote-ls') 2 | 3 | exports.config = function (opts) { 4 | return require('./config')(opts) 5 | } 6 | 7 | exports.ls = function (name, version, flatten, cb) { 8 | var ls = new exports.RemoteLS() 9 | 10 | if (typeof version === 'function') { 11 | cb = version 12 | version = 'latest' 13 | } 14 | 15 | if (typeof flatten === 'function') { 16 | cb = flatten 17 | flatten = false 18 | } 19 | 20 | ls.ls(name, version, function () { 21 | if (flatten) cb(Object.keys(ls.flat)) 22 | else cb(ls.tree) 23 | }) 24 | } 25 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | ## ISC License 2 | 3 | Copyright (c) 2014, npm, Inc. and Contributors 4 | 5 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 8 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "npm-remote-ls", 3 | "version": "1.3.2", 4 | "description": "Examine a package's dependency graph before you install it", 5 | "main": "./lib/index.js", 6 | "bin": { 7 | "npm-remote-ls": "./bin/npm-remote-ls.js" 8 | }, 9 | "scripts": { 10 | "test": "standard && tap --coverage test", 11 | "version": "standard-version" 12 | }, 13 | "repository": { 14 | "type": "git", 15 | "url": "git://github.com/npm/npm-remote-ls.git" 16 | }, 17 | "keywords": [ 18 | "npm", 19 | "ls", 20 | "remote", 21 | "dependency" 22 | ], 23 | "author": "Ben Coe ", 24 | "license": "ISC", 25 | "bugs": { 26 | "url": "https://github.com/npm/npm-remote-ls/issues" 27 | }, 28 | "homepage": "https://github.com/npm/npm-remote-ls", 29 | "devDependencies": { 30 | "chai": "^3.5.0", 31 | "nock": "^8.0.0", 32 | "standard": "^6.0.8", 33 | "standard-version": "^2.1.2", 34 | "tap": "^5.7.1" 35 | }, 36 | "dependencies": { 37 | "async": "^2.0.0-rc.3", 38 | "char-spinner": "^1.0.1", 39 | "lodash": "^4.10.0", 40 | "npm-package-arg": "^4.2.0", 41 | "once": "^1.3.3", 42 | "registry-url": "^3.0.3", 43 | "request": "^2.37.0", 44 | "semver": "^5.1.0", 45 | "treeify": "^1.0.1", 46 | "yargs": "^4.6.0" 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. 4 | 5 | 6 | ## [1.3.2](https://github.com/npm/npm-remote-ls/compare/v1.3.1...v1.3.2) (2016-06-24) 7 | 8 | 9 | ### Bug Fixes 10 | 11 | * match * with dist-tags.latest for prerelease-only versions ([#26](https://github.com/npm/npm-remote-ls/issues/26)) ([9478a97](https://github.com/npm/npm-remote-ls/commit/9478a97)) 12 | 13 | 14 | 15 | 16 | ## [1.3.1](https://github.com/npm/npm-remote-ls/compare/v1.3.0...v1.3.1) (2016-06-15) 17 | 18 | 19 | ### Bug Fixes 20 | 21 | * support scoped packages via npm-package-arg ([#25](https://github.com/npm/npm-remote-ls/issues/25)) ([fdda84b](https://github.com/npm/npm-remote-ls/commit/fdda84b)) 22 | 23 | 24 | 25 | 26 | # [1.3.0](https://github.com/npm/npm-remote-ls/compare/v1.2.0...v1.3.0) (2016-04-13) 27 | 28 | 29 | ### Bug Fixes 30 | 31 | * fix bug with default registry URL found while adding documentation to address [#10](https://github.com/npm/npm-remote-ls/issues/10) ([556d40f](https://github.com/npm/npm-remote-ls/commit/556d40f)), closes [#10](https://github.com/npm/npm-remote-ls/issues/10) 32 | * switch to appropriate repository URL in package.json ([502841f](https://github.com/npm/npm-remote-ls/commit/502841f)) 33 | 34 | ### Features 35 | 36 | * **update:** update to newer versions of all the things ([#20](https://github.com/npm/npm-remote-ls/issues/20)) ([c9be768](https://github.com/npm/npm-remote-ls/commit/c9be768)) 37 | -------------------------------------------------------------------------------- /bin/npm-remote-ls.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var yargs = require('yargs') 4 | .usage('$0 [options]') 5 | .options('n', { 6 | alias: 'name', 7 | description: 'package name' 8 | }) 9 | .options('v', { 10 | alias: 'version', 11 | description: 'package version', 12 | default: 'latest' 13 | }) 14 | .options('e', { 15 | alias: 'verbose', 16 | description: 'enable verbose logging', 17 | default: false, 18 | boolean: true 19 | }) 20 | .options('d', { 21 | alias: 'development', 22 | description: 'show development dependencies', 23 | default: true, 24 | boolean: true 25 | }) 26 | .options('o', { 27 | alias: 'optional', 28 | description: 'show optional dependencies', 29 | default: true, 30 | boolean: true 31 | }) 32 | .options('p', { 33 | alias: 'peer', 34 | description: 'show peer dependencies', 35 | default: false, 36 | boolean: true 37 | }) 38 | .options('r', { 39 | alias: 'registry', 40 | description: 'set an alternative registry url', 41 | default: require('registry-url') 42 | }) 43 | .options('f', { 44 | alias: 'flatten', 45 | description: 'return flat representation of dependencies', 46 | default: false, 47 | boolean: true 48 | }) 49 | var argv = yargs.argv 50 | var ls = require('../lib').ls 51 | var treeify = require('treeify') 52 | var spinner = require('char-spinner') 53 | var npa = require('npm-package-arg') 54 | 55 | require('../lib').config({ 56 | verbose: argv.verbose, 57 | development: argv.development, 58 | optional: argv.optional, 59 | peer: argv.peer, 60 | registry: argv.registry 61 | }) 62 | 63 | var name = argv.name || argv._[0] || '' 64 | 65 | if (argv.help || !name) { 66 | yargs.showHelp() 67 | } else { 68 | spinner() 69 | var parsed = npa(name) 70 | ls(parsed.name, parsed.rawSpec || argv.version, argv.flatten, function (obj) { 71 | if (Array.isArray(obj)) console.log(obj) 72 | else console.log(treeify.asTree(obj)) 73 | }) 74 | } 75 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # npm-remote-ls 2 | 3 | [![Build Status](https://travis-ci.org/npm/npm-remote-ls.png)](https://travis-ci.org/npm/npm-remote-ls) 4 | [![Coverage Status](https://coveralls.io/repos/npm/npm-remote-ls/badge.svg?branch=)](https://coveralls.io/r/npm/npm-remote-ls?branch=master) 5 | [![NPM version](https://img.shields.io/npm/v/npm-remote-ls.svg)](https://www.npmjs.com/package/npm-remote-ls) 6 | [![Standard Version](https://img.shields.io/badge/release-standard%20version-brightgreen.svg)](https://github.com/conventional-changelog/standard-version) 7 | 8 | Examine a package's dependency graph before you install it. 9 | 10 | ## Installation 11 | 12 | ```bash 13 | npm install npm-remote-ls -g 14 | ``` 15 | 16 | ## Usage 17 | 18 | ### Listing Package Dependencies 19 | 20 | ``` 21 | npm-remote-ls sha@1.2.4 22 | 23 | └─ sha@1.2.4 24 | ├─ readable-stream@1.0.27-1 25 | │ ├─ isarray@0.0.1 26 | │ ├─ string_decoder@0.10.25 27 | │ ├─ inherits@2.0.1 28 | │ └─ core-util-is@1.0.1 29 | └─ graceful-fs@3.0.2 30 | ``` 31 | 32 | ### Help! 33 | 34 | There are various command line flags you can toggle for `npm-remote-ls`, for 35 | details run: 36 | 37 | ```bash 38 | npm-remote-ls --help 39 | ``` 40 | 41 | ## API 42 | 43 | **Return dependency graph for `latest` version:** 44 | 45 | ```javascript 46 | var ls = require('npm-remote-ls').ls; 47 | 48 | ls('grunt', 'latest', function(obj) { 49 | console.log(obj); 50 | }); 51 | ``` 52 | 53 | **Return dependency graph for specific version:** 54 | 55 | ```javascript 56 | var ls = require('npm-remote-ls').ls; 57 | 58 | ls('grunt', '0.1.0', function(obj) { 59 | console.log(obj); 60 | }); 61 | ``` 62 | 63 | **Return a flattened list of dependencies:** 64 | 65 | ```javascript 66 | var ls = require('npm-remote-ls').ls; 67 | 68 | ls('grunt', '0.1.0', true, function(obj) { 69 | console.log(obj); 70 | }); 71 | ``` 72 | 73 | **Configure to only return production dependencies:** 74 | 75 | ```javascript 76 | var ls = require('npm-remote-ls').ls 77 | var config = require('npm-remote-ls').config 78 | 79 | config({ 80 | development: false, 81 | optional: false 82 | }) 83 | 84 | ls('yargs', 'latest', true, function (obj) { 85 | console.log(obj) 86 | }) 87 | ``` 88 | 89 | **Configure to return peer dependencies:** 90 | 91 | ```javascript 92 | var ls = require('npm-remote-ls').ls 93 | var config = require('npm-remote-ls').config 94 | 95 | config({ 96 | development: true, 97 | peer: true 98 | }) 99 | 100 | ls('grunt-contrib-coffee', 'latest', true, function (obj) { 101 | console.log(obj) 102 | }) 103 | ``` 104 | 105 | ## License 106 | 107 | ISC 108 | -------------------------------------------------------------------------------- /test/fixtures/abbrev.json: -------------------------------------------------------------------------------- 1 | {"_id":"abbrev","_rev":"30-b7768fb0b6a3e028d233df8da48ddec9","name":"abbrev","dist-tags":{"latest":"1.0.5"},"versions":{"1.0.3":{"name":"abbrev","version":"1.0.3","description":"Like ruby's abbrev module, but in js","author":{"name":"Isaac Z. Schlueter","email":"i@izs.me"},"main":"./lib/abbrev.js","scripts":{"test":"node lib/abbrev.js"},"repository":{"type":"git","url":"git://github.com/isaacs/abbrev-js.git"},"_id":"abbrev@1.0.3","engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.0.0rc7","_nodeVersion":"v0.5.0-pre","_defaultsLoaded":true,"dist":{"shasum":"aa049c967f999222aa42e14434f0c562ef468241","tarball":"http://registry.npmjs.org/abbrev/-/abbrev-1.0.3.tgz"},"directories":{}},"1.0.4":{"name":"abbrev","version":"1.0.4","description":"Like ruby's abbrev module, but in js","author":{"name":"Isaac Z. Schlueter","email":"i@izs.me"},"main":"./lib/abbrev.js","scripts":{"test":"node lib/abbrev.js"},"repository":{"type":"git","url":"http://github.com/isaacs/abbrev-js"},"license":{"type":"MIT","url":"https://github.com/isaacs/abbrev-js/raw/master/LICENSE"},"_id":"abbrev@1.0.4","dist":{"shasum":"bd55ae5e413ba1722ee4caba1f6ea10414a59ecd","tarball":"http://registry.npmjs.org/abbrev/-/abbrev-1.0.4.tgz"},"_npmVersion":"1.1.70","_npmUser":{"name":"isaacs","email":"i@izs.me"},"maintainers":[{"name":"isaacs","email":"i@izs.me"}],"directories":{}},"1.0.5":{"name":"abbrev","version":"1.0.5","description":"Like ruby's abbrev module, but in js","author":{"name":"Isaac Z. Schlueter","email":"i@izs.me"},"main":"abbrev.js","scripts":{"test":"node test.js"},"repository":{"type":"git","url":"http://github.com/isaacs/abbrev-js"},"license":{"type":"MIT","url":"https://github.com/isaacs/abbrev-js/raw/master/LICENSE"},"bugs":{"url":"https://github.com/isaacs/abbrev-js/issues"},"homepage":"https://github.com/isaacs/abbrev-js","_id":"abbrev@1.0.5","_shasum":"5d8257bd9ebe435e698b2fa431afde4fe7b10b03","_from":".","_npmVersion":"1.4.7","_npmUser":{"name":"isaacs","email":"i@izs.me"},"maintainers":[{"name":"isaacs","email":"i@izs.me"}],"dist":{"shasum":"5d8257bd9ebe435e698b2fa431afde4fe7b10b03","tarball":"http://registry.npmjs.org/abbrev/-/abbrev-1.0.5.tgz"}}},"maintainers":[{"name":"isaacs","email":"i@izs.me"}],"author":{"name":"Isaac Z. Schlueter","email":"i@izs.me"},"description":"Like ruby's abbrev module, but in js","time":{"modified":"2014-04-17T20:09:12.523Z","created":"2011-03-21T22:21:11.183Z","1.0.1":"2011-03-21T22:21:11.183Z","1.0.2":"2011-03-21T22:21:11.183Z","1.0.3":"2011-03-21T22:21:11.183Z","1.0.3-1":"2011-03-24T23:01:19.581Z","1.0.4":"2013-01-09T00:01:24.135Z","1.0.5":"2014-04-17T20:09:12.523Z"},"repository":{"type":"git","url":"http://github.com/isaacs/abbrev-js"},"users":{"leesei":true,"ceejbot":true,"isaacs":true,"npm-www":true,"jamescostian":true,"tunnckocore":true},"readme":"# abbrev-js\n\nJust like [ruby's Abbrev](http://apidock.com/ruby/Abbrev).\n\nUsage:\n\n var abbrev = require(\"abbrev\");\n abbrev(\"foo\", \"fool\", \"folding\", \"flop\");\n \n // returns:\n { fl: 'flop'\n , flo: 'flop'\n , flop: 'flop'\n , fol: 'folding'\n , fold: 'folding'\n , foldi: 'folding'\n , foldin: 'folding'\n , folding: 'folding'\n , foo: 'foo'\n , fool: 'fool'\n }\n\nThis is handy for command-line scripts, or other cases where you want to be able to accept shorthands.\n","readmeFilename":"README.md","homepage":"https://github.com/isaacs/abbrev-js","bugs":{"url":"https://github.com/isaacs/abbrev-js/issues"},"license":{"type":"MIT","url":"https://github.com/isaacs/abbrev-js/raw/master/LICENSE"}} 2 | -------------------------------------------------------------------------------- /lib/remote-ls.js: -------------------------------------------------------------------------------- 1 | var _ = require('lodash') 2 | var async = require('async') 3 | var semver = require('semver') 4 | var request = require('request') 5 | var once = require('once') 6 | var npa = require('npm-package-arg') 7 | 8 | // perform a recursive walk of a remote 9 | // npm package and determine its dependency 10 | // tree. 11 | function RemoteLS (opts) { 12 | var _this = this 13 | 14 | _.extend(this, { 15 | logger: console, 16 | development: true, // include dev dependencies. 17 | optional: true, // include optional dependencies. 18 | peer: false, // include peer dependencies. 19 | verbose: false, 20 | registry: require('registry-url')(), // URL of registry to ls. 21 | queue: async.queue(function (task, done) { 22 | _this._loadPackageJson(task, done) 23 | }, 8), 24 | tree: {}, 25 | flat: {} 26 | }, require('./config')(), opts) 27 | 28 | this.queue.pause() 29 | } 30 | 31 | RemoteLS.prototype._loadPackageJson = function (task, done) { 32 | var _this = this 33 | var name = task.name 34 | 35 | // account for scoped packages like @foo/bar 36 | var couchPackageName = name && npa(name).escapedName 37 | 38 | // wrap done so it's only called once 39 | // if done throws in _walkDependencies, it will be called again in catch below 40 | // we want to avoid "Callback was already called." from async 41 | done = once(done) 42 | 43 | request.get(this.registry.replace(/\/$/, '') + '/' + couchPackageName, {json: true}, function (err, res, obj) { 44 | if (err || (res.statusCode < 200 || res.statusCode >= 400)) { 45 | var message = res ? 'status = ' + res.statusCode : 'error = ' + err.message 46 | _this.logger.log( 47 | 'could not load ' + name + '@' + task.version + ' ' + message 48 | ) 49 | return done() 50 | } 51 | 52 | try { 53 | if (_this.verbose) console.log('loading:', name + '@' + task.version) 54 | _this._walkDependencies(task, obj, done) 55 | } catch (e) { 56 | _this.logger.log(e.message) 57 | done() 58 | } 59 | }) 60 | } 61 | 62 | RemoteLS.prototype._walkDependencies = function (task, packageJson, done) { 63 | var _this = this 64 | var version = this._guessVersion(task.version, packageJson) 65 | var dependencies = _.extend( 66 | {}, 67 | packageJson.versions[version].dependencies, 68 | this.optional ? packageJson.versions[version].optionalDependencies : {}, 69 | this.peer ? packageJson.versions[version].peerDependencies : {}, 70 | // show development dependencies if we're at the root, and deevelopment flag is true. 71 | (task.parent === this.tree && this.development) ? packageJson.versions[version].devDependencies : {} 72 | ) 73 | var fullName = packageJson.name + '@' + version 74 | var parent = task.parent[fullName] = {} 75 | 76 | if (_this.flat[fullName]) return done() 77 | else _this.flat[fullName] = true 78 | 79 | Object.keys(dependencies).forEach(function (name) { 80 | _this.queue.push({ 81 | name: name, 82 | version: dependencies[name], 83 | parent: parent 84 | }) 85 | }) 86 | 87 | done() 88 | } 89 | 90 | RemoteLS.prototype._guessVersion = function (versionString, packageJson) { 91 | if (versionString === 'latest') versionString = '*' 92 | 93 | var availableVersions = Object.keys(packageJson.versions) 94 | var version = semver.maxSatisfying(availableVersions, versionString, true) 95 | 96 | // check for prerelease-only versions 97 | if (!version && versionString === '*' && availableVersions.every(function (av) { 98 | return new semver.SemVer(av, true).prerelease.length 99 | })) { 100 | // just use latest then 101 | version = packageJson['dist-tags'] && packageJson['dist-tags'].latest 102 | } 103 | 104 | if (!version) throw Error('could not find a satisfactory version for string ' + versionString) 105 | else return version 106 | } 107 | 108 | RemoteLS.prototype.ls = function (name, version, callback) { 109 | var _this = this 110 | 111 | this.queue.push({ 112 | name: name, 113 | version: version, 114 | parent: this.tree 115 | }) 116 | 117 | this.queue.drain = function () { 118 | callback(_this.tree) 119 | } 120 | 121 | this.queue.resume() 122 | } 123 | 124 | module.exports = RemoteLS 125 | -------------------------------------------------------------------------------- /test/remote-ls-test.js: -------------------------------------------------------------------------------- 1 | var test = require('tap').test 2 | var nock = require('nock') 3 | var fs = require('fs') 4 | var RemoteLS = require('../lib/remote-ls') 5 | 6 | require('chai').should() 7 | 8 | test('RemoteLS', function (t) { 9 | t.test('guessVersion', function (t) { 10 | t.test('should handle an exact version being provided', function (t) { 11 | var versionString = '1.0.0' 12 | var packageJson = JSON.parse( 13 | fs.readFileSync('./test/fixtures/nopt.json').toString() 14 | ) 15 | var ls = new RemoteLS() 16 | 17 | t.equal( 18 | ls._guessVersion(versionString, packageJson), 19 | '1.0.0' 20 | ) 21 | t.end() 22 | }) 23 | 24 | t.test('should handle a complex version being provided', function (t) { 25 | var versionString = '*' 26 | var packageJson = JSON.parse( 27 | fs.readFileSync('./test/fixtures/nopt.json').toString() 28 | ) 29 | var ls = new RemoteLS() 30 | 31 | t.equal( 32 | ls._guessVersion(versionString, packageJson), 33 | '3.0.1' 34 | ) 35 | t.end() 36 | }) 37 | 38 | t.test('should raise an exception if version cannot be found', function (t) { 39 | var versionString = '9.0.0' 40 | var packageJson = JSON.parse( 41 | fs.readFileSync('./test/fixtures/nopt.json').toString() 42 | ) 43 | var ls = new RemoteLS() 44 | 45 | t.throws( 46 | function () { 47 | ls._guessVersion(versionString, packageJson) 48 | }, 49 | /could not find a satisfactory version/ 50 | ) 51 | t.end() 52 | }) 53 | 54 | t.test('should raise an exception if version cannot be found', function (t) { 55 | var versionString = '9.0.0' 56 | var packageJson = JSON.parse( 57 | fs.readFileSync('./test/fixtures/nopt.json').toString() 58 | ) 59 | var ls = new RemoteLS() 60 | 61 | t.throws( 62 | function () { 63 | ls._guessVersion(versionString, packageJson) 64 | }, 65 | /could not find a satisfactory version/ 66 | ) 67 | t.end() 68 | }) 69 | 70 | t.test('should handle "latest" being provided as version', function (t) { 71 | var versionString = 'latest' 72 | var packageJson = JSON.parse( 73 | fs.readFileSync('./test/fixtures/nopt.json').toString() 74 | ) 75 | var ls = new RemoteLS() 76 | 77 | t.equal( 78 | ls._guessVersion(versionString, packageJson), 79 | '3.0.1' 80 | ) 81 | t.end() 82 | }) 83 | 84 | t.test('should return dist-tags.latest when * wanted and package has only prerelease versions', function (t) { 85 | var versionString = '*' 86 | var packageJson = JSON.parse( 87 | fs.readFileSync('./test/fixtures/angular-core.json').toString() 88 | ) 89 | var ls = new RemoteLS() 90 | 91 | t.equal( 92 | ls._guessVersion(versionString, packageJson), 93 | '2.0.0-rc.3' 94 | ) 95 | t.end() 96 | }) 97 | 98 | t.end() 99 | }) 100 | 101 | t.test('_walkDependencies', function (t) { 102 | t.test('should push appropriate dependencies to queue', function (t) { 103 | var packageJson = JSON.parse( 104 | fs.readFileSync('./test/fixtures/nopt.json').toString() 105 | ) 106 | var ls = new RemoteLS({ 107 | queue: { 108 | pause: function () {}, 109 | push: function (obj) { 110 | t.equal(obj.name, 'abbrev') 111 | t.equal(obj.version, '1') 112 | t.end() 113 | } 114 | } 115 | }) 116 | 117 | ls._walkDependencies({ 118 | name: 'nopt', 119 | version: '1.0.6', 120 | parent: {} 121 | }, packageJson, function () {}) 122 | }) 123 | 124 | t.test('should push devDependencies to queue', function (t) { 125 | var packageJson = JSON.parse( 126 | fs.readFileSync('./test/fixtures/nopt.json').toString() 127 | ) 128 | var ls = new RemoteLS({ 129 | queue: { 130 | pause: function () {}, 131 | push: function (obj) { 132 | t.equal(obj.name, 'tap') 133 | t.equal(obj.version, '1.0.0') 134 | t.end() 135 | } 136 | } 137 | }) 138 | 139 | ls._walkDependencies({ 140 | name: 'nopt', 141 | version: '1.0.8', 142 | parent: ls.tree 143 | }, packageJson, function () {}) 144 | }) 145 | 146 | t.test('should not raise an exception if package has no dependencies', function (t) { 147 | var packageJson = JSON.parse( 148 | fs.readFileSync('./test/fixtures/abbrev.json').toString() 149 | ) 150 | var ls = new RemoteLS() 151 | 152 | t.doesNotThrow(function () { 153 | ls._walkDependencies({ 154 | name: 'abbrev', 155 | version: '*', 156 | parent: {} 157 | }, packageJson, function () {}) 158 | }) 159 | 160 | t.end() 161 | }) 162 | 163 | t.test('should not walk dependency if dependency has already been observed', function (t) { 164 | var packageJson = JSON.parse( 165 | fs.readFileSync('./test/fixtures/nopt.json').toString() 166 | ) 167 | var ls = new RemoteLS({ 168 | flat: { 169 | 'nopt@1.0.0': true 170 | }, 171 | queue: { 172 | pause: function () {}, 173 | push: function (obj) { 174 | t.fail('should not walk dependency') 175 | t.end() 176 | } 177 | } 178 | }) 179 | 180 | ls._walkDependencies({ 181 | name: 'nopt', 182 | version: '1.0.0', 183 | parent: {} 184 | }, packageJson, function () {}) 185 | 186 | t.end() 187 | }) 188 | 189 | t.test('should push peerDependencies to queue', function (t) { 190 | var packageJson = JSON.parse( 191 | fs.readFileSync('./test/fixtures/angular-core.json').toString() 192 | ) 193 | var ls = new RemoteLS({ 194 | peer: true, 195 | queue: { 196 | pause: function () {}, 197 | push: function (obj) { 198 | t.equal(obj.name, 'rxjs') 199 | t.equal(obj.version, '5.0.0-beta.6') 200 | t.end() 201 | } 202 | } 203 | }) 204 | 205 | ls._walkDependencies({ 206 | name: 'angular', 207 | version: '2.0.0-rc.3', 208 | parent: ls.tree 209 | }, packageJson, function () {}) 210 | }) 211 | 212 | t.end() 213 | }) 214 | 215 | t.test('ls', function (t) { 216 | t.test('handles a 404 and prints an appropriate message', function (t) { 217 | nock('https://skimdb.npmjs.com') 218 | .get('/registry/request') 219 | .reply(404) 220 | var ls = new RemoteLS({ 221 | registry: 'https://skimdb.npmjs.com/registry/', 222 | logger: { 223 | log: function (msg) { 224 | t.match(msg, /status = 404/) 225 | t.end() 226 | } 227 | } 228 | }) 229 | 230 | ls.ls('request', '*', function () {}) 231 | }) 232 | 233 | t.test('defaults to appropriate registry URL', function (t) { 234 | nock('https://registry.npmjs.org') 235 | .get('/request') 236 | .reply(404) 237 | var ls = new RemoteLS({ 238 | logger: { 239 | log: function (msg) { 240 | t.match(msg, /status = 404/) 241 | t.end() 242 | } 243 | } 244 | }) 245 | 246 | ls.ls('request', '*', function () {}) 247 | }) 248 | 249 | t.test('happy path works as expected', function (t) { 250 | var request = nock('https://registry.npmjs.org') 251 | .get('/request') 252 | .reply(200, { 253 | name: 'request', 254 | versions: { 255 | '0.0.1': { 256 | dependencies: { 257 | lodash: '0.0.2' 258 | } 259 | } 260 | } 261 | }) 262 | var lodash = nock('https://registry.npmjs.org') 263 | .get('/lodash') 264 | .reply(200, { 265 | name: 'lodash', 266 | versions: { 267 | '0.0.2': { 268 | dependencies: {} 269 | } 270 | } 271 | }) 272 | var ls = new RemoteLS() 273 | 274 | ls.ls('request', '*', function (res) { 275 | res.should.deep.equal({ 'request@0.0.1': { 'lodash@0.0.2': {} } }) 276 | request.done() 277 | lodash.done() 278 | t.end() 279 | }) 280 | }) 281 | 282 | t.test('supports scoped packages', function (t) { 283 | var storybook = nock('https://registry.npmjs.org') 284 | .get('/@kadira%2fstorybook') 285 | .reply(200, { 286 | name: '@kadira/storybook', 287 | versions: { 288 | '1.30.0': { 289 | dependencies: { '@kadira/storybook-core': '1.27.0' } 290 | } 291 | } 292 | }) 293 | var storybook404 = nock('https://registry.npmjs.org') 294 | .get('/@kadira/storybook') 295 | .reply(404, { 296 | error: 'Not found' 297 | }) 298 | var core = nock('https://registry.npmjs.org') 299 | .get('/@kadira%2fstorybook-core') 300 | .reply(200, { 301 | name: '@kadira/storybook-core', 302 | versions: { 303 | '1.27.0': { dependencies: {} } 304 | } 305 | }) 306 | var core404 = nock('https://registry.npmjs.org') 307 | .get('/@kadira/storybook-core') 308 | .reply(404, { 309 | error: 'Not found' 310 | }) 311 | var ls = new RemoteLS() 312 | 313 | ls.ls('@kadira/storybook', '*', function (res) { 314 | res.should.deep.equal({ '@kadira/storybook@1.30.0': { '@kadira/storybook-core@1.27.0': {} } }) 315 | storybook.done() 316 | core.done() 317 | t.notOk(storybook404.isDone()) 318 | t.notOk(core404.isDone()) 319 | t.end() 320 | }) 321 | }) 322 | 323 | t.end() 324 | }) 325 | 326 | t.end() 327 | }) 328 | -------------------------------------------------------------------------------- /test/fixtures/angular-core.json: -------------------------------------------------------------------------------- 1 | { 2 | "_id": "@angular/core", 3 | "_rev": "18-bd6960c220ca5abb5dc3ce61d7b1518e", 4 | "name": "@angular/core", 5 | "dist-tags": { 6 | "latest": "2.0.0-rc.3" 7 | }, 8 | "versions": { 9 | "0.0.0-0": { 10 | "name": "@angular/core", 11 | "version": "0.0.0-0", 12 | "description": "", 13 | "main": "index.js", 14 | "jsnext:main": "esm/index.js", 15 | "typings": "index.d.ts", 16 | "author": { 17 | "name": "angular" 18 | }, 19 | "license": "MIT", 20 | "peerDependencies": { 21 | "rxjs": "5.0.0-beta.2", 22 | "zone.js": "^0.6.6" 23 | }, 24 | "_id": "@angular/core@0.0.0-0", 25 | "scripts": {}, 26 | "_shasum": "86a993dccd1afc17de1d1108913fca0b609cd4e9", 27 | "_from": "dist/packages-dist/core", 28 | "_resolved": "file:dist/packages-dist/core", 29 | "_npmVersion": "3.8.7", 30 | "_nodeVersion": "5.4.1", 31 | "_npmUser": { 32 | "name": "angular", 33 | "email": "angular-core+npm@google.com" 34 | }, 35 | "dist": { 36 | "shasum": "86a993dccd1afc17de1d1108913fca0b609cd4e9", 37 | "tarball": "https://registry.npmjs.org/@angular/core/-/core-0.0.0-0.tgz" 38 | }, 39 | "maintainers": [ 40 | { 41 | "name": "angular", 42 | "email": "angular-core+npm@google.com" 43 | } 44 | ], 45 | "_npmOperationalInternal": { 46 | "host": "packages-12-west.internal.npmjs.com", 47 | "tmp": "tmp/core-0.0.0-0.tgz_1461817407408_0.06274212151765823" 48 | }, 49 | "directories": {} 50 | }, 51 | "0.0.0-1": { 52 | "name": "@angular/core", 53 | "version": "0.0.0-1", 54 | "description": "", 55 | "main": "index.js", 56 | "jsnext:main": "esm/index.js", 57 | "typings": "index.d.ts", 58 | "author": { 59 | "name": "angular" 60 | }, 61 | "license": "MIT", 62 | "peerDependencies": { 63 | "rxjs": "5.0.0-beta.2", 64 | "zone.js": "^0.6.6" 65 | }, 66 | "_id": "@angular/core@0.0.0-1", 67 | "scripts": {}, 68 | "_shasum": "c7d4e03924c86c1ee1c9c60d90280a7322e77e67", 69 | "_from": "dist/packages-dist/core", 70 | "_resolved": "file:dist/packages-dist/core", 71 | "_npmVersion": "3.8.7", 72 | "_nodeVersion": "5.4.1", 73 | "_npmUser": { 74 | "name": "angular", 75 | "email": "angular-core+npm@google.com" 76 | }, 77 | "dist": { 78 | "shasum": "c7d4e03924c86c1ee1c9c60d90280a7322e77e67", 79 | "tarball": "https://registry.npmjs.org/@angular/core/-/core-0.0.0-1.tgz" 80 | }, 81 | "maintainers": [ 82 | { 83 | "name": "angular", 84 | "email": "angular-core+npm@google.com" 85 | } 86 | ], 87 | "_npmOperationalInternal": { 88 | "host": "packages-12-west.internal.npmjs.com", 89 | "tmp": "tmp/core-0.0.0-1.tgz_1461968769228_0.4824655666016042" 90 | }, 91 | "directories": {} 92 | }, 93 | "0.0.0-2": { 94 | "name": "@angular/core", 95 | "version": "0.0.0-2", 96 | "description": "", 97 | "main": "index.js", 98 | "jsnext:main": "esm/index.js", 99 | "typings": "index.d.ts", 100 | "author": { 101 | "name": "angular" 102 | }, 103 | "license": "MIT", 104 | "peerDependencies": { 105 | "rxjs": "5.0.0-beta.6", 106 | "zone.js": "^0.6.6" 107 | }, 108 | "_id": "@angular/core@0.0.0-2", 109 | "scripts": {}, 110 | "_shasum": "e89f6ffb56cf4ced1a77766c14333e0c9c690670", 111 | "_from": "dist/packages-dist/core", 112 | "_resolved": "file:dist/packages-dist/core", 113 | "_npmVersion": "3.8.7", 114 | "_nodeVersion": "5.4.1", 115 | "_npmUser": { 116 | "name": "angular", 117 | "email": "angular-core+npm@google.com" 118 | }, 119 | "dist": { 120 | "shasum": "e89f6ffb56cf4ced1a77766c14333e0c9c690670", 121 | "tarball": "https://registry.npmjs.org/@angular/core/-/core-0.0.0-2.tgz" 122 | }, 123 | "maintainers": [ 124 | { 125 | "name": "angular", 126 | "email": "angular-core+npm@google.com" 127 | } 128 | ], 129 | "_npmOperationalInternal": { 130 | "host": "packages-16-east.internal.npmjs.com", 131 | "tmp": "tmp/core-0.0.0-2.tgz_1461969055255_0.8375075184740126" 132 | }, 133 | "directories": {} 134 | }, 135 | "0.0.0-3": { 136 | "name": "@angular/core", 137 | "version": "0.0.0-3", 138 | "description": "", 139 | "main": "index.js", 140 | "jsnext:main": "esm/index.js", 141 | "typings": "index.d.ts", 142 | "author": { 143 | "name": "angular" 144 | }, 145 | "license": "MIT", 146 | "peerDependencies": { 147 | "rxjs": "5.0.0-beta.6", 148 | "zone.js": "^0.6.6" 149 | }, 150 | "_id": "@angular/core@0.0.0-3", 151 | "scripts": {}, 152 | "_shasum": "e04af2e986bf3b6f1e1f76297af94c319618d4b8", 153 | "_from": "dist/packages-dist/core", 154 | "_resolved": "file:dist/packages-dist/core", 155 | "_npmVersion": "3.8.7", 156 | "_nodeVersion": "5.4.1", 157 | "_npmUser": { 158 | "name": "angular", 159 | "email": "angular-core+npm@google.com" 160 | }, 161 | "dist": { 162 | "shasum": "e04af2e986bf3b6f1e1f76297af94c319618d4b8", 163 | "tarball": "https://registry.npmjs.org/@angular/core/-/core-0.0.0-3.tgz" 164 | }, 165 | "maintainers": [ 166 | { 167 | "name": "angular", 168 | "email": "angular-core+npm@google.com" 169 | } 170 | ], 171 | "_npmOperationalInternal": { 172 | "host": "packages-12-west.internal.npmjs.com", 173 | "tmp": "tmp/core-0.0.0-3.tgz_1462004972793_0.5296473759226501" 174 | }, 175 | "directories": {} 176 | }, 177 | "0.0.0-4": { 178 | "name": "@angular/core", 179 | "version": "0.0.0-4", 180 | "description": "", 181 | "main": "index.js", 182 | "jsnext:main": "esm/index.js", 183 | "typings": "index.d.ts", 184 | "author": { 185 | "name": "angular" 186 | }, 187 | "license": "MIT", 188 | "peerDependencies": { 189 | "rxjs": "5.0.0-beta.6", 190 | "zone.js": "^0.6.6" 191 | }, 192 | "_id": "@angular/core@0.0.0-4", 193 | "scripts": {}, 194 | "_shasum": "12a99e89f04c7c5e4fdca0581ae87910f9c3514c", 195 | "_from": "dist/packages-dist/core", 196 | "_resolved": "file:dist/packages-dist/core", 197 | "_npmVersion": "3.8.7", 198 | "_nodeVersion": "5.4.1", 199 | "_npmUser": { 200 | "name": "angular", 201 | "email": "angular-core+npm@google.com" 202 | }, 203 | "dist": { 204 | "shasum": "12a99e89f04c7c5e4fdca0581ae87910f9c3514c", 205 | "tarball": "https://registry.npmjs.org/@angular/core/-/core-0.0.0-4.tgz" 206 | }, 207 | "maintainers": [ 208 | { 209 | "name": "angular", 210 | "email": "angular-core+npm@google.com" 211 | } 212 | ], 213 | "_npmOperationalInternal": { 214 | "host": "packages-12-west.internal.npmjs.com", 215 | "tmp": "tmp/core-0.0.0-4.tgz_1462143694703_0.22930496162734926" 216 | }, 217 | "directories": {} 218 | }, 219 | "0.0.0-5": { 220 | "name": "@angular/core", 221 | "version": "0.0.0-5", 222 | "description": "", 223 | "main": "index.js", 224 | "jsnext:main": "esm/index.js", 225 | "typings": "index.d.ts", 226 | "author": { 227 | "name": "angular" 228 | }, 229 | "license": "MIT", 230 | "peerDependencies": { 231 | "rxjs": "5.0.0-beta.6", 232 | "zone.js": "^0.6.6" 233 | }, 234 | "_id": "@angular/core@0.0.0-5", 235 | "scripts": {}, 236 | "_shasum": "7987d7b665e8ff6f74134bc48a5c85fe67fd027e", 237 | "_from": "dist/packages-dist/core", 238 | "_resolved": "file:dist/packages-dist/core", 239 | "_npmVersion": "3.8.7", 240 | "_nodeVersion": "5.4.1", 241 | "_npmUser": { 242 | "name": "angular", 243 | "email": "angular-core+npm@google.com" 244 | }, 245 | "dist": { 246 | "shasum": "7987d7b665e8ff6f74134bc48a5c85fe67fd027e", 247 | "tarball": "https://registry.npmjs.org/@angular/core/-/core-0.0.0-5.tgz" 248 | }, 249 | "maintainers": [ 250 | { 251 | "name": "angular", 252 | "email": "angular-core+npm@google.com" 253 | } 254 | ], 255 | "_npmOperationalInternal": { 256 | "host": "packages-12-west.internal.npmjs.com", 257 | "tmp": "tmp/core-0.0.0-5.tgz_1462172219165_0.5186660275794566" 258 | }, 259 | "directories": {} 260 | }, 261 | "0.0.0-6": { 262 | "name": "@angular/core", 263 | "version": "0.0.0-6", 264 | "description": "", 265 | "main": "index.js", 266 | "jsnext:main": "esm/index.js", 267 | "typings": "index.d.ts", 268 | "author": { 269 | "name": "angular" 270 | }, 271 | "license": "MIT", 272 | "peerDependencies": { 273 | "rxjs": "5.0.0-beta.6", 274 | "zone.js": "^0.6.6" 275 | }, 276 | "_id": "@angular/core@0.0.0-6", 277 | "scripts": {}, 278 | "_shasum": "af5b5fed4ced08a97863df61196dbe674a681827", 279 | "_from": "dist/packages-dist/core", 280 | "_resolved": "file:dist/packages-dist/core", 281 | "_npmVersion": "3.8.7", 282 | "_nodeVersion": "5.4.1", 283 | "_npmUser": { 284 | "name": "angular", 285 | "email": "angular-core+npm@google.com" 286 | }, 287 | "dist": { 288 | "shasum": "af5b5fed4ced08a97863df61196dbe674a681827", 289 | "tarball": "https://registry.npmjs.org/@angular/core/-/core-0.0.0-6.tgz" 290 | }, 291 | "maintainers": [ 292 | { 293 | "name": "angular", 294 | "email": "angular-core+npm@google.com" 295 | } 296 | ], 297 | "_npmOperationalInternal": { 298 | "host": "packages-12-west.internal.npmjs.com", 299 | "tmp": "tmp/core-0.0.0-6.tgz_1462221728789_0.5278214267455041" 300 | }, 301 | "directories": {} 302 | }, 303 | "0.0.0-7": { 304 | "name": "@angular/core", 305 | "version": "0.0.0-7", 306 | "description": "", 307 | "main": "index.js", 308 | "jsnext:main": "esm/index.js", 309 | "typings": "index.d.ts", 310 | "author": { 311 | "name": "angular" 312 | }, 313 | "license": "MIT", 314 | "peerDependencies": { 315 | "rxjs": "5.0.0-beta.6", 316 | "zone.js": "^0.6.6" 317 | }, 318 | "_id": "@angular/core@0.0.0-7", 319 | "scripts": {}, 320 | "_shasum": "671014c18856063a47786428ff50ad71a2dd1b78", 321 | "_from": "dist/packages-dist/core", 322 | "_resolved": "file:dist/packages-dist/core", 323 | "_npmVersion": "3.8.7", 324 | "_nodeVersion": "5.4.1", 325 | "_npmUser": { 326 | "name": "angular", 327 | "email": "angular-core+npm@google.com" 328 | }, 329 | "dist": { 330 | "shasum": "671014c18856063a47786428ff50ad71a2dd1b78", 331 | "tarball": "https://registry.npmjs.org/@angular/core/-/core-0.0.0-7.tgz" 332 | }, 333 | "maintainers": [ 334 | { 335 | "name": "angular", 336 | "email": "angular-core+npm@google.com" 337 | } 338 | ], 339 | "_npmOperationalInternal": { 340 | "host": "packages-12-west.internal.npmjs.com", 341 | "tmp": "tmp/core-0.0.0-7.tgz_1462227162697_0.8847784982062876" 342 | }, 343 | "directories": {} 344 | }, 345 | "2.0.0-rc.0": { 346 | "name": "@angular/core", 347 | "version": "2.0.0-rc.0", 348 | "description": "", 349 | "main": "index.js", 350 | "jsnext:main": "esm/index.js", 351 | "typings": "index.d.ts", 352 | "author": { 353 | "name": "angular" 354 | }, 355 | "license": "MIT", 356 | "peerDependencies": { 357 | "rxjs": "5.0.0-beta.6", 358 | "zone.js": "^0.6.6" 359 | }, 360 | "_id": "@angular/core@2.0.0-rc.0", 361 | "scripts": {}, 362 | "_shasum": "c74d23aa05cce7be4754a0956c075e2d62d3afc0", 363 | "_from": "dist/packages-dist/core", 364 | "_resolved": "file:dist/packages-dist/core", 365 | "_npmVersion": "3.8.7", 366 | "_nodeVersion": "5.4.1", 367 | "_npmUser": { 368 | "name": "angular", 369 | "email": "angular-core+npm@google.com" 370 | }, 371 | "dist": { 372 | "shasum": "c74d23aa05cce7be4754a0956c075e2d62d3afc0", 373 | "tarball": "https://registry.npmjs.org/@angular/core/-/core-2.0.0-rc.0.tgz" 374 | }, 375 | "maintainers": [ 376 | { 377 | "name": "angular", 378 | "email": "angular-core+npm@google.com" 379 | } 380 | ], 381 | "_npmOperationalInternal": { 382 | "host": "packages-12-west.internal.npmjs.com", 383 | "tmp": "tmp/core-2.0.0-rc.0.tgz_1462234522995_0.7761272273492068" 384 | }, 385 | "directories": {} 386 | }, 387 | "2.0.0-rc.1": { 388 | "name": "@angular/core", 389 | "version": "2.0.0-rc.1", 390 | "description": "", 391 | "main": "index.js", 392 | "jsnext:main": "esm/index.js", 393 | "typings": "index.d.ts", 394 | "author": { 395 | "name": "angular" 396 | }, 397 | "license": "MIT", 398 | "peerDependencies": { 399 | "rxjs": "5.0.0-beta.6", 400 | "zone.js": "^0.6.6" 401 | }, 402 | "_id": "@angular/core@2.0.0-rc.1", 403 | "scripts": {}, 404 | "_shasum": "34e381faffb60fc12e8ac9887badb252550907e0", 405 | "_from": "dist/packages-dist/core", 406 | "_resolved": "file:dist/packages-dist/core", 407 | "_npmVersion": "3.8.7", 408 | "_nodeVersion": "5.4.1", 409 | "_npmUser": { 410 | "name": "angular", 411 | "email": "angular-core+npm@google.com" 412 | }, 413 | "dist": { 414 | "shasum": "34e381faffb60fc12e8ac9887badb252550907e0", 415 | "tarball": "https://registry.npmjs.org/@angular/core/-/core-2.0.0-rc.1.tgz" 416 | }, 417 | "maintainers": [ 418 | { 419 | "name": "angular", 420 | "email": "angular-core+npm@google.com" 421 | } 422 | ], 423 | "_npmOperationalInternal": { 424 | "host": "packages-16-east.internal.npmjs.com", 425 | "tmp": "tmp/core-2.0.0-rc.1.tgz_1462310703407_0.9186127157881856" 426 | }, 427 | "directories": {} 428 | }, 429 | "2.0.0-rc.2": { 430 | "name": "@angular/core", 431 | "version": "2.0.0-rc.2", 432 | "description": "", 433 | "main": "index.js", 434 | "jsnext:main": "esm/index.js", 435 | "typings": "index.d.ts", 436 | "author": { 437 | "name": "angular" 438 | }, 439 | "license": "MIT", 440 | "peerDependencies": { 441 | "rxjs": "5.0.0-beta.6", 442 | "zone.js": "^0.6.6" 443 | }, 444 | "repository": { 445 | "type": "git", 446 | "url": "git+https://github.com/angular/angular.git" 447 | }, 448 | "bugs": { 449 | "url": "https://github.com/angular/angular/issues" 450 | }, 451 | "homepage": "https://github.com/angular/angular#readme", 452 | "_id": "@angular/core@2.0.0-rc.2", 453 | "scripts": {}, 454 | "_shasum": "a5761cdaf1c65b0c726b34e8bc1bb5dd692086c3", 455 | "_from": "dist/packages-dist/core", 456 | "_resolved": "file:dist/packages-dist/core", 457 | "_npmVersion": "3.9.2", 458 | "_nodeVersion": "5.4.1", 459 | "_npmUser": { 460 | "name": "angular", 461 | "email": "angular-core+npm@google.com" 462 | }, 463 | "dist": { 464 | "shasum": "a5761cdaf1c65b0c726b34e8bc1bb5dd692086c3", 465 | "tarball": "https://registry.npmjs.org/@angular/core/-/core-2.0.0-rc.2.tgz" 466 | }, 467 | "maintainers": [ 468 | { 469 | "name": "angular", 470 | "email": "angular-core+npm@google.com" 471 | } 472 | ], 473 | "_npmOperationalInternal": { 474 | "host": "packages-16-east.internal.npmjs.com", 475 | "tmp": "tmp/core-2.0.0-rc.2.tgz_1466013731566_0.9461118599865586" 476 | }, 477 | "directories": {} 478 | }, 479 | "2.0.0-rc.3": { 480 | "name": "@angular/core", 481 | "version": "2.0.0-rc.3", 482 | "description": "", 483 | "main": "index.js", 484 | "jsnext:main": "esm/index.js", 485 | "typings": "index.d.ts", 486 | "author": { 487 | "name": "angular" 488 | }, 489 | "license": "MIT", 490 | "peerDependencies": { 491 | "rxjs": "5.0.0-beta.6" 492 | }, 493 | "repository": { 494 | "type": "git", 495 | "url": "git+https://github.com/angular/angular.git" 496 | }, 497 | "bugs": { 498 | "url": "https://github.com/angular/angular/issues" 499 | }, 500 | "homepage": "https://github.com/angular/angular#readme", 501 | "_id": "@angular/core@2.0.0-rc.3", 502 | "scripts": {}, 503 | "_shasum": "cd13cd17172da0fdbe20d0f273519522f3146694", 504 | "_from": "dist/packages-dist/core", 505 | "_resolved": "file:dist/packages-dist/core", 506 | "_npmVersion": "3.9.2", 507 | "_nodeVersion": "5.4.1", 508 | "_npmUser": { 509 | "name": "angular", 510 | "email": "angular-core+npm@google.com" 511 | }, 512 | "dist": { 513 | "shasum": "cd13cd17172da0fdbe20d0f273519522f3146694", 514 | "tarball": "https://registry.npmjs.org/@angular/core/-/core-2.0.0-rc.3.tgz" 515 | }, 516 | "maintainers": [ 517 | { 518 | "name": "angular", 519 | "email": "angular-core+npm@google.com" 520 | } 521 | ], 522 | "_npmOperationalInternal": { 523 | "host": "packages-12-west.internal.npmjs.com", 524 | "tmp": "tmp/core-2.0.0-rc.3.tgz_1466553890718_0.7374602861236781" 525 | }, 526 | "directories": {} 527 | } 528 | }, 529 | "readme": "ERROR: No README data found!", 530 | "maintainers": [ 531 | { 532 | "name": "angular", 533 | "email": "angular-core+npm@google.com" 534 | } 535 | ], 536 | "time": { 537 | "modified": "2016-06-22T00:04:53.980Z", 538 | "created": "2016-04-28T04:23:30.108Z", 539 | "0.0.0-0": "2016-04-28T04:23:30.108Z", 540 | "0.0.0-1": "2016-04-29T22:26:11.973Z", 541 | "0.0.0-2": "2016-04-29T22:30:56.172Z", 542 | "0.0.0-3": "2016-04-30T08:29:35.373Z", 543 | "0.0.0-4": "2016-05-01T23:01:35.138Z", 544 | "0.0.0-5": "2016-05-02T06:57:01.667Z", 545 | "0.0.0-6": "2016-05-02T20:42:11.430Z", 546 | "0.0.0-7": "2016-05-02T22:12:45.949Z", 547 | "2.0.0-rc.0": "2016-05-03T00:15:26.716Z", 548 | "2.0.0-rc.1": "2016-05-03T21:25:04.689Z", 549 | "2.0.0-rc.2": "2016-06-15T18:02:15.307Z", 550 | "2.0.0-rc.3": "2016-06-22T00:04:53.980Z" 551 | }, 552 | "author": { 553 | "name": "angular" 554 | }, 555 | "license": "MIT", 556 | "readmeFilename": "", 557 | "users": { 558 | "d4nc3r": true, 559 | "langley": true, 560 | "daniborgs": true, 561 | "uditrugman": true, 562 | "jordanilchev": true, 563 | "jeandrebosch": true 564 | }, 565 | "homepage": "https://github.com/angular/angular#readme", 566 | "repository": { 567 | "type": "git", 568 | "url": "git+https://github.com/angular/angular.git" 569 | }, 570 | "bugs": { 571 | "url": "https://github.com/angular/angular/issues" 572 | }, 573 | "_attachments": {} 574 | } 575 | -------------------------------------------------------------------------------- /test/fixtures/nopt.json: -------------------------------------------------------------------------------- 1 | {"_id":"nopt","_rev":"61-c55dce9eca0104468e65919fd55242b1","name":"nopt","description":"Option parsing for Node, supporting types, shorthands, etc. Used by npm.","dist-tags":{"latest":"3.0.1"},"versions":{"1.0.0":{"name":"nopt","version":"1.0.0","description":"Option parsing for Node, supporting types, shorthands, etc. Used by npm.","author":{"name":"Isaac Z. Schlueter","email":"i@izs.me","url":"http://blog.izs.me/"},"main":"lib/nopt.js","scripts":{"test":"node lib/optparse.js"},"repository":{"type":"git","url":"git://github.com/isaacs/nopt.git"},"dependencies":{"nopt": "1.0.0", "abbrev":"1"},"_id":"nopt@1.0.0","engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.0.1rc0","_nodeVersion":"v0.5.0-pre","_defaultsLoaded":true,"dist":{"shasum":"a786d439b09c142dca74b0b29ef1458da50e37d8","tarball":"http://registry.npmjs.org/nopt/-/nopt-1.0.0.tgz","bin":{"0.4-darwin-10.7.0":{"shasum":"e0864df8d3e4d2b81ef268d8a50b2f1bccd39e54","tarball":"http://registry.npmjs.org/nopt/-/nopt-1.0.0-0.4-darwin-10.7.0.tgz"}}},"directories":{}},"1.0.1":{"name":"nopt","version":"1.0.1","description":"Option parsing for Node, supporting types, shorthands, etc. Used by npm.","author":{"name":"Isaac Z. Schlueter","email":"i@izs.me","url":"http://blog.izs.me/"},"main":"lib/nopt.js","scripts":{"test":"node lib/optparse.js"},"repository":{"type":"git","url":"git://github.com/isaacs/nopt.git"},"dependencies":{"abbrev":"1"},"_id":"nopt@1.0.1","engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.0.1rc2","_nodeVersion":"v0.4.4","_defaultsLoaded":true,"dist":{"shasum":"585e38c61508b02b1ea2cc0028eef8c303079285","tarball":"http://registry.npmjs.org/nopt/-/nopt-1.0.1.tgz"}},"1.0.2":{"name":"nopt","version":"1.0.2","description":"Option parsing for Node, supporting types, shorthands, etc. Used by npm.","author":{"name":"Isaac Z. Schlueter","email":"i@izs.me","url":"http://blog.izs.me/"},"main":"lib/nopt.js","scripts":{"test":"node lib/nopt.js"},"repository":{"type":"git","url":"git://github.com/isaacs/nopt.git"},"dependencies":{"abbrev":"1"},"_id":"nopt@1.0.2","engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.0.1rc3","_nodeVersion":"v0.5.0-pre","_defaultsLoaded":true,"dist":{"shasum":"bb26ab771fb09411f716b122c12cd98fdc98f4d1","tarball":"http://registry.npmjs.org/nopt/-/nopt-1.0.2.tgz"}},"1.0.3":{"name":"nopt","version":"1.0.3","description":"Option parsing for Node, supporting types, shorthands, etc. Used by npm.","author":{"name":"Isaac Z. Schlueter","email":"i@izs.me","url":"http://blog.izs.me/"},"main":"lib/nopt.js","scripts":{"test":"node lib/nopt.js"},"repository":{"type":"git","url":"git://github.com/isaacs/nopt.git"},"dependencies":{"abbrev":"1"},"_id":"nopt@1.0.3","engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.0.1rc3","_nodeVersion":"v0.5.0-pre","_defaultsLoaded":true,"dist":{"shasum":"a5557211e05f4baad09bbf8e9d798072bff69166","tarball":"http://registry.npmjs.org/nopt/-/nopt-1.0.3.tgz"}},"1.0.4":{"name":"nopt","version":"1.0.4","description":"Option parsing for Node, supporting types, shorthands, etc. Used by npm.","author":{"name":"Isaac Z. Schlueter","email":"i@izs.me","url":"http://blog.izs.me/"},"main":"lib/nopt.js","scripts":{"test":"node lib/nopt.js"},"repository":{"type":"git","url":"git://github.com/isaacs/nopt.git"},"dependencies":{"abbrev":"1"},"_id":"nopt@1.0.4","engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.0.1rc4","_nodeVersion":"v0.5.0-pre","_defaultsLoaded":true,"dist":{"shasum":"023fc93f439094e662e2e4186345bfabda8eceda","tarball":"http://registry.npmjs.org/nopt/-/nopt-1.0.4.tgz"}},"1.0.5":{"name":"nopt","version":"1.0.5","description":"Option parsing for Node, supporting types, shorthands, etc. Used by npm.","author":{"name":"Isaac Z. Schlueter","email":"i@izs.me","url":"http://blog.izs.me/"},"main":"lib/nopt.js","scripts":{"test":"node lib/nopt.js"},"repository":{"type":"git","url":"git://github.com/isaacs/nopt.git"},"dependencies":{"abbrev":"1"},"devDependencies":{},"_id":"nopt@1.0.5","engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.0.1rcFINAL","_nodeVersion":"v0.4.8-pre","_defaultsLoaded":true,"dist":{"shasum":"fc79e34a4e8862e9c413d2e1cac07ee645ac4cc8","tarball":"http://registry.npmjs.org/nopt/-/nopt-1.0.5.tgz"}},"1.0.6":{"name":"nopt","version":"1.0.6","description":"Option parsing for Node, supporting types, shorthands, etc. Used by npm.","author":{"name":"Isaac Z. Schlueter","email":"i@izs.me","url":"http://blog.izs.me/"},"main":"lib/nopt.js","scripts":{"test":"node lib/nopt.js"},"repository":{"type":"git","url":"git://github.com/isaacs/nopt.git"},"bin":{"nopt":"./bin/nopt.js"},"license":{"type":"MIT","url":"https://github.com/isaacs/nopt/raw/master/LICENSE"},"dependencies":{"abbrev":"1"},"_npmJsonOpts":{"file":"/Users/isaacs/.npm/nopt/1.0.6/package/package.json","wscript":false,"contributors":false,"serverjs":false},"_id":"nopt@1.0.6","devDependencies":{},"engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.0.15","_nodeVersion":"v0.4.10-pre","_defaultsLoaded":true,"dist":{"shasum":"37307cafcdccf78b954ec06dcef31b936b4d03df","tarball":"http://registry.npmjs.org/nopt/-/nopt-1.0.6.tgz"}},"1.0.7":{"name":"nopt","version":"1.0.7","description":"Option parsing for Node, supporting types, shorthands, etc. Used by npm.","author":{"name":"Isaac Z. Schlueter","email":"i@izs.me","url":"http://blog.izs.me/"},"main":"lib/nopt.js","scripts":{"test":"node lib/nopt.js"},"repository":{"type":"git","url":"git://github.com/isaacs/nopt.git"},"bin":{"nopt":"./bin/nopt.js"},"license":{"type":"MIT","url":"https://github.com/isaacs/nopt/raw/master/LICENSE"},"dependencies":{"abbrev":"1"},"_npmJsonOpts":{"file":"/Users/isaacs/.npm/nopt/1.0.7/package/package.json","wscript":false,"contributors":false,"serverjs":false},"_id":"nopt@1.0.7","devDependencies":{},"engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.0.28-pre-DEV-UNSTABLE","_nodeVersion":"v0.4.11","_defaultsLoaded":true,"dist":{"shasum":"cc72658b52a3f653a70883a1823dd8f3ddc57f75","tarball":"http://registry.npmjs.org/nopt/-/nopt-1.0.7.tgz"},"maintainers":[{"name":"isaacs","email":"i@izs.me"}]},"1.0.8":{"name":"nopt","version":"1.0.8","description":"Option parsing for Node, supporting types, shorthands, etc. Used by npm.","author":{"name":"Isaac Z. Schlueter","email":"i@izs.me","url":"http://blog.izs.me/"},"main":"lib/nopt.js","scripts":{"test":"node lib/nopt.js"},"repository":{"type":"git","url":"git://github.com/isaacs/nopt.git"},"bin":{"nopt":"./bin/nopt.js"},"license":{"type":"MIT","url":"https://github.com/isaacs/nopt/raw/master/LICENSE"},"dependencies":{},"_npmJsonOpts":{"file":"/Users/isaacs/.npm/nopt/1.0.8/package/package.json","wscript":false,"contributors":false,"serverjs":false},"_id":"nopt@1.0.8","devDependencies":{"tap": "1.0.0"},"engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.0.28-pre-DEV-UNSTABLE","_nodeVersion":"v0.5.7-pre","_defaultsLoaded":true,"dist":{"shasum":"d4ac752df307f1a02eb771c40ed23188e7ca44c6","tarball":"http://registry.npmjs.org/nopt/-/nopt-1.0.8.tgz"},"maintainers":[{"name":"isaacs","email":"i@izs.me"}]},"1.0.9":{"name":"nopt","version":"1.0.9","description":"Option parsing for Node, supporting types, shorthands, etc. Used by npm.","author":{"name":"Isaac Z. Schlueter","email":"i@izs.me","url":"http://blog.izs.me/"},"main":"lib/nopt.js","scripts":{"test":"node lib/nopt.js"},"repository":{"type":"git","url":"git://github.com/isaacs/nopt.git"},"bin":{"nopt":"./bin/nopt.js"},"license":{"type":"MIT","url":"https://github.com/isaacs/nopt/raw/master/LICENSE"},"dependencies":{},"_npmUser":{"name":"isaacs","email":"i@izs.me"},"_id":"nopt@1.0.9","devDependencies":{},"engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.0.30","_nodeVersion":"v0.5.8-pre","_defaultsLoaded":true,"dist":{"shasum":"3bc0d7cba7bfb0d5a676dbed7c0ebe48a4fd454e","tarball":"http://registry.npmjs.org/nopt/-/nopt-1.0.9.tgz"},"maintainers":[{"name":"isaacs","email":"i@izs.me"}]},"1.0.10":{"name":"nopt","version":"1.0.10","description":"Option parsing for Node, supporting types, shorthands, etc. Used by npm.","author":{"name":"Isaac Z. Schlueter","email":"i@izs.me","url":"http://blog.izs.me/"},"main":"lib/nopt.js","scripts":{"test":"node lib/nopt.js"},"repository":{"type":"git","url":"git://github.com/isaacs/nopt.git"},"bin":{"nopt":"./bin/nopt.js"},"license":{"type":"MIT","url":"https://github.com/isaacs/nopt/raw/master/LICENSE"},"dependencies":{"abbrev":"1"},"_npmUser":{"name":"isaacs","email":"i@izs.me"},"_id":"nopt@1.0.10","devDependencies":{},"engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.0.93","_nodeVersion":"v0.5.9-pre","_defaultsLoaded":true,"dist":{"shasum":"6ddd21bd2a31417b92727dd585f8a6f37608ebee","tarball":"http://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz"},"maintainers":[{"name":"isaacs","email":"i@izs.me"}]},"2.0.0":{"name":"nopt","version":"2.0.0","description":"Option parsing for Node, supporting types, shorthands, etc. Used by npm.","author":{"name":"Isaac Z. Schlueter","email":"i@izs.me","url":"http://blog.izs.me/"},"main":"lib/nopt.js","scripts":{"test":"node lib/nopt.js"},"repository":{"type":"git","url":"http://github.com/isaacs/nopt"},"bin":{"nopt":"./bin/nopt.js"},"license":{"type":"MIT","url":"https://github.com/isaacs/nopt/raw/master/LICENSE"},"dependencies":{"abbrev":"1"},"_id":"nopt@2.0.0","dist":{"shasum":"ca7416f20a5e3f9c3b86180f96295fa3d0b52e0d","tarball":"http://registry.npmjs.org/nopt/-/nopt-2.0.0.tgz"},"maintainers":[{"name":"isaacs","email":"i@izs.me"}]},"2.1.0":{"name":"nopt","version":"2.1.0","description":"Option parsing for Node, supporting types, shorthands, etc. Used by npm.","author":{"name":"Isaac Z. Schlueter","email":"i@izs.me","url":"http://blog.izs.me/"},"main":"lib/nopt.js","scripts":{"test":"node lib/nopt.js"},"repository":{"type":"git","url":"http://github.com/isaacs/nopt"},"bin":{"nopt":"./bin/nopt.js"},"license":{"type":"MIT","url":"https://github.com/isaacs/nopt/raw/master/LICENSE"},"dependencies":{"abbrev":"1"},"_id":"nopt@2.1.0","dist":{"shasum":"2334c03a00c1dcb22eb1c4a4c34ebde213ee49e2","tarball":"http://registry.npmjs.org/nopt/-/nopt-2.1.0.tgz"},"_from":".","_npmVersion":"1.2.1","_npmUser":{"name":"isaacs","email":"i@izs.me"},"maintainers":[{"name":"isaacs","email":"i@izs.me"}]},"2.1.1":{"name":"nopt","version":"2.1.1","description":"Option parsing for Node, supporting types, shorthands, etc. Used by npm.","author":{"name":"Isaac Z. Schlueter","email":"i@izs.me","url":"http://blog.izs.me/"},"main":"lib/nopt.js","scripts":{"test":"node lib/nopt.js"},"repository":{"type":"git","url":"http://github.com/isaacs/nopt"},"bin":{"nopt":"./bin/nopt.js"},"license":{"type":"MIT","url":"https://github.com/isaacs/nopt/raw/master/LICENSE"},"dependencies":{"abbrev":"1"},"_id":"nopt@2.1.1","dist":{"shasum":"91eb7c4b017e7c00adcad1fd6d63944d0fdb75c1","tarball":"http://registry.npmjs.org/nopt/-/nopt-2.1.1.tgz"},"_from":".","_npmVersion":"1.2.1","_npmUser":{"name":"isaacs","email":"i@izs.me"},"maintainers":[{"name":"isaacs","email":"i@izs.me"}]},"2.1.2":{"name":"nopt","version":"2.1.2","description":"Option parsing for Node, supporting types, shorthands, etc. Used by npm.","author":{"name":"Isaac Z. Schlueter","email":"i@izs.me","url":"http://blog.izs.me/"},"main":"lib/nopt.js","scripts":{"test":"node lib/nopt.js"},"repository":{"type":"git","url":"http://github.com/isaacs/nopt"},"bin":{"nopt":"./bin/nopt.js"},"license":{"type":"MIT","url":"https://github.com/isaacs/nopt/raw/master/LICENSE"},"dependencies":{"abbrev":"1"},"bugs":{"url":"https://github.com/isaacs/nopt/issues"},"_id":"nopt@2.1.2","dist":{"shasum":"6cccd977b80132a07731d6e8ce58c2c8303cf9af","tarball":"http://registry.npmjs.org/nopt/-/nopt-2.1.2.tgz"},"_from":".","_npmVersion":"1.3.4","_npmUser":{"name":"isaacs","email":"i@izs.me"},"maintainers":[{"name":"isaacs","email":"i@izs.me"}]},"2.2.0":{"name":"nopt","version":"2.2.0","description":"Option parsing for Node, supporting types, shorthands, etc. Used by npm.","author":{"name":"Isaac Z. Schlueter","email":"i@izs.me","url":"http://blog.izs.me/"},"main":"lib/nopt.js","scripts":{"test":"tap test/*.js"},"repository":{"type":"git","url":"http://github.com/isaacs/nopt"},"bin":{"nopt":"./bin/nopt.js"},"license":{"type":"MIT","url":"https://github.com/isaacs/nopt/raw/master/LICENSE"},"dependencies":{"abbrev":"1"},"devDependencies":{"tap":"~0.4.8"},"bugs":{"url":"https://github.com/isaacs/nopt/issues"},"homepage":"https://github.com/isaacs/nopt","_id":"nopt@2.2.0","dist":{"shasum":"3d106676f3607ac466af9bf82bd707b1501d3bd5","tarball":"http://registry.npmjs.org/nopt/-/nopt-2.2.0.tgz"},"_from":".","_npmVersion":"1.4.2","_npmUser":{"name":"isaacs","email":"i@izs.me"},"maintainers":[{"name":"isaacs","email":"i@izs.me"}]},"2.2.1":{"name":"nopt","version":"2.2.1","description":"Option parsing for Node, supporting types, shorthands, etc. Used by npm.","author":{"name":"Isaac Z. Schlueter","email":"i@izs.me","url":"http://blog.izs.me/"},"main":"lib/nopt.js","scripts":{"test":"tap test/*.js"},"repository":{"type":"git","url":"http://github.com/isaacs/nopt"},"bin":{"nopt":"./bin/nopt.js"},"license":{"type":"MIT","url":"https://github.com/isaacs/nopt/raw/master/LICENSE"},"dependencies":{"abbrev":"1"},"devDependencies":{"tap":"~0.4.8"},"bugs":{"url":"https://github.com/isaacs/nopt/issues"},"homepage":"https://github.com/isaacs/nopt","_id":"nopt@2.2.1","_shasum":"2aa09b7d1768487b3b89a9c5aa52335bff0baea7","_from":".","_npmVersion":"1.4.7","_npmUser":{"name":"isaacs","email":"i@izs.me"},"maintainers":[{"name":"isaacs","email":"i@izs.me"}],"dist":{"shasum":"2aa09b7d1768487b3b89a9c5aa52335bff0baea7","tarball":"http://registry.npmjs.org/nopt/-/nopt-2.2.1.tgz"}},"3.0.0":{"name":"nopt","version":"3.0.0","description":"Option parsing for Node, supporting types, shorthands, etc. Used by npm.","author":{"name":"Isaac Z. Schlueter","email":"i@izs.me","url":"http://blog.izs.me/"},"main":"lib/nopt.js","scripts":{"test":"tap test/*.js"},"repository":{"type":"git","url":"http://github.com/isaacs/nopt"},"bin":{"nopt":"./bin/nopt.js"},"license":{"type":"MIT","url":"https://github.com/isaacs/nopt/raw/master/LICENSE"},"dependencies":{"abbrev":"1"},"devDependencies":{"tap":"~0.4.8"},"gitHead":"b08ea1db39ca91cb5db37bc1b2fcf07e16386094","bugs":{"url":"https://github.com/isaacs/nopt/issues"},"homepage":"https://github.com/isaacs/nopt","_id":"nopt@3.0.0","_shasum":"4fcf4bf09123d5ee6b2f70214a4d95789b875c79","_from":".","_npmVersion":"1.4.14","_npmUser":{"name":"isaacs","email":"i@izs.me"},"maintainers":[{"name":"isaacs","email":"i@izs.me"}],"dist":{"shasum":"4fcf4bf09123d5ee6b2f70214a4d95789b875c79","tarball":"http://registry.npmjs.org/nopt/-/nopt-3.0.0.tgz"}},"3.0.1":{"name":"nopt","version":"3.0.1","description":"Option parsing for Node, supporting types, shorthands, etc. Used by npm.","author":{"name":"Isaac Z. Schlueter","email":"i@izs.me","url":"http://blog.izs.me/"},"main":"lib/nopt.js","scripts":{"test":"tap test/*.js"},"repository":{"type":"git","url":"http://github.com/isaacs/nopt"},"bin":{"nopt":"./bin/nopt.js"},"license":{"type":"MIT","url":"https://github.com/isaacs/nopt/raw/master/LICENSE"},"dependencies":{"abbrev":"1"},"devDependencies":{"tap":"~0.4.8"},"gitHead":"4296f7aba7847c198fea2da594f9e1bec02817ec","bugs":{"url":"https://github.com/isaacs/nopt/issues"},"homepage":"https://github.com/isaacs/nopt","_id":"nopt@3.0.1","_shasum":"bce5c42446a3291f47622a370abbf158fbbacbfd","_from":".","_npmVersion":"1.4.18","_npmUser":{"name":"isaacs","email":"i@izs.me"},"maintainers":[{"name":"isaacs","email":"i@izs.me"}],"dist":{"shasum":"bce5c42446a3291f47622a370abbf158fbbacbfd","tarball":"http://registry.npmjs.org/nopt/-/nopt-3.0.1.tgz"}}},"maintainers":[{"name":"isaacs","email":"i@izs.me"}],"time":{"modified":"2014-07-01T17:12:00.014Z","created":"2011-03-30T03:23:55.464Z","1.0.0":"2011-03-30T03:23:56.092Z","1.0.1":"2011-03-30T06:58:18.917Z","1.0.2":"2011-03-31T01:07:58.593Z","1.0.3":"2011-03-31T01:12:32.481Z","1.0.4":"2011-03-31T04:42:56.217Z","1.0.5":"2011-04-29T19:50:02.032Z","1.0.6":"2011-07-06T03:49:31.397Z","1.0.7":"2011-09-08T17:49:45.337Z","1.0.8":"2011-09-15T21:26:19.372Z","1.0.9":"2011-09-22T21:20:18.314Z","1.0.10":"2011-10-05T21:47:05.876Z","2.0.0":"2012-07-23T22:36:57.179Z","2.1.0":"2013-01-17T20:23:13.858Z","2.1.1":"2013-01-18T16:26:25.780Z","2.1.2":"2013-07-17T15:24:56.574Z","2.2.0":"2014-02-16T20:54:31.122Z","2.2.1":"2014-04-28T21:59:11.261Z","3.0.0":"2014-06-06T20:36:37.144Z","3.0.1":"2014-07-01T17:12:00.014Z"},"author":{"name":"Isaac Z. Schlueter","email":"i@izs.me","url":"http://blog.izs.me/"},"repository":{"type":"git","url":"http://github.com/isaacs/nopt"},"users":{"agnat":true,"fgribreau":true,"lupomontero":true,"chrisdickinson":true,"pid":true,"kastor":true,"chrisenytc":true,"jamescostian":true,"manishrc":true,"evanlucas":true,"lucasbrigida":true,"amio":true,"tunnckocore":true,"kahboom":true},"readme":"If you want to write an option parser, and have it be good, there are\ntwo ways to do it. The Right Way, and the Wrong Way.\n\nThe Wrong Way is to sit down and write an option parser. We've all done\nthat.\n\nThe Right Way is to write some complex configurable program with so many\noptions that you go half-insane just trying to manage them all, and put\nit off with duct-tape solutions until you see exactly to the core of the\nproblem, and finally snap and write an awesome option parser.\n\nIf you want to write an option parser, don't write an option parser.\nWrite a package manager, or a source control system, or a service\nrestarter, or an operating system. You probably won't end up with a\ngood one of those, but if you don't give up, and you are relentless and\ndiligent enough in your procrastination, you may just end up with a very\nnice option parser.\n\n## USAGE\n\n // my-program.js\n var nopt = require(\"nopt\")\n , Stream = require(\"stream\").Stream\n , path = require(\"path\")\n , knownOpts = { \"foo\" : [String, null]\n , \"bar\" : [Stream, Number]\n , \"baz\" : path\n , \"bloo\" : [ \"big\", \"medium\", \"small\" ]\n , \"flag\" : Boolean\n , \"pick\" : Boolean\n , \"many\" : [String, Array]\n }\n , shortHands = { \"foofoo\" : [\"--foo\", \"Mr. Foo\"]\n , \"b7\" : [\"--bar\", \"7\"]\n , \"m\" : [\"--bloo\", \"medium\"]\n , \"p\" : [\"--pick\"]\n , \"f\" : [\"--flag\"]\n }\n // everything is optional.\n // knownOpts and shorthands default to {}\n // arg list defaults to process.argv\n // slice defaults to 2\n , parsed = nopt(knownOpts, shortHands, process.argv, 2)\n console.log(parsed)\n\nThis would give you support for any of the following:\n\n```bash\n$ node my-program.js --foo \"blerp\" --no-flag\n{ \"foo\" : \"blerp\", \"flag\" : false }\n\n$ node my-program.js ---bar 7 --foo \"Mr. Hand\" --flag\n{ bar: 7, foo: \"Mr. Hand\", flag: true }\n\n$ node my-program.js --foo \"blerp\" -f -----p\n{ foo: \"blerp\", flag: true, pick: true }\n\n$ node my-program.js -fp --foofoo\n{ foo: \"Mr. Foo\", flag: true, pick: true }\n\n$ node my-program.js --foofoo -- -fp # -- stops the flag parsing.\n{ foo: \"Mr. Foo\", argv: { remain: [\"-fp\"] } }\n\n$ node my-program.js --blatzk -fp # unknown opts are ok.\n{ blatzk: true, flag: true, pick: true }\n\n$ node my-program.js --blatzk=1000 -fp # but you need to use = if they have a value\n{ blatzk: 1000, flag: true, pick: true }\n\n$ node my-program.js --no-blatzk -fp # unless they start with \"no-\"\n{ blatzk: false, flag: true, pick: true }\n\n$ node my-program.js --baz b/a/z # known paths are resolved.\n{ baz: \"/Users/isaacs/b/a/z\" }\n\n# if Array is one of the types, then it can take many\n# values, and will always be an array. The other types provided\n# specify what types are allowed in the list.\n\n$ node my-program.js --many 1 --many null --many foo\n{ many: [\"1\", \"null\", \"foo\"] }\n\n$ node my-program.js --many foo\n{ many: [\"foo\"] }\n```\n\nRead the tests at the bottom of `lib/nopt.js` for more examples of\nwhat this puppy can do.\n\n## Types\n\nThe following types are supported, and defined on `nopt.typeDefs`\n\n* String: A normal string. No parsing is done.\n* path: A file system path. Gets resolved against cwd if not absolute.\n* url: A url. If it doesn't parse, it isn't accepted.\n* Number: Must be numeric.\n* Date: Must parse as a date. If it does, and `Date` is one of the options,\n then it will return a Date object, not a string.\n* Boolean: Must be either `true` or `false`. If an option is a boolean,\n then it does not need a value, and its presence will imply `true` as\n the value. To negate boolean flags, do `--no-whatever` or `--whatever\n false`\n* NaN: Means that the option is strictly not allowed. Any value will\n fail.\n* Stream: An object matching the \"Stream\" class in node. Valuable\n for use when validating programmatically. (npm uses this to let you\n supply any WriteStream on the `outfd` and `logfd` config options.)\n* Array: If `Array` is specified as one of the types, then the value\n will be parsed as a list of options. This means that multiple values\n can be specified, and that the value will always be an array.\n\nIf a type is an array of values not on this list, then those are\nconsidered valid values. For instance, in the example above, the\n`--bloo` option can only be one of `\"big\"`, `\"medium\"`, or `\"small\"`,\nand any other value will be rejected.\n\nWhen parsing unknown fields, `\"true\"`, `\"false\"`, and `\"null\"` will be\ninterpreted as their JavaScript equivalents.\n\nYou can also mix types and values, or multiple types, in a list. For\ninstance `{ blah: [Number, null] }` would allow a value to be set to\neither a Number or null. When types are ordered, this implies a\npreference, and the first type that can be used to properly interpret\nthe value will be used.\n\nTo define a new type, add it to `nopt.typeDefs`. Each item in that\nhash is an object with a `type` member and a `validate` method. The\n`type` member is an object that matches what goes in the type list. The\n`validate` method is a function that gets called with `validate(data,\nkey, val)`. Validate methods should assign `data[key]` to the valid\nvalue of `val` if it can be handled properly, or return boolean\n`false` if it cannot.\n\nYou can also call `nopt.clean(data, types, typeDefs)` to clean up a\nconfig object and remove its invalid properties.\n\n## Error Handling\n\nBy default, nopt outputs a warning to standard error when invalid\noptions are found. You can change this behavior by assigning a method\nto `nopt.invalidHandler`. This method will be called with\nthe offending `nopt.invalidHandler(key, val, types)`.\n\nIf no `nopt.invalidHandler` is assigned, then it will console.error\nits whining. If it is assigned to boolean `false` then the warning is\nsuppressed.\n\n## Abbreviations\n\nYes, they are supported. If you define options like this:\n\n```javascript\n{ \"foolhardyelephants\" : Boolean\n, \"pileofmonkeys\" : Boolean }\n```\n\nThen this will work:\n\n```bash\nnode program.js --foolhar --pil\nnode program.js --no-f --pileofmon\n# etc.\n```\n\n## Shorthands\n\nShorthands are a hash of shorter option names to a snippet of args that\nthey expand to.\n\nIf multiple one-character shorthands are all combined, and the\ncombination does not unambiguously match any other option or shorthand,\nthen they will be broken up into their constituent parts. For example:\n\n```json\n{ \"s\" : [\"--loglevel\", \"silent\"]\n, \"g\" : \"--global\"\n, \"f\" : \"--force\"\n, \"p\" : \"--parseable\"\n, \"l\" : \"--long\"\n}\n```\n\n```bash\nnpm ls -sgflp\n# just like doing this:\nnpm ls --loglevel silent --global --force --long --parseable\n```\n\n## The Rest of the args\n\nThe config object returned by nopt is given a special member called\n`argv`, which is an object with the following fields:\n\n* `remain`: The remaining args after all the parsing has occurred.\n* `original`: The args as they originally appeared.\n* `cooked`: The args after flags and shorthands are expanded.\n\n## Slicing\n\nNode programs are called with more or less the exact argv as it appears\nin C land, after the v8 and node-specific options have been plucked off.\nAs such, `argv[0]` is always `node` and `argv[1]` is always the\nJavaScript program being run.\n\nThat's usually not very useful to you. So they're sliced off by\ndefault. If you want them, then you can pass in `0` as the last\nargument, or any other number that you'd like to slice off the start of\nthe list.\n","readmeFilename":"README.md","homepage":"https://github.com/isaacs/nopt","bugs":{"url":"https://github.com/isaacs/nopt/issues"},"license":{"type":"MIT","url":"https://github.com/isaacs/nopt/raw/master/LICENSE"}} 2 | --------------------------------------------------------------------------------