fix bugs
commit
4deaf4dc38
@ -1,23 +0,0 @@
|
||||
var util = require("util")
|
||||
var messages = require("./warning_messages.json")
|
||||
|
||||
module.exports = function() {
|
||||
var args = Array.prototype.slice.call(arguments, 0)
|
||||
var warningName = args.shift()
|
||||
if (warningName == "typo") {
|
||||
return makeTypoWarning.apply(null,args)
|
||||
}
|
||||
else {
|
||||
var msgTemplate = messages[warningName] ? messages[warningName] : warningName + ": '%s'"
|
||||
args.unshift(msgTemplate)
|
||||
return util.format.apply(null, args)
|
||||
}
|
||||
}
|
||||
|
||||
function makeTypoWarning (providedName, probableName, field) {
|
||||
if (field) {
|
||||
providedName = field + "['" + providedName + "']"
|
||||
probableName = field + "['" + probableName + "']"
|
||||
}
|
||||
return util.format(messages.typo, providedName, probableName)
|
||||
}
|
||||
@ -1,39 +0,0 @@
|
||||
module.exports = normalize
|
||||
|
||||
var fixer = require("./fixer")
|
||||
normalize.fixer = fixer
|
||||
|
||||
var makeWarning = require("./make_warning")
|
||||
|
||||
var fieldsToFix = ['name','version','description','repository','modules','scripts'
|
||||
,'files','bin','man','bugs','keywords','readme','homepage','license']
|
||||
var otherThingsToFix = ['dependencies','people', 'typos']
|
||||
|
||||
var thingsToFix = fieldsToFix.map(function(fieldName) {
|
||||
return ucFirst(fieldName) + "Field"
|
||||
})
|
||||
// two ways to do this in CoffeeScript on only one line, sub-70 chars:
|
||||
// thingsToFix = fieldsToFix.map (name) -> ucFirst(name) + "Field"
|
||||
// thingsToFix = (ucFirst(name) + "Field" for name in fieldsToFix)
|
||||
thingsToFix = thingsToFix.concat(otherThingsToFix)
|
||||
|
||||
function normalize (data, warn, strict) {
|
||||
if(warn === true) warn = null, strict = true
|
||||
if(!strict) strict = false
|
||||
if(!warn || data.private) warn = function(msg) { /* noop */ }
|
||||
|
||||
if (data.scripts &&
|
||||
data.scripts.install === "node-gyp rebuild" &&
|
||||
!data.scripts.preinstall) {
|
||||
data.gypfile = true
|
||||
}
|
||||
fixer.warn = function() { warn(makeWarning.apply(null, arguments)) }
|
||||
thingsToFix.forEach(function(thingName) {
|
||||
fixer["fix" + ucFirst(thingName)](data, strict)
|
||||
})
|
||||
data._id = data.name + "@" + data.version
|
||||
}
|
||||
|
||||
function ucFirst (string) {
|
||||
return string.charAt(0).toUpperCase() + string.slice(1);
|
||||
}
|
||||
@ -1,9 +0,0 @@
|
||||
var util = require('util')
|
||||
|
||||
module.exports = function() {
|
||||
var args = Array.prototype.slice.call(arguments, 0)
|
||||
args.forEach(function(arg) {
|
||||
if (!arg) throw new TypeError('Bad arguments.')
|
||||
})
|
||||
return util.format.apply(null, arguments)
|
||||
}
|
||||
@ -1,25 +0,0 @@
|
||||
{
|
||||
"topLevel": {
|
||||
"dependancies": "dependencies"
|
||||
,"dependecies": "dependencies"
|
||||
,"depdenencies": "dependencies"
|
||||
,"devEependencies": "devDependencies"
|
||||
,"depends": "dependencies"
|
||||
,"dev-dependencies": "devDependencies"
|
||||
,"devDependences": "devDependencies"
|
||||
,"devDepenencies": "devDependencies"
|
||||
,"devdependencies": "devDependencies"
|
||||
,"repostitory": "repository"
|
||||
,"repo": "repository"
|
||||
,"prefereGlobal": "preferGlobal"
|
||||
,"hompage": "homepage"
|
||||
,"hampage": "homepage"
|
||||
,"autohr": "author"
|
||||
,"autor": "author"
|
||||
,"contributers": "contributors"
|
||||
,"publicationConfig": "publishConfig"
|
||||
,"script": "scripts"
|
||||
},
|
||||
"bugs": { "web": "url", "name": "url" },
|
||||
"script": { "server": "start", "tests": "test" }
|
||||
}
|
||||
@ -1,30 +0,0 @@
|
||||
{
|
||||
"repositories": "'repositories' (plural) Not supported. Please pick one as the 'repository' field"
|
||||
,"missingRepository": "No repository field."
|
||||
,"brokenGitUrl": "Probably broken git url: %s"
|
||||
,"nonObjectScripts": "scripts must be an object"
|
||||
,"nonStringScript": "script values must be string commands"
|
||||
,"nonArrayFiles": "Invalid 'files' member"
|
||||
,"invalidFilename": "Invalid filename in 'files' list: %s"
|
||||
,"nonArrayBundleDependencies": "Invalid 'bundleDependencies' list. Must be array of package names"
|
||||
,"nonStringBundleDependency": "Invalid bundleDependencies member: %s"
|
||||
,"nonDependencyBundleDependency": "Non-dependency in bundleDependencies: %s"
|
||||
,"nonObjectDependencies": "%s field must be an object"
|
||||
,"nonStringDependency": "Invalid dependency: %s %s"
|
||||
,"deprecatedArrayDependencies": "specifying %s as array is deprecated"
|
||||
,"deprecatedModules": "modules field is deprecated"
|
||||
,"nonArrayKeywords": "keywords should be an array of strings"
|
||||
,"nonStringKeyword": "keywords should be an array of strings"
|
||||
,"conflictingName": "%s is also the name of a node core module."
|
||||
,"nonStringDescription": "'description' field should be a string"
|
||||
,"missingDescription": "No description"
|
||||
,"missingReadme": "No README data"
|
||||
,"missingLicense": "No license field."
|
||||
,"nonEmailUrlBugsString": "Bug string field must be url, email, or {email,url}"
|
||||
,"nonUrlBugsUrlField": "bugs.url field must be a string url. Deleted."
|
||||
,"nonEmailBugsEmailField": "bugs.email field must be a string email. Deleted."
|
||||
,"emptyNormalizedBugs": "Normalized value of bugs field is an empty object. Deleted."
|
||||
,"nonUrlHomepage": "homepage field must be a string url. Deleted."
|
||||
,"invalidLicense": "license should be a valid SPDX license expression"
|
||||
,"typo": "%s should probably be %s."
|
||||
}
|
||||
@ -1,21 +0,0 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014-2017, Jon Schlinkert
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
@ -1,92 +0,0 @@
|
||||
# normalize-path [](https://www.npmjs.com/package/normalize-path) [](https://npmjs.org/package/normalize-path) [](https://npmjs.org/package/normalize-path) [](https://travis-ci.org/jonschlinkert/normalize-path)
|
||||
|
||||
> Normalize file path slashes to be unix-like forward slashes. Also condenses repeat slashes to a single slash and removes and trailing slashes unless disabled.
|
||||
|
||||
## Install
|
||||
|
||||
Install with [npm](https://www.npmjs.com/):
|
||||
|
||||
```sh
|
||||
$ npm install --save normalize-path
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var normalize = require('normalize-path');
|
||||
|
||||
normalize('\\foo\\bar\\baz\\');
|
||||
//=> '/foo/bar/baz'
|
||||
|
||||
normalize('./foo/bar/baz/');
|
||||
//=> './foo/bar/baz'
|
||||
```
|
||||
|
||||
Pass `false` as the last argument to **keep** trailing slashes:
|
||||
|
||||
```js
|
||||
normalize('./foo/bar/baz/', false);
|
||||
//=> './foo/bar/baz/'
|
||||
|
||||
normalize('foo\\bar\\baz\\', false);
|
||||
//=> 'foo/bar/baz/'
|
||||
```
|
||||
|
||||
## About
|
||||
|
||||
### Related projects
|
||||
|
||||
* [contains-path](https://www.npmjs.com/package/contains-path): Return true if a file path contains the given path. | [homepage](https://github.com/jonschlinkert/contains-path "Return true if a file path contains the given path.")
|
||||
* [ends-with](https://www.npmjs.com/package/ends-with): Returns `true` if the given `string` or `array` ends with `suffix` using strict equality for… [more](https://github.com/jonschlinkert/ends-with) | [homepage](https://github.com/jonschlinkert/ends-with "Returns `true` if the given `string` or `array` ends with `suffix` using strict equality for comparisons.")
|
||||
* [is-absolute](https://www.npmjs.com/package/is-absolute): Polyfill for node.js `path.isAbolute`. Returns true if a file path is absolute. | [homepage](https://github.com/jonschlinkert/is-absolute "Polyfill for node.js `path.isAbolute`. Returns true if a file path is absolute.")
|
||||
* [is-relative](https://www.npmjs.com/package/is-relative): Returns `true` if the path appears to be relative. | [homepage](https://github.com/jonschlinkert/is-relative "Returns `true` if the path appears to be relative.")
|
||||
* [parse-filepath](https://www.npmjs.com/package/parse-filepath): Pollyfill for node.js `path.parse`, parses a filepath into an object. | [homepage](https://github.com/jonschlinkert/parse-filepath "Pollyfill for node.js `path.parse`, parses a filepath into an object.")
|
||||
* [path-ends-with](https://www.npmjs.com/package/path-ends-with): Return `true` if a file path ends with the given string/suffix. | [homepage](https://github.com/jonschlinkert/path-ends-with "Return `true` if a file path ends with the given string/suffix.")
|
||||
* [path-segments](https://www.npmjs.com/package/path-segments): Get n specific segments of a file path, e.g. first 2, last 3, etc. | [homepage](https://github.com/jonschlinkert/path-segments "Get n specific segments of a file path, e.g. first 2, last 3, etc.")
|
||||
* [rewrite-ext](https://www.npmjs.com/package/rewrite-ext): Automatically re-write the destination extension of a filepath based on the source extension. e.g… [more](https://github.com/jonschlinkert/rewrite-ext) | [homepage](https://github.com/jonschlinkert/rewrite-ext "Automatically re-write the destination extension of a filepath based on the source extension. e.g `.coffee` => `.js`. This will only rename the ext, no other path parts are modified.")
|
||||
* [unixify](https://www.npmjs.com/package/unixify): Convert Windows file paths to unix paths. | [homepage](https://github.com/jonschlinkert/unixify "Convert Windows file paths to unix paths.")
|
||||
|
||||
### Contributing
|
||||
|
||||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
|
||||
|
||||
### Contributors
|
||||
|
||||
| **Commits** | **Contributor** |
|
||||
| --- | --- |
|
||||
| 31 | [jonschlinkert](https://github.com/jonschlinkert) |
|
||||
| 1 | [phated](https://github.com/phated) |
|
||||
|
||||
### Building docs
|
||||
|
||||
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
|
||||
|
||||
To generate the readme, run the following command:
|
||||
|
||||
```sh
|
||||
$ npm install -g verbose/verb#dev verb-generate-readme && verb
|
||||
```
|
||||
|
||||
### Running tests
|
||||
|
||||
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
|
||||
|
||||
```sh
|
||||
$ npm install && npm test
|
||||
```
|
||||
|
||||
### Author
|
||||
|
||||
**Jon Schlinkert**
|
||||
|
||||
* [github/jonschlinkert](https://github.com/jonschlinkert)
|
||||
* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
|
||||
|
||||
### License
|
||||
|
||||
Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
|
||||
Released under the [MIT License](LICENSE).
|
||||
|
||||
***
|
||||
|
||||
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.4.3, on March 29, 2017._
|
||||
@ -1,19 +0,0 @@
|
||||
/*!
|
||||
* normalize-path <https://github.com/jonschlinkert/normalize-path>
|
||||
*
|
||||
* Copyright (c) 2014-2017, Jon Schlinkert.
|
||||
* Released under the MIT License.
|
||||
*/
|
||||
|
||||
var removeTrailingSeparator = require('remove-trailing-separator');
|
||||
|
||||
module.exports = function normalizePath(str, stripTrailing) {
|
||||
if (typeof str !== 'string') {
|
||||
throw new TypeError('expected a string');
|
||||
}
|
||||
str = str.replace(/[\\\/]+/g, '/');
|
||||
if (stripTrailing !== false) {
|
||||
str = removeTrailingSeparator(str);
|
||||
}
|
||||
return str;
|
||||
};
|
||||
@ -1,54 +0,0 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
wrap: wrapRange,
|
||||
limit: limitRange,
|
||||
validate: validateRange,
|
||||
test: testRange,
|
||||
curry: curry,
|
||||
name: name
|
||||
};
|
||||
|
||||
function wrapRange(min, max, value) {
|
||||
var maxLessMin = max - min;
|
||||
return ((value - min) % maxLessMin + maxLessMin) % maxLessMin + min;
|
||||
}
|
||||
|
||||
function limitRange(min, max, value) {
|
||||
return Math.max(min, Math.min(max, value));
|
||||
}
|
||||
|
||||
function validateRange(min, max, value, minExclusive, maxExclusive) {
|
||||
if (!testRange(min, max, value, minExclusive, maxExclusive)) {
|
||||
throw new Error(value + ' is outside of range [' + min + ',' + max + ')');
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
function testRange(min, max, value, minExclusive, maxExclusive) {
|
||||
return !(
|
||||
value < min ||
|
||||
value > max ||
|
||||
(maxExclusive && (value === max)) ||
|
||||
(minExclusive && (value === min))
|
||||
);
|
||||
}
|
||||
|
||||
function name(min, max, minExcl, maxExcl) {
|
||||
return (minExcl ? '(' : '[') + min + ',' + max + (maxExcl ? ')' : ']');
|
||||
}
|
||||
|
||||
function curry(min, max, minExclusive, maxExclusive) {
|
||||
var boundNameFn = name.bind(null, min, max, minExclusive, maxExclusive);
|
||||
return {
|
||||
wrap: wrapRange.bind(null, min, max),
|
||||
limit: limitRange.bind(null, min, max),
|
||||
validate: function(value) {
|
||||
return validateRange(min, max, value, minExclusive, maxExclusive);
|
||||
},
|
||||
test: function(value) {
|
||||
return testRange(min, max, value, minExclusive, maxExclusive);
|
||||
},
|
||||
toString: boundNameFn,
|
||||
name: boundNameFn
|
||||
};
|
||||
}
|
||||
@ -1,21 +0,0 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) James Talmage <james@talmage.io> (github.com/jamestalmage)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
@ -1,148 +0,0 @@
|
||||
# normalize-range
|
||||
|
||||
Utility for normalizing a numeric range, with a wrapping function useful for polar coordinates.
|
||||
|
||||
[](https://travis-ci.org/jamestalmage/normalize-range)
|
||||
[](https://coveralls.io/github/jamestalmage/normalize-range?branch=master)
|
||||
[](https://codeclimate.com/github/jamestalmage/normalize-range)
|
||||
[](https://david-dm.org/jamestalmage/normalize-range)
|
||||
[](https://david-dm.org/jamestalmage/normalize-range#info=devDependencies)
|
||||
|
||||
[](https://nodei.co/npm/normalize-range/)
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var nr = require('normalize-range');
|
||||
|
||||
nr.wrap(0, 360, 400);
|
||||
//=> 40
|
||||
|
||||
nr.wrap(0, 360, -90);
|
||||
//=> 270
|
||||
|
||||
nr.limit(0, 100, 500);
|
||||
//=> 100
|
||||
|
||||
nr.limit(0, 100, -20);
|
||||
//=> 0
|
||||
|
||||
// There is a convenient currying function
|
||||
var wrapAngle = nr.curry(0, 360).wrap;
|
||||
var limitTo10 = nr.curry(0, 10).limit;
|
||||
|
||||
wrapAngle(-30);
|
||||
//=> 330
|
||||
```
|
||||
## API
|
||||
|
||||
### wrap(min, max, value)
|
||||
|
||||
Normalizes a values that "wraps around". For example, in a polar coordinate system, 270˚ can also be
|
||||
represented as -90˚.
|
||||
For wrapping purposes we assume `max` is functionally equivalent to `min`, and that `wrap(max + 1) === wrap(min + 1)`.
|
||||
Wrap always assumes that `min` is *inclusive*, and `max` is *exclusive*.
|
||||
In other words, if `value === max` the function will wrap it, and return `min`, but `min` will not be wrapped.
|
||||
|
||||
```js
|
||||
nr.wrap(0, 360, 0) === 0;
|
||||
nr.wrap(0, 360, 360) === 0;
|
||||
nr.wrap(0, 360, 361) === 1;
|
||||
nr.wrap(0, 360, -1) === 359;
|
||||
```
|
||||
|
||||
You are not restricted to whole numbers, and ranges can be negative.
|
||||
|
||||
```js
|
||||
var π = Math.PI;
|
||||
var radianRange = nr.curry(-π, π);
|
||||
|
||||
redianRange.wrap(0) === 0;
|
||||
nr.wrap(π) === -π;
|
||||
nr.wrap(4 * π / 3) === -2 * π / 3;
|
||||
```
|
||||
|
||||
### limit(min, max, value)
|
||||
|
||||
Normalize the value by bringing it within the range.
|
||||
If `value` is greater than `max`, `max` will be returned.
|
||||
If `value` is less than `min`, `min` will be returned.
|
||||
Otherwise, `value` is returned unaltered.
|
||||
Both ends of this range are *inclusive*.
|
||||
|
||||
### test(min, max, value, [minExclusive], [maxExclusive])
|
||||
|
||||
Returns `true` if `value` is within the range, `false` otherwise.
|
||||
It defaults to `inclusive` on both ends of the range, but that can be
|
||||
changed by setting `minExclusive` and/or `maxExclusive` to a truthy value.
|
||||
|
||||
### validate(min, max, value, [minExclusive], [maxExclusive])
|
||||
|
||||
Returns `value` or throws an error if `value` is outside the specified range.
|
||||
|
||||
### name(min, max, value, [minExclusive], [maxExclusive])
|
||||
|
||||
Returns a string representing this range in
|
||||
[range notation](https://en.wikipedia.org/wiki/Interval_(mathematics)#Classification_of_intervals).
|
||||
|
||||
### curry(min, max, [minExclusive], [maxExclusive])
|
||||
|
||||
Convenience method for currying all method arguments except `value`.
|
||||
|
||||
```js
|
||||
var angle = require('normalize-range').curry(-180, 180, false, true);
|
||||
|
||||
angle.wrap(270)
|
||||
//=> -90
|
||||
|
||||
angle.limit(200)
|
||||
//=> 180
|
||||
|
||||
angle.test(0)
|
||||
//=> true
|
||||
|
||||
angle.validate(300)
|
||||
//=> throws an Error
|
||||
|
||||
angle.toString() // or angle.name()
|
||||
//=> "[-180,180)"
|
||||
```
|
||||
|
||||
#### min
|
||||
|
||||
*Required*
|
||||
Type: `number`
|
||||
|
||||
The minimum value (inclusive) of the range.
|
||||
|
||||
#### max
|
||||
|
||||
*Required*
|
||||
Type: `number`
|
||||
|
||||
The maximum value (exclusive) of the range.
|
||||
|
||||
#### value
|
||||
|
||||
*Required*
|
||||
Type: `number`
|
||||
|
||||
The value to be normalized.
|
||||
|
||||
#### returns
|
||||
|
||||
Type: `number`
|
||||
|
||||
The normalized value.
|
||||
|
||||
## Building and Releasing
|
||||
|
||||
- `npm test`: tests, linting, coverage and style checks.
|
||||
- `npm run watch`: autotest mode for active development.
|
||||
- `npm run debug`: run tests without coverage (istanbul can obscure line #'s)
|
||||
|
||||
Release via `cut-release` tool.
|
||||
|
||||
## License
|
||||
|
||||
MIT © [James Talmage](http://github.com/jamestalmage)
|
||||
@ -1,15 +0,0 @@
|
||||
The ISC License
|
||||
|
||||
Copyright (c) npm, Inc. and Contributors
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
@ -1,48 +0,0 @@
|
||||
# npm-bundled
|
||||
|
||||
Run this in a node package, and it'll tell you which things in
|
||||
node_modules are bundledDependencies, or transitive dependencies of
|
||||
bundled dependencies.
|
||||
|
||||
[](https://travis-ci.org/npm/npm-bundled)
|
||||
|
||||
## USAGE
|
||||
|
||||
To get the list of deps at the top level that are bundled (or
|
||||
transitive deps of a bundled dep) run this:
|
||||
|
||||
```js
|
||||
const bundled = require('npm-bundled')
|
||||
|
||||
// async version
|
||||
bundled({ path: '/path/to/pkg/defaults/to/cwd'}, (er, list) => {
|
||||
// er means it had an error, which is _hella_ weird
|
||||
// list is a list of package names, like `fooblz` or `@corp/blerg`
|
||||
// the might not all be deps of the top level, because transitives
|
||||
})
|
||||
|
||||
// async promise version
|
||||
bundled({ path: '/path/to/pkg/defaults/to/cwd'}).then(list => {
|
||||
// so promisey!
|
||||
// actually the callback version returns a promise, too, it just
|
||||
// attaches the supplied callback to the promise
|
||||
})
|
||||
|
||||
// sync version, throws if there's an error
|
||||
const list = bundled({ path: '/path/to/pkg/defaults/to/cwd'})
|
||||
```
|
||||
|
||||
That's basically all you need to know. If you care to dig into it,
|
||||
you can also use the `bundled.Walker` and `bundled.WalkerSync`
|
||||
classes to get fancy.
|
||||
|
||||
This library does not write anything to the filesystem, but it _may_
|
||||
have undefined behavior if the structure of `node_modules` changes
|
||||
while it's reading deps.
|
||||
|
||||
All symlinks are followed. This means that it can lead to surprising
|
||||
results if a symlinked bundled dependency has a missing dependency
|
||||
that is satisfied at the top level. Since package creation resolves
|
||||
symlinks as well, this is an edge case where package creation and
|
||||
development environment are not going to be aligned, and is best
|
||||
avoided.
|
||||
@ -1,249 +0,0 @@
|
||||
'use strict'
|
||||
|
||||
// walk the tree of deps starting from the top level list of bundled deps
|
||||
// Any deps at the top level that are depended on by a bundled dep that
|
||||
// does not have that dep in its own node_modules folder are considered
|
||||
// bundled deps as well. This list of names can be passed to npm-packlist
|
||||
// as the "bundled" argument. Additionally, packageJsonCache is shared so
|
||||
// packlist doesn't have to re-read files already consumed in this pass
|
||||
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const EE = require('events').EventEmitter
|
||||
// we don't care about the package bins, but we share a pj cache
|
||||
// with other modules that DO care about it, so keep it nice.
|
||||
const normalizePackageBin = require('npm-normalize-package-bin')
|
||||
|
||||
class BundleWalker extends EE {
|
||||
constructor (opt) {
|
||||
opt = opt || {}
|
||||
super(opt)
|
||||
this.path = path.resolve(opt.path || process.cwd())
|
||||
|
||||
this.parent = opt.parent || null
|
||||
if (this.parent) {
|
||||
this.result = this.parent.result
|
||||
// only collect results in node_modules folders at the top level
|
||||
// since the node_modules in a bundled dep is included always
|
||||
if (!this.parent.parent) {
|
||||
const base = path.basename(this.path)
|
||||
const scope = path.basename(path.dirname(this.path))
|
||||
this.result.add(/^@/.test(scope) ? scope + '/' + base : base)
|
||||
}
|
||||
this.root = this.parent.root
|
||||
this.packageJsonCache = this.parent.packageJsonCache
|
||||
} else {
|
||||
this.result = new Set()
|
||||
this.root = this.path
|
||||
this.packageJsonCache = opt.packageJsonCache || new Map()
|
||||
}
|
||||
|
||||
this.seen = new Set()
|
||||
this.didDone = false
|
||||
this.children = 0
|
||||
this.node_modules = []
|
||||
this.package = null
|
||||
this.bundle = null
|
||||
}
|
||||
|
||||
addListener (ev, fn) {
|
||||
return this.on(ev, fn)
|
||||
}
|
||||
|
||||
on (ev, fn) {
|
||||
const ret = super.on(ev, fn)
|
||||
if (ev === 'done' && this.didDone) {
|
||||
this.emit('done', this.result)
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
done () {
|
||||
if (!this.didDone) {
|
||||
this.didDone = true
|
||||
if (!this.parent) {
|
||||
const res = Array.from(this.result)
|
||||
this.result = res
|
||||
this.emit('done', res)
|
||||
} else {
|
||||
this.emit('done')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
start () {
|
||||
const pj = path.resolve(this.path, 'package.json')
|
||||
if (this.packageJsonCache.has(pj))
|
||||
this.onPackage(this.packageJsonCache.get(pj))
|
||||
else
|
||||
this.readPackageJson(pj)
|
||||
return this
|
||||
}
|
||||
|
||||
readPackageJson (pj) {
|
||||
fs.readFile(pj, (er, data) =>
|
||||
er ? this.done() : this.onPackageJson(pj, data))
|
||||
}
|
||||
|
||||
onPackageJson (pj, data) {
|
||||
try {
|
||||
this.package = normalizePackageBin(JSON.parse(data + ''))
|
||||
} catch (er) {
|
||||
return this.done()
|
||||
}
|
||||
this.packageJsonCache.set(pj, this.package)
|
||||
this.onPackage(this.package)
|
||||
}
|
||||
|
||||
allDepsBundled (pkg) {
|
||||
return Object.keys(pkg.dependencies || {}).concat(
|
||||
Object.keys(pkg.optionalDependencies || {}))
|
||||
}
|
||||
|
||||
onPackage (pkg) {
|
||||
// all deps are bundled if we got here as a child.
|
||||
// otherwise, only bundle bundledDeps
|
||||
// Get a unique-ified array with a short-lived Set
|
||||
const bdRaw = this.parent ? this.allDepsBundled(pkg)
|
||||
: pkg.bundleDependencies || pkg.bundledDependencies || []
|
||||
|
||||
const bd = Array.from(new Set(
|
||||
Array.isArray(bdRaw) ? bdRaw
|
||||
: bdRaw === true ? this.allDepsBundled(pkg)
|
||||
: Object.keys(bdRaw)))
|
||||
|
||||
if (!bd.length)
|
||||
return this.done()
|
||||
|
||||
this.bundle = bd
|
||||
const nm = this.path + '/node_modules'
|
||||
this.readModules()
|
||||
}
|
||||
|
||||
readModules () {
|
||||
readdirNodeModules(this.path + '/node_modules', (er, nm) =>
|
||||
er ? this.onReaddir([]) : this.onReaddir(nm))
|
||||
}
|
||||
|
||||
onReaddir (nm) {
|
||||
// keep track of what we have, in case children need it
|
||||
this.node_modules = nm
|
||||
|
||||
this.bundle.forEach(dep => this.childDep(dep))
|
||||
if (this.children === 0)
|
||||
this.done()
|
||||
}
|
||||
|
||||
childDep (dep) {
|
||||
if (this.node_modules.indexOf(dep) !== -1 && !this.seen.has(dep)) {
|
||||
this.seen.add(dep)
|
||||
this.child(dep)
|
||||
} else if (this.parent) {
|
||||
this.parent.childDep(dep)
|
||||
}
|
||||
}
|
||||
|
||||
child (dep) {
|
||||
const p = this.path + '/node_modules/' + dep
|
||||
this.children += 1
|
||||
const child = new BundleWalker({
|
||||
path: p,
|
||||
parent: this
|
||||
})
|
||||
child.on('done', _ => {
|
||||
if (--this.children === 0)
|
||||
this.done()
|
||||
})
|
||||
child.start()
|
||||
}
|
||||
}
|
||||
|
||||
class BundleWalkerSync extends BundleWalker {
|
||||
constructor (opt) {
|
||||
super(opt)
|
||||
}
|
||||
|
||||
start () {
|
||||
super.start()
|
||||
this.done()
|
||||
return this
|
||||
}
|
||||
|
||||
readPackageJson (pj) {
|
||||
try {
|
||||
this.onPackageJson(pj, fs.readFileSync(pj))
|
||||
} catch (er) {}
|
||||
return this
|
||||
}
|
||||
|
||||
readModules () {
|
||||
try {
|
||||
this.onReaddir(readdirNodeModulesSync(this.path + '/node_modules'))
|
||||
} catch (er) {
|
||||
this.onReaddir([])
|
||||
}
|
||||
}
|
||||
|
||||
child (dep) {
|
||||
new BundleWalkerSync({
|
||||
path: this.path + '/node_modules/' + dep,
|
||||
parent: this
|
||||
}).start()
|
||||
}
|
||||
}
|
||||
|
||||
const readdirNodeModules = (nm, cb) => {
|
||||
fs.readdir(nm, (er, set) => {
|
||||
if (er)
|
||||
cb(er)
|
||||
else {
|
||||
const scopes = set.filter(f => /^@/.test(f))
|
||||
if (!scopes.length)
|
||||
cb(null, set)
|
||||
else {
|
||||
const unscoped = set.filter(f => !/^@/.test(f))
|
||||
let count = scopes.length
|
||||
scopes.forEach(scope => {
|
||||
fs.readdir(nm + '/' + scope, (er, pkgs) => {
|
||||
if (er || !pkgs.length)
|
||||
unscoped.push(scope)
|
||||
else
|
||||
unscoped.push.apply(unscoped, pkgs.map(p => scope + '/' + p))
|
||||
if (--count === 0)
|
||||
cb(null, unscoped)
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const readdirNodeModulesSync = nm => {
|
||||
const set = fs.readdirSync(nm)
|
||||
const unscoped = set.filter(f => !/^@/.test(f))
|
||||
const scopes = set.filter(f => /^@/.test(f)).map(scope => {
|
||||
try {
|
||||
const pkgs = fs.readdirSync(nm + '/' + scope)
|
||||
return pkgs.length ? pkgs.map(p => scope + '/' + p) : [scope]
|
||||
} catch (er) {
|
||||
return [scope]
|
||||
}
|
||||
}).reduce((a, b) => a.concat(b), [])
|
||||
return unscoped.concat(scopes)
|
||||
}
|
||||
|
||||
const walk = (options, callback) => {
|
||||
const p = new Promise((resolve, reject) => {
|
||||
new BundleWalker(options).on('done', resolve).on('error', reject).start()
|
||||
})
|
||||
return callback ? p.then(res => callback(null, res), callback) : p
|
||||
}
|
||||
|
||||
const walkSync = options => {
|
||||
return new BundleWalkerSync(options).start().result
|
||||
}
|
||||
|
||||
module.exports = walk
|
||||
walk.sync = walkSync
|
||||
walk.BundleWalker = BundleWalker
|
||||
walk.BundleWalkerSync = BundleWalkerSync
|
||||
@ -1,2 +0,0 @@
|
||||
---
|
||||
_extends: 'open-source-project-boilerplate'
|
||||
@ -1,24 +0,0 @@
|
||||
# ignore most things, include some others
|
||||
/*
|
||||
/.*
|
||||
|
||||
!bin/
|
||||
!lib/
|
||||
!docs/
|
||||
!package.json
|
||||
!package-lock.json
|
||||
!README.md
|
||||
!CONTRIBUTING.md
|
||||
!LICENSE
|
||||
!CHANGELOG.md
|
||||
!example/
|
||||
!scripts/
|
||||
!tap-snapshots/
|
||||
!test/
|
||||
!.github/
|
||||
!.travis.yml
|
||||
!.gitignore
|
||||
!.gitattributes
|
||||
!coverage-map.js
|
||||
!map.js
|
||||
!index.js
|
||||
@ -1,15 +0,0 @@
|
||||
The ISC License
|
||||
|
||||
Copyright (c) npm, Inc.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
@ -1,14 +0,0 @@
|
||||
# npm-normalize-package-bin
|
||||
|
||||
Turn any flavor of allowable package.json bin into a normalized object.
|
||||
|
||||
## API
|
||||
|
||||
```js
|
||||
const normalize = require('npm-normalize-package-bin')
|
||||
const pkg = {name: 'foo', bin: 'bar'}
|
||||
console.log(normalize(pkg)) // {name:'foo', bin:{foo: 'bar'}}
|
||||
```
|
||||
|
||||
Also strips out weird dots and slashes to prevent accidental and/or
|
||||
malicious bad behavior when the package is installed.
|
||||
@ -1,60 +0,0 @@
|
||||
// pass in a manifest with a 'bin' field here, and it'll turn it
|
||||
// into a properly santized bin object
|
||||
const {join, basename} = require('path')
|
||||
|
||||
const normalize = pkg =>
|
||||
!pkg.bin ? removeBin(pkg)
|
||||
: typeof pkg.bin === 'string' ? normalizeString(pkg)
|
||||
: Array.isArray(pkg.bin) ? normalizeArray(pkg)
|
||||
: typeof pkg.bin === 'object' ? normalizeObject(pkg)
|
||||
: removeBin(pkg)
|
||||
|
||||
const normalizeString = pkg => {
|
||||
if (!pkg.name)
|
||||
return removeBin(pkg)
|
||||
pkg.bin = { [pkg.name]: pkg.bin }
|
||||
return normalizeObject(pkg)
|
||||
}
|
||||
|
||||
const normalizeArray = pkg => {
|
||||
pkg.bin = pkg.bin.reduce((acc, k) => {
|
||||
acc[basename(k)] = k
|
||||
return acc
|
||||
}, {})
|
||||
return normalizeObject(pkg)
|
||||
}
|
||||
|
||||
const removeBin = pkg => {
|
||||
delete pkg.bin
|
||||
return pkg
|
||||
}
|
||||
|
||||
const normalizeObject = pkg => {
|
||||
const orig = pkg.bin
|
||||
const clean = {}
|
||||
let hasBins = false
|
||||
Object.keys(orig).forEach(binKey => {
|
||||
const base = join('/', basename(binKey.replace(/\\|:/g, '/'))).substr(1)
|
||||
|
||||
if (typeof orig[binKey] !== 'string' || !base)
|
||||
return
|
||||
|
||||
const binTarget = join('/', orig[binKey])
|
||||
.replace(/\\/g, '/').substr(1)
|
||||
|
||||
if (!binTarget)
|
||||
return
|
||||
|
||||
clean[base] = binTarget
|
||||
hasBins = true
|
||||
})
|
||||
|
||||
if (hasBins)
|
||||
pkg.bin = clean
|
||||
else
|
||||
delete pkg.bin
|
||||
|
||||
return pkg
|
||||
}
|
||||
|
||||
module.exports = normalize
|
||||
@ -1,37 +0,0 @@
|
||||
const normalize = require('../')
|
||||
const t = require('tap')
|
||||
|
||||
t.test('benign array', async t => {
|
||||
const pkg = { name: 'hello', version: 'world', bin: ['./x/y', 'y/z', './a'] }
|
||||
const expect = { name: 'hello', version: 'world', bin: {
|
||||
y: 'x/y',
|
||||
z: 'y/z',
|
||||
a: 'a',
|
||||
} }
|
||||
t.strictSame(normalize(pkg), expect)
|
||||
t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok')
|
||||
})
|
||||
|
||||
t.test('conflicting array', async t => {
|
||||
const pkg = { name: 'hello', version: 'world', bin: ['./x/y', 'z/y', './a'] }
|
||||
const expect = { name: 'hello', version: 'world', bin: {
|
||||
y: 'z/y',
|
||||
a: 'a',
|
||||
} }
|
||||
t.strictSame(normalize(pkg), expect)
|
||||
t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok')
|
||||
})
|
||||
|
||||
t.test('slashy array', async t => {
|
||||
const pkg = { name: 'hello', version: 'world', bin: [ '/etc/passwd' ] }
|
||||
const expect = { name: 'hello', version: 'world', bin: { passwd: 'etc/passwd' } }
|
||||
t.strictSame(normalize(pkg), expect)
|
||||
t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok')
|
||||
})
|
||||
|
||||
t.test('dotty array', async t => {
|
||||
const pkg = { name: 'hello', version: 'world', bin: ['../../../../etc/passwd'] }
|
||||
const expect = { name: 'hello', version: 'world', bin: { passwd: 'etc/passwd' } }
|
||||
t.strictSame(normalize(pkg), expect)
|
||||
t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok')
|
||||
})
|
||||
@ -1,35 +0,0 @@
|
||||
const normalize = require('../')
|
||||
const t = require('tap')
|
||||
|
||||
// all of these just delete the bins, so expect the same value
|
||||
const expect = { name: 'hello', version: 'world' }
|
||||
|
||||
t.test('no bin in object', async t => {
|
||||
const pkg = { name: 'hello', version: 'world' }
|
||||
t.strictSame(normalize(pkg), expect)
|
||||
t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok')
|
||||
})
|
||||
|
||||
t.test('empty string bin in object', async t => {
|
||||
const pkg = { name: 'hello', version: 'world', bin: '' }
|
||||
t.strictSame(normalize(pkg), expect)
|
||||
t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok')
|
||||
})
|
||||
|
||||
t.test('false bin in object', async t => {
|
||||
const pkg = { name: 'hello', version: 'world', bin: false }
|
||||
t.strictSame(normalize(pkg), expect)
|
||||
t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok')
|
||||
})
|
||||
|
||||
t.test('null bin in object', async t => {
|
||||
const pkg = { name: 'hello', version: 'world', bin: null }
|
||||
t.strictSame(normalize(pkg), expect)
|
||||
t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok')
|
||||
})
|
||||
|
||||
t.test('number bin', async t => {
|
||||
const pkg = { name: 'hello', version: 'world', bin: 42069 }
|
||||
t.strictSame(normalize(pkg), expect)
|
||||
t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok')
|
||||
})
|
||||
@ -1,37 +0,0 @@
|
||||
const normalize = require('../')
|
||||
const t = require('tap')
|
||||
|
||||
t.test('benign string', async t => {
|
||||
const pkg = { name: 'hello', version: 'world', bin: 'hello.js' }
|
||||
const expect = { name: 'hello', version: 'world', bin: { hello: 'hello.js' } }
|
||||
t.strictSame(normalize(pkg), expect)
|
||||
t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok')
|
||||
})
|
||||
|
||||
t.test('slashy string', async t => {
|
||||
const pkg = { name: 'hello', version: 'world', bin: '/etc/passwd' }
|
||||
const expect = { name: 'hello', version: 'world', bin: { hello: 'etc/passwd' } }
|
||||
t.strictSame(normalize(pkg), expect)
|
||||
t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok')
|
||||
})
|
||||
|
||||
t.test('dotty string', async t => {
|
||||
const pkg = { name: 'hello', version: 'world', bin: '../../../../etc/passwd' }
|
||||
const expect = { name: 'hello', version: 'world', bin: { hello: 'etc/passwd' } }
|
||||
t.strictSame(normalize(pkg), expect)
|
||||
t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok')
|
||||
})
|
||||
|
||||
t.test('double path', async t => {
|
||||
const pkg = { name: 'hello', version: 'world', bin: '/etc/passwd:/bin/usr/exec' }
|
||||
const expect = { name: 'hello', version: 'world', bin: { hello: 'etc/passwd:/bin/usr/exec' } }
|
||||
t.strictSame(normalize(pkg), expect)
|
||||
t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok')
|
||||
})
|
||||
|
||||
t.test('string with no name', async t => {
|
||||
const pkg = { bin: 'foobar.js' }
|
||||
const expect = {}
|
||||
t.strictSame(normalize(pkg), expect)
|
||||
t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok')
|
||||
})
|
||||
@ -1,16 +0,0 @@
|
||||
# Change Log
|
||||
|
||||
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.
|
||||
|
||||
<a name="6.1.0"></a>
|
||||
# [6.1.0](https://github.com/npm/npm-package-arg/compare/v6.0.0...v6.1.0) (2018-04-10)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **git:** Fix gitRange for git+ssh for private git ([#33](https://github.com/npm/npm-package-arg/issues/33)) ([647a0b3](https://github.com/npm/npm-package-arg/commit/647a0b3))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **alias:** add `npm:` registry alias spec ([#34](https://github.com/npm/npm-package-arg/issues/34)) ([ab99f8e](https://github.com/npm/npm-package-arg/commit/ab99f8e))
|
||||
@ -1,15 +0,0 @@
|
||||
The ISC License
|
||||
|
||||
Copyright (c) Isaac Z. Schlueter
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
@ -1,83 +0,0 @@
|
||||
# npm-package-arg
|
||||
|
||||
[](https://travis-ci.org/npm/npm-package-arg)
|
||||
|
||||
Parses package name and specifier passed to commands like `npm install` or
|
||||
`npm cache add`, or as found in `package.json` dependency sections.
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
```javascript
|
||||
var assert = require("assert")
|
||||
var npa = require("npm-package-arg")
|
||||
|
||||
// Pass in the descriptor, and it'll return an object
|
||||
try {
|
||||
var parsed = npa("@bar/foo@1.2")
|
||||
} catch (ex) {
|
||||
…
|
||||
}
|
||||
```
|
||||
|
||||
## USING
|
||||
|
||||
`var npa = require('npm-package-arg')`
|
||||
|
||||
### var result = npa(*arg*[, *where*])
|
||||
|
||||
* *arg* - a string that you might pass to `npm install`, like:
|
||||
`foo@1.2`, `@bar/foo@1.2`, `foo@user/foo`, `http://x.com/foo.tgz`,
|
||||
`git+https://github.com/user/foo`, `bitbucket:user/foo`, `foo.tar.gz`,
|
||||
`../foo/bar/` or `bar`. If the *arg* you provide doesn't have a specifier
|
||||
part, eg `foo` then the specifier will default to `latest`.
|
||||
* *where* - Optionally the path to resolve file paths relative to. Defaults to `process.cwd()`
|
||||
|
||||
**Throws** if the package name is invalid, a dist-tag is invalid or a URL's protocol is not supported.
|
||||
|
||||
### var result = npa.resolve(*name*, *spec*[, *where*])
|
||||
|
||||
* *name* - The name of the module you want to install. For example: `foo` or `@bar/foo`.
|
||||
* *spec* - The specifier indicating where and how you can get this module. Something like:
|
||||
`1.2`, `^1.7.17`, `http://x.com/foo.tgz`, `git+https://github.com/user/foo`,
|
||||
`bitbucket:user/foo`, `file:foo.tar.gz` or `file:../foo/bar/`. If not
|
||||
included then the default is `latest`.
|
||||
* *where* - Optionally the path to resolve file paths relative to. Defaults to `process.cwd()`
|
||||
|
||||
**Throws** if the package name is invalid, a dist-tag is invalid or a URL's protocol is not supported.
|
||||
|
||||
## RESULT OBJECT
|
||||
|
||||
The objects that are returned by npm-package-arg contain the following
|
||||
keys:
|
||||
|
||||
* `type` - One of the following strings:
|
||||
* `git` - A git repo
|
||||
* `tag` - A tagged version, like `"foo@latest"`
|
||||
* `version` - A specific version number, like `"foo@1.2.3"`
|
||||
* `range` - A version range, like `"foo@2.x"`
|
||||
* `file` - A local `.tar.gz`, `.tar` or `.tgz` file.
|
||||
* `directory` - A local directory.
|
||||
* `remote` - An http url (presumably to a tgz)
|
||||
* `registry` - If true this specifier refers to a resource hosted on a
|
||||
registry. This is true for `tag`, `version` and `range` types.
|
||||
* `name` - If known, the `name` field expected in the resulting pkg.
|
||||
* `scope` - If a name is something like `@org/module` then the `scope`
|
||||
field will be set to `@org`. If it doesn't have a scoped name, then
|
||||
scope is `null`.
|
||||
* `escapedName` - A version of `name` escaped to match the npm scoped packages
|
||||
specification. Mostly used when making requests against a registry. When
|
||||
`name` is `null`, `escapedName` will also be `null`.
|
||||
* `rawSpec` - The specifier part that was parsed out in calls to `npa(arg)`,
|
||||
or the value of `spec` in calls to `npa.resolve(name, spec).
|
||||
* `saveSpec` - The normalized specifier, for saving to package.json files.
|
||||
`null` for registry dependencies.
|
||||
* `fetchSpec` - The version of the specifier to be used to fetch this
|
||||
resource. `null` for shortcuts to hosted git dependencies as there isn't
|
||||
just one URL to try with them.
|
||||
* `gitRange` - If set, this is a semver specifier to match against git tags with
|
||||
* `gitCommittish` - If set, this is the specific committish to use with a git dependency.
|
||||
* `hosted` - If `from === 'hosted'` then this will be a `hosted-git-info`
|
||||
object. This property is not included when serializing the object as
|
||||
JSON.
|
||||
* `raw` - The original un-modified string that was provided. If called as
|
||||
`npa.resolve(name, spec)` then this will be `name + '@' + spec`.
|
||||
@ -1,295 +0,0 @@
|
||||
'use strict'
|
||||
module.exports = npa
|
||||
module.exports.resolve = resolve
|
||||
module.exports.Result = Result
|
||||
|
||||
let url
|
||||
let HostedGit
|
||||
let semver
|
||||
let path
|
||||
let validatePackageName
|
||||
let osenv
|
||||
|
||||
const isWindows = process.platform === 'win32' || global.FAKE_WINDOWS
|
||||
const hasSlashes = isWindows ? /\\|[/]/ : /[/]/
|
||||
const isURL = /^(?:git[+])?[a-z]+:/i
|
||||
const isFilename = /[.](?:tgz|tar.gz|tar)$/i
|
||||
|
||||
function npa (arg, where) {
|
||||
let name
|
||||
let spec
|
||||
if (typeof arg === 'object') {
|
||||
if (arg instanceof Result && (!where || where === arg.where)) {
|
||||
return arg
|
||||
} else if (arg.name && arg.rawSpec) {
|
||||
return npa.resolve(arg.name, arg.rawSpec, where || arg.where)
|
||||
} else {
|
||||
return npa(arg.raw, where || arg.where)
|
||||
}
|
||||
}
|
||||
const nameEndsAt = arg[0] === '@' ? arg.slice(1).indexOf('@') + 1 : arg.indexOf('@')
|
||||
const namePart = nameEndsAt > 0 ? arg.slice(0, nameEndsAt) : arg
|
||||
if (isURL.test(arg)) {
|
||||
spec = arg
|
||||
} else if (namePart[0] !== '@' && (hasSlashes.test(namePart) || isFilename.test(namePart))) {
|
||||
spec = arg
|
||||
} else if (nameEndsAt > 0) {
|
||||
name = namePart
|
||||
spec = arg.slice(nameEndsAt + 1)
|
||||
} else {
|
||||
if (!validatePackageName) validatePackageName = require('validate-npm-package-name')
|
||||
const valid = validatePackageName(arg)
|
||||
if (valid.validForOldPackages) {
|
||||
name = arg
|
||||
} else {
|
||||
spec = arg
|
||||
}
|
||||
}
|
||||
return resolve(name, spec, where, arg)
|
||||
}
|
||||
|
||||
const isFilespec = isWindows ? /^(?:[.]|~[/]|[/\\]|[a-zA-Z]:)/ : /^(?:[.]|~[/]|[/]|[a-zA-Z]:)/
|
||||
|
||||
function resolve (name, spec, where, arg) {
|
||||
const res = new Result({
|
||||
raw: arg,
|
||||
name: name,
|
||||
rawSpec: spec,
|
||||
fromArgument: arg != null
|
||||
})
|
||||
|
||||
if (name) res.setName(name)
|
||||
|
||||
if (spec && (isFilespec.test(spec) || /^file:/i.test(spec))) {
|
||||
return fromFile(res, where)
|
||||
} else if (spec && /^npm:/i.test(spec)) {
|
||||
return fromAlias(res, where)
|
||||
}
|
||||
if (!HostedGit) HostedGit = require('hosted-git-info')
|
||||
const hosted = HostedGit.fromUrl(spec, {noGitPlus: true, noCommittish: true})
|
||||
if (hosted) {
|
||||
return fromHostedGit(res, hosted)
|
||||
} else if (spec && isURL.test(spec)) {
|
||||
return fromURL(res)
|
||||
} else if (spec && (hasSlashes.test(spec) || isFilename.test(spec))) {
|
||||
return fromFile(res, where)
|
||||
} else {
|
||||
return fromRegistry(res)
|
||||
}
|
||||
}
|
||||
|
||||
function invalidPackageName (name, valid) {
|
||||
const err = new Error(`Invalid package name "${name}": ${valid.errors.join('; ')}`)
|
||||
err.code = 'EINVALIDPACKAGENAME'
|
||||
return err
|
||||
}
|
||||
function invalidTagName (name) {
|
||||
const err = new Error(`Invalid tag name "${name}": Tags may not have any characters that encodeURIComponent encodes.`)
|
||||
err.code = 'EINVALIDTAGNAME'
|
||||
return err
|
||||
}
|
||||
|
||||
function Result (opts) {
|
||||
this.type = opts.type
|
||||
this.registry = opts.registry
|
||||
this.where = opts.where
|
||||
if (opts.raw == null) {
|
||||
this.raw = opts.name ? opts.name + '@' + opts.rawSpec : opts.rawSpec
|
||||
} else {
|
||||
this.raw = opts.raw
|
||||
}
|
||||
this.name = undefined
|
||||
this.escapedName = undefined
|
||||
this.scope = undefined
|
||||
this.rawSpec = opts.rawSpec == null ? '' : opts.rawSpec
|
||||
this.saveSpec = opts.saveSpec
|
||||
this.fetchSpec = opts.fetchSpec
|
||||
if (opts.name) this.setName(opts.name)
|
||||
this.gitRange = opts.gitRange
|
||||
this.gitCommittish = opts.gitCommittish
|
||||
this.hosted = opts.hosted
|
||||
}
|
||||
Result.prototype = {}
|
||||
|
||||
Result.prototype.setName = function (name) {
|
||||
if (!validatePackageName) validatePackageName = require('validate-npm-package-name')
|
||||
const valid = validatePackageName(name)
|
||||
if (!valid.validForOldPackages) {
|
||||
throw invalidPackageName(name, valid)
|
||||
}
|
||||
this.name = name
|
||||
this.scope = name[0] === '@' ? name.slice(0, name.indexOf('/')) : undefined
|
||||
// scoped packages in couch must have slash url-encoded, e.g. @foo%2Fbar
|
||||
this.escapedName = name.replace('/', '%2f')
|
||||
return this
|
||||
}
|
||||
|
||||
Result.prototype.toString = function () {
|
||||
const full = []
|
||||
if (this.name != null && this.name !== '') full.push(this.name)
|
||||
const spec = this.saveSpec || this.fetchSpec || this.rawSpec
|
||||
if (spec != null && spec !== '') full.push(spec)
|
||||
return full.length ? full.join('@') : this.raw
|
||||
}
|
||||
|
||||
Result.prototype.toJSON = function () {
|
||||
const result = Object.assign({}, this)
|
||||
delete result.hosted
|
||||
return result
|
||||
}
|
||||
|
||||
function setGitCommittish (res, committish) {
|
||||
if (committish != null && committish.length >= 7 && committish.slice(0, 7) === 'semver:') {
|
||||
res.gitRange = decodeURIComponent(committish.slice(7))
|
||||
res.gitCommittish = null
|
||||
} else {
|
||||
res.gitCommittish = committish === '' ? null : committish
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
const isAbsolutePath = /^[/]|^[A-Za-z]:/
|
||||
|
||||
function resolvePath (where, spec) {
|
||||
if (isAbsolutePath.test(spec)) return spec
|
||||
if (!path) path = require('path')
|
||||
return path.resolve(where, spec)
|
||||
}
|
||||
|
||||
function isAbsolute (dir) {
|
||||
if (dir[0] === '/') return true
|
||||
if (/^[A-Za-z]:/.test(dir)) return true
|
||||
return false
|
||||
}
|
||||
|
||||
function fromFile (res, where) {
|
||||
if (!where) where = process.cwd()
|
||||
res.type = isFilename.test(res.rawSpec) ? 'file' : 'directory'
|
||||
res.where = where
|
||||
|
||||
const spec = res.rawSpec.replace(/\\/g, '/')
|
||||
.replace(/^file:[/]*([A-Za-z]:)/, '$1') // drive name paths on windows
|
||||
.replace(/^file:(?:[/]*([~./]))?/, '$1')
|
||||
if (/^~[/]/.test(spec)) {
|
||||
// this is needed for windows and for file:~/foo/bar
|
||||
if (!osenv) osenv = require('osenv')
|
||||
res.fetchSpec = resolvePath(osenv.home(), spec.slice(2))
|
||||
res.saveSpec = 'file:' + spec
|
||||
} else {
|
||||
res.fetchSpec = resolvePath(where, spec)
|
||||
if (isAbsolute(spec)) {
|
||||
res.saveSpec = 'file:' + spec
|
||||
} else {
|
||||
if (!path) path = require('path')
|
||||
res.saveSpec = 'file:' + path.relative(where, res.fetchSpec)
|
||||
}
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
function fromHostedGit (res, hosted) {
|
||||
res.type = 'git'
|
||||
res.hosted = hosted
|
||||
res.saveSpec = hosted.toString({noGitPlus: false, noCommittish: false})
|
||||
res.fetchSpec = hosted.getDefaultRepresentation() === 'shortcut' ? null : hosted.toString()
|
||||
return setGitCommittish(res, hosted.committish)
|
||||
}
|
||||
|
||||
function unsupportedURLType (protocol, spec) {
|
||||
const err = new Error(`Unsupported URL Type "${protocol}": ${spec}`)
|
||||
err.code = 'EUNSUPPORTEDPROTOCOL'
|
||||
return err
|
||||
}
|
||||
|
||||
function matchGitScp (spec) {
|
||||
// git ssh specifiers are overloaded to also use scp-style git
|
||||
// specifiers, so we have to parse those out and treat them special.
|
||||
// They are NOT true URIs, so we can't hand them to `url.parse`.
|
||||
//
|
||||
// This regex looks for things that look like:
|
||||
// git+ssh://git@my.custom.git.com:username/project.git#deadbeef
|
||||
//
|
||||
// ...and various combinations. The username in the beginning is *required*.
|
||||
const matched = spec.match(/^git\+ssh:\/\/([^:#]+:[^#]+(?:\.git)?)(?:#(.*))?$/i)
|
||||
return matched && !matched[1].match(/:[0-9]+\/?.*$/i) && {
|
||||
fetchSpec: matched[1],
|
||||
gitCommittish: matched[2] == null ? null : matched[2]
|
||||
}
|
||||
}
|
||||
|
||||
function fromURL (res) {
|
||||
if (!url) url = require('url')
|
||||
const urlparse = url.parse(res.rawSpec)
|
||||
res.saveSpec = res.rawSpec
|
||||
// check the protocol, and then see if it's git or not
|
||||
switch (urlparse.protocol) {
|
||||
case 'git:':
|
||||
case 'git+http:':
|
||||
case 'git+https:':
|
||||
case 'git+rsync:':
|
||||
case 'git+ftp:':
|
||||
case 'git+file:':
|
||||
case 'git+ssh:':
|
||||
res.type = 'git'
|
||||
const match = urlparse.protocol === 'git+ssh:' && matchGitScp(res.rawSpec)
|
||||
if (match) {
|
||||
setGitCommittish(res, match.gitCommittish)
|
||||
res.fetchSpec = match.fetchSpec
|
||||
} else {
|
||||
setGitCommittish(res, urlparse.hash != null ? urlparse.hash.slice(1) : '')
|
||||
urlparse.protocol = urlparse.protocol.replace(/^git[+]/, '')
|
||||
delete urlparse.hash
|
||||
res.fetchSpec = url.format(urlparse)
|
||||
}
|
||||
break
|
||||
case 'http:':
|
||||
case 'https:':
|
||||
res.type = 'remote'
|
||||
res.fetchSpec = res.saveSpec
|
||||
break
|
||||
|
||||
default:
|
||||
throw unsupportedURLType(urlparse.protocol, res.rawSpec)
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
function fromAlias (res, where) {
|
||||
const subSpec = npa(res.rawSpec.substr(4), where)
|
||||
if (subSpec.type === 'alias') {
|
||||
throw new Error('nested aliases not supported')
|
||||
}
|
||||
if (!subSpec.registry) {
|
||||
throw new Error('aliases only work for registry deps')
|
||||
}
|
||||
res.subSpec = subSpec
|
||||
res.registry = true
|
||||
res.type = 'alias'
|
||||
res.saveSpec = null
|
||||
res.fetchSpec = null
|
||||
return res
|
||||
}
|
||||
|
||||
function fromRegistry (res) {
|
||||
res.registry = true
|
||||
const spec = res.rawSpec === '' ? 'latest' : res.rawSpec
|
||||
// no save spec for registry components as we save based on the fetched
|
||||
// version, not on the argument so this can't compute that.
|
||||
res.saveSpec = null
|
||||
res.fetchSpec = spec
|
||||
if (!semver) semver = require('semver')
|
||||
const version = semver.valid(spec, true)
|
||||
const range = semver.validRange(spec, true)
|
||||
if (version) {
|
||||
res.type = 'version'
|
||||
} else if (range) {
|
||||
res.type = 'range'
|
||||
} else {
|
||||
if (encodeURIComponent(spec) !== spec) {
|
||||
throw invalidTagName(spec)
|
||||
}
|
||||
res.type = 'tag'
|
||||
}
|
||||
return res
|
||||
}
|
||||
@ -1,15 +0,0 @@
|
||||
The ISC License
|
||||
|
||||
Copyright (c) Isaac Z. Schlueter and Contributors
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
@ -1,68 +0,0 @@
|
||||
# npm-packlist
|
||||
|
||||
[](https://travis-ci.com/npm/npm-packlist)
|
||||
|
||||
Get a list of the files to add from a folder into an npm package
|
||||
|
||||
These can be handed to [tar](http://npm.im/tar) like so to make an npm
|
||||
package tarball:
|
||||
|
||||
```js
|
||||
const packlist = require('npm-packlist')
|
||||
const tar = require('tar')
|
||||
const packageDir = '/path/to/package'
|
||||
const packageTarball = '/path/to/package.tgz'
|
||||
|
||||
packlist({ path: packageDir })
|
||||
.then(files => tar.create({
|
||||
prefix: 'package/',
|
||||
cwd: packageDir,
|
||||
file: packageTarball,
|
||||
gzip: true
|
||||
}, files))
|
||||
.then(_ => {
|
||||
// tarball has been created, continue with your day
|
||||
})
|
||||
```
|
||||
|
||||
This uses the following rules:
|
||||
|
||||
1. If a `package.json` file is found, and it has a `files` list,
|
||||
then ignore everything that isn't in `files`. Always include the
|
||||
readme, license, notice, changes, changelog, and history files, if
|
||||
they exist, and the package.json file itself.
|
||||
2. If there's no `package.json` file (or it has no `files` list), and
|
||||
there is a `.npmignore` file, then ignore all the files in the
|
||||
`.npmignore` file.
|
||||
3. If there's no `package.json` with a `files` list, and there's no
|
||||
`.npmignore` file, but there is a `.gitignore` file, then ignore
|
||||
all the files in the `.gitignore` file.
|
||||
4. Everything in the root `node_modules` is ignored, unless it's a
|
||||
bundled dependency. If it IS a bundled dependency, and it's a
|
||||
symbolic link, then the target of the link is included, not the
|
||||
symlink itself.
|
||||
4. Unless they're explicitly included (by being in a `files` list, or
|
||||
a `!negated` rule in a relevant `.npmignore` or `.gitignore`),
|
||||
always ignore certain common cruft files:
|
||||
|
||||
1. .npmignore and .gitignore files (their effect is in the package
|
||||
already, there's no need to include them in the package)
|
||||
2. editor junk like `.*.swp`, `._*` and `.*.orig` files
|
||||
3. `.npmrc` files (these may contain private configs)
|
||||
4. The `node_modules/.bin` folder
|
||||
5. Waf and gyp cruft like `/build/config.gypi` and `.lock-wscript`
|
||||
6. Darwin's `.DS_Store` files because wtf are those even
|
||||
7. `npm-debug.log` files at the root of a project
|
||||
|
||||
You can explicitly re-include any of these with a `files` list in
|
||||
`package.json` or a negated ignore file rule.
|
||||
|
||||
## API
|
||||
|
||||
Same API as [ignore-walk](http://npm.im/ignore-walk), just hard-coded
|
||||
file list and rule sets.
|
||||
|
||||
The `Walker` and `WalkerSync` classes take a `bundled` argument, which
|
||||
is a list of package names to include from node_modules. When calling
|
||||
the top-level `packlist()` and `packlist.sync()` functions, this
|
||||
module calls into `npm-bundled` directly.
|
||||
@ -1,289 +0,0 @@
|
||||
'use strict'
|
||||
|
||||
// Do a two-pass walk, first to get the list of packages that need to be
|
||||
// bundled, then again to get the actual files and folders.
|
||||
// Keep a cache of node_modules content and package.json data, so that the
|
||||
// second walk doesn't have to re-do all the same work.
|
||||
|
||||
const bundleWalk = require('npm-bundled')
|
||||
const BundleWalker = bundleWalk.BundleWalker
|
||||
const BundleWalkerSync = bundleWalk.BundleWalkerSync
|
||||
|
||||
const ignoreWalk = require('ignore-walk')
|
||||
const IgnoreWalker = ignoreWalk.Walker
|
||||
const IgnoreWalkerSync = ignoreWalk.WalkerSync
|
||||
|
||||
const rootBuiltinRules = Symbol('root-builtin-rules')
|
||||
const packageNecessaryRules = Symbol('package-necessary-rules')
|
||||
const path = require('path')
|
||||
|
||||
const normalizePackageBin = require('npm-normalize-package-bin')
|
||||
|
||||
const defaultRules = [
|
||||
'.npmignore',
|
||||
'.gitignore',
|
||||
'**/.git',
|
||||
'**/.svn',
|
||||
'**/.hg',
|
||||
'**/CVS',
|
||||
'**/.git/**',
|
||||
'**/.svn/**',
|
||||
'**/.hg/**',
|
||||
'**/CVS/**',
|
||||
'/.lock-wscript',
|
||||
'/.wafpickle-*',
|
||||
'/build/config.gypi',
|
||||
'npm-debug.log',
|
||||
'**/.npmrc',
|
||||
'.*.swp',
|
||||
'.DS_Store',
|
||||
'**/.DS_Store/**',
|
||||
'._*',
|
||||
'**/._*/**',
|
||||
'*.orig',
|
||||
'/package-lock.json',
|
||||
'/yarn.lock',
|
||||
'archived-packages/**',
|
||||
'core',
|
||||
'!core/',
|
||||
'!**/core/',
|
||||
'*.core',
|
||||
'*.vgcore',
|
||||
'vgcore.*',
|
||||
'core.+([0-9])',
|
||||
]
|
||||
|
||||
// There may be others, but :?|<> are handled by node-tar
|
||||
const nameIsBadForWindows = file => /\*/.test(file)
|
||||
|
||||
// a decorator that applies our custom rules to an ignore walker
|
||||
const npmWalker = Class => class Walker extends Class {
|
||||
constructor (opt) {
|
||||
opt = opt || {}
|
||||
|
||||
// the order in which rules are applied.
|
||||
opt.ignoreFiles = [
|
||||
rootBuiltinRules,
|
||||
'package.json',
|
||||
'.npmignore',
|
||||
'.gitignore',
|
||||
packageNecessaryRules
|
||||
]
|
||||
|
||||
opt.includeEmpty = false
|
||||
opt.path = opt.path || process.cwd()
|
||||
const dirName = path.basename(opt.path)
|
||||
const parentName = path.basename(path.dirname(opt.path))
|
||||
opt.follow =
|
||||
dirName === 'node_modules' ||
|
||||
(parentName === 'node_modules' && /^@/.test(dirName))
|
||||
super(opt)
|
||||
|
||||
// ignore a bunch of things by default at the root level.
|
||||
// also ignore anything in node_modules, except bundled dependencies
|
||||
if (!this.parent) {
|
||||
this.bundled = opt.bundled || []
|
||||
this.bundledScopes = Array.from(new Set(
|
||||
this.bundled.filter(f => /^@/.test(f))
|
||||
.map(f => f.split('/')[0])))
|
||||
const rules = defaultRules.join('\n') + '\n'
|
||||
this.packageJsonCache = opt.packageJsonCache || new Map()
|
||||
super.onReadIgnoreFile(rootBuiltinRules, rules, _=>_)
|
||||
} else {
|
||||
this.bundled = []
|
||||
this.bundledScopes = []
|
||||
this.packageJsonCache = this.parent.packageJsonCache
|
||||
}
|
||||
}
|
||||
|
||||
onReaddir (entries) {
|
||||
if (!this.parent) {
|
||||
entries = entries.filter(e =>
|
||||
e !== '.git' &&
|
||||
!(e === 'node_modules' && this.bundled.length === 0)
|
||||
)
|
||||
}
|
||||
return super.onReaddir(entries)
|
||||
}
|
||||
|
||||
filterEntry (entry, partial) {
|
||||
// get the partial path from the root of the walk
|
||||
const p = this.path.substr(this.root.length + 1)
|
||||
const pkgre = /^node_modules\/(@[^\/]+\/?[^\/]+|[^\/]+)(\/.*)?$/
|
||||
const isRoot = !this.parent
|
||||
const pkg = isRoot && pkgre.test(entry) ?
|
||||
entry.replace(pkgre, '$1') : null
|
||||
const rootNM = isRoot && entry === 'node_modules'
|
||||
const rootPJ = isRoot && entry === 'package.json'
|
||||
|
||||
return (
|
||||
// if we're in a bundled package, check with the parent.
|
||||
/^node_modules($|\/)/i.test(p) ? this.parent.filterEntry(
|
||||
this.basename + '/' + entry, partial)
|
||||
|
||||
// if package is bundled, all files included
|
||||
// also include @scope dirs for bundled scoped deps
|
||||
// they'll be ignored if no files end up in them.
|
||||
// However, this only matters if we're in the root.
|
||||
// node_modules folders elsewhere, like lib/node_modules,
|
||||
// should be included normally unless ignored.
|
||||
: pkg ? -1 !== this.bundled.indexOf(pkg) ||
|
||||
-1 !== this.bundledScopes.indexOf(pkg)
|
||||
|
||||
// only walk top node_modules if we want to bundle something
|
||||
: rootNM ? !!this.bundled.length
|
||||
|
||||
// always include package.json at the root.
|
||||
: rootPJ ? true
|
||||
|
||||
// otherwise, follow ignore-walk's logic
|
||||
: super.filterEntry(entry, partial)
|
||||
)
|
||||
}
|
||||
|
||||
filterEntries () {
|
||||
if (this.ignoreRules['package.json'])
|
||||
this.ignoreRules['.gitignore'] = this.ignoreRules['.npmignore'] = null
|
||||
else if (this.ignoreRules['.npmignore'])
|
||||
this.ignoreRules['.gitignore'] = null
|
||||
this.filterEntries = super.filterEntries
|
||||
super.filterEntries()
|
||||
}
|
||||
|
||||
addIgnoreFile (file, then) {
|
||||
const ig = path.resolve(this.path, file)
|
||||
if (this.packageJsonCache.has(ig))
|
||||
this.onPackageJson(ig, this.packageJsonCache.get(ig), then)
|
||||
else
|
||||
super.addIgnoreFile(file, then)
|
||||
}
|
||||
|
||||
onPackageJson (ig, pkg, then) {
|
||||
this.packageJsonCache.set(ig, pkg)
|
||||
|
||||
// if there's a bin, browser or main, make sure we don't ignore it
|
||||
// also, don't ignore the package.json itself!
|
||||
//
|
||||
// Weird side-effect of this: a readme (etc) file will be included
|
||||
// if it exists anywhere within a folder with a package.json file.
|
||||
// The original intent was only to include these files in the root,
|
||||
// but now users in the wild are dependent on that behavior for
|
||||
// localized documentation and other use cases. Adding a `/` to
|
||||
// these rules, while tempting and arguably more "correct", is a
|
||||
// breaking change.
|
||||
const rules = [
|
||||
pkg.browser ? '!' + pkg.browser : '',
|
||||
pkg.main ? '!' + pkg.main : '',
|
||||
'!package.json',
|
||||
'!npm-shrinkwrap.json',
|
||||
'!@(readme|copying|license|licence|notice|changes|changelog|history){,.*[^~$]}'
|
||||
]
|
||||
if (pkg.bin) {
|
||||
// always an object, because normalized already
|
||||
for (const key in pkg.bin)
|
||||
rules.push('!' + pkg.bin[key])
|
||||
}
|
||||
|
||||
const data = rules.filter(f => f).join('\n') + '\n'
|
||||
super.onReadIgnoreFile(packageNecessaryRules, data, _=>_)
|
||||
|
||||
if (Array.isArray(pkg.files))
|
||||
super.onReadIgnoreFile('package.json', '*\n' + pkg.files.map(
|
||||
f => '!' + f + '\n!' + f.replace(/\/+$/, '') + '/**'
|
||||
).join('\n') + '\n', then)
|
||||
else
|
||||
then()
|
||||
}
|
||||
|
||||
// override parent stat function to completely skip any filenames
|
||||
// that will break windows entirely.
|
||||
// XXX(isaacs) Next major version should make this an error instead.
|
||||
stat (entry, file, dir, then) {
|
||||
if (nameIsBadForWindows(entry))
|
||||
then()
|
||||
else
|
||||
super.stat(entry, file, dir, then)
|
||||
}
|
||||
|
||||
// override parent onstat function to nix all symlinks
|
||||
onstat (st, entry, file, dir, then) {
|
||||
if (st.isSymbolicLink())
|
||||
then()
|
||||
else
|
||||
super.onstat(st, entry, file, dir, then)
|
||||
}
|
||||
|
||||
onReadIgnoreFile (file, data, then) {
|
||||
if (file === 'package.json')
|
||||
try {
|
||||
const ig = path.resolve(this.path, file)
|
||||
this.onPackageJson(ig, normalizePackageBin(JSON.parse(data)), then)
|
||||
} catch (er) {
|
||||
// ignore package.json files that are not json
|
||||
then()
|
||||
}
|
||||
else
|
||||
super.onReadIgnoreFile(file, data, then)
|
||||
}
|
||||
|
||||
sort (a, b) {
|
||||
return sort(a, b)
|
||||
}
|
||||
}
|
||||
|
||||
class Walker extends npmWalker(IgnoreWalker) {
|
||||
walker (entry, then) {
|
||||
new Walker(this.walkerOpt(entry)).on('done', then).start()
|
||||
}
|
||||
}
|
||||
|
||||
class WalkerSync extends npmWalker(IgnoreWalkerSync) {
|
||||
walker (entry, then) {
|
||||
new WalkerSync(this.walkerOpt(entry)).start()
|
||||
then()
|
||||
}
|
||||
}
|
||||
|
||||
const walk = (options, callback) => {
|
||||
options = options || {}
|
||||
const p = new Promise((resolve, reject) => {
|
||||
const bw = new BundleWalker(options)
|
||||
bw.on('done', bundled => {
|
||||
options.bundled = bundled
|
||||
options.packageJsonCache = bw.packageJsonCache
|
||||
new Walker(options).on('done', resolve).on('error', reject).start()
|
||||
})
|
||||
bw.start()
|
||||
})
|
||||
return callback ? p.then(res => callback(null, res), callback) : p
|
||||
}
|
||||
|
||||
const walkSync = options => {
|
||||
options = options || {}
|
||||
const bw = new BundleWalkerSync(options).start()
|
||||
options.bundled = bw.result
|
||||
options.packageJsonCache = bw.packageJsonCache
|
||||
const walker = new WalkerSync(options)
|
||||
walker.start()
|
||||
return walker.result
|
||||
}
|
||||
|
||||
// optimize for compressibility
|
||||
// extname, then basename, then locale alphabetically
|
||||
// https://twitter.com/isntitvacant/status/1131094910923231232
|
||||
const sort = (a, b) => {
|
||||
const exta = path.extname(a).toLowerCase()
|
||||
const extb = path.extname(b).toLowerCase()
|
||||
const basea = path.basename(a).toLowerCase()
|
||||
const baseb = path.basename(b).toLowerCase()
|
||||
|
||||
return exta.localeCompare(extb) ||
|
||||
basea.localeCompare(baseb) ||
|
||||
a.localeCompare(b)
|
||||
}
|
||||
|
||||
|
||||
module.exports = walk
|
||||
walk.sync = walkSync
|
||||
walk.Walker = Walker
|
||||
walk.WalkerSync = WalkerSync
|
||||
@ -1,133 +0,0 @@
|
||||
# Change Log
|
||||
|
||||
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.
|
||||
|
||||
<a name="2.2.3"></a>
|
||||
## [2.2.3](https://github.com/zkat/npm-pick-manifest/compare/v2.2.2...v2.2.3) (2018-10-31)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **enjoyBy:** rework semantics for enjoyBy again ([5e89b62](https://github.com/zkat/npm-pick-manifest/commit/5e89b62))
|
||||
|
||||
|
||||
|
||||
<a name="2.2.2"></a>
|
||||
## [2.2.2](https://github.com/zkat/npm-pick-manifest/compare/v2.2.1...v2.2.2) (2018-10-31)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **enjoyBy:** rework semantics for enjoyBy ([5684f45](https://github.com/zkat/npm-pick-manifest/commit/5684f45))
|
||||
|
||||
|
||||
|
||||
<a name="2.2.1"></a>
|
||||
## [2.2.1](https://github.com/zkat/npm-pick-manifest/compare/v2.2.0...v2.2.1) (2018-10-30)
|
||||
|
||||
|
||||
|
||||
<a name="2.2.0"></a>
|
||||
# [2.2.0](https://github.com/zkat/npm-pick-manifest/compare/v2.1.0...v2.2.0) (2018-10-30)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **audit:** npm audit fix --force ([d5ae6c4](https://github.com/zkat/npm-pick-manifest/commit/d5ae6c4))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **enjoyBy:** add opts.enjoyBy option to filter versions by date ([0b8a790](https://github.com/zkat/npm-pick-manifest/commit/0b8a790))
|
||||
|
||||
|
||||
|
||||
<a name="2.1.0"></a>
|
||||
# [2.1.0](https://github.com/zkat/npm-pick-manifest/compare/v2.0.1...v2.1.0) (2017-10-18)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **selection:** allow manually disabling deprecation skipping ([0d239d3](https://github.com/zkat/npm-pick-manifest/commit/0d239d3))
|
||||
|
||||
|
||||
|
||||
<a name="2.0.1"></a>
|
||||
## [2.0.1](https://github.com/zkat/npm-pick-manifest/compare/v2.0.0...v2.0.1) (2017-10-18)
|
||||
|
||||
|
||||
|
||||
<a name="2.0.0"></a>
|
||||
# [2.0.0](https://github.com/zkat/npm-pick-manifest/compare/v1.0.4...v2.0.0) (2017-10-03)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **license:** relicense project according to npm policy (#3) ([ed743a0](https://github.com/zkat/npm-pick-manifest/commit/ed743a0))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **selection:** Avoid matching deprecated packages if possible ([3fc6c3a](https://github.com/zkat/npm-pick-manifest/commit/3fc6c3a))
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* **selection:** deprecated versions may be skipped now
|
||||
* **license:** This moves the license from CC0 to ISC and properly documents the copyright as belonging to npm, Inc.
|
||||
|
||||
|
||||
|
||||
<a name="1.0.4"></a>
|
||||
## [1.0.4](https://github.com/zkat/npm-pick-manifest/compare/v1.0.3...v1.0.4) (2017-06-29)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **npa:** bump npa version for bugfixes ([7cdaca7](https://github.com/zkat/npm-pick-manifest/commit/7cdaca7))
|
||||
* **semver:** use loose semver parsing for *all* ops ([bbc0daa](https://github.com/zkat/npm-pick-manifest/commit/bbc0daa))
|
||||
|
||||
|
||||
|
||||
<a name="1.0.3"></a>
|
||||
## [1.0.3](https://github.com/zkat/npm-pick-manifest/compare/v1.0.2...v1.0.3) (2017-05-04)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **semver:** use semver.clean() instead ([f4133b5](https://github.com/zkat/npm-pick-manifest/commit/f4133b5))
|
||||
|
||||
|
||||
|
||||
<a name="1.0.2"></a>
|
||||
## [1.0.2](https://github.com/zkat/npm-pick-manifest/compare/v1.0.1...v1.0.2) (2017-05-04)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **picker:** spaces in `wanted` prevented match ([97a7d0a](https://github.com/zkat/npm-pick-manifest/commit/97a7d0a))
|
||||
|
||||
|
||||
|
||||
<a name="1.0.1"></a>
|
||||
## [1.0.1](https://github.com/zkat/npm-pick-manifest/compare/v1.0.0...v1.0.1) (2017-04-24)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **deps:** forgot to add semver ([1876f4f](https://github.com/zkat/npm-pick-manifest/commit/1876f4f))
|
||||
|
||||
|
||||
|
||||
<a name="1.0.0"></a>
|
||||
# 1.0.0 (2017-04-24)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **api:** initial implementation. ([b086912](https://github.com/zkat/npm-pick-manifest/commit/b086912))
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* **api:** ex nihilo
|
||||
@ -1,16 +0,0 @@
|
||||
ISC License
|
||||
|
||||
Copyright (c) npm, Inc.
|
||||
|
||||
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.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE COPYRIGHT HOLDER DISCLAIMS
|
||||
ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER 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.
|
||||
@ -1,84 +0,0 @@
|
||||
# npm-pick-manifest [](https://npm.im/npm-pick-manifest) [](https://npm.im/npm-pick-manifest) [](https://travis-ci.org/zkat/npm-pick-manifest) [](https://ci.appveyor.com/project/zkat/npm-pick-manifest) [](https://coveralls.io/github/zkat/npm-pick-manifest?branch=latest)
|
||||
|
||||
[`npm-pick-manifest`](https://github.com/zkat/npm-pick-manifest) is a standalone
|
||||
implementation of [npm](https://npmjs.com)'s semver range resolution algorithm.
|
||||
|
||||
## Install
|
||||
|
||||
`$ npm install --save npm-pick-manifest`
|
||||
|
||||
## Table of Contents
|
||||
|
||||
* [Example](#example)
|
||||
* [Features](#features)
|
||||
* [Contributing](#contributing)
|
||||
* [API](#api)
|
||||
* [`pickManifest()`](#pick-manifest)
|
||||
|
||||
### Example
|
||||
|
||||
```javascript
|
||||
const pickManifest = require('npm-pick-manifest')
|
||||
|
||||
fetch('https://registry.npmjs.org/npm-pick-manifest').then(res => {
|
||||
return res.json()
|
||||
}).then(packument => {
|
||||
return pickManifest(packument, '^1.0.0')
|
||||
}) // get same manifest as npm would get if you `npm i npm-pick-manifest@^1.0.0`
|
||||
```
|
||||
|
||||
### Features
|
||||
|
||||
* Uses npm's exact semver resolution algorithm
|
||||
* Supports ranges, tags, and versions
|
||||
|
||||
### Contributing
|
||||
|
||||
The npm-pick-manifest team enthusiastically welcomes contributions and project participation!
|
||||
There's a bunch of things you can do if you want to contribute! The [Contributor
|
||||
Guide](CONTRIBUTING.md) has all the information you need for everything from
|
||||
reporting bugs to contributing entire new features. Please don't hesitate to
|
||||
jump in if you'd like to, or even ask us questions if something isn't clear.
|
||||
|
||||
### API
|
||||
|
||||
#### <a name="pick-manifest"></a> `> pickManifest(packument, selector, [opts]) -> manifest`
|
||||
|
||||
Returns the manifest that matches `selector`, or throws an error.
|
||||
|
||||
Packuments are anything returned by metadata URLs from the npm registry. That
|
||||
is, they're objects with the following shape (only fields used by
|
||||
`npm-pick-manifest` included):
|
||||
|
||||
```javascript
|
||||
{
|
||||
name: 'some-package',
|
||||
'dist-tags': {
|
||||
foo: '1.0.1'
|
||||
},
|
||||
versions: {
|
||||
'1.0.0': { version: '1.0.0' },
|
||||
'1.0.1': { version: '1.0.1' },
|
||||
'1.0.2': { version: '1.0.2' },
|
||||
'2.0.0': { version: '2.0.0' }
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The algorithm will follow npm's algorithm for semver resolution, and only `tag`,
|
||||
`range`, and `version` selectors are supported.
|
||||
|
||||
The function will throw `ETARGET` if there was no matching manifest, and
|
||||
`ENOVERSIONS` if the packument object has no valid versions in `versions`.
|
||||
|
||||
If `opts.defaultTag` is provided, it will be used instead of `latest`. That is,
|
||||
if that tag matches the selector, it will be used, even if a higher available
|
||||
version matches the range.
|
||||
|
||||
If `opts.enjoyBy` is provided, it should be something that can be passed to `new
|
||||
Date(x)`, such as a `Date` object or a timestamp string. It will be used to
|
||||
filter the selected versions such that only versions less than or equal to
|
||||
`enjoyBy` are considered.
|
||||
|
||||
If `opts.includeDeprecated` passed in as true, deprecated versions will be
|
||||
selected. By default, deprecated versions other than `defaultTag` are ignored.
|
||||
@ -1,121 +0,0 @@
|
||||
'use strict'
|
||||
|
||||
const figgyPudding = require('figgy-pudding')
|
||||
const npa = require('npm-package-arg')
|
||||
const semver = require('semver')
|
||||
|
||||
const PickerOpts = figgyPudding({
|
||||
defaultTag: { default: 'latest' },
|
||||
enjoyBy: {},
|
||||
includeDeprecated: { default: false }
|
||||
})
|
||||
|
||||
module.exports = pickManifest
|
||||
function pickManifest (packument, wanted, opts) {
|
||||
opts = PickerOpts(opts)
|
||||
const time = opts.enjoyBy && packument.time && +(new Date(opts.enjoyBy))
|
||||
const spec = npa.resolve(packument.name, wanted)
|
||||
const type = spec.type
|
||||
if (type === 'version' || type === 'range') {
|
||||
wanted = semver.clean(wanted, true) || wanted
|
||||
}
|
||||
const distTags = packument['dist-tags'] || {}
|
||||
const versions = Object.keys(packument.versions || {}).filter(v => {
|
||||
return semver.valid(v, true)
|
||||
})
|
||||
|
||||
function enjoyableBy (v) {
|
||||
return !time || (
|
||||
packument.time[v] && time >= +(new Date(packument.time[v]))
|
||||
)
|
||||
}
|
||||
|
||||
let err
|
||||
|
||||
if (!versions.length) {
|
||||
err = new Error(`No valid versions available for ${packument.name}`)
|
||||
err.code = 'ENOVERSIONS'
|
||||
err.name = packument.name
|
||||
err.type = type
|
||||
err.wanted = wanted
|
||||
throw err
|
||||
}
|
||||
|
||||
let target
|
||||
|
||||
if (type === 'tag' && enjoyableBy(distTags[wanted])) {
|
||||
target = distTags[wanted]
|
||||
} else if (type === 'version') {
|
||||
target = wanted
|
||||
} else if (type !== 'range' && enjoyableBy(distTags[wanted])) {
|
||||
throw new Error('Only tag, version, and range are supported')
|
||||
}
|
||||
|
||||
const tagVersion = distTags[opts.defaultTag]
|
||||
|
||||
if (
|
||||
!target &&
|
||||
tagVersion &&
|
||||
packument.versions[tagVersion] &&
|
||||
enjoyableBy(tagVersion) &&
|
||||
semver.satisfies(tagVersion, wanted, true)
|
||||
) {
|
||||
target = tagVersion
|
||||
}
|
||||
|
||||
if (!target && !opts.includeDeprecated) {
|
||||
const undeprecated = versions.filter(v => !packument.versions[v].deprecated && enjoyableBy(v)
|
||||
)
|
||||
target = semver.maxSatisfying(undeprecated, wanted, true)
|
||||
}
|
||||
if (!target) {
|
||||
const stillFresh = versions.filter(enjoyableBy)
|
||||
target = semver.maxSatisfying(stillFresh, wanted, true)
|
||||
}
|
||||
|
||||
if (!target && wanted === '*' && enjoyableBy(tagVersion)) {
|
||||
// This specific corner is meant for the case where
|
||||
// someone is using `*` as a selector, but all versions
|
||||
// are pre-releases, which don't match ranges at all.
|
||||
target = tagVersion
|
||||
}
|
||||
|
||||
if (
|
||||
!target &&
|
||||
time &&
|
||||
type === 'tag' &&
|
||||
distTags[wanted] &&
|
||||
!enjoyableBy(distTags[wanted])
|
||||
) {
|
||||
const stillFresh = versions.filter(v =>
|
||||
enjoyableBy(v) && semver.lte(v, distTags[wanted], true)
|
||||
).sort(semver.rcompare)
|
||||
target = stillFresh[0]
|
||||
}
|
||||
|
||||
const manifest = (
|
||||
target &&
|
||||
packument.versions[target]
|
||||
)
|
||||
if (!manifest) {
|
||||
err = new Error(
|
||||
`No matching version found for ${packument.name}@${wanted}${
|
||||
opts.enjoyBy
|
||||
? ` with an Enjoy By date of ${
|
||||
new Date(opts.enjoyBy).toLocaleString()
|
||||
}. Maybe try a different date?`
|
||||
: ''
|
||||
}`
|
||||
)
|
||||
err.code = 'ETARGET'
|
||||
err.name = packument.name
|
||||
err.type = type
|
||||
err.wanted = wanted
|
||||
err.versions = versions
|
||||
err.distTags = distTags
|
||||
err.defaultTag = opts.defaultTag
|
||||
throw err
|
||||
} else {
|
||||
return manifest
|
||||
}
|
||||
}
|
||||
@ -1,214 +0,0 @@
|
||||
# Change Log
|
||||
|
||||
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.
|
||||
|
||||
<a name="3.9.1"></a>
|
||||
## [3.9.1](https://github.com/npm/registry-fetch/compare/v3.9.0...v3.9.1) (2019-07-02)
|
||||
|
||||
|
||||
|
||||
<a name="3.9.0"></a>
|
||||
# [3.9.0](https://github.com/npm/registry-fetch/compare/v3.8.0...v3.9.0) (2019-01-24)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **auth:** support username:password encoded legacy _auth ([a91f90c](https://github.com/npm/registry-fetch/commit/a91f90c))
|
||||
|
||||
|
||||
|
||||
<a name="3.8.0"></a>
|
||||
# [3.8.0](https://github.com/npm/registry-fetch/compare/v3.7.0...v3.8.0) (2018-08-23)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **mapJson:** add support for passing in json stream mapper ([0600986](https://github.com/npm/registry-fetch/commit/0600986))
|
||||
|
||||
|
||||
|
||||
<a name="3.7.0"></a>
|
||||
# [3.7.0](https://github.com/npm/registry-fetch/compare/v3.6.0...v3.7.0) (2018-08-23)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **json.stream:** add utility function for streamed JSON parsing ([051d969](https://github.com/npm/registry-fetch/commit/051d969))
|
||||
|
||||
|
||||
|
||||
<a name="3.6.0"></a>
|
||||
# [3.6.0](https://github.com/npm/registry-fetch/compare/v3.5.0...v3.6.0) (2018-08-22)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **docs:** document opts.forceAuth ([40bcd65](https://github.com/npm/registry-fetch/commit/40bcd65))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **opts.ignoreBody:** add a boolean to throw away response bodies ([6923702](https://github.com/npm/registry-fetch/commit/6923702))
|
||||
|
||||
|
||||
|
||||
<a name="3.5.0"></a>
|
||||
# [3.5.0](https://github.com/npm/registry-fetch/compare/v3.4.0...v3.5.0) (2018-08-22)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **pkgid:** heuristic pkgid calculation for errors ([2e789a5](https://github.com/npm/registry-fetch/commit/2e789a5))
|
||||
|
||||
|
||||
|
||||
<a name="3.4.0"></a>
|
||||
# [3.4.0](https://github.com/npm/registry-fetch/compare/v3.3.0...v3.4.0) (2018-08-22)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **deps:** use new figgy-pudding with aliases fix ([0308f54](https://github.com/npm/registry-fetch/commit/0308f54))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **auth:** add forceAuth option to force a specific auth mechanism ([4524d17](https://github.com/npm/registry-fetch/commit/4524d17))
|
||||
|
||||
|
||||
|
||||
<a name="3.3.0"></a>
|
||||
# [3.3.0](https://github.com/npm/registry-fetch/compare/v3.2.1...v3.3.0) (2018-08-21)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **query:** stop including undefined keys ([4718b1b](https://github.com/npm/registry-fetch/commit/4718b1b))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **otp:** use heuristic detection for malformed EOTP responses ([f035194](https://github.com/npm/registry-fetch/commit/f035194))
|
||||
|
||||
|
||||
|
||||
<a name="3.2.1"></a>
|
||||
## [3.2.1](https://github.com/npm/registry-fetch/compare/v3.2.0...v3.2.1) (2018-08-16)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **opts:** pass through non-null opts.retry ([beba040](https://github.com/npm/registry-fetch/commit/beba040))
|
||||
|
||||
|
||||
|
||||
<a name="3.2.0"></a>
|
||||
# [3.2.0](https://github.com/npm/registry-fetch/compare/v3.1.1...v3.2.0) (2018-07-27)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **gzip:** add opts.gzip convenience opt ([340abe0](https://github.com/npm/registry-fetch/commit/340abe0))
|
||||
|
||||
|
||||
|
||||
<a name="3.1.1"></a>
|
||||
## [3.1.1](https://github.com/npm/registry-fetch/compare/v3.1.0...v3.1.1) (2018-04-09)
|
||||
|
||||
|
||||
|
||||
<a name="3.1.0"></a>
|
||||
# [3.1.0](https://github.com/npm/registry-fetch/compare/v3.0.0...v3.1.0) (2018-04-09)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **config:** support no-proxy and https-proxy options ([9aa906b](https://github.com/npm/registry-fetch/commit/9aa906b))
|
||||
|
||||
|
||||
|
||||
<a name="3.0.0"></a>
|
||||
# [3.0.0](https://github.com/npm/registry-fetch/compare/v2.1.0...v3.0.0) (2018-04-09)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **api:** pacote integration-related fixes ([a29de4f](https://github.com/npm/registry-fetch/commit/a29de4f))
|
||||
* **config:** stop caring about opts.config ([5856a6f](https://github.com/npm/registry-fetch/commit/5856a6f))
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* **config:** opts.config is no longer supported. Pass the options down in opts itself.
|
||||
|
||||
|
||||
|
||||
<a name="2.1.0"></a>
|
||||
# [2.1.0](https://github.com/npm/registry-fetch/compare/v2.0.0...v2.1.0) (2018-04-08)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **token:** accept opts.token for opts._authToken ([108c9f0](https://github.com/npm/registry-fetch/commit/108c9f0))
|
||||
|
||||
|
||||
|
||||
<a name="2.0.0"></a>
|
||||
# [2.0.0](https://github.com/npm/registry-fetch/compare/v1.1.1...v2.0.0) (2018-04-08)
|
||||
|
||||
|
||||
### meta
|
||||
|
||||
* drop support for node@4 ([758536e](https://github.com/npm/registry-fetch/commit/758536e))
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* node@4 is no longer supported
|
||||
|
||||
|
||||
|
||||
<a name="1.1.1"></a>
|
||||
## [1.1.1](https://github.com/npm/registry-fetch/compare/v1.1.0...v1.1.1) (2018-04-06)
|
||||
|
||||
|
||||
|
||||
<a name="1.1.0"></a>
|
||||
# [1.1.0](https://github.com/npm/registry-fetch/compare/v1.0.1...v1.1.0) (2018-03-16)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **specs:** can use opts.spec to trigger pickManifest ([85c4ac9](https://github.com/npm/registry-fetch/commit/85c4ac9))
|
||||
|
||||
|
||||
|
||||
<a name="1.0.1"></a>
|
||||
## [1.0.1](https://github.com/npm/registry-fetch/compare/v1.0.0...v1.0.1) (2018-03-16)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **query:** oops console.log ([870e4f5](https://github.com/npm/registry-fetch/commit/870e4f5))
|
||||
|
||||
|
||||
|
||||
<a name="1.0.0"></a>
|
||||
# 1.0.0 (2018-03-16)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **auth:** get auth working with all the little details ([84b94ba](https://github.com/npm/registry-fetch/commit/84b94ba))
|
||||
* **deps:** add bluebird as an actual dep ([1286e31](https://github.com/npm/registry-fetch/commit/1286e31))
|
||||
* **errors:** Unknown auth errors use default code ([#1](https://github.com/npm/registry-fetch/issues/1)) ([3d91b93](https://github.com/npm/registry-fetch/commit/3d91b93))
|
||||
* **standard:** remove args from invocation ([9620a0a](https://github.com/npm/registry-fetch/commit/9620a0a))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **api:** baseline kinda-working API impl ([bf91f9f](https://github.com/npm/registry-fetch/commit/bf91f9f))
|
||||
* **body:** automatic handling of different opts.body values ([f3b97db](https://github.com/npm/registry-fetch/commit/f3b97db))
|
||||
* **config:** nicer input config input handling ([b9ce21d](https://github.com/npm/registry-fetch/commit/b9ce21d))
|
||||
* **opts:** use figgy-pudding for opts handling ([0abd527](https://github.com/npm/registry-fetch/commit/0abd527))
|
||||
* **query:** add query utility support ([65ea8b1](https://github.com/npm/registry-fetch/commit/65ea8b1))
|
||||
@ -1,16 +0,0 @@
|
||||
ISC License
|
||||
|
||||
Copyright (c) npm, Inc.
|
||||
|
||||
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.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE COPYRIGHT HOLDER DISCLAIMS
|
||||
ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER 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.
|
||||
@ -1,609 +0,0 @@
|
||||
# npm-registry-fetch [](https://npm.im/npm-registry-fetch) [](https://npm.im/npm-registry-fetch) [](https://travis-ci.org/npm/npm-registry-fetch) [](https://ci.appveyor.com/project/npm/npm-registry-fetch) [](https://coveralls.io/github/npm/npm-registry-fetch?branch=latest)
|
||||
|
||||
[`npm-registry-fetch`](https://github.com/npm/npm-registry-fetch) is a Node.js
|
||||
library that implements a `fetch`-like API for accessing npm registry APIs
|
||||
consistently. It's able to consume npm-style configuration values and has all
|
||||
the necessary logic for picking registries, handling scopes, and dealing with
|
||||
authentication details built-in.
|
||||
|
||||
This package is meant to replace the older
|
||||
[`npm-registry-client`](https://npm.im/npm-registry-client).
|
||||
|
||||
## Example
|
||||
|
||||
```javascript
|
||||
const npmFetch = require('npm-registry-fetch')
|
||||
|
||||
console.log(
|
||||
await npmFetch.json('/-/ping')
|
||||
)
|
||||
```
|
||||
|
||||
## Table of Contents
|
||||
|
||||
* [Installing](#install)
|
||||
* [Example](#example)
|
||||
* [Contributing](#contributing)
|
||||
* [API](#api)
|
||||
* [`fetch`](#fetch)
|
||||
* [`fetch.json`](#fetch-json)
|
||||
* [`fetch` options](#fetch-opts)
|
||||
|
||||
### Install
|
||||
|
||||
`$ npm install npm-registry-fetch`
|
||||
|
||||
### Contributing
|
||||
|
||||
The npm team enthusiastically welcomes contributions and project participation!
|
||||
There's a bunch of things you can do if you want to contribute! The [Contributor
|
||||
Guide](CONTRIBUTING.md) has all the information you need for everything from
|
||||
reporting bugs to contributing entire new features. Please don't hesitate to
|
||||
jump in if you'd like to, or even ask us questions if something isn't clear.
|
||||
|
||||
All participants and maintainers in this project are expected to follow [Code of
|
||||
Conduct](CODE_OF_CONDUCT.md), and just generally be excellent to each other.
|
||||
|
||||
Please refer to the [Changelog](CHANGELOG.md) for project history details, too.
|
||||
|
||||
Happy hacking!
|
||||
|
||||
### API
|
||||
|
||||
#### <a name="fetch"></a> `> fetch(url, [opts]) -> Promise<Response>`
|
||||
|
||||
Performs a request to a given URL.
|
||||
|
||||
The URL can be either a full URL, or a path to one. The appropriate registry
|
||||
will be automatically picked if only a URL path is given.
|
||||
|
||||
For available options, please see the section on [`fetch` options](#fetch-opts).
|
||||
|
||||
##### Example
|
||||
|
||||
```javascript
|
||||
const res = await fetch('/-/ping')
|
||||
console.log(res.headers)
|
||||
res.on('data', d => console.log(d.toString('utf8')))
|
||||
```
|
||||
|
||||
#### <a name="fetch-json"></a> `> fetch.json(url, [opts]) -> Promise<ResponseJSON>`
|
||||
|
||||
Performs a request to a given registry URL, parses the body of the response as
|
||||
JSON, and returns it as its final value. This is a utility shorthand for
|
||||
`fetch(url).then(res => res.json())`.
|
||||
|
||||
For available options, please see the section on [`fetch` options](#fetch-opts).
|
||||
|
||||
##### Example
|
||||
|
||||
```javascript
|
||||
const res = await fetch.json('/-/ping')
|
||||
console.log(res) // Body parsed as JSON
|
||||
```
|
||||
|
||||
#### <a name="fetch-json-stream"></a> `> fetch.json.stream(url, jsonPath, [opts]) -> Stream`
|
||||
|
||||
Performs a request to a given registry URL and parses the body of the response
|
||||
as JSON, with each entry being emitted through the stream.
|
||||
|
||||
The `jsonPath` argument is a [`JSONStream.parse()`
|
||||
path](https://github.com/dominictarr/JSONStream#jsonstreamparsepath), and the
|
||||
returned stream (unlike default `JSONStream`s), has a valid
|
||||
`Symbol.asyncIterator` implementation.
|
||||
|
||||
For available options, please see the section on [`fetch` options](#fetch-opts).
|
||||
|
||||
##### Example
|
||||
|
||||
```javascript
|
||||
console.log('https://npm.im/~zkat has access to the following packages:')
|
||||
for await (let {key, value} of fetch.json.stream('/-/user/zkat/package', '$*')) {
|
||||
console.log(`https://npm.im/${key} (perms: ${value})`)
|
||||
}
|
||||
```
|
||||
|
||||
#### <a name="fetch-opts"></a> `fetch` Options
|
||||
|
||||
Fetch options are optional, and can be passed in as either a Map-like object
|
||||
(one with a `.get()` method), a plain javascript object, or a
|
||||
[`figgy-pudding`](https://npm.im/figgy-pudding) instance.
|
||||
|
||||
##### <a name="opts-agent"></a> `opts.agent`
|
||||
|
||||
* Type: http.Agent
|
||||
* Default: an appropriate agent based on URL protocol and proxy settings
|
||||
|
||||
An [`Agent`](https://nodejs.org/api/http.html#http_class_http_agent) instance to
|
||||
be shared across requests. This allows multiple concurrent `fetch` requests to
|
||||
happen on the same socket.
|
||||
|
||||
You do _not_ need to provide this option unless you want something particularly
|
||||
specialized, since proxy configurations and http/https agents are already
|
||||
automatically managed internally when this option is not passed through.
|
||||
|
||||
##### <a name="opts-body"></a> `opts.body`
|
||||
|
||||
* Type: Buffer | Stream | Object
|
||||
* Default: null
|
||||
|
||||
Request body to send through the outgoing request. Buffers and Streams will be
|
||||
passed through as-is, with a default `content-type` of
|
||||
`application/octet-stream`. Plain JavaScript objects will be `JSON.stringify`ed
|
||||
and the `content-type` will default to `application/json`.
|
||||
|
||||
Use [`opts.headers`](#opts-headers) to set the content-type to something else.
|
||||
|
||||
##### <a name="opts-ca"></a> `opts.ca`
|
||||
|
||||
* Type: String, Array, or null
|
||||
* Default: null
|
||||
|
||||
The Certificate Authority signing certificate that is trusted for SSL
|
||||
connections to the registry. Values should be in PEM format (Windows calls it
|
||||
"Base-64 encoded X.509 (.CER)") with newlines replaced by the string `'\n'`. For
|
||||
example:
|
||||
|
||||
```
|
||||
{
|
||||
ca: '-----BEGIN CERTIFICATE-----\nXXXX\nXXXX\n-----END CERTIFICATE-----'
|
||||
}
|
||||
```
|
||||
|
||||
Set to `null` to only allow "known" registrars, or to a specific CA cert
|
||||
to trust only that specific signing authority.
|
||||
|
||||
Multiple CAs can be trusted by specifying an array of certificates instead of a
|
||||
single string.
|
||||
|
||||
See also [`opts.strict-ssl`](#opts-strict-ssl), [`opts.ca`](#opts-ca) and
|
||||
[`opts.key`](#opts-key)
|
||||
|
||||
##### <a name="opts-cache"></a> `opts.cache`
|
||||
|
||||
* Type: path
|
||||
* Default: null
|
||||
|
||||
The location of the http cache directory. If provided, certain cachable requests
|
||||
will be cached according to [IETF RFC 7234](https://tools.ietf.org/html/rfc7234)
|
||||
rules. This will speed up future requests, as well as make the cached data
|
||||
available offline if necessary/requested.
|
||||
|
||||
See also [`offline`](#opts-offline), [`prefer-offline`](#opts-prefer-offline),
|
||||
and [`prefer-online`](#opts-prefer-online).
|
||||
|
||||
##### <a name="opts-cert"></a> `opts.cert`
|
||||
|
||||
* Type: String
|
||||
* Default: null
|
||||
|
||||
A client certificate to pass when accessing the registry. Values should be in
|
||||
PEM format (Windows calls it "Base-64 encoded X.509 (.CER)") with newlines
|
||||
replaced by the string `'\n'`. For example:
|
||||
|
||||
```
|
||||
{
|
||||
cert: '-----BEGIN CERTIFICATE-----\nXXXX\nXXXX\n-----END CERTIFICATE-----'
|
||||
}
|
||||
```
|
||||
|
||||
It is _not_ the path to a certificate file (and there is no "certfile" option).
|
||||
|
||||
See also: [`opts.ca`](#opts-ca) and [`opts.key`](#opts-key)
|
||||
|
||||
##### <a name="opts-fetch-retries"></a> `opts.fetch-retries`
|
||||
|
||||
* Type: Number
|
||||
* Default: 2
|
||||
|
||||
The "retries" config for [`retry`](https://npm.im/retry) to use when fetching
|
||||
packages from the registry.
|
||||
|
||||
See also [`opts.retry`](#opts-retry) to provide all retry options as a single
|
||||
object.
|
||||
|
||||
##### <a name="opts-fetch-retry-factor"></a> `opts.fetch-retry-factor`
|
||||
|
||||
* Type: Number
|
||||
* Default: 10
|
||||
|
||||
The "factor" config for [`retry`](https://npm.im/retry) to use when fetching
|
||||
packages.
|
||||
|
||||
See also [`opts.retry`](#opts-retry) to provide all retry options as a single
|
||||
object.
|
||||
|
||||
##### <a name="opts-fetch-retry-mintimeout"></a> `opts.fetch-retry-mintimeout`
|
||||
|
||||
* Type: Number
|
||||
* Default: 10000 (10 seconds)
|
||||
|
||||
The "minTimeout" config for [`retry`](https://npm.im/retry) to use when fetching
|
||||
packages.
|
||||
|
||||
See also [`opts.retry`](#opts-retry) to provide all retry options as a single
|
||||
object.
|
||||
|
||||
##### <a name="opts-fetch-retry-maxtimeout"></a> `opts.fetch-retry-maxtimeout`
|
||||
|
||||
* Type: Number
|
||||
* Default: 60000 (1 minute)
|
||||
|
||||
The "maxTimeout" config for [`retry`](https://npm.im/retry) to use when fetching
|
||||
packages.
|
||||
|
||||
See also [`opts.retry`](#opts-retry) to provide all retry options as a single
|
||||
object.
|
||||
|
||||
##### <a name="opts-force-auth"></a> `opts.force-auth`
|
||||
|
||||
* Alias: `opts.forceAuth`
|
||||
* Type: Object
|
||||
* Default: null
|
||||
|
||||
If present, other auth-related values in `opts` will be completely ignored,
|
||||
including `alwaysAuth`, `email`, and `otp`, when calculating auth for a request,
|
||||
and the auth details in `opts.forceAuth` will be used instead.
|
||||
|
||||
##### <a name="opts-gzip"></a> `opts.gzip`
|
||||
|
||||
* Type: Boolean
|
||||
* Default: false
|
||||
|
||||
If true, `npm-registry-fetch` will set the `Content-Encoding` header to `gzip`
|
||||
and use `zlib.gzip()` or `zlib.createGzip()` to gzip-encode
|
||||
[`opts.body`](#opts-body).
|
||||
|
||||
##### <a name="opts-headers"></a> `opts.headers`
|
||||
|
||||
* Type: Object
|
||||
* Default: null
|
||||
|
||||
Additional headers for the outgoing request. This option can also be used to
|
||||
override headers automatically generated by `npm-registry-fetch`, such as
|
||||
`Content-Type`.
|
||||
|
||||
##### <a name="opts-ignore-body"></a> `opts.ignore-body`
|
||||
|
||||
* Alias: `opts.ignoreBody`
|
||||
* Type: Boolean
|
||||
* Default: false
|
||||
|
||||
If true, the **response body** will be thrown away and `res.body` set to `null`.
|
||||
This will prevent dangling response sockets for requests where you don't usually
|
||||
care what the response body is.
|
||||
|
||||
##### <a name="opts-integrity"></a> `opts.integrity`
|
||||
|
||||
* Type: String | [SRI object](https://npm.im/ssri)
|
||||
* Default: null
|
||||
|
||||
If provided, the response body's will be verified against this integrity string,
|
||||
using [`ssri`](https://npm.im/ssri). If verification succeeds, the response will
|
||||
complete as normal. If verification fails, the response body will error with an
|
||||
`EINTEGRITY` error.
|
||||
|
||||
Body integrity is only verified if the body is actually consumed to completion --
|
||||
that is, if you use `res.json()`/`res.buffer()`, or if you consume the default
|
||||
`res` stream data to its end.
|
||||
|
||||
Cached data will have its integrity automatically verified using the
|
||||
previously-generated integrity hash for the saved request information, so
|
||||
`EINTEGRITY` errors can happen if [`opts.cache`](#opts-cache) is used, even if
|
||||
`opts.integrity` is not passed in.
|
||||
|
||||
##### <a name='opts-is-from-ci'></a> `opts.is-from-ci`
|
||||
|
||||
* Alias: `opts.isFromCI`
|
||||
* Type: Boolean
|
||||
* Default: Based on environment variables
|
||||
|
||||
This is used to populate the `npm-in-ci` request header sent to the registry.
|
||||
|
||||
##### <a name="opts-key"></a> `opts.key`
|
||||
|
||||
* Type: String
|
||||
* Default: null
|
||||
|
||||
A client key to pass when accessing the registry. Values should be in PEM
|
||||
format with newlines replaced by the string `'\n'`. For example:
|
||||
|
||||
```
|
||||
{
|
||||
key: '-----BEGIN PRIVATE KEY-----\nXXXX\nXXXX\n-----END PRIVATE KEY-----'
|
||||
}
|
||||
```
|
||||
|
||||
It is _not_ the path to a key file (and there is no "keyfile" option).
|
||||
|
||||
See also: [`opts.ca`](#opts-ca) and [`opts.cert`](#opts-cert)
|
||||
|
||||
##### <a name="opts-local-address"></a> `opts.local-address`
|
||||
|
||||
* Type: IP Address String
|
||||
* Default: null
|
||||
|
||||
The IP address of the local interface to use when making connections
|
||||
to the registry.
|
||||
|
||||
See also [`opts.proxy`](#opts-proxy)
|
||||
|
||||
##### <a name="opts-log"></a> `opts.log`
|
||||
|
||||
* Type: [`npmlog`](https://npm.im/npmlog)-like
|
||||
* Default: null
|
||||
|
||||
Logger object to use for logging operation details. Must have the same methods
|
||||
as `npmlog`.
|
||||
|
||||
##### <a name="opts-map-json"></a> `opts.map-json`
|
||||
|
||||
* Alias: `mapJson`, `mapJSON`
|
||||
* Type: Function
|
||||
* Default: undefined
|
||||
|
||||
When using `fetch.json.stream()` (NOT `fetch.json()`), this will be passed down
|
||||
to [`JSONStream`](https://npm.im/JSONStream) as the second argument to
|
||||
`JSONStream.parse`, and can be used to transform stream data before output.
|
||||
|
||||
##### <a name="opts-maxsockets"></a> `opts.maxsockets`
|
||||
|
||||
* Alias: `opts.max-sockets`
|
||||
* Type: Integer
|
||||
* Default: 12
|
||||
|
||||
Maximum number of sockets to keep open during requests. Has no effect if
|
||||
[`opts.agent`](#opts-agent) is used.
|
||||
|
||||
##### <a name="opts-method"></a> `opts.method`
|
||||
|
||||
* Type: String
|
||||
* Default: 'GET'
|
||||
|
||||
HTTP method to use for the outgoing request. Case-insensitive.
|
||||
|
||||
##### <a name="opts-noproxy"></a> `opts.noproxy`
|
||||
|
||||
* Type: Boolean
|
||||
* Default: process.env.NOPROXY
|
||||
|
||||
If true, proxying will be disabled even if [`opts.proxy`](#opts-proxy) is used.
|
||||
|
||||
##### <a name="opts-npm-session"></a> `opts.npm-session`
|
||||
|
||||
* Alias: `opts.npmSession`
|
||||
* Type: String
|
||||
* Default: null
|
||||
|
||||
If provided, will be sent in the `npm-session` header. This header is used by
|
||||
the npm registry to identify individual user sessions (usually individual
|
||||
invocations of the CLI).
|
||||
|
||||
##### <a name="opts-offline"></a> `opts.offline`
|
||||
|
||||
* Type: Boolean
|
||||
* Default: false
|
||||
|
||||
Force offline mode: no network requests will be done during install. To allow
|
||||
`npm-registry-fetch` to fill in missing cache data, see
|
||||
[`opts.prefer-offline`](#opts-prefer-offline).
|
||||
|
||||
This option is only really useful if you're also using
|
||||
[`opts.cache`](#opts-cache).
|
||||
|
||||
##### <a name="opts-otp"></a> `opts.otp`
|
||||
|
||||
* Type: Number | String
|
||||
* Default: null
|
||||
|
||||
This is a one-time password from a two-factor authenticator. It is required for
|
||||
certain registry interactions when two-factor auth is enabled for a user
|
||||
account.
|
||||
|
||||
##### <a name="opts-password"></a> `opts.password`
|
||||
|
||||
* Alias: _password
|
||||
* Type: String
|
||||
* Default: null
|
||||
|
||||
Password used for basic authentication. For the more modern authentication
|
||||
method, please use the (more secure) [`opts.token`](#opts-token)
|
||||
|
||||
Can optionally be scoped to a registry by using a "nerf dart" for that registry.
|
||||
That is:
|
||||
|
||||
```
|
||||
{
|
||||
'//registry.npmjs.org/:password': 't0k3nH34r'
|
||||
}
|
||||
```
|
||||
|
||||
See also [`opts.username`](#opts-username)
|
||||
|
||||
##### <a name="opts-prefer-offline"></a> `opts.prefer-offline`
|
||||
|
||||
* Type: Boolean
|
||||
* Default: false
|
||||
|
||||
If true, staleness checks for cached data will be bypassed, but missing data
|
||||
will be requested from the server. To force full offline mode, use
|
||||
[`opts.offline`](#opts-offline).
|
||||
|
||||
This option is generally only useful if you're also using
|
||||
[`opts.cache`](#opts-cache).
|
||||
|
||||
##### <a name="opts-prefer-online"></a> `opts.prefer-online`
|
||||
|
||||
* Type: Boolean
|
||||
* Default: false
|
||||
|
||||
If true, staleness checks for cached data will be forced, making the CLI look
|
||||
for updates immediately even for fresh package data.
|
||||
|
||||
This option is generally only useful if you're also using
|
||||
[`opts.cache`](#opts-cache).
|
||||
|
||||
|
||||
##### <a name="opts-project-scope"></a> `opts.project-scope`
|
||||
|
||||
* Alias: `opts.projectScope`
|
||||
* Type: String
|
||||
* Default: null
|
||||
|
||||
If provided, will be sent in the `npm-scope` header. This header is used by the
|
||||
npm registry to identify the toplevel package scope that a particular project
|
||||
installation is using.
|
||||
|
||||
##### <a name="opts-proxy"></a> `opts.proxy`
|
||||
|
||||
* Type: url
|
||||
* Default: null
|
||||
|
||||
A proxy to use for outgoing http requests. If not passed in, the `HTTP(S)_PROXY`
|
||||
environment variable will be used.
|
||||
|
||||
##### <a name="opts-query"></a> `opts.query`
|
||||
|
||||
* Type: String | Object
|
||||
* Default: null
|
||||
|
||||
If provided, the request URI will have a query string appended to it using this
|
||||
query. If `opts.query` is an object, it will be converted to a query string
|
||||
using
|
||||
[`querystring.stringify()`](https://nodejs.org/api/querystring.html#querystring_querystring_stringify_obj_sep_eq_options).
|
||||
|
||||
If the request URI already has a query string, it will be merged with
|
||||
`opts.query`, preferring `opts.query` values.
|
||||
|
||||
##### <a name="opts-refer"></a> `opts.refer`
|
||||
|
||||
* Alias: `opts.referer`
|
||||
* Type: String
|
||||
* Default: null
|
||||
|
||||
Value to use for the `Referer` header. The npm CLI itself uses this to serialize
|
||||
the npm command line using the given request.
|
||||
|
||||
##### <a name="opts-registry"></a> `opts.registry`
|
||||
|
||||
* Type: URL
|
||||
* Default: `'https://registry.npmjs.org'`
|
||||
|
||||
Registry configuration for a request. If a request URL only includes the URL
|
||||
path, this registry setting will be prepended. This configuration is also used
|
||||
to determine authentication details, so even if the request URL references a
|
||||
completely different host, `opts.registry` will be used to find the auth details
|
||||
for that request.
|
||||
|
||||
See also [`opts.scope`](#opts-scope), [`opts.spec`](#opts-spec), and
|
||||
[`opts.<scope>:registry`](#opts-scope-registry) which can all affect the actual
|
||||
registry URL used by the outgoing request.
|
||||
|
||||
##### <a name="opts-retry"></a> `opts.retry`
|
||||
|
||||
* Type: Object
|
||||
* Default: null
|
||||
|
||||
Single-object configuration for request retry settings. If passed in, will
|
||||
override individually-passed `fetch-retry-*` settings.
|
||||
|
||||
##### <a name="opts-scope"></a> `opts.scope`
|
||||
|
||||
* Type: String
|
||||
* Default: null
|
||||
|
||||
Associate an operation with a scope for a scoped registry. This option can force
|
||||
lookup of scope-specific registries and authentication.
|
||||
|
||||
See also [`opts.<scope>:registry`](#opts-scope-registry) and
|
||||
[`opts.spec`](#opts-spec) for interactions with this option.
|
||||
|
||||
##### <a name="opts-scope-registry"></a> `opts.<scope>:registry`
|
||||
|
||||
* Type: String
|
||||
* Default: null
|
||||
|
||||
This option type can be used to configure the registry used for requests
|
||||
involving a particular scope. For example, `opts['@myscope:registry'] =
|
||||
'https://scope-specific.registry/'` will make it so requests go out to this
|
||||
registry instead of [`opts.registry`](#opts-registry) when
|
||||
[`opts.scope`](#opts-scope) is used, or when [`opts.spec`](#opts-spec) is a
|
||||
scoped package spec.
|
||||
|
||||
The `@` before the scope name is optional, but recommended.
|
||||
|
||||
##### <a name="opts-spec"></a> `opts.spec`
|
||||
|
||||
* Type: String | [`npm-registry-arg`](https://npm.im/npm-registry-arg) object.
|
||||
* Default: null
|
||||
|
||||
If provided, can be used to automatically configure [`opts.scope`](#opts-scope)
|
||||
based on a specific package name. Non-registry package specs will throw an
|
||||
error.
|
||||
|
||||
##### <a name="opts-strict-ssl"></a> `opts.strict-ssl`
|
||||
|
||||
* Type: Boolean
|
||||
* Default: true
|
||||
|
||||
Whether or not to do SSL key validation when making requests to the
|
||||
registry via https.
|
||||
|
||||
See also [`opts.ca`](#opts-ca).
|
||||
|
||||
##### <a name="opts-timeout"></a> `opts.timeout`
|
||||
|
||||
* Type: Milliseconds
|
||||
* Default: 30000 (30 seconds)
|
||||
|
||||
Time before a hanging request times out.
|
||||
|
||||
##### <a name="opts-token"></a> `opts.token`
|
||||
|
||||
* Alias: `opts._authToken`
|
||||
* Type: String
|
||||
* Default: null
|
||||
|
||||
Authentication token string.
|
||||
|
||||
Can be scoped to a registry by using a "nerf dart" for that registry. That is:
|
||||
|
||||
```
|
||||
{
|
||||
'//registry.npmjs.org/:token': 't0k3nH34r'
|
||||
}
|
||||
```
|
||||
|
||||
##### <a name="opts-user-agent"></a> `opts.user-agent`
|
||||
|
||||
* Type: String
|
||||
* Default: `'npm-registry-fetch@<version>/node@<node-version>+<arch> (<platform>)'`
|
||||
|
||||
User agent string to send in the `User-Agent` header.
|
||||
|
||||
##### <a name="opts-username"></a> `opts.username`
|
||||
|
||||
* Type: String
|
||||
* Default: null
|
||||
|
||||
Username used for basic authentication. For the more modern authentication
|
||||
method, please use the (more secure) [`opts.token`](#opts-token)
|
||||
|
||||
Can optionally be scoped to a registry by using a "nerf dart" for that registry.
|
||||
That is:
|
||||
|
||||
```
|
||||
{
|
||||
'//registry.npmjs.org/:username': 't0k3nH34r'
|
||||
}
|
||||
```
|
||||
|
||||
See also [`opts.password`](#opts-password)
|
||||
|
||||
##### <a name="opts-auth"></a> `opts._auth`
|
||||
|
||||
* Type: String
|
||||
* Default: null
|
||||
|
||||
** DEPRECATED ** This is a legacy authentication token supported only for
|
||||
*compatibility. Please use [`opts.token`](#opts-token) instead.
|
||||
@ -1,57 +0,0 @@
|
||||
'use strict'
|
||||
|
||||
const config = require('./config.js')
|
||||
const url = require('url')
|
||||
|
||||
module.exports = getAuth
|
||||
function getAuth (registry, opts) {
|
||||
if (!registry) { throw new Error('registry is required') }
|
||||
opts = config(opts)
|
||||
let AUTH = {}
|
||||
const regKey = registry && registryKey(registry)
|
||||
if (opts.forceAuth) {
|
||||
opts = opts.forceAuth
|
||||
}
|
||||
const doKey = (key, alias) => addKey(opts, AUTH, regKey, key, alias)
|
||||
doKey('token')
|
||||
doKey('_authToken', 'token')
|
||||
doKey('username')
|
||||
doKey('password')
|
||||
doKey('_password', 'password')
|
||||
doKey('email')
|
||||
doKey('_auth')
|
||||
doKey('otp')
|
||||
doKey('always-auth', 'alwaysAuth')
|
||||
if (AUTH.password) {
|
||||
AUTH.password = Buffer.from(AUTH.password, 'base64').toString('utf8')
|
||||
}
|
||||
if (AUTH._auth && !(AUTH.username && AUTH.password)) {
|
||||
let auth = Buffer.from(AUTH._auth, 'base64').toString()
|
||||
auth = auth.split(':')
|
||||
AUTH.username = auth.shift()
|
||||
AUTH.password = auth.join(':')
|
||||
}
|
||||
AUTH.alwaysAuth = AUTH.alwaysAuth === 'false' ? false : !!AUTH.alwaysAuth
|
||||
return AUTH
|
||||
}
|
||||
|
||||
function addKey (opts, obj, scope, key, objKey) {
|
||||
if (opts[key]) {
|
||||
obj[objKey || key] = opts[key]
|
||||
}
|
||||
if (scope && opts[`${scope}:${key}`]) {
|
||||
obj[objKey || key] = opts[`${scope}:${key}`]
|
||||
}
|
||||
}
|
||||
|
||||
// Called a nerf dart in the main codebase. Used as a "safe"
|
||||
// key when fetching registry info from config.
|
||||
function registryKey (registry) {
|
||||
const parsed = url.parse(registry)
|
||||
const formatted = url.format({
|
||||
host: parsed.host,
|
||||
pathname: parsed.pathname,
|
||||
slashes: parsed.slashes
|
||||
})
|
||||
return url.resolve(formatted, '.')
|
||||
}
|
||||
@ -1,109 +0,0 @@
|
||||
'use strict'
|
||||
|
||||
const config = require('./config.js')
|
||||
const errors = require('./errors.js')
|
||||
const LRU = require('lru-cache')
|
||||
|
||||
module.exports = checkResponse
|
||||
function checkResponse (method, res, registry, startTime, opts) {
|
||||
opts = config(opts)
|
||||
if (res.headers.has('npm-notice') && !res.headers.has('x-local-cache')) {
|
||||
opts.log.notice('', res.headers.get('npm-notice'))
|
||||
}
|
||||
checkWarnings(res, registry, opts)
|
||||
if (res.status >= 400) {
|
||||
logRequest(method, res, startTime, opts)
|
||||
return checkErrors(method, res, startTime, opts)
|
||||
} else {
|
||||
res.body.on('end', () => logRequest(method, res, startTime, opts))
|
||||
if (opts.ignoreBody) {
|
||||
res.body.resume()
|
||||
res.body = null
|
||||
}
|
||||
return res
|
||||
}
|
||||
}
|
||||
|
||||
function logRequest (method, res, startTime, opts) {
|
||||
const elapsedTime = Date.now() - startTime
|
||||
const attempt = res.headers.get('x-fetch-attempts')
|
||||
const attemptStr = attempt && attempt > 1 ? ` attempt #${attempt}` : ''
|
||||
const cacheStr = res.headers.get('x-local-cache') ? ' (from cache)' : ''
|
||||
opts.log.http(
|
||||
'fetch',
|
||||
`${method.toUpperCase()} ${res.status} ${res.url} ${elapsedTime}ms${attemptStr}${cacheStr}`
|
||||
)
|
||||
}
|
||||
|
||||
const WARNING_REGEXP = /^\s*(\d{3})\s+(\S+)\s+"(.*)"\s+"([^"]+)"/
|
||||
const BAD_HOSTS = new LRU({ max: 50 })
|
||||
|
||||
function checkWarnings (res, registry, opts) {
|
||||
if (res.headers.has('warning') && !BAD_HOSTS.has(registry)) {
|
||||
const warnings = {}
|
||||
res.headers.raw()['warning'].forEach(w => {
|
||||
const match = w.match(WARNING_REGEXP)
|
||||
if (match) {
|
||||
warnings[match[1]] = {
|
||||
code: match[1],
|
||||
host: match[2],
|
||||
message: match[3],
|
||||
date: new Date(match[4])
|
||||
}
|
||||
}
|
||||
})
|
||||
BAD_HOSTS.set(registry, true)
|
||||
if (warnings['199']) {
|
||||
if (warnings['199'].message.match(/ENOTFOUND/)) {
|
||||
opts.log.warn('registry', `Using stale data from ${registry} because the host is inaccessible -- are you offline?`)
|
||||
} else {
|
||||
opts.log.warn('registry', `Unexpected warning for ${registry}: ${warnings['199'].message}`)
|
||||
}
|
||||
}
|
||||
if (warnings['111']) {
|
||||
// 111 Revalidation failed -- we're using stale data
|
||||
opts.log.warn(
|
||||
'registry',
|
||||
`Using stale data from ${registry} due to a request error during revalidation.`
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function checkErrors (method, res, startTime, opts) {
|
||||
return res.buffer()
|
||||
.catch(() => null)
|
||||
.then(body => {
|
||||
let parsed = body
|
||||
try {
|
||||
parsed = JSON.parse(body.toString('utf8'))
|
||||
} catch (e) {}
|
||||
if (res.status === 401 && res.headers.get('www-authenticate')) {
|
||||
const auth = res.headers.get('www-authenticate')
|
||||
.split(/,\s*/)
|
||||
.map(s => s.toLowerCase())
|
||||
if (auth.indexOf('ipaddress') !== -1) {
|
||||
throw new errors.HttpErrorAuthIPAddress(
|
||||
method, res, parsed, opts.spec
|
||||
)
|
||||
} else if (auth.indexOf('otp') !== -1) {
|
||||
throw new errors.HttpErrorAuthOTP(
|
||||
method, res, parsed, opts.spec
|
||||
)
|
||||
} else {
|
||||
throw new errors.HttpErrorAuthUnknown(
|
||||
method, res, parsed, opts.spec
|
||||
)
|
||||
}
|
||||
} else if (res.status === 401 && /one-time pass/.test(body.toString('utf8'))) {
|
||||
// Heuristic for malformed OTP responses that don't include the www-authenticate header.
|
||||
throw new errors.HttpErrorAuthOTP(
|
||||
method, res, parsed, opts.spec
|
||||
)
|
||||
} else {
|
||||
throw new errors.HttpErrorGeneral(
|
||||
method, res, parsed, opts.spec
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -1,98 +0,0 @@
|
||||
'use strict'
|
||||
|
||||
const pkg = require('./package.json')
|
||||
const figgyPudding = require('figgy-pudding')
|
||||
const silentLog = require('./silentlog.js')
|
||||
|
||||
const AUTH_REGEX = /^(?:.*:)?(token|_authToken|username|_password|password|email|always-auth|_auth|otp)$/
|
||||
const SCOPE_REGISTRY_REGEX = /@.*:registry$/gi
|
||||
module.exports = figgyPudding({
|
||||
'agent': {},
|
||||
'algorithms': {},
|
||||
'body': {},
|
||||
'ca': {},
|
||||
'cache': {},
|
||||
'cert': {},
|
||||
'fetch-retries': {},
|
||||
'fetch-retry-factor': {},
|
||||
'fetch-retry-maxtimeout': {},
|
||||
'fetch-retry-mintimeout': {},
|
||||
'force-auth': {},
|
||||
forceAuth: 'force-auth',
|
||||
'gid': {},
|
||||
'gzip': {},
|
||||
'headers': {},
|
||||
'https-proxy': {},
|
||||
'ignore-body': {},
|
||||
ignoreBody: 'ignore-body',
|
||||
'integrity': {},
|
||||
'is-from-ci': 'isFromCI',
|
||||
'isFromCI': {
|
||||
default () {
|
||||
return (
|
||||
process.env['CI'] === 'true' ||
|
||||
process.env['TDDIUM'] ||
|
||||
process.env['JENKINS_URL'] ||
|
||||
process.env['bamboo.buildKey'] ||
|
||||
process.env['GO_PIPELINE_NAME']
|
||||
)
|
||||
}
|
||||
},
|
||||
'key': {},
|
||||
'local-address': {},
|
||||
'log': {
|
||||
default: silentLog
|
||||
},
|
||||
'map-json': 'mapJson',
|
||||
'mapJSON': 'mapJson',
|
||||
'mapJson': {},
|
||||
'max-sockets': 'maxsockets',
|
||||
'maxsockets': {
|
||||
default: 12
|
||||
},
|
||||
'memoize': {},
|
||||
'method': {
|
||||
default: 'GET'
|
||||
},
|
||||
'no-proxy': {},
|
||||
'noproxy': {},
|
||||
'npm-session': 'npmSession',
|
||||
'npmSession': {},
|
||||
'offline': {},
|
||||
'otp': {},
|
||||
'prefer-offline': {},
|
||||
'prefer-online': {},
|
||||
'projectScope': {},
|
||||
'project-scope': 'projectScope',
|
||||
'Promise': {default: () => Promise},
|
||||
'proxy': {},
|
||||
'query': {},
|
||||
'refer': {},
|
||||
'referer': 'refer',
|
||||
'registry': {
|
||||
default: 'https://registry.npmjs.org/'
|
||||
},
|
||||
'retry': {},
|
||||
'scope': {},
|
||||
'spec': {},
|
||||
'strict-ssl': {},
|
||||
'timeout': {},
|
||||
'uid': {},
|
||||
'user-agent': {
|
||||
default: `${
|
||||
pkg.name
|
||||
}@${
|
||||
pkg.version
|
||||
}/node@${
|
||||
process.version
|
||||
}+${
|
||||
process.arch
|
||||
} (${
|
||||
process.platform
|
||||
})`
|
||||
}
|
||||
}, {
|
||||
other (key) {
|
||||
return key.match(AUTH_REGEX) || key.match(SCOPE_REGISTRY_REGEX)
|
||||
}
|
||||
})
|
||||
@ -1,79 +0,0 @@
|
||||
'use strict'
|
||||
|
||||
const url = require('url')
|
||||
|
||||
function packageName (href) {
|
||||
try {
|
||||
let basePath = url.parse(href).pathname.substr(1)
|
||||
if (!basePath.match(/^-/)) {
|
||||
basePath = basePath.split('/')
|
||||
var index = basePath.indexOf('_rewrite')
|
||||
if (index === -1) {
|
||||
index = basePath.length - 1
|
||||
} else {
|
||||
index++
|
||||
}
|
||||
return decodeURIComponent(basePath[index])
|
||||
}
|
||||
} catch (_) {
|
||||
// this is ok
|
||||
}
|
||||
}
|
||||
|
||||
class HttpErrorBase extends Error {
|
||||
constructor (method, res, body, spec) {
|
||||
super()
|
||||
this.headers = res.headers.raw()
|
||||
this.statusCode = res.status
|
||||
this.code = `E${res.status}`
|
||||
this.method = method
|
||||
this.uri = res.url
|
||||
this.body = body
|
||||
this.pkgid = spec ? spec.toString() : packageName(res.url)
|
||||
}
|
||||
}
|
||||
module.exports.HttpErrorBase = HttpErrorBase
|
||||
|
||||
class HttpErrorGeneral extends HttpErrorBase {
|
||||
constructor (method, res, body, spec) {
|
||||
super(method, res, body, spec)
|
||||
this.message = `${res.status} ${res.statusText} - ${
|
||||
this.method.toUpperCase()
|
||||
} ${
|
||||
this.spec || this.uri
|
||||
}${
|
||||
(body && body.error) ? ' - ' + body.error : ''
|
||||
}`
|
||||
Error.captureStackTrace(this, HttpErrorGeneral)
|
||||
}
|
||||
}
|
||||
module.exports.HttpErrorGeneral = HttpErrorGeneral
|
||||
|
||||
class HttpErrorAuthOTP extends HttpErrorBase {
|
||||
constructor (method, res, body, spec) {
|
||||
super(method, res, body, spec)
|
||||
this.message = 'OTP required for authentication'
|
||||
this.code = 'EOTP'
|
||||
Error.captureStackTrace(this, HttpErrorAuthOTP)
|
||||
}
|
||||
}
|
||||
module.exports.HttpErrorAuthOTP = HttpErrorAuthOTP
|
||||
|
||||
class HttpErrorAuthIPAddress extends HttpErrorBase {
|
||||
constructor (method, res, body, spec) {
|
||||
super(method, res, body, spec)
|
||||
this.message = 'Login is not allowed from your IP address'
|
||||
this.code = 'EAUTHIP'
|
||||
Error.captureStackTrace(this, HttpErrorAuthIPAddress)
|
||||
}
|
||||
}
|
||||
module.exports.HttpErrorAuthIPAddress = HttpErrorAuthIPAddress
|
||||
|
||||
class HttpErrorAuthUnknown extends HttpErrorBase {
|
||||
constructor (method, res, body, spec) {
|
||||
super(method, res, body, spec)
|
||||
this.message = 'Unable to authenticate, need: ' + res.headers.get('www-authenticate')
|
||||
Error.captureStackTrace(this, HttpErrorAuthUnknown)
|
||||
}
|
||||
}
|
||||
module.exports.HttpErrorAuthUnknown = HttpErrorAuthUnknown
|
||||
@ -1,193 +0,0 @@
|
||||
'use strict'
|
||||
|
||||
const Buffer = require('safe-buffer').Buffer
|
||||
|
||||
const checkResponse = require('./check-response.js')
|
||||
const config = require('./config.js')
|
||||
const getAuth = require('./auth.js')
|
||||
const fetch = require('make-fetch-happen')
|
||||
const JSONStream = require('JSONStream')
|
||||
const npa = require('npm-package-arg')
|
||||
const {PassThrough} = require('stream')
|
||||
const qs = require('querystring')
|
||||
const url = require('url')
|
||||
const zlib = require('zlib')
|
||||
|
||||
module.exports = regFetch
|
||||
function regFetch (uri, opts) {
|
||||
opts = config(opts)
|
||||
const registry = (
|
||||
(opts.spec && pickRegistry(opts.spec, opts)) ||
|
||||
opts.registry ||
|
||||
'https://registry.npmjs.org/'
|
||||
)
|
||||
uri = url.parse(uri).protocol
|
||||
? uri
|
||||
: `${
|
||||
registry.trim().replace(/\/?$/g, '')
|
||||
}/${
|
||||
uri.trim().replace(/^\//, '')
|
||||
}`
|
||||
// through that takes into account the scope, the prefix of `uri`, etc
|
||||
const startTime = Date.now()
|
||||
const headers = getHeaders(registry, uri, opts)
|
||||
let body = opts.body
|
||||
const bodyIsStream = body &&
|
||||
typeof body === 'object' &&
|
||||
typeof body.pipe === 'function'
|
||||
if (body && !bodyIsStream && typeof body !== 'string' && !Buffer.isBuffer(body)) {
|
||||
headers['content-type'] = headers['content-type'] || 'application/json'
|
||||
body = JSON.stringify(body)
|
||||
} else if (body && !headers['content-type']) {
|
||||
headers['content-type'] = 'application/octet-stream'
|
||||
}
|
||||
if (opts.gzip) {
|
||||
headers['content-encoding'] = 'gzip'
|
||||
if (bodyIsStream) {
|
||||
const gz = zlib.createGzip()
|
||||
body.on('error', err => gz.emit('error', err))
|
||||
body = body.pipe(gz)
|
||||
} else {
|
||||
body = new opts.Promise((resolve, reject) => {
|
||||
zlib.gzip(body, (err, gz) => err ? reject(err) : resolve(gz))
|
||||
})
|
||||
}
|
||||
}
|
||||
if (opts.query) {
|
||||
let q = opts.query
|
||||
if (typeof q === 'string') {
|
||||
q = qs.parse(q)
|
||||
}
|
||||
Object.keys(q).forEach(key => {
|
||||
if (q[key] === undefined) {
|
||||
delete q[key]
|
||||
}
|
||||
})
|
||||
if (Object.keys(q).length) {
|
||||
const parsed = url.parse(uri)
|
||||
parsed.search = '?' + qs.stringify(
|
||||
parsed.query
|
||||
? Object.assign(qs.parse(parsed.query), q)
|
||||
: q
|
||||
)
|
||||
uri = url.format(parsed)
|
||||
}
|
||||
}
|
||||
return opts.Promise.resolve(body).then(body => fetch(uri, {
|
||||
agent: opts.agent,
|
||||
algorithms: opts.algorithms,
|
||||
body,
|
||||
cache: getCacheMode(opts),
|
||||
cacheManager: opts.cache,
|
||||
ca: opts.ca,
|
||||
cert: opts.cert,
|
||||
headers,
|
||||
integrity: opts.integrity,
|
||||
key: opts.key,
|
||||
localAddress: opts['local-address'],
|
||||
maxSockets: opts.maxsockets,
|
||||
memoize: opts.memoize,
|
||||
method: opts.method || 'GET',
|
||||
noProxy: opts['no-proxy'] || opts.noproxy,
|
||||
Promise: opts.Promise,
|
||||
proxy: opts['https-proxy'] || opts.proxy,
|
||||
referer: opts.refer,
|
||||
retry: opts.retry != null ? opts.retry : {
|
||||
retries: opts['fetch-retries'],
|
||||
factor: opts['fetch-retry-factor'],
|
||||
minTimeout: opts['fetch-retry-mintimeout'],
|
||||
maxTimeout: opts['fetch-retry-maxtimeout']
|
||||
},
|
||||
strictSSL: !!opts['strict-ssl'],
|
||||
timeout: opts.timeout,
|
||||
uid: opts.uid,
|
||||
gid: opts.gid
|
||||
}).then(res => checkResponse(
|
||||
opts.method || 'GET', res, registry, startTime, opts
|
||||
)))
|
||||
}
|
||||
|
||||
module.exports.json = fetchJSON
|
||||
function fetchJSON (uri, opts) {
|
||||
return regFetch(uri, opts).then(res => res.json())
|
||||
}
|
||||
|
||||
module.exports.json.stream = fetchJSONStream
|
||||
function fetchJSONStream (uri, jsonPath, opts) {
|
||||
opts = config(opts)
|
||||
const parser = JSONStream.parse(jsonPath, opts.mapJson)
|
||||
const pt = parser.pipe(new PassThrough({objectMode: true}))
|
||||
parser.on('error', err => pt.emit('error', err))
|
||||
regFetch(uri, opts).then(res => {
|
||||
res.body.on('error', err => parser.emit('error', err))
|
||||
res.body.pipe(parser)
|
||||
}, err => pt.emit('error', err))
|
||||
return pt
|
||||
}
|
||||
|
||||
module.exports.pickRegistry = pickRegistry
|
||||
function pickRegistry (spec, opts) {
|
||||
spec = npa(spec)
|
||||
opts = config(opts)
|
||||
let registry = spec.scope &&
|
||||
opts[spec.scope.replace(/^@?/, '@') + ':registry']
|
||||
|
||||
if (!registry && opts.scope) {
|
||||
registry = opts[opts.scope.replace(/^@?/, '@') + ':registry']
|
||||
}
|
||||
|
||||
if (!registry) {
|
||||
registry = opts.registry || 'https://registry.npmjs.org/'
|
||||
}
|
||||
|
||||
return registry
|
||||
}
|
||||
|
||||
function getCacheMode (opts) {
|
||||
return opts.offline
|
||||
? 'only-if-cached'
|
||||
: opts['prefer-offline']
|
||||
? 'force-cache'
|
||||
: opts['prefer-online']
|
||||
? 'no-cache'
|
||||
: 'default'
|
||||
}
|
||||
|
||||
function getHeaders (registry, uri, opts) {
|
||||
const headers = Object.assign({
|
||||
'npm-in-ci': !!(
|
||||
opts['is-from-ci'] ||
|
||||
process.env['CI'] === 'true' ||
|
||||
process.env['TDDIUM'] ||
|
||||
process.env['JENKINS_URL'] ||
|
||||
process.env['bamboo.buildKey'] ||
|
||||
process.env['GO_PIPELINE_NAME']
|
||||
),
|
||||
'npm-scope': opts['project-scope'],
|
||||
'npm-session': opts['npm-session'],
|
||||
'user-agent': opts['user-agent'],
|
||||
'referer': opts.refer
|
||||
}, opts.headers)
|
||||
|
||||
const auth = getAuth(registry, opts)
|
||||
// If a tarball is hosted on a different place than the manifest, only send
|
||||
// credentials on `alwaysAuth`
|
||||
const shouldAuth = (
|
||||
auth.alwaysAuth ||
|
||||
url.parse(uri).host === url.parse(registry).host
|
||||
)
|
||||
if (shouldAuth && auth.token) {
|
||||
headers.authorization = `Bearer ${auth.token}`
|
||||
} else if (shouldAuth && auth.username && auth.password) {
|
||||
const encoded = Buffer.from(
|
||||
`${auth.username}:${auth.password}`, 'utf8'
|
||||
).toString('base64')
|
||||
headers.authorization = `Basic ${encoded}`
|
||||
} else if (shouldAuth && auth._auth) {
|
||||
headers.authorization = `Basic ${auth._auth}`
|
||||
}
|
||||
if (shouldAuth && auth.otp) {
|
||||
headers['npm-otp'] = auth.otp
|
||||
}
|
||||
return headers
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
'use strict'
|
||||
|
||||
const noop = Function.prototype
|
||||
module.exports = {
|
||||
error: noop,
|
||||
warn: noop,
|
||||
notice: noop,
|
||||
info: noop,
|
||||
verbose: noop,
|
||||
silly: noop,
|
||||
http: noop,
|
||||
pause: noop,
|
||||
resume: noop
|
||||
}
|
||||
@ -1,39 +0,0 @@
|
||||
'use strict';
|
||||
const path = require('path');
|
||||
const pathKey = require('path-key');
|
||||
|
||||
module.exports = opts => {
|
||||
opts = Object.assign({
|
||||
cwd: process.cwd(),
|
||||
path: process.env[pathKey()]
|
||||
}, opts);
|
||||
|
||||
let prev;
|
||||
let pth = path.resolve(opts.cwd);
|
||||
const ret = [];
|
||||
|
||||
while (prev !== pth) {
|
||||
ret.push(path.join(pth, 'node_modules/.bin'));
|
||||
prev = pth;
|
||||
pth = path.resolve(pth, '..');
|
||||
}
|
||||
|
||||
// ensure the running `node` binary is used
|
||||
ret.push(path.dirname(process.execPath));
|
||||
|
||||
return ret.concat(opts.path).join(path.delimiter);
|
||||
};
|
||||
|
||||
module.exports.env = opts => {
|
||||
opts = Object.assign({
|
||||
env: process.env
|
||||
}, opts);
|
||||
|
||||
const env = Object.assign({}, opts.env);
|
||||
const path = pathKey({env});
|
||||
|
||||
opts.path = env[path];
|
||||
env[path] = module.exports(opts);
|
||||
|
||||
return env;
|
||||
};
|
||||
@ -1,21 +0,0 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
@ -1,81 +0,0 @@
|
||||
# npm-run-path [](https://travis-ci.org/sindresorhus/npm-run-path)
|
||||
|
||||
> Get your [PATH](https://en.wikipedia.org/wiki/PATH_(variable)) prepended with locally installed binaries
|
||||
|
||||
In [npm run scripts](https://docs.npmjs.com/cli/run-script) you can execute locally installed binaries by name. This enables the same outside npm.
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save npm-run-path
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const childProcess = require('child_process');
|
||||
const npmRunPath = require('npm-run-path');
|
||||
|
||||
console.log(process.env.PATH);
|
||||
//=> '/usr/local/bin'
|
||||
|
||||
console.log(npmRunPath());
|
||||
//=> '/Users/sindresorhus/dev/foo/node_modules/.bin:/Users/sindresorhus/dev/node_modules/.bin:/Users/sindresorhus/node_modules/.bin:/Users/node_modules/.bin:/node_modules/.bin:/usr/local/bin'
|
||||
|
||||
// `foo` is a locally installed binary
|
||||
childProcess.execFileSync('foo', {
|
||||
env: npmRunPath.env()
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### npmRunPath([options])
|
||||
|
||||
#### options
|
||||
|
||||
##### cwd
|
||||
|
||||
Type: `string`<br>
|
||||
Default: `process.cwd()`
|
||||
|
||||
Working directory.
|
||||
|
||||
##### path
|
||||
|
||||
Type: `string`<br>
|
||||
Default: [`PATH`](https://github.com/sindresorhus/path-key)
|
||||
|
||||
PATH to be appended.<br>
|
||||
Set it to an empty string to exclude the default PATH.
|
||||
|
||||
### npmRunPath.env([options])
|
||||
|
||||
#### options
|
||||
|
||||
##### cwd
|
||||
|
||||
Type: `string`<br>
|
||||
Default: `process.cwd()`
|
||||
|
||||
Working directory.
|
||||
|
||||
##### env
|
||||
|
||||
Type: `Object`
|
||||
|
||||
Accepts an object of environment variables, like `process.env`, and modifies the PATH using the correct [PATH key](https://github.com/sindresorhus/path-key). Use this if you're modifying the PATH for use in the `child_process` options.
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [npm-run-path-cli](https://github.com/sindresorhus/npm-run-path-cli) - CLI for this module
|
||||
- [execa](https://github.com/sindresorhus/execa) - Execute a locally installed binary
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
||||
@ -1,15 +0,0 @@
|
||||
{
|
||||
"licenses": {
|
||||
"spdx": [
|
||||
"CC-BY-3.0"
|
||||
],
|
||||
"blueOak": "bronze"
|
||||
},
|
||||
"corrections": true,
|
||||
"packages": {
|
||||
"config-chain": "1.1.12",
|
||||
"cyclist": "0.2.2",
|
||||
"json-schema": "0.2.3",
|
||||
"qrcode-terminal": "0.12.0"
|
||||
}
|
||||
}
|
||||
@ -1,77 +0,0 @@
|
||||
Alex K. Wolfe <alexkwolfe@gmail.com>
|
||||
Andrew Bradley <cspotcode@gmail.com>
|
||||
Andrew Lunny <alunny@gmail.com>
|
||||
Arlo Breault <arlolra@gmail.com>
|
||||
Ashley Williams <ashley@npmjs.com> <ashley666ashley@gmail.com>
|
||||
Ashley Williams <ashley@npmjs.com> <ashley@bocoup.com>
|
||||
Benjamin Coe <bencoe@gmail.com>
|
||||
Benjamin Coe <bencoe@gmail.com> <ben@npmjs.com>
|
||||
Brian White <mscdex@mscdex.net> <mscdex@gmail.com>
|
||||
Cedric Nelson <cedric.nelson@gmail.com>
|
||||
Charlie Robbins <charlie.robbins@gmail.com>
|
||||
Claudia Hernández <cghr1990@gmail.com>
|
||||
Dalmais Maxence <root@ip-10-195-202-5.ec2.internal>
|
||||
Danila Gerasimov <danila.gerasimov@gmail.com>
|
||||
Dave Galbraith <dave@jut.io>
|
||||
David Beitey <david@davidjb.com>
|
||||
David Rousselie <guido.dassori@gmail.com>
|
||||
Domenic Denicola <domenic@domenicdenicola.com>
|
||||
Einar Otto Stangvik <einaros@gmail.com>
|
||||
Emma Ramirez <ramirez.emma.g@gmail.com>
|
||||
Erik Wienhold <git@ewie.name>
|
||||
Evan Lucas <evan@btc.com> <evan.lucas@hattiesburgclinic.com>
|
||||
Evan Lucas <evan@btc.com> <evanlucas@me.com>
|
||||
Faiq Raza <faiqrazarizvi@gmail.com>
|
||||
Forbes Lindesay <forbes@lindesay.co.uk>
|
||||
Forrest L Norvell <ogd@aoaioxxysz.net> <forrest@npmjs.com>
|
||||
Forrest L Norvell <ogd@aoaioxxysz.net> <othiym23@gmail.com>
|
||||
Gabriel Barros <descartavel1@gmail.com>
|
||||
Geoff Flarity <geoff.flarity@gmail.com> <gflarity@raptvm-x02.(none)>
|
||||
Gregers Gram Rygg <gregers.gram.rygg@finn.no>
|
||||
Ifeanyi Oraelosi <ifeanyioraelosi@gmail.com>
|
||||
isaacs <i@izs.me> <i@foohack.com>
|
||||
isaacs <i@izs.me> <nope@not.real>
|
||||
isaacs <i@izs.me> <isaacs@npmjs.com>
|
||||
Jake Verbaten <raynos2@gmail.com>
|
||||
James Sanders <jimmyjazz14@gmail.com>
|
||||
James Treworgy <jamietre@gmail.com>
|
||||
Jason Smith <jhs@iriscouch.com>
|
||||
Jed Fox <git@twopointzero.us>
|
||||
Jonas Weber <github@jonasw.de>
|
||||
Joshua Bennett <legodudejb@gmail.com>
|
||||
Joshua Bennett <legodudejb@gmail.com> <legodude17@users.noreply.github.com>
|
||||
Julien Meddah <julien.meddah@deveryware.com>
|
||||
Kat Marchán <kzm@zkat.tech> <kzm@sykosomatic.org>
|
||||
Kevin Lorenz <mail@kevinlorenz.com>
|
||||
Kris Windham <kriswindham@gmail.com>
|
||||
Leonardo Rojas <leonardo.rojas@shopify.com>
|
||||
Lin Clark <lin.w.clark@gmail.com>
|
||||
Luke Arduini <luke.arduini@gmail.com> <luke.arduini@me.com>
|
||||
Maciej Małecki <me@mmalecki.com> <maciej.malecki@notimplemented.org>
|
||||
Martin Ek <mail@ekmartin.com>
|
||||
Max Goodman <c@chromakode.com>
|
||||
Maxim Bogushevich <boga1@mail.ru>
|
||||
Maximilian Antoni <mail@maxantoni.de> <maximilian.antoni@juliusbaer.com>
|
||||
Michael Hayes <michael@hayes.io> <mhayes@newrelic.com>
|
||||
Misha Kaletsky <misha.kaletsky@gmail.com>
|
||||
Nicolas Morel <marsup@gmail.com>
|
||||
Olivier Melcher <olivier.melcher@gmail.com>
|
||||
Ra'Shaun Stovall <rashaunstovall@gmail.com>
|
||||
Rebecca Turner <me@re-becca.org> <rebecca@npmjs.com>
|
||||
Rebecca Turner <me@re-becca.org> <turner@mikomi.org>
|
||||
Ryan Emery <seebees@gmail.com>
|
||||
Sam Mikes <smikes@cubane.com>
|
||||
Sreenivas Alapati <sreenivas9alapati@gmail.com>
|
||||
Stephanie Snopek <stephaniesnopek@gmail.com>
|
||||
Takaya Kobayashi <jigsaw@live.jp>
|
||||
Ted Yavuzkurt <hello@TedY.io> <davidteoman@gmail.com>
|
||||
Thomas Reggi <thomas@reggi.com>
|
||||
Timo Weiß <timoweiss@Timo-MBP.local>
|
||||
Tony <zearin@gonk.net>
|
||||
Trent Mick <trentm@gmail.com> <trent.mick@joyent.com>
|
||||
Visnu Pitiyanuvath <visnupx@gmail.com>
|
||||
Will Elwood <w.elwood08@gmail.com>
|
||||
Wout Mertens <Wout.Mertens@gmail.com>
|
||||
Yeonghoon Park <sola92@gmail.com>
|
||||
Zeke Sikelianos <zeke@sikelianos.com>
|
||||
Zoujie Wzj <zoujie.wzj@alibaba-inc.com>
|
||||
@ -1,28 +0,0 @@
|
||||
*.swp
|
||||
.*.swp
|
||||
netlify.toml
|
||||
npm-debug.log
|
||||
/.github
|
||||
/test
|
||||
node_modules/marked
|
||||
node_modules/marked-man
|
||||
node_modules/tap
|
||||
tap-snapshots
|
||||
node_modules/.bin
|
||||
node_modules/npm-registry-mock
|
||||
/npmrc
|
||||
/release/
|
||||
|
||||
# don't need these in the npm package.
|
||||
html/*.png
|
||||
|
||||
# don't ignore .npmignore files
|
||||
# these are used in some tests.
|
||||
!.npmignore
|
||||
|
||||
/npm-*.tgz
|
||||
|
||||
*.pyc
|
||||
|
||||
|
||||
.nyc_output
|
||||
@ -1,22 +0,0 @@
|
||||
# need to declare the language as well as the matrix below
|
||||
language: node_js
|
||||
|
||||
os:
|
||||
- windows
|
||||
|
||||
node_js:
|
||||
- 12
|
||||
- 10
|
||||
- 8
|
||||
- 6
|
||||
|
||||
env: "DEPLOY_VERSION=testing"
|
||||
|
||||
notifications:
|
||||
slack: npm-inc:kRqQjto7YbINqHPb1X6nS3g8
|
||||
|
||||
install:
|
||||
- "node . install"
|
||||
|
||||
script:
|
||||
- "node . run tap -- \"test/tap/*.js\" -t600 -Rclassic -c"
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,192 +0,0 @@
|
||||
# npm CLI Contributor Roles and Responsibilities
|
||||
|
||||
## Table of Contents
|
||||
|
||||
* [Introduction](#introduction)
|
||||
* [Code Structure](#code-structure)
|
||||
* [Running Tests](#running-tests)
|
||||
* [Debugging](#debugging)
|
||||
* [Coverage](#coverage)
|
||||
* [Benchmarking](#benchmarking)
|
||||
* [Types of Contributions](#types-of-contributions)
|
||||
* [Contributing an Issue?](#contributing-an-issue)
|
||||
* [Contributing a Question?](#contributing-a-question)
|
||||
* [Contributing a Bug Fix?](#contributing-a-bug-fix)
|
||||
* [Contributing a Feature?](#contributing-a-bug-feature)
|
||||
* [Development Dependencies](#development-dependencies)
|
||||
* [Dependencies](#dependencies)
|
||||
|
||||
## Introduction
|
||||
|
||||
Welcome to the npm CLI Contributor Guide! This document outlines the npm CLI repository's process for community interaction and contribution. This includes the issue tracker, pull requests, wiki pages, and, to a certain extent, outside communication in the context of the npm CLI. This is an entry point for anyone wishing to contribute their time and effort to making npm a better tool for the JavaScript community!
|
||||
|
||||
All interactions in the npm repository are covered by the [npm Code of Conduct](https://www.npmjs.com/policies/conduct)
|
||||
|
||||
|
||||
## Code Structure
|
||||
```
|
||||
/
|
||||
├── bin/
|
||||
│ │ # Directory for executable files. It's very rare that you
|
||||
│ │ # will need to update a file in this directory.
|
||||
│ │
|
||||
│ ├── npm # npm-cli entrypoint for bourne shell
|
||||
│ ├── npm-cli.js # npm-cli entrypoint for node
|
||||
│ ├── npm.cmd # npm-cli entrypoint for windows
|
||||
│ ├── npx # npx entrypoint for bourne shell
|
||||
│ ├── npx-cli.js # npx entrypoint for node
|
||||
│ └── npx.cmd # npx entrypoint for windows
|
||||
│
|
||||
├── docs/ 📖
|
||||
│ │ # Directory that contains the documentation website for
|
||||
│ │ # the npm-cli. You can run this website locally, and have
|
||||
│ │ # offline docs! 🔥📖🤓
|
||||
│ │
|
||||
│ ├── content/ # Markdown files for site content
|
||||
│ ├── src/ # Source files for the website; gatsby related
|
||||
│ └── package.json # Site manifest; scripts and dependencies
|
||||
│
|
||||
├── lib/ 📦
|
||||
│ # All the Good Bits(tm) of the CLI project live here
|
||||
│
|
||||
├── node_modules/ 🔋
|
||||
│ # Vendored dependencies for the CLI project (See the
|
||||
│ # dependencies section below for more details).
|
||||
│
|
||||
├── scripts/ 📜
|
||||
│ # We've created some helper scripts for working with the
|
||||
│ # CLI project, specifically around managing our vendored
|
||||
│ # dependencies, merging in pull-requests, and publishing
|
||||
│ # releases.
|
||||
│
|
||||
├── test/ 🧪
|
||||
│ # All the tests for the CLI live in this folder. We've
|
||||
│ # got a lot of tests 🤓🧪🩺
|
||||
│
|
||||
├── CONTRIBUTING.md # This file! 🎉
|
||||
└── package.json # The projects main manifest file 📃
|
||||
```
|
||||
|
||||
## Running Tests
|
||||
|
||||
```
|
||||
# Make sure you install the dependencies first before running tests.
|
||||
$ npm install
|
||||
|
||||
# Run tests for the CLI (it could take awhile).
|
||||
$ npm run test
|
||||
```
|
||||
|
||||
## Debugging
|
||||
|
||||
It can be tricky to track down issues in the CLI. It's a large code base that has been evolving for over a decade. There is a handy `make` command that will connect the **cloned repository** you have on your machine with the global command, so you can add `console.log` statements or debug any other way you feel most comfortable with.
|
||||
|
||||
```
|
||||
# Clone the repository to start with
|
||||
$ git clone git@github.com:npm/cli.git
|
||||
|
||||
# Change working directories into the repository
|
||||
$ cd cli
|
||||
|
||||
# Make sure you have the latest code (if that's what you're trying to debug)
|
||||
$ git fetch origin latest
|
||||
|
||||
# Connect repository to the global namespace
|
||||
$ make link
|
||||
|
||||
#################
|
||||
# ALTERNATIVELY
|
||||
#################
|
||||
# If ou're working on a feature or bug, you can run the same command on your
|
||||
# working branch and link that code.
|
||||
|
||||
# Create new branch to work from (there are many ways)
|
||||
$ git checkout -b feature/awesome-feature
|
||||
|
||||
# Connect repository to global namespace
|
||||
$ make link
|
||||
```
|
||||
|
||||
## Coverage
|
||||
|
||||
We try and make sure that each new feature or bug fix has tests to go along with them in order to keep code coverages consistent and increasing. We are actively striving for 100% code coverage!
|
||||
|
||||
```
|
||||
# You can run the following command to find out coverage
|
||||
$ npm run test-coverage
|
||||
```
|
||||
|
||||
## Benchmarking
|
||||
|
||||
We often want to know if the bug we've fixed for the feature we've added has any sort of performance impact. We've created a [benchmark suite](https://github.com/npm/benchmarks) to run against the CLI project from pull-requests. If you would like to know if there are any performance impacts to the work you're contributing, simply do the following:
|
||||
|
||||
1. Make a pull-request against this repository
|
||||
2. Add the following comment to the pull-request: "`test this please ✅`"
|
||||
|
||||
This will trigger the [benmark suite](https://github.com/npm/benchmarks) to run against your pull-request, and when it's finished running it will post a comment on your pull-request just like bellow. You'll be able to see the results from the suite inline in your pull-request.
|
||||
|
||||
> You'll notice that the bot-user will also add a 🚀 reaction to your comment to
|
||||
let you know that it's sent the request to start the benchmark suite.
|
||||
|
||||

|
||||
|
||||
If you've updated your pull-reuqest and you'd like to run the the benchmark suite again, simple update your original comment, by adding `test this please ✅` again, or simply just adding another emoji to the **end**. _(The trigger is the phrase "test this please ✅" at the beginning of a comment. Updates will trigger as well, so long as the phrase stays at the beginning.)_.
|
||||
|
||||

|
||||
|
||||
## Types of Contributions
|
||||
|
||||
### Contributing an Issue?
|
||||
|
||||
Great!! Is your [new issue](https://github.com/npm/cli/issues/new/choose) a [bug](https://github.com/npm/cli/issues/new?template=bug.md&title=%5BBUG%5D+%3Ctitle%3E), a [feature](https://github.com/npm/cli/issues/new?template=feature.md&title=%5BFEATURE%5D+%3Ctitle%3E), or a [question](https://github.com/npm/cli/issues/new?template=question.md&title=%5BQUESTION%5D+%3Ctitle%3E)?
|
||||
|
||||
### Contributing a Question?
|
||||
|
||||
Huh? 🤔 Got a situation you're not sure about?! Perfect! We've got some resources you can use.
|
||||
|
||||
* Our [documentation site](https://docs.npmjs.com/)
|
||||
* The local docs that come with the CLI project
|
||||
|
||||
> **Example**: `npm help install --viewer browser`
|
||||
|
||||
* The man pages that are built and shipped with the CLI
|
||||
|
||||
> **Example**: `man npm-install` (only on linux/macOS)
|
||||
|
||||
* Search of the [current issues](https://github.com/npm/cli/issues)
|
||||
|
||||
### Contributing a Bug Fix?
|
||||
|
||||
We'd be happy to triage and help! Head over to the issues and [create a new one](https://github.com/npm/cli/issues/new?template=bug.md&title=%5BBUG%5D+%3Ctitle%3E)!
|
||||
|
||||
> We'll need a little bit of information about what happened, rather than "it broke". Such as:
|
||||
* When did/does this bug happen?
|
||||
* Can you reproduce it? _(Can you make it happen more than once.)_
|
||||
* What version of `node`/`npm` are you running on your computer?
|
||||
* What did you expect it to do?
|
||||
* What did it _actually do?
|
||||
* etc...
|
||||
|
||||
### Contributing a Feature?
|
||||
|
||||
Snazzy, we're always up for fancy new things! If the feature is fairly minor, the team can triage it and prioritize it into our backlog. However, if the feature is a little more complex, then it's best to create an [RFC](https://en.wikipedia.org/wiki/Request_for_Comments) in our [RFC repository](https://github.com/npm/rfcs). Exactly how to do that is outlined in that repository. If you're not sure _exactly_ how to implement your idea, or don't want to make a document about your idea, then please create an issue on that repository. We consider these RRFC's, or a "Requesting Request For Comment".
|
||||
|
||||
## Development Dependencies
|
||||
|
||||
You'll need a few things installed in order to update and test the CLI project during development:
|
||||
|
||||
* [node](https://nodejs.org/) v8 or greater
|
||||
|
||||
> We recommend that you have a [node version manager](https://github.com/nvm-sh/nvm) installed if you plan on fixing bugs that might be present in a specific version of node. With a version manager you can easily switch versions of node and test if your changes to the CLI project are working.
|
||||
|
||||
* [git](https://git-scm.com/) v2.11+
|
||||
|
||||
|
||||
## Dependencies
|
||||
|
||||
> Package vendoring is commonly referred to as the case where dependent packages are stored in the same place as your project. That usually means you dependencies are checked into your source management system, such as Git.
|
||||
|
||||
The CLI project vendors it's dependencies in the `node_modules/` folder. Meaning all the dependencies that the CLI project uses are contained withing the project itself. This is represented by the `bundledDependencies` section in the root level `package.json` file. The main reason for this is because the `npm` CLI project is distributed with the NodeJS runtime and needs to work out of the box, which means all dependencies need to be available after the runtime is installed.
|
||||
|
||||
There are a couple scripts created to help manage this process in the `scripts/` folder.
|
||||
|
||||
@ -1,235 +0,0 @@
|
||||
The npm application
|
||||
Copyright (c) npm, Inc. and Contributors
|
||||
Licensed on the terms of The Artistic License 2.0
|
||||
|
||||
Node package dependencies of the npm application
|
||||
Copyright (c) their respective copyright owners
|
||||
Licensed on their respective license terms
|
||||
|
||||
The npm public registry at https://registry.npmjs.org
|
||||
and the npm website at https://www.npmjs.com
|
||||
Operated by npm, Inc.
|
||||
Use governed by terms published on https://www.npmjs.com
|
||||
|
||||
"Node.js"
|
||||
Trademark Joyent, Inc., https://joyent.com
|
||||
Neither npm nor npm, Inc. are affiliated with Joyent, Inc.
|
||||
|
||||
The Node.js application
|
||||
Project of Node Foundation, https://nodejs.org
|
||||
|
||||
The npm Logo
|
||||
Copyright (c) Mathias Pettersson and Brian Hammond
|
||||
|
||||
"Gubblebum Blocky" typeface
|
||||
Copyright (c) Tjarda Koster, https://jelloween.deviantart.com
|
||||
Used with permission
|
||||
|
||||
|
||||
--------
|
||||
|
||||
|
||||
The Artistic License 2.0
|
||||
|
||||
Copyright (c) 2000-2006, The Perl Foundation.
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
This license establishes the terms under which a given free software
|
||||
Package may be copied, modified, distributed, and/or redistributed.
|
||||
The intent is that the Copyright Holder maintains some artistic
|
||||
control over the development of that Package while still keeping the
|
||||
Package available as open source and free software.
|
||||
|
||||
You are always permitted to make arrangements wholly outside of this
|
||||
license directly with the Copyright Holder of a given Package. If the
|
||||
terms of this license do not permit the full use that you propose to
|
||||
make of the Package, you should contact the Copyright Holder and seek
|
||||
a different licensing arrangement.
|
||||
|
||||
Definitions
|
||||
|
||||
"Copyright Holder" means the individual(s) or organization(s)
|
||||
named in the copyright notice for the entire Package.
|
||||
|
||||
"Contributor" means any party that has contributed code or other
|
||||
material to the Package, in accordance with the Copyright Holder's
|
||||
procedures.
|
||||
|
||||
"You" and "your" means any person who would like to copy,
|
||||
distribute, or modify the Package.
|
||||
|
||||
"Package" means the collection of files distributed by the
|
||||
Copyright Holder, and derivatives of that collection and/or of
|
||||
those files. A given Package may consist of either the Standard
|
||||
Version, or a Modified Version.
|
||||
|
||||
"Distribute" means providing a copy of the Package or making it
|
||||
accessible to anyone else, or in the case of a company or
|
||||
organization, to others outside of your company or organization.
|
||||
|
||||
"Distributor Fee" means any fee that you charge for Distributing
|
||||
this Package or providing support for this Package to another
|
||||
party. It does not mean licensing fees.
|
||||
|
||||
"Standard Version" refers to the Package if it has not been
|
||||
modified, or has been modified only in ways explicitly requested
|
||||
by the Copyright Holder.
|
||||
|
||||
"Modified Version" means the Package, if it has been changed, and
|
||||
such changes were not explicitly requested by the Copyright
|
||||
Holder.
|
||||
|
||||
"Original License" means this Artistic License as Distributed with
|
||||
the Standard Version of the Package, in its current version or as
|
||||
it may be modified by The Perl Foundation in the future.
|
||||
|
||||
"Source" form means the source code, documentation source, and
|
||||
configuration files for the Package.
|
||||
|
||||
"Compiled" form means the compiled bytecode, object code, binary,
|
||||
or any other form resulting from mechanical transformation or
|
||||
translation of the Source form.
|
||||
|
||||
|
||||
Permission for Use and Modification Without Distribution
|
||||
|
||||
(1) You are permitted to use the Standard Version and create and use
|
||||
Modified Versions for any purpose without restriction, provided that
|
||||
you do not Distribute the Modified Version.
|
||||
|
||||
|
||||
Permissions for Redistribution of the Standard Version
|
||||
|
||||
(2) You may Distribute verbatim copies of the Source form of the
|
||||
Standard Version of this Package in any medium without restriction,
|
||||
either gratis or for a Distributor Fee, provided that you duplicate
|
||||
all of the original copyright notices and associated disclaimers. At
|
||||
your discretion, such verbatim copies may or may not include a
|
||||
Compiled form of the Package.
|
||||
|
||||
(3) You may apply any bug fixes, portability changes, and other
|
||||
modifications made available from the Copyright Holder. The resulting
|
||||
Package will still be considered the Standard Version, and as such
|
||||
will be subject to the Original License.
|
||||
|
||||
|
||||
Distribution of Modified Versions of the Package as Source
|
||||
|
||||
(4) You may Distribute your Modified Version as Source (either gratis
|
||||
or for a Distributor Fee, and with or without a Compiled form of the
|
||||
Modified Version) provided that you clearly document how it differs
|
||||
from the Standard Version, including, but not limited to, documenting
|
||||
any non-standard features, executables, or modules, and provided that
|
||||
you do at least ONE of the following:
|
||||
|
||||
(a) make the Modified Version available to the Copyright Holder
|
||||
of the Standard Version, under the Original License, so that the
|
||||
Copyright Holder may include your modifications in the Standard
|
||||
Version.
|
||||
|
||||
(b) ensure that installation of your Modified Version does not
|
||||
prevent the user installing or running the Standard Version. In
|
||||
addition, the Modified Version must bear a name that is different
|
||||
from the name of the Standard Version.
|
||||
|
||||
(c) allow anyone who receives a copy of the Modified Version to
|
||||
make the Source form of the Modified Version available to others
|
||||
under
|
||||
|
||||
(i) the Original License or
|
||||
|
||||
(ii) a license that permits the licensee to freely copy,
|
||||
modify and redistribute the Modified Version using the same
|
||||
licensing terms that apply to the copy that the licensee
|
||||
received, and requires that the Source form of the Modified
|
||||
Version, and of any works derived from it, be made freely
|
||||
available in that license fees are prohibited but Distributor
|
||||
Fees are allowed.
|
||||
|
||||
|
||||
Distribution of Compiled Forms of the Standard Version
|
||||
or Modified Versions without the Source
|
||||
|
||||
(5) You may Distribute Compiled forms of the Standard Version without
|
||||
the Source, provided that you include complete instructions on how to
|
||||
get the Source of the Standard Version. Such instructions must be
|
||||
valid at the time of your distribution. If these instructions, at any
|
||||
time while you are carrying out such distribution, become invalid, you
|
||||
must provide new instructions on demand or cease further distribution.
|
||||
If you provide valid instructions or cease distribution within thirty
|
||||
days after you become aware that the instructions are invalid, then
|
||||
you do not forfeit any of your rights under this license.
|
||||
|
||||
(6) You may Distribute a Modified Version in Compiled form without
|
||||
the Source, provided that you comply with Section 4 with respect to
|
||||
the Source of the Modified Version.
|
||||
|
||||
|
||||
Aggregating or Linking the Package
|
||||
|
||||
(7) You may aggregate the Package (either the Standard Version or
|
||||
Modified Version) with other packages and Distribute the resulting
|
||||
aggregation provided that you do not charge a licensing fee for the
|
||||
Package. Distributor Fees are permitted, and licensing fees for other
|
||||
components in the aggregation are permitted. The terms of this license
|
||||
apply to the use and Distribution of the Standard or Modified Versions
|
||||
as included in the aggregation.
|
||||
|
||||
(8) You are permitted to link Modified and Standard Versions with
|
||||
other works, to embed the Package in a larger work of your own, or to
|
||||
build stand-alone binary or bytecode versions of applications that
|
||||
include the Package, and Distribute the result without restriction,
|
||||
provided the result does not expose a direct interface to the Package.
|
||||
|
||||
|
||||
Items That are Not Considered Part of a Modified Version
|
||||
|
||||
(9) Works (including, but not limited to, modules and scripts) that
|
||||
merely extend or make use of the Package, do not, by themselves, cause
|
||||
the Package to be a Modified Version. In addition, such works are not
|
||||
considered parts of the Package itself, and are not subject to the
|
||||
terms of this license.
|
||||
|
||||
|
||||
General Provisions
|
||||
|
||||
(10) Any use, modification, and distribution of the Standard or
|
||||
Modified Versions is governed by this Artistic License. By using,
|
||||
modifying or distributing the Package, you accept this license. Do not
|
||||
use, modify, or distribute the Package, if you do not accept this
|
||||
license.
|
||||
|
||||
(11) If your Modified Version has been derived from a Modified
|
||||
Version made by someone other than you, you are nevertheless required
|
||||
to ensure that your Modified Version complies with the requirements of
|
||||
this license.
|
||||
|
||||
(12) This license does not grant you the right to use any trademark,
|
||||
service mark, tradename, or logo of the Copyright Holder.
|
||||
|
||||
(13) This license includes the non-exclusive, worldwide,
|
||||
free-of-charge patent license to make, have made, use, offer to sell,
|
||||
sell, import and otherwise transfer the Package with respect to any
|
||||
patent claims licensable by the Copyright Holder that are necessarily
|
||||
infringed by the Package. If you institute patent litigation
|
||||
(including a cross-claim or counterclaim) against any party alleging
|
||||
that the Package constitutes direct or contributory patent
|
||||
infringement, then this Artistic License to you shall terminate on the
|
||||
date that such litigation is filed.
|
||||
|
||||
(14) Disclaimer of Warranty:
|
||||
THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS
|
||||
IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL
|
||||
LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL
|
||||
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
--------
|
||||
@ -1,139 +0,0 @@
|
||||
# vim: set softtabstop=2 shiftwidth=2:
|
||||
SHELL = bash
|
||||
|
||||
PUBLISHTAG = $(shell node scripts/publish-tag.js)
|
||||
BRANCH = $(shell git rev-parse --abbrev-ref HEAD)
|
||||
|
||||
markdowns = $(shell find docs -name '*.md' | grep -v 'index') README.md
|
||||
|
||||
cli_mandocs = $(shell find docs/content/cli-commands -name '*.md' \
|
||||
|sed 's|.md|.1|g' \
|
||||
|sed 's|docs/content/cli-commands/|man/man1/|g' ) \
|
||||
man/man1/npm-README.1 \
|
||||
man/man1/npx.1
|
||||
|
||||
files_mandocs = $(shell find docs/content/configuring-npm -name '*.md' \
|
||||
|sed 's|.md|.5|g' \
|
||||
|sed 's|docs/content/configuring-npm/|man/man5/|g' ) \
|
||||
|
||||
misc_mandocs = $(shell find docs/content/using-npm -name '*.md' \
|
||||
|sed 's|.md|.7|g' \
|
||||
|sed 's|docs/content/using-npm/|man/man7/|g' ) \
|
||||
|
||||
mandocs = $(cli_mandocs) $(files_mandocs) $(misc_mandocs)
|
||||
|
||||
all: docs
|
||||
|
||||
latest:
|
||||
@echo "Installing latest published npm"
|
||||
@echo "Use 'make install' or 'make link' to install the code"
|
||||
@echo "in this folder that you're looking at right now."
|
||||
node bin/npm-cli.js install -g -f npm ${NPMOPTS}
|
||||
|
||||
install: all
|
||||
node bin/npm-cli.js install -g -f ${NPMOPTS} $(shell node bin/npm-cli.js pack | tail -1)
|
||||
|
||||
# backwards compat
|
||||
dev: install
|
||||
|
||||
link: uninstall
|
||||
node bin/npm-cli.js link -f
|
||||
|
||||
clean: markedclean marked-manclean docs-clean
|
||||
rm -rf npmrc
|
||||
node bin/npm-cli.js cache clean --force
|
||||
|
||||
uninstall:
|
||||
node bin/npm-cli.js rm npm -g -f
|
||||
|
||||
mandocs: $(mandocs)
|
||||
|
||||
htmldocs:
|
||||
cd docs && node ../bin/npm-cli.js install && \
|
||||
node ../bin/npm-cli.js run build:static echo>&2 && \
|
||||
rm -rf node_modules .cache public/*js public/*json public/404* public/page-data public/manifest*
|
||||
|
||||
docs: mandocs htmldocs
|
||||
|
||||
markedclean:
|
||||
rm -rf node_modules/marked node_modules/.bin/marked .building_marked
|
||||
|
||||
marked-manclean:
|
||||
rm -rf node_modules/marked-man node_modules/.bin/marked-man .building_marked-man
|
||||
|
||||
docsclean: docs-clean
|
||||
docs-clean:
|
||||
rm -rf \
|
||||
.building_marked \
|
||||
.building_marked-man \
|
||||
man \
|
||||
docs/node_modules \
|
||||
docs/public \
|
||||
docs/.cache
|
||||
|
||||
## build-time tools for the documentation
|
||||
build-doc-tools := node_modules/.bin/marked \
|
||||
node_modules/.bin/marked-man
|
||||
|
||||
# use `npm install marked-man` for this to work.
|
||||
man/man1/npm-README.1: README.md scripts/docs-build.js package.json $(build-doc-tools)
|
||||
@[ -d man/man1 ] || mkdir -p man/man1
|
||||
node scripts/docs-build.js $< $@
|
||||
|
||||
man/man1/%.1: docs/content/cli-commands/%.md scripts/docs-build.js package.json $(build-doc-tools)
|
||||
@[ -d man/man1 ] || mkdir -p man/man1
|
||||
node scripts/docs-build.js $< $@
|
||||
|
||||
man/man1/npx.1: node_modules/libnpx/libnpx.1
|
||||
cat $< | sed s/libnpx/npx/ > $@
|
||||
|
||||
man/man5/npm-json.5: man/man5/package.json.5
|
||||
cp $< $@
|
||||
|
||||
man/man5/npm-global.5: man/man5/folders.5
|
||||
cp $< $@
|
||||
|
||||
man/man5/%.5: docs/content/configuring-npm/%.md scripts/docs-build.js package.json $(build-doc-tools)
|
||||
@[ -d man/man5 ] || mkdir -p man/man5
|
||||
node scripts/docs-build.js $< $@
|
||||
|
||||
man/man7/%.7: docs/content/using-npm/%.md scripts/docs-build.js package.json $(build-doc-tools)
|
||||
@[ -d man/man7 ] || mkdir -p man/man7
|
||||
node scripts/docs-build.js $< $@
|
||||
|
||||
marked: node_modules/.bin/marked
|
||||
|
||||
node_modules/.bin/marked:
|
||||
node bin/npm-cli.js install marked --no-global --no-timing --no-save
|
||||
|
||||
marked-man: node_modules/.bin/marked-man
|
||||
|
||||
node_modules/.bin/marked-man:
|
||||
node bin/npm-cli.js install marked-man --no-global --no-timing --no-save
|
||||
|
||||
test: docs
|
||||
node bin/npm-cli.js test
|
||||
|
||||
tag:
|
||||
node bin/npm-cli.js tag npm@$(PUBLISHTAG) latest
|
||||
|
||||
ls-ok:
|
||||
node . ls >/dev/null
|
||||
|
||||
gitclean:
|
||||
git clean -fd
|
||||
|
||||
publish: gitclean ls-ok link docs-clean docs
|
||||
@git push origin :v$(shell node bin/npm-cli.js --no-timing -v) 2>&1 || true
|
||||
git push origin $(BRANCH) &&\
|
||||
git push origin --tags &&\
|
||||
node bin/npm-cli.js publish --tag=$(PUBLISHTAG)
|
||||
|
||||
release: gitclean ls-ok markedclean marked-manclean docs-clean docs
|
||||
node bin/npm-cli.js prune --production --no-save
|
||||
@bash scripts/release.sh
|
||||
|
||||
sandwich:
|
||||
@[ $$(whoami) = "root" ] && (echo "ok"; echo "ham" > sandwich) || (echo "make it yourself" && exit 13)
|
||||
|
||||
.PHONY: all latest install dev link docs clean uninstall test man docs-clean docclean release ls-ok realclean
|
||||
@ -1,161 +0,0 @@
|
||||
npm(1) -- a JavaScript package manager
|
||||
==============================
|
||||
|
||||
[](https://travis-ci.org/npm/cli)
|
||||
|
||||
## SYNOPSIS
|
||||
|
||||
This is just enough info to get you up and running.
|
||||
|
||||
Much more info will be available via `npm help` once it's installed.
|
||||
|
||||
## IMPORTANT
|
||||
|
||||
**You need node v6 or higher to run this program.**
|
||||
|
||||
To install an old **and unsupported** version of npm that works on node v5
|
||||
and prior, clone the git repo and dig through the old tags and branches.
|
||||
|
||||
**npm is configured to use npm, Inc.'s public registry at
|
||||
<https://registry.npmjs.org> by default.** Use of the npm public registry
|
||||
is subject to terms of use available at <https://www.npmjs.com/policies/terms>.
|
||||
|
||||
You can configure npm to use any compatible registry you
|
||||
like, and even run your own registry. Check out the [doc on
|
||||
registries](https://docs.npmjs.com/misc/registry).
|
||||
|
||||
## Super Easy Install
|
||||
|
||||
npm is bundled with [node](https://nodejs.org/en/download/).
|
||||
|
||||
### Windows Computers
|
||||
|
||||
[Get the MSI](https://nodejs.org/en/download/). npm is in it.
|
||||
|
||||
### Apple Macintosh Computers
|
||||
|
||||
[Get the pkg](https://nodejs.org/en/download/). npm is in it.
|
||||
|
||||
### Other Sorts of Unices
|
||||
|
||||
Run `make install`. npm will be installed with node.
|
||||
|
||||
If you want a more fancy pants install (a different version, customized
|
||||
paths, etc.) then read on.
|
||||
|
||||
## Fancy Install (Unix)
|
||||
|
||||
There's a pretty robust install script at
|
||||
<https://www.npmjs.com/install.sh>. You can download that and run it.
|
||||
|
||||
Here's an example using curl:
|
||||
|
||||
```sh
|
||||
curl -L https://www.npmjs.com/install.sh | sh
|
||||
```
|
||||
|
||||
### Slightly Fancier
|
||||
|
||||
You can set any npm configuration params with that script:
|
||||
|
||||
```sh
|
||||
npm_config_prefix=/some/path sh install.sh
|
||||
```
|
||||
|
||||
Or, you can run it in uber-debuggery mode:
|
||||
|
||||
```sh
|
||||
npm_debug=1 sh install.sh
|
||||
```
|
||||
|
||||
### Even Fancier
|
||||
|
||||
Get the code with git. Use `make` to build the docs and do other stuff.
|
||||
If you plan on hacking on npm, `make link` is your friend.
|
||||
|
||||
If you've got the npm source code, you can also semi-permanently set
|
||||
arbitrary config keys using the `./configure --key=val ...`, and then
|
||||
run npm commands by doing `node bin/npm-cli.js <command> <args>`. (This is helpful
|
||||
for testing, or running stuff without actually installing npm itself.)
|
||||
|
||||
## Windows Install or Upgrade
|
||||
|
||||
Many improvements for Windows users have been made in npm 3 - you will have a better
|
||||
experience if you run a recent version of npm. To upgrade, either use [Microsoft's
|
||||
upgrade tool](https://github.com/felixrieseberg/npm-windows-upgrade),
|
||||
[download a new version of Node](https://nodejs.org/en/download/),
|
||||
or follow the Windows upgrade instructions in the
|
||||
[Installing/upgrading npm](https://npm.community/t/installing-upgrading-npm/251/2) post.
|
||||
|
||||
If that's not fancy enough for you, then you can fetch the code with
|
||||
git, and mess with it directly.
|
||||
|
||||
## Installing on Cygwin
|
||||
|
||||
No.
|
||||
|
||||
## Uninstalling
|
||||
|
||||
So sad to see you go.
|
||||
|
||||
```sh
|
||||
sudo npm uninstall npm -g
|
||||
```
|
||||
Or, if that fails,
|
||||
|
||||
```sh
|
||||
sudo make uninstall
|
||||
```
|
||||
|
||||
## More Severe Uninstalling
|
||||
|
||||
Usually, the above instructions are sufficient. That will remove
|
||||
npm, but leave behind anything you've installed.
|
||||
|
||||
If you would like to remove all the packages that you have installed,
|
||||
then you can use the `npm ls` command to find them, and then `npm rm` to
|
||||
remove them.
|
||||
|
||||
To remove cruft left behind by npm 0.x, you can use the included
|
||||
`clean-old.sh` script file. You can run it conveniently like this:
|
||||
|
||||
```sh
|
||||
npm explore npm -g -- sh scripts/clean-old.sh
|
||||
```
|
||||
|
||||
npm uses two configuration files, one for per-user configs, and another
|
||||
for global (every-user) configs. You can view them by doing:
|
||||
|
||||
```sh
|
||||
npm config get userconfig # defaults to ~/.npmrc
|
||||
npm config get globalconfig # defaults to /usr/local/etc/npmrc
|
||||
```
|
||||
|
||||
Uninstalling npm does not remove configuration files by default. You
|
||||
must remove them yourself manually if you want them gone. Note that
|
||||
this means that future npm installs will not remember the settings that
|
||||
you have chosen.
|
||||
|
||||
## More Docs
|
||||
|
||||
Check out the [docs](https://docs.npmjs.com/).
|
||||
|
||||
You can use the `npm help` command to read any of them.
|
||||
|
||||
If you're a developer, and you want to use npm to publish your program,
|
||||
you should [read this](https://docs.npmjs.com/misc/developers).
|
||||
|
||||
## BUGS
|
||||
|
||||
When you find issues, please report them:
|
||||
|
||||
* web:
|
||||
<https://npm.community/c/bugs>
|
||||
|
||||
Be sure to include *all* of the output from the npm command that didn't work
|
||||
as expected. The `npm-debug.log` file is also helpful to provide.
|
||||
|
||||
## SEE ALSO
|
||||
|
||||
* npm(1)
|
||||
* npm-help(1)
|
||||
@ -1,6 +0,0 @@
|
||||
#!/usr/bin/env sh
|
||||
if [ "x$npm_config_node_gyp" = "x" ]; then
|
||||
node "`dirname "$0"`/../../node_modules/node-gyp/bin/node-gyp.js" "$@"
|
||||
else
|
||||
"$npm_config_node_gyp" "$@"
|
||||
fi
|
||||
@ -1,5 +0,0 @@
|
||||
if not defined npm_config_node_gyp (
|
||||
node "%~dp0\..\..\node_modules\node-gyp\bin\node-gyp.js" %*
|
||||
) else (
|
||||
node "%npm_config_node_gyp%" %*
|
||||
)
|
||||
@ -1,37 +0,0 @@
|
||||
#!/bin/sh
|
||||
(set -o igncr) 2>/dev/null && set -o igncr; # cygwin encoding fix
|
||||
|
||||
basedir=`dirname "$0"`
|
||||
|
||||
case `uname` in
|
||||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
||||
esac
|
||||
|
||||
NODE_EXE="$basedir/node.exe"
|
||||
if ! [ -x "$NODE_EXE" ]; then
|
||||
NODE_EXE="$basedir/node"
|
||||
fi
|
||||
if ! [ -x "$NODE_EXE" ]; then
|
||||
NODE_EXE=node
|
||||
fi
|
||||
|
||||
NPM_CLI_JS="$basedir/node_modules/npm/bin/npm-cli.js"
|
||||
|
||||
case `uname` in
|
||||
*MINGW*)
|
||||
NPM_PREFIX=`"$NODE_EXE" "$NPM_CLI_JS" prefix -g`
|
||||
NPM_PREFIX_NPM_CLI_JS="$NPM_PREFIX/node_modules/npm/bin/npm-cli.js"
|
||||
if [ -f "$NPM_PREFIX_NPM_CLI_JS" ]; then
|
||||
NPM_CLI_JS="$NPM_PREFIX_NPM_CLI_JS"
|
||||
fi
|
||||
;;
|
||||
*CYGWIN*)
|
||||
NPM_PREFIX=`"$NODE_EXE" "$NPM_CLI_JS" prefix -g`
|
||||
NPM_PREFIX_NPM_CLI_JS="$NPM_PREFIX/node_modules/npm/bin/npm-cli.js"
|
||||
if [ -f "$NPM_PREFIX_NPM_CLI_JS" ]; then
|
||||
NPM_CLI_JS="$NPM_PREFIX_NPM_CLI_JS"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
"$NODE_EXE" "$NPM_CLI_JS" "$@"
|
||||
@ -1,153 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
;(function () { // wrapper in case we're in module_context mode
|
||||
// windows: running "npm blah" in this folder will invoke WSH, not node.
|
||||
/* global WScript */
|
||||
if (typeof WScript !== 'undefined') {
|
||||
WScript.echo(
|
||||
'npm does not work when run\n' +
|
||||
'with the Windows Scripting Host\n\n' +
|
||||
"'cd' to a different directory,\n" +
|
||||
"or type 'npm.cmd <args>',\n" +
|
||||
"or type 'node npm <args>'."
|
||||
)
|
||||
WScript.quit(1)
|
||||
return
|
||||
}
|
||||
|
||||
process.title = 'npm'
|
||||
|
||||
var unsupported = require('../lib/utils/unsupported.js')
|
||||
unsupported.checkForBrokenNode()
|
||||
|
||||
var log = require('npmlog')
|
||||
log.pause() // will be unpaused when config is loaded.
|
||||
log.info('it worked if it ends with', 'ok')
|
||||
|
||||
unsupported.checkForUnsupportedNode()
|
||||
|
||||
var npm = require('../lib/npm.js')
|
||||
var npmconf = require('../lib/config/core.js')
|
||||
var errorHandler = require('../lib/utils/error-handler.js')
|
||||
|
||||
var configDefs = npmconf.defs
|
||||
var shorthands = configDefs.shorthands
|
||||
var types = configDefs.types
|
||||
var nopt = require('nopt')
|
||||
|
||||
// if npm is called as "npmg" or "npm_g", then
|
||||
// run in global mode.
|
||||
if (process.argv[1][process.argv[1].length - 1] === 'g') {
|
||||
process.argv.splice(1, 1, 'npm', '-g')
|
||||
}
|
||||
|
||||
log.verbose('cli', process.argv)
|
||||
|
||||
var conf = nopt(types, shorthands)
|
||||
npm.argv = conf.argv.remain
|
||||
if (npm.deref(npm.argv[0])) npm.command = npm.argv.shift()
|
||||
else conf.usage = true
|
||||
|
||||
if (conf.version) {
|
||||
console.log(npm.version)
|
||||
return errorHandler.exit(0)
|
||||
}
|
||||
|
||||
if (conf.versions) {
|
||||
npm.command = 'version'
|
||||
conf.usage = false
|
||||
npm.argv = []
|
||||
}
|
||||
|
||||
log.info('using', 'npm@%s', npm.version)
|
||||
log.info('using', 'node@%s', process.version)
|
||||
|
||||
process.on('uncaughtException', errorHandler)
|
||||
process.on('unhandledRejection', errorHandler)
|
||||
|
||||
if (conf.usage && npm.command !== 'help') {
|
||||
npm.argv.unshift(npm.command)
|
||||
npm.command = 'help'
|
||||
}
|
||||
|
||||
var isGlobalNpmUpdate = conf.global && ['install', 'update'].includes(npm.command) && npm.argv.includes('npm')
|
||||
|
||||
// now actually fire up npm and run the command.
|
||||
// this is how to use npm programmatically:
|
||||
conf._exit = true
|
||||
npm.load(conf, function (er) {
|
||||
if (er) return errorHandler(er)
|
||||
if (
|
||||
!isGlobalNpmUpdate &&
|
||||
npm.config.get('update-notifier') &&
|
||||
!unsupported.checkVersion(process.version).unsupported
|
||||
) {
|
||||
const pkg = require('../package.json')
|
||||
let notifier = require('update-notifier')({pkg})
|
||||
const isCI = require('ci-info').isCI
|
||||
if (
|
||||
notifier.update &&
|
||||
notifier.update.latest !== pkg.version &&
|
||||
!isCI
|
||||
) {
|
||||
const color = require('ansicolors')
|
||||
const useColor = npm.config.get('color')
|
||||
const useUnicode = npm.config.get('unicode')
|
||||
const old = notifier.update.current
|
||||
const latest = notifier.update.latest
|
||||
let type = notifier.update.type
|
||||
if (useColor) {
|
||||
switch (type) {
|
||||
case 'major':
|
||||
type = color.red(type)
|
||||
break
|
||||
case 'minor':
|
||||
type = color.yellow(type)
|
||||
break
|
||||
case 'patch':
|
||||
type = color.green(type)
|
||||
break
|
||||
}
|
||||
}
|
||||
const changelog = `https://github.com/npm/cli/releases/tag/v${latest}`
|
||||
notifier.notify({
|
||||
message: `New ${type} version of ${pkg.name} available! ${
|
||||
useColor ? color.red(old) : old
|
||||
} ${useUnicode ? '→' : '->'} ${
|
||||
useColor ? color.green(latest) : latest
|
||||
}\n` +
|
||||
`${
|
||||
useColor ? color.yellow('Changelog:') : 'Changelog:'
|
||||
} ${
|
||||
useColor ? color.cyan(changelog) : changelog
|
||||
}\n` +
|
||||
`Run ${
|
||||
useColor
|
||||
? color.green(`npm install -g ${pkg.name}`)
|
||||
: `npm i -g ${pkg.name}`
|
||||
} to update!`
|
||||
})
|
||||
}
|
||||
}
|
||||
npm.commands[npm.command](npm.argv, function (err) {
|
||||
// https://genius.com/Lin-manuel-miranda-your-obedient-servant-lyrics
|
||||
if (
|
||||
!err &&
|
||||
npm.config.get('ham-it-up') &&
|
||||
!npm.config.get('json') &&
|
||||
!npm.config.get('parseable') &&
|
||||
npm.command !== 'completion'
|
||||
) {
|
||||
console.error(
|
||||
`\n ${
|
||||
npm.config.get('unicode') ? '🎵 ' : ''
|
||||
} I Have the Honour to Be Your Obedient Servant,${
|
||||
npm.config.get('unicode') ? '🎵 ' : ''
|
||||
} ~ npm ${
|
||||
npm.config.get('unicode') ? '📜🖋 ' : ''
|
||||
}\n`
|
||||
)
|
||||
}
|
||||
errorHandler.apply(this, arguments)
|
||||
})
|
||||
})
|
||||
})()
|
||||
@ -1,19 +0,0 @@
|
||||
:: Created by npm, please don't edit manually.
|
||||
@ECHO OFF
|
||||
|
||||
SETLOCAL
|
||||
|
||||
SET "NODE_EXE=%~dp0\node.exe"
|
||||
IF NOT EXIST "%NODE_EXE%" (
|
||||
SET "NODE_EXE=node"
|
||||
)
|
||||
|
||||
SET "NPM_CLI_JS=%~dp0\node_modules\npm\bin\npm-cli.js"
|
||||
FOR /F "delims=" %%F IN ('CALL "%NODE_EXE%" "%NPM_CLI_JS%" prefix -g') DO (
|
||||
SET "NPM_PREFIX_NPM_CLI_JS=%%F\node_modules\npm\bin\npm-cli.js"
|
||||
)
|
||||
IF EXIST "%NPM_PREFIX_NPM_CLI_JS%" (
|
||||
SET "NPM_CLI_JS=%NPM_PREFIX_NPM_CLI_JS%"
|
||||
)
|
||||
|
||||
"%NODE_EXE%" "%NPM_CLI_JS%" %*
|
||||
@ -1,35 +0,0 @@
|
||||
#!/bin/sh
|
||||
(set -o igncr) 2>/dev/null && set -o igncr; # cygwin encoding fix
|
||||
|
||||
basedir=`dirname "$0"`
|
||||
|
||||
case `uname` in
|
||||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
||||
esac
|
||||
|
||||
NODE_EXE="$basedir/node.exe"
|
||||
if ! [ -x "$NODE_EXE" ]; then
|
||||
NODE_EXE=node
|
||||
fi
|
||||
|
||||
NPM_CLI_JS="$basedir/node_modules/npm/bin/npm-cli.js"
|
||||
NPX_CLI_JS="$basedir/node_modules/npm/bin/npx-cli.js"
|
||||
|
||||
case `uname` in
|
||||
*MINGW*)
|
||||
NPM_PREFIX=`"$NODE_EXE" "$NPM_CLI_JS" prefix -g`
|
||||
NPM_PREFIX_NPX_CLI_JS="$NPM_PREFIX/node_modules/npm/bin/npx-cli.js"
|
||||
if [ -f "$NPM_PREFIX_NPX_CLI_JS" ]; then
|
||||
NPX_CLI_JS="$NPM_PREFIX_NPX_CLI_JS"
|
||||
fi
|
||||
;;
|
||||
*CYGWIN*)
|
||||
NPM_PREFIX=`"$NODE_EXE" "$NPM_CLI_JS" prefix -g`
|
||||
NPM_PREFIX_NPX_CLI_JS="$NPM_PREFIX/node_modules/npm/bin/npx-cli.js"
|
||||
if [ -f "$NPM_PREFIX_NPX_CLI_JS" ]; then
|
||||
NPX_CLI_JS="$NPM_PREFIX_NPX_CLI_JS"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
"$NODE_EXE" "$NPX_CLI_JS" "$@"
|
||||
@ -1,8 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const npx = require('libnpx')
|
||||
const path = require('path')
|
||||
|
||||
const NPM_PATH = path.join(__dirname, 'npm-cli.js')
|
||||
|
||||
npx(npx.parseArgs(process.argv, NPM_PATH))
|
||||
@ -1,20 +0,0 @@
|
||||
:: Created by npm, please don't edit manually.
|
||||
@ECHO OFF
|
||||
|
||||
SETLOCAL
|
||||
|
||||
SET "NODE_EXE=%~dp0\node.exe"
|
||||
IF NOT EXIST "%NODE_EXE%" (
|
||||
SET "NODE_EXE=node"
|
||||
)
|
||||
|
||||
SET "NPM_CLI_JS=%~dp0\node_modules\npm\bin\npm-cli.js"
|
||||
SET "NPX_CLI_JS=%~dp0\node_modules\npm\bin\npx-cli.js"
|
||||
FOR /F "delims=" %%F IN ('CALL "%NODE_EXE%" "%NPM_CLI_JS%" prefix -g') DO (
|
||||
SET "NPM_PREFIX_NPX_CLI_JS=%%F\node_modules\npm\bin\npx-cli.js"
|
||||
)
|
||||
IF EXIST "%NPM_PREFIX_NPX_CLI_JS%" (
|
||||
SET "NPX_CLI_JS=%NPM_PREFIX_NPX_CLI_JS%"
|
||||
)
|
||||
|
||||
"%NODE_EXE%" "%NPX_CLI_JS%" %*
|
||||
@ -1,743 +0,0 @@
|
||||
### v1.4.29 (2015-10-29):
|
||||
|
||||
#### THINGS ARE HAPPENING IN LTS LAND
|
||||
|
||||
In a special one-off release as part of the [strategy to get a version of npm
|
||||
into Node LTS that works with the current
|
||||
registry](https://github.com/nodejs/LTS/issues/37), modify npm to print out
|
||||
this deprecation banner literally every time npm is invoked to do anything:
|
||||
|
||||
```
|
||||
npm WARN deprecated This version of npm lacks support for important features,
|
||||
npm WARN deprecated such as scoped packages, offered by the primary npm
|
||||
npm WARN deprecated registry. Consider upgrading to at least npm@2, if not the
|
||||
npm WARN deprecated latest stable version. To upgrade to npm@2, run:
|
||||
npm WARN deprecated
|
||||
npm WARN deprecated npm -g install npm@latest-2
|
||||
npm WARN deprecated
|
||||
npm WARN deprecated To upgrade to the latest stable version, run:
|
||||
npm WARN deprecated
|
||||
npm WARN deprecated npm -g install npm@latest
|
||||
npm WARN deprecated
|
||||
npm WARN deprecated (Depending on how Node.js was installed on your system, you
|
||||
npm WARN deprecated may need to prefix the preceding commands with `sudo`, or if
|
||||
npm WARN deprecated on Windows, run them from an Administrator prompt.)
|
||||
npm WARN deprecated
|
||||
npm WARN deprecated If you're running the version of npm bundled with
|
||||
npm WARN deprecated Node.js 0.10 LTS, be aware that the next version of 0.10 LTS
|
||||
npm WARN deprecated will be bundled with a version of npm@2, which has some small
|
||||
npm WARN deprecated backwards-incompatible changes made to `npm run-script` and
|
||||
npm WARN deprecated semver behavior.
|
||||
```
|
||||
|
||||
The message basically tells the tale: Node 0.10 will finally be getting
|
||||
`npm@2`, so those of you who haven't upgraded your build systems to deal with
|
||||
its (relatively small) breaking changes should do so now.
|
||||
|
||||
Also, this version doesn't even pretend that it can deal with scoped packages,
|
||||
which, given the confusing behavior of older versions of `npm@1.4`, where it
|
||||
would sometimes try to install packages from GitHub, is a distinct improvement.
|
||||
|
||||
There is no good reason for you as an end user to upgrade to this version of
|
||||
npm yourself.
|
||||
|
||||
* [`709e9b4`](https://github.com/npm/npm/commit/709e9b44f5df9817a1c4babfbf26a2329bd265fb)
|
||||
Print 20-line deprecation banner on all command invocations.
|
||||
([@othiym23](https://github.com/othiym23))
|
||||
* [`0c29d09`](https://github.com/npm/npm/commit/0c29d0906608e8e174bd30a7a245e19795326051)
|
||||
Crash out immediately with an exhortation to upgrade on attempts to use
|
||||
scoped packages. ([@othiym23](https://github.com/othiym23))
|
||||
|
||||
### v1.5.0-alpha-4 (2014-07-18):
|
||||
|
||||
* fall back to `_auth` config as default auth when using default registry
|
||||
([@isaacs](https://github.com/isaacs))
|
||||
* support for 'init.version' for those who don't want to deal with semver 0.0.x
|
||||
oddities ([@rvagg](https://github.com/rvagg))
|
||||
* [`be06213`](https://github.com/npm/npm/commit/be06213415f2d51a50d2c792b4cd0d3412a9a7b1)
|
||||
remove residual support for `win` log level
|
||||
([@aterris](https://github.com/aterris))
|
||||
|
||||
### v1.5.0-alpha-3 (2014-07-17):
|
||||
|
||||
* [`a3a85dd`](https://github.com/npm/npm/commit/a3a85dd004c9245a71ad2f0213bd1a9a90d64cd6)
|
||||
`--save` scoped packages correctly ([@othiym23](https://github.com/othiym23))
|
||||
* [`18a3385`](https://github.com/npm/npm/commit/18a3385bcf8bfb8312239216afbffb7eec759150)
|
||||
`npm-registry-client@3.0.2` ([@othiym23](https://github.com/othiym23))
|
||||
* [`375988b`](https://github.com/npm/npm/commit/375988b9bf5aa5170f06a790d624d31b1eb32c6d)
|
||||
invalid package names are an early error for optional deps
|
||||
([@othiym23](https://github.com/othiym23))
|
||||
* consistently use `node-package-arg` instead of arbitrary package spec
|
||||
splitting ([@othiym23](https://github.com/othiym23))
|
||||
|
||||
### v1.5.0-alpha-2 (2014-07-01):
|
||||
|
||||
* [`54cf625`](https://github.com/npm/npm/commit/54cf62534e3331e3f454e609e44f0b944e819283)
|
||||
fix handling for 301s in `npm-registry-client@3.0.1`
|
||||
([@Raynos](https://github.com/Raynos))
|
||||
* [`e410861`](https://github.com/npm/npm/commit/e410861c69a3799c1874614cb5b87af8124ff98d)
|
||||
don't crash if no username set on `whoami`
|
||||
([@isaacs](https://github.com/isaacs))
|
||||
* [`0353dde`](https://github.com/npm/npm/commit/0353ddeaca8171aa7dbdd8102b7e2eb581a86406)
|
||||
respect `--json` for output ([@isaacs](https://github.com/isaacs))
|
||||
* [`b3d112a`](https://github.com/npm/npm/commit/b3d112ae190b984cc1779b9e6de92218f22380c6)
|
||||
outdated: Don't show headings if there's nothing to output
|
||||
([@isaacs](https://github.com/isaacs))
|
||||
* [`bb4b90c`](https://github.com/npm/npm/commit/bb4b90c80dbf906a1cb26d85bc0625dc2758acc3)
|
||||
outdated: Default to `latest` rather than `*` for unspecified deps
|
||||
([@isaacs](https://github.com/isaacs))
|
||||
|
||||
### v1.5.0-alpha-1 (2014-07-01):
|
||||
|
||||
* [`eef4884`](https://github.com/npm/npm/commit/eef4884d6487ee029813e60a5f9c54e67925d9fa)
|
||||
use the correct piece of the spec for GitHub shortcuts
|
||||
([@othiym23](https://github.com/othiym23))
|
||||
|
||||
### v1.5.0-alpha-0 (2014-07-01):
|
||||
|
||||
* [`7f55057`](https://github.com/npm/npm/commit/7f55057807cfdd9ceaf6331968e666424f48116c)
|
||||
install scoped packages ([#5239](https://github.com/npm/npm/issues/5239))
|
||||
([@othiym23](https://github.com/othiym23))
|
||||
* [`0df7e16`](https://github.com/npm/npm/commit/0df7e16c0232d8f4d036ebf4ec3563215517caac)
|
||||
publish scoped packages ([#5239](https://github.com/npm/npm/issues/5239))
|
||||
([@othiym23](https://github.com/othiym23))
|
||||
* [`0689ba2`](https://github.com/npm/npm/commit/0689ba249b92b4c6279a26804c96af6f92b3a501)
|
||||
support (and save) --scope=@s config
|
||||
([@othiym23](https://github.com/othiym23))
|
||||
* [`f34878f`](https://github.com/npm/npm/commit/f34878fc4cee29901e4daf7bace94be01e25cad7)
|
||||
scope credentials to registry ([@othiym23](https://github.com/othiym23))
|
||||
* [`0ac7ca2`](https://github.com/npm/npm/commit/0ac7ca233f7a69751fe4386af6c4daa3ee9fc0da)
|
||||
capture and store bearer tokens when sent by registry
|
||||
([@othiym23](https://github.com/othiym23))
|
||||
* [`63c3277`](https://github.com/npm/npm/commit/63c3277f089b2c4417e922826bdc313ac854cad6)
|
||||
only delete files that are created by npm
|
||||
([@othiym23](https://github.com/othiym23))
|
||||
* [`4f54043`](https://github.com/npm/npm/commit/4f540437091d1cbca3915cd20c2da83c2a88bb8e)
|
||||
`npm-package-arg@2.0.0` ([@othiym23](https://github.com/othiym23))
|
||||
* [`9e1460e`](https://github.com/npm/npm/commit/9e1460e6ac9433019758481ec031358f4af4cd44)
|
||||
`read-package-json@1.2.3` ([@othiym23](https://github.com/othiym23))
|
||||
* [`719d8ad`](https://github.com/npm/npm/commit/719d8adb9082401f905ff4207ede494661f8a554)
|
||||
`fs-vacuum@1.2.1` ([@othiym23](https://github.com/othiym23))
|
||||
* [`9ef8fe4`](https://github.com/npm/npm/commit/9ef8fe4d6ead3acb3e88c712000e2d3a9480ebec)
|
||||
`async-some@1.0.0` ([@othiym23](https://github.com/othiym23))
|
||||
* [`a964f65`](https://github.com/npm/npm/commit/a964f65ab662107b62a4ca58535ce817e8cca331)
|
||||
`npmconf@2.0.1` ([@othiym23](https://github.com/othiym23))
|
||||
* [`113765b`](https://github.com/npm/npm/commit/113765bfb7d3801917c1d9f124b8b3d942bec89a)
|
||||
`npm-registry-client@3.0.0` ([@othiym23](https://github.com/othiym23))
|
||||
|
||||
### v1.4.28 (2014-09-12):
|
||||
|
||||
* [`f4540b6`](https://github.com/npm/npm/commit/f4540b6537a87e653d7495a9ddcf72949fdd4d14)
|
||||
[#6043](https://github.com/npm/npm/issues/6043) defer rollbacks until just
|
||||
before the CLI exits ([@isaacs](https://github.com/isaacs))
|
||||
* [`1eabfd5`](https://github.com/npm/npm/commit/1eabfd5c03f33c2bd28823714ff02059eeee3899)
|
||||
[#6043](https://github.com/npm/npm/issues/6043) `slide@1.1.6`: wait until all
|
||||
callbacks have finished before proceeding
|
||||
([@othiym23](https://github.com/othiym23))
|
||||
|
||||
### v1.4.27 (2014-09-04):
|
||||
|
||||
* [`4cf3c8f`](https://github.com/npm/npm/commit/4cf3c8fd78c9e2693a5f899f50c28f4823c88e2e)
|
||||
[#6007](https://github.com/npm/npm/issues/6007) request@2.42.0: properly set
|
||||
headers on proxy requests ([@isaacs](https://github.com/isaacs))
|
||||
* [`403cb52`](https://github.com/npm/npm/commit/403cb526be1472bb7545fa8e62d4976382cdbbe5)
|
||||
[#6055](https://github.com/npm/npm/issues/6055) npmconf@1.1.8: restore
|
||||
case-insensitivity of environmental config
|
||||
([@iarna](https://github.com/iarna))
|
||||
|
||||
### v1.4.26 (2014-08-28):
|
||||
|
||||
* [`eceea95`](https://github.com/npm/npm/commit/eceea95c804fa15b18e91c52c0beb08d42a3e77d)
|
||||
`github-url-from-git@1.4.0`: add support for git+https and git+ssh
|
||||
([@stefanbuck](https://github.com/stefanbuck))
|
||||
* [`e561758`](https://github.com/npm/npm/commit/e5617587e7d7ab686192391ce55357dbc7fed0a3)
|
||||
`columnify@1.2.1` ([@othiym23](https://github.com/othiym23))
|
||||
* [`0c4fab3`](https://github.com/npm/npm/commit/0c4fab372ee76eab01dda83b6749429a8564902e)
|
||||
`cmd-shim@2.0.0`: upgrade to graceful-fs 3
|
||||
([@ForbesLindesay](https://github.com/ForbesLindesay))
|
||||
* [`2d69e4d`](https://github.com/npm/npm/commit/2d69e4d95777671958b5e08d3b2f5844109d73e4)
|
||||
`github-url-from-username-repo@1.0.0`: accept slashes in branch names
|
||||
([@robertkowalski](https://github.com/robertkowalski))
|
||||
* [`81f9b2b`](https://github.com/npm/npm/commit/81f9b2bac9d34c223ea093281ba3c495f23f10d1)
|
||||
ensure lifecycle spawn errors caught properly
|
||||
([@isaacs](https://github.com/isaacs))
|
||||
* [`bfaab8c`](https://github.com/npm/npm/commit/bfaab8c6e0942382a96b250634ded22454c36b5a)
|
||||
`npm-registry-client@2.0.7`: properly encode % in passwords
|
||||
([@isaacs](https://github.com/isaacs))
|
||||
* [`91cfb58`](https://github.com/npm/npm/commit/91cfb58dda851377ec604782263519f01fd96ad8)
|
||||
doc: Fix 'npm help index' ([@isaacs](https://github.com/isaacs))
|
||||
|
||||
### v1.4.25 (2014-08-21):
|
||||
|
||||
* [`64c0ec2`](https://github.com/npm/npm/commit/64c0ec241ef5d83761ca8de54acb3c41b079956e)
|
||||
`npm-registry-client@2.0.6`: Print the notification header returned by the
|
||||
registry, and make sure status codes are printed without gratuitous quotes
|
||||
around them.
|
||||
([@othiym23](https://github.com/othiym23))
|
||||
* [`a8ed12b`](https://github.com/npm/npm/commit/a8ed12b) `tar@1.0.1`:
|
||||
Add test for removing an extract target immediately after unpacking.
|
||||
([@isaacs](https://github.com/isaacs))
|
||||
* [`70fd11d`](https://github.com/npm/npm/commit/70fd11d)
|
||||
`lockfile@1.0.0`: Fix incorrect interaction between `wait`, `stale`,
|
||||
and `retries` options. Part 2 of race condition leading to `ENOENT`
|
||||
errors.
|
||||
([@isaacs](https://github.com/isaacs))
|
||||
* [`0072c4d`](https://github.com/npm/npm/commit/0072c4d)
|
||||
`fstream@1.0.2`: Fix a double-finish call which can result in excess
|
||||
FS operations after the `close` event. Part 2 of race condition
|
||||
leading to `ENOENT` errors.
|
||||
([@isaacs](https://github.com/isaacs))
|
||||
|
||||
### v1.4.24 (2014-08-14):
|
||||
|
||||
* [`9344bd9`](https://github.com/npm/npm/commit/9344bd9b2929b5c399a0e0e0b34d45bce7bc24bb)
|
||||
doc: add new changelog ([@othiym23](https://github.com/othiym23))
|
||||
* [`4be76fd`](https://github.com/npm/npm/commit/4be76fd65e895883c337a99f275ccc8c801adda3)
|
||||
doc: update version doc to include `pre-*` increment args
|
||||
([@isaacs](https://github.com/isaacs))
|
||||
* [`e4f2620`](https://github.com/npm/npm/commit/e4f262036080a282ad60e236a9aeebd39fde9fe4)
|
||||
build: add `make tag` to tag current release as `latest`
|
||||
([@isaacs](https://github.com/isaacs))
|
||||
* [`ec2596a`](https://github.com/npm/npm/commit/ec2596a7cb626772780b25b0a94a7e547a812bd5)
|
||||
build: publish with `--tag=v1.4-next` ([@isaacs](https://github.com/isaacs))
|
||||
* [`9ee55f8`](https://github.com/npm/npm/commit/9ee55f892b8b473032a43c59912c5684fd1b39e6)
|
||||
build: add script to output `v1.4-next` publish tag
|
||||
([@isaacs](https://github.com/isaacs))
|
||||
* [`aecb56f`](https://github.com/npm/npm/commit/aecb56f95a84687ea46920a0b98aaa587fee1568)
|
||||
build: remove outdated `docpublish` make target
|
||||
([@isaacs](https://github.com/isaacs))
|
||||
* [`b57a9b7`](https://github.com/npm/npm/commit/b57a9b7ccd13e6b38831ed63595c8ea5763da247)
|
||||
build: remove unpublish step from `make publish`
|
||||
([@isaacs](https://github.com/isaacs))
|
||||
* [`2c6acb9`](https://github.com/npm/npm/commit/2c6acb96c71c16106965d5cd829b67195dd673c7)
|
||||
install: rename `.gitignore` when unpacking foreign tarballs
|
||||
([@isaacs](https://github.com/isaacs))
|
||||
* [`22f3681`](https://github.com/npm/npm/commit/22f3681923e993a47fc1769ba735bfa3dd138082)
|
||||
cache: detect non-gzipped tar files more reliably
|
||||
([@isaacs](https://github.com/isaacs))
|
||||
|
||||
### v1.4.23 (2014-07-31):
|
||||
|
||||
* [`8dd11d1`](https://github.com/npm/npm/commit/8dd11d1) update several
|
||||
dependencies to avoid using `semver`s starting with 0.
|
||||
|
||||
### v1.4.22 (2014-07-31):
|
||||
|
||||
* [`d9a9e84`](https://github.com/npm/npm/commit/d9a9e84) `read-package-json@1.2.4`
|
||||
([@isaacs](https://github.com/isaacs))
|
||||
* [`86f0340`](https://github.com/npm/npm/commit/86f0340)
|
||||
`github-url-from-git@1.2.0` ([@isaacs](https://github.com/isaacs))
|
||||
* [`a94136a`](https://github.com/npm/npm/commit/a94136a) `fstream@0.1.29`
|
||||
([@isaacs](https://github.com/isaacs))
|
||||
* [`bb82d18`](https://github.com/npm/npm/commit/bb82d18) `glob@4.0.5`
|
||||
([@isaacs](https://github.com/isaacs))
|
||||
* [`5b6bcf4`](https://github.com/npm/npm/commit/5b6bcf4) `cmd-shim@1.1.2`
|
||||
([@isaacs](https://github.com/isaacs))
|
||||
* [`c2aa8b3`](https://github.com/npm/npm/commit/c2aa8b3) license: Cleaned up
|
||||
legalese with actual lawyer ([@isaacs](https://github.com/isaacs))
|
||||
* [`63fe0ee`](https://github.com/npm/npm/commit/63fe0ee) `init-package-json@1.0.0`
|
||||
([@isaacs](https://github.com/isaacs))
|
||||
|
||||
### v1.4.21 (2014-07-14):
|
||||
|
||||
* [`88f51aa`](https://github.com/npm/npm/commit/88f51aa27eb9a958d1fa7ec50fee5cfdedd05110)
|
||||
fix handling for 301s in `npm-registry-client@2.0.3`
|
||||
([@Raynos](https://github.com/Raynos))
|
||||
|
||||
### v1.4.20 (2014-07-02):
|
||||
|
||||
* [`0353dde`](https://github.com/npm/npm/commit/0353ddeaca8171aa7dbdd8102b7e2eb581a86406)
|
||||
respect `--json` for output ([@isaacs](https://github.com/isaacs))
|
||||
* [`b3d112a`](https://github.com/npm/npm/commit/b3d112ae190b984cc1779b9e6de92218f22380c6)
|
||||
outdated: Don't show headings if there's nothing to output
|
||||
([@isaacs](https://github.com/isaacs))
|
||||
* [`bb4b90c`](https://github.com/npm/npm/commit/bb4b90c80dbf906a1cb26d85bc0625dc2758acc3)
|
||||
outdated: Default to `latest` rather than `*` for unspecified deps
|
||||
([@isaacs](https://github.com/isaacs))
|
||||
|
||||
### v1.4.19 (2014-07-01):
|
||||
|
||||
* [`f687433`](https://github.com/npm/npm/commit/f687433) relative URLS for
|
||||
working non-root registry URLS ([@othiym23](https://github.com/othiym23))
|
||||
* [`bea190c`](https://github.com/npm/npm/commit/bea190c)
|
||||
[#5591](https://github.com/npm/npm/issues/5591) bump nopt and npmconf
|
||||
([@isaacs](https://github.com/isaacs))
|
||||
|
||||
### v1.4.18 (2014-06-29):
|
||||
|
||||
* Bump glob dependency from 4.0.2 to 4.0.3. It now uses graceful-fs when
|
||||
available, increasing resilience to [various filesystem
|
||||
errors](https://github.com/isaacs/node-graceful-fs#improvements-over-fs-module).
|
||||
([@isaacs](https://github.com/isaacs))
|
||||
|
||||
### v1.4.17 (2014-06-27):
|
||||
|
||||
* replace escape codes with ansicolors
|
||||
([@othiym23](https://github.com/othiym23))
|
||||
* Allow to build all the docs OOTB. ([@GeJ](https://github.com/GeJ))
|
||||
* Use core.longpaths on win32 git - fixes
|
||||
[#5525](https://github.com/npm/npm/issues/5525) ([@bmeck](https://github.com/bmeck))
|
||||
* `npmconf@1.1.2` ([@isaacs](https://github.com/isaacs))
|
||||
* Consolidate color sniffing in config/log loading process
|
||||
([@isaacs](https://github.com/isaacs))
|
||||
* add verbose log when project config file is ignored
|
||||
([@isaacs](https://github.com/isaacs))
|
||||
* npmconf: Float patch to remove 'scope' from config defs
|
||||
([@isaacs](https://github.com/isaacs))
|
||||
* doc: npm-explore can't handle a version
|
||||
([@robertkowalski](https://github.com/robertkowalski))
|
||||
* Add user-friendly errors for ENOSPC and EROFS.
|
||||
([@voodootikigod](https://github.com/voodootikigod))
|
||||
* bump tar and fstream deps ([@isaacs](https://github.com/isaacs))
|
||||
* Run the npm-registry-couchapp tests along with npm tests
|
||||
([@isaacs](https://github.com/isaacs))
|
||||
|
||||
### v1.2.8000 (2014-06-17):
|
||||
|
||||
* Same as v1.4.16, but with the spinner disabled, and a version number that
|
||||
starts with v1.2.
|
||||
|
||||
### v1.4.16 (2014-06-17):
|
||||
|
||||
* `npm-registry-client@2.0.2` ([@isaacs](https://github.com/isaacs))
|
||||
* `fstream@0.1.27` ([@isaacs](https://github.com/isaacs))
|
||||
* `sha@1.2.4` ([@isaacs](https://github.com/isaacs))
|
||||
* `rimraf@2.2.8` ([@isaacs](https://github.com/isaacs))
|
||||
* `npmlog@1.0.1` ([@isaacs](https://github.com/isaacs))
|
||||
* `npm-registry-client@2.0.1` ([@isaacs](https://github.com/isaacs))
|
||||
* removed redundant dependency ([@othiym23](https://github.com/othiym23))
|
||||
* `npmconf@1.0.5` ([@isaacs](https://github.com/isaacs))
|
||||
* Properly handle errors that can occur in the config-loading process
|
||||
([@isaacs](https://github.com/isaacs))
|
||||
|
||||
### v1.4.15 (2014-06-10):
|
||||
|
||||
* cache: atomic de-race-ified package.json writing
|
||||
([@isaacs](https://github.com/isaacs))
|
||||
* `fstream@0.1.26` ([@isaacs](https://github.com/isaacs))
|
||||
* `graceful-fs@3.0.2` ([@isaacs](https://github.com/isaacs))
|
||||
* `osenv@0.1.0` ([@isaacs](https://github.com/isaacs))
|
||||
* Only spin the spinner when we're fetching stuff
|
||||
([@isaacs](https://github.com/isaacs))
|
||||
* Update `osenv@0.1.0` which removes ~/tmp as possible tmp-folder
|
||||
([@robertkowalski](https://github.com/robertkowalski))
|
||||
* `ini@1.2.1` ([@isaacs](https://github.com/isaacs))
|
||||
* `graceful-fs@3` ([@isaacs](https://github.com/isaacs))
|
||||
* Update glob and things depending on glob
|
||||
([@isaacs](https://github.com/isaacs))
|
||||
* github-url-from-username-repo and read-package-json updates
|
||||
([@isaacs](https://github.com/isaacs))
|
||||
* `editor@0.1.0` ([@isaacs](https://github.com/isaacs))
|
||||
* `columnify@1.1.0` ([@isaacs](https://github.com/isaacs))
|
||||
* bump ansi and associated deps ([@isaacs](https://github.com/isaacs))
|
||||
|
||||
### v1.4.14 (2014-06-05):
|
||||
|
||||
* char-spinner: update to not bork windows
|
||||
([@isaacs](https://github.com/isaacs))
|
||||
|
||||
### v1.4.13 (2014-05-23):
|
||||
|
||||
* Fix `npm install` on a tarball.
|
||||
([`ed3abf1`](https://github.com/npm/npm/commit/ed3abf1aa10000f0f687330e976d78d1955557f6),
|
||||
[#5330](https://github.com/npm/npm/issues/5330),
|
||||
[@othiym23](https://github.com/othiym23))
|
||||
* Fix an issue with the spinner on Node 0.8.
|
||||
([`9f00306`](https://github.com/npm/npm/commit/9f003067909440390198c0b8f92560d84da37762),
|
||||
[@isaacs](https://github.com/isaacs))
|
||||
* Re-add `npm.commands.cache.clean` and `npm.commands.cache.read` APIs, and
|
||||
document `npm.commands.cache.*` as npm-cache(3).
|
||||
([`e06799e`](https://github.com/npm/npm/commit/e06799e77e60c1fc51869619083a25e074d368b3),
|
||||
[@isaacs](https://github.com/isaacs))
|
||||
|
||||
### v1.4.12 (2014-05-23):
|
||||
|
||||
* remove normalize-package-data from top level, de-^-ify inflight dep
|
||||
([@isaacs](https://github.com/isaacs))
|
||||
* Always sort saved bundleDependencies ([@isaacs](https://github.com/isaacs))
|
||||
* add inflight to bundledDependencies
|
||||
([@othiym23](https://github.com/othiym23))
|
||||
|
||||
### v1.4.11 (2014-05-22):
|
||||
|
||||
* fix `npm ls` labeling issue
|
||||
* `node-gyp@0.13.1`
|
||||
* default repository to https:// instead of git://
|
||||
* addLocalTarball: Remove extraneous unpack
|
||||
([@isaacs](https://github.com/isaacs))
|
||||
* Massive cache folder refactor ([@othiym23](https://github.com/othiym23) and
|
||||
[@isaacs](https://github.com/isaacs))
|
||||
* Busy Spinner, no http noise ([@isaacs](https://github.com/isaacs))
|
||||
* Per-project .npmrc file support ([@isaacs](https://github.com/isaacs))
|
||||
* `npmconf@1.0.0`, Refactor config/uid/prefix loading process
|
||||
([@isaacs](https://github.com/isaacs))
|
||||
* Allow once-disallowed characters in passwords
|
||||
([@isaacs](https://github.com/isaacs))
|
||||
* Send npm version as 'version' header ([@isaacs](https://github.com/isaacs))
|
||||
* fix cygwin encoding issue (Karsten Tinnefeld)
|
||||
* Allow non-github repositories with `npm repo`
|
||||
([@evanlucas](https://github.com/evanlucas))
|
||||
* Allow peer deps to be satisfied by grandparent
|
||||
* Stop optional deps moving into deps on `update --save`
|
||||
([@timoxley](https://github.com/timoxley))
|
||||
* Ensure only matching deps update with `update --save*`
|
||||
([@timoxley](https://github.com/timoxley))
|
||||
* Add support for `prerelease`, `preminor`, `prepatch` to `npm version`
|
||||
|
||||
### v1.4.10 (2014-05-05):
|
||||
|
||||
* Don't set referer if already set
|
||||
* fetch: Send referer and npm-session headers
|
||||
* `run-script`: Support `--parseable` and `--json`
|
||||
* list runnable scripts ([@evanlucas](https://github.com/evanlucas))
|
||||
* Use marked instead of ronn for html docs
|
||||
|
||||
### v1.4.9 (2014-05-01):
|
||||
|
||||
* Send referer header (with any potentially private stuff redacted)
|
||||
* Fix critical typo bug in previous npm release
|
||||
|
||||
### v1.4.8 (2014-05-01):
|
||||
|
||||
* Check SHA before using files from cache
|
||||
* adduser: allow change of the saved password
|
||||
* Make `npm install` respect `config.unicode`
|
||||
* Fix lifecycle to pass `Infinity` for config env value
|
||||
* Don't return 0 exit code on invalid command
|
||||
* cache: Handle 404s and other HTTP errors as errors
|
||||
* Resolve ~ in path configs to env.HOME
|
||||
* Include npm version in default user-agent conf
|
||||
* npm init: Use ISC as default license, use save-prefix for deps
|
||||
* Many test and doc fixes
|
||||
|
||||
### v1.4.7 (2014-04-15):
|
||||
|
||||
* Add `--save-prefix` option that can be used to override the default of `^`
|
||||
when using `npm install --save` and its counterparts.
|
||||
([`64eefdf`](https://github.com/npm/npm/commit/64eefdfe26bb27db8dc90e3ab5d27a5ef18a4470),
|
||||
[@thlorenz](https://github.com/thlorenz))
|
||||
* Allow `--silent` to silence the echoing of commands that occurs with `npm
|
||||
run`.
|
||||
([`c95cf08`](https://github.com/npm/npm/commit/c95cf086e5b97dbb48ff95a72517b203a8f29eab),
|
||||
[@Raynos](https://github.com/Raynos))
|
||||
* Some speed improvements to the cache, which should improve install times.
|
||||
([`cb94310`](https://github.com/npm/npm/commit/cb94310a6adb18cb7b881eacb8d67171eda8b744),
|
||||
[`3b0870f`](https://github.com/npm/npm/commit/3b0870fb2f40358b3051abdab6be4319d196b99d),
|
||||
[`120f5a9`](https://github.com/npm/npm/commit/120f5a93437bbbea9249801574a2f33e44e81c33),
|
||||
[@isaacs](https://github.com/isaacs))
|
||||
* Improve ability to retry registry requests when a subset of the registry
|
||||
servers are down.
|
||||
([`4a5257d`](https://github.com/npm/npm/commit/4a5257de3870ac3dafa39667379f19f6dcd6093e),
|
||||
https://github.com/npm/npm-registry-client/commit/7686d02cb0b844626d6a401e58c0755ef3bc8432,
|
||||
[@isaacs](https://github.com/isaacs))
|
||||
* Fix marking of peer dependencies as extraneous.
|
||||
([`779b164`](https://github.com/npm/npm/commit/779b1649764607b062c031c7e5c972151b4a1754),
|
||||
https://github.com/npm/read-installed/commit/6680ba6ef235b1ca3273a00b70869798ad662ddc,
|
||||
[@isaacs](https://github.com/isaacs))
|
||||
* Fix npm crashing when doing `npm shrinkwrap` in the presence of a
|
||||
`package.json` with no dependencies.
|
||||
([`a9d9fa5`](https://github.com/npm/npm/commit/a9d9fa5ad3b8c925a589422b7be28d2735f320b0),
|
||||
[@kislyuk](https://github.com/kislyuk))
|
||||
* Fix error when using `npm view` on packages that have no versions or have
|
||||
been unpublished.
|
||||
([`94df2f5`](https://github.com/npm/npm/commit/94df2f56d684b35d1df043660180fc321b743dc8),
|
||||
[@juliangruber](https://github.com/juliangruber);
|
||||
[`2241a09`](https://github.com/npm/npm/commit/2241a09c843669c70633c399ce698cec3add40b3),
|
||||
[@isaacs](https://github.com/isaacs))
|
||||
|
||||
### v1.4.6 (2014-03-19):
|
||||
|
||||
* Fix extraneous package detection to work in more cases.
|
||||
([`f671286`](https://github.com/npm/npm/commit/f671286), npm/read-installed#20,
|
||||
[@LaurentVB](https://github.com/LaurentVB))
|
||||
|
||||
### v1.4.5 (2014-03-18):
|
||||
|
||||
* Sort dependencies in `package.json` when doing `npm install --save` and all
|
||||
its variants.
|
||||
([`6fd6ff7`](https://github.com/npm/npm/commit/6fd6ff7e536ea6acd33037b1878d4eca1f931985),
|
||||
[@domenic](https://github.com/domenic))
|
||||
* Add `--save-exact` option, usable alongside `--save` and its variants, which
|
||||
will write the exact version number into `package.json` instead of the
|
||||
appropriate semver-compatibility range.
|
||||
([`17f07df`](https://github.com/npm/npm/commit/17f07df8ad8e594304c2445bf7489cb53346f2c5),
|
||||
[@timoxley](https://github.com/timoxley))
|
||||
* Accept gzipped content from the registry to speed up downloads and save
|
||||
bandwidth.
|
||||
([`a3762de`](https://github.com/npm/npm/commit/a3762de843b842be8fa0ab57cdcd6b164f145942),
|
||||
npm/npm-registry-client#40, [@fengmk2](https://github.com/fengmk2))
|
||||
* Fix `npm ls`'s `--depth` and `--log` options.
|
||||
([`1d29b17`](https://github.com/npm/npm/commit/1d29b17f5193d52a5c4faa412a95313dcf41ed91),
|
||||
npm/read-installed#13, [@zertosh](https://github.com/zertosh))
|
||||
* Fix "Adding a cache directory to the cache will make the world implode" in
|
||||
certain cases.
|
||||
([`9a4b2c4`](https://github.com/npm/npm/commit/9a4b2c4667c2b1e0054e3d5611ab86acb1760834),
|
||||
domenic/path-is-inside#1, [@pmarques](https://github.com/pmarques))
|
||||
* Fix readmes not being uploaded in certain rare cases.
|
||||
([`527b72c`](https://github.com/npm/npm/commit/527b72cca6c55762b51e592c48a9f28cc7e2ff8b),
|
||||
[@isaacs](https://github.com/isaacs))
|
||||
|
||||
### v1.4.4 (2014-02-20):
|
||||
|
||||
* Add `npm t` as an alias for `npm test` (which is itself an alias for `npm run
|
||||
test`, or even `npm run-script test`). We like making running your tests
|
||||
easy. ([`14e650b`](https://github.com/npm/npm/commit/14e650bce0bfebba10094c961ac104a61417a5de), [@isaacs](https://github.com/isaacs))
|
||||
|
||||
### v1.4.3 (2014-02-16):
|
||||
|
||||
* Add back `npm prune --production`, which was removed in 1.3.24.
|
||||
([`acc4d02`](https://github.com/npm/npm/commit/acc4d023c57d07704b20a0955e4bf10ee91bdc83),
|
||||
[@davglass](https://github.com/davglass))
|
||||
* Default `npm install --save` and its counterparts to use the `^` version
|
||||
specifier, instead of `~`.
|
||||
([`0a3151c`](https://github.com/npm/npm/commit/0a3151c9cbeb50c1c65895685c2eabdc7e2608dc),
|
||||
[@mikolalysenko](https://github.com/mikolalysenko))
|
||||
* Make `npm shrinkwrap` output dependencies in a sorted order, so that diffs
|
||||
between shrinkwrap files should be saner now.
|
||||
([`059b2bf`](https://github.com/npm/npm/commit/059b2bfd06ae775205a37257dca80142596a0113),
|
||||
[@Raynos](https://github.com/Raynos))
|
||||
* Fix `npm dedupe` not correctly respecting dependency constraints.
|
||||
([`86028e9`](https://github.com/npm/npm/commit/86028e9fd8524d5e520ce01ba2ebab5a030103fc),
|
||||
[@rafeca](https://github.com/rafeca))
|
||||
* Fix `npm ls` giving spurious warnings when you used `"latest"` as a version
|
||||
specifier.
|
||||
(https://github.com/npm/read-installed/commit/d2956400e0386931c926e0f30c334840e0938f14,
|
||||
[@bajtos](https://github.com/bajtos))
|
||||
* Fixed a bug where using `npm link` on packages without a `name` value could
|
||||
cause npm to delete itself.
|
||||
([`401a642`](https://github.com/npm/npm/commit/401a64286aa6665a94d1d2f13604f7014c5fce87),
|
||||
[@isaacs](https://github.com/isaacs))
|
||||
* Fixed `npm install ./pkg@1.2.3` to actually install the directory at
|
||||
`pkg@1.2.3`; before it would try to find version `1.2.3` of the package
|
||||
`./pkg` in the npm registry.
|
||||
([`46d8768`](https://github.com/npm/npm/commit/46d876821d1dd94c050d5ebc86444bed12c56739),
|
||||
[@rlidwka](https://github.com/rlidwka); see also
|
||||
[`f851b79`](https://github.com/npm/npm/commit/f851b79a71d9a5f5125aa85877c94faaf91bea5f))
|
||||
* Fix `npm outdated` to respect the `color` configuration option.
|
||||
([`d4f6f3f`](https://github.com/npm/npm/commit/d4f6f3ff83bd14fb60d3ac6392cb8eb6b1c55ce1),
|
||||
[@timoxley](https://github.com/timoxley))
|
||||
* Fix `npm outdated --parseable`.
|
||||
([`9575a23`](https://github.com/npm/npm/commit/9575a23f955ce3e75b509c89504ef0bd707c8cf6),
|
||||
[@yhpark](https://github.com/yhpark))
|
||||
* Fix a lockfile-related errors when using certain Git URLs.
|
||||
([`164b97e`](https://github.com/npm/npm/commit/164b97e6089f64e686db7a9a24016f245effc37f),
|
||||
[@nigelzor](https://github.com/nigelzor))
|
||||
|
||||
### v1.4.2 (2014-02-13):
|
||||
|
||||
* Fixed an issue related to mid-publish GET requests made against the registry.
|
||||
(https://github.com/npm/npm-registry-client/commit/acbec48372bc1816c67c9e7cbf814cf50437ff93,
|
||||
[@isaacs](https://github.com/isaacs))
|
||||
|
||||
### v1.4.1 (2014-02-13):
|
||||
|
||||
* Fix `npm shrinkwrap` forgetting to shrinkwrap dependencies that were also
|
||||
development dependencies.
|
||||
([`9c575c5`](https://github.com/npm/npm/commit/9c575c56efa9b0c8b0d4a17cb9c1de3833004bcd),
|
||||
[@diwu1989](https://github.com/diwu1989))
|
||||
* Fixed publishing of pre-existing packages with uppercase characters in their
|
||||
name.
|
||||
(https://github.com/npm/npm-registry-client/commit/9345d3b6c3d8510dd5c4418f27ee1fce59acebad,
|
||||
[@isaacs](https://github.com/isaacs))
|
||||
|
||||
### v1.4.0 (2014-02-12):
|
||||
|
||||
* Remove `npm publish --force`. See
|
||||
https://github.com/npm/npmjs.org/issues/148.
|
||||
([@isaacs](https://github.com/isaacs),
|
||||
npm/npm-registry-client@2c8dba990de6a59af6545b75cc00a6dc12777c2a)
|
||||
* Other changes to the registry client related to saved configs and couch
|
||||
logins. ([@isaacs](https://github.com/isaacs);
|
||||
npm/npm-registry-client@25e2b019a1588155e5f87d035c27e79963b75951,
|
||||
npm/npm-registry-client@9e41e9101b68036e0f078398785f618575f3cdde,
|
||||
npm/npm-registry-client@2c8dba990de6a59af6545b75cc00a6dc12777c2a)
|
||||
* Show an error to the user when doing `npm update` and the `package.json`
|
||||
specifies a version that does not exist.
|
||||
([@evanlucas](https://github.com/evanlucas),
|
||||
[`027a33a`](https://github.com/npm/npm/commit/027a33a5c594124cc1d82ddec5aee2c18bc8dc32))
|
||||
* Fix some issues with cache ownership in certain installation configurations.
|
||||
([@outcoldman](https://github.com/outcoldman),
|
||||
[`a132690`](https://github.com/npm/npm/commit/a132690a2876cda5dcd1e4ca751f21dfcb11cb9e))
|
||||
* Fix issues where GitHub shorthand dependencies `user/repo` were not always
|
||||
treated the same as full Git URLs.
|
||||
([@robertkowalski](https://github.com/robertkowalski),
|
||||
https://github.com/meryn/normalize-package-data/commit/005d0b637aec1895117fcb4e3b49185eebf9e240)
|
||||
|
||||
### v1.3.26 (2014-02-02):
|
||||
|
||||
* Fixes and updates to publishing code
|
||||
([`735427a`](https://github.com/npm/npm/commit/735427a69ba4fe92aafa2d88f202aaa42920a9e2)
|
||||
and
|
||||
[`c0ac832`](https://github.com/npm/npm/commit/c0ac83224d49aa62e55577f8f27d53bbfd640dc5),
|
||||
[@isaacs](https://github.com/isaacs))
|
||||
* Fix `npm bugs` with no arguments.
|
||||
([`b99d465`](https://github.com/npm/npm/commit/b99d465221ac03bca30976cbf4d62ca80ab34091),
|
||||
[@Hoops](https://github.com/Hoops))
|
||||
|
||||
### v1.3.25 (2014-01-25):
|
||||
|
||||
* Remove gubblebum blocky font from documentation headers.
|
||||
([`6940c9a`](https://github.com/npm/npm/commit/6940c9a100160056dc6be8f54a7ad7fa8ceda7e2),
|
||||
[@isaacs](https://github.com/isaacs))
|
||||
|
||||
### v1.3.24 (2014-01-19):
|
||||
|
||||
* Make the search output prettier, with nice truncated columns, and a `--long`
|
||||
option to create wrapping columns.
|
||||
([`20439b2`](https://github.com/npm/npm/commit/20439b2) and
|
||||
[`3a6942d`](https://github.com/npm/npm/commit/3a6942d),
|
||||
[@timoxley](https://github.com/timoxley))
|
||||
* Support multiple packagenames in `npm docs`.
|
||||
([`823010b`](https://github.com/npm/npm/commit/823010b),
|
||||
[@timoxley](https://github.com/timoxley))
|
||||
* Fix the `npm adduser` bug regarding "Error: default value must be string or
|
||||
number" again. ([`b9b4248`](https://github.com/npm/npm/commit/b9b4248),
|
||||
[@isaacs](https://github.com/isaacs))
|
||||
* Fix `scripts` entries containing whitespaces on Windows.
|
||||
([`80282ed`](https://github.com/npm/npm/commit/80282ed),
|
||||
[@robertkowalski](https://github.com/robertkowalski))
|
||||
* Fix `npm update` for Git URLs that have credentials in them
|
||||
([`93fc364`](https://github.com/npm/npm/commit/93fc364),
|
||||
[@danielsantiago](https://github.com/danielsantiago))
|
||||
* Fix `npm install` overwriting `npm link`-ed dependencies when they are tagged
|
||||
Git dependencies. ([`af9bbd9`](https://github.com/npm/npm/commit/af9bbd9),
|
||||
[@evanlucas](https://github.com/evanlucas))
|
||||
* Remove `npm prune --production` since it buggily removed some dependencies
|
||||
that were necessary for production; see
|
||||
[#4509](https://github.com/npm/npm/issues/4509). Hopefully it can make its
|
||||
triumphant return, one day.
|
||||
([`1101b6a`](https://github.com/npm/npm/commit/1101b6a),
|
||||
[@isaacs](https://github.com/isaacs))
|
||||
|
||||
Dependency updates:
|
||||
* [`909cccf`](https://github.com/npm/npm/commit/909cccf) `read-package-json@1.1.6`
|
||||
* [`a3891b6`](https://github.com/npm/npm/commit/a3891b6) `rimraf@2.2.6`
|
||||
* [`ac6efbc`](https://github.com/npm/npm/commit/ac6efbc) `sha@1.2.3`
|
||||
* [`dd30038`](https://github.com/npm/npm/commit/dd30038) `node-gyp@0.12.2`
|
||||
* [`c8c3ebe`](https://github.com/npm/npm/commit/c8c3ebe) `npm-registry-client@0.3.3`
|
||||
* [`4315286`](https://github.com/npm/npm/commit/4315286) `npmconf@0.1.12`
|
||||
|
||||
### v1.3.23 (2014-01-03):
|
||||
|
||||
* Properly handle installations that contained a certain class of circular
|
||||
dependencies.
|
||||
([`5dc93e8`](https://github.com/npm/npm/commit/5dc93e8c82604c45b6067b1acf1c768e0bfce754),
|
||||
[@substack](https://github.com/substack))
|
||||
|
||||
### v1.3.22 (2013-12-25):
|
||||
|
||||
* Fix a critical bug in `npm adduser` that would manifest in the error message
|
||||
"Error: default value must be string or number."
|
||||
([`fba4bd2`](https://github.com/npm/npm/commit/fba4bd24bc2ab00ccfeda2043aa53af7d75ef7ce),
|
||||
[@isaacs](https://github.com/isaacs))
|
||||
* Allow `npm bugs` in the current directory to open the current package's bugs
|
||||
URL.
|
||||
([`d04cf64`](https://github.com/npm/npm/commit/d04cf6483932c693452f3f778c2fa90f6153a4af),
|
||||
[@evanlucas](https://github.com/evanlucas))
|
||||
* Several fixes to various error messages to include more useful or updated
|
||||
information.
|
||||
([`1e6f2a7`](https://github.com/npm/npm/commit/1e6f2a72ca058335f9f5e7ca22d01e1a8bb0f9f7),
|
||||
[`ff46366`](https://github.com/npm/npm/commit/ff46366bd40ff0ef33c7bac8400bc912c56201d1),
|
||||
[`8b4bb48`](https://github.com/npm/npm/commit/8b4bb4815d80a3612186dc5549d698e7b988eb03);
|
||||
[@rlidwka](https://github.com/rlidwka),
|
||||
[@evanlucas](https://github.com/evanlucas))
|
||||
|
||||
### v1.3.21 (2013-12-17):
|
||||
|
||||
* Fix a critical bug that prevented publishing due to incorrect hash
|
||||
calculation.
|
||||
([`4ca4a2c`](https://github.com/npm/npm-registry-client/commit/4ca4a2c6333144299428be6b572e2691aa59852e),
|
||||
[@dominictarr](https://github.com/dominictarr))
|
||||
|
||||
### v1.3.20 (2013-12-17):
|
||||
|
||||
* Fixes a critical bug in v1.3.19. Thankfully, due to that bug, no one could
|
||||
install npm v1.3.19 :)
|
||||
|
||||
### v1.3.19 (2013-12-16):
|
||||
|
||||
* Adds atomic PUTs for publishing packages, which should result in far fewer
|
||||
requests and less room for replication errors on the server-side.
|
||||
|
||||
### v1.3.18 (2013-12-16):
|
||||
|
||||
* Added an `--ignore-scripts` option, which will prevent `package.json` scripts
|
||||
from being run. Most notably, this will work on `npm install`, so e.g. `npm
|
||||
install --ignore-scripts` will not run preinstall and prepublish scripts.
|
||||
([`d7e67bf`](https://github.com/npm/npm/commit/d7e67bf0d94b085652ec1c87d595afa6f650a8f6),
|
||||
[@sqs](https://github.com/sqs))
|
||||
* Fixed a bug introduced in 1.3.16 that would manifest with certain cache
|
||||
configurations, by causing spurious errors saying "Adding a cache directory
|
||||
to the cache will make the world implode."
|
||||
([`966373f`](https://github.com/npm/npm/commit/966373fad8d741637f9744882bde9f6e94000865),
|
||||
[@domenic](https://github.com/domenic))
|
||||
* Re-fixed the multiple download of URL dependencies, whose fix was reverted in
|
||||
1.3.17.
|
||||
([`a362c3f`](https://github.com/npm/npm/commit/a362c3f1919987419ed8a37c8defa19d2e6697b0),
|
||||
[@spmason](https://github.com/spmason))
|
||||
|
||||
### v1.3.17 (2013-12-11):
|
||||
|
||||
* This release reverts
|
||||
[`644c2ff`](https://github.com/npm/npm/commit/644c2ff3e3d9c93764f7045762477f48864d64a7),
|
||||
which avoided re-downloading URL and shinkwrap dependencies when doing `npm
|
||||
install`. You can see the in-depth reasoning in
|
||||
[`d8c907e`](https://github.com/npm/npm/commit/d8c907edc2019b75cff0f53467e34e0ffd7e5fba);
|
||||
the problem was, that the patch changed the behavior of `npm install -f` to
|
||||
reinstall all dependencies.
|
||||
* A new version of the no-re-downloading fix has been submitted as
|
||||
[#4303](https://github.com/npm/npm/issues/4303) and will hopefully be
|
||||
included in the next release.
|
||||
|
||||
### v1.3.16 (2013-12-11):
|
||||
|
||||
* Git URL dependencies are now updated on `npm install`, fixing a two-year old
|
||||
bug
|
||||
([`5829ecf`](https://github.com/npm/npm/commit/5829ecf032b392d2133bd351f53d3c644961396b),
|
||||
[@robertkowalski](https://github.com/robertkowalski)). Additional progress on
|
||||
reducing the resulting Git-related I/O is tracked as
|
||||
[#4191](https://github.com/npm/npm/issues/4191), but for now, this will be a
|
||||
big improvement.
|
||||
* Added a `--json` mode to `npm outdated` to give a parseable output.
|
||||
([`0b6c9b7`](https://github.com/npm/npm/commit/0b6c9b7c8c5579f4d7d37a0c24d9b7a12ccbe5fe),
|
||||
[@yyx990803](https://github.com/yyx990803))
|
||||
* Made `npm outdated` much prettier and more useful. It now outputs a
|
||||
color-coded and easy-to-read table.
|
||||
([`fd3017f`](https://github.com/npm/npm/commit/fd3017fc3e9d42acf6394a5285122edb4dc16106),
|
||||
[@quimcalpe](https://github.com/quimcalpe))
|
||||
* Added the `--depth` option to `npm outdated`, so that e.g. you can do `npm
|
||||
outdated --depth=0` to show only top-level outdated dependencies.
|
||||
([`1d184ef`](https://github.com/npm/npm/commit/1d184ef3f4b4bc309d38e9128732e3e6fb46d49c),
|
||||
[@yyx990803](https://github.com/yyx990803))
|
||||
* Added a `--no-git-tag-version` option to `npm version`, for doing the usual
|
||||
job of `npm version` minus the Git tagging. This could be useful if you need
|
||||
to increase the version in other related files before actually adding the
|
||||
tag.
|
||||
([`59ca984`](https://github.com/npm/npm/commit/59ca9841ba4f4b2f11b8e72533f385c77ae9f8bd),
|
||||
[@evanlucas](https://github.com/evanlucas))
|
||||
* Made `npm repo` and `npm docs` work without any arguments, adding them to the
|
||||
list of npm commands that work on the package in the current directory when
|
||||
invoked without arguments.
|
||||
([`bf9048e`](https://github.com/npm/npm/commit/bf9048e2fa16d43fbc4b328d162b0a194ca484e8),
|
||||
[@robertkowalski](https://github.com/robertkowalski);
|
||||
[`07600d0`](https://github.com/npm/npm/commit/07600d006c652507cb04ac0dae9780e35073dd67),
|
||||
[@wilmoore](https://github.com/wilmoore)). There are a few other commands we
|
||||
still want to implement this for; see
|
||||
[#4204](https://github.com/npm/npm/issues/4204).
|
||||
* Pass through the `GIT_SSL_NO_VERIFY` environment variable to Git, if it is
|
||||
set; we currently do this with a few other environment variables, but we
|
||||
missed that one.
|
||||
([`c625de9`](https://github.com/npm/npm/commit/c625de91770df24c189c77d2e4bc821f2265efa8),
|
||||
[@arikon](https://github.com/arikon))
|
||||
* Fixed `npm dedupe` on Windows due to incorrect path separators being used
|
||||
([`7677de4`](https://github.com/npm/npm/commit/7677de4583100bc39407093ecc6bc13715bf8161),
|
||||
[@mcolyer](https://github.com/mcolyer)).
|
||||
* Fixed the `npm help` command when multiple words were searched for; it
|
||||
previously gave a `ReferenceError`.
|
||||
([`6a28dd1`](https://github.com/npm/npm/commit/6a28dd147c6957a93db12b1081c6e0da44fe5e3c),
|
||||
[@dereckson](https://github.com/dereckson))
|
||||
* Stopped re-downloading URL and shrinkwrap dependencies, as demonstrated in
|
||||
[#3463](https://github.com/npm/npm/issues/3463)
|
||||
([`644c2ff`](https://github.com/isaacs/npm/commit/644c2ff3e3d9c93764f7045762477f48864d64a7),
|
||||
[@spmason](https://github.com/spmason)). You can use the `--force` option to
|
||||
force re-download and installation of all dependencies.
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,33 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# set configurations that will be "sticky" on this system,
|
||||
# surviving npm self-updates.
|
||||
|
||||
CONFIGS=()
|
||||
i=0
|
||||
|
||||
# get the location of this file.
|
||||
unset CDPATH
|
||||
CONFFILE=$(cd $(dirname "$0"); pwd -P)/npmrc
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
conf="$1"
|
||||
case $conf in
|
||||
--help)
|
||||
echo "./configure --param=value ..."
|
||||
exit 0
|
||||
;;
|
||||
--*)
|
||||
CONFIGS[$i]="${conf:2}"
|
||||
;;
|
||||
*)
|
||||
CONFIGS[$i]="$conf"
|
||||
;;
|
||||
esac
|
||||
let i++
|
||||
shift
|
||||
done
|
||||
|
||||
for c in "${CONFIGS[@]}"; do
|
||||
echo "$c" >> "$CONFFILE"
|
||||
done
|
||||
@ -1,22 +0,0 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 gatsbyjs
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
@ -1,93 +0,0 @@
|
||||
---
|
||||
section: cli-commands
|
||||
title: npm-access
|
||||
description: Set access level on published packages
|
||||
---
|
||||
|
||||
# npm-access(1)
|
||||
|
||||
## Set access level on published packages
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm access public [<package>]
|
||||
npm access restricted [<package>]
|
||||
|
||||
npm access grant <read-only|read-write> <scope:team> [<package>]
|
||||
npm access revoke <scope:team> [<package>]
|
||||
|
||||
npm access 2fa-required [<package>]
|
||||
npm access 2fa-not-required [<package>]
|
||||
|
||||
npm access ls-packages [<user>|<scope>|<scope:team>]
|
||||
npm access ls-collaborators [<package> [<user>]]
|
||||
npm access edit [<package>]
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
Used to set access controls on private packages.
|
||||
|
||||
For all of the subcommands, `npm access` will perform actions on the packages
|
||||
in the current working directory if no package name is passed to the
|
||||
subcommand.
|
||||
|
||||
* public / restricted:
|
||||
Set a package to be either publicly accessible or restricted.
|
||||
|
||||
* grant / revoke:
|
||||
Add or remove the ability of users and teams to have read-only or read-write
|
||||
access to a package.
|
||||
|
||||
* 2fa-required / 2fa-not-required:
|
||||
Configure whether a package requires that anyone publishing it have two-factor
|
||||
authentication enabled on their account.
|
||||
|
||||
* ls-packages:
|
||||
Show all of the packages a user or a team is able to access, along with the
|
||||
access level, except for read-only public packages (it won't print the whole
|
||||
registry listing)
|
||||
|
||||
* ls-collaborators:
|
||||
Show all of the access privileges for a package. Will only show permissions
|
||||
for packages to which you have at least read access. If `<user>` is passed in,
|
||||
the list is filtered only to teams _that_ user happens to belong to.
|
||||
|
||||
* edit:
|
||||
Set the access privileges for a package at once using `$EDITOR`.
|
||||
|
||||
### Details
|
||||
|
||||
`npm access` always operates directly on the current registry, configurable
|
||||
from the command line using `--registry=<registry url>`.
|
||||
|
||||
Unscoped packages are *always public*.
|
||||
|
||||
Scoped packages *default to restricted*, but you can either publish them as
|
||||
public using `npm publish --access=public`, or set their access as public using
|
||||
`npm access public` after the initial publish.
|
||||
|
||||
You must have privileges to set the access of a package:
|
||||
|
||||
* You are an owner of an unscoped or scoped package.
|
||||
* You are a member of the team that owns a scope.
|
||||
* You have been given read-write privileges for a package, either as a member
|
||||
of a team or directly as an owner.
|
||||
|
||||
If you have two-factor authentication enabled then you'll have to pass in an
|
||||
otp with `--otp` when making access changes.
|
||||
|
||||
If your account is not paid, then attempts to publish scoped packages will fail
|
||||
with an HTTP 402 status code (logically enough), unless you use
|
||||
`--access=public`.
|
||||
|
||||
Management of teams and team memberships is done with the `npm team` command.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`libnpmaccess`](https://npm.im/libnpmaccess)
|
||||
* [npm team](/cli-commands/npm-team)
|
||||
* [npm publish](/cli-commands/npm-publish)
|
||||
* [npm config](/cli-commands/npm-config)
|
||||
* [npm registry](/using-npm/registry)
|
||||
@ -1,95 +0,0 @@
|
||||
---
|
||||
section: cli-commands
|
||||
title: npm-adduser
|
||||
description: Set access level on published packages
|
||||
---
|
||||
|
||||
# npm-adduser(1)
|
||||
|
||||
## Add a registry user account
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm adduser [--registry=url] [--scope=@orgname] [--always-auth] [--auth-type=legacy]
|
||||
|
||||
aliases: login, add-user
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
Create or verify a user named `<username>` in the specified registry, and
|
||||
save the credentials to the `.npmrc` file. If no registry is specified,
|
||||
the default registry will be used (see [`config`](/using-npm/config)).
|
||||
|
||||
The username, password, and email are read in from prompts.
|
||||
|
||||
To reset your password, go to <https://www.npmjs.com/forgot>
|
||||
|
||||
To change your email address, go to <https://www.npmjs.com/email-edit>
|
||||
|
||||
You may use this command multiple times with the same user account to
|
||||
authorize on a new machine. When authenticating on a new machine,
|
||||
the username, password and email address must all match with
|
||||
your existing record.
|
||||
|
||||
`npm login` is an alias to `adduser` and behaves exactly the same way.
|
||||
|
||||
### Configuration
|
||||
|
||||
#### registry
|
||||
|
||||
Default: https://registry.npmjs.org/
|
||||
|
||||
The base URL of the npm package registry. If `scope` is also specified,
|
||||
this registry will only be used for packages with that scope. `scope` defaults
|
||||
to the scope of the project directory you're currently in, if any. See [`scope`](/using-npm/scope).
|
||||
|
||||
#### scope
|
||||
|
||||
Default: none
|
||||
|
||||
If specified, the user and login credentials given will be associated
|
||||
with the specified scope. See [`scope`](/using-npm/scope). You can use both at the same time,
|
||||
e.g.
|
||||
|
||||
```bash
|
||||
npm adduser --registry=http://myregistry.example.com --scope=@myco
|
||||
```
|
||||
|
||||
This will set a registry for the given scope and login or create a user for
|
||||
that registry at the same time.
|
||||
|
||||
#### always-auth
|
||||
|
||||
Default: false
|
||||
|
||||
If specified, save configuration indicating that all requests to the given
|
||||
registry should include authorization information. Useful for private
|
||||
registries. Can be used with `--registry` and / or `--scope`, e.g.
|
||||
|
||||
```bash
|
||||
npm adduser --registry=http://private-registry.example.com --always-auth
|
||||
```
|
||||
|
||||
This will ensure that all requests to that registry (including for tarballs)
|
||||
include an authorization header. This setting may be necessary for use with
|
||||
private registries where metadata and package tarballs are stored on hosts with
|
||||
different hostnames. See `always-auth` in [`config`](/using-npm/config) for more details on always-auth. Registry-specific configuration of `always-auth` takes precedence over any global configuration.
|
||||
|
||||
#### auth-type
|
||||
|
||||
* Default: `'legacy'`
|
||||
* Type: `'legacy'`, `'sso'`, `'saml'`, `'oauth'`
|
||||
|
||||
What authentication strategy to use with `adduser`/`login`. Some npm registries
|
||||
(for example, npmE) might support alternative auth strategies besides classic
|
||||
username/password entry in legacy npm.
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm registry](/using-npm/registry)
|
||||
* [npm config](/cli-commands/npm-config)
|
||||
* [npmrc](/configuring-npm/npmrc)
|
||||
* [npm owner](/cli-commands/npm-owner)
|
||||
* [npm whoami](/cli-commands/npm-whoami)
|
||||
@ -1,136 +0,0 @@
|
||||
---
|
||||
section: cli-commands
|
||||
title: npm-audit
|
||||
description: Run a security audit
|
||||
---
|
||||
|
||||
# npm-audit(1)
|
||||
|
||||
## Run a security audit
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm audit [--json|--parseable|--audit-level=(low|moderate|high|critical)]
|
||||
npm audit fix [--force|--package-lock-only|--dry-run]
|
||||
|
||||
common options: [--production] [--only=(dev|prod)]
|
||||
```
|
||||
|
||||
### Examples
|
||||
|
||||
Scan your project for vulnerabilities and automatically install any compatible
|
||||
updates to vulnerable dependencies:
|
||||
```bash
|
||||
$ npm audit fix
|
||||
```
|
||||
|
||||
Run `audit fix` without modifying `node_modules`, but still updating the
|
||||
pkglock:
|
||||
```bash
|
||||
$ npm audit fix --package-lock-only
|
||||
```
|
||||
|
||||
Skip updating `devDependencies`:
|
||||
```bash
|
||||
$ npm audit fix --only=prod
|
||||
```
|
||||
|
||||
Have `audit fix` install semver-major updates to toplevel dependencies, not just
|
||||
semver-compatible ones:
|
||||
```bash
|
||||
$ npm audit fix --force
|
||||
```
|
||||
|
||||
Do a dry run to get an idea of what `audit fix` will do, and _also_ output
|
||||
install information in JSON format:
|
||||
```bash
|
||||
$ npm audit fix --dry-run --json
|
||||
```
|
||||
|
||||
Scan your project for vulnerabilities and just show the details, without fixing
|
||||
anything:
|
||||
```bash
|
||||
$ npm audit
|
||||
```
|
||||
|
||||
Get the detailed audit report in JSON format:
|
||||
```bash
|
||||
$ npm audit --json
|
||||
```
|
||||
|
||||
Get the detailed audit report in plain text result, separated by tab characters, allowing for
|
||||
future reuse in scripting or command line post processing, like for example, selecting
|
||||
some of the columns printed:
|
||||
```bash
|
||||
$ npm audit --parseable
|
||||
```
|
||||
|
||||
To parse columns, you can use for example `awk`, and just print some of them:
|
||||
```bash
|
||||
$ npm audit --parseable | awk -F $'\t' '{print $1,$4}'
|
||||
```
|
||||
|
||||
Fail an audit only if the results include a vulnerability with a level of moderate or higher:
|
||||
```bash
|
||||
$ npm audit --audit-level=moderate
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
The audit command submits a description of the dependencies configured in
|
||||
your project to your default registry and asks for a report of known
|
||||
vulnerabilities. The report returned includes instructions on how to act on
|
||||
this information. The command will exit with a 0 exit code if no
|
||||
vulnerabilities were found.
|
||||
|
||||
You can also have npm automatically fix the vulnerabilities by running `npm
|
||||
audit fix`. Note that some vulnerabilities cannot be fixed automatically and
|
||||
will require manual intervention or review. Also note that since `npm audit fix`
|
||||
runs a full-fledged `npm install` under the hood, all configs that apply to the
|
||||
installer will also apply to `npm install` -- so things like `npm audit fix
|
||||
--package-lock-only` will work as expected.
|
||||
|
||||
By default, the audit command will exit with a non-zero code if any vulnerability
|
||||
is found. It may be useful in CI environments to include the `--audit-level` parameter
|
||||
to specify the minimum vulnerability level that will cause the command to fail. This
|
||||
option does not filter the report output, it simply changes the command's failure
|
||||
threshold.
|
||||
|
||||
### Content Submitted
|
||||
|
||||
* npm_version
|
||||
* node_version
|
||||
* platform
|
||||
* node_env
|
||||
* A scrubbed version of your package-lock.json or npm-shrinkwrap.json
|
||||
|
||||
#### Scrubbing
|
||||
|
||||
In order to ensure that potentially sensitive information is not included in
|
||||
the audit data bundle, some dependencies may have their names (and sometimes
|
||||
versions) replaced with opaque non-reversible identifiers. It is done for
|
||||
the following dependency types:
|
||||
|
||||
* Any module referencing a scope that is configured for a non-default
|
||||
registry has its name scrubbed. (That is, a scope you did a `npm login --scope=@ourscope` for.)
|
||||
* All git dependencies have their names and specifiers scrubbed.
|
||||
* All remote tarball dependencies have their names and specifiers scrubbed.
|
||||
* All local directory and tarball dependencies have their names and specifiers scrubbed.
|
||||
|
||||
The non-reversible identifiers are a sha256 of a session-specific UUID and the
|
||||
value being replaced, ensuring a consistent value within the payload that is
|
||||
different between runs.
|
||||
|
||||
### Exit Code
|
||||
|
||||
The `npm audit` command will exit with a 0 exit code if no vulnerabilities were found.
|
||||
|
||||
If vulnerabilities were found the exit code will depend on the `audit-level`
|
||||
configuration setting.
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm install](/cli-commands/npm-install)
|
||||
* [package-locks](/configuring-npm/package-locks)
|
||||
* [config](/using-npm/config)
|
||||
@ -1,26 +0,0 @@
|
||||
---
|
||||
section: cli-commands
|
||||
title: npm-bin
|
||||
description: Display npm bin folder
|
||||
---
|
||||
|
||||
# npm-bin(1)
|
||||
|
||||
## Display npm bin folder
|
||||
|
||||
### Synopsis
|
||||
```bash
|
||||
npm bin [-g|--global]
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
Print the folder where npm will install executables.
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm prefix](/cli-commands/npm-prefix)
|
||||
* [npm root](/cli-commands/npm-root)
|
||||
* [npm folders](/configuring-npm/folders)
|
||||
* [npm config](/cli-commands/npm-config)
|
||||
* [npmrc](/configuring-npm/npmrc)
|
||||
@ -1,50 +0,0 @@
|
||||
---
|
||||
section: cli-commands
|
||||
title: npm-bugs
|
||||
description: Bugs for a package in a web browser maybe
|
||||
---
|
||||
|
||||
# npm-bugs(1)
|
||||
|
||||
## Bugs for a package in a web browser maybe
|
||||
|
||||
### Synopsis
|
||||
```bash
|
||||
npm bugs [<pkgname>]
|
||||
|
||||
aliases: issues
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
This command tries to guess at the likely location of a package's
|
||||
bug tracker URL, and then tries to open it using the `--browser`
|
||||
config param. If no package name is provided, it will search for
|
||||
a `package.json` in the current folder and use the `name` property.
|
||||
|
||||
### Configuration
|
||||
|
||||
#### browser
|
||||
|
||||
* Default: OS X: `"open"`, Windows: `"start"`, Others: `"xdg-open"`
|
||||
* Type: String
|
||||
|
||||
The browser that is called by the `npm bugs` command to open websites.
|
||||
|
||||
#### registry
|
||||
|
||||
* Default: https://registry.npmjs.org/
|
||||
* Type: url
|
||||
|
||||
The base URL of the npm package registry.
|
||||
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm docs](/cli-commands/npm-docs)
|
||||
* [npm view](/cli-commands/npm-view)
|
||||
* [npm publish](/cli-commands/npm-publish)
|
||||
* [npm registry](/using-npm/registry)
|
||||
* [npm config](/cli-commands/npm-config)
|
||||
* [npmrc](/configuring-npm/npmrc)
|
||||
* [package.json](/configuring-npm/package-json)
|
||||
@ -1,34 +0,0 @@
|
||||
---
|
||||
section: cli-commands
|
||||
title: npm-build
|
||||
description: Build a package
|
||||
---
|
||||
|
||||
# npm-build(1)
|
||||
|
||||
## Build a package
|
||||
|
||||
### Synopsis
|
||||
```shell
|
||||
npm build [<package-folder>]
|
||||
```
|
||||
|
||||
* `<package-folder>`:
|
||||
A folder containing a `package.json` file in its root.
|
||||
|
||||
### Description
|
||||
|
||||
This is the plumbing command called by `npm link` and `npm install`.
|
||||
|
||||
It should generally be called during installation, but if you need to run it
|
||||
directly, run:
|
||||
```bash
|
||||
npm run-script build
|
||||
```
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm install](/cli-commands/npm-install)
|
||||
* [npm link](/cli-commands/npm-link)
|
||||
* [npm scripts](/using-npm/scripts)
|
||||
* [package.json](/configuring-npm/package-json)
|
||||
@ -1,21 +0,0 @@
|
||||
---
|
||||
section: cli-commands
|
||||
title: npm-bundle
|
||||
description: REMOVED
|
||||
---
|
||||
|
||||
# npm-bundle(1)
|
||||
|
||||
## REMOVED
|
||||
|
||||
### Description
|
||||
|
||||
The `npm bundle` command has been removed in 1.0, for the simple reason
|
||||
that it is no longer necessary, as the default behavior is now to
|
||||
install packages into the local space.
|
||||
|
||||
Just use `npm install` now to do what `npm bundle` used to do.
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm install](/cli-commands/npm-install)
|
||||
@ -1,91 +0,0 @@
|
||||
---
|
||||
section: cli-commands
|
||||
title: npm-cache
|
||||
description: Manipulates packages cache
|
||||
---
|
||||
|
||||
# npm-cache(1)
|
||||
|
||||
## Manipulates packages cache
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm cache add <tarball file>
|
||||
npm cache add <folder>
|
||||
npm cache add <tarball url>
|
||||
npm cache add <name>@<version>
|
||||
|
||||
npm cache clean [<path>]
|
||||
aliases: npm cache clear, npm cache rm
|
||||
|
||||
npm cache verify
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
Used to add, list, or clean the npm cache folder.
|
||||
|
||||
* add:
|
||||
Add the specified package to the local cache. This command is primarily
|
||||
intended to be used internally by npm, but it can provide a way to
|
||||
add data to the local installation cache explicitly.
|
||||
|
||||
* clean:
|
||||
Delete all data out of the cache folder.
|
||||
|
||||
* verify:
|
||||
Verify the contents of the cache folder, garbage collecting any unneeded data,
|
||||
and verifying the integrity of the cache index and all cached data.
|
||||
|
||||
### Details
|
||||
|
||||
npm stores cache data in an opaque directory within the configured `cache`,
|
||||
named `_cacache`. This directory is a `cacache`-based content-addressable cache
|
||||
that stores all http request data as well as other package-related data. This
|
||||
directory is primarily accessed through `pacote`, the library responsible for
|
||||
all package fetching as of npm@5.
|
||||
|
||||
All data that passes through the cache is fully verified for integrity on both
|
||||
insertion and extraction. Cache corruption will either trigger an error, or
|
||||
signal to `pacote` that the data must be refetched, which it will do
|
||||
automatically. For this reason, it should never be necessary to clear the cache
|
||||
for any reason other than reclaiming disk space, thus why `clean` now requires
|
||||
`--force` to run.
|
||||
|
||||
There is currently no method exposed through npm to inspect or directly manage
|
||||
the contents of this cache. In order to access it, `cacache` must be used
|
||||
directly.
|
||||
|
||||
npm will not remove data by itself: the cache will grow as new packages are
|
||||
installed.
|
||||
|
||||
### A note about the cache's design
|
||||
|
||||
The npm cache is strictly a cache: it should not be relied upon as a persistent
|
||||
and reliable data store for package data. npm makes no guarantee that a
|
||||
previously-cached piece of data will be available later, and will automatically
|
||||
delete corrupted contents. The primary guarantee that the cache makes is that,
|
||||
if it does return data, that data will be exactly the data that was inserted.
|
||||
|
||||
To run an offline verification of existing cache contents, use `npm cache
|
||||
verify`.
|
||||
|
||||
### Configuration
|
||||
|
||||
#### cache
|
||||
|
||||
Default: `~/.npm` on Posix, or `%AppData%/npm-cache` on Windows.
|
||||
|
||||
The root cache folder.
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm folders](/configuring-npm/folders)
|
||||
* [npm config](/cli-commands/npm-config)
|
||||
* [npmrc](/configuring-npm/npmrc)
|
||||
* [npm install](/cli-commands/npm-install)
|
||||
* [npm publish](/cli-commands/npm-publish)
|
||||
* [npm pack](/cli-commands/npm-pack)
|
||||
* https://npm.im/cacache
|
||||
* https://npm.im/pacote
|
||||
@ -1,67 +0,0 @@
|
||||
---
|
||||
section: cli-commands
|
||||
title: npm-ci
|
||||
description: Install a project with a clean slate
|
||||
---
|
||||
|
||||
# npm-ci(1)
|
||||
|
||||
## Install a project with a clean slate
|
||||
|
||||
### Synopsis
|
||||
```bash
|
||||
npm ci
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
Make sure you have a package-lock and an up-to-date install:
|
||||
|
||||
```bash
|
||||
$ cd ./my/npm/project
|
||||
$ npm install
|
||||
added 154 packages in 10s
|
||||
$ ls | grep package-lock
|
||||
```
|
||||
|
||||
Run `npm ci` in that project
|
||||
|
||||
```bash
|
||||
$ npm ci
|
||||
added 154 packages in 5s
|
||||
```
|
||||
|
||||
Configure Travis to build using `npm ci` instead of `npm install`:
|
||||
|
||||
```bash
|
||||
# .travis.yml
|
||||
install:
|
||||
- npm ci
|
||||
# keep the npm cache around to speed up installs
|
||||
cache:
|
||||
directories:
|
||||
- "$HOME/.npm"
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
This command is similar to [`npm install`](/cli-commands/npm-install), except it's meant to be used in
|
||||
automated environments such as test platforms, continuous integration, and
|
||||
deployment -- or any situation where you want to make sure you're doing a clean
|
||||
install of your dependencies. It can be significantly faster than a regular npm
|
||||
install by skipping certain user-oriented features. It is also more strict than
|
||||
a regular install, which can help catch errors or inconsistencies caused by the
|
||||
incrementally-installed local environments of most npm users.
|
||||
|
||||
In short, the main differences between using `npm install` and `npm ci` are:
|
||||
|
||||
* The project **must** have an existing `package-lock.json` or `npm-shrinkwrap.json`.
|
||||
* If dependencies in the package lock do not match those in `package.json`, `npm ci` will exit with an error, instead of updating the package lock.
|
||||
* `npm ci` can only install entire projects at a time: individual dependencies cannot be added with this command.
|
||||
* If a `node_modules` is already present, it will be automatically removed before `npm ci` begins its install.
|
||||
* It will never write to `package.json` or any of the package-locks: installs are essentially frozen.
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm install](/cli-commands/npm-install)
|
||||
* [package-locks](/configuring-npm/package-locks)
|
||||
@ -1,42 +0,0 @@
|
||||
---
|
||||
section: cli-commands
|
||||
title: npm-completion
|
||||
description: Tab Completion for npm
|
||||
---
|
||||
|
||||
# npm-completion(1)
|
||||
|
||||
## Tab Completion for npm
|
||||
|
||||
### Synopsis
|
||||
```bash
|
||||
source <(npm completion)
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
Enables tab-completion in all npm commands.
|
||||
|
||||
The synopsis above
|
||||
loads the completions into your current shell. Adding it to
|
||||
your ~/.bashrc or ~/.zshrc will make the completions available
|
||||
everywhere:
|
||||
|
||||
```bash
|
||||
npm completion >> ~/.bashrc
|
||||
npm completion >> ~/.zshrc
|
||||
```
|
||||
|
||||
You may of course also pipe the output of `npm completion` to a file
|
||||
such as `/usr/local/etc/bash_completion.d/npm` or
|
||||
`/etc/bash_completion.d/npm` if you have a system that will read
|
||||
that file for you.
|
||||
|
||||
When `COMP_CWORD`, `COMP_LINE`, and `COMP_POINT` are defined in the
|
||||
environment, `npm completion` acts in "plumbing mode", and outputs
|
||||
completions based on the arguments.
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm developers](/using-npm/developers)
|
||||
* [npm](/cli-commands/npm)
|
||||
@ -1,85 +0,0 @@
|
||||
---
|
||||
section: cli-commands
|
||||
title: npm-config
|
||||
description: Manage the npm configuration files
|
||||
---
|
||||
|
||||
# npm-config(1)
|
||||
|
||||
## Manage the npm configuration files
|
||||
|
||||
### Synopsis
|
||||
```bash
|
||||
npm config set <key> <value> [-g|--global]
|
||||
npm config get <key>
|
||||
npm config delete <key>
|
||||
npm config list [-l] [--json]
|
||||
npm config edit
|
||||
npm get <key>
|
||||
npm set <key> <value> [-g|--global]
|
||||
|
||||
aliases: c
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
npm gets its config settings from the command line, environment
|
||||
variables, `npmrc` files, and in some cases, the `package.json` file.
|
||||
|
||||
See [npmrc](/configuring-npm/npmrc) for more information about the npmrc files.
|
||||
|
||||
See [config](/using-npm/config) for a more thorough discussion of the mechanisms
|
||||
involved.
|
||||
|
||||
The `npm config` command can be used to update and edit the contents
|
||||
of the user and global npmrc files.
|
||||
|
||||
### Sub-commands
|
||||
|
||||
Config supports the following sub-commands:
|
||||
|
||||
#### set
|
||||
```bash
|
||||
npm config set key value
|
||||
```
|
||||
Sets the config key to the value.
|
||||
|
||||
If value is omitted, then it sets it to "true".
|
||||
|
||||
#### get
|
||||
```bash
|
||||
npm config get key
|
||||
```
|
||||
|
||||
Echo the config value to stdout.
|
||||
|
||||
#### list
|
||||
```bash
|
||||
npm config list
|
||||
```
|
||||
|
||||
Show all the config settings. Use `-l` to also show defaults. Use `--json`
|
||||
to show the settings in json format.
|
||||
|
||||
#### delete
|
||||
```bash
|
||||
npm config delete key
|
||||
```
|
||||
|
||||
Deletes the key from all configuration files.
|
||||
|
||||
#### edit
|
||||
```bash
|
||||
npm config edit
|
||||
```
|
||||
|
||||
Opens the config file in an editor. Use the `--global` flag to edit the
|
||||
global config.
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm folders](/configuring-npm/folders)
|
||||
* [npm config](/cli-commands/npm-config)
|
||||
* [package.json](/configuring-npm/package-json)
|
||||
* [npmrc](/configuring-npm/npmrc)
|
||||
* [npm](/cli-commands/npm)
|
||||
@ -1,67 +0,0 @@
|
||||
---
|
||||
section: cli-commands
|
||||
title: npm-dedupe
|
||||
description: Reduce duplication
|
||||
---
|
||||
|
||||
# npm-dedupe(1)
|
||||
|
||||
## Reduce duplication
|
||||
|
||||
### Synopsis
|
||||
```bash
|
||||
npm dedupe
|
||||
npm ddp
|
||||
|
||||
aliases: find-dupes, ddp
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
Searches the local package tree and attempts to simplify the overall
|
||||
structure by moving dependencies further up the tree, where they can
|
||||
be more effectively shared by multiple dependent packages.
|
||||
|
||||
For example, consider this dependency graph:
|
||||
|
||||
```bash
|
||||
a
|
||||
+-- b <-- depends on c@1.0.x
|
||||
| `-- c@1.0.3
|
||||
`-- d <-- depends on c@~1.0.9
|
||||
`-- c@1.0.10
|
||||
```
|
||||
|
||||
In this case, `npm dedupe` will transform the tree to:
|
||||
|
||||
```bash
|
||||
a
|
||||
+-- b
|
||||
+-- d
|
||||
`-- c@1.0.10
|
||||
```
|
||||
|
||||
Because of the hierarchical nature of node's module lookup, b and d
|
||||
will both get their dependency met by the single c package at the root
|
||||
level of the tree.
|
||||
|
||||
The deduplication algorithm walks the tree, moving each dependency as far
|
||||
up in the tree as possible, even if duplicates are not found. This will
|
||||
result in both a flat and deduplicated tree.
|
||||
|
||||
If a suitable version exists at the target location in the tree
|
||||
already, then it will be left untouched, but the other duplicates will
|
||||
be deleted.
|
||||
|
||||
Arguments are ignored. Dedupe always acts on the entire tree.
|
||||
|
||||
Modules
|
||||
|
||||
Note that this operation transforms the dependency tree, but will never
|
||||
result in new modules being installed.
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm ls](/cli-commands/npm-ls)
|
||||
* [npm update](/cli-commands/npm-update)
|
||||
* [npm install](/cli-commands/npm-install)
|
||||
@ -1,36 +0,0 @@
|
||||
---
|
||||
section: cli-commands
|
||||
title: npm-deprecate
|
||||
description: Deprecate a version of a package
|
||||
---
|
||||
# npm-deprecate(1)
|
||||
|
||||
## Deprecate a version of a package
|
||||
|
||||
### Synopsis
|
||||
```bash
|
||||
npm deprecate <pkg>[@<version>] <message>
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
This command will update the npm registry entry for a package, providing
|
||||
a deprecation warning to all who attempt to install it.
|
||||
|
||||
It works on [version ranges](https://semver.npmjs.com/) as well as specific
|
||||
versions, so you can do something like this:
|
||||
```bash
|
||||
npm deprecate my-thing@"< 0.2.3" "critical bug fixed in v0.2.3"
|
||||
```
|
||||
|
||||
Note that you must be the package owner to deprecate something. See the
|
||||
`owner` and `adduser` help topics.
|
||||
|
||||
To un-deprecate a package, specify an empty string (`""`) for the `message`
|
||||
argument. Note that you must use double quotes with no space between them to
|
||||
format an empty string.
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm publish](/cli-commands/npm-publish)
|
||||
* [npm registry](/using-npm/registry)
|
||||
@ -1,52 +0,0 @@
|
||||
---
|
||||
section: cli-commands
|
||||
title: npm-docs
|
||||
description: Docs for a package in a web browser maybe
|
||||
---
|
||||
|
||||
# npm-docs(1)
|
||||
|
||||
## Docs for a package in a web browser maybe
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm docs [<pkgname> [<pkgname> ...]]
|
||||
npm docs .
|
||||
npm home [<pkgname> [<pkgname> ...]]
|
||||
npm home .
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
This command tries to guess at the likely location of a package's
|
||||
documentation URL, and then tries to open it using the `--browser`
|
||||
config param. You can pass multiple package names at once. If no
|
||||
package name is provided, it will search for a `package.json` in
|
||||
the current folder and use the `name` property.
|
||||
|
||||
### Configuration
|
||||
|
||||
#### browser
|
||||
|
||||
* Default: OS X: `"open"`, Windows: `"start"`, Others: `"xdg-open"`
|
||||
* Type: String
|
||||
|
||||
The browser that is called by the `npm docs` command to open websites.
|
||||
|
||||
#### registry
|
||||
|
||||
* Default: https://registry.npmjs.org/
|
||||
* Type: url
|
||||
|
||||
The base URL of the npm package registry.
|
||||
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm view](/cli-commands/npm-view)
|
||||
* [npm publish](/cli-commands/npm-publish)
|
||||
* [npm registry](/using-npm/registry)
|
||||
* [npm config](/cli-commands/npm-config)
|
||||
* [npmrc](/configuring-npm/npmrc)
|
||||
* [package.json](/configuring-npm/package-json)
|
||||
@ -1,47 +0,0 @@
|
||||
---
|
||||
section: cli-commands
|
||||
title: npm-edit
|
||||
description: Edit an installed package
|
||||
---
|
||||
|
||||
# npm-edit(1)
|
||||
|
||||
## Edit an installed package
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm edit <pkg>[/<subpkg>...]
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
Selects a (sub)dependency in the current
|
||||
working directory and opens the package folder in the default editor
|
||||
(or whatever you've configured as the npm `editor` config -- see
|
||||
[`npm-config`](npm-config).)
|
||||
|
||||
After it has been edited, the package is rebuilt so as to pick up any
|
||||
changes in compiled packages.
|
||||
|
||||
For instance, you can do `npm install connect` to install connect
|
||||
into your package, and then `npm edit connect` to make a few
|
||||
changes to your locally installed copy.
|
||||
|
||||
### Configuration
|
||||
|
||||
#### editor
|
||||
|
||||
* Default: `EDITOR` environment variable if set, or `"vi"` on Posix,
|
||||
or `"notepad"` on Windows.
|
||||
* Type: path
|
||||
|
||||
The command to run for `npm edit` or `npm config edit`.
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm folders](/configuring-npm/folders)
|
||||
* [npm explore](/cli-commands/npm-explore)
|
||||
* [npm install](/cli-commands/npm-install)
|
||||
* [npm config](/cli-commands/npm-config)
|
||||
* [npmrc](/configuring-npm/npmrc)
|
||||
@ -1,50 +0,0 @@
|
||||
---
|
||||
section: cli-commands
|
||||
title: npm-explore
|
||||
description: Browse an installed package
|
||||
---
|
||||
|
||||
# npm-explore(1)
|
||||
|
||||
## Browse an installed package
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm explore <pkg> [ -- <command>]
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
Spawn a subshell in the directory of the installed package specified.
|
||||
|
||||
If a command is specified, then it is run in the subshell, which then
|
||||
immediately terminates.
|
||||
|
||||
This is particularly handy in the case of git submodules in the
|
||||
`node_modules` folder:
|
||||
|
||||
```bash
|
||||
npm explore some-dependency -- git pull origin master
|
||||
```
|
||||
|
||||
Note that the package is *not* automatically rebuilt afterwards, so be
|
||||
sure to use `npm rebuild <pkg>` if you make any changes.
|
||||
|
||||
### Configuration
|
||||
|
||||
#### shell
|
||||
|
||||
* Default: SHELL environment variable, or "bash" on Posix, or "cmd" on
|
||||
Windows
|
||||
* Type: path
|
||||
|
||||
The shell to run for the `npm explore` command.
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm folders](/configuring-npm/folders)
|
||||
* [npm edit](/cli-commands/npm-edit)
|
||||
* [npm rebuild](/cli-commands/npm-rebuild)
|
||||
* [npm build](/cli-commands/npm-build)
|
||||
* [npm install](/cli-commands/npm-install)
|
||||
@ -1,68 +0,0 @@
|
||||
---
|
||||
section: cli-commands
|
||||
title: npm-fund
|
||||
description: Retrieve funding information
|
||||
---
|
||||
|
||||
# npm-fund(1)
|
||||
|
||||
## Retrieve funding information
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm fund [<pkg>]
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
This command retrieves information on how to fund the dependencies of
|
||||
a given project. If no package name is provided, it will list all
|
||||
dependencies that are looking for funding in a tree-structure in which
|
||||
are listed the type of funding and the url to visit. If a package name
|
||||
is provided then it tries to open its funding url using the `--browser`
|
||||
config param; if there are multiple funding sources for the package, the
|
||||
user will be instructed to pass the `--which` command to disambiguate.
|
||||
|
||||
The list will avoid duplicated entries and will stack all packages
|
||||
that share the same type/url as a single entry. Given this nature the
|
||||
list is not going to have the same shape of the output from `npm ls`.
|
||||
|
||||
### Configuration
|
||||
|
||||
#### browser
|
||||
|
||||
* Default: OS X: `"open"`, Windows: `"start"`, Others: `"xdg-open"`
|
||||
* Type: String
|
||||
|
||||
The browser that is called by the `npm fund` command to open websites.
|
||||
|
||||
#### json
|
||||
|
||||
* Type: Boolean
|
||||
* Default: false
|
||||
|
||||
Show information in JSON format.
|
||||
|
||||
#### unicode
|
||||
|
||||
* Type: Boolean
|
||||
* Default: true
|
||||
|
||||
Whether to represent the tree structure using unicode characters.
|
||||
Set it to `false` in order to use all-ansi output.
|
||||
|
||||
#### which
|
||||
|
||||
* Type: Number
|
||||
* Default: undefined
|
||||
|
||||
If there are multiple funding sources, which 1-indexed source URL to open.
|
||||
|
||||
## See Also
|
||||
|
||||
* [npm docs](/cli-commands/npm-docs)
|
||||
* [npm config](/cli-commands/npm-config)
|
||||
* [npm install](/cli-commands/npm-install)
|
||||
* [npm ls](/cli-commands/npm-ls)
|
||||
|
||||
@ -1,43 +0,0 @@
|
||||
---
|
||||
section: cli-commands
|
||||
title: npm-help-search
|
||||
description: Search npm help documentation
|
||||
---
|
||||
|
||||
# npm-help-search(1)
|
||||
|
||||
## Search npm help documentation
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm help-search <text>
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
This command will search the npm markdown documentation files for the
|
||||
terms provided, and then list the results, sorted by relevance.
|
||||
|
||||
If only one result is found, then it will show that help topic.
|
||||
|
||||
If the argument to `npm help` is not a known help topic, then it will
|
||||
call `help-search`. It is rarely if ever necessary to call this
|
||||
command directly.
|
||||
|
||||
### Configuration
|
||||
|
||||
#### long
|
||||
|
||||
* Type: Boolean
|
||||
* Default: false
|
||||
|
||||
If true, the "long" flag will cause help-search to output context around
|
||||
where the terms were found in the documentation.
|
||||
|
||||
If false, then help-search will just list out the help topics found.
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm](/cli-commands/npm)
|
||||
* [npm help](/cli-commands/npm-help)
|
||||
@ -1,44 +0,0 @@
|
||||
---
|
||||
section: cli-commands
|
||||
title: npm-help
|
||||
description: Get help on npm
|
||||
---
|
||||
|
||||
# npm-help(1)
|
||||
|
||||
## Get help on npm
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm help <term> [<terms..>]
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
If supplied a topic, then show the appropriate documentation page.
|
||||
|
||||
If the topic does not exist, or if multiple terms are provided, then run
|
||||
the `help-search` command to find a match. Note that, if `help-search`
|
||||
finds a single subject, then it will run `help` on that topic, so unique
|
||||
matches are equivalent to specifying a topic name.
|
||||
|
||||
### Configuration
|
||||
|
||||
#### viewer
|
||||
|
||||
* Default: "man" on Posix, "browser" on Windows
|
||||
* Type: path
|
||||
|
||||
The program to use to view help content.
|
||||
|
||||
Set to `"browser"` to view html help content in the default web browser.
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm](/cli-commands/npm)
|
||||
* [npm folders](/configuring-npm/folders)
|
||||
* [npm config](/cli-commands/npm-config)
|
||||
* [npmrc](/configuring-npm/npmrc)
|
||||
* [package.json](/configuring-npm/package-json)
|
||||
* [npm help-search](/cli-commands/npm-help-search)
|
||||
@ -1,80 +0,0 @@
|
||||
---
|
||||
section: cli-commands
|
||||
title: npm-hook
|
||||
description: Manage registry hooks
|
||||
---
|
||||
|
||||
# npm-hook(1)
|
||||
|
||||
## Manage registry hooks
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm hook ls [pkg]
|
||||
npm hook add <entity> <url> <secret>
|
||||
npm hook update <id> <url> [secret]
|
||||
npm hook rm <id>
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
Add a hook to watch a package for changes:
|
||||
```bash
|
||||
$ npm hook add lodash https://example.com/ my-shared-secret
|
||||
```
|
||||
|
||||
Add a hook to watch packages belonging to the user `substack`:
|
||||
```bash
|
||||
$ npm hook add ~substack https://example.com/ my-shared-secret
|
||||
```
|
||||
|
||||
Add a hook to watch packages in the scope `@npm`
|
||||
```bash
|
||||
$ npm hook add @npm https://example.com/ my-shared-secret
|
||||
```
|
||||
|
||||
List all your active hooks:
|
||||
```bash
|
||||
$ npm hook ls
|
||||
```
|
||||
|
||||
List your active hooks for the `lodash` package:
|
||||
```bash
|
||||
$ npm hook ls lodash
|
||||
```
|
||||
|
||||
Update an existing hook's url:
|
||||
```bash
|
||||
$ npm hook update id-deadbeef https://my-new-website.here/
|
||||
```
|
||||
|
||||
Remove a hook:
|
||||
```bash
|
||||
$ npm hook rm id-deadbeef
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
Allows you to manage [npm hooks](https://blog.npmjs.org/post/145260155635/introducing-hooks-get-notifications-of-npm),
|
||||
including adding, removing, listing, and updating.
|
||||
|
||||
Hooks allow you to configure URL endpoints that will be notified whenever a
|
||||
change happens to any of the supported entity types. Three different types of
|
||||
entities can be watched by hooks: packages, owners, and scopes.
|
||||
|
||||
To create a package hook, simply reference the package name.
|
||||
|
||||
To create an owner hook, prefix the owner name with `~` (as in, `~youruser`).
|
||||
|
||||
To create a scope hook, prefix the scope name with `@` (as in, `@yourscope`).
|
||||
|
||||
The hook `id` used by `update` and `rm` are the IDs listed in `npm hook ls` for
|
||||
that particular hook.
|
||||
|
||||
The shared secret will be sent along to the URL endpoint so you can verify the
|
||||
request came from your own configured hook.
|
||||
|
||||
### See Also
|
||||
|
||||
* ["Introducing Hooks" blog post](https://blog.npmjs.org/post/145260155635/introducing-hooks-get-notifications-of-npm)
|
||||
@ -1,74 +0,0 @@
|
||||
---
|
||||
section: cli-commands
|
||||
title: npm-init
|
||||
description: create a package.json file
|
||||
---
|
||||
|
||||
# npm-init(1)
|
||||
|
||||
## create a package.json file
|
||||
|
||||
### Synopsis
|
||||
```bash
|
||||
npm init [--force|-f|--yes|-y|--scope]
|
||||
npm init <@scope> (same as `npx <@scope>/create`)
|
||||
npm init [<@scope>/]<name> (same as `npx [<@scope>/]create-<name>`)
|
||||
```
|
||||
|
||||
### Examples
|
||||
|
||||
Create a new React-based project using [`create-react-app`](https://npm.im/create-react-app):
|
||||
```bash
|
||||
$ npm init react-app ./my-react-app
|
||||
```
|
||||
|
||||
Create a new `esm`-compatible package using [`create-esm`](https://npm.im/create-esm):
|
||||
```bash
|
||||
$ mkdir my-esm-lib && cd my-esm-lib
|
||||
$ npm init esm --yes
|
||||
```
|
||||
|
||||
Generate a plain old package.json using legacy init:
|
||||
```bash
|
||||
$ mkdir my-npm-pkg && cd my-npm-pkg
|
||||
$ git init
|
||||
$ npm init
|
||||
```
|
||||
|
||||
Generate it without having it ask any questions:
|
||||
```bash
|
||||
$ npm init -y
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
`npm init <initializer>` can be used to set up a new or existing npm package.
|
||||
|
||||
`initializer` in this case is an npm package named `create-<initializer>`, which
|
||||
will be installed by [`npx`](https://npm.im/npx), and then have its main bin
|
||||
executed -- presumably creating or updating `package.json` and running any other
|
||||
initialization-related operations.
|
||||
|
||||
The init command is transformed to a corresponding `npx` operation as follows:
|
||||
|
||||
* `npm init foo` -> `npx create-foo`
|
||||
* `npm init @usr/foo` -> `npx @usr/create-foo`
|
||||
* `npm init @usr` -> `npx @usr/create`
|
||||
|
||||
Any additional options will be passed directly to the command, so `npm init foo
|
||||
--hello` will map to `npx create-foo --hello`.
|
||||
|
||||
If the initializer is omitted (by just calling `npm init`), init will fall back
|
||||
to legacy init behavior. It will ask you a bunch of questions, and then write a
|
||||
package.json for you. It will attempt to make reasonable guesses based on
|
||||
existing fields, dependencies, and options selected. It is strictly additive, so
|
||||
it will keep any fields and values that were already set. You can also use
|
||||
`-y`/`--yes` to skip the questionnaire altogether. If you pass `--scope`, it
|
||||
will create a scoped package.
|
||||
|
||||
### See Also
|
||||
|
||||
* <https://github.com/isaacs/init-package-json>
|
||||
* [package.json](/configuring-npm/package-json)
|
||||
* [npm version](/cli-commands/npm-version)
|
||||
* [npm scope](/using-npm/scope)
|
||||
@ -1,26 +0,0 @@
|
||||
---
|
||||
section: cli-commands
|
||||
title: npm-install-ci-test
|
||||
description: Install a project with a clean slate and run tests
|
||||
---
|
||||
|
||||
# npm install-ci-test(1)
|
||||
|
||||
## Install a project with a clean slate and run tests
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm install-ci-test
|
||||
|
||||
alias: npm cit
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
This command runs an `npm ci` followed immediately by an `npm test`.
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm ci](/cli-commands/npm-ci)
|
||||
* [npm test](/cli-commands/npm-test)
|
||||
@ -1,35 +0,0 @@
|
||||
---
|
||||
section: cli-commands
|
||||
title: npm-install-test
|
||||
description: Install package(s) and run tests
|
||||
---
|
||||
|
||||
# npm install-test(1)
|
||||
|
||||
## Install package(s) and run tests
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm install-test (with no args, in package dir)
|
||||
npm install-test [<@scope>/]<name>
|
||||
npm install-test [<@scope>/]<name>@<tag>
|
||||
npm install-test [<@scope>/]<name>@<version>
|
||||
npm install-test [<@scope>/]<name>@<version range>
|
||||
npm install-test <tarball file>
|
||||
npm install-test <tarball url>
|
||||
npm install-test <folder>
|
||||
|
||||
alias: npm it
|
||||
common options: [--save|--save-dev|--save-optional] [--save-exact] [--dry-run]
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
This command runs an `npm install` followed immediately by an `npm test`. It
|
||||
takes exactly the same arguments as `npm install`.
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm install](/cli-commands/npm-install)
|
||||
* [npm test](/cli-commands/npm-test)
|
||||
@ -1,519 +0,0 @@
|
||||
---
|
||||
section: cli-commands
|
||||
title: npm-install
|
||||
description: Install a package
|
||||
---
|
||||
|
||||
# npm-install(1)
|
||||
|
||||
## Install a package
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm install (with no args, in package dir)
|
||||
npm install [<@scope>/]<name>
|
||||
npm install [<@scope>/]<name>@<tag>
|
||||
npm install [<@scope>/]<name>@<version>
|
||||
npm install [<@scope>/]<name>@<version range>
|
||||
npm install <alias>@npm:<name>
|
||||
npm install <git-host>:<git-user>/<repo-name>
|
||||
npm install <git repo url>
|
||||
npm install <tarball file>
|
||||
npm install <tarball url>
|
||||
npm install <folder>
|
||||
|
||||
aliases: npm i, npm add
|
||||
common options: [-P|--save-prod|-D|--save-dev|-O|--save-optional] [-E|--save-exact] [-B|--save-bundle] [--no-save] [--dry-run]
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
This command installs a package, and any packages that it depends on. If the
|
||||
package has a package-lock or shrinkwrap file, the installation of dependencies
|
||||
will be driven by that, with an `npm-shrinkwrap.json` taking precedence if both
|
||||
files exist. See [package-lock.json](/configuring-npm/package-lock-json) and [`npm shrinkwrap`](/cli-commands/npm-shrinkwrap).
|
||||
|
||||
A `package` is:
|
||||
|
||||
* a) a folder containing a program described by a [`package.json`](/configuring-npm/package-json) file
|
||||
* b) a gzipped tarball containing (a)
|
||||
* c) a url that resolves to (b)
|
||||
* d) a `<name>@<version>` that is published on the registry (see [`registry`](/using-npm/registry)) with (c)
|
||||
* e) a `<name>@<tag>` (see [`npm dist-tag`](/cli-commands/npm-dist-tag)) that points to (d)
|
||||
* f) a `<name>` that has a "latest" tag satisfying (e)
|
||||
* g) a `<git remote url>` that resolves to (a)
|
||||
|
||||
Even if you never publish your package, you can still get a lot of
|
||||
benefits of using npm if you just want to write a node program (a), and
|
||||
perhaps if you also want to be able to easily install it elsewhere
|
||||
after packing it up into a tarball (b).
|
||||
|
||||
|
||||
* `npm install` (in package directory, no arguments):
|
||||
|
||||
Install the dependencies in the local node_modules folder.
|
||||
|
||||
In global mode (ie, with `-g` or `--global` appended to the command),
|
||||
it installs the current package context (ie, the current working
|
||||
directory) as a global package.
|
||||
|
||||
By default, `npm install` will install all modules listed as dependencies
|
||||
in [`package.json`](/configuring-npm/package-json).
|
||||
|
||||
With the `--production` flag (or when the `NODE_ENV` environment variable
|
||||
is set to `production`), npm will not install modules listed in
|
||||
`devDependencies`. To install all modules listed in both `dependencies`
|
||||
and `devDependencies` when `NODE_ENV` environment variable is set to `production`,
|
||||
you can use `--production=false`.
|
||||
|
||||
> NOTE: The `--production` flag has no particular meaning when adding a
|
||||
dependency to a project.
|
||||
|
||||
* `npm install <folder>`:
|
||||
|
||||
Install the package in the directory as a symlink in the current project.
|
||||
Its dependencies will be installed before it's linked. If `<folder>` sits
|
||||
inside the root of your project, its dependencies may be hoisted to the
|
||||
toplevel `node_modules` as they would for other types of dependencies.
|
||||
|
||||
* `npm install <tarball file>`:
|
||||
|
||||
Install a package that is sitting on the filesystem. Note: if you just want
|
||||
to link a dev directory into your npm root, you can do this more easily by
|
||||
using `npm link`.
|
||||
|
||||
Tarball requirements:
|
||||
* The filename *must* use `.tar`, `.tar.gz`, or `.tgz` as
|
||||
the extension.
|
||||
* The package contents should reside in a subfolder inside the tarball (usually it is called `package/`). npm strips one directory layer when installing the package (an equivalent of `tar x --strip-components=1` is run).
|
||||
* The package must contain a `package.json` file with `name` and `version` properties.
|
||||
|
||||
Example:
|
||||
|
||||
npm install ./package.tgz
|
||||
|
||||
* `npm install <tarball url>`:
|
||||
|
||||
Fetch the tarball url, and then install it. In order to distinguish between
|
||||
this and other options, the argument must start with "http://" or "https://"
|
||||
|
||||
Example:
|
||||
|
||||
npm install https://github.com/indexzero/forever/tarball/v0.5.6
|
||||
|
||||
* `npm install [<@scope>/]<name>`:
|
||||
|
||||
Do a `<name>@<tag>` install, where `<tag>` is the "tag" config. (See
|
||||
[`config`](/using-npm/config). The config's default value is `latest`.)
|
||||
|
||||
In most cases, this will install the version of the modules tagged as
|
||||
`latest` on the npm registry.
|
||||
|
||||
Example:
|
||||
|
||||
npm install sax
|
||||
|
||||
* `npm install <alias>@npm:<name>`:
|
||||
|
||||
Install a package under a custom alias. Allows multiple versions of
|
||||
a same-name package side-by-side, more convenient import names for
|
||||
packages with otherwise long ones and using git forks replacements
|
||||
or forked npm packages as replacements. Aliasing works only on your
|
||||
project and does not rename packages in transitive dependencies.
|
||||
Aliases should follow the naming conventions stated in
|
||||
[`validate-npm-package-name`](https://www.npmjs.com/package/validate-npm-package-name#naming-rules).
|
||||
|
||||
Examples:
|
||||
|
||||
npm install my-react@npm:react
|
||||
npm install jquery2@npm:jquery@2
|
||||
npm install jquery3@npm:jquery@3
|
||||
npm install npa@npm:npm-package-arg
|
||||
|
||||
|
||||
`npm install` saves any specified packages into `dependencies` by default.
|
||||
Additionally, you can control where and how they get saved with some
|
||||
additional flags:
|
||||
|
||||
* `-P, --save-prod`: Package will appear in your `dependencies`. This is the
|
||||
default unless `-D` or `-O` are present.
|
||||
|
||||
* `-D, --save-dev`: Package will appear in your `devDependencies`.
|
||||
|
||||
* `-O, --save-optional`: Package will appear in your `optionalDependencies`.
|
||||
|
||||
* `--no-save`: Prevents saving to `dependencies`.
|
||||
|
||||
When using any of the above options to save dependencies to your
|
||||
package.json, there are two additional, optional flags:
|
||||
|
||||
* `-E, --save-exact`: Saved dependencies will be configured with an
|
||||
exact version rather than using npm's default semver range
|
||||
operator.
|
||||
|
||||
* `-B, --save-bundle`: Saved dependencies will also be added to your `bundleDependencies` list.
|
||||
|
||||
Further, if you have an `npm-shrinkwrap.json` or `package-lock.json` then it
|
||||
will be updated as well.
|
||||
|
||||
`<scope>` is optional. The package will be downloaded from the registry
|
||||
associated with the specified scope. If no registry is associated with
|
||||
the given scope the default registry is assumed. See [`scope`](/using-npm/scope).
|
||||
|
||||
Note: if you do not include the @-symbol on your scope name, npm will
|
||||
interpret this as a GitHub repository instead, see below. Scopes names
|
||||
must also be followed by a slash.
|
||||
|
||||
Examples:
|
||||
|
||||
```bash
|
||||
npm install sax
|
||||
npm install githubname/reponame
|
||||
npm install @myorg/privatepackage
|
||||
npm install node-tap --save-dev
|
||||
npm install dtrace-provider --save-optional
|
||||
npm install readable-stream --save-exact
|
||||
npm install ansi-regex --save-bundle
|
||||
```
|
||||
|
||||
**Note**: If there is a file or folder named `<name>` in the current
|
||||
working directory, then it will try to install that, and only try to
|
||||
fetch the package by name if it is not valid.
|
||||
|
||||
* `npm install [<@scope>/]<name>@<tag>`:
|
||||
|
||||
Install the version of the package that is referenced by the specified tag.
|
||||
If the tag does not exist in the registry data for that package, then this
|
||||
will fail.
|
||||
|
||||
Example:
|
||||
|
||||
```bash
|
||||
npm install sax@latest
|
||||
npm install @myorg/mypackage@latest
|
||||
```
|
||||
|
||||
* `npm install [<@scope>/]<name>@<version>`:
|
||||
|
||||
Install the specified version of the package. This will fail if the
|
||||
version has not been published to the registry.
|
||||
|
||||
Example:
|
||||
|
||||
```bash
|
||||
npm install sax@0.1.1
|
||||
npm install @myorg/privatepackage@1.5.0
|
||||
```
|
||||
|
||||
* `npm install [<@scope>/]<name>@<version range>`:
|
||||
|
||||
Install a version of the package matching the specified version range. This
|
||||
will follow the same rules for resolving dependencies described in [`package.json`](/configuring-npm/package-json).
|
||||
|
||||
Note that most version ranges must be put in quotes so that your shell will
|
||||
treat it as a single argument.
|
||||
|
||||
Example:
|
||||
```bash
|
||||
npm install sax@">=0.1.0 <0.2.0"
|
||||
npm install @myorg/privatepackage@">=0.1.0 <0.2.0"
|
||||
```
|
||||
|
||||
* `npm install <git remote url>`:
|
||||
|
||||
Installs the package from the hosted git provider, cloning it with `git`.
|
||||
For a full git remote url, only that URL will be attempted.
|
||||
|
||||
```bash
|
||||
<protocol>://[<user>[:<password>]@]<hostname>[:<port>][:][/]<path>[#<commit-ish> | #semver:<semver>]
|
||||
```
|
||||
|
||||
`<protocol>` is one of `git`, `git+ssh`, `git+http`, `git+https`, or
|
||||
`git+file`.
|
||||
|
||||
If `#<commit-ish>` is provided, it will be used to clone exactly that
|
||||
commit. If the commit-ish has the format `#semver:<semver>`, `<semver>` can
|
||||
be any valid semver range or exact version, and npm will look for any tags
|
||||
or refs matching that range in the remote repository, much as it would for a
|
||||
registry dependency. If neither `#<commit-ish>` or `#semver:<semver>` is
|
||||
specified, then the default branch of the repository is used.
|
||||
|
||||
If the repository makes use of submodules, those submodules will be cloned
|
||||
as well.
|
||||
|
||||
If the package being installed contains a `prepare` script, its
|
||||
`dependencies` and `devDependencies` will be installed, and the prepare
|
||||
script will be run, before the package is packaged and installed.
|
||||
|
||||
The following git environment variables are recognized by npm and will be
|
||||
added to the environment when running git:
|
||||
|
||||
* `GIT_ASKPASS`
|
||||
* `GIT_EXEC_PATH`
|
||||
* `GIT_PROXY_COMMAND`
|
||||
* `GIT_SSH`
|
||||
* `GIT_SSH_COMMAND`
|
||||
* `GIT_SSL_CAINFO`
|
||||
* `GIT_SSL_NO_VERIFY`
|
||||
|
||||
See the git man page for details.
|
||||
|
||||
Examples:
|
||||
|
||||
```bash
|
||||
npm install git+ssh://git@github.com:npm/cli.git#v1.0.27
|
||||
npm install git+ssh://git@github.com:npm/cli#semver:^5.0
|
||||
npm install git+https://isaacs@github.com/npm/cli.git
|
||||
npm install git://github.com/npm/cli.git#v1.0.27
|
||||
GIT_SSH_COMMAND='ssh -i ~/.ssh/custom_ident' npm install git+ssh://git@github.com:npm/cli.git
|
||||
```
|
||||
|
||||
* `npm install <githubname>/<githubrepo>[#<commit-ish>]`:
|
||||
* `npm install github:<githubname>/<githubrepo>[#<commit-ish>]`:
|
||||
|
||||
Install the package at `https://github.com/githubname/githubrepo` by
|
||||
attempting to clone it using `git`.
|
||||
|
||||
If `#<commit-ish>` is provided, it will be used to clone exactly that
|
||||
commit. If the commit-ish has the format `#semver:<semver>`, `<semver>` can
|
||||
be any valid semver range or exact version, and npm will look for any tags
|
||||
or refs matching that range in the remote repository, much as it would for a
|
||||
registry dependency. If neither `#<commit-ish>` or `#semver:<semver>` is
|
||||
specified, then `master` is used.
|
||||
|
||||
As with regular git dependencies, `dependencies` and `devDependencies` will
|
||||
be installed if the package has a `prepare` script, before the package is
|
||||
done installing.
|
||||
|
||||
Examples:
|
||||
|
||||
```bash
|
||||
npm install mygithubuser/myproject
|
||||
npm install github:mygithubuser/myproject
|
||||
```
|
||||
|
||||
* `npm install gist:[<githubname>/]<gistID>[#<commit-ish>|#semver:<semver>]`:
|
||||
|
||||
Install the package at `https://gist.github.com/gistID` by attempting to
|
||||
clone it using `git`. The GitHub username associated with the gist is
|
||||
optional and will not be saved in `package.json`.
|
||||
|
||||
As with regular git dependencies, `dependencies` and `devDependencies` will
|
||||
be installed if the package has a `prepare` script, before the package is
|
||||
done installing.
|
||||
|
||||
Example:
|
||||
|
||||
```bash
|
||||
npm install gist:101a11beef
|
||||
```
|
||||
|
||||
* `npm install bitbucket:<bitbucketname>/<bitbucketrepo>[#<commit-ish>]`:
|
||||
|
||||
Install the package at `https://bitbucket.org/bitbucketname/bitbucketrepo`
|
||||
by attempting to clone it using `git`.
|
||||
|
||||
If `#<commit-ish>` is provided, it will be used to clone exactly that
|
||||
commit. If the commit-ish has the format `#semver:<semver>`, `<semver>` can
|
||||
be any valid semver range or exact version, and npm will look for any tags
|
||||
or refs matching that range in the remote repository, much as it would for a
|
||||
registry dependency. If neither `#<commit-ish>` or `#semver:<semver>` is
|
||||
specified, then `master` is used.
|
||||
|
||||
As with regular git dependencies, `dependencies` and `devDependencies` will
|
||||
be installed if the package has a `prepare` script, before the package is
|
||||
done installing.
|
||||
|
||||
Example:
|
||||
|
||||
```bash
|
||||
npm install bitbucket:mybitbucketuser/myproject
|
||||
```
|
||||
|
||||
* `npm install gitlab:<gitlabname>/<gitlabrepo>[#<commit-ish>]`:
|
||||
|
||||
Install the package at `https://gitlab.com/gitlabname/gitlabrepo`
|
||||
by attempting to clone it using `git`.
|
||||
|
||||
If `#<commit-ish>` is provided, it will be used to clone exactly that
|
||||
commit. If the commit-ish has the format `#semver:<semver>`, `<semver>` can
|
||||
be any valid semver range or exact version, and npm will look for any tags
|
||||
or refs matching that range in the remote repository, much as it would for a
|
||||
registry dependency. If neither `#<commit-ish>` or `#semver:<semver>` is
|
||||
specified, then `master` is used.
|
||||
|
||||
As with regular git dependencies, `dependencies` and `devDependencies` will
|
||||
be installed if the package has a `prepare` script, before the package is
|
||||
done installing.
|
||||
|
||||
Example:
|
||||
|
||||
```bash
|
||||
npm install gitlab:mygitlabuser/myproject
|
||||
npm install gitlab:myusr/myproj#semver:^5.0
|
||||
```
|
||||
|
||||
You may combine multiple arguments, and even multiple types of arguments.
|
||||
For example:
|
||||
|
||||
```bash
|
||||
npm install sax@">=0.1.0 <0.2.0" bench supervisor
|
||||
```
|
||||
|
||||
The `--tag` argument will apply to all of the specified install targets. If a
|
||||
tag with the given name exists, the tagged version is preferred over newer
|
||||
versions.
|
||||
|
||||
The `--dry-run` argument will report in the usual way what the install would
|
||||
have done without actually installing anything.
|
||||
|
||||
The `--package-lock-only` argument will only update the `package-lock.json`,
|
||||
instead of checking `node_modules` and downloading dependencies.
|
||||
|
||||
The `-f` or `--force` argument will force npm to fetch remote resources even if a
|
||||
local copy exists on disk.
|
||||
|
||||
```bash
|
||||
npm install sax --force
|
||||
```
|
||||
|
||||
The `--no-fund` argument will hide the message displayed at the end of each
|
||||
install that acknowledges the number of dependencies looking for funding.
|
||||
See `npm-fund(1)`
|
||||
|
||||
The `-g` or `--global` argument will cause npm to install the package globally
|
||||
rather than locally. See [folders](/configuring-npm/folders).
|
||||
|
||||
The `--global-style` argument will cause npm to install the package into
|
||||
your local `node_modules` folder with the same layout it uses with the
|
||||
global `node_modules` folder. Only your direct dependencies will show in
|
||||
`node_modules` and everything they depend on will be flattened in their
|
||||
`node_modules` folders. This obviously will eliminate some deduping.
|
||||
|
||||
The `--ignore-scripts` argument will cause npm to not execute any
|
||||
scripts defined in the package.json. See [`scripts`](/using-npm/scripts).
|
||||
|
||||
The `--legacy-bundling` argument will cause npm to install the package such
|
||||
that versions of npm prior to 1.4, such as the one included with node 0.8,
|
||||
can install the package. This eliminates all automatic deduping.
|
||||
|
||||
The `--link` argument will cause npm to link global installs into the
|
||||
local space in some cases.
|
||||
|
||||
The `--no-bin-links` argument will prevent npm from creating symlinks for
|
||||
any binaries the package might contain.
|
||||
|
||||
The `--no-optional` argument will prevent optional dependencies from
|
||||
being installed.
|
||||
|
||||
The `--no-shrinkwrap` argument, which will ignore an available
|
||||
package lock or shrinkwrap file and use the package.json instead.
|
||||
|
||||
The `--no-package-lock` argument will prevent npm from creating a
|
||||
`package-lock.json` file. When running with package-lock's disabled npm
|
||||
will not automatically prune your node modules when installing.
|
||||
|
||||
The `--nodedir=/path/to/node/source` argument will allow npm to find the
|
||||
node source code so that npm can compile native modules.
|
||||
|
||||
The `--only={prod[uction]|dev[elopment]}` argument will cause either only
|
||||
`devDependencies` or only non-`devDependencies` to be installed regardless of the `NODE_ENV`.
|
||||
|
||||
The `--no-audit` argument can be used to disable sending of audit reports to
|
||||
the configured registries. See [`npm-audit`](npm-audit) for details on what is sent.
|
||||
|
||||
See [`config`](/using-npm/config). Many of the configuration params have some
|
||||
effect on installation, since that's most of what npm does.
|
||||
|
||||
#### Algorithm
|
||||
|
||||
To install a package, npm uses the following algorithm:
|
||||
```bash
|
||||
load the existing node_modules tree from disk
|
||||
clone the tree
|
||||
fetch the package.json and assorted metadata and add it to the clone
|
||||
walk the clone and add any missing dependencies
|
||||
dependencies will be added as close to the top as is possible
|
||||
without breaking any other modules
|
||||
compare the original tree with the cloned tree and make a list of
|
||||
actions to take to convert one to the other
|
||||
execute all of the actions, deepest first
|
||||
kinds of actions are install, update, remove and move
|
||||
```
|
||||
|
||||
For this `package{dep}` structure: `A{B,C}, B{C}, C{D}`,
|
||||
this algorithm produces:
|
||||
|
||||
```bash
|
||||
A
|
||||
+-- B
|
||||
+-- C
|
||||
+-- D
|
||||
```
|
||||
|
||||
That is, the dependency from B to C is satisfied by the fact that A
|
||||
already caused C to be installed at a higher level. D is still installed
|
||||
at the top level because nothing conflicts with it.
|
||||
|
||||
For `A{B,C}, B{C,D@1}, C{D@2}`, this algorithm produces:
|
||||
|
||||
```bash
|
||||
A
|
||||
+-- B
|
||||
+-- C
|
||||
`-- D@2
|
||||
+-- D@1
|
||||
```
|
||||
|
||||
Because B's D@1 will be installed in the top level, C now has to install D@2
|
||||
privately for itself. This algorithm is deterministic, but different trees may
|
||||
be produced if two dependencies are requested for installation in a different
|
||||
order.
|
||||
|
||||
See [folders](/configuring-npm/folders) for a more detailed description of the specific folder structures that npm creates.
|
||||
|
||||
### Limitations of npm's Install Algorithm
|
||||
|
||||
npm will refuse to install any package with an identical name to the
|
||||
current package. This can be overridden with the `--force` flag, but in
|
||||
most cases can simply be addressed by changing the local package name.
|
||||
|
||||
There are some very rare and pathological edge-cases where a cycle can
|
||||
cause npm to try to install a never-ending tree of packages. Here is
|
||||
the simplest case:
|
||||
|
||||
```bash
|
||||
A -> B -> A' -> B' -> A -> B -> A' -> B' -> A -> ...
|
||||
```
|
||||
|
||||
where `A` is some version of a package, and `A'` is a different version
|
||||
of the same package. Because `B` depends on a different version of `A`
|
||||
than the one that is already in the tree, it must install a separate
|
||||
copy. The same is true of `A'`, which must install `B'`. Because `B'`
|
||||
depends on the original version of `A`, which has been overridden, the
|
||||
cycle falls into infinite regress.
|
||||
|
||||
To avoid this situation, npm flat-out refuses to install any
|
||||
`name@version` that is already present anywhere in the tree of package
|
||||
folder ancestors. A more correct, but more complex, solution would be
|
||||
to symlink the existing version into the new location. If this ever
|
||||
affects a real use-case, it will be investigated.
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm folders](/configuring-npm/folders)
|
||||
* [npm update](/cli-commands/npm-update)
|
||||
* [npm audit](/cli-commands/npm-audit)
|
||||
* [npm fund](/cli-commands/npm-fund)
|
||||
* [npm link](/cli-commands/npm-link)
|
||||
* [npm rebuild](/cli-commands/npm-rebuild)
|
||||
* [npm scripts](/using-npm/scripts)
|
||||
* [npm build](/cli-commands/npm-build)
|
||||
* [npm config](/cli-commands/npm-config)
|
||||
* [npmrc](/configuring-npm/npmrc)
|
||||
* [npm registry](/using-npm/registry)
|
||||
* [npm dist-tag](/cli-commands/npm-dist-tag)
|
||||
* [npm uninstall](/cli-commands/npm-uninstall)
|
||||
* [npm shrinkwrap](/cli-commands/npm-shrinkwrap)
|
||||
* [package.json](/configuring-npm/package-json)
|
||||
@ -1,92 +0,0 @@
|
||||
---
|
||||
section: cli-commands
|
||||
title: npm-link
|
||||
description: Symlink a package folder
|
||||
---
|
||||
|
||||
# npm-link(1)
|
||||
|
||||
## Symlink a package folder
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm link (in package dir)
|
||||
npm link [<@scope>/]<pkg>[@<version>]
|
||||
|
||||
alias: npm ln
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
Package linking is a two-step process.
|
||||
|
||||
First, `npm link` in a package folder will create a symlink in the global folder
|
||||
`{prefix}/lib/node_modules/<package>` that links to the package where the `npm
|
||||
link` command was executed. It will also link any bins in the package to `{prefix}/bin/{name}`.
|
||||
Note that `npm link` uses the global prefix (see `npm prefix -g` for its value).
|
||||
|
||||
Next, in some other location, `npm link package-name` will create a
|
||||
symbolic link from globally-installed `package-name` to `node_modules/`
|
||||
of the current folder.
|
||||
|
||||
Note that `package-name` is taken from `package.json`,
|
||||
not from directory name.
|
||||
|
||||
The package name can be optionally prefixed with a scope. See [`scope`](/using-npm/npm-scope).
|
||||
The scope must be preceded by an @-symbol and followed by a slash.
|
||||
|
||||
When creating tarballs for `npm publish`, the linked packages are
|
||||
"snapshotted" to their current state by resolving the symbolic links.
|
||||
|
||||
This is handy for installing your own stuff, so that you can work on it and
|
||||
test it iteratively without having to continually rebuild.
|
||||
|
||||
For example:
|
||||
|
||||
```bash
|
||||
cd ~/projects/node-redis # go into the package directory
|
||||
npm link # creates global link
|
||||
cd ~/projects/node-bloggy # go into some other package directory.
|
||||
npm link redis # link-install the package
|
||||
```
|
||||
|
||||
Now, any changes to ~/projects/node-redis will be reflected in
|
||||
~/projects/node-bloggy/node_modules/node-redis/. Note that the link should
|
||||
be to the package name, not the directory name for that package.
|
||||
|
||||
You may also shortcut the two steps in one. For example, to do the
|
||||
above use-case in a shorter way:
|
||||
|
||||
```bash
|
||||
cd ~/projects/node-bloggy # go into the dir of your main project
|
||||
npm link ../node-redis # link the dir of your dependency
|
||||
```
|
||||
|
||||
The second line is the equivalent of doing:
|
||||
|
||||
```bash
|
||||
(cd ../node-redis; npm link)
|
||||
npm link redis
|
||||
```
|
||||
|
||||
That is, it first creates a global link, and then links the global
|
||||
installation target into your project's `node_modules` folder.
|
||||
|
||||
Note that in this case, you are referring to the directory name, `node-redis`,
|
||||
rather than the package name `redis`.
|
||||
|
||||
If your linked package is scoped (see [`scope`](/using-npm/npm-scope)) your link command must include that scope, e.g.
|
||||
|
||||
```bash
|
||||
npm link @myorg/privatepackage
|
||||
```
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm developers](/using-npm/developers)
|
||||
* [package.json](/configuring-npm/package-json)
|
||||
* [npm- nstall](/cli-commands/npm-install)
|
||||
* [npm folders](/configuring-npm/folders)
|
||||
* [npm config](/cli-commands/npm-config)
|
||||
* [npmrc](/configuring-npm/npmrc)
|
||||
@ -1,54 +0,0 @@
|
||||
---
|
||||
section: cli-commands
|
||||
title: npm-logout
|
||||
description: Log out of the registry
|
||||
---
|
||||
|
||||
# npm-logout(1)
|
||||
|
||||
## Log out of the registry
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm logout [--registry=<url>] [--scope=<@scope>]
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
When logged into a registry that supports token-based authentication, tell the
|
||||
server to end this token's session. This will invalidate the token everywhere
|
||||
you're using it, not just for the current environment.
|
||||
|
||||
When logged into a legacy registry that uses username and password authentication, this will
|
||||
clear the credentials in your user configuration. In this case, it will _only_ affect
|
||||
the current environment.
|
||||
|
||||
If `--scope` is provided, this will find the credentials for the registry
|
||||
connected to that scope, if set.
|
||||
|
||||
### Configuration
|
||||
|
||||
#### registry
|
||||
|
||||
Default: https://registry.npmjs.org/
|
||||
|
||||
The base URL of the npm package registry. If `scope` is also specified,
|
||||
it takes precedence.
|
||||
|
||||
#### scope
|
||||
|
||||
Default: The scope of your current project, if any, otherwise none.
|
||||
|
||||
If specified, you will be logged out of the specified scope. See [`scope`](/using-npm/npm-scope).
|
||||
|
||||
```bash
|
||||
npm logout --scope=@myco
|
||||
```
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm adduser](/cli-commands/npm-adduser)
|
||||
* [npm registry](/using-npm/registry)
|
||||
* [npm config](/cli-commands/npm-config)
|
||||
* [npm whoami](/cli-commands/npm-whoami)
|
||||
@ -1,129 +0,0 @@
|
||||
---
|
||||
section: cli-commands
|
||||
title: npm-ls
|
||||
description: List installed packages
|
||||
---
|
||||
|
||||
# npm-ls(1)
|
||||
|
||||
## List installed packages
|
||||
|
||||
### Synopsis
|
||||
|
||||
```bash
|
||||
npm ls [[<@scope>/]<pkg> ...]
|
||||
|
||||
aliases: list, la, ll
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
This command will print to stdout all the versions of packages that are
|
||||
installed, as well as their dependencies, in a tree-structure.
|
||||
|
||||
Positional arguments are `name@version-range` identifiers, which will
|
||||
limit the results to only the paths to the packages named. Note that
|
||||
nested packages will *also* show the paths to the specified packages.
|
||||
For example, running `npm ls promzard` in npm's source tree will show:
|
||||
|
||||
```bash
|
||||
npm@@VERSION@ /path/to/npm
|
||||
└─┬ init-package-json@0.0.4
|
||||
└── promzard@0.1.5
|
||||
```
|
||||
|
||||
It will print out extraneous, missing, and invalid packages.
|
||||
|
||||
If a project specifies git urls for dependencies these are shown
|
||||
in parentheses after the name@version to make it easier for users to
|
||||
recognize potential forks of a project.
|
||||
|
||||
The tree shown is the logical dependency tree, based on package
|
||||
dependencies, not the physical layout of your node_modules folder.
|
||||
|
||||
When run as `ll` or `la`, it shows extended information by default.
|
||||
|
||||
### Configuration
|
||||
|
||||
#### json
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Show information in JSON format.
|
||||
|
||||
#### long
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Show extended information.
|
||||
|
||||
#### parseable
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Show parseable output instead of tree view.
|
||||
|
||||
#### global
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
List packages in the global install prefix instead of in the current
|
||||
project.
|
||||
|
||||
#### depth
|
||||
|
||||
* Type: Int
|
||||
|
||||
Max display depth of the dependency tree.
|
||||
|
||||
#### prod / production
|
||||
|
||||
* Type: Boolean
|
||||
* Default: false
|
||||
|
||||
Display only the dependency tree for packages in `dependencies`.
|
||||
|
||||
#### dev / development
|
||||
|
||||
* Type: Boolean
|
||||
* Default: false
|
||||
|
||||
Display only the dependency tree for packages in `devDependencies`.
|
||||
|
||||
#### only
|
||||
|
||||
* Type: String
|
||||
|
||||
When "dev" or "development", is an alias to `dev`.
|
||||
|
||||
When "prod" or "production", is an alias to `production`.
|
||||
|
||||
#### link
|
||||
|
||||
* Type: Boolean
|
||||
* Default: false
|
||||
|
||||
Display only dependencies which are linked
|
||||
|
||||
#### unicode
|
||||
|
||||
* Type: Boolean
|
||||
* Default: true
|
||||
|
||||
Whether to represent the tree structure using unicode characters.
|
||||
Set it to false in order to use all-ansi output.
|
||||
|
||||
### See Also
|
||||
|
||||
* [npm config](/cli-commands/npm-config)
|
||||
* [npmrc](/configuring-npm/npmrc)
|
||||
* [npm folders](/configuring-npm/folders)
|
||||
* [npm install](/cli-commands/npm-install)
|
||||
* [npm link](/cli-commands/npm-link)
|
||||
* [npm prune](/cli-commands/npm-prune)
|
||||
* [npm outdated](/cli-commands/npm-outdated)
|
||||
* [npm update](/cli-commands/npm-update)
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue