From 9bdd1ace86300a8ee562027bbc5cb57d62dc7ba8 Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Tue, 22 Feb 2022 09:49:47 -0700 Subject: [PATCH 01/43] fix(arborist): use full location as tracker key when inflating (#4300) Fixes: #4273 Ref: #4298 Co-authored-by: Kirtan Gajjar <8456197+kirtangajjar@users.noreply.github.com> --- workspaces/arborist/lib/arborist/build-ideal-tree.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/workspaces/arborist/lib/arborist/build-ideal-tree.js b/workspaces/arborist/lib/arborist/build-ideal-tree.js index b7bc56f3e9797..3fedd972f9c00 100644 --- a/workspaces/arborist/lib/arborist/build-ideal-tree.js +++ b/workspaces/arborist/lib/arborist/build-ideal-tree.js @@ -753,8 +753,7 @@ This is a one-time fix-up, please be patient... const id = useResolved ? resolved : version || `file:${node.path}` const spec = npa.resolve(name, id, dirname(path)) - const sloc = location.substr('node_modules/'.length) - const t = `idealTree:inflate:${sloc}` + const t = `idealTree:inflate:${location}` this.addTracker(t) await pacote.manifest(spec, { ...this.options, From e83e5c9bad93e598969088ae780149dbe34c6b5c Mon Sep 17 00:00:00 2001 From: Gar Date: Tue, 22 Feb 2022 11:47:56 -0800 Subject: [PATCH 02/43] docs: clarify npm init @latest behavior (#4435) Closes: https://github.com/npm/cli/issues/3821 --- docs/content/commands/npm-init.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/content/commands/npm-init.md b/docs/content/commands/npm-init.md index a608061a96d8d..e9212a37e0f25 100644 --- a/docs/content/commands/npm-init.md +++ b/docs/content/commands/npm-init.md @@ -38,6 +38,15 @@ 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. +*Note:* if a user already has the `create-` package +globally installed, that will be what `npm init` uses. If you want npm +to use the latest version, or another specific version you must specify +it: + +* `npm init foo@latest` # fetches and runs the latest `create-foo` from + the registry +* `npm init foo@1.2.3` # runs `create-foo@1.2.3` specifically + #### Forwarding additional options Any additional options will be passed directly to the command, so `npm init From c9ff797e8b5e5a7b39ced04b1d3f8a0006993a1f Mon Sep 17 00:00:00 2001 From: Gar Date: Tue, 22 Feb 2022 11:48:45 -0800 Subject: [PATCH 03/43] fix: remove html comments from man entries (#4457) --- scripts/docs-build.js | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/docs-build.js b/scripts/docs-build.js index 63658c79b1631..c380b4b7653dc 100644 --- a/scripts/docs-build.js +++ b/scripts/docs-build.js @@ -30,6 +30,7 @@ fs.readFile(src, 'utf8', function (err, data) { } var result = data.replace(/@VERSION@/g, npm.version) + .replace(/^$/gm, '') .replace(/^---\n([\s\S]+\n)---/, frontmatter) .replace(/\[([^\]]+)\]\(\/commands\/([^)]+)\)/g, replacer) .replace(/\[([^\]]+)\]\(\/configuring-npm\/([^)]+)\)/g, replacer) From d8fa9fa5e44d91e1c0170628d4839f7802c65a7f Mon Sep 17 00:00:00 2001 From: Gar Date: Tue, 22 Feb 2022 11:58:19 -0800 Subject: [PATCH 04/43] docs: explain $INIT_CWD on using scripts page (#4436) --- docs/content/using-npm/scripts.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/content/using-npm/scripts.md b/docs/content/using-npm/scripts.md index a3fa868f6a61c..7df289b3bd6bd 100644 --- a/docs/content/using-npm/scripts.md +++ b/docs/content/using-npm/scripts.md @@ -344,6 +344,11 @@ file. preinstall or install script. If you are doing this, please consider if there is another option. The only valid use of `install` or `preinstall` scripts is for compilation which must be done on the target architecture. +* Scripts are run from the root of the package folder, regardless of what the + current working directory is when `npm` is invoked. If you want your + script to use different behavior based on what subdirectory you're in, you + can use the `INIT_CWD` environment variable, which holds the full path you + were in when you ran `npm run`. ### See Also From 5b29666e566c09dc685108daaa20163dd58ade2b Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Wed, 23 Feb 2022 08:28:05 -0700 Subject: [PATCH 05/43] deps: columnify@1.6.0 and dedupe vulnerable deps (#4459) --- node_modules/.gitignore | 2 + .../is-fullwidth-code-point/index.js | 50 --- .../is-fullwidth-code-point/package.json | 42 -- .../node_modules/string-width/index.js | 47 -- .../node_modules/string-width/package.json | 56 --- .../node_modules/ansi-regex/license | 9 - .../node_modules/ansi-regex/readme.md | 78 ---- .../is-fullwidth-code-point/index.d.ts | 17 - .../is-fullwidth-code-point/index.js | 50 --- .../is-fullwidth-code-point/license | 9 - .../is-fullwidth-code-point/package.json | 42 -- .../is-fullwidth-code-point/readme.md | 39 -- .../node_modules/string-width/index.d.ts | 29 -- .../node_modules/string-width/index.js | 47 -- .../node_modules/string-width/license | 9 - .../node_modules/string-width/package.json | 56 --- .../node_modules/string-width/readme.md | 50 --- .../node_modules/strip-ansi/license | 9 - .../node_modules/strip-ansi/readme.md | 46 -- node_modules/columnify/Readme.md | 49 ++- node_modules/columnify/columnify.js | 22 +- .../node_modules/ansi-regex/index.d.ts | 0 .../node_modules/ansi-regex/index.js | 2 +- .../node_modules/ansi-regex}/license | 0 .../node_modules/ansi-regex/package.json | 2 +- .../node_modules/strip-ansi/index.d.ts | 0 .../node_modules/strip-ansi/index.js | 0 .../node_modules/strip-ansi}/license | 0 .../node_modules/strip-ansi/package.json | 4 +- node_modules/columnify/package.json | 12 +- .../is-fullwidth-code-point/index.d.ts | 17 - .../is-fullwidth-code-point/index.js | 50 --- .../is-fullwidth-code-point/license | 9 - .../is-fullwidth-code-point/package.json | 42 -- .../node_modules/string-width/index.d.ts | 29 -- .../gauge/node_modules/string-width/index.js | 47 -- .../gauge/node_modules/string-width/license | 9 - .../node_modules/string-width/package.json | 56 --- .../is-fullwidth-code-point/index.d.ts | 0 node_modules/is-fullwidth-code-point/index.js | 46 +- node_modules/is-fullwidth-code-point/license | 20 +- .../is-fullwidth-code-point/package.json | 83 ++-- .../is-fullwidth-code-point/readme.md | 12 +- .../node_modules => }/string-width/index.d.ts | 0 node_modules/string-width/index.js | 21 +- .../node_modules/ansi-regex/index.d.ts | 37 ++ .../node_modules/ansi-regex/index.js | 8 +- .../node_modules/ansi-regex/package.json | 104 ++--- .../node_modules/ansi-regex/readme.md | 38 +- .../node_modules/strip-ansi/index.d.ts | 17 + .../node_modules/strip-ansi/index.js | 2 +- .../node_modules/strip-ansi/package.json | 102 ++--- .../node_modules/strip-ansi/readme.md | 17 +- node_modules/string-width/package.json | 21 +- node_modules/string-width/readme.md | 22 +- package-lock.json | 405 ++++-------------- package.json | 2 +- 57 files changed, 468 insertions(+), 1526 deletions(-) delete mode 100644 node_modules/cli-columns/node_modules/is-fullwidth-code-point/index.js delete mode 100644 node_modules/cli-columns/node_modules/is-fullwidth-code-point/package.json delete mode 100644 node_modules/cli-columns/node_modules/string-width/index.js delete mode 100644 node_modules/cli-columns/node_modules/string-width/package.json delete mode 100644 node_modules/cli-table3/node_modules/ansi-regex/license delete mode 100644 node_modules/cli-table3/node_modules/ansi-regex/readme.md delete mode 100644 node_modules/cli-table3/node_modules/is-fullwidth-code-point/index.d.ts delete mode 100644 node_modules/cli-table3/node_modules/is-fullwidth-code-point/index.js delete mode 100644 node_modules/cli-table3/node_modules/is-fullwidth-code-point/license delete mode 100644 node_modules/cli-table3/node_modules/is-fullwidth-code-point/package.json delete mode 100644 node_modules/cli-table3/node_modules/is-fullwidth-code-point/readme.md delete mode 100644 node_modules/cli-table3/node_modules/string-width/index.d.ts delete mode 100644 node_modules/cli-table3/node_modules/string-width/index.js delete mode 100644 node_modules/cli-table3/node_modules/string-width/license delete mode 100644 node_modules/cli-table3/node_modules/string-width/package.json delete mode 100644 node_modules/cli-table3/node_modules/string-width/readme.md delete mode 100644 node_modules/cli-table3/node_modules/strip-ansi/license delete mode 100644 node_modules/cli-table3/node_modules/strip-ansi/readme.md rename node_modules/{cli-table3 => columnify}/node_modules/ansi-regex/index.d.ts (100%) rename node_modules/{cli-table3 => columnify}/node_modules/ansi-regex/index.js (62%) rename node_modules/{cli-columns/node_modules/is-fullwidth-code-point => columnify/node_modules/ansi-regex}/license (100%) rename node_modules/{cli-table3 => columnify}/node_modules/ansi-regex/package.json (97%) rename node_modules/{cli-table3 => columnify}/node_modules/strip-ansi/index.d.ts (100%) rename node_modules/{cli-table3 => columnify}/node_modules/strip-ansi/index.js (100%) rename node_modules/{cli-columns/node_modules/string-width => columnify/node_modules/strip-ansi}/license (100%) rename node_modules/{cli-table3 => columnify}/node_modules/strip-ansi/package.json (94%) delete mode 100644 node_modules/gauge/node_modules/is-fullwidth-code-point/index.d.ts delete mode 100644 node_modules/gauge/node_modules/is-fullwidth-code-point/index.js delete mode 100644 node_modules/gauge/node_modules/is-fullwidth-code-point/license delete mode 100644 node_modules/gauge/node_modules/is-fullwidth-code-point/package.json delete mode 100644 node_modules/gauge/node_modules/string-width/index.d.ts delete mode 100644 node_modules/gauge/node_modules/string-width/index.js delete mode 100644 node_modules/gauge/node_modules/string-width/license delete mode 100644 node_modules/gauge/node_modules/string-width/package.json rename node_modules/{cli-columns/node_modules => }/is-fullwidth-code-point/index.d.ts (100%) rename node_modules/{cli-columns/node_modules => }/string-width/index.d.ts (100%) create mode 100644 node_modules/string-width/node_modules/ansi-regex/index.d.ts create mode 100644 node_modules/string-width/node_modules/strip-ansi/index.d.ts diff --git a/node_modules/.gitignore b/node_modules/.gitignore index a14c4c9d2bea8..10951adf348d8 100644 --- a/node_modules/.gitignore +++ b/node_modules/.gitignore @@ -69,6 +69,7 @@ readme* /acorn-walk /ajv /ansi-colors +/ansi-regex /anymatch /append-transform /arg @@ -379,6 +380,7 @@ readme* /state-toggle /string.prototype.trimend /string.prototype.trimstart +/strip-ansi /strip-json-comments /style-to-object /symbol-tree diff --git a/node_modules/cli-columns/node_modules/is-fullwidth-code-point/index.js b/node_modules/cli-columns/node_modules/is-fullwidth-code-point/index.js deleted file mode 100644 index 671f97f760779..0000000000000 --- a/node_modules/cli-columns/node_modules/is-fullwidth-code-point/index.js +++ /dev/null @@ -1,50 +0,0 @@ -/* eslint-disable yoda */ -'use strict'; - -const isFullwidthCodePoint = codePoint => { - if (Number.isNaN(codePoint)) { - return false; - } - - // Code points are derived from: - // http://www.unix.org/Public/UNIDATA/EastAsianWidth.txt - if ( - codePoint >= 0x1100 && ( - codePoint <= 0x115F || // Hangul Jamo - codePoint === 0x2329 || // LEFT-POINTING ANGLE BRACKET - codePoint === 0x232A || // RIGHT-POINTING ANGLE BRACKET - // CJK Radicals Supplement .. Enclosed CJK Letters and Months - (0x2E80 <= codePoint && codePoint <= 0x3247 && codePoint !== 0x303F) || - // Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A - (0x3250 <= codePoint && codePoint <= 0x4DBF) || - // CJK Unified Ideographs .. Yi Radicals - (0x4E00 <= codePoint && codePoint <= 0xA4C6) || - // Hangul Jamo Extended-A - (0xA960 <= codePoint && codePoint <= 0xA97C) || - // Hangul Syllables - (0xAC00 <= codePoint && codePoint <= 0xD7A3) || - // CJK Compatibility Ideographs - (0xF900 <= codePoint && codePoint <= 0xFAFF) || - // Vertical Forms - (0xFE10 <= codePoint && codePoint <= 0xFE19) || - // CJK Compatibility Forms .. Small Form Variants - (0xFE30 <= codePoint && codePoint <= 0xFE6B) || - // Halfwidth and Fullwidth Forms - (0xFF01 <= codePoint && codePoint <= 0xFF60) || - (0xFFE0 <= codePoint && codePoint <= 0xFFE6) || - // Kana Supplement - (0x1B000 <= codePoint && codePoint <= 0x1B001) || - // Enclosed Ideographic Supplement - (0x1F200 <= codePoint && codePoint <= 0x1F251) || - // CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane - (0x20000 <= codePoint && codePoint <= 0x3FFFD) - ) - ) { - return true; - } - - return false; -}; - -module.exports = isFullwidthCodePoint; -module.exports.default = isFullwidthCodePoint; diff --git a/node_modules/cli-columns/node_modules/is-fullwidth-code-point/package.json b/node_modules/cli-columns/node_modules/is-fullwidth-code-point/package.json deleted file mode 100644 index 2137e888fa503..0000000000000 --- a/node_modules/cli-columns/node_modules/is-fullwidth-code-point/package.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "name": "is-fullwidth-code-point", - "version": "3.0.0", - "description": "Check if the character represented by a given Unicode code point is fullwidth", - "license": "MIT", - "repository": "sindresorhus/is-fullwidth-code-point", - "author": { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" - }, - "engines": { - "node": ">=8" - }, - "scripts": { - "test": "xo && ava && tsd-check" - }, - "files": [ - "index.js", - "index.d.ts" - ], - "keywords": [ - "fullwidth", - "full-width", - "full", - "width", - "unicode", - "character", - "string", - "codepoint", - "code", - "point", - "is", - "detect", - "check" - ], - "devDependencies": { - "ava": "^1.3.1", - "tsd-check": "^0.5.0", - "xo": "^0.24.0" - } -} diff --git a/node_modules/cli-columns/node_modules/string-width/index.js b/node_modules/cli-columns/node_modules/string-width/index.js deleted file mode 100644 index f4d261a96a099..0000000000000 --- a/node_modules/cli-columns/node_modules/string-width/index.js +++ /dev/null @@ -1,47 +0,0 @@ -'use strict'; -const stripAnsi = require('strip-ansi'); -const isFullwidthCodePoint = require('is-fullwidth-code-point'); -const emojiRegex = require('emoji-regex'); - -const stringWidth = string => { - if (typeof string !== 'string' || string.length === 0) { - return 0; - } - - string = stripAnsi(string); - - if (string.length === 0) { - return 0; - } - - string = string.replace(emojiRegex(), ' '); - - let width = 0; - - for (let i = 0; i < string.length; i++) { - const code = string.codePointAt(i); - - // Ignore control characters - if (code <= 0x1F || (code >= 0x7F && code <= 0x9F)) { - continue; - } - - // Ignore combining characters - if (code >= 0x300 && code <= 0x36F) { - continue; - } - - // Surrogates - if (code > 0xFFFF) { - i++; - } - - width += isFullwidthCodePoint(code) ? 2 : 1; - } - - return width; -}; - -module.exports = stringWidth; -// TODO: remove this in the next major version -module.exports.default = stringWidth; diff --git a/node_modules/cli-columns/node_modules/string-width/package.json b/node_modules/cli-columns/node_modules/string-width/package.json deleted file mode 100644 index 28ba7b4cae9bf..0000000000000 --- a/node_modules/cli-columns/node_modules/string-width/package.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "name": "string-width", - "version": "4.2.3", - "description": "Get the visual width of a string - the number of columns required to display it", - "license": "MIT", - "repository": "sindresorhus/string-width", - "author": { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" - }, - "engines": { - "node": ">=8" - }, - "scripts": { - "test": "xo && ava && tsd" - }, - "files": [ - "index.js", - "index.d.ts" - ], - "keywords": [ - "string", - "character", - "unicode", - "width", - "visual", - "column", - "columns", - "fullwidth", - "full-width", - "full", - "ansi", - "escape", - "codes", - "cli", - "command-line", - "terminal", - "console", - "cjk", - "chinese", - "japanese", - "korean", - "fixed-width" - ], - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "devDependencies": { - "ava": "^1.4.1", - "tsd": "^0.7.1", - "xo": "^0.24.0" - } -} diff --git a/node_modules/cli-table3/node_modules/ansi-regex/license b/node_modules/cli-table3/node_modules/ansi-regex/license deleted file mode 100644 index e7af2f77107d7..0000000000000 --- a/node_modules/cli-table3/node_modules/ansi-regex/license +++ /dev/null @@ -1,9 +0,0 @@ -MIT License - -Copyright (c) Sindre Sorhus (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. diff --git a/node_modules/cli-table3/node_modules/ansi-regex/readme.md b/node_modules/cli-table3/node_modules/ansi-regex/readme.md deleted file mode 100644 index 3c2b77c4354b6..0000000000000 --- a/node_modules/cli-table3/node_modules/ansi-regex/readme.md +++ /dev/null @@ -1,78 +0,0 @@ -# ansi-regex [![Build Status](https://travis-ci.org/chalk/ansi-regex.svg?branch=master)](https://travis-ci.org/chalk/ansi-regex) - -> Regular expression for matching [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) - - -## Install - -``` -$ npm install ansi-regex -``` - - -## Usage - -```js -const ansiRegex = require('ansi-regex'); - -ansiRegex().test('\u001B[4mcake\u001B[0m'); -//=> true - -ansiRegex().test('cake'); -//=> false - -'\u001B[4mcake\u001B[0m'.match(ansiRegex()); -//=> ['\u001B[4m', '\u001B[0m'] - -'\u001B[4mcake\u001B[0m'.match(ansiRegex({onlyFirst: true})); -//=> ['\u001B[4m'] - -'\u001B]8;;https://github.com\u0007click\u001B]8;;\u0007'.match(ansiRegex()); -//=> ['\u001B]8;;https://github.com\u0007', '\u001B]8;;\u0007'] -``` - - -## API - -### ansiRegex(options?) - -Returns a regex for matching ANSI escape codes. - -#### options - -Type: `object` - -##### onlyFirst - -Type: `boolean`
-Default: `false` *(Matches any ANSI escape codes in a string)* - -Match only the first ANSI escape. - - -## FAQ - -### Why do you test for codes not in the ECMA 48 standard? - -Some of the codes we run as a test are codes that we acquired finding various lists of non-standard or manufacturer specific codes. We test for both standard and non-standard codes, as most of them follow the same or similar format and can be safely matched in strings without the risk of removing actual string content. There are a few non-standard control codes that do not follow the traditional format (i.e. they end in numbers) thus forcing us to exclude them from the test because we cannot reliably match them. - -On the historical side, those ECMA standards were established in the early 90's whereas the VT100, for example, was designed in the mid/late 70's. At that point in time, control codes were still pretty ungoverned and engineers used them for a multitude of things, namely to activate hardware ports that may have been proprietary. Somewhere else you see a similar 'anarchy' of codes is in the x86 architecture for processors; there are a ton of "interrupts" that can mean different things on certain brands of processors, most of which have been phased out. - - -## Maintainers - -- [Sindre Sorhus](https://github.com/sindresorhus) -- [Josh Junon](https://github.com/qix-) - - ---- - -
- - Get professional support for this package with a Tidelift subscription - -
- - Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies. -
-
diff --git a/node_modules/cli-table3/node_modules/is-fullwidth-code-point/index.d.ts b/node_modules/cli-table3/node_modules/is-fullwidth-code-point/index.d.ts deleted file mode 100644 index 729d2020516f0..0000000000000 --- a/node_modules/cli-table3/node_modules/is-fullwidth-code-point/index.d.ts +++ /dev/null @@ -1,17 +0,0 @@ -/** -Check if the character represented by a given [Unicode code point](https://en.wikipedia.org/wiki/Code_point) is [fullwidth](https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms). - -@param codePoint - The [code point](https://en.wikipedia.org/wiki/Code_point) of a character. - -@example -``` -import isFullwidthCodePoint from 'is-fullwidth-code-point'; - -isFullwidthCodePoint('谢'.codePointAt(0)); -//=> true - -isFullwidthCodePoint('a'.codePointAt(0)); -//=> false -``` -*/ -export default function isFullwidthCodePoint(codePoint: number): boolean; diff --git a/node_modules/cli-table3/node_modules/is-fullwidth-code-point/index.js b/node_modules/cli-table3/node_modules/is-fullwidth-code-point/index.js deleted file mode 100644 index 671f97f760779..0000000000000 --- a/node_modules/cli-table3/node_modules/is-fullwidth-code-point/index.js +++ /dev/null @@ -1,50 +0,0 @@ -/* eslint-disable yoda */ -'use strict'; - -const isFullwidthCodePoint = codePoint => { - if (Number.isNaN(codePoint)) { - return false; - } - - // Code points are derived from: - // http://www.unix.org/Public/UNIDATA/EastAsianWidth.txt - if ( - codePoint >= 0x1100 && ( - codePoint <= 0x115F || // Hangul Jamo - codePoint === 0x2329 || // LEFT-POINTING ANGLE BRACKET - codePoint === 0x232A || // RIGHT-POINTING ANGLE BRACKET - // CJK Radicals Supplement .. Enclosed CJK Letters and Months - (0x2E80 <= codePoint && codePoint <= 0x3247 && codePoint !== 0x303F) || - // Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A - (0x3250 <= codePoint && codePoint <= 0x4DBF) || - // CJK Unified Ideographs .. Yi Radicals - (0x4E00 <= codePoint && codePoint <= 0xA4C6) || - // Hangul Jamo Extended-A - (0xA960 <= codePoint && codePoint <= 0xA97C) || - // Hangul Syllables - (0xAC00 <= codePoint && codePoint <= 0xD7A3) || - // CJK Compatibility Ideographs - (0xF900 <= codePoint && codePoint <= 0xFAFF) || - // Vertical Forms - (0xFE10 <= codePoint && codePoint <= 0xFE19) || - // CJK Compatibility Forms .. Small Form Variants - (0xFE30 <= codePoint && codePoint <= 0xFE6B) || - // Halfwidth and Fullwidth Forms - (0xFF01 <= codePoint && codePoint <= 0xFF60) || - (0xFFE0 <= codePoint && codePoint <= 0xFFE6) || - // Kana Supplement - (0x1B000 <= codePoint && codePoint <= 0x1B001) || - // Enclosed Ideographic Supplement - (0x1F200 <= codePoint && codePoint <= 0x1F251) || - // CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane - (0x20000 <= codePoint && codePoint <= 0x3FFFD) - ) - ) { - return true; - } - - return false; -}; - -module.exports = isFullwidthCodePoint; -module.exports.default = isFullwidthCodePoint; diff --git a/node_modules/cli-table3/node_modules/is-fullwidth-code-point/license b/node_modules/cli-table3/node_modules/is-fullwidth-code-point/license deleted file mode 100644 index e7af2f77107d7..0000000000000 --- a/node_modules/cli-table3/node_modules/is-fullwidth-code-point/license +++ /dev/null @@ -1,9 +0,0 @@ -MIT License - -Copyright (c) Sindre Sorhus (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. diff --git a/node_modules/cli-table3/node_modules/is-fullwidth-code-point/package.json b/node_modules/cli-table3/node_modules/is-fullwidth-code-point/package.json deleted file mode 100644 index 2137e888fa503..0000000000000 --- a/node_modules/cli-table3/node_modules/is-fullwidth-code-point/package.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "name": "is-fullwidth-code-point", - "version": "3.0.0", - "description": "Check if the character represented by a given Unicode code point is fullwidth", - "license": "MIT", - "repository": "sindresorhus/is-fullwidth-code-point", - "author": { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" - }, - "engines": { - "node": ">=8" - }, - "scripts": { - "test": "xo && ava && tsd-check" - }, - "files": [ - "index.js", - "index.d.ts" - ], - "keywords": [ - "fullwidth", - "full-width", - "full", - "width", - "unicode", - "character", - "string", - "codepoint", - "code", - "point", - "is", - "detect", - "check" - ], - "devDependencies": { - "ava": "^1.3.1", - "tsd-check": "^0.5.0", - "xo": "^0.24.0" - } -} diff --git a/node_modules/cli-table3/node_modules/is-fullwidth-code-point/readme.md b/node_modules/cli-table3/node_modules/is-fullwidth-code-point/readme.md deleted file mode 100644 index 4236bba980d8f..0000000000000 --- a/node_modules/cli-table3/node_modules/is-fullwidth-code-point/readme.md +++ /dev/null @@ -1,39 +0,0 @@ -# is-fullwidth-code-point [![Build Status](https://travis-ci.org/sindresorhus/is-fullwidth-code-point.svg?branch=master)](https://travis-ci.org/sindresorhus/is-fullwidth-code-point) - -> Check if the character represented by a given [Unicode code point](https://en.wikipedia.org/wiki/Code_point) is [fullwidth](https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms) - - -## Install - -``` -$ npm install is-fullwidth-code-point -``` - - -## Usage - -```js -const isFullwidthCodePoint = require('is-fullwidth-code-point'); - -isFullwidthCodePoint('谢'.codePointAt(0)); -//=> true - -isFullwidthCodePoint('a'.codePointAt(0)); -//=> false -``` - - -## API - -### isFullwidthCodePoint(codePoint) - -#### codePoint - -Type: `number` - -The [code point](https://en.wikipedia.org/wiki/Code_point) of a character. - - -## License - -MIT © [Sindre Sorhus](https://sindresorhus.com) diff --git a/node_modules/cli-table3/node_modules/string-width/index.d.ts b/node_modules/cli-table3/node_modules/string-width/index.d.ts deleted file mode 100644 index 12b5309751dd5..0000000000000 --- a/node_modules/cli-table3/node_modules/string-width/index.d.ts +++ /dev/null @@ -1,29 +0,0 @@ -declare const stringWidth: { - /** - Get the visual width of a string - the number of columns required to display it. - - Some Unicode characters are [fullwidth](https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms) and use double the normal width. [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) are stripped and doesn't affect the width. - - @example - ``` - import stringWidth = require('string-width'); - - stringWidth('a'); - //=> 1 - - stringWidth('古'); - //=> 2 - - stringWidth('\u001B[1m古\u001B[22m'); - //=> 2 - ``` - */ - (string: string): number; - - // TODO: remove this in the next major version, refactor the whole definition to: - // declare function stringWidth(string: string): number; - // export = stringWidth; - default: typeof stringWidth; -} - -export = stringWidth; diff --git a/node_modules/cli-table3/node_modules/string-width/index.js b/node_modules/cli-table3/node_modules/string-width/index.js deleted file mode 100644 index f4d261a96a099..0000000000000 --- a/node_modules/cli-table3/node_modules/string-width/index.js +++ /dev/null @@ -1,47 +0,0 @@ -'use strict'; -const stripAnsi = require('strip-ansi'); -const isFullwidthCodePoint = require('is-fullwidth-code-point'); -const emojiRegex = require('emoji-regex'); - -const stringWidth = string => { - if (typeof string !== 'string' || string.length === 0) { - return 0; - } - - string = stripAnsi(string); - - if (string.length === 0) { - return 0; - } - - string = string.replace(emojiRegex(), ' '); - - let width = 0; - - for (let i = 0; i < string.length; i++) { - const code = string.codePointAt(i); - - // Ignore control characters - if (code <= 0x1F || (code >= 0x7F && code <= 0x9F)) { - continue; - } - - // Ignore combining characters - if (code >= 0x300 && code <= 0x36F) { - continue; - } - - // Surrogates - if (code > 0xFFFF) { - i++; - } - - width += isFullwidthCodePoint(code) ? 2 : 1; - } - - return width; -}; - -module.exports = stringWidth; -// TODO: remove this in the next major version -module.exports.default = stringWidth; diff --git a/node_modules/cli-table3/node_modules/string-width/license b/node_modules/cli-table3/node_modules/string-width/license deleted file mode 100644 index e7af2f77107d7..0000000000000 --- a/node_modules/cli-table3/node_modules/string-width/license +++ /dev/null @@ -1,9 +0,0 @@ -MIT License - -Copyright (c) Sindre Sorhus (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. diff --git a/node_modules/cli-table3/node_modules/string-width/package.json b/node_modules/cli-table3/node_modules/string-width/package.json deleted file mode 100644 index b9b20caaf6f1c..0000000000000 --- a/node_modules/cli-table3/node_modules/string-width/package.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "name": "string-width", - "version": "4.2.2", - "description": "Get the visual width of a string - the number of columns required to display it", - "license": "MIT", - "repository": "sindresorhus/string-width", - "author": { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" - }, - "engines": { - "node": ">=8" - }, - "scripts": { - "test": "xo && ava && tsd" - }, - "files": [ - "index.js", - "index.d.ts" - ], - "keywords": [ - "string", - "character", - "unicode", - "width", - "visual", - "column", - "columns", - "fullwidth", - "full-width", - "full", - "ansi", - "escape", - "codes", - "cli", - "command-line", - "terminal", - "console", - "cjk", - "chinese", - "japanese", - "korean", - "fixed-width" - ], - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.0" - }, - "devDependencies": { - "ava": "^1.4.1", - "tsd": "^0.7.1", - "xo": "^0.24.0" - } -} diff --git a/node_modules/cli-table3/node_modules/string-width/readme.md b/node_modules/cli-table3/node_modules/string-width/readme.md deleted file mode 100644 index bdd314129ca74..0000000000000 --- a/node_modules/cli-table3/node_modules/string-width/readme.md +++ /dev/null @@ -1,50 +0,0 @@ -# string-width - -> Get the visual width of a string - the number of columns required to display it - -Some Unicode characters are [fullwidth](https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms) and use double the normal width. [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) are stripped and doesn't affect the width. - -Useful to be able to measure the actual width of command-line output. - - -## Install - -``` -$ npm install string-width -``` - - -## Usage - -```js -const stringWidth = require('string-width'); - -stringWidth('a'); -//=> 1 - -stringWidth('古'); -//=> 2 - -stringWidth('\u001B[1m古\u001B[22m'); -//=> 2 -``` - - -## Related - -- [string-width-cli](https://github.com/sindresorhus/string-width-cli) - CLI for this module -- [string-length](https://github.com/sindresorhus/string-length) - Get the real length of a string -- [widest-line](https://github.com/sindresorhus/widest-line) - Get the visual width of the widest line in a string - - ---- - -
- - Get professional support for this package with a Tidelift subscription - -
- - Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies. -
-
diff --git a/node_modules/cli-table3/node_modules/strip-ansi/license b/node_modules/cli-table3/node_modules/strip-ansi/license deleted file mode 100644 index e7af2f77107d7..0000000000000 --- a/node_modules/cli-table3/node_modules/strip-ansi/license +++ /dev/null @@ -1,9 +0,0 @@ -MIT License - -Copyright (c) Sindre Sorhus (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. diff --git a/node_modules/cli-table3/node_modules/strip-ansi/readme.md b/node_modules/cli-table3/node_modules/strip-ansi/readme.md deleted file mode 100644 index 7c4b56d46ddc7..0000000000000 --- a/node_modules/cli-table3/node_modules/strip-ansi/readme.md +++ /dev/null @@ -1,46 +0,0 @@ -# strip-ansi [![Build Status](https://travis-ci.org/chalk/strip-ansi.svg?branch=master)](https://travis-ci.org/chalk/strip-ansi) - -> Strip [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) from a string - - -## Install - -``` -$ npm install strip-ansi -``` - - -## Usage - -```js -const stripAnsi = require('strip-ansi'); - -stripAnsi('\u001B[4mUnicorn\u001B[0m'); -//=> 'Unicorn' - -stripAnsi('\u001B]8;;https://github.com\u0007Click\u001B]8;;\u0007'); -//=> 'Click' -``` - - -## strip-ansi for enterprise - -Available as part of the Tidelift Subscription. - -The maintainers of strip-ansi and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-strip-ansi?utm_source=npm-strip-ansi&utm_medium=referral&utm_campaign=enterprise&utm_term=repo) - - -## Related - -- [strip-ansi-cli](https://github.com/chalk/strip-ansi-cli) - CLI for this module -- [strip-ansi-stream](https://github.com/chalk/strip-ansi-stream) - Streaming version of this module -- [has-ansi](https://github.com/chalk/has-ansi) - Check if a string has ANSI escape codes -- [ansi-regex](https://github.com/chalk/ansi-regex) - Regular expression for matching ANSI escape codes -- [chalk](https://github.com/chalk/chalk) - Terminal string styling done right - - -## Maintainers - -- [Sindre Sorhus](https://github.com/sindresorhus) -- [Josh Junon](https://github.com/qix-) - diff --git a/node_modules/columnify/Readme.md b/node_modules/columnify/Readme.md index 4a37928a76203..d94ab9bc5f128 100644 --- a/node_modules/columnify/Readme.md +++ b/node_modules/columnify/Readme.md @@ -1,13 +1,8 @@ # columnify -[![NPM](https://nodei.co/npm/columnify.png?downloads=true&downloadRank=true&stars=true&chrome)](https://nodei.co/npm-dl/columnify/) -[![NPM](https://nodei.co/npm-dl/columnify.png?months=3&height=3&chrome)](https://nodei.co/npm/columnify/) - -[![Build Status](https://img.shields.io/travis/timoxley/columnify.svg?style=flat)](https://travis-ci.org/timoxley/columnify) +[![Columnify Unit Tests](https://github.com/timoxley/columnify/actions/workflows/test.yml/badge.svg)](https://github.com/timoxley/columnify/actions/workflows/test.yml) [![NPM Version](https://img.shields.io/npm/v/columnify.svg?style=flat)](https://npmjs.org/package/columnify) [![License](http://img.shields.io/npm/l/columnify.svg?style=flat)](LICENSE) -[![Dependency Status](https://david-dm.org/timoxley/columnify.svg)](https://david-dm.org/timoxley/columnify) -[![devDependency Status](https://david-dm.org/timoxley/columnify/dev-status.svg)](https://david-dm.org/timoxley/columnify#info=devDependencies) Create text-based columns suitable for console output from objects or arrays of objects. @@ -22,10 +17,10 @@ Designed to [handle sensible wrapping in npm search results](https://github.com/ ![npm-tidy-search](https://f.cloud.github.com/assets/43438/1848959/ae02ad04-76a1-11e3-8255-4781debffc26.gif) -## Installation & Update +## Installation ``` -$ npm install --save columnify@latest +$ npm install columnify ``` ## Usage @@ -379,7 +374,7 @@ var columns = columnify(data, { ``` ### Transforming Column Data and Headers -If you need to modify the presentation of column content or heading content there are two useful options for doing that: `dataTransform` and `headerTransform`. Both of these take a function and need to return a valid string. +If you need to modify the presentation of column content or heading content there are two useful options for doing that: `dataTransform` and `headingTransform`. Both of these take a function and need to return a valid string. ```javascript var columns = columnify([{ @@ -392,6 +387,9 @@ var columns = columnify([{ dataTransform: function(data) { return data.toLowerCase() }, + headingTransform: function(heading) { + return heading.toLowerCase() + }, config: { name: { headingTransform: function(heading) { @@ -404,7 +402,7 @@ var columns = columnify([{ ``` #### Output: ``` -*MODULE NAME* DESCRIPTION +*MODULE NAME* description mod1 some description text. module-two some slightly longer description text. ``` @@ -450,19 +448,26 @@ module-one some description 0.0.1 ``` project : columnify - repo age : 1 year, 2 months - active : 32 days - commits : 120 - files : 54 + repo age : 8 years + active : 47 days + commits : 180 + files : 57 authors : - 90 Tim Oxley 75.0% - 8 Tim 6.7% - 7 Arjun Mehta 5.8% - 6 Dany 5.0% - 5 Wei Gao 4.2% - 2 Dany Shaanan 1.7% - 1 Seth Miller 0.8% - 1 Isaac Z. Schlueter 0.8% + 123 Tim Oxley 68.3% + 11 Nicholas Hoffman 6.1% + 8 Tim 4.4% + 7 Arjun Mehta 3.9% + 6 Dany 3.3% + 5 Tim Kevin Oxley 2.8% + 5 Wei Gao 2.8% + 4 Matias Singers 2.2% + 3 Michael Kriese 1.7% + 2 sreekanth370 1.1% + 2 Dany Shaanan 1.1% + 1 Tim Malone 0.6% + 1 Seth Miller 0.6% + 1 andyfusniak 0.6% + 1 Isaac Z. Schlueter 0.6% ``` ## License diff --git a/node_modules/columnify/columnify.js b/node_modules/columnify/columnify.js index 334d5509ae222..dcef9236e1843 100644 --- a/node_modules/columnify/columnify.js +++ b/node_modules/columnify/columnify.js @@ -2,14 +2,13 @@ var wcwidth = require('./width'); -var _require = require('./utils'); - -var padRight = _require.padRight; -var padCenter = _require.padCenter; -var padLeft = _require.padLeft; -var splitIntoLines = _require.splitIntoLines; -var splitLongWords = _require.splitLongWords; -var truncateString = _require.truncateString; +var _require = require('./utils'), + padRight = _require.padRight, + padCenter = _require.padCenter, + padLeft = _require.padLeft, + splitIntoLines = _require.splitIntoLines, + splitLongWords = _require.splitLongWords, + truncateString = _require.truncateString; var DEFAULT_HEADING_TRANSFORM = function DEFAULT_HEADING_TRANSFORM(key) { return key.toUpperCase(); @@ -33,7 +32,8 @@ var DEFAULTS = Object.freeze({ }); module.exports = function (items) { - var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + var columnConfigs = options.config || {}; delete options.config; // remove config so doesn't appear on every column. @@ -244,9 +244,7 @@ function createRows(items, columns, columnNames, paddingChr) { */ function mixin() { - var _Object; - - if (Object.assign) return (_Object = Object).assign.apply(_Object, arguments); + if (Object.assign) return Object.assign.apply(Object, arguments); return ObjectAssign.apply(undefined, arguments); } diff --git a/node_modules/cli-table3/node_modules/ansi-regex/index.d.ts b/node_modules/columnify/node_modules/ansi-regex/index.d.ts similarity index 100% rename from node_modules/cli-table3/node_modules/ansi-regex/index.d.ts rename to node_modules/columnify/node_modules/ansi-regex/index.d.ts diff --git a/node_modules/cli-table3/node_modules/ansi-regex/index.js b/node_modules/columnify/node_modules/ansi-regex/index.js similarity index 62% rename from node_modules/cli-table3/node_modules/ansi-regex/index.js rename to node_modules/columnify/node_modules/ansi-regex/index.js index 35054aa6774af..616ff837d3ff0 100644 --- a/node_modules/cli-table3/node_modules/ansi-regex/index.js +++ b/node_modules/columnify/node_modules/ansi-regex/index.js @@ -2,7 +2,7 @@ module.exports = ({onlyFirst = false} = {}) => { const pattern = [ - '[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)', + '[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)', '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))' ].join('|'); diff --git a/node_modules/cli-columns/node_modules/is-fullwidth-code-point/license b/node_modules/columnify/node_modules/ansi-regex/license similarity index 100% rename from node_modules/cli-columns/node_modules/is-fullwidth-code-point/license rename to node_modules/columnify/node_modules/ansi-regex/license diff --git a/node_modules/cli-table3/node_modules/ansi-regex/package.json b/node_modules/columnify/node_modules/ansi-regex/package.json similarity index 97% rename from node_modules/cli-table3/node_modules/ansi-regex/package.json rename to node_modules/columnify/node_modules/ansi-regex/package.json index 7af801f352220..017f53116a9e2 100644 --- a/node_modules/cli-table3/node_modules/ansi-regex/package.json +++ b/node_modules/columnify/node_modules/ansi-regex/package.json @@ -1,6 +1,6 @@ { "name": "ansi-regex", - "version": "5.0.0", + "version": "5.0.1", "description": "Regular expression for matching ANSI escape codes", "license": "MIT", "repository": "chalk/ansi-regex", diff --git a/node_modules/cli-table3/node_modules/strip-ansi/index.d.ts b/node_modules/columnify/node_modules/strip-ansi/index.d.ts similarity index 100% rename from node_modules/cli-table3/node_modules/strip-ansi/index.d.ts rename to node_modules/columnify/node_modules/strip-ansi/index.d.ts diff --git a/node_modules/cli-table3/node_modules/strip-ansi/index.js b/node_modules/columnify/node_modules/strip-ansi/index.js similarity index 100% rename from node_modules/cli-table3/node_modules/strip-ansi/index.js rename to node_modules/columnify/node_modules/strip-ansi/index.js diff --git a/node_modules/cli-columns/node_modules/string-width/license b/node_modules/columnify/node_modules/strip-ansi/license similarity index 100% rename from node_modules/cli-columns/node_modules/string-width/license rename to node_modules/columnify/node_modules/strip-ansi/license diff --git a/node_modules/cli-table3/node_modules/strip-ansi/package.json b/node_modules/columnify/node_modules/strip-ansi/package.json similarity index 94% rename from node_modules/cli-table3/node_modules/strip-ansi/package.json rename to node_modules/columnify/node_modules/strip-ansi/package.json index 65a6c95161f74..1a41108d42831 100644 --- a/node_modules/cli-table3/node_modules/strip-ansi/package.json +++ b/node_modules/columnify/node_modules/strip-ansi/package.json @@ -1,6 +1,6 @@ { "name": "strip-ansi", - "version": "6.0.0", + "version": "6.0.1", "description": "Strip ANSI escape codes from a string", "license": "MIT", "repository": "chalk/strip-ansi", @@ -44,7 +44,7 @@ "text" ], "dependencies": { - "ansi-regex": "^5.0.0" + "ansi-regex": "^5.0.1" }, "devDependencies": { "ava": "^2.4.0", diff --git a/node_modules/columnify/package.json b/node_modules/columnify/package.json index 4bff7f5268471..29565407a8cd7 100644 --- a/node_modules/columnify/package.json +++ b/node_modules/columnify/package.json @@ -1,6 +1,6 @@ { "name": "columnify", - "version": "1.5.4", + "version": "1.6.0", "description": "Render data in text columns. Supports in-column text-wrap.", "main": "columnify.js", "scripts": { @@ -17,11 +17,10 @@ "author": "Tim Oxley", "license": "MIT", "devDependencies": { - "babel": "^6.3.26", - "babel-cli": "^6.3.17", + "babel-cli": "^6.26.0", "babel-preset-es2015": "^6.3.13", "chalk": "^1.1.1", - "tap-spec": "^4.1.1", + "tap-spec": "^5.0.0", "tape": "^4.4.0" }, "repository": { @@ -41,8 +40,11 @@ "url": "https://github.com/timoxley/columnify/issues" }, "homepage": "https://github.com/timoxley/columnify", + "engines": { + "node": ">=8.0.0" + }, "dependencies": { - "strip-ansi": "^3.0.0", + "strip-ansi": "^6.0.1", "wcwidth": "^1.0.0" }, "directories": { diff --git a/node_modules/gauge/node_modules/is-fullwidth-code-point/index.d.ts b/node_modules/gauge/node_modules/is-fullwidth-code-point/index.d.ts deleted file mode 100644 index 729d2020516f0..0000000000000 --- a/node_modules/gauge/node_modules/is-fullwidth-code-point/index.d.ts +++ /dev/null @@ -1,17 +0,0 @@ -/** -Check if the character represented by a given [Unicode code point](https://en.wikipedia.org/wiki/Code_point) is [fullwidth](https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms). - -@param codePoint - The [code point](https://en.wikipedia.org/wiki/Code_point) of a character. - -@example -``` -import isFullwidthCodePoint from 'is-fullwidth-code-point'; - -isFullwidthCodePoint('谢'.codePointAt(0)); -//=> true - -isFullwidthCodePoint('a'.codePointAt(0)); -//=> false -``` -*/ -export default function isFullwidthCodePoint(codePoint: number): boolean; diff --git a/node_modules/gauge/node_modules/is-fullwidth-code-point/index.js b/node_modules/gauge/node_modules/is-fullwidth-code-point/index.js deleted file mode 100644 index 671f97f760779..0000000000000 --- a/node_modules/gauge/node_modules/is-fullwidth-code-point/index.js +++ /dev/null @@ -1,50 +0,0 @@ -/* eslint-disable yoda */ -'use strict'; - -const isFullwidthCodePoint = codePoint => { - if (Number.isNaN(codePoint)) { - return false; - } - - // Code points are derived from: - // http://www.unix.org/Public/UNIDATA/EastAsianWidth.txt - if ( - codePoint >= 0x1100 && ( - codePoint <= 0x115F || // Hangul Jamo - codePoint === 0x2329 || // LEFT-POINTING ANGLE BRACKET - codePoint === 0x232A || // RIGHT-POINTING ANGLE BRACKET - // CJK Radicals Supplement .. Enclosed CJK Letters and Months - (0x2E80 <= codePoint && codePoint <= 0x3247 && codePoint !== 0x303F) || - // Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A - (0x3250 <= codePoint && codePoint <= 0x4DBF) || - // CJK Unified Ideographs .. Yi Radicals - (0x4E00 <= codePoint && codePoint <= 0xA4C6) || - // Hangul Jamo Extended-A - (0xA960 <= codePoint && codePoint <= 0xA97C) || - // Hangul Syllables - (0xAC00 <= codePoint && codePoint <= 0xD7A3) || - // CJK Compatibility Ideographs - (0xF900 <= codePoint && codePoint <= 0xFAFF) || - // Vertical Forms - (0xFE10 <= codePoint && codePoint <= 0xFE19) || - // CJK Compatibility Forms .. Small Form Variants - (0xFE30 <= codePoint && codePoint <= 0xFE6B) || - // Halfwidth and Fullwidth Forms - (0xFF01 <= codePoint && codePoint <= 0xFF60) || - (0xFFE0 <= codePoint && codePoint <= 0xFFE6) || - // Kana Supplement - (0x1B000 <= codePoint && codePoint <= 0x1B001) || - // Enclosed Ideographic Supplement - (0x1F200 <= codePoint && codePoint <= 0x1F251) || - // CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane - (0x20000 <= codePoint && codePoint <= 0x3FFFD) - ) - ) { - return true; - } - - return false; -}; - -module.exports = isFullwidthCodePoint; -module.exports.default = isFullwidthCodePoint; diff --git a/node_modules/gauge/node_modules/is-fullwidth-code-point/license b/node_modules/gauge/node_modules/is-fullwidth-code-point/license deleted file mode 100644 index e7af2f77107d7..0000000000000 --- a/node_modules/gauge/node_modules/is-fullwidth-code-point/license +++ /dev/null @@ -1,9 +0,0 @@ -MIT License - -Copyright (c) Sindre Sorhus (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. diff --git a/node_modules/gauge/node_modules/is-fullwidth-code-point/package.json b/node_modules/gauge/node_modules/is-fullwidth-code-point/package.json deleted file mode 100644 index 2137e888fa503..0000000000000 --- a/node_modules/gauge/node_modules/is-fullwidth-code-point/package.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "name": "is-fullwidth-code-point", - "version": "3.0.0", - "description": "Check if the character represented by a given Unicode code point is fullwidth", - "license": "MIT", - "repository": "sindresorhus/is-fullwidth-code-point", - "author": { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" - }, - "engines": { - "node": ">=8" - }, - "scripts": { - "test": "xo && ava && tsd-check" - }, - "files": [ - "index.js", - "index.d.ts" - ], - "keywords": [ - "fullwidth", - "full-width", - "full", - "width", - "unicode", - "character", - "string", - "codepoint", - "code", - "point", - "is", - "detect", - "check" - ], - "devDependencies": { - "ava": "^1.3.1", - "tsd-check": "^0.5.0", - "xo": "^0.24.0" - } -} diff --git a/node_modules/gauge/node_modules/string-width/index.d.ts b/node_modules/gauge/node_modules/string-width/index.d.ts deleted file mode 100644 index 12b5309751dd5..0000000000000 --- a/node_modules/gauge/node_modules/string-width/index.d.ts +++ /dev/null @@ -1,29 +0,0 @@ -declare const stringWidth: { - /** - Get the visual width of a string - the number of columns required to display it. - - Some Unicode characters are [fullwidth](https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms) and use double the normal width. [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) are stripped and doesn't affect the width. - - @example - ``` - import stringWidth = require('string-width'); - - stringWidth('a'); - //=> 1 - - stringWidth('古'); - //=> 2 - - stringWidth('\u001B[1m古\u001B[22m'); - //=> 2 - ``` - */ - (string: string): number; - - // TODO: remove this in the next major version, refactor the whole definition to: - // declare function stringWidth(string: string): number; - // export = stringWidth; - default: typeof stringWidth; -} - -export = stringWidth; diff --git a/node_modules/gauge/node_modules/string-width/index.js b/node_modules/gauge/node_modules/string-width/index.js deleted file mode 100644 index f4d261a96a099..0000000000000 --- a/node_modules/gauge/node_modules/string-width/index.js +++ /dev/null @@ -1,47 +0,0 @@ -'use strict'; -const stripAnsi = require('strip-ansi'); -const isFullwidthCodePoint = require('is-fullwidth-code-point'); -const emojiRegex = require('emoji-regex'); - -const stringWidth = string => { - if (typeof string !== 'string' || string.length === 0) { - return 0; - } - - string = stripAnsi(string); - - if (string.length === 0) { - return 0; - } - - string = string.replace(emojiRegex(), ' '); - - let width = 0; - - for (let i = 0; i < string.length; i++) { - const code = string.codePointAt(i); - - // Ignore control characters - if (code <= 0x1F || (code >= 0x7F && code <= 0x9F)) { - continue; - } - - // Ignore combining characters - if (code >= 0x300 && code <= 0x36F) { - continue; - } - - // Surrogates - if (code > 0xFFFF) { - i++; - } - - width += isFullwidthCodePoint(code) ? 2 : 1; - } - - return width; -}; - -module.exports = stringWidth; -// TODO: remove this in the next major version -module.exports.default = stringWidth; diff --git a/node_modules/gauge/node_modules/string-width/license b/node_modules/gauge/node_modules/string-width/license deleted file mode 100644 index e7af2f77107d7..0000000000000 --- a/node_modules/gauge/node_modules/string-width/license +++ /dev/null @@ -1,9 +0,0 @@ -MIT License - -Copyright (c) Sindre Sorhus (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. diff --git a/node_modules/gauge/node_modules/string-width/package.json b/node_modules/gauge/node_modules/string-width/package.json deleted file mode 100644 index 28ba7b4cae9bf..0000000000000 --- a/node_modules/gauge/node_modules/string-width/package.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "name": "string-width", - "version": "4.2.3", - "description": "Get the visual width of a string - the number of columns required to display it", - "license": "MIT", - "repository": "sindresorhus/string-width", - "author": { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" - }, - "engines": { - "node": ">=8" - }, - "scripts": { - "test": "xo && ava && tsd" - }, - "files": [ - "index.js", - "index.d.ts" - ], - "keywords": [ - "string", - "character", - "unicode", - "width", - "visual", - "column", - "columns", - "fullwidth", - "full-width", - "full", - "ansi", - "escape", - "codes", - "cli", - "command-line", - "terminal", - "console", - "cjk", - "chinese", - "japanese", - "korean", - "fixed-width" - ], - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "devDependencies": { - "ava": "^1.4.1", - "tsd": "^0.7.1", - "xo": "^0.24.0" - } -} diff --git a/node_modules/cli-columns/node_modules/is-fullwidth-code-point/index.d.ts b/node_modules/is-fullwidth-code-point/index.d.ts similarity index 100% rename from node_modules/cli-columns/node_modules/is-fullwidth-code-point/index.d.ts rename to node_modules/is-fullwidth-code-point/index.d.ts diff --git a/node_modules/is-fullwidth-code-point/index.js b/node_modules/is-fullwidth-code-point/index.js index d506327c3e557..671f97f760779 100644 --- a/node_modules/is-fullwidth-code-point/index.js +++ b/node_modules/is-fullwidth-code-point/index.js @@ -1,42 +1,43 @@ -'use strict'; /* eslint-disable yoda */ -module.exports = x => { - if (Number.isNaN(x)) { +'use strict'; + +const isFullwidthCodePoint = codePoint => { + if (Number.isNaN(codePoint)) { return false; } - // code points are derived from: + // Code points are derived from: // http://www.unix.org/Public/UNIDATA/EastAsianWidth.txt if ( - x >= 0x1100 && ( - x <= 0x115f || // Hangul Jamo - x === 0x2329 || // LEFT-POINTING ANGLE BRACKET - x === 0x232a || // RIGHT-POINTING ANGLE BRACKET + codePoint >= 0x1100 && ( + codePoint <= 0x115F || // Hangul Jamo + codePoint === 0x2329 || // LEFT-POINTING ANGLE BRACKET + codePoint === 0x232A || // RIGHT-POINTING ANGLE BRACKET // CJK Radicals Supplement .. Enclosed CJK Letters and Months - (0x2e80 <= x && x <= 0x3247 && x !== 0x303f) || + (0x2E80 <= codePoint && codePoint <= 0x3247 && codePoint !== 0x303F) || // Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A - (0x3250 <= x && x <= 0x4dbf) || + (0x3250 <= codePoint && codePoint <= 0x4DBF) || // CJK Unified Ideographs .. Yi Radicals - (0x4e00 <= x && x <= 0xa4c6) || + (0x4E00 <= codePoint && codePoint <= 0xA4C6) || // Hangul Jamo Extended-A - (0xa960 <= x && x <= 0xa97c) || + (0xA960 <= codePoint && codePoint <= 0xA97C) || // Hangul Syllables - (0xac00 <= x && x <= 0xd7a3) || + (0xAC00 <= codePoint && codePoint <= 0xD7A3) || // CJK Compatibility Ideographs - (0xf900 <= x && x <= 0xfaff) || + (0xF900 <= codePoint && codePoint <= 0xFAFF) || // Vertical Forms - (0xfe10 <= x && x <= 0xfe19) || + (0xFE10 <= codePoint && codePoint <= 0xFE19) || // CJK Compatibility Forms .. Small Form Variants - (0xfe30 <= x && x <= 0xfe6b) || + (0xFE30 <= codePoint && codePoint <= 0xFE6B) || // Halfwidth and Fullwidth Forms - (0xff01 <= x && x <= 0xff60) || - (0xffe0 <= x && x <= 0xffe6) || + (0xFF01 <= codePoint && codePoint <= 0xFF60) || + (0xFFE0 <= codePoint && codePoint <= 0xFFE6) || // Kana Supplement - (0x1b000 <= x && x <= 0x1b001) || + (0x1B000 <= codePoint && codePoint <= 0x1B001) || // Enclosed Ideographic Supplement - (0x1f200 <= x && x <= 0x1f251) || + (0x1F200 <= codePoint && codePoint <= 0x1F251) || // CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane - (0x20000 <= x && x <= 0x3fffd) + (0x20000 <= codePoint && codePoint <= 0x3FFFD) ) ) { return true; @@ -44,3 +45,6 @@ module.exports = x => { return false; }; + +module.exports = isFullwidthCodePoint; +module.exports.default = isFullwidthCodePoint; diff --git a/node_modules/is-fullwidth-code-point/license b/node_modules/is-fullwidth-code-point/license index 654d0bfe94343..e7af2f77107d7 100644 --- a/node_modules/is-fullwidth-code-point/license +++ b/node_modules/is-fullwidth-code-point/license @@ -1,21 +1,9 @@ -The MIT License (MIT) +MIT License Copyright (c) Sindre Sorhus (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: +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 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. +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. diff --git a/node_modules/is-fullwidth-code-point/package.json b/node_modules/is-fullwidth-code-point/package.json index 3049d9e030499..2137e888fa503 100644 --- a/node_modules/is-fullwidth-code-point/package.json +++ b/node_modules/is-fullwidth-code-point/package.json @@ -1,45 +1,42 @@ { - "name": "is-fullwidth-code-point", - "version": "2.0.0", - "description": "Check if the character represented by a given Unicode code point is fullwidth", - "license": "MIT", - "repository": "sindresorhus/is-fullwidth-code-point", - "author": { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" - }, - "engines": { - "node": ">=4" - }, - "scripts": { - "test": "xo && ava" - }, - "files": [ - "index.js" - ], - "keywords": [ - "fullwidth", - "full-width", - "full", - "width", - "unicode", - "character", - "char", - "string", - "str", - "codepoint", - "code", - "point", - "is", - "detect", - "check" - ], - "devDependencies": { - "ava": "*", - "xo": "*" - }, - "xo": { - "esnext": true - } + "name": "is-fullwidth-code-point", + "version": "3.0.0", + "description": "Check if the character represented by a given Unicode code point is fullwidth", + "license": "MIT", + "repository": "sindresorhus/is-fullwidth-code-point", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "sindresorhus.com" + }, + "engines": { + "node": ">=8" + }, + "scripts": { + "test": "xo && ava && tsd-check" + }, + "files": [ + "index.js", + "index.d.ts" + ], + "keywords": [ + "fullwidth", + "full-width", + "full", + "width", + "unicode", + "character", + "string", + "codepoint", + "code", + "point", + "is", + "detect", + "check" + ], + "devDependencies": { + "ava": "^1.3.1", + "tsd-check": "^0.5.0", + "xo": "^0.24.0" + } } diff --git a/node_modules/is-fullwidth-code-point/readme.md b/node_modules/is-fullwidth-code-point/readme.md index 093b0281b2c46..4236bba980d8f 100644 --- a/node_modules/is-fullwidth-code-point/readme.md +++ b/node_modules/is-fullwidth-code-point/readme.md @@ -6,7 +6,7 @@ ## Install ``` -$ npm install --save is-fullwidth-code-point +$ npm install is-fullwidth-code-point ``` @@ -15,23 +15,23 @@ $ npm install --save is-fullwidth-code-point ```js const isFullwidthCodePoint = require('is-fullwidth-code-point'); -isFullwidthCodePoint('谢'.codePointAt()); +isFullwidthCodePoint('谢'.codePointAt(0)); //=> true -isFullwidthCodePoint('a'.codePointAt()); +isFullwidthCodePoint('a'.codePointAt(0)); //=> false ``` ## API -### isFullwidthCodePoint(input) +### isFullwidthCodePoint(codePoint) -#### input +#### codePoint Type: `number` -[Code point](https://en.wikipedia.org/wiki/Code_point) of a character. +The [code point](https://en.wikipedia.org/wiki/Code_point) of a character. ## License diff --git a/node_modules/cli-columns/node_modules/string-width/index.d.ts b/node_modules/string-width/index.d.ts similarity index 100% rename from node_modules/cli-columns/node_modules/string-width/index.d.ts rename to node_modules/string-width/index.d.ts diff --git a/node_modules/string-width/index.js b/node_modules/string-width/index.js index bbc49d29b156c..f4d261a96a099 100644 --- a/node_modules/string-width/index.js +++ b/node_modules/string-width/index.js @@ -1,18 +1,25 @@ 'use strict'; const stripAnsi = require('strip-ansi'); const isFullwidthCodePoint = require('is-fullwidth-code-point'); +const emojiRegex = require('emoji-regex'); -module.exports = str => { - if (typeof str !== 'string' || str.length === 0) { +const stringWidth = string => { + if (typeof string !== 'string' || string.length === 0) { return 0; } - str = stripAnsi(str); + string = stripAnsi(string); + + if (string.length === 0) { + return 0; + } + + string = string.replace(emojiRegex(), ' '); let width = 0; - for (let i = 0; i < str.length; i++) { - const code = str.codePointAt(i); + for (let i = 0; i < string.length; i++) { + const code = string.codePointAt(i); // Ignore control characters if (code <= 0x1F || (code >= 0x7F && code <= 0x9F)) { @@ -34,3 +41,7 @@ module.exports = str => { return width; }; + +module.exports = stringWidth; +// TODO: remove this in the next major version +module.exports.default = stringWidth; diff --git a/node_modules/string-width/node_modules/ansi-regex/index.d.ts b/node_modules/string-width/node_modules/ansi-regex/index.d.ts new file mode 100644 index 0000000000000..2dbf6af2b6f3b --- /dev/null +++ b/node_modules/string-width/node_modules/ansi-regex/index.d.ts @@ -0,0 +1,37 @@ +declare namespace ansiRegex { + interface Options { + /** + Match only the first ANSI escape. + + @default false + */ + onlyFirst: boolean; + } +} + +/** +Regular expression for matching ANSI escape codes. + +@example +``` +import ansiRegex = require('ansi-regex'); + +ansiRegex().test('\u001B[4mcake\u001B[0m'); +//=> true + +ansiRegex().test('cake'); +//=> false + +'\u001B[4mcake\u001B[0m'.match(ansiRegex()); +//=> ['\u001B[4m', '\u001B[0m'] + +'\u001B[4mcake\u001B[0m'.match(ansiRegex({onlyFirst: true})); +//=> ['\u001B[4m'] + +'\u001B]8;;https://github.com\u0007click\u001B]8;;\u0007'.match(ansiRegex()); +//=> ['\u001B]8;;https://github.com\u0007', '\u001B]8;;\u0007'] +``` +*/ +declare function ansiRegex(options?: ansiRegex.Options): RegExp; + +export = ansiRegex; diff --git a/node_modules/string-width/node_modules/ansi-regex/index.js b/node_modules/string-width/node_modules/ansi-regex/index.js index c4aaecf505063..616ff837d3ff0 100644 --- a/node_modules/string-width/node_modules/ansi-regex/index.js +++ b/node_modules/string-width/node_modules/ansi-regex/index.js @@ -1,10 +1,10 @@ 'use strict'; -module.exports = () => { +module.exports = ({onlyFirst = false} = {}) => { const pattern = [ - '[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\\u0007)', - '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))' + '[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)', + '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))' ].join('|'); - return new RegExp(pattern, 'g'); + return new RegExp(pattern, onlyFirst ? undefined : 'g'); }; diff --git a/node_modules/string-width/node_modules/ansi-regex/package.json b/node_modules/string-width/node_modules/ansi-regex/package.json index e94852fd70b09..017f53116a9e2 100644 --- a/node_modules/string-width/node_modules/ansi-regex/package.json +++ b/node_modules/string-width/node_modules/ansi-regex/package.json @@ -1,53 +1,55 @@ { - "name": "ansi-regex", - "version": "3.0.0", - "description": "Regular expression for matching ANSI escape codes", - "license": "MIT", - "repository": "chalk/ansi-regex", - "author": { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" - }, - "engines": { - "node": ">=4" - }, - "scripts": { - "test": "xo && ava", - "view-supported": "node fixtures/view-codes.js" - }, - "files": [ - "index.js" - ], - "keywords": [ - "ansi", - "styles", - "color", - "colour", - "colors", - "terminal", - "console", - "cli", - "string", - "tty", - "escape", - "formatting", - "rgb", - "256", - "shell", - "xterm", - "command-line", - "text", - "regex", - "regexp", - "re", - "match", - "test", - "find", - "pattern" - ], - "devDependencies": { - "ava": "*", - "xo": "*" - } + "name": "ansi-regex", + "version": "5.0.1", + "description": "Regular expression for matching ANSI escape codes", + "license": "MIT", + "repository": "chalk/ansi-regex", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "sindresorhus.com" + }, + "engines": { + "node": ">=8" + }, + "scripts": { + "test": "xo && ava && tsd", + "view-supported": "node fixtures/view-codes.js" + }, + "files": [ + "index.js", + "index.d.ts" + ], + "keywords": [ + "ansi", + "styles", + "color", + "colour", + "colors", + "terminal", + "console", + "cli", + "string", + "tty", + "escape", + "formatting", + "rgb", + "256", + "shell", + "xterm", + "command-line", + "text", + "regex", + "regexp", + "re", + "match", + "test", + "find", + "pattern" + ], + "devDependencies": { + "ava": "^2.4.0", + "tsd": "^0.9.0", + "xo": "^0.25.3" + } } diff --git a/node_modules/string-width/node_modules/ansi-regex/readme.md b/node_modules/string-width/node_modules/ansi-regex/readme.md index 22db1c3405555..4d848bc36f6b8 100644 --- a/node_modules/string-width/node_modules/ansi-regex/readme.md +++ b/node_modules/string-width/node_modules/ansi-regex/readme.md @@ -1,4 +1,4 @@ -# ansi-regex [![Build Status](https://travis-ci.org/chalk/ansi-regex.svg?branch=master)](https://travis-ci.org/chalk/ansi-regex) +# ansi-regex > Regular expression for matching [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) @@ -23,9 +23,33 @@ ansiRegex().test('cake'); '\u001B[4mcake\u001B[0m'.match(ansiRegex()); //=> ['\u001B[4m', '\u001B[0m'] + +'\u001B[4mcake\u001B[0m'.match(ansiRegex({onlyFirst: true})); +//=> ['\u001B[4m'] + +'\u001B]8;;https://github.com\u0007click\u001B]8;;\u0007'.match(ansiRegex()); +//=> ['\u001B]8;;https://github.com\u0007', '\u001B]8;;\u0007'] ``` +## API + +### ansiRegex(options?) + +Returns a regex for matching ANSI escape codes. + +#### options + +Type: `object` + +##### onlyFirst + +Type: `boolean`
+Default: `false` *(Matches any ANSI escape codes in a string)* + +Match only the first ANSI escape. + + ## FAQ ### Why do you test for codes not in the ECMA 48 standard? @@ -41,6 +65,14 @@ On the historical side, those ECMA standards were established in the early 90's - [Josh Junon](https://github.com/qix-) -## License +--- -MIT +
+ + Get professional support for this package with a Tidelift subscription + +
+ + Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies. +
+
diff --git a/node_modules/string-width/node_modules/strip-ansi/index.d.ts b/node_modules/string-width/node_modules/strip-ansi/index.d.ts new file mode 100644 index 0000000000000..907fccc29269e --- /dev/null +++ b/node_modules/string-width/node_modules/strip-ansi/index.d.ts @@ -0,0 +1,17 @@ +/** +Strip [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) from a string. + +@example +``` +import stripAnsi = require('strip-ansi'); + +stripAnsi('\u001B[4mUnicorn\u001B[0m'); +//=> 'Unicorn' + +stripAnsi('\u001B]8;;https://github.com\u0007Click\u001B]8;;\u0007'); +//=> 'Click' +``` +*/ +declare function stripAnsi(string: string): string; + +export = stripAnsi; diff --git a/node_modules/string-width/node_modules/strip-ansi/index.js b/node_modules/string-width/node_modules/strip-ansi/index.js index 96e0292c8e2f6..9a593dfcd1fd5 100644 --- a/node_modules/string-width/node_modules/strip-ansi/index.js +++ b/node_modules/string-width/node_modules/strip-ansi/index.js @@ -1,4 +1,4 @@ 'use strict'; const ansiRegex = require('ansi-regex'); -module.exports = input => typeof input === 'string' ? input.replace(ansiRegex(), '') : input; +module.exports = string => typeof string === 'string' ? string.replace(ansiRegex(), '') : string; diff --git a/node_modules/string-width/node_modules/strip-ansi/package.json b/node_modules/string-width/node_modules/strip-ansi/package.json index 555f194616501..1a41108d42831 100644 --- a/node_modules/string-width/node_modules/strip-ansi/package.json +++ b/node_modules/string-width/node_modules/strip-ansi/package.json @@ -1,52 +1,54 @@ { - "name": "strip-ansi", - "version": "4.0.0", - "description": "Strip ANSI escape codes", - "license": "MIT", - "repository": "chalk/strip-ansi", - "author": { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" - }, - "engines": { - "node": ">=4" - }, - "scripts": { - "test": "xo && ava" - }, - "files": [ - "index.js" - ], - "keywords": [ - "strip", - "trim", - "remove", - "ansi", - "styles", - "color", - "colour", - "colors", - "terminal", - "console", - "string", - "tty", - "escape", - "formatting", - "rgb", - "256", - "shell", - "xterm", - "log", - "logging", - "command-line", - "text" - ], - "dependencies": { - "ansi-regex": "^3.0.0" - }, - "devDependencies": { - "ava": "*", - "xo": "*" - } + "name": "strip-ansi", + "version": "6.0.1", + "description": "Strip ANSI escape codes from a string", + "license": "MIT", + "repository": "chalk/strip-ansi", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "sindresorhus.com" + }, + "engines": { + "node": ">=8" + }, + "scripts": { + "test": "xo && ava && tsd" + }, + "files": [ + "index.js", + "index.d.ts" + ], + "keywords": [ + "strip", + "trim", + "remove", + "ansi", + "styles", + "color", + "colour", + "colors", + "terminal", + "console", + "string", + "tty", + "escape", + "formatting", + "rgb", + "256", + "shell", + "xterm", + "log", + "logging", + "command-line", + "text" + ], + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "devDependencies": { + "ava": "^2.4.0", + "tsd": "^0.10.0", + "xo": "^0.25.3" + } } diff --git a/node_modules/string-width/node_modules/strip-ansi/readme.md b/node_modules/string-width/node_modules/strip-ansi/readme.md index dc76f0cb1a059..7c4b56d46ddc7 100644 --- a/node_modules/string-width/node_modules/strip-ansi/readme.md +++ b/node_modules/string-width/node_modules/strip-ansi/readme.md @@ -1,6 +1,6 @@ # strip-ansi [![Build Status](https://travis-ci.org/chalk/strip-ansi.svg?branch=master)](https://travis-ci.org/chalk/strip-ansi) -> Strip [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) +> Strip [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) from a string ## Install @@ -17,12 +17,23 @@ const stripAnsi = require('strip-ansi'); stripAnsi('\u001B[4mUnicorn\u001B[0m'); //=> 'Unicorn' + +stripAnsi('\u001B]8;;https://github.com\u0007Click\u001B]8;;\u0007'); +//=> 'Click' ``` +## strip-ansi for enterprise + +Available as part of the Tidelift Subscription. + +The maintainers of strip-ansi and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-strip-ansi?utm_source=npm-strip-ansi&utm_medium=referral&utm_campaign=enterprise&utm_term=repo) + + ## Related - [strip-ansi-cli](https://github.com/chalk/strip-ansi-cli) - CLI for this module +- [strip-ansi-stream](https://github.com/chalk/strip-ansi-stream) - Streaming version of this module - [has-ansi](https://github.com/chalk/has-ansi) - Check if a string has ANSI escape codes - [ansi-regex](https://github.com/chalk/ansi-regex) - Regular expression for matching ANSI escape codes - [chalk](https://github.com/chalk/chalk) - Terminal string styling done right @@ -33,7 +44,3 @@ stripAnsi('\u001B[4mUnicorn\u001B[0m'); - [Sindre Sorhus](https://github.com/sindresorhus) - [Josh Junon](https://github.com/qix-) - -## License - -MIT diff --git a/node_modules/string-width/package.json b/node_modules/string-width/package.json index 89f0b6a6c6027..28ba7b4cae9bf 100644 --- a/node_modules/string-width/package.json +++ b/node_modules/string-width/package.json @@ -1,6 +1,6 @@ { "name": "string-width", - "version": "2.1.1", + "version": "4.2.3", "description": "Get the visual width of a string - the number of columns required to display it", "license": "MIT", "repository": "sindresorhus/string-width", @@ -10,19 +10,18 @@ "url": "sindresorhus.com" }, "engines": { - "node": ">=4" + "node": ">=8" }, "scripts": { - "test": "xo && ava" + "test": "xo && ava && tsd" }, "files": [ - "index.js" + "index.js", + "index.d.ts" ], "keywords": [ "string", - "str", "character", - "char", "unicode", "width", "visual", @@ -45,11 +44,13 @@ "fixed-width" ], "dependencies": { - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^4.0.0" + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" }, "devDependencies": { - "ava": "*", - "xo": "*" + "ava": "^1.4.1", + "tsd": "^0.7.1", + "xo": "^0.24.0" } } diff --git a/node_modules/string-width/readme.md b/node_modules/string-width/readme.md index df5b7199f9091..bdd314129ca74 100644 --- a/node_modules/string-width/readme.md +++ b/node_modules/string-width/readme.md @@ -1,4 +1,4 @@ -# string-width [![Build Status](https://travis-ci.org/sindresorhus/string-width.svg?branch=master)](https://travis-ci.org/sindresorhus/string-width) +# string-width > Get the visual width of a string - the number of columns required to display it @@ -19,14 +19,14 @@ $ npm install string-width ```js const stringWidth = require('string-width'); +stringWidth('a'); +//=> 1 + stringWidth('古'); //=> 2 -stringWidth('\u001b[1m古\u001b[22m'); +stringWidth('\u001B[1m古\u001B[22m'); //=> 2 - -stringWidth('a'); -//=> 1 ``` @@ -37,6 +37,14 @@ stringWidth('a'); - [widest-line](https://github.com/sindresorhus/widest-line) - Get the visual width of the widest line in a string -## License +--- -MIT © [Sindre Sorhus](https://sindresorhus.com) +
+ + Get professional support for this package with a Tidelift subscription + +
+ + Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies. +
+
diff --git a/package-lock.json b/package-lock.json index 0e6871d7773bf..25f28f9d6e9b3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -102,7 +102,7 @@ "chownr": "^2.0.0", "cli-columns": "^4.0.0", "cli-table3": "^0.6.1", - "columnify": "~1.5.4", + "columnify": "^1.6.0", "fastest-levenshtein": "^1.0.12", "glob": "^7.2.0", "graceful-fs": "^4.2.9", @@ -1174,7 +1174,7 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "inBundle": true, + "dev": true, "engines": { "node": ">=0.10.0" } @@ -1831,29 +1831,6 @@ "node": ">=8" } }, - "node_modules/cli-columns/node_modules/is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "inBundle": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/cli-columns/node_modules/string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "inBundle": true, - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/cli-columns/node_modules/strip-ansi": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", @@ -1881,50 +1858,6 @@ "colors": "1.4.0" } }, - "node_modules/cli-table3/node_modules/ansi-regex": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", - "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", - "inBundle": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/cli-table3/node_modules/is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "inBundle": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/cli-table3/node_modules/string-width": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz", - "integrity": "sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA==", - "inBundle": true, - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/cli-table3/node_modules/strip-ansi": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", - "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", - "inBundle": true, - "dependencies": { - "ansi-regex": "^5.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/cliui": { "version": "7.0.4", "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", @@ -1945,29 +1878,6 @@ "node": ">=8" } }, - "node_modules/cliui/node_modules/is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/cliui/node_modules/string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/cliui/node_modules/strip-ansi": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", @@ -2072,13 +1982,37 @@ } }, "node_modules/columnify": { - "version": "1.5.4", - "resolved": "https://registry.npmjs.org/columnify/-/columnify-1.5.4.tgz", - "integrity": "sha1-Rzfd8ce2mop8NAVweC6UfuyOeLs=", + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/columnify/-/columnify-1.6.0.tgz", + "integrity": "sha512-lomjuFZKfM6MSAnV9aCZC9sc0qGbmZdfygNv+nCpqVkSKdCxCklLtd16O0EILGkImHw9ZpHkAnHaB+8Zxq5W6Q==", "inBundle": true, "dependencies": { - "strip-ansi": "^3.0.0", + "strip-ansi": "^6.0.1", "wcwidth": "^1.0.0" + }, + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/columnify/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "inBundle": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/columnify/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "inBundle": true, + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" } }, "node_modules/combined-stream": { @@ -3451,29 +3385,6 @@ "node": ">=8" } }, - "node_modules/gauge/node_modules/is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "inBundle": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/gauge/node_modules/string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "inBundle": true, - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/gauge/node_modules/strip-ansi": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", @@ -4255,12 +4166,12 @@ } }, "node_modules/is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", "inBundle": true, "engines": { - "node": ">=4" + "node": ">=8" } }, "node_modules/is-glob": { @@ -7291,37 +7202,38 @@ } }, "node_modules/string-width": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", "inBundle": true, "dependencies": { - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^4.0.0" + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" }, "engines": { - "node": ">=4" + "node": ">=8" } }, "node_modules/string-width/node_modules/ansi-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", "inBundle": true, "engines": { - "node": ">=4" + "node": ">=8" } }, "node_modules/string-width/node_modules/strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", "inBundle": true, "dependencies": { - "ansi-regex": "^3.0.0" + "ansi-regex": "^5.0.1" }, "engines": { - "node": ">=4" + "node": ">=8" } }, "node_modules/string.prototype.trimend": { @@ -7359,7 +7271,7 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "inBundle": true, + "dev": true, "dependencies": { "ansi-regex": "^2.0.0" }, @@ -10178,29 +10090,6 @@ "node": ">=8" } }, - "node_modules/wrap-ansi/node_modules/is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/wrap-ansi/node_modules/string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/wrap-ansi/node_modules/strip-ansi": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", @@ -10374,15 +10263,6 @@ "node": ">=8" } }, - "node_modules/yargs/node_modules/is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/yargs/node_modules/locate-path": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", @@ -10440,20 +10320,6 @@ "node": ">=8" } }, - "node_modules/yargs/node_modules/string-width": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz", - "integrity": "sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA==", - "dev": true, - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/yargs/node_modules/strip-ansi": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", @@ -11767,7 +11633,8 @@ "ansi-regex": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true }, "ansi-styles": { "version": "4.3.0", @@ -12259,21 +12126,6 @@ "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==" }, - "is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==" - }, - "string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "requires": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - } - }, "strip-ansi": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", @@ -12291,36 +12143,6 @@ "requires": { "colors": "1.4.0", "string-width": "^4.2.0" - }, - "dependencies": { - "ansi-regex": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", - "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==" - }, - "is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==" - }, - "string-width": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz", - "integrity": "sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA==", - "requires": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.0" - } - }, - "strip-ansi": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", - "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", - "requires": { - "ansi-regex": "^5.0.0" - } - } } }, "cliui": { @@ -12340,23 +12162,6 @@ "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", "dev": true }, - "is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true - }, - "string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "requires": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - } - }, "strip-ansi": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", @@ -12429,12 +12234,27 @@ "optional": true }, "columnify": { - "version": "1.5.4", - "resolved": "https://registry.npmjs.org/columnify/-/columnify-1.5.4.tgz", - "integrity": "sha1-Rzfd8ce2mop8NAVweC6UfuyOeLs=", + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/columnify/-/columnify-1.6.0.tgz", + "integrity": "sha512-lomjuFZKfM6MSAnV9aCZC9sc0qGbmZdfygNv+nCpqVkSKdCxCklLtd16O0EILGkImHw9ZpHkAnHaB+8Zxq5W6Q==", "requires": { - "strip-ansi": "^3.0.0", + "strip-ansi": "^6.0.1", "wcwidth": "^1.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==" + }, + "strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "requires": { + "ansi-regex": "^5.0.1" + } + } } }, "combined-stream": { @@ -13473,21 +13293,6 @@ "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==" }, - "is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==" - }, - "string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "requires": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - } - }, "strip-ansi": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", @@ -14018,9 +13823,9 @@ "dev": true }, "is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=" + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==" }, "is-glob": { "version": "4.0.3", @@ -16529,25 +16334,26 @@ } }, "string-width": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", "requires": { - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^4.0.0" + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" }, "dependencies": { "ansi-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=" + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==" }, "strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", "requires": { - "ansi-regex": "^3.0.0" + "ansi-regex": "^5.0.1" } } } @@ -16581,6 +16387,7 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, "requires": { "ansi-regex": "^2.0.0" } @@ -18510,23 +18317,6 @@ "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", "dev": true }, - "is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true - }, - "string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "requires": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - } - }, "strip-ansi": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", @@ -18648,12 +18438,6 @@ "path-exists": "^4.0.0" } }, - "is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true - }, "locate-path": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", @@ -18693,17 +18477,6 @@ "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", "dev": true }, - "string-width": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz", - "integrity": "sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA==", - "dev": true, - "requires": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.0" - } - }, "strip-ansi": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", diff --git a/package.json b/package.json index c407a66ae12d1..519fb22f13e4e 100644 --- a/package.json +++ b/package.json @@ -70,7 +70,7 @@ "chownr": "^2.0.0", "cli-columns": "^4.0.0", "cli-table3": "^0.6.1", - "columnify": "~1.5.4", + "columnify": "^1.6.0", "fastest-levenshtein": "^1.0.12", "glob": "^7.2.0", "graceful-fs": "^4.2.9", From f4c5f0e52679b1aa42db833fc23dc07d96cc904e Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Wed, 23 Feb 2022 19:10:42 +0200 Subject: [PATCH 06/43] fix(arborist): fix unescaped periods (#4462) --- workspaces/arborist/lib/arborist/reify.js | 2 +- workspaces/arborist/lib/shrinkwrap.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/workspaces/arborist/lib/arborist/reify.js b/workspaces/arborist/lib/arborist/reify.js index 91507fd791871..92e2b69606c81 100644 --- a/workspaces/arborist/lib/arborist/reify.js +++ b/workspaces/arborist/lib/arborist/reify.js @@ -716,7 +716,7 @@ module.exports = cls => class Reifier extends cls { // Shrinkwrap and Node classes carefully, so for now, just treat // the default reg as the magical animal that it has been. return resolved && resolved - .replace(/^https?:\/\/registry.npmjs.org\//, this.registry) + .replace(/^https?:\/\/registry\.npmjs\.org\//, this.registry) } // bundles are *sort of* like shrinkwraps, in that the branch is defined diff --git a/workspaces/arborist/lib/shrinkwrap.js b/workspaces/arborist/lib/shrinkwrap.js index bb6971f7ad57a..f4af71f478d5a 100644 --- a/workspaces/arborist/lib/shrinkwrap.js +++ b/workspaces/arborist/lib/shrinkwrap.js @@ -80,8 +80,8 @@ const swKeyOrder = [ ] // used to rewrite from yarn registry to npm registry -const yarnRegRe = /^https?:\/\/registry.yarnpkg.com\// -const npmRegRe = /^https?:\/\/registry.npmjs.org\// +const yarnRegRe = /^https?:\/\/registry\.yarnpkg\.com\// +const npmRegRe = /^https?:\/\/registry\.npmjs\.org\// // sometimes resolved: is weird or broken, or something npa can't handle const specFromResolved = resolved => { From d9b63784dbef50c5b3a7bd62ba5df1aaa45133fc Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Wed, 23 Feb 2022 19:11:33 +0200 Subject: [PATCH 07/43] fix(libnpmpublish): remove superfluous argument (#4463) --- workspaces/libnpmpublish/lib/publish.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workspaces/libnpmpublish/lib/publish.js b/workspaces/libnpmpublish/lib/publish.js index f6d88f7325bd0..75b764c98963f 100644 --- a/workspaces/libnpmpublish/lib/publish.js +++ b/workspaces/libnpmpublish/lib/publish.js @@ -58,7 +58,7 @@ Remove the 'private' field from the package.json to publish it.`), ...opts, query: { write: true }, }) - const newMetadata = patchMetadata(current, metadata, opts) + const newMetadata = patchMetadata(current, metadata) return npmFetch(spec.escapedName, { ...opts, method: 'PUT', From 63b35578bd759cb5f3edaaef1c1122ecd0b27f48 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Wed, 23 Feb 2022 20:34:18 +0200 Subject: [PATCH 08/43] fix(arborist): fix superfluous arguments (#4464) --- workspaces/arborist/test/audit-report.js | 2 +- workspaces/arborist/test/diff.js | 2 +- workspaces/arborist/test/inventory.js | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/workspaces/arborist/test/audit-report.js b/workspaces/arborist/test/audit-report.js index 16ea7e13b7386..c9c610c84ed49 100644 --- a/workspaces/arborist/test/audit-report.js +++ b/workspaces/arborist/test/audit-report.js @@ -30,7 +30,7 @@ const sortReport = report => { { ...vuln, via: (vuln.via || []).sort((a, b) => - String(a.source || a).localeCompare(String(b.source || b, 'en'))), + String(a.source || a).localeCompare(String(b.source || b), 'en')), effects: (vuln.effects || []).sort((a, b) => a.localeCompare(b, 'en')), }, ]) diff --git a/workspaces/arborist/test/diff.js b/workspaces/arborist/test/diff.js index 0e943d5786ef0..78e59c293179d 100644 --- a/workspaces/arborist/test/diff.js +++ b/workspaces/arborist/test/diff.js @@ -31,7 +31,7 @@ const formatDiff = obj => removed: obj.removed.map(d => normalizePath(d.path).split(normalizedCWD).join('{CWD}')), children: [...obj.children] .map(formatDiff) - .sort((a, b) => path(a).localeCompare(path(b, 'en'))), + .sort((a, b) => path(a).localeCompare(path(b), 'en')), }) t.formatSnapshot = obj => format(formatDiff(obj), { sort: false }) diff --git a/workspaces/arborist/test/inventory.js b/workspaces/arborist/test/inventory.js index cb0a286c9edaf..31995e0caa516 100644 --- a/workspaces/arborist/test/inventory.js +++ b/workspaces/arborist/test/inventory.js @@ -21,7 +21,7 @@ t.test('basic operations', t => { i.get('y'), ], 'filter returns an iterable of all matching nodes') - t.same([...i.query('license')].sort((a, b) => String(a).localeCompare(String(b, 'en'))), + t.same([...i.query('license')].sort((a, b) => String(a).localeCompare(String(b), 'en')), ['ISC', 'MIT', undefined]) t.same([...i.query('license', 'MIT')], [ { location: 'x', name: 'x', package: { licence: 'MIT', funding: 'foo' } }, @@ -33,7 +33,7 @@ t.test('basic operations', t => { { location: 'x', name: 'x', package: { licence: 'MIT', funding: 'foo' } }, { location: 'y', name: 'x', package: { licenses: [{ type: 'ISC' }], funding: { url: 'foo' } } }, ], 'can query by name') - t.same([...i.query('funding')].sort((a, b) => String(a).localeCompare(String(b, 'en'))), + t.same([...i.query('funding')].sort((a, b) => String(a).localeCompare(String(b), 'en')), ['bar', 'foo', undefined]) t.same([...i.query('funding', 'foo')], [ { location: 'x', name: 'x', package: { licence: 'MIT', funding: 'foo' } }, From 1b4385f85e8f6dd5015080cdd3e02a8fa3749ffd Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Wed, 23 Feb 2022 12:32:54 -0700 Subject: [PATCH 09/43] fix(arborist): convert all sorting to string-locale-compare (#4465) --- workspaces/arborist/bin/license.js | 3 ++- workspaces/arborist/test/arborist/rebuild.js | 5 +++-- workspaces/arborist/test/arborist/reify.js | 3 ++- workspaces/arborist/test/audit-report.js | 7 ++++--- workspaces/arborist/test/diff.js | 3 ++- workspaces/arborist/test/fixtures/index.js | 3 ++- workspaces/arborist/test/gather-dep-set.js | 3 ++- workspaces/arborist/test/inventory.js | 6 ++++-- 8 files changed, 21 insertions(+), 12 deletions(-) diff --git a/workspaces/arborist/bin/license.js b/workspaces/arborist/bin/license.js index 7fc08dd83eb5b..af34fece67a46 100644 --- a/workspaces/arborist/bin/license.js +++ b/workspaces/arborist/bin/license.js @@ -1,4 +1,5 @@ const Arborist = require('../') +const localeCompare = require('@isaacs/string-locale-compare')('en') const options = require('./lib/options.js') require('./lib/logging.js') require('./lib/timers.js') @@ -24,7 +25,7 @@ a.loadVirtual().then(tree => { } for (const [count, license] of set.sort((a, b) => - a[1] && b[1] ? b[0] - a[0] || a[1].localeCompare(b[1], 'en') + a[1] && b[1] ? b[0] - a[0] || localeCompare(a[1], b[1]) : a[1] ? -1 : b[1] ? 1 : 0)) { diff --git a/workspaces/arborist/test/arborist/rebuild.js b/workspaces/arborist/test/arborist/rebuild.js index 4f7a09c368ce1..e75895628c289 100644 --- a/workspaces/arborist/test/arborist/rebuild.js +++ b/workspaces/arborist/test/arborist/rebuild.js @@ -5,6 +5,7 @@ const { resolve, dirname } = require('path') const fs = require('fs') const fixtures = resolve(__dirname, '../fixtures') const relpath = require('../../lib/relpath.js') +const localeCompare = require('@isaacs/string-locale-compare')('en') const fixture = (t, p) => require(`${fixtures}/reify-cases/${p}`)(t) @@ -181,7 +182,7 @@ t.test('verify dep flags in script environments', async t => { // don't include path or env, because that's going to be platform-specific const saved = [...arb.scriptsRun] .sort(({ path: patha, event: eventa }, { path: pathb, event: eventb }) => - patha.localeCompare(pathb, 'en') || eventa.localeCompare(eventb, 'en')) + localeCompare(patha, pathb) || localeCompare(eventa, eventb)) .map(({ pkg, event, cmd, code, signal, stdout, stderr }) => ({ pkg, event, cmd, code, signal, stdout, stderr })) t.matchSnapshot(saved, 'saved script results') @@ -191,7 +192,7 @@ t.test('verify dep flags in script environments', async t => { t.strictSame(flags, fs.readFileSync(file, 'utf8').split('\n'), pkg) } t.strictSame(checkLogs().sort((a, b) => - a[2].localeCompare(b[2], 'en') || (typeof a[4] === 'string' ? -1 : 1)), [ + localeCompare(a[2], b[2]) || (typeof a[4] === 'string' ? -1 : 1)), [ ['info', 'run', 'devdep@1.0.0', 'postinstall', 'node_modules/devdep', 'node ../../env.js'], ['info', 'run', 'devdep@1.0.0', 'postinstall', { code: 0, signal: null }], ['info', 'run', 'devopt@1.0.0', 'postinstall', 'node_modules/devopt', 'node ../../env.js'], diff --git a/workspaces/arborist/test/arborist/reify.js b/workspaces/arborist/test/arborist/reify.js index 7fb1f1f2bfdf8..db4b64c9bcee8 100644 --- a/workspaces/arborist/test/arborist/reify.js +++ b/workspaces/arborist/test/arborist/reify.js @@ -1,6 +1,7 @@ const { resolve, basename } = require('path') const t = require('tap') const runScript = require('@npmcli/run-script') +const localeCompare = require('@isaacs/string-locale-compare')('en') // mock rimraf so we can make it fail in rollback tests const realRimraf = require('rimraf') @@ -241,7 +242,7 @@ t.test('omit peer deps', t => { .then(() => { process.removeListener('time', onTime) process.removeListener('timeEnd', onTimeEnd) - finishedTimers.sort((a, b) => a.localeCompare(b, 'en')) + finishedTimers.sort(localeCompare) t.matchSnapshot(finishedTimers, 'finished timers') t.strictSame(timers, {}, 'should have no timers in progress now') }) diff --git a/workspaces/arborist/test/audit-report.js b/workspaces/arborist/test/audit-report.js index c9c610c84ed49..13e2e4d70c897 100644 --- a/workspaces/arborist/test/audit-report.js +++ b/workspaces/arborist/test/audit-report.js @@ -1,4 +1,5 @@ const t = require('tap') +const localeCompare = require('@isaacs/string-locale-compare')('en') const AuditReport = require('../lib/audit-report.js') const { auditToBulk } = AuditReport const Node = require('../lib/node.js') @@ -24,14 +25,14 @@ const newArb = (path, opts = {}) => const sortReport = report => { const entries = Object.entries(report.vulnerabilities) - const vulns = entries.sort(([a], [b]) => a.localeCompare(b, 'en')) + const vulns = entries.sort(([a], [b]) => localeCompare(a, b)) .map(([name, vuln]) => [ name, { ...vuln, via: (vuln.via || []).sort((a, b) => - String(a.source || a).localeCompare(String(b.source || b), 'en')), - effects: (vuln.effects || []).sort((a, b) => a.localeCompare(b, 'en')), + localeCompare(String(a.source || a), String(b.source || b))), + effects: (vuln.effects || []).sort(localeCompare), }, ]) report.vulnerabilities = vulns.reduce((set, [k, v]) => { diff --git a/workspaces/arborist/test/diff.js b/workspaces/arborist/test/diff.js index 78e59c293179d..219a0bb383a29 100644 --- a/workspaces/arborist/test/diff.js +++ b/workspaces/arborist/test/diff.js @@ -1,3 +1,4 @@ +const localeCompare = require('@isaacs/string-locale-compare')('en') const Diff = require('../lib/diff.js') const t = require('tap') const Node = require('../lib/node.js') @@ -31,7 +32,7 @@ const formatDiff = obj => removed: obj.removed.map(d => normalizePath(d.path).split(normalizedCWD).join('{CWD}')), children: [...obj.children] .map(formatDiff) - .sort((a, b) => path(a).localeCompare(path(b), 'en')), + .sort((a, b) => localeCompare(path(a), path(b))), }) t.formatSnapshot = obj => format(formatDiff(obj), { sort: false }) diff --git a/workspaces/arborist/test/fixtures/index.js b/workspaces/arborist/test/fixtures/index.js index f03480785c64a..31b6b0a9e1160 100644 --- a/workspaces/arborist/test/fixtures/index.js +++ b/workspaces/arborist/test/fixtures/index.js @@ -1,4 +1,5 @@ const mkdirp = require('mkdirp').sync +const localeCompare = require('@isaacs/string-locale-compare')('en') const { unlinkSync, symlinkSync, readFileSync, writeFileSync } = require('fs') const { relative, resolve, dirname } = require('path') @@ -167,7 +168,7 @@ const setup = () => { `### BEGIN IGNORED SYMLINKS ### ### this list is generated automatically, do not edit directly ### update it by running \`node test/fixtures/index.js\` -${links.sort((a,b) => a.localeCompare(b, 'en')).join('\n')} +${links.sort(localeCompare).join('\n')} ### END IGNORED SYMLINKS ###`) writeFileSync(gifile, gitignore) } diff --git a/workspaces/arborist/test/gather-dep-set.js b/workspaces/arborist/test/gather-dep-set.js index 877e419007ac8..9fdb87628f9ea 100644 --- a/workspaces/arborist/test/gather-dep-set.js +++ b/workspaces/arborist/test/gather-dep-set.js @@ -1,4 +1,5 @@ const t = require('tap') +const localeCompare = require('@isaacs/string-locale-compare')('en') const gatherDepSet = require('../lib/gather-dep-set.js') const Node = require('../lib/node.js') @@ -81,7 +82,7 @@ const tree = new Node({ const normalizePath = path => path.replace(/[A-Z]:/, '').replace(/\\/g, '/') const printSet = set => [...set] - .sort((a, b) => a.name.localeCompare(b.name, 'en')) + .sort((a, b) => localeCompare(a.name, b.name)) .map(n => n.location) const cwd = normalizePath(process.cwd()) diff --git a/workspaces/arborist/test/inventory.js b/workspaces/arborist/test/inventory.js index 31995e0caa516..1b087fe70eb35 100644 --- a/workspaces/arborist/test/inventory.js +++ b/workspaces/arborist/test/inventory.js @@ -2,6 +2,8 @@ // does not enable it. process.env.ARBORIST_DEBUG = '1' const Inventory = require('../lib/inventory.js') +const localeCompare = require('@isaacs/string-locale-compare')('en') + const t = require('tap') t.test('basic operations', t => { @@ -21,7 +23,7 @@ t.test('basic operations', t => { i.get('y'), ], 'filter returns an iterable of all matching nodes') - t.same([...i.query('license')].sort((a, b) => String(a).localeCompare(String(b), 'en')), + t.same([...i.query('license')].sort((a, b) => localeCompare(String(a), String(b))), ['ISC', 'MIT', undefined]) t.same([...i.query('license', 'MIT')], [ { location: 'x', name: 'x', package: { licence: 'MIT', funding: 'foo' } }, @@ -33,7 +35,7 @@ t.test('basic operations', t => { { location: 'x', name: 'x', package: { licence: 'MIT', funding: 'foo' } }, { location: 'y', name: 'x', package: { licenses: [{ type: 'ISC' }], funding: { url: 'foo' } } }, ], 'can query by name') - t.same([...i.query('funding')].sort((a, b) => String(a).localeCompare(String(b), 'en')), + t.same([...i.query('funding')].sort((a, b) => localeCompare(String(a), String(b))), ['bar', 'foo', undefined]) t.same([...i.query('funding', 'foo')], [ { location: 'x', name: 'x', package: { licence: 'MIT', funding: 'foo' } }, From e5b4fa6251f0c6b16d84d46d62f5b98ad755385f Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Wed, 23 Feb 2022 21:45:55 +0000 Subject: [PATCH 10/43] deps(arborist): update to latest major versions of npm deps BREAKING CHANGE: the log option is no longer passed to the updated deps --- workspaces/arborist/package.json | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/workspaces/arborist/package.json b/workspaces/arborist/package.json index a915c9d8b1f6f..3864d55d94568 100644 --- a/workspaces/arborist/package.json +++ b/workspaces/arborist/package.json @@ -6,7 +6,7 @@ "@isaacs/string-locale-compare": "^1.1.0", "@npmcli/installed-package-contents": "^1.0.7", "@npmcli/map-workspaces": "^2.0.0", - "@npmcli/metavuln-calculator": "^2.0.0", + "@npmcli/metavuln-calculator": "^3.0.0", "@npmcli/move-file": "^1.1.0", "@npmcli/name-from-folder": "^1.0.1", "@npmcli/node-gyp": "^1.0.3", @@ -20,12 +20,13 @@ "mkdirp": "^1.0.4", "mkdirp-infer-owner": "^2.0.0", "npm-install-checks": "^4.0.0", - "npm-package-arg": "^8.1.5", - "npm-pick-manifest": "^6.1.0", - "npm-registry-fetch": "^12.0.1", - "pacote": "^12.0.2", + "npm-package-arg": "^9.0.0", + "npm-pick-manifest": "^7.0.0", + "npm-registry-fetch": "^13.0.0", + "npmlog": "^6.0.1", + "pacote": "^13.0.2", "parse-conflict-json": "^2.0.1", - "proc-log": "^1.0.0", + "proc-log": "^2.0.0", "promise-all-reject-late": "^1.0.0", "promise-call-limit": "^1.0.1", "read-package-json-fast": "^2.0.2", From 381d0e14df19371ce0ddee3eef66ac96169e7d46 Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Mon, 21 Feb 2022 13:34:34 -0700 Subject: [PATCH 11/43] deps(libnpmaccess): update to latest major versions of npm deps BREAKING CHANGE: the log option is no longer passed to the updated deps --- workspaces/libnpmaccess/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/workspaces/libnpmaccess/package.json b/workspaces/libnpmaccess/package.json index 760da6cc1be87..f32c1a3c8373e 100644 --- a/workspaces/libnpmaccess/package.json +++ b/workspaces/libnpmaccess/package.json @@ -31,8 +31,8 @@ "dependencies": { "aproba": "^2.0.0", "minipass": "^3.1.1", - "npm-package-arg": "^8.1.2", - "npm-registry-fetch": "^12.0.1" + "npm-package-arg": "^9.0.0", + "npm-registry-fetch": "^13.0.0" }, "engines": { "node": "^12.13.0 || ^14.15.0 || >=16" From b6401fd1b793be08c4af280111fe9fb53b7b3dd2 Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Mon, 21 Feb 2022 13:35:53 -0700 Subject: [PATCH 12/43] deps(libnpmdiff): update to latest major versions of npm deps BREAKING CHANGE: the log option is no longer passed to the updated deps --- workspaces/libnpmdiff/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/workspaces/libnpmdiff/package.json b/workspaces/libnpmdiff/package.json index 24846f39cf4fb..2d18763396f1e 100644 --- a/workspaces/libnpmdiff/package.json +++ b/workspaces/libnpmdiff/package.json @@ -53,8 +53,8 @@ "binary-extensions": "^2.2.0", "diff": "^5.0.0", "minimatch": "^3.0.4", - "npm-package-arg": "^8.1.4", - "pacote": "^12.0.0", + "npm-package-arg": "^9.0.0", + "pacote": "^13.0.2", "tar": "^6.1.0" }, "templateOSS": { From fde2f85cea28b0a6b56f90eeaa3144b4d05c7f75 Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Mon, 21 Feb 2022 13:36:48 -0700 Subject: [PATCH 13/43] deps(libnpmexec): update to latest major versions of npm deps BREAKING CHANGE: the log option is no longer passed to the updated deps --- workspaces/libnpmexec/package.json | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/workspaces/libnpmexec/package.json b/workspaces/libnpmexec/package.json index 4410f187ec66a..c88bfb16384df 100644 --- a/workspaces/libnpmexec/package.json +++ b/workspaces/libnpmexec/package.json @@ -55,9 +55,10 @@ "@npmcli/run-script": "^2.0.0", "chalk": "^4.1.0", "mkdirp-infer-owner": "^2.0.0", - "npm-package-arg": "^8.1.2", - "pacote": "^12.0.0", - "proc-log": "^1.0.0", + "npm-package-arg": "^9.0.0", + "npmlog": "^6.0.1", + "pacote": "^13.0.2", + "proc-log": "^2.0.0", "read": "^1.0.7", "read-package-json-fast": "^2.0.2", "walk-up-path": "^1.0.0" From 78f4a013c6e577714bda6851fb69a39c873571af Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Mon, 21 Feb 2022 13:40:58 -0700 Subject: [PATCH 14/43] deps(libnpmhook): update to latest major versions of npm deps BREAKING CHANGE: the log option is no longer passed to the updated deps --- workspaces/libnpmhook/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workspaces/libnpmhook/package.json b/workspaces/libnpmhook/package.json index 4f30555273205..86e3c9b684447 100644 --- a/workspaces/libnpmhook/package.json +++ b/workspaces/libnpmhook/package.json @@ -34,7 +34,7 @@ "license": "ISC", "dependencies": { "aproba": "^2.0.0", - "npm-registry-fetch": "^12.0.1" + "npm-registry-fetch": "^13.0.0" }, "devDependencies": { "@npmcli/template-oss": "^2.4.2", From 73a42ba177cf6de98c60ab3efe777ee402700db2 Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Mon, 21 Feb 2022 13:41:43 -0700 Subject: [PATCH 15/43] deps(libnpmorg): update to latest major versions of npm deps BREAKING CHANGE: the log option is no longer passed to the updated deps --- workspaces/libnpmorg/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workspaces/libnpmorg/package.json b/workspaces/libnpmorg/package.json index 5c4909b1c9505..781fa9b524695 100644 --- a/workspaces/libnpmorg/package.json +++ b/workspaces/libnpmorg/package.json @@ -45,7 +45,7 @@ "homepage": "https://npmjs.com/package/libnpmorg", "dependencies": { "aproba": "^2.0.0", - "npm-registry-fetch": "^12.0.1" + "npm-registry-fetch": "^13.0.0" }, "engines": { "node": "^12.13.0 || ^14.15.0 || >=16" From 780609b0be8cc7b06e2c36dd0707a6e5a154d976 Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Mon, 21 Feb 2022 13:46:45 -0700 Subject: [PATCH 16/43] deps(libnpmpack): update to latest major versions of npm deps BREAKING CHANGE: the log option is no longer passed to the updated deps --- workspaces/libnpmpack/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/workspaces/libnpmpack/package.json b/workspaces/libnpmpack/package.json index 7317c272f7e22..94507504080d5 100644 --- a/workspaces/libnpmpack/package.json +++ b/workspaces/libnpmpack/package.json @@ -39,8 +39,8 @@ "homepage": "https://npmjs.com/package/libnpmpack", "dependencies": { "@npmcli/run-script": "^2.0.0", - "npm-package-arg": "^8.1.0", - "pacote": "^12.0.0" + "npm-package-arg": "^9.0.0", + "pacote": "^13.0.2" }, "engines": { "node": "^12.13.0 || ^14.15.0 || >=16" From b8f082950667d7f6aee46f13a958c465dd9d68f6 Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Mon, 21 Feb 2022 13:48:24 -0700 Subject: [PATCH 17/43] deps(libnpmpublish): update to latest major versions of npm deps BREAKING CHANGE: the log option is no longer passed to the updated deps --- workspaces/libnpmpublish/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/workspaces/libnpmpublish/package.json b/workspaces/libnpmpublish/package.json index 3fd2d6d5a3961..cb73ee348e2fb 100644 --- a/workspaces/libnpmpublish/package.json +++ b/workspaces/libnpmpublish/package.json @@ -43,8 +43,8 @@ "homepage": "https://npmjs.com/package/libnpmpublish", "dependencies": { "normalize-package-data": "^3.0.2", - "npm-package-arg": "^8.1.2", - "npm-registry-fetch": "^12.0.1", + "npm-package-arg": "^9.0.0", + "npm-registry-fetch": "^13.0.0", "semver": "^7.1.3", "ssri": "^8.0.1" }, From 1c09034d41db3a7dc622a2ec56e303aa63980d7b Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Mon, 21 Feb 2022 13:49:44 -0700 Subject: [PATCH 18/43] deps(libnpmsearch): update to latest major versions of npm deps BREAKING CHANGE: the log option is no longer passed to the updated deps --- workspaces/libnpmsearch/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workspaces/libnpmsearch/package.json b/workspaces/libnpmsearch/package.json index f524426dc65f8..ba660269893e2 100644 --- a/workspaces/libnpmsearch/package.json +++ b/workspaces/libnpmsearch/package.json @@ -41,7 +41,7 @@ "bugs": "https://github.com/npm/libnpmsearch/issues", "homepage": "https://npmjs.com/package/libnpmsearch", "dependencies": { - "npm-registry-fetch": "^12.0.1" + "npm-registry-fetch": "^13.0.0" }, "engines": { "node": "^12.13.0 || ^14.15.0 || >=16" From c5a801d0f46e474133b3ebdf2bf42be29ffce494 Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Mon, 21 Feb 2022 13:50:29 -0700 Subject: [PATCH 19/43] deps(libnpmteam): update to latest major versions of npm deps BREAKING CHANGE: the log option is no longer passed to the updated deps --- workspaces/libnpmteam/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workspaces/libnpmteam/package.json b/workspaces/libnpmteam/package.json index 23903551aa8c1..083fd6f088123 100644 --- a/workspaces/libnpmteam/package.json +++ b/workspaces/libnpmteam/package.json @@ -32,7 +32,7 @@ "homepage": "https://npmjs.com/package/libnpmteam", "dependencies": { "aproba": "^2.0.0", - "npm-registry-fetch": "^12.0.1" + "npm-registry-fetch": "^13.0.0" }, "engines": { "node": "^12.13.0 || ^14.15.0 || >=16" From cfabd66d31c51c159b287ae1b3470beef690fe3d Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Mon, 21 Feb 2022 13:55:53 -0700 Subject: [PATCH 20/43] deps(libnpmversion): update to latest major versions of npm deps BREAKING CHANGE: the log option is no longer passed to the updated deps --- workspaces/libnpmversion/package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/workspaces/libnpmversion/package.json b/workspaces/libnpmversion/package.json index 6d7823f5d0a5b..11ab7d9ebba7c 100644 --- a/workspaces/libnpmversion/package.json +++ b/workspaces/libnpmversion/package.json @@ -34,9 +34,10 @@ "tap": "^15" }, "dependencies": { - "@npmcli/git": "^2.0.7", + "@npmcli/git": "^3.0.0", "@npmcli/run-script": "^2.0.0", "json-parse-even-better-errors": "^2.3.1", + "proc-log": "^2.0.0", "semver": "^7.3.5", "stringify-package": "^1.0.1" }, From 654c4cd991b8d2b5bde9042326fd617ef43f16f2 Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Mon, 21 Feb 2022 13:56:30 -0700 Subject: [PATCH 21/43] chore(cli): install and resetdeps --- .../@npmcli/config/lib/env-replace.js | 2 +- node_modules/@npmcli/config/lib/index.js | 15 +- node_modules/@npmcli/config/lib/proc-log.js | 4 - node_modules/@npmcli/config/package.json | 11 +- node_modules/@npmcli/git/lib/clone.js | 24 +- node_modules/@npmcli/git/lib/errors.js | 2 +- node_modules/@npmcli/git/lib/index.js | 2 +- node_modules/@npmcli/git/lib/lines-to-revs.js | 14 +- node_modules/@npmcli/git/lib/make-error.js | 4 +- node_modules/@npmcli/git/lib/opts.js | 4 +- node_modules/@npmcli/git/lib/proc-log.js | 21 - node_modules/@npmcli/git/lib/revs.js | 2 +- node_modules/@npmcli/git/lib/spawn.js | 9 +- .../git/node_modules/lru-cache/LICENSE | 15 + .../git/node_modules/lru-cache/index.js | 581 ++++++++++++++++++ .../git/node_modules/lru-cache/package.json | 34 + node_modules/@npmcli/git/package.json | 29 +- .../metavuln-calculator/lib/advisory.js | 94 ++- .../@npmcli/metavuln-calculator/lib/hash.js | 4 +- .../@npmcli/metavuln-calculator/lib/index.js | 14 +- .../@npmcli/metavuln-calculator/package.json | 28 +- .../lib/init-package-json.js | 2 +- node_modules/init-package-json/package.json | 21 +- node_modules/npm-package-arg/{ => lib}/npa.js | 98 +-- node_modules/npm-package-arg/package.json | 33 +- .../npm-pick-manifest/{ => lib}/index.js | 14 +- node_modules/npm-pick-manifest/package.json | 35 +- node_modules/npm-profile/lib/index.js | 19 +- node_modules/npm-profile/package.json | 16 +- .../npm-registry-fetch/lib/check-response.js | 13 +- .../npm-registry-fetch/lib/default-opts.js | 1 - node_modules/npm-registry-fetch/package.json | 8 +- node_modules/pacote/lib/bin.js | 30 +- node_modules/pacote/lib/dir.js | 17 +- node_modules/pacote/lib/fetcher.js | 101 +-- node_modules/pacote/lib/file.js | 41 +- node_modules/pacote/lib/git.js | 87 +-- node_modules/pacote/lib/registry.js | 39 +- node_modules/pacote/lib/remote.js | 8 +- node_modules/pacote/lib/util/cache-dir.js | 2 +- .../pacote/lib/util/is-package-bin.js | 7 +- node_modules/pacote/lib/util/npm.js | 1 - node_modules/pacote/lib/util/proc-log.js | 21 - .../pacote/lib/util/tar-create-options.js | 5 +- .../pacote/lib/util/trailing-slashes.js | 10 + node_modules/pacote/package.json | 45 +- node_modules/proc-log/{ => lib}/index.js | 3 +- node_modules/proc-log/package.json | 30 +- package-lock.json | 373 ++++++----- package.json | 16 +- 50 files changed, 1409 insertions(+), 600 deletions(-) delete mode 100644 node_modules/@npmcli/config/lib/proc-log.js delete mode 100644 node_modules/@npmcli/git/lib/proc-log.js create mode 100644 node_modules/@npmcli/git/node_modules/lru-cache/LICENSE create mode 100644 node_modules/@npmcli/git/node_modules/lru-cache/index.js create mode 100644 node_modules/@npmcli/git/node_modules/lru-cache/package.json rename node_modules/npm-package-arg/{ => lib}/npa.js (86%) rename node_modules/npm-pick-manifest/{ => lib}/index.js (96%) delete mode 100644 node_modules/pacote/lib/util/proc-log.js create mode 100644 node_modules/pacote/lib/util/trailing-slashes.js rename node_modules/proc-log/{ => lib}/index.js (91%) diff --git a/node_modules/@npmcli/config/lib/env-replace.js b/node_modules/@npmcli/config/lib/env-replace.js index a6e4b2968d04e..e0f7276b1ec2b 100644 --- a/node_modules/@npmcli/config/lib/env-replace.js +++ b/node_modules/@npmcli/config/lib/env-replace.js @@ -1,6 +1,6 @@ // replace any ${ENV} values with the appropriate environ. -const envExpr = /(\\*)\$\{([^}]+)\}/g +const envExpr = /(? f.replace(envExpr, (orig, esc, name) => { const val = env[name] !== undefined ? env[name] : `$\{${name}}` diff --git a/node_modules/@npmcli/config/lib/index.js b/node_modules/@npmcli/config/lib/index.js index dc839a5389c3a..82e369938db9c 100644 --- a/node_modules/@npmcli/config/lib/index.js +++ b/node_modules/@npmcli/config/lib/index.js @@ -5,6 +5,7 @@ const nopt = require('nopt') const mkdirp = require('mkdirp-infer-owner') const mapWorkspaces = require('@npmcli/map-workspaces') const rpj = require('read-package-json-fast') +const log = require('proc-log') /* istanbul ignore next */ const myUid = process.getuid && process.getuid() @@ -88,7 +89,6 @@ class Config { // options just to override in tests, mostly env = process.env, argv = process.argv, - log = require('./proc-log.js'), platform = process.platform, execPath = process.execPath, cwd = process.cwd(), @@ -114,7 +114,6 @@ class Config { this.defaults = defaults this.npmPath = npmPath - this.log = log this.argv = argv this.env = env this.execPath = execPath @@ -436,7 +435,7 @@ class Config { } invalidHandler (k, val, type, source, where) { - this.log.warn( + log.warn( 'invalid config', k + '=' + JSON.stringify(val), `set in ${source}` @@ -469,7 +468,7 @@ class Config { : mustBe.filter(m => m !== Array) .map(n => typeof n === 'string' ? n : JSON.stringify(n)) .join(', ') - this.log.warn('invalid config', msg, desc) + log.warn('invalid config', msg, desc) } [_loadObject] (obj, where, source, er = null) { @@ -491,7 +490,7 @@ class Config { if (er) { conf.loadError = er if (er.code !== 'ENOENT') { - this.log.verbose('config', `error loading ${where} config`, er) + log.verbose('config', `error loading ${where} config`, er) } } else { conf.raw = obj @@ -510,7 +509,7 @@ class Config { // XXX a future npm version will make this a warning. // An even more future npm version will make this an error. if (this.deprecated[key]) { - this.log.verbose('config', key, this.deprecated[key]) + log.verbose('config', key, this.deprecated[key]) } } @@ -607,14 +606,14 @@ class Config { .catch(() => false) if (hasNpmrc) { - this.log.warn(`ignoring workspace config at ${this.localPrefix}/.npmrc`) + log.warn(`ignoring workspace config at ${this.localPrefix}/.npmrc`) } // set the workspace in the default layer, which allows it to be overridden easily const { data } = this.data.get('default') data.workspace = [this.localPrefix] this.localPrefix = p - this.log.info(`found workspace root at ${this.localPrefix}`) + log.info(`found workspace root at ${this.localPrefix}`) // we found a root, so we return now return } diff --git a/node_modules/@npmcli/config/lib/proc-log.js b/node_modules/@npmcli/config/lib/proc-log.js deleted file mode 100644 index 0492a26180756..0000000000000 --- a/node_modules/@npmcli/config/lib/proc-log.js +++ /dev/null @@ -1,4 +0,0 @@ -const log = (level) => (...args) => process.emit('log', level, ...args) -for (const level of ['silly', 'verbose', 'warn', 'error']) { - exports[level] = log(level) -} diff --git a/node_modules/@npmcli/config/package.json b/node_modules/@npmcli/config/package.json index b0722db413e5b..ea03f957f83c5 100644 --- a/node_modules/@npmcli/config/package.json +++ b/node_modules/@npmcli/config/package.json @@ -1,6 +1,6 @@ { "name": "@npmcli/config", - "version": "3.0.0", + "version": "4.0.0", "files": [ "bin", "lib" @@ -30,22 +30,23 @@ "coverage-map": "map.js" }, "devDependencies": { - "@npmcli/template-oss": "^2.5.1", - "tap": "^15.0.4" + "@npmcli/template-oss": "^2.7.1", + "tap": "^15.1.6" }, "dependencies": { "@npmcli/map-workspaces": "^2.0.0", "ini": "^2.0.0", "mkdirp-infer-owner": "^2.0.0", "nopt": "^5.0.0", + "proc-log": "^2.0.0", "read-package-json-fast": "^2.0.3", - "semver": "^7.3.4", + "semver": "^7.3.5", "walk-up-path": "^1.0.0" }, "engines": { "node": "^12.13.0 || ^14.15.0 || >=16" }, "templateOSS": { - "version": "2.6.0" + "version": "2.7.1" } } diff --git a/node_modules/@npmcli/git/lib/clone.js b/node_modules/@npmcli/git/lib/clone.js index 6754fd7606009..ac5f86b14494c 100644 --- a/node_modules/@npmcli/git/lib/clone.js +++ b/node_modules/@npmcli/git/lib/clone.js @@ -15,7 +15,7 @@ const shallowHosts = new Set([ 'gist.github.com', 'gitlab.com', 'bitbucket.com', - 'bitbucket.org' + 'bitbucket.org', ]) // we have to use url.parse until we add the same shim that hosted-git-info has // to handle scp:// urls @@ -113,10 +113,14 @@ const branch = (repo, revDoc, target, opts) => { revDoc.ref, repo, target, - '--recurse-submodules' + '--recurse-submodules', ] - if (maybeShallow(repo, opts)) { args.push('--depth=1') } - if (isWindows(opts)) { args.push('--config', 'core.longpaths=true') } + if (maybeShallow(repo, opts)) { + args.push('--depth=1') + } + if (isWindows(opts)) { + args.push('--config', 'core.longpaths=true') + } return spawn(args, opts).then(() => revDoc.sha) } @@ -126,10 +130,14 @@ const plain = (repo, revDoc, target, opts) => { 'clone', repo, target, - '--recurse-submodules' + '--recurse-submodules', ] - if (maybeShallow(repo, opts)) { args.push('--depth=1') } - if (isWindows(opts)) { args.push('--config', 'core.longpaths=true') } + if (maybeShallow(repo, opts)) { + args.push('--depth=1') + } + if (isWindows(opts)) { + args.push('--config', 'core.longpaths=true') + } return spawn(args, opts).then(() => revDoc.sha) } @@ -143,7 +151,7 @@ const updateSubmodules = (target, opts) => new Promise(resolve => 'update', '-q', '--init', - '--recursive' + '--recursive', ], { ...opts, cwd: target })) })) diff --git a/node_modules/@npmcli/git/lib/errors.js b/node_modules/@npmcli/git/lib/errors.js index 25b2b9f9fd6a6..7aeac4762866f 100644 --- a/node_modules/@npmcli/git/lib/errors.js +++ b/node_modules/@npmcli/git/lib/errors.js @@ -32,5 +32,5 @@ class GitUnknownError extends GitError { module.exports = { GitConnectionError, GitPathspecError, - GitUnknownError + GitUnknownError, } diff --git a/node_modules/@npmcli/git/lib/index.js b/node_modules/@npmcli/git/lib/index.js index 20d7cfd01cfd1..10a65f782e6da 100644 --- a/node_modules/@npmcli/git/lib/index.js +++ b/node_modules/@npmcli/git/lib/index.js @@ -5,5 +5,5 @@ module.exports = { is: require('./is.js'), find: require('./find.js'), isClean: require('./is-clean.js'), - errors: require('./errors.js') + errors: require('./errors.js'), } diff --git a/node_modules/@npmcli/git/lib/lines-to-revs.js b/node_modules/@npmcli/git/lib/lines-to-revs.js index 9f879ca2475f5..3cf3778fe9178 100644 --- a/node_modules/@npmcli/git/lib/lines-to-revs.js +++ b/node_modules/@npmcli/git/lib/lines-to-revs.js @@ -7,7 +7,7 @@ module.exports = lines => finish(lines.reduce(linesToRevsReducer, { versions: {}, 'dist-tags': {}, refs: {}, - shas: {} + shas: {}, })) const finish = revs => distTags(shaList(peelTags(revs))) @@ -52,7 +52,9 @@ const distTags = revs => { revs['dist-tags'].latest = v } else if (ver.sha === HEAD.sha) { revs['dist-tags'].HEAD = v - if (!revs.refs.latest) { revs['dist-tags'].latest = v } + if (!revs.refs.latest) { + revs['dist-tags'].latest = v + } } }) return revs @@ -79,7 +81,9 @@ const refType = ref => { // return the doc, or null if we should ignore it. const lineToRevDoc = line => { const split = line.trim().split(/\s+/, 2) - if (split.length < 2) { return null } + if (split.length < 2) { + return null + } const sha = split[0].trim() const rawRef = split[1].trim() @@ -122,7 +126,9 @@ const lineToRevDoc = line => { const linesToRevsReducer = (revs, line) => { const doc = lineToRevDoc(line) - if (!doc) { return revs } + if (!doc) { + return revs + } revs.refs[doc.ref] = doc revs.refs[doc.rawRef] = doc diff --git a/node_modules/@npmcli/git/lib/make-error.js b/node_modules/@npmcli/git/lib/make-error.js index 043a8e6e95181..7540ec7c8b9f7 100644 --- a/node_modules/@npmcli/git/lib/make-error.js +++ b/node_modules/@npmcli/git/lib/make-error.js @@ -1,7 +1,7 @@ const { GitConnectionError, GitPathspecError, - GitUnknownError + GitUnknownError, } = require('./errors.js') const connectionErrorRe = new RegExp([ @@ -12,7 +12,7 @@ const connectionErrorRe = new RegExp([ 'Failed to connect to .* Timed out', 'Connection reset by peer', 'SSL_ERROR_SYSCALL', - 'The requested URL returned error: 503' + 'The requested URL returned error: 503', ].join('|')) const missingPathspecRe = /pathspec .* did not match any file\(s\) known to git/ diff --git a/node_modules/@npmcli/git/lib/opts.js b/node_modules/@npmcli/git/lib/opts.js index 144e0a3aaf03f..3119af16e0cf1 100644 --- a/node_modules/@npmcli/git/lib/opts.js +++ b/node_modules/@npmcli/git/lib/opts.js @@ -2,11 +2,11 @@ // This defaults to accepting new ssh host key fingerprints const gitEnv = { GIT_ASKPASS: 'echo', - GIT_SSH_COMMAND: 'ssh -oStrictHostKeyChecking=accept-new' + GIT_SSH_COMMAND: 'ssh -oStrictHostKeyChecking=accept-new', } module.exports = (opts = {}) => ({ stdioString: true, ...opts, shell: false, - env: opts.env || { ...gitEnv, ...process.env } + env: opts.env || { ...gitEnv, ...process.env }, }) diff --git a/node_modules/@npmcli/git/lib/proc-log.js b/node_modules/@npmcli/git/lib/proc-log.js deleted file mode 100644 index b2bdd9dc90205..0000000000000 --- a/node_modules/@npmcli/git/lib/proc-log.js +++ /dev/null @@ -1,21 +0,0 @@ -// default logger. -// emits 'log' events on the process -const LEVELS = [ - 'notice', - 'error', - 'warn', - 'info', - 'verbose', - 'http', - 'silly', - 'pause', - 'resume' -] - -const log = level => (...args) => process.emit('log', level, ...args) - -const logger = {} -for (const level of LEVELS) { - logger[level] = log(level) -} -module.exports = logger diff --git a/node_modules/@npmcli/git/lib/revs.js b/node_modules/@npmcli/git/lib/revs.js index 81059594f7aee..ee72370d5b7ec 100644 --- a/node_modules/@npmcli/git/lib/revs.js +++ b/node_modules/@npmcli/git/lib/revs.js @@ -4,7 +4,7 @@ const LRU = require('lru-cache') const revsCache = new LRU({ max: 100, - maxAge: 5 * 60 * 1000 + ttl: 5 * 60 * 1000, }) const linesToRevs = require('./lines-to-revs.js') diff --git a/node_modules/@npmcli/git/lib/spawn.js b/node_modules/@npmcli/git/lib/spawn.js index 1c89a4c53cf86..40972a509caa5 100644 --- a/node_modules/@npmcli/git/lib/spawn.js +++ b/node_modules/@npmcli/git/lib/spawn.js @@ -1,28 +1,29 @@ const spawn = require('@npmcli/promise-spawn') const promiseRetry = require('promise-retry') +const log = require('proc-log') const makeError = require('./make-error.js') const whichGit = require('./which.js') const makeOpts = require('./opts.js') -const procLog = require('./proc-log.js') module.exports = (gitArgs, opts = {}) => { const gitPath = whichGit(opts) - if (gitPath instanceof Error) { return Promise.reject(gitPath) } + if (gitPath instanceof Error) { + return Promise.reject(gitPath) + } // undocumented option, mostly only here for tests const args = opts.allowReplace || gitArgs[0] === '--no-replace-objects' ? gitArgs : ['--no-replace-objects', ...gitArgs] - const log = opts.log || procLog let retry = opts.retry if (retry === null || retry === undefined) { retry = { retries: opts.fetchRetries || 2, factor: opts.fetchRetryFactor || 10, maxTimeout: opts.fetchRetryMaxtimeout || 60000, - minTimeout: opts.fetchRetryMintimeout || 1000 + minTimeout: opts.fetchRetryMintimeout || 1000, } } return promiseRetry((retry, number) => { diff --git a/node_modules/@npmcli/git/node_modules/lru-cache/LICENSE b/node_modules/@npmcli/git/node_modules/lru-cache/LICENSE new file mode 100644 index 0000000000000..9b58a3e03d1df --- /dev/null +++ b/node_modules/@npmcli/git/node_modules/lru-cache/LICENSE @@ -0,0 +1,15 @@ +The ISC License + +Copyright (c) 2010-2022 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. diff --git a/node_modules/@npmcli/git/node_modules/lru-cache/index.js b/node_modules/@npmcli/git/node_modules/lru-cache/index.js new file mode 100644 index 0000000000000..ede2f30cc4b23 --- /dev/null +++ b/node_modules/@npmcli/git/node_modules/lru-cache/index.js @@ -0,0 +1,581 @@ +const perf = typeof performance === 'object' && performance && + typeof performance.now === 'function' ? performance : Date + +const warned = new Set() +const deprecatedOption = (opt, msg) => { + const code = `LRU_CACHE_OPTION_${opt}` + if (shouldWarn(code)) { + warn(code, `The ${opt} option is deprecated. ${msg}`, LRUCache) + } +} +const deprecatedMethod = (method, msg) => { + const code = `LRU_CACHE_METHOD_${method}` + if (shouldWarn(code)) { + const { prototype } = LRUCache + const { get } = Object.getOwnPropertyDescriptor(prototype, method) + warn(code, `The ${method} method is deprecated. ${msg}`, get) + } +} +const deprecatedProperty = (field, msg) => { + const code = `LRU_CACHE_PROPERTY_${field}` + if (shouldWarn(code)) { + const { prototype } = LRUCache + const { get } = Object.getOwnPropertyDescriptor(prototype, field) + warn(code, `The ${field} property is deprecated. ${msg}`, get) + } +} +const shouldWarn = (code) => !(process.noDeprecation || warned.has(code)) +const warn = (code, msg, fn) => { + warned.add(code) + process.emitWarning(msg, 'DeprecationWarning', code, fn) +} + +const isPosInt = n => n && n === Math.floor(n) && n > 0 && isFinite(n) + +/* istanbul ignore next - This is a little bit ridiculous, tbh. + * The maximum array length is 2^32-1 or thereabouts on most JS impls. + * And well before that point, you're caching the entire world, I mean, + * that's ~32GB of just integers for the next/prev links, plus whatever + * else to hold that many keys and values. Just filling the memory with + * zeroes at init time is brutal when you get that big. + * But why not be complete? + * Maybe in the future, these limits will have expanded. */ +const getUintArray = max => !isPosInt(max) ? null +: max <= Math.pow(2, 8) ? Uint8Array +: max <= Math.pow(2, 16) ? Uint16Array +: max <= Math.pow(2, 32) ? Uint32Array +: max <= Number.MAX_SAFE_INTEGER ? ZeroArray +: null + +class ZeroArray extends Array { + constructor (size) { + super(size) + this.fill(0) + } +} + +class Stack { + constructor (max) { + const UintArray = getUintArray(max) + this.heap = new UintArray(max) + this.length = 0 + } + push (n) { + this.heap[this.length++] = n + } + pop () { + return this.heap[--this.length] + } +} + +class LRUCache { + constructor (options = {}) { + const { + max, + ttl, + ttlResolution = 1, + ttlAutopurge, + updateAgeOnGet, + allowStale, + dispose, + disposeAfter, + noDisposeOnSet, + maxSize, + sizeCalculation, + } = options + + // deprecated options, don't trigger a warning for getting them if + // the thing being passed in is another LRUCache we're copying. + const { + length, + maxAge, + stale, + } = options instanceof LRUCache ? {} : options + + if (!isPosInt(max)) { + throw new TypeError('max option must be an integer') + } + + const UintArray = getUintArray(max) + if (!UintArray) { + throw new Error('invalid max value: ' + max) + } + + this.max = max + this.maxSize = maxSize || 0 + this.sizeCalculation = sizeCalculation || length + if (this.sizeCalculation) { + if (!this.maxSize) { + throw new TypeError('cannot set sizeCalculation without setting maxSize') + } + if (typeof this.sizeCalculation !== 'function') { + throw new TypeError('sizeCalculating set to non-function') + } + } + this.keyMap = new Map() + this.keyList = new Array(max).fill(null) + this.valList = new Array(max).fill(null) + this.next = new UintArray(max) + this.prev = new UintArray(max) + this.head = 0 + this.tail = 0 + this.free = new Stack(max) + this.initialFill = 1 + this.size = 0 + + if (typeof dispose === 'function') { + this.dispose = dispose + } + if (typeof disposeAfter === 'function') { + this.disposeAfter = disposeAfter + this.disposed = [] + } else { + this.disposeAfter = null + this.disposed = null + } + this.noDisposeOnSet = !!noDisposeOnSet + + if (this.maxSize) { + if (!isPosInt(this.maxSize)) { + throw new TypeError('maxSize must be a positive integer if specified') + } + this.initializeSizeTracking() + } + + this.allowStale = !!allowStale || !!stale + this.updateAgeOnGet = !!updateAgeOnGet + this.ttlResolution = isPosInt(ttlResolution) || ttlResolution === 0 + ? ttlResolution : 1 + this.ttlAutopurge = !!ttlAutopurge + this.ttl = ttl || maxAge || 0 + if (this.ttl) { + if (!isPosInt(this.ttl)) { + throw new TypeError('ttl must be a positive integer if specified') + } + this.initializeTTLTracking() + } + + if (stale) { + deprecatedOption('stale', 'please use options.allowStale instead') + } + if (maxAge) { + deprecatedOption('maxAge', 'please use options.ttl instead') + } + if (length) { + deprecatedOption('length', 'please use options.sizeCalculation instead') + } + } + + initializeTTLTracking () { + this.ttls = new ZeroArray(this.max) + this.starts = new ZeroArray(this.max) + this.setItemTTL = (index, ttl) => { + this.starts[index] = ttl !== 0 ? perf.now() : 0 + this.ttls[index] = ttl + if (ttl !== 0 && this.ttlAutopurge) { + const t = setTimeout(() => { + if (this.isStale(index)) { + this.delete(this.keyList[index]) + } + }, ttl + 1) + /* istanbul ignore else - unref() not supported on all platforms */ + if (t.unref) { + t.unref() + } + } + } + this.updateItemAge = (index) => { + this.starts[index] = this.ttls[index] !== 0 ? perf.now() : 0 + } + // debounce calls to perf.now() to 1s so we're not hitting + // that costly call repeatedly. + let cachedNow = 0 + const getNow = () => { + const n = perf.now() + if (this.ttlResolution > 0) { + cachedNow = n + const t = setTimeout(() => cachedNow = 0, this.ttlResolution) + /* istanbul ignore else - not available on all platforms */ + if (t.unref) { + t.unref() + } + } + return n + } + this.isStale = (index) => { + return this.ttls[index] !== 0 && this.starts[index] !== 0 && + ((cachedNow || getNow()) - this.starts[index] > this.ttls[index]) + } + } + updateItemAge (index) {} + setItemTTL (index, ttl) {} + isStale (index) { return false } + + initializeSizeTracking () { + this.calculatedSize = 0 + this.sizes = new ZeroArray(this.max) + this.removeItemSize = index => this.calculatedSize -= this.sizes[index] + this.addItemSize = (index, v, k, size, sizeCalculation) => { + const s = size || (sizeCalculation ? sizeCalculation(v, k) : 0) + this.sizes[index] = isPosInt(s) ? s : 0 + const maxSize = this.maxSize - this.sizes[index] + while (this.calculatedSize > maxSize) { + this.evict() + } + this.calculatedSize += this.sizes[index] + } + this.delete = k => { + if (this.size !== 0) { + const index = this.keyMap.get(k) + if (index !== undefined) { + this.calculatedSize -= this.sizes[index] + } + } + return LRUCache.prototype.delete.call(this, k) + } + } + removeItemSize (index) {} + addItemSize (index, v, k, size, sizeCalculation) {} + + *indexes () { + if (this.size) { + for (let i = this.tail; true; i = this.prev[i]) { + if (!this.isStale(i)) { + yield i + } + if (i === this.head) { + break + } + } + } + } + *rindexes () { + if (this.size) { + for (let i = this.head; true; i = this.next[i]) { + if (!this.isStale(i)) { + yield i + } + if (i === this.tail) { + break + } + } + } + } + + *entries () { + for (const i of this.indexes()) { + yield [this.keyList[i], this.valList[i]] + } + } + + *keys () { + for (const i of this.indexes()) { + yield this.keyList[i] + } + } + + *values () { + for (const i of this.indexes()) { + yield this.valList[i] + } + } + + [Symbol.iterator] () { + return this.entries() + } + + find (fn, getOptions = {}) { + for (const i of this.indexes()) { + if (fn(this.valList[i], this.keyList[i], this)) { + return this.get(this.keyList[i], getOptions) + } + } + } + + forEach (fn, thisp = this) { + for (const i of this.indexes()) { + fn.call(thisp, this.valList[i], this.keyList[i], this) + } + } + + rforEach (fn, thisp = this) { + for (const i of this.rindexes()) { + fn.call(thisp, this.valList[i], this.keyList[i], this) + } + } + + get prune () { + deprecatedMethod('prune', 'Please use cache.purgeStale() instead.') + return this.purgeStale + } + + purgeStale () { + let deleted = false + if (this.size) { + for (let i = this.head; true; i = this.next[i]) { + const b = i === this.tail + if (this.isStale(i)) { + this.delete(this.keyList[i]) + deleted = true + } + if (b) { + break + } + } + } + return deleted + } + + dump () { + const arr = [] + for (const i of this.indexes()) { + const key = this.keyList[i] + const value = this.valList[i] + const entry = { value } + if (this.ttls) { + entry.ttl = this.ttls[i] + } + if (this.sizes) { + entry.size = this.sizes[i] + } + arr.unshift([key, entry]) + } + return arr + } + + load (arr) { + this.clear() + for (const [key, entry] of arr) { + this.set(key, entry.value, entry) + } + } + + dispose (v, k, reason) {} + + set (k, v, { + ttl = this.ttl, + noDisposeOnSet = this.noDisposeOnSet, + size = 0, + sizeCalculation = this.sizeCalculation, + } = {}) { + let index = this.size === 0 ? undefined : this.keyMap.get(k) + if (index === undefined) { + // addition + index = this.newIndex() + this.keyList[index] = k + this.valList[index] = v + this.keyMap.set(k, index) + this.next[this.tail] = index + this.prev[index] = this.tail + this.tail = index + this.size ++ + this.addItemSize(index, v, k, size, sizeCalculation) + } else { + // update + const oldVal = this.valList[index] + if (v !== oldVal) { + if (!noDisposeOnSet) { + this.dispose(oldVal, k, 'set') + if (this.disposeAfter) { + this.disposed.push([oldVal, k, 'set']) + } + } + this.removeItemSize(index) + this.valList[index] = v + this.addItemSize(index, v, k, size, sizeCalculation) + } + this.moveToTail(index) + } + if (ttl !== 0 && this.ttl === 0 && !this.ttls) { + this.initializeTTLTracking() + } + this.setItemTTL(index, ttl) + if (this.disposeAfter) { + while (this.disposed.length) { + this.disposeAfter(...this.disposed.shift()) + } + } + return this + } + + newIndex () { + if (this.size === 0) { + return this.tail + } + if (this.size === this.max) { + return this.evict() + } + if (this.free.length !== 0) { + return this.free.pop() + } + // initial fill, just keep writing down the list + return this.initialFill++ + } + + pop () { + if (this.size) { + const val = this.valList[this.head] + this.evict() + return val + } + } + + evict () { + const head = this.head + const k = this.keyList[head] + const v = this.valList[head] + this.dispose(v, k, 'evict') + if (this.disposeAfter) { + this.disposed.push([v, k, 'evict']) + } + this.removeItemSize(head) + this.head = this.next[head] + this.keyMap.delete(k) + this.size -- + return head + } + + has (k) { + return this.keyMap.has(k) && !this.isStale(this.keyMap.get(k)) + } + + // like get(), but without any LRU updating or TTL expiration + peek (k, { allowStale = this.allowStale } = {}) { + const index = this.keyMap.get(k) + if (index !== undefined && (allowStale || !this.isStale(index))) { + return this.valList[index] + } + } + + get (k, { + allowStale = this.allowStale, + updateAgeOnGet = this.updateAgeOnGet, + } = {}) { + const index = this.keyMap.get(k) + if (index !== undefined) { + if (this.isStale(index)) { + const value = allowStale ? this.valList[index] : undefined + this.delete(k) + return value + } else { + this.moveToTail(index) + if (updateAgeOnGet) { + this.updateItemAge(index) + } + return this.valList[index] + } + } + } + + connect (p, n) { + this.prev[n] = p + this.next[p] = n + } + + moveToTail (index) { + // if tail already, nothing to do + // if head, move head to next[index] + // else + // move next[prev[index]] to next[index] (head has no prev) + // move prev[next[index]] to prev[index] + // prev[index] = tail + // next[tail] = index + // tail = index + if (index !== this.tail) { + if (index === this.head) { + this.head = this.next[index] + } else { + this.connect(this.prev[index], this.next[index]) + } + this.connect(this.tail, index) + this.tail = index + } + } + + get del () { + deprecatedMethod('del', 'Please use cache.delete() instead.') + return this.delete + } + delete (k) { + let deleted = false + if (this.size !== 0) { + const index = this.keyMap.get(k) + if (index !== undefined) { + deleted = true + if (this.size === 1) { + this.clear() + } else { + this.removeItemSize(index) + this.dispose(this.valList[index], k, 'delete') + if (this.disposeAfter) { + this.disposed.push([this.valList[index], k, 'delete']) + } + this.keyMap.delete(k) + this.keyList[index] = null + this.valList[index] = null + if (index === this.tail) { + this.tail = this.prev[index] + } else if (index === this.head) { + this.head = this.next[index] + } else { + this.next[this.prev[index]] = this.next[index] + this.prev[this.next[index]] = this.prev[index] + } + this.size -- + this.free.push(index) + } + } + } + if (this.disposed) { + while (this.disposed.length) { + this.disposeAfter(...this.disposed.shift()) + } + } + return deleted + } + + clear () { + if (this.dispose !== LRUCache.prototype.dispose) { + for (const index of this.rindexes()) { + this.dispose(this.valList[index], this.keyList[index], 'delete') + } + } + if (this.disposeAfter) { + for (const index of this.rindexes()) { + this.disposed.push([this.valList[index], this.keyList[index], 'delete']) + } + } + this.keyMap.clear() + this.valList.fill(null) + this.keyList.fill(null) + if (this.ttls) { + this.ttls.fill(0) + this.starts.fill(0) + } + if (this.sizes) { + this.sizes.fill(0) + } + this.head = 0 + this.tail = 0 + this.initialFill = 1 + this.free.length = 0 + this.calculatedSize = 0 + this.size = 0 + if (this.disposed) { + while (this.disposed.length) { + this.disposeAfter(...this.disposed.shift()) + } + } + } + get reset () { + deprecatedMethod('reset', 'Please use cache.clear() instead.') + return this.clear + } + + get length () { + deprecatedProperty('length', 'Please use cache.size instead.') + return this.size + } +} + +module.exports = LRUCache diff --git a/node_modules/@npmcli/git/node_modules/lru-cache/package.json b/node_modules/@npmcli/git/node_modules/lru-cache/package.json new file mode 100644 index 0000000000000..66dbbd9c11503 --- /dev/null +++ b/node_modules/@npmcli/git/node_modules/lru-cache/package.json @@ -0,0 +1,34 @@ +{ + "name": "lru-cache", + "description": "A cache object that deletes the least-recently-used items.", + "version": "7.3.1", + "author": "Isaac Z. Schlueter ", + "keywords": [ + "mru", + "lru", + "cache" + ], + "scripts": { + "test": "tap", + "snap": "tap", + "preversion": "npm test", + "postversion": "npm publish", + "prepublishOnly": "git push origin --follow-tags" + }, + "main": "index.js", + "repository": "git://github.com/isaacs/node-lru-cache.git", + "devDependencies": { + "benchmark": "^2.1.4", + "tap": "^15.1.6" + }, + "license": "ISC", + "files": [ + "index.js" + ], + "engines": { + "node": ">=12" + }, + "tap": { + "coverage-map": "map.js" + } +} diff --git a/node_modules/@npmcli/git/package.json b/node_modules/@npmcli/git/package.json index 9475da5007a7d..02cd37fa225ad 100644 --- a/node_modules/@npmcli/git/package.json +++ b/node_modules/@npmcli/git/package.json @@ -1,44 +1,57 @@ { "name": "@npmcli/git", - "version": "2.1.0", + "version": "3.0.0", "main": "lib/index.js", "files": [ - "lib/*.js" + "bin", + "lib" ], "description": "a util for spawning git from npm CLI contexts", "repository": { "type": "git", "url": "git+https://github.com/npm/git" }, - "author": "Isaac Z. Schlueter (https://izs.me)", + "author": "GitHub Inc.", "license": "ISC", "scripts": { - "lint": "standard", + "lint": "eslint '**/*.js'", "lint:fix": "standard --fix", "postversion": "npm publish", "prepublishOnly": "git push origin --follow-tags", "preversion": "npm test", "snap": "tap", "test": "tap", - "posttest": "npm run lint" + "posttest": "npm run lint", + "postlint": "npm-template-check", + "template-copy": "npm-template-copy --force", + "lintfix": "npm run lint -- --fix" }, "tap": { "check-coverage": true, "coverage-map": "map.js" }, "devDependencies": { + "@npmcli/template-oss": "^2.7.1", "slash": "^3.0.0", "standard": "^16.0.3", - "tap": "^15.0.6" + "tap": "^15.1.6" }, "dependencies": { "@npmcli/promise-spawn": "^1.3.2", - "lru-cache": "^6.0.0", + "lru-cache": "^7.3.1", "mkdirp": "^1.0.4", - "npm-pick-manifest": "^6.1.1", + "npm-pick-manifest": "^7.0.0", + "proc-log": "^2.0.0", "promise-inflight": "^1.0.1", "promise-retry": "^2.0.1", "semver": "^7.3.5", "which": "^2.0.2" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16" + }, + "templateOSS": { + "windowsCI": false, + "version": "2.7.1" } } diff --git a/node_modules/@npmcli/metavuln-calculator/lib/advisory.js b/node_modules/@npmcli/metavuln-calculator/lib/advisory.js index d0900e3732846..5b58ef6370724 100644 --- a/node_modules/@npmcli/metavuln-calculator/lib/advisory.js +++ b/node_modules/@npmcli/metavuln-calculator/lib/advisory.js @@ -22,8 +22,9 @@ class Advisory { this[_source] = source this[_options] = options this.name = name - if (!source.name) + if (!source.name) { source.name = name + } this.dependency = source.name @@ -70,11 +71,13 @@ class Advisory { // load up the data from a cache entry and a fetched packument load (cached, packument) { // basic data integrity gutcheck - if (!cached || typeof cached !== 'object') + if (!cached || typeof cached !== 'object') { throw new TypeError('invalid cached data, expected object') + } - if (!packument || typeof packument !== 'object') + if (!packument || typeof packument !== 'object') { throw new TypeError('invalid packument data, expected object') + } if (cached.id && cached.id !== this.id) { throw Object.assign(new Error('loading from incorrect cache entry'), { @@ -88,14 +91,16 @@ class Advisory { actual: packument.name, }) } - if (this[_packument]) + if (this[_packument]) { throw new Error('advisory object already loaded') + } // if we have a range from the initialization, and the cached // data has a *different* range, then we know we have to recalc. // just don't use the cached data, so we will definitely not match later - if (!this.range || cached.range && cached.range === this.range) + if (!this.range || cached.range && cached.range === this.range) { Object.assign(this, cached) + } this[_packument] = packument @@ -107,8 +112,9 @@ class Advisory { if (!this.versions.includes(v)) { versionsAdded.push(v) this.versions.push(v) - } else if (!pakuVersions.includes(v)) + } else if (!pakuVersions.includes(v)) { versionsRemoved.push(v) + } } // strip out any removed versions from our lists, and sort by semver @@ -138,14 +144,16 @@ class Advisory { this[_updated] = true // test any versions newly added - if (!unchanged || versionsAdded.length) + if (!unchanged || versionsAdded.length) { this[_testVersions](unchanged ? versionsAdded : this.versions) + } this.vulnerableVersions = semver.sort(this.vulnerableVersions, semverOpt) // metavulns have to calculate their range, since cache is invalidated // advisories just get their range from the advisory above - if (this.type === 'metavuln') + if (this.type === 'metavuln') { this[_calculateRange]() + } return this } @@ -170,10 +178,11 @@ class Advisory { } break } - if (vr.length > 1) + if (vr.length > 1) { vr[1] = this.versions[v] - else + } else { vr.push(this.versions[v]) + } v++ vulnVer++ } @@ -198,26 +207,30 @@ class Advisory { // we use the dependency version from the manifest. testVersion (version, spec = null) { const sv = String(version) - if (this[_versionVulnMemo].has(sv)) + if (this[_versionVulnMemo].has(sv)) { return this[_versionVulnMemo].get(sv) + } const result = this[_testVersion](version, spec) - if (result) + if (result) { this[_markVulnerable](version) + } this[_versionVulnMemo].set(sv, !!result) return result } [_markVulnerable] (version) { const sv = String(version) - if (!this.vulnerableVersions.includes(sv)) + if (!this.vulnerableVersions.includes(sv)) { this.vulnerableVersions.push(sv) + } } [_testVersion] (version, spec) { const sv = String(version) - if (this.vulnerableVersions.includes(sv)) + if (this.vulnerableVersions.includes(sv)) { return true + } if (this.type === 'advisory') { // advisory, just test range @@ -233,12 +246,14 @@ class Advisory { }, } - if (!spec) + if (!spec) { spec = getDepSpec(mani, this.dependency) + } // no dep, no vuln - if (spec === null) + if (spec === null) { return false + } if (!semver.validRange(spec, semverOpt)) { // not a semver range, nothing we can hope to do about it @@ -252,8 +267,9 @@ class Advisory { // try to pick a version of the dep that isn't vulnerable const avoid = this[_source].range - if (bundled) + if (bundled) { return semver.intersects(spec, avoid, semverOpt) + } return this[_source].testSpec(spec) } @@ -263,8 +279,9 @@ class Advisory { // consistent across multiple versions, so memoize this as well, in case // we're testing lots of versions. const memo = this[_specVulnMemo] - if (memo.has(spec)) + if (memo.has(spec)) { return memo.get(spec) + } const res = this[_testSpec](spec) memo.set(spec, res) @@ -274,10 +291,12 @@ class Advisory { [_testSpec] (spec) { for (const v of this.versions) { const satisfies = semver.satisfies(v, spec) - if (!satisfies) + if (!satisfies) { continue - if (!this.testVersion(v)) + } + if (!this.testVersion(v)) { return false + } } // either vulnerable, or not installable because nothing satisfied // either way, best avoided. @@ -285,8 +304,9 @@ class Advisory { } [_testVersions] (versions) { - if (!versions.length) + if (!versions.length) { return + } // set of lists of versions const versionSets = new Set() @@ -328,30 +348,34 @@ class Advisory { // version in the list, then start there instead. let h = 0 const origHeadVuln = this.testVersion(list[h]) - while (h < list.length && /-/.test(String(list[h]))) + while (h < list.length && /-/.test(String(list[h]))) { h++ + } // don't filter out the whole list! they might all be pr's - if (h === list.length) + if (h === list.length) { h = 0 - else if (origHeadVuln) { + } else if (origHeadVuln) { // if the original was vulnerable, assume so are all of these - for (let hh = 0; hh < h; hh++) + for (let hh = 0; hh < h; hh++) { this[_markVulnerable](list[hh]) + } } let t = list.length - 1 const origTailVuln = this.testVersion(list[t]) - while (t > h && /-/.test(String(list[t]))) + while (t > h && /-/.test(String(list[t]))) { t-- + } // don't filter out the whole list! might all be pr's - if (t === h) + if (t === h) { t = list.length - 1 - else if (origTailVuln) { + } else if (origTailVuln) { // if original tail was vulnerable, assume these are as well - for (let tt = list.length - 1; tt > t; tt--) + for (let tt = list.length - 1; tt > t; tt--) { this[_markVulnerable](list[tt]) + } } const headVuln = h === 0 ? origHeadVuln @@ -362,14 +386,16 @@ class Advisory { // if head and tail both vulnerable, whole list is thrown out if (headVuln && tailVuln) { - for (let v = h; v < t; v++) + for (let v = h; v < t; v++) { this[_markVulnerable](list[v]) + } continue } // if length is 2 or 1, then we marked them all already - if (t < h + 2) + if (t < h + 2) { continue + } const mid = Math.floor(list.length / 2) const pre = list.slice(0, mid) @@ -382,8 +408,9 @@ class Advisory { const midVuln = this.testVersion(pre[pre.length - 1]) while (/-/.test(String(pre[pre.length - 1]))) { const v = pre.pop() - if (midVuln) + if (midVuln) { this[_markVulnerable](v) + } } } @@ -391,8 +418,9 @@ class Advisory { const midVuln = this.testVersion(post[0]) while (/-/.test(String(post[0]))) { const v = post.shift() - if (midVuln) + if (midVuln) { this[_markVulnerable](v) + } } } diff --git a/node_modules/@npmcli/metavuln-calculator/lib/hash.js b/node_modules/@npmcli/metavuln-calculator/lib/hash.js index 79c0678c7581a..634bf99de0494 100644 --- a/node_modules/@npmcli/metavuln-calculator/lib/hash.js +++ b/node_modules/@npmcli/metavuln-calculator/lib/hash.js @@ -1,5 +1,5 @@ -const {createHash} = require('crypto') +const { createHash } = require('crypto') -module.exports = ({name, source}) => createHash('sha512') +module.exports = ({ name, source }) => createHash('sha512') .update(JSON.stringify([name, source])) .digest('base64') diff --git a/node_modules/@npmcli/metavuln-calculator/lib/index.js b/node_modules/@npmcli/metavuln-calculator/lib/index.js index 02c1ed018b8b5..668f55942c506 100644 --- a/node_modules/@npmcli/metavuln-calculator/lib/index.js +++ b/node_modules/@npmcli/metavuln-calculator/lib/index.js @@ -4,7 +4,7 @@ const pacote = require('pacote') const cacache = require('cacache') const Advisory = require('./advisory.js') -const {homedir} = require('os') +const { homedir } = require('os') const jsonParse = require('json-parse-even-better-errors') const _packument = Symbol('packument') @@ -37,8 +37,9 @@ class Calculator { async calculate (name, source) { const k = `security-advisory:${name}:${source.id}` - if (this[_advisories].has(k)) + if (this[_advisories].has(k)) { return this[_advisories].get(k) + } const p = this[_calculate](name, source) this[_advisories].set(k, p) @@ -58,8 +59,9 @@ class Calculator { process.emit('time', `metavuln:load:${k}`) advisory.load(cached, packument) process.emit('timeEnd', `metavuln:load:${k}`) - if (advisory.updated) + if (advisory.updated) { await this[_cachePut](advisory) + } this[_advisories].set(k, advisory) process.emit('timeEnd', t) return advisory @@ -81,8 +83,9 @@ class Calculator { const key = `security-advisory:${name}:${id}` /* istanbul ignore if - should be impossible, since we memoize the * advisory object itself using the same key, just being cautious */ - if (this[_cacheData].has(key)) + if (this[_cacheData].has(key)) { return this[_cacheData].get(key) + } process.emit('time', `metavuln:cache:get:${key}`) const p = cacache.get(this[_cache], key, { ...this[_options] }) @@ -98,8 +101,9 @@ class Calculator { } async [_packument] (name) { - if (this[_packuments].has(name)) + if (this[_packuments].has(name)) { return this[_packuments].get(name) + } process.emit('time', `metavuln:packument:${name}`) const p = pacote.packument(name, { ...this[_options] }) diff --git a/node_modules/@npmcli/metavuln-calculator/package.json b/node_modules/@npmcli/metavuln-calculator/package.json index 131cff672332d..385a34b85af27 100644 --- a/node_modules/@npmcli/metavuln-calculator/package.json +++ b/node_modules/@npmcli/metavuln-calculator/package.json @@ -1,13 +1,14 @@ { "name": "@npmcli/metavuln-calculator", - "version": "2.0.0", + "version": "3.0.0", "main": "lib/index.js", "files": [ + "bin", "lib" ], "description": "Calculate meta-vulnerabilities from package security advisories", "repository": "https://github.com/npm/metavuln-calculator", - "author": "Isaac Z. Schlueter (https://izs.me)", + "author": "GitHub Inc.", "license": "ISC", "scripts": { "test": "tap", @@ -18,29 +19,30 @@ "postversion": "npm publish", "prepublishOnly": "git push origin --follow-tags", "eslint": "eslint", - "lint": "npm run eslint -- \"lib/**/*.js\" \"test/**/*.js\"", - "lintfix": "npm run lint -- --fix" + "lint": "eslint '**/*.js'", + "lintfix": "npm run lint -- --fix", + "postlint": "npm-template-check", + "template-copy": "npm-template-copy --force" }, "tap": { "check-coverage": true, "coverage-map": "map.js" }, "devDependencies": { - "eslint": "^7.20.0", - "eslint-plugin-import": "^2.22.1", - "eslint-plugin-node": "^11.1.0", - "eslint-plugin-promise": "^4.3.1", - "eslint-plugin-standard": "^4.1.0", + "@npmcli/template-oss": "^2.7.1", "require-inject": "^1.4.4", - "tap": "^14.10.8" + "tap": "^15.1.6" }, "dependencies": { - "cacache": "^15.0.5", + "cacache": "^15.3.0", "json-parse-even-better-errors": "^2.3.1", - "pacote": "^12.0.0", - "semver": "^7.3.2" + "pacote": "^13.0.1", + "semver": "^7.3.5" }, "engines": { "node": "^12.13.0 || ^14.15.0 || >=16" + }, + "templateOSS": { + "version": "2.7.1" } } diff --git a/node_modules/init-package-json/lib/init-package-json.js b/node_modules/init-package-json/lib/init-package-json.js index bee79351caab3..f13a34ce6ff4e 100644 --- a/node_modules/init-package-json/lib/init-package-json.js +++ b/node_modules/init-package-json/lib/init-package-json.js @@ -127,7 +127,7 @@ function init (dir, input, config, cb) { return write(true) } console.log('About to write to %s:\n\n%s\n', packageFile, d) - read({prompt: 'Is this OK? ', default: 'yes'}, function (er, ok) { + read({ prompt: 'Is this OK? ', default: 'yes' }, function (er, ok) { if (er) { return cb(er) } diff --git a/node_modules/init-package-json/package.json b/node_modules/init-package-json/package.json index 6d642f6cf6879..7649c503de815 100644 --- a/node_modules/init-package-json/package.json +++ b/node_modules/init-package-json/package.json @@ -1,6 +1,6 @@ { "name": "init-package-json", - "version": "2.0.5", + "version": "3.0.0", "main": "lib/init-package-json.js", "scripts": { "test": "tap", @@ -11,7 +11,8 @@ "postlint": "npm-template-check", "lintfix": "npm run lint -- --fix", "snap": "tap", - "posttest": "npm run lint" + "posttest": "npm run lint", + "template-copy": "npm-template-copy --force" }, "repository": { "type": "git", @@ -21,21 +22,21 @@ "license": "ISC", "description": "A node module to get your node module started", "dependencies": { - "npm-package-arg": "^8.1.5", + "npm-package-arg": "^9.0.0", "promzard": "^0.3.0", - "read": "~1.0.1", + "read": "^1.0.7", "read-package-json": "^4.1.1", "semver": "^7.3.5", "validate-npm-package-license": "^3.0.4", "validate-npm-package-name": "^3.0.0" }, "devDependencies": { - "@npmcli/config": "^2.1.0", - "@npmcli/template-oss": "^1.0.3", - "tap": "^15.0.9" + "@npmcli/config": "^4.0.0", + "@npmcli/template-oss": "^2.7.1", + "tap": "^15.1.6" }, "engines": { - "node": ">=10" + "node": "^12.13.0 || ^14.15.0 || >=16" }, "tap": { "statements": "94", @@ -56,5 +57,7 @@ "bin", "lib" ], - "templateVersion": "1.0.3" + "templateOSS": { + "version": "2.7.1" + } } diff --git a/node_modules/npm-package-arg/npa.js b/node_modules/npm-package-arg/lib/npa.js similarity index 86% rename from node_modules/npm-package-arg/npa.js rename to node_modules/npm-package-arg/lib/npa.js index 191befeb5e69d..cc1eddaec74b4 100644 --- a/node_modules/npm-package-arg/npa.js +++ b/node_modules/npm-package-arg/lib/npa.js @@ -20,30 +20,32 @@ function npa (arg, where) { let name let spec if (typeof arg === 'object') { - if (arg instanceof Result && (!where || where === arg.where)) + if (arg instanceof Result && (!where || where === arg.where)) { return arg - else if (arg.name && arg.rawSpec) + } else if (arg.name && arg.rawSpec) { return npa.resolve(arg.name, arg.rawSpec, where || arg.where) - else + } 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)) + if (isURL.test(arg)) { spec = arg - else if (isGit.test(arg)) + } else if (isGit.test(arg)) { spec = `git+ssh://${arg}` - else if (namePart[0] !== '@' && (hasSlashes.test(namePart) || isFilename.test(namePart))) + } else if (namePart[0] !== '@' && (hasSlashes.test(namePart) || isFilename.test(namePart))) { spec = arg - else if (nameEndsAt > 0) { + } else if (nameEndsAt > 0) { name = namePart spec = arg.slice(nameEndsAt + 1) } else { const valid = validatePackageName(arg) - if (valid.validForOldPackages) + if (valid.validForOldPackages) { name = arg - else + } else { spec = arg + } } return resolve(name, spec, where, arg) } @@ -58,35 +60,41 @@ function resolve (name, spec, where, arg) { fromArgument: arg != null, }) - if (name) + if (name) { res.setName(name) + } - if (spec && (isFilespec.test(spec) || /^file:/i.test(spec))) + if (spec && (isFilespec.test(spec) || /^file:/i.test(spec))) { return fromFile(res, where) - else if (spec && /^npm:/i.test(spec)) + } else if (spec && /^npm:/i.test(spec)) { return fromAlias(res, where) + } const hosted = HostedGit.fromUrl(spec, { noGitPlus: true, noCommittish: true, }) - if (hosted) + if (hosted) { return fromHostedGit(res, hosted) - else if (spec && isURL.test(spec)) + } else if (spec && isURL.test(spec)) { return fromURL(res) - else if (spec && (hasSlashes.test(spec) || isFilename.test(spec))) + } else if (spec && (hasSlashes.test(spec) || isFilename.test(spec))) { return fromFile(res, where) - else + } else { return fromRegistry(res) + } } -function invalidPackageName (name, valid) { - const err = new Error(`Invalid package name "${name}": ${valid.errors.join('; ')}`) +function invalidPackageName (name, valid, raw) { + // eslint-disable-next-line max-len + const err = new Error(`Invalid package name "${name}" of package "${raw}": ${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.`) + +function invalidTagName (name, raw) { + // eslint-disable-next-line max-len + const err = new Error(`Invalid tag name "${name}" of package "${raw}": Tags may not have any characters that encodeURIComponent encodes.`) err.code = 'EINVALIDTAGNAME' return err } @@ -95,10 +103,11 @@ function Result (opts) { this.type = opts.type this.registry = opts.registry this.where = opts.where - if (opts.raw == null) + if (opts.raw == null) { this.raw = opts.name ? opts.name + '@' + opts.rawSpec : opts.rawSpec - else + } else { this.raw = opts.raw + } this.name = undefined this.escapedName = undefined @@ -106,8 +115,9 @@ function Result (opts) { this.rawSpec = opts.rawSpec == null ? '' : opts.rawSpec this.saveSpec = opts.saveSpec this.fetchSpec = opts.fetchSpec - if (opts.name) + if (opts.name) { this.setName(opts.name) + } this.gitRange = opts.gitRange this.gitCommittish = opts.gitCommittish this.hosted = opts.hosted @@ -115,8 +125,9 @@ function Result (opts) { Result.prototype.setName = function (name) { const valid = validatePackageName(name) - if (!valid.validForOldPackages) - throw invalidPackageName(name, valid) + if (!valid.validForOldPackages) { + throw invalidPackageName(name, valid, this.raw) + } this.name = name this.scope = name[0] === '@' ? name.slice(0, name.indexOf('/')) : undefined @@ -127,11 +138,13 @@ Result.prototype.setName = function (name) { Result.prototype.toString = function () { const full = [] - if (this.name != null && this.name !== '') + if (this.name != null && this.name !== '') { full.push(this.name) + } const spec = this.saveSpec || this.fetchSpec || this.rawSpec - if (spec != null && spec !== '') + if (spec != null && spec !== '') { full.push(spec) + } return full.length ? full.join('@') : this.raw } @@ -145,21 +158,23 @@ 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 + } else { res.gitCommittish = committish === '' ? null : committish + } return res } function fromFile (res, where) { - if (!where) + if (!where) { where = process.cwd() + } res.type = isFilename.test(res.rawSpec) ? 'file' : 'directory' res.where = where // always put the '/' on where when resolving urls, or else // file:foo from /path/to/bar goes to /path/to/foo, when we want - // it to be /path/to/foo/bar + // it to be /path/to/bar/foo let specUrl let resolvedUrl @@ -225,10 +240,11 @@ function fromFile (res, where) { if (/^\/~(\/|$)/.test(specPath)) { res.saveSpec = `file:${specPath.substr(1)}` resolvedPath = path.resolve(homedir(), specPath.substr(3)) - } else if (!path.isAbsolute(rawNoPrefix)) + } else if (!path.isAbsolute(rawNoPrefix)) { res.saveSpec = `file:${path.relative(where, resolvedPath)}` - else + } else { res.saveSpec = `file:${path.resolve(resolvedPath)}` + } res.fetchSpec = path.resolve(where, resolvedPath) return res @@ -311,11 +327,13 @@ function fromURL (res) { function fromAlias (res, where) { const subSpec = npa(res.rawSpec.substr(4), where) - if (subSpec.type === 'alias') + if (subSpec.type === 'alias') { throw new Error('nested aliases not supported') + } - if (!subSpec.registry) + if (!subSpec.registry) { throw new Error('aliases only work for registry deps') + } res.subSpec = subSpec res.registry = true @@ -334,14 +352,14 @@ function fromRegistry (res) { res.fetchSpec = spec const version = semver.valid(spec, true) const range = semver.validRange(spec, true) - if (version) + if (version) { res.type = 'version' - else if (range) + } else if (range) { res.type = 'range' - else { - if (encodeURIComponent(spec) !== spec) - throw invalidTagName(spec) - + } else { + if (encodeURIComponent(spec) !== spec) { + throw invalidTagName(spec, res.raw) + } res.type = 'tag' } return res diff --git a/node_modules/npm-package-arg/package.json b/node_modules/npm-package-arg/package.json index bf5f597e6d8df..b0821312a7f0d 100644 --- a/node_modules/npm-package-arg/package.json +++ b/node_modules/npm-package-arg/package.json @@ -1,22 +1,23 @@ { "name": "npm-package-arg", - "version": "8.1.5", + "version": "9.0.0", "description": "Parse the things that can be arguments to `npm install`", - "main": "npa.js", + "main": "./lib/npa.js", "directories": { "test": "test" }, "files": [ - "npa.js" + "bin", + "lib" ], "dependencies": { - "hosted-git-info": "^4.0.1", - "semver": "^7.3.4", + "hosted-git-info": "^4.1.0", + "semver": "^7.3.5", "validate-npm-package-name": "^3.0.0" }, "devDependencies": { - "@npmcli/lint": "^1.0.1", - "tap": "^15.0.9" + "@npmcli/template-oss": "^2.7.1", + "tap": "^15.1.6" }, "scripts": { "preversion": "npm test", @@ -25,22 +26,30 @@ "test": "tap", "snap": "tap", "npmclilint": "npmcli-lint", - "lint": "npm run npmclilint -- \"*.*js\" \"test/**/*.*js\"", + "lint": "eslint '**/*.js'", "lintfix": "npm run lint -- --fix", - "posttest": "npm run lint --", - "postsnap": "npm run lintfix --" + "posttest": "npm run lint", + "postsnap": "npm run lintfix --", + "postlint": "npm-template-check", + "template-copy": "npm-template-copy --force" }, "repository": { "type": "git", "url": "https://github.com/npm/npm-package-arg" }, - "author": "Isaac Z. Schlueter (http://blog.izs.me/)", + "author": "GitHub Inc.", "license": "ISC", "bugs": { "url": "https://github.com/npm/npm-package-arg/issues" }, "homepage": "https://github.com/npm/npm-package-arg", "engines": { - "node": ">=10" + "node": "^12.13.0 || ^14.15.0 || >=16" + }, + "tap": { + "branches": 97 + }, + "templateOSS": { + "version": "2.7.1" } } diff --git a/node_modules/npm-pick-manifest/index.js b/node_modules/npm-pick-manifest/lib/index.js similarity index 96% rename from node_modules/npm-pick-manifest/index.js rename to node_modules/npm-pick-manifest/lib/index.js index 695450524dc13..f2934e9ca1822 100644 --- a/node_modules/npm-pick-manifest/index.js +++ b/node_modules/npm-pick-manifest/lib/index.js @@ -34,7 +34,7 @@ const pickManifest = (packument, wanted, opts) => { npmVersion = null, includeStaged = false, avoid = null, - avoidStrict = false + avoidStrict = false, } = opts const { name, time: verTimes } = packument @@ -43,7 +43,7 @@ const pickManifest = (packument, wanted, opts) => { if (avoidStrict) { const looseOpts = { ...opts, - avoidStrict: false + avoidStrict: false, } const result = pickManifest(packument, wanted, looseOpts) @@ -56,7 +56,7 @@ const pickManifest = (packument, wanted, opts) => { return { ...caret, _outsideDependencyRange: true, - _isSemVerMajor: false + _isSemVerMajor: false, } } @@ -65,7 +65,7 @@ const pickManifest = (packument, wanted, opts) => { return { ...star, _outsideDependencyRange: true, - _isSemVerMajor: true + _isSemVerMajor: true, } } @@ -75,7 +75,7 @@ const pickManifest = (packument, wanted, opts) => { wanted, avoid, before, - versions: Object.keys(versions) + versions: Object.keys(versions), }) } @@ -143,7 +143,7 @@ const pickManifest = (packument, wanted, opts) => { type, wanted, before, - versions: Object.keys(versions) + versions: Object.keys(versions), }) } @@ -213,6 +213,6 @@ module.exports = (packument, wanted, opts = {}) => { versions: Object.keys(packument.versions), name, distTags: packument['dist-tags'], - defaultTag + defaultTag, }) } diff --git a/node_modules/npm-pick-manifest/package.json b/node_modules/npm-pick-manifest/package.json index 4b4866cbf8832..ece1d174dbc0c 100644 --- a/node_modules/npm-pick-manifest/package.json +++ b/node_modules/npm-pick-manifest/package.json @@ -1,19 +1,24 @@ { "name": "npm-pick-manifest", - "version": "6.1.1", + "version": "7.0.0", "description": "Resolves a matching manifest from a package metadata document according to standard npm semver resolution rules.", - "main": "index.js", + "main": "./lib", "files": [ - "*.js" + "bin", + "lib" ], "scripts": { "coverage": "tap", - "lint": "standard", + "lint": "eslint '**/*.js'", "test": "tap", "posttest": "npm run lint", "preversion": "npm test", "postversion": "npm publish", - "prepublishOnly": "git push origin --follow-tags" + "prepublishOnly": "git push origin --follow-tags", + "postlint": "npm-template-check", + "template-copy": "npm-template-copy --force", + "lintfix": "npm run lint -- --fix", + "snap": "tap" }, "repository": "https://github.com/npm/npm-pick-manifest", "keywords": [ @@ -21,23 +26,25 @@ "semver", "package manager" ], - "author": { - "name": "Kat Marchán", - "email": "kzm@sykosomatic.org", - "twitter": "maybekatz" - }, + "author": "GitHub Inc.", "license": "ISC", "dependencies": { "npm-install-checks": "^4.0.0", "npm-normalize-package-bin": "^1.0.1", - "npm-package-arg": "^8.1.2", - "semver": "^7.3.4" + "npm-package-arg": "^9.0.0", + "semver": "^7.3.5" }, "devDependencies": { - "standard": "^14.3.1", - "tap": "^14.11.0" + "@npmcli/template-oss": "^2.7.1", + "tap": "^15.1.6" }, "tap": { "check-coverage": true + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16" + }, + "templateOSS": { + "version": "2.7.1" } } diff --git a/node_modules/npm-profile/lib/index.js b/node_modules/npm-profile/lib/index.js index aa322e37f4824..74a8084292a6c 100644 --- a/node_modules/npm-profile/lib/index.js +++ b/node_modules/npm-profile/lib/index.js @@ -4,13 +4,14 @@ const fetch = require('npm-registry-fetch') const { HttpErrorBase } = require('npm-registry-fetch/lib/errors') const os = require('os') const { URL } = require('url') +const log = require('proc-log') // try loginWeb, catch the "not supported" message and fall back to couch const login = (opener, prompter, opts = {}) => { const { creds } = opts return loginWeb(opener, opts).catch(er => { if (er instanceof WebLoginNotSupported) { - process.emit('log', 'verbose', 'web login not supported, trying couch') + log.verbose('web login not supported, trying couch') return prompter(creds) .then(data => loginCouch(data.username, data.password, opts)) } else { @@ -23,7 +24,7 @@ const adduser = (opener, prompter, opts = {}) => { const { creds } = opts return adduserWeb(opener, opts).catch(er => { if (er instanceof WebLoginNotSupported) { - process.emit('log', 'verbose', 'web adduser not supported, trying couch') + log.verbose('web adduser not supported, trying couch') return prompter(creds) .then(data => adduserCouch(data.username, data.email, data.password, opts)) } else { @@ -33,12 +34,12 @@ const adduser = (opener, prompter, opts = {}) => { } const adduserWeb = (opener, opts = {}) => { - process.emit('log', 'verbose', 'web adduser', 'before first POST') + log.verbose('web adduser', 'before first POST') return webAuth(opener, opts, { create: true }) } const loginWeb = (opener, opts = {}) => { - process.emit('log', 'verbose', 'web login', 'before first POST') + log.verbose('web login', 'before first POST') return webAuth(opener, opts, {}) } @@ -62,13 +63,13 @@ const webAuth = (opener, opts, body) => { return Promise.all([res, res.json()]) }).then(([res, content]) => { const { doneUrl, loginUrl } = content - process.emit('log', 'verbose', 'web auth', 'got response', content) + log.verbose('web auth', 'got response', content) if (!isValidUrl(doneUrl) || !isValidUrl(loginUrl)) { throw new WebLoginInvalidResponse('POST', res, content) } return content }).then(({ doneUrl, loginUrl }) => { - process.emit('log', 'verbose', 'web auth', 'opening url pair') + log.verbose('web auth', 'opening url pair') return opener(loginUrl).then( () => webAuthCheckLogin(doneUrl, { ...opts, cache: false }) ) @@ -121,7 +122,7 @@ const adduserCouch = (username, email, password, opts = {}) => { ...body, password: 'XXXXX', } - process.emit('log', 'verbose', 'adduser', 'before first PUT', logObj) + log.verbose('adduser', 'before first PUT', logObj) const target = '/-/user/org.couchdb.user:' + encodeURIComponent(username) return fetch.json(target, { @@ -147,9 +148,9 @@ const loginCouch = (username, password, opts = {}) => { ...body, password: 'XXXXX', } - process.emit('log', 'verbose', 'login', 'before first PUT', logObj) + log.verbose('login', 'before first PUT', logObj) - const target = '-/user/org.couchdb.user:' + encodeURIComponent(username) + const target = '/-/user/org.couchdb.user:' + encodeURIComponent(username) return fetch.json(target, { ...opts, method: 'PUT', diff --git a/node_modules/npm-profile/package.json b/node_modules/npm-profile/package.json index 8745c2559f33f..68b04bba6d900 100644 --- a/node_modules/npm-profile/package.json +++ b/node_modules/npm-profile/package.json @@ -1,12 +1,13 @@ { "name": "npm-profile", - "version": "6.0.0", + "version": "6.0.2", "description": "Library for updating an npmjs.com profile", "keywords": [], "author": "GitHub Inc.", "license": "ISC", "dependencies": { - "npm-registry-fetch": "^12.0.0" + "npm-registry-fetch": "^13.0.0", + "proc-log": "^2.0.0" }, "main": "./lib/index.js", "repository": { @@ -18,9 +19,9 @@ "lib" ], "devDependencies": { - "@npmcli/template-oss": "^2.5.1", - "nock": "^13.2.1", - "tap": "^15.1.5" + "@npmcli/template-oss": "^2.7.1", + "nock": "^13.2.4", + "tap": "^15.1.6" }, "scripts": { "preversion": "npm test", @@ -31,7 +32,8 @@ "snap": "tap", "lint": "eslint '**/*.js'", "postlint": "npm-template-check", - "lintfix": "npm run lint -- --fix" + "lintfix": "npm run lint -- --fix", + "template-copy": "npm-template-copy --force" }, "tap": { "check-coverage": true @@ -40,6 +42,6 @@ "node": "^12.13.0 || ^14.15.0 || >=16" }, "templateOSS": { - "version": "2.5.1" + "version": "2.7.1" } } diff --git a/node_modules/npm-registry-fetch/lib/check-response.js b/node_modules/npm-registry-fetch/lib/check-response.js index 26043a96de854..872ec8a888694 100644 --- a/node_modules/npm-registry-fetch/lib/check-response.js +++ b/node_modules/npm-registry-fetch/lib/check-response.js @@ -3,23 +3,24 @@ const errors = require('./errors.js') const { Response } = require('minipass-fetch') const defaultOpts = require('./default-opts.js') +const log = require('proc-log') /* eslint-disable-next-line max-len */ const moreInfoUrl = 'https://github.com/npm/cli/wiki/No-auth-for-URI,-but-auth-present-for-scoped-registry' const checkResponse = - async ({ method, uri, res, registry, startTime, auth, opts }) => { + async ({ method, uri, res, startTime, auth, opts }) => { opts = { ...defaultOpts, ...opts } if (res.headers.has('npm-notice') && !res.headers.has('x-local-cache')) { - opts.log.notice('', res.headers.get('npm-notice')) + log.notice('', res.headers.get('npm-notice')) } if (res.status >= 400) { - logRequest(method, res, startTime, opts) + logRequest(method, res, startTime) if (auth && auth.scopeAuthKey && !auth.token && !auth.auth) { // we didn't have auth for THIS request, but we do have auth for // requests to the registry indicated by the spec's scope value. // Warn the user. - opts.log.warn('registry', `No auth for URI, but auth present for scoped registry. + log.warn('registry', `No auth for URI, but auth present for scoped registry. URI: ${uri} Scoped Registry Key: ${auth.scopeAuthKey} @@ -38,7 +39,7 @@ More info here: ${moreInfoUrl}`) } module.exports = checkResponse -function logRequest (method, res, startTime, opts) { +function logRequest (method, res, startTime) { const elapsedTime = Date.now() - startTime const attempt = res.headers.get('x-fetch-attempts') const attemptStr = attempt && attempt > 1 ? ` attempt #${attempt}` : '' @@ -58,7 +59,7 @@ function logRequest (method, res, startTime, opts) { urlStr = res.url } - opts.log.http( + log.http( 'fetch', `${method.toUpperCase()} ${res.status} ${urlStr} ${elapsedTime}ms${attemptStr}${cacheStr}` ) diff --git a/node_modules/npm-registry-fetch/lib/default-opts.js b/node_modules/npm-registry-fetch/lib/default-opts.js index e8e8221da4a58..f0847f0b507e2 100644 --- a/node_modules/npm-registry-fetch/lib/default-opts.js +++ b/node_modules/npm-registry-fetch/lib/default-opts.js @@ -1,6 +1,5 @@ const pkg = require('../package.json') module.exports = { - log: require('./silentlog.js'), maxSockets: 12, method: 'GET', registry: 'https://registry.npmjs.org/', diff --git a/node_modules/npm-registry-fetch/package.json b/node_modules/npm-registry-fetch/package.json index f1aab5c7bb4a8..9349619e99e61 100644 --- a/node_modules/npm-registry-fetch/package.json +++ b/node_modules/npm-registry-fetch/package.json @@ -1,6 +1,6 @@ { "name": "npm-registry-fetch", - "version": "12.0.2", + "version": "13.0.0", "description": "Fetch-based http client for use with npm registry APIs", "main": "lib", "files": [ @@ -31,18 +31,18 @@ "author": "GitHub Inc.", "license": "ISC", "dependencies": { - "make-fetch-happen": "^10.0.1", + "make-fetch-happen": "^10.0.2", "minipass": "^3.1.6", "minipass-fetch": "^1.4.1", "minipass-json-stream": "^1.0.1", "minizlib": "^2.1.2", - "npm-package-arg": "^8.1.5" + "npm-package-arg": "^9.0.0", + "proc-log": "^2.0.0" }, "devDependencies": { "@npmcli/template-oss": "^2.7.1", "cacache": "^15.3.0", "nock": "^13.2.4", - "npmlog": "^6.0.0", "require-inject": "^1.4.4", "ssri": "^8.0.1", "tap": "^15.1.6" diff --git a/node_modules/pacote/lib/bin.js b/node_modules/pacote/lib/bin.js index c0409be1ff085..369304adaa879 100755 --- a/node_modules/pacote/lib/bin.js +++ b/node_modules/pacote/lib/bin.js @@ -4,26 +4,28 @@ const run = conf => { const pacote = require('../') switch (conf._[0]) { case 'resolve': - if (conf.long) + case 'manifest': + case 'packument': + if (conf._[0] === 'resolve' && conf.long) { return pacote.manifest(conf._[1], conf).then(mani => ({ resolved: mani._resolved, integrity: mani._integrity, from: mani._from, })) - case 'manifest': - case 'packument': + } return pacote[conf._[0]](conf._[1], conf) case 'tarball': if (!conf._[2] || conf._[2] === '-') { return pacote.tarball.stream(conf._[1], stream => { stream.pipe(conf.testStdout || - /* istanbul ignore next */ process.stdout) + /* istanbul ignore next */ process.stdout) // make sure it resolves something falsey return stream.promise().then(() => {}) }, conf) - } else + } else { return pacote.tarball.file(conf._[1], conf._[2], conf) + } case 'extract': return pacote.extract(conf._[1], conf._[2], conf) @@ -81,8 +83,9 @@ const pretty = (conf, result) => let addedLogListener = false const main = args => { const conf = parse(args) - if (conf.help || conf.h) + if (conf.help || conf.h) { return console.log(usage()) + } if (!addedLogListener) { process.on('log', console.error) @@ -121,14 +124,14 @@ const parse = args => { } let dashdash = false args.forEach(arg => { - if (dashdash) + if (dashdash) { conf._.push(arg) - else if (arg === '--') + } else if (arg === '--') { dashdash = true - else if (arg === '-h') + } else if (arg === '-h') { conf.help = true - else if (/^--/.test(arg)) { - const {key, value} = parseArg(arg) + } else if (/^--/.test(arg)) { + const { key, value } = parseArg(arg) conf[key] = value } else { conf._.push(arg) @@ -137,9 +140,9 @@ const parse = args => { return conf } -if (module === require.main) +if (module === require.main) { main(process.argv.slice(2)) -else +} else { module.exports = { main, run, @@ -147,3 +150,4 @@ else parseArg, parse, } +} diff --git a/node_modules/pacote/lib/dir.js b/node_modules/pacote/lib/dir.js index 0d3a00d95ae7c..598b029f7ad48 100644 --- a/node_modules/pacote/lib/dir.js +++ b/node_modules/pacote/lib/dir.js @@ -1,14 +1,12 @@ const Fetcher = require('./fetcher.js') const FileFetcher = require('./file.js') -const cacache = require('cacache') const Minipass = require('minipass') -const { promisify } = require('util') -const readPackageJson = require('read-package-json-fast') const tarCreateOptions = require('./util/tar-create-options.js') const packlist = require('npm-packlist') const tar = require('tar') const _prepareDir = Symbol('_prepareDir') const { resolve } = require('path') +const _readPackageJson = Symbol.for('package.Fetcher._readPackageJson') const runScript = require('@npmcli/run-script') @@ -31,18 +29,18 @@ class DirFetcher extends Fetcher { [_prepareDir] () { return this.manifest().then(mani => { - if (!mani.scripts || !mani.scripts.prepare) + if (!mani.scripts || !mani.scripts.prepare) { return + } // we *only* run prepare. // pre/post-pack is run by the npm CLI for publish and pack, // but this function is *also* run when installing git deps const stdio = this.opts.foregroundScripts ? 'inherit' : 'pipe' - // hide the banner if loglevel is silent, or if prepare running + // hide the banner if silent opt is passed in, or if prepare running // in the background. - const banner = this.opts.log && this.opts.log.level === 'silent' ? false - : stdio === 'inherit' + const banner = this.opts.silent ? false : stdio === 'inherit' return runScript({ pkg: mani, @@ -76,10 +74,11 @@ class DirFetcher extends Fetcher { } manifest () { - if (this.package) + if (this.package) { return Promise.resolve(this.package) + } - return readPackageJson(this.resolved + '/package.json') + return this[_readPackageJson](this.resolved + '/package.json') .then(mani => this.package = { ...mani, _integrity: this.integrity && String(this.integrity), diff --git a/node_modules/pacote/lib/fetcher.js b/node_modules/pacote/lib/fetcher.js index 69dd025b7bd98..78b13a9637c4f 100644 --- a/node_modules/pacote/lib/fetcher.js +++ b/node_modules/pacote/lib/fetcher.js @@ -9,12 +9,15 @@ const { promisify } = require('util') const { basename, dirname } = require('path') const rimraf = promisify(require('rimraf')) const tar = require('tar') -const procLog = require('./util/proc-log.js') +const log = require('proc-log') const retry = require('promise-retry') const fsm = require('fs-minipass') const cacache = require('cacache') const isPackageBin = require('./util/is-package-bin.js') +const removeTrailingSlashes = require('./util/trailing-slashes.js') const getContents = require('@npmcli/installed-package-contents') +const readPackageJsonFast = require('read-package-json-fast') +const readPackageJson = promisify(require('read-package-json')) // we only change ownership on unix platforms, and only if uid is 0 const selfOwner = process.getuid && process.getuid() === 0 ? { @@ -41,11 +44,13 @@ const _assertType = Symbol('_assertType') const _tarballFromCache = Symbol('_tarballFromCache') const _tarballFromResolved = Symbol.for('pacote.Fetcher._tarballFromResolved') const _cacheFetches = Symbol.for('pacote.Fetcher._cacheFetches') +const _readPackageJson = Symbol.for('package.Fetcher._readPackageJson') class FetcherBase { constructor (spec, opts) { - if (!opts || typeof opts !== 'object') + if (!opts || typeof opts !== 'object') { throw new TypeError('options object is required') + } this.spec = npa(spec, opts.where) this.allowGitIgnore = !!opts.allowGitIgnore @@ -62,7 +67,7 @@ class FetcherBase { this[_assertType]() // clone the opts object so that others aren't upset when we mutate it // by adding/modifying the integrity value. - this.opts = {...opts} + this.opts = { ...opts } this.cache = opts.cache || cacheDir() this.resolved = opts.resolved || null @@ -72,8 +77,9 @@ class FetcherBase { // is no longer strong enough. this.defaultIntegrityAlgorithm = opts.defaultIntegrityAlgorithm || 'sha512' - if (typeof opts.integrity === 'string') + if (typeof opts.integrity === 'string') { this.opts.integrity = ssri.parse(opts.integrity) + } this.package = null this.type = this.constructor.name @@ -85,7 +91,6 @@ class FetcherBase { // the process's umask setting do its job. but if configured, we do // respect it. this.umask = opts.umask || 0 - this.log = opts.log || procLog this.preferOnline = !!opts.preferOnline this.preferOffline = !!opts.preferOffline @@ -93,10 +98,15 @@ class FetcherBase { this.before = opts.before this.fullMetadata = this.before ? true : !!opts.fullMetadata + this.fullReadJson = !!opts.fullReadJson + if (this.fullReadJson) { + this[_readPackageJson] = readPackageJson + } else { + this[_readPackageJson] = readPackageJsonFast + } this.defaultTag = opts.defaultTag || 'latest' - this.registry = (opts.registry || 'https://registry.npmjs.org') - .replace(/\/+$/, '') + this.registry = removeTrailingSlashes(opts.registry || 'https://registry.npmjs.org') // command to run 'prepare' scripts on directories and git dirs // To use pacote with yarn, for example, set npmBin to 'yarn' @@ -104,7 +114,7 @@ class FetcherBase { this.npmBin = opts.npmBin || 'npm' // command to install deps for preparing - this.npmInstallCmd = opts.npmInstallCmd || [ 'install', '--force' ] + this.npmInstallCmd = opts.npmInstallCmd || ['install', '--force'] // XXX fill more of this in based on what we know from this.opts // we explicitly DO NOT fill in --tag, though, since we are often @@ -132,19 +142,22 @@ class FetcherBase { get integrity () { return this.opts.integrity || null } + set integrity (i) { - if (!i) + if (!i) { return + } i = ssri.parse(i) const current = this.opts.integrity // do not ever update an existing hash value, but do // merge in NEW algos and hashes that we don't already have. - if (current) + if (current) { current.merge(i) - else + } else { this.opts.integrity = i + } } get notImplementedError () { @@ -212,8 +225,9 @@ class FetcherBase { stream.on('error', er => istream.emit('error', er)) // if not caching this, just pipe through to the istream and return it - if (!this.opts.cache || !this[_cacheFetches]) + if (!this.opts.cache || !this[_cacheFetches]) { return stream.pipe(istream) + } // we have to return a stream that gets ALL the data, and proxies errors, // but then pipe from the original tarball stream into the cache as well. @@ -288,39 +302,42 @@ class FetcherBase { this.integrity && this.resolved ) ? streamHandler(this[_tarballFromCache]()).catch(er => { - if (this.isDataCorruptionError(er)) { - this.log.warn('tarball', `cached data for ${ + if (this.isDataCorruptionError(er)) { + log.warn('tarball', `cached data for ${ this.spec } (${this.integrity}) seems to be corrupted. Refreshing cache.`) - return this.cleanupCached().then(() => { throw er }) - } else { - throw er - } - }) : null + return this.cleanupCached().then(() => { + throw er + }) + } else { + throw er + } + }) : null const fromResolved = er => { if (er) { - if (!this.isRetriableError(er)) + if (!this.isRetriableError(er)) { throw er - this.log.silly('tarball', `no local data for ${ + } + log.silly('tarball', `no local data for ${ this.spec }. Extracting by manifest.`) } return this.resolve().then(() => retry(tryAgain => streamHandler(this[_istream](this[_tarballFromResolved]())) - .catch(er => { + .catch(er => { // Most likely data integrity. A cache ENOENT error is unlikely // here, since we're definitely not reading from the cache, but it // IS possible that the fetch subsystem accessed the cache, and the // entry got blown away or something. Try one more time to be sure. - if (this.isRetriableError(er)) { - this.log.warn('tarball', `tarball data for ${ + if (this.isRetriableError(er)) { + log.warn('tarball', `tarball data for ${ this.spec } (${this.integrity}) seems to be corrupted. Trying again.`) - return this.cleanupCached().then(() => tryAgain(er)) - } - throw er - }), { retries: 1, minTimeout: 0, maxTimeout: 0 })) + return this.cleanupCached().then(() => tryAgain(er)) + } + throw er + }), { retries: 1, minTimeout: 0, maxTimeout: 0 })) } return fromCache ? fromCache.catch(fromResolved) : fromResolved() @@ -337,7 +354,7 @@ class FetcherBase { } [_empty] (path) { - return getContents({path, depth: 1}).then(contents => Promise.all( + return getContents({ path, depth: 1 }).then(contents => Promise.all( contents.map(entry => rimraf(entry)))) } @@ -350,7 +367,7 @@ class FetcherBase { // parent folder (rare, but probably happens sometimes). return !inferOwner ? this[_empty](dest).then(() => mkdirp(dest)).then(() => ({})) - : inferOwner(dest).then(({uid, gid}) => + : inferOwner(dest).then(({ uid, gid }) => this[_empty](dest) .then(() => mkdirp(dest)) .then(made => { @@ -360,13 +377,13 @@ class FetcherBase { const dir = made || /* istanbul ignore next */ dest return this[_chown](dir, uid, gid) }) - .then(() => ({uid, gid}))) + .then(() => ({ uid, gid }))) } // extraction is always the same. the only difference is where // the tarball comes from. extract (dest) { - return this[_mkdir](dest).then(({uid, gid}) => + return this[_mkdir](dest).then(({ uid, gid }) => this.tarballStream(tarball => this[_extract](dest, tarball, uid, gid))) } @@ -389,7 +406,7 @@ class FetcherBase { const dir = dirname(dest) return !inferOwner ? mkdirp(dir).then(() => this[_toFile](dest)) - : inferOwner(dest).then(({uid, gid}) => + : inferOwner(dest).then(({ uid, gid }) => mkdirp(dir).then(made => this[_toFile](dest) .then(res => this[_chown](made || dir, uid, gid) .then(() => res)))) @@ -407,8 +424,8 @@ class FetcherBase { }) extractor.on('error', er => { - this.log.warn('tar', er.message) - this.log.silly('tar', er) + log.warn('tar', er.message) + log.silly('tar', er) reject(er) }) @@ -439,21 +456,23 @@ class FetcherBase { noChmod: true, noMtime: true, filter: (name, entry) => { - if (/Link$/.test(entry.type)) + if (/Link$/.test(entry.type)) { return false + } entry.mode = this[_entryMode](entry.path, entry.mode, entry.type) // this replicates the npm pack behavior where .gitignore files // are treated like .npmignore files, but only if a .npmignore // file is not present. if (/File$/.test(entry.type)) { const base = basename(entry.path) - if (base === '.npmignore') + if (base === '.npmignore') { sawIgnores.add(entry.path) - else if (base === '.gitignore' && !this.allowGitIgnore) { + } else if (base === '.gitignore' && !this.allowGitIgnore) { // rename, but only if there's not already a .npmignore const ni = entry.path.replace(/\.gitignore$/, '.npmignore') - if (sawIgnores.has(ni)) + if (sawIgnores.has(ni)) { return false + } entry.path = ni } return true @@ -462,8 +481,8 @@ class FetcherBase { strip: 1, onwarn: /* istanbul ignore next - we can trust that tar logs */ (code, msg, data) => { - this.log.warn('tar', code, msg) - this.log.silly('tar', code, msg, data) + log.warn('tar', code, msg) + log.silly('tar', code, msg, data) }, uid, gid, diff --git a/node_modules/pacote/lib/file.js b/node_modules/pacote/lib/file.js index d5c601aabd873..bf99bb86e359e 100644 --- a/node_modules/pacote/lib/file.js +++ b/node_modules/pacote/lib/file.js @@ -1,12 +1,11 @@ const Fetcher = require('./fetcher.js') const fsm = require('fs-minipass') const cacache = require('cacache') -const { promisify } = require('util') -const readPackageJson = require('read-package-json-fast') const _tarballFromResolved = Symbol.for('pacote.Fetcher._tarballFromResolved') const _exeBins = Symbol('_exeBins') const { resolve } = require('path') const fs = require('fs') +const _readPackageJson = Symbol.for('package.Fetcher._readPackageJson') class FileFetcher extends Fetcher { constructor (spec, opts) { @@ -20,24 +19,26 @@ class FileFetcher extends Fetcher { } manifest () { - if (this.package) + if (this.package) { return Promise.resolve(this.package) + } // have to unpack the tarball for this. return cacache.tmp.withTmp(this.cache, this.opts, dir => this.extract(dir) - .then(() => readPackageJson(dir + '/package.json')) - .then(mani => this.package = { - ...mani, - _integrity: this.integrity && String(this.integrity), - _resolved: this.resolved, - _from: this.from, - })) + .then(() => this[_readPackageJson](dir + '/package.json')) + .then(mani => this.package = { + ...mani, + _integrity: this.integrity && String(this.integrity), + _resolved: this.resolved, + _from: this.from, + })) } [_exeBins] (pkg, dest) { - if (!pkg.bin) + if (!pkg.bin) { return Promise.resolve() + } return Promise.all(Object.keys(pkg.bin).map(k => new Promise(res => { const script = resolve(dest, pkg.bin[k]) @@ -46,11 +47,13 @@ class FileFetcher extends Fetcher { // something, we just leave it for a later stage to trip over // when we can provide a more useful contextual error. fs.stat(script, (er, st) => { - if (er) + if (er) { return res() + } const mode = st.mode | 0o111 - if (mode === st.mode) + if (mode === st.mode) { return res() + } fs.chmod(script, mode, res) }) }))) @@ -61,8 +64,8 @@ class FileFetcher extends Fetcher { // but if not, read the unpacked manifest and chmod properly. return super.extract(dest) .then(result => this.package ? result - : readPackageJson(dest + '/package.json').then(pkg => - this[_exeBins](pkg, dest)).then(() => result)) + : this[_readPackageJson](dest + '/package.json').then(pkg => + this[_exeBins](pkg, dest)).then(() => result)) } [_tarballFromResolved] () { @@ -75,7 +78,7 @@ class FileFetcher extends Fetcher { return this.manifest().then(mani => ({ name: mani.name, 'dist-tags': { - [this.defaultTag]: mani.version + [this.defaultTag]: mani.version, }, versions: { [mani.version]: { @@ -83,9 +86,9 @@ class FileFetcher extends Fetcher { dist: { tarball: `file:${this.resolved}`, integrity: this.integrity && String(this.integrity), - } - } - } + }, + }, + }, })) } } diff --git a/node_modules/pacote/lib/git.js b/node_modules/pacote/lib/git.js index ab87d494ce4ba..cab389ff179c2 100644 --- a/node_modules/pacote/lib/git.js +++ b/node_modules/pacote/lib/git.js @@ -6,11 +6,9 @@ const hashre = /^[a-f0-9]{40}$/ const git = require('@npmcli/git') const pickManifest = require('npm-pick-manifest') const npa = require('npm-package-arg') -const url = require('url') const Minipass = require('minipass') const cacache = require('cacache') -const { promisify } = require('util') -const readPackageJson = require('read-package-json-fast') +const log = require('proc-log') const npm = require('./util/npm.js') const _resolvedFromRepo = Symbol('_resolvedFromRepo') @@ -24,6 +22,7 @@ const _cloneHosted = Symbol('_cloneHosted') const _cloneRepo = Symbol('_cloneRepo') const _setResolvedWithSha = Symbol('_setResolvedWithSha') const _prepareDir = Symbol('_prepareDir') +const _readPackageJson = Symbol.for('package.Fetcher._readPackageJson') // get the repository url. // prefer https if there's auth, since ssh will drop that. @@ -40,8 +39,9 @@ class GitFetcher extends Fetcher { constructor (spec, opts) { super(spec, opts) this.resolvedRef = null - if (this.spec.hosted) + if (this.spec.hosted) { this.from = this.spec.hosted.shortcut({ noCommittish: false }) + } // shortcut: avoid full clone when we can go straight to the tgz // if we have the full sha and it's a hosted git platform @@ -51,8 +51,9 @@ class GitFetcher extends Fetcher { this.resolved = this.spec.hosted ? repoUrl(this.spec.hosted, { noCommittish: false }) : this.spec.rawSpec - } else + } else { this.resolvedSha = '' + } } // just exposed to make it easier to test all the combinations @@ -67,8 +68,9 @@ class GitFetcher extends Fetcher { resolve () { // likely a hosted git repo with a sha, so get the tarball url // but in general, no reason to resolve() more than necessary! - if (this.resolved) + if (this.resolved) { return super.resolve() + } // fetch the git repo and then look at the current hash const h = this.spec.hosted @@ -86,37 +88,41 @@ class GitFetcher extends Fetcher { return this[_resolvedFromRepo](hosted.https && hosted.https()) .catch(er => { // Throw early since we know pathspec errors will fail again if retried - if (er instanceof git.errors.GitPathspecError) + if (er instanceof git.errors.GitPathspecError) { throw er + } const ssh = hosted.sshurl && hosted.sshurl() // no fallthrough if we can't fall through or have https auth - if (!ssh || hosted.auth) + if (!ssh || hosted.auth) { throw er + } return this[_resolvedFromRepo](ssh) }) } [_resolvedFromRepo] (gitRemote) { // XXX make this a custom error class - if (!gitRemote) + if (!gitRemote) { return Promise.reject(new Error(`No git url for ${this.spec}`)) + } const gitRange = this.spec.gitRange const name = this.spec.name return git.revs(gitRemote, this.opts).then(remoteRefs => { return gitRange ? pickManifest({ - versions: remoteRefs.versions, - 'dist-tags': remoteRefs['dist-tags'], - name, - }, gitRange, this.opts) + versions: remoteRefs.versions, + 'dist-tags': remoteRefs['dist-tags'], + name, + }, gitRange, this.opts) : this.spec.gitCommittish ? remoteRefs.refs[this.spec.gitCommittish] || remoteRefs.refs[remoteRefs.shas[this.spec.gitCommittish]] - : remoteRefs.refs.HEAD // no git committish, get default head + : remoteRefs.refs.HEAD // no git committish, get default head }).then(revDoc => { // the committish provided isn't in the rev list // things like HEAD~3 or @yesterday can land here. - if (!revDoc || !revDoc.sha) + if (!revDoc || !revDoc.sha) { return this[_resolvedFromClone]() + } this.resolvedRef = revDoc this.resolvedSha = revDoc.sha @@ -145,16 +151,18 @@ class GitFetcher extends Fetcher { } [_prepareDir] (dir) { - return readPackageJson(dir + '/package.json').then(mani => { + return this[_readPackageJson](dir + '/package.json').then(mani => { // no need if we aren't going to do any preparation. const scripts = mani.scripts - if (!scripts || !( - scripts.postinstall || + if (!mani.workspaces && (!scripts || !( + scripts.postinstall || scripts.build || scripts.preinstall || scripts.install || - scripts.prepare)) + scripts.prepack || + scripts.prepare))) { return + } // to avoid cases where we have an cycle of git deps that depend // on one another, we only ever do preparation for one instance @@ -166,7 +174,7 @@ class GitFetcher extends Fetcher { const noPrepare = !process.env._PACOTE_NO_PREPARE_ ? [] : process.env._PACOTE_NO_PREPARE_.split('\n') if (noPrepare.includes(this.resolved)) { - this.log.info('prepare', 'skip prepare, already seen', this.resolved) + log.info('prepare', 'skip prepare, already seen', this.resolved) return } noPrepare.push(this.resolved) @@ -202,9 +210,9 @@ class GitFetcher extends Fetcher { dirStream.on('end', res) dirStream.pipe(stream) }))).catch( - /* istanbul ignore next: very unlikely and hard to test */ - er => stream.emit('error', er) - ) + /* istanbul ignore next: very unlikely and hard to test */ + er => stream.emit('error', er) + ) return stream } @@ -237,10 +245,11 @@ class GitFetcher extends Fetcher { integrity: null, // it'll always be different, if we have one }).extract(tmp).then(() => handler(tmp), er => { // fall back to ssh download if tarball fails - if (er.constructor.name.match(/^Http/)) + if (er.constructor.name.match(/^Http/)) { return this[_clone](handler, false) - else + } else { throw er + } }) } @@ -249,10 +258,11 @@ class GitFetcher extends Fetcher { : this[_cloneRepo](this.spec.fetchSpec, ref, tmp) ).then(sha => { this.resolvedSha = sha - if (!this.resolved) + if (!this.resolved) { this[_addGitSha](sha) + } }) - .then(() => handler(tmp)) + .then(() => handler(tmp)) }) } @@ -266,12 +276,14 @@ class GitFetcher extends Fetcher { return this[_cloneRepo](hosted.https({ noCommittish: true }), ref, tmp) .catch(er => { // Throw early since we know pathspec errors will fail again if retried - if (er instanceof git.errors.GitPathspecError) + if (er instanceof git.errors.GitPathspecError) { throw er + } const ssh = hosted.sshurl && hosted.sshurl({ noCommittish: true }) // no fallthrough if we can't fall through or have https auth - if (!ssh || hosted.auth) + if (!ssh || hosted.auth) { throw er + } return this[_cloneRepo](ssh, ref, tmp) }) } @@ -282,19 +294,20 @@ class GitFetcher extends Fetcher { } manifest () { - if (this.package) + if (this.package) { return Promise.resolve(this.package) + } return this.spec.hosted && this.resolved ? FileFetcher.prototype.manifest.apply(this) : this[_clone](dir => - readPackageJson(dir + '/package.json') - .then(mani => this.package = { - ...mani, - _integrity: this.integrity && String(this.integrity), - _resolved: this.resolved, - _from: this.from, - })) + this[_readPackageJson](dir + '/package.json') + .then(mani => this.package = { + ...mani, + _integrity: this.integrity && String(this.integrity), + _resolved: this.resolved, + _from: this.from, + })) } packument () { diff --git a/node_modules/pacote/lib/registry.js b/node_modules/pacote/lib/registry.js index e0a310717420d..b4f890d310dfa 100644 --- a/node_modules/pacote/lib/registry.js +++ b/node_modules/pacote/lib/registry.js @@ -2,11 +2,11 @@ const Fetcher = require('./fetcher.js') const RemoteFetcher = require('./remote.js') const _tarballFromResolved = Symbol.for('pacote.Fetcher._tarballFromResolved') const pacoteVersion = require('../package.json').version +const removeTrailingSlashes = require('./util/trailing-slashes.js') const npa = require('npm-package-arg') const rpj = require('read-package-json-fast') const pickManifest = require('npm-pick-manifest') const ssri = require('ssri') -const Minipass = require('minipass') // Corgis are cute. 🐕🐶 const corgiDoc = 'application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*' @@ -32,10 +32,11 @@ class RegistryFetcher extends Fetcher { // handle case when npm-package-arg guesses wrong. if (this.spec.type === 'tag' && this.spec.rawSpec === '' && - this.defaultTag !== 'latest') + this.defaultTag !== 'latest') { this.spec = npa(`${this.spec.name}@${this.defaultTag}`) + } this.registry = fetch.pickRegistry(spec, opts) - this.packumentUrl = this.registry.replace(/\/*$/, '/') + + this.packumentUrl = removeTrailingSlashes(this.registry) + '/' + this.spec.escapedName // XXX pacote <=9 has some logic to ignore opts.resolved if @@ -45,13 +46,15 @@ class RegistryFetcher extends Fetcher { } resolve () { - if (this.resolved) + if (this.resolved) { return Promise.resolve(this.resolved) + } // fetching the manifest sets resolved and (usually) integrity return this.manifest().then(() => { - if (this.resolved) + if (this.resolved) { return this.resolved + } throw Object.assign( new Error('Invalid package manifest: no `dist.tarball` field'), @@ -77,8 +80,9 @@ class RegistryFetcher extends Fetcher { // note this might be either an in-flight promise for a request, // or the actual packument, but we never want to make more than // one request at a time for the same thing regardless. - if (this.packumentCache && this.packumentCache.has(this.packumentUrl)) + if (this.packumentCache && this.packumentCache.has(this.packumentUrl)) { return this.packumentCache.get(this.packumentUrl) + } // npm-registry-fetch the packument // set the appropriate header for corgis if fullMetadata isn't set @@ -92,12 +96,14 @@ class RegistryFetcher extends Fetcher { }).then(res => res.json().then(packument => { packument._cached = res.headers.has('x-local-cache') packument._contentLength = +res.headers.get('content-length') - if (this.packumentCache) + if (this.packumentCache) { this.packumentCache.set(this.packumentUrl, packument) + } return packument })).catch(er => { - if (this.packumentCache) + if (this.packumentCache) { this.packumentCache.delete(this.packumentUrl) + } if (er.code === 'E404' && !this.fullMetadata) { // possible that corgis are not supported by this registry this.fullMetadata = true @@ -105,14 +111,16 @@ class RegistryFetcher extends Fetcher { } throw er }) - if (this.packumentCache) + if (this.packumentCache) { this.packumentCache.set(this.packumentUrl, p) + } return p } manifest () { - if (this.package) + if (this.package) { return Promise.resolve(this.package) + } return this.packument() .then(packument => pickManifest(packument, this.spec.fetchSpec, { @@ -127,12 +135,12 @@ class RegistryFetcher extends Fetcher { this.resolved = mani._resolved = dist.tarball mani._from = this.from const distIntegrity = dist.integrity ? ssri.parse(dist.integrity) - : dist.shasum ? ssri.fromHex(dist.shasum, 'sha1', {...this.opts}) + : dist.shasum ? ssri.fromHex(dist.shasum, 'sha1', { ...this.opts }) : null if (distIntegrity) { - if (!this.integrity) + if (!this.integrity) { this.integrity = distIntegrity - else if (!this.integrity.match(distIntegrity)) { + } else if (!this.integrity.match(distIntegrity)) { // only bork if they have algos in common. // otherwise we end up breaking if we have saved a sha512 // previously for the tarball, but the manifest only @@ -143,7 +151,7 @@ class RegistryFetcher extends Fetcher { for (const algo of Object.keys(this.integrity)) { if (distIntegrity[algo]) { throw Object.assign(new Error( - `Integrity checksum failed when using ${algo}: `+ + `Integrity checksum failed when using ${algo}: ` + `wanted ${this.integrity} but got ${distIntegrity}.` ), { code: 'EINTEGRITY' }) } @@ -155,8 +163,9 @@ class RegistryFetcher extends Fetcher { } } } - if (this.integrity) + if (this.integrity) { mani._integrity = String(this.integrity) + } this.package = rpj.normalize(mani) return this.package }) diff --git a/node_modules/pacote/lib/remote.js b/node_modules/pacote/lib/remote.js index 727a8bfc8e608..5cabfe4fcda44 100644 --- a/node_modules/pacote/lib/remote.js +++ b/node_modules/pacote/lib/remote.js @@ -3,7 +3,6 @@ const FileFetcher = require('./file.js') const _tarballFromResolved = Symbol.for('pacote.Fetcher._tarballFromResolved') const pacoteVersion = require('../package.json').version const fetch = require('npm-registry-fetch') -const ssri = require('ssri') const Minipass = require('minipass') // The default registry URL is a string of great magic. const magic = /^https?:\/\/registry\.npmjs\.org\// @@ -14,8 +13,9 @@ class RemoteFetcher extends Fetcher { constructor (spec, opts) { super(spec, opts) this.resolved = this.spec.fetchSpec - if (magic.test(this.resolved) && !magic.test(this.registry + '/')) + if (magic.test(this.resolved) && !magic.test(this.registry + '/')) { this.resolved = this.resolved.replace(magic, this.registry + '/') + } // nam is a fermented pork sausage that is good to eat const nameat = this.spec.name ? `${this.spec.name}@` : '' @@ -35,7 +35,7 @@ class RemoteFetcher extends Fetcher { headers: this[_headers](), spec: this.spec, integrity: this.integrity, - algorithms: [ this.pickIntegrityAlgorithm() ], + algorithms: [this.pickIntegrityAlgorithm()], } fetch(this.resolved, fetchOpts).then(res => { const hash = res.headers.get('x-local-cache-hash') @@ -62,7 +62,7 @@ class RemoteFetcher extends Fetcher { 'pacote-req-type': 'tarball', 'pacote-pkg-id': this.pkgid, ...(this.integrity ? { 'pacote-integrity': String(this.integrity) } - : {}), + : {}), ...(this.opts.headers || {}), } } diff --git a/node_modules/pacote/lib/util/cache-dir.js b/node_modules/pacote/lib/util/cache-dir.js index abd2453232027..4236213edd409 100644 --- a/node_modules/pacote/lib/util/cache-dir.js +++ b/node_modules/pacote/lib/util/cache-dir.js @@ -1,5 +1,5 @@ const os = require('os') -const {resolve} = require('path') +const { resolve } = require('path') module.exports = (fakePlatform = false) => { const temp = os.tmpdir() diff --git a/node_modules/pacote/lib/util/is-package-bin.js b/node_modules/pacote/lib/util/is-package-bin.js index 35cf0642703c7..49a3f73f537ce 100644 --- a/node_modules/pacote/lib/util/is-package-bin.js +++ b/node_modules/pacote/lib/util/is-package-bin.js @@ -12,10 +12,11 @@ const binObj = (name, bin) => const hasBin = (pkg, path) => { const bin = binObj(pkg.name, pkg.bin) - const p = path.replace(/^[^\\\/]*\//, '') - for (const [k, v] of Object.entries(bin)) { - if (v === p) + const p = path.replace(/^[^\\/]*\//, '') + for (const kv of Object.entries(bin)) { + if (kv[1] === p) { return true + } } return false } diff --git a/node_modules/pacote/lib/util/npm.js b/node_modules/pacote/lib/util/npm.js index f2f29bd0acbd1..c444d788ad192 100644 --- a/node_modules/pacote/lib/util/npm.js +++ b/node_modules/pacote/lib/util/npm.js @@ -1,6 +1,5 @@ // run an npm command const spawn = require('@npmcli/promise-spawn') -const {dirname} = require('path') module.exports = (npmBin, npmCommand, cwd, env, extra) => { const isJS = npmBin.endsWith('.js') diff --git a/node_modules/pacote/lib/util/proc-log.js b/node_modules/pacote/lib/util/proc-log.js deleted file mode 100644 index b2bdd9dc90205..0000000000000 --- a/node_modules/pacote/lib/util/proc-log.js +++ /dev/null @@ -1,21 +0,0 @@ -// default logger. -// emits 'log' events on the process -const LEVELS = [ - 'notice', - 'error', - 'warn', - 'info', - 'verbose', - 'http', - 'silly', - 'pause', - 'resume' -] - -const log = level => (...args) => process.emit('log', level, ...args) - -const logger = {} -for (const level of LEVELS) { - logger[level] = log(level) -} -module.exports = logger diff --git a/node_modules/pacote/lib/util/tar-create-options.js b/node_modules/pacote/lib/util/tar-create-options.js index 31ab34c9d949f..d070f0f7ba2d4 100644 --- a/node_modules/pacote/lib/util/tar-create-options.js +++ b/node_modules/pacote/lib/util/tar-create-options.js @@ -9,7 +9,7 @@ const tarCreateOptions = manifest => ({ // platform specific optimizations that cause // integrity mismatch errors due to differing // end results after compression - level: 9 + level: 9, }, // ensure that package bins are always executable @@ -17,8 +17,9 @@ const tarCreateOptions = manifest => ({ // anything that is not a regular file, ignored by // .npmignore or package.json "files", etc. filter: (path, stat) => { - if (isPackageBin(manifest, path)) + if (isPackageBin(manifest, path)) { stat.mode |= 0o111 + } return true }, diff --git a/node_modules/pacote/lib/util/trailing-slashes.js b/node_modules/pacote/lib/util/trailing-slashes.js new file mode 100644 index 0000000000000..ff75dfd9c0fbc --- /dev/null +++ b/node_modules/pacote/lib/util/trailing-slashes.js @@ -0,0 +1,10 @@ +const removeTrailingSlashes = (input) => { + // in order to avoid regexp redos detection + let output = input + while (output.endsWith('/')) { + output = output.substr(0, output.length - 1) + } + return output +} + +module.exports = removeTrailingSlashes diff --git a/node_modules/pacote/package.json b/node_modules/pacote/package.json index ffbc067f68dee..7e1f07cafdcd3 100644 --- a/node_modules/pacote/package.json +++ b/node_modules/pacote/package.json @@ -1,8 +1,8 @@ { "name": "pacote", - "version": "12.0.3", + "version": "13.0.2", "description": "JavaScript package downloader", - "author": "Isaac Z. Schlueter (https://izs.me)", + "author": "GitHub Inc.", "bin": { "pacote": "lib/bin.js" }, @@ -13,19 +13,26 @@ "snap": "tap", "preversion": "npm test", "postversion": "npm publish", - "prepublishOnly": "git push origin --follow-tags" + "prepublishOnly": "git push origin --follow-tags", + "lint": "eslint '**/*.js'", + "postlint": "npm-template-check", + "lintfix": "npm run lint -- --fix", + "posttest": "npm run lint", + "template-copy": "npm-template-copy --force" }, "tap": { "timeout": 300, "coverage-map": "map.js" }, "devDependencies": { + "@npmcli/template-oss": "^2.7.1", "mutate-fs": "^2.1.1", "npm-registry-mock": "^1.3.1", - "tap": "^15.0.4" + "tap": "^15.1.6" }, "files": [ - "lib/**/*.js" + "bin", + "lib" ], "keywords": [ "packages", @@ -33,28 +40,34 @@ "git" ], "dependencies": { - "@npmcli/git": "^2.1.0", - "@npmcli/installed-package-contents": "^1.0.6", + "@npmcli/git": "^3.0.0", + "@npmcli/installed-package-contents": "^1.0.7", "@npmcli/promise-spawn": "^1.2.0", "@npmcli/run-script": "^2.0.0", - "cacache": "^15.0.5", + "cacache": "^15.3.0", "chownr": "^2.0.0", "fs-minipass": "^2.1.0", "infer-owner": "^1.0.4", - "minipass": "^3.1.3", - "mkdirp": "^1.0.3", - "npm-package-arg": "^8.0.1", + "minipass": "^3.1.6", + "mkdirp": "^1.0.4", + "npm-package-arg": "^9.0.0", "npm-packlist": "^3.0.0", - "npm-pick-manifest": "^6.0.0", - "npm-registry-fetch": "^12.0.0", + "npm-pick-manifest": "^7.0.0", + "npm-registry-fetch": "^13.0.0", + "proc-log": "^2.0.0", "promise-retry": "^2.0.1", - "read-package-json-fast": "^2.0.1", + "read-package-json": "^4.1.1", + "read-package-json-fast": "^2.0.3", "rimraf": "^3.0.2", "ssri": "^8.0.1", - "tar": "^6.1.0" + "tar": "^6.1.11" }, "engines": { "node": "^12.13.0 || ^14.15.0 || >=16" }, - "repository": "git@github.com:npm/pacote" + "repository": "git@github.com:npm/pacote", + "templateOSS": { + "version": "2.7.1", + "windowsCI": false + } } diff --git a/node_modules/proc-log/index.js b/node_modules/proc-log/lib/index.js similarity index 91% rename from node_modules/proc-log/index.js rename to node_modules/proc-log/lib/index.js index 9b58713ff3f85..7c5dfad3b7ba3 100644 --- a/node_modules/proc-log/index.js +++ b/node_modules/proc-log/lib/index.js @@ -14,8 +14,9 @@ const LEVELS = [ const log = level => (...args) => process.emit('log', level, ...args) const logger = {} -for (const level of LEVELS) +for (const level of LEVELS) { logger[level] = log(level) +} logger.LEVELS = LEVELS diff --git a/node_modules/proc-log/package.json b/node_modules/proc-log/package.json index 178009f61b8d2..17e9249b7ca46 100644 --- a/node_modules/proc-log/package.json +++ b/node_modules/proc-log/package.json @@ -1,28 +1,36 @@ { "name": "proc-log", - "version": "1.0.0", + "version": "2.0.0", "files": [ - "index.js" + "bin", + "lib" ], + "main": "lib/index.js", "description": "just emit 'log' events on the process object", "repository": "https://github.com/npm/proc-log", - "author": "Isaac Z. Schlueter (https://izs.me)", + "author": "GitHub Inc.", "license": "ISC", "scripts": { "test": "tap", "snap": "tap", - "posttest": "eslint index.js test/*.js", + "posttest": "npm run lint", "postsnap": "eslint index.js test/*.js --fix", "preversion": "npm test", "postversion": "npm publish", - "prepublishOnly": "git push origin --follow-tags" + "prepublishOnly": "git push origin --follow-tags", + "lint": "eslint '**/*.js'", + "postlint": "npm-template-check", + "template-copy": "npm-template-copy --force", + "lintfix": "npm run lint -- --fix" }, "devDependencies": { - "eslint": "^7.9.0", - "eslint-plugin-import": "^2.22.0", - "eslint-plugin-node": "^11.1.0", - "eslint-plugin-promise": "^4.2.1", - "eslint-plugin-standard": "^4.0.1", - "tap": "^15.0.2" + "@npmcli/template-oss": "^2.7.1", + "tap": "^15.1.6" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16" + }, + "templateOSS": { + "version": "2.7.1" } } diff --git a/package-lock.json b/package-lock.json index 25f28f9d6e9b3..69a9daa868a47 100644 --- a/package-lock.json +++ b/package-lock.json @@ -89,7 +89,7 @@ "@isaacs/string-locale-compare": "^1.1.0", "@npmcli/arborist": "^4.3.1", "@npmcli/ci-detect": "^2.0.0", - "@npmcli/config": "^3.0.0", + "@npmcli/config": "^4.0.0", "@npmcli/map-workspaces": "^2.0.0", "@npmcli/package-json": "^1.0.1", "@npmcli/run-script": "^2.0.0", @@ -108,7 +108,7 @@ "graceful-fs": "^4.2.9", "hosted-git-info": "^4.1.0", "ini": "^2.0.0", - "init-package-json": "^2.0.5", + "init-package-json": "^3.0.0", "is-cidr": "^4.0.2", "json-parse-even-better-errors": "^2.3.1", "libnpmaccess": "^5.0.1", @@ -132,16 +132,16 @@ "nopt": "^5.0.0", "npm-audit-report": "^2.1.5", "npm-install-checks": "^4.0.0", - "npm-package-arg": "^8.1.5", - "npm-pick-manifest": "^6.1.1", - "npm-profile": "^6.0.0", - "npm-registry-fetch": "^12.0.2", + "npm-package-arg": "^9.0.0", + "npm-pick-manifest": "^7.0.0", + "npm-profile": "^6.0.2", + "npm-registry-fetch": "^13.0.0", "npm-user-validate": "^1.0.1", "npmlog": "^6.0.1", "opener": "^1.5.2", - "pacote": "^12.0.3", + "pacote": "^13.0.2", "parse-conflict-json": "^2.0.1", - "proc-log": "^1.0.0", + "proc-log": "^2.0.0", "qrcode-terminal": "^0.12.0", "read": "~1.0.7", "read-package-json": "^4.1.1", @@ -815,17 +815,18 @@ } }, "node_modules/@npmcli/config": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/@npmcli/config/-/config-3.0.0.tgz", - "integrity": "sha512-2cYe2MCGintq1s6izbLYO2gAHZwNFQ92lIb5QhtpRizwHwqrV9v4+xNpvx1EBaEaqTHFR4QuozgZLA1scao/5Q==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@npmcli/config/-/config-4.0.0.tgz", + "integrity": "sha512-iywEsUhkA6GSgTS3vHLxHttU6lovSYt7wCGD0MOsjfd1YAUlz8243TXUKhcJiPfWvQYB4FnZkn30m3KmZS8GuA==", "inBundle": true, "dependencies": { "@npmcli/map-workspaces": "^2.0.0", "ini": "^2.0.0", "mkdirp-infer-owner": "^2.0.0", "nopt": "^5.0.0", + "proc-log": "^2.0.0", "read-package-json-fast": "^2.0.3", - "semver": "^7.3.4", + "semver": "^7.3.5", "walk-up-path": "^1.0.0" }, "engines": { @@ -876,19 +877,32 @@ } }, "node_modules/@npmcli/git": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/@npmcli/git/-/git-2.1.0.tgz", - "integrity": "sha512-/hBFX/QG1b+N7PZBFs0bi+evgRZcK9nWBxQKZkGoXUT5hJSwl5c4d7y8/hm+NQZRPhQ67RzFaj5UM9YeyKoryw==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@npmcli/git/-/git-3.0.0.tgz", + "integrity": "sha512-xfSBJ+KBMZWWqRHFbEgIaXG/LtELHrQZMJ72Gkb3yWdHysu/7+VGOs8ME0c3td7QNQX57Ggo3kYL6ylcd70/kA==", "inBundle": true, "dependencies": { "@npmcli/promise-spawn": "^1.3.2", - "lru-cache": "^6.0.0", + "lru-cache": "^7.3.1", "mkdirp": "^1.0.4", - "npm-pick-manifest": "^6.1.1", + "npm-pick-manifest": "^7.0.0", + "proc-log": "^2.0.0", "promise-inflight": "^1.0.1", "promise-retry": "^2.0.1", "semver": "^7.3.5", "which": "^2.0.2" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16" + } + }, + "node_modules/@npmcli/git/node_modules/lru-cache": { + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.3.1.tgz", + "integrity": "sha512-nX1x4qUrKqwbIAhv4s9et4FIUVzNOpeY07bsjGUy8gwJrXH/wScImSQqXErmo/b2jZY2r0mohbLA9zVj7u1cNw==", + "inBundle": true, + "engines": { + "node": ">=12" } }, "node_modules/@npmcli/installed-package-contents": { @@ -923,14 +937,14 @@ } }, "node_modules/@npmcli/metavuln-calculator": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@npmcli/metavuln-calculator/-/metavuln-calculator-2.0.0.tgz", - "integrity": "sha512-VVW+JhWCKRwCTE+0xvD6p3uV4WpqocNYYtzyvenqL/u1Q3Xx6fGTJ+6UoIoii07fbuEO9U3IIyuGY0CYHDv1sg==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@npmcli/metavuln-calculator/-/metavuln-calculator-3.0.0.tgz", + "integrity": "sha512-tIzAdW3DAvlyuQyYvy7WuDKaJs55LoXFAIyglZTrHsc9DGZWP1YVL7+8WFKqx+lHyHUEkfk02Dc8ie4JWtNO6w==", "dependencies": { - "cacache": "^15.0.5", + "cacache": "^15.3.0", "json-parse-even-better-errors": "^2.3.1", - "pacote": "^12.0.0", - "semver": "^7.3.2" + "pacote": "^13.0.1", + "semver": "^7.3.5" }, "engines": { "node": "^12.13.0 || ^14.15.0 || >=16" @@ -3947,21 +3961,21 @@ } }, "node_modules/init-package-json": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/init-package-json/-/init-package-json-2.0.5.tgz", - "integrity": "sha512-u1uGAtEFu3VA6HNl/yUWw57jmKEMx8SKOxHhxjGnOFUiIlFnohKDFg4ZrPpv9wWqk44nDxGJAtqjdQFm+9XXQA==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/init-package-json/-/init-package-json-3.0.0.tgz", + "integrity": "sha512-b0PZaZ3lF0mKsk7QcP03LhxXttVR0kb4XIafD1HXV4JIvLhifdvFgNyXr3qSA/3DZmiskFveLP1eXfXGFybG6g==", "inBundle": true, "dependencies": { - "npm-package-arg": "^8.1.5", + "npm-package-arg": "^9.0.0", "promzard": "^0.3.0", - "read": "~1.0.1", + "read": "^1.0.7", "read-package-json": "^4.1.1", "semver": "^7.3.5", "validate-npm-package-license": "^3.0.4", "validate-npm-package-name": "^3.0.0" }, "engines": { - "node": ">=10" + "node": "^12.13.0 || ^14.15.0 || >=16" } }, "node_modules/inline-style-parser": { @@ -5505,17 +5519,17 @@ "inBundle": true }, "node_modules/npm-package-arg": { - "version": "8.1.5", - "resolved": "https://registry.npmjs.org/npm-package-arg/-/npm-package-arg-8.1.5.tgz", - "integrity": "sha512-LhgZrg0n0VgvzVdSm1oiZworPbTxYHUJCgtsJW8mGvlDpxTM1vSJc3m5QZeUkhAHIzbz3VCHd/R4osi1L1Tg/Q==", + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/npm-package-arg/-/npm-package-arg-9.0.0.tgz", + "integrity": "sha512-yhzXxeor+Zfhe5MGwPdDumz6HtNlj2pMekWB95IX3CC6uDNgde0oPKHDCLDPoJqQfd0HqAWt+y4Hs5m7CK1+9Q==", "inBundle": true, "dependencies": { - "hosted-git-info": "^4.0.1", - "semver": "^7.3.4", + "hosted-git-info": "^4.1.0", + "semver": "^7.3.5", "validate-npm-package-name": "^3.0.0" }, "engines": { - "node": ">=10" + "node": "^12.13.0 || ^14.15.0 || >=16" } }, "node_modules/npm-packlist": { @@ -5537,41 +5551,46 @@ } }, "node_modules/npm-pick-manifest": { - "version": "6.1.1", - "resolved": "https://registry.npmjs.org/npm-pick-manifest/-/npm-pick-manifest-6.1.1.tgz", - "integrity": "sha512-dBsdBtORT84S8V8UTad1WlUyKIY9iMsAmqxHbLdeEeBNMLQDlDWWra3wYUx9EBEIiG/YwAy0XyNHDd2goAsfuA==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/npm-pick-manifest/-/npm-pick-manifest-7.0.0.tgz", + "integrity": "sha512-njM1AcdioFaKd0JSGtLO09YA1WRwctjGQJbnHGmKS+u+uwP8oFvtZtOQWPYdxrnY5eJud3wn8OpH4sEIx6+GEQ==", "inBundle": true, "dependencies": { "npm-install-checks": "^4.0.0", "npm-normalize-package-bin": "^1.0.1", - "npm-package-arg": "^8.1.2", - "semver": "^7.3.4" + "npm-package-arg": "^9.0.0", + "semver": "^7.3.5" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16" } }, "node_modules/npm-profile": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/npm-profile/-/npm-profile-6.0.0.tgz", - "integrity": "sha512-ZiwXx3Fq3wNqJMz+d4AVZ9X4xAw/0TqsvdiyDF5Y+h9lQ7AjYDOxY06lj7AP5vUBqB/7k/0oNFQOx03Ay0iHPw==", + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/npm-profile/-/npm-profile-6.0.2.tgz", + "integrity": "sha512-0Fq8l+A10YXnnS63E3HThWjOb7+19Wsh1nOVutC2fKuowar8t/5PpINsbcm5xQ2dA28uAu+wjFfUyiEVSMz4Jw==", "inBundle": true, "dependencies": { - "npm-registry-fetch": "^12.0.0" + "npm-registry-fetch": "^13.0.0", + "proc-log": "^2.0.0" }, "engines": { "node": "^12.13.0 || ^14.15.0 || >=16" } }, "node_modules/npm-registry-fetch": { - "version": "12.0.2", - "resolved": "https://registry.npmjs.org/npm-registry-fetch/-/npm-registry-fetch-12.0.2.tgz", - "integrity": "sha512-Df5QT3RaJnXYuOwtXBXS9BWs+tHH2olvkCLh6jcR/b/u3DvPMlp3J0TvvYwplPKxHMOwfg287PYih9QqaVFoKA==", + "version": "13.0.0", + "resolved": "https://registry.npmjs.org/npm-registry-fetch/-/npm-registry-fetch-13.0.0.tgz", + "integrity": "sha512-MmiMuV9DU5gRuAU0jia952Qq+E4h7ZoUaeltCXivhClcqfOVKqNLZEQsRUOb6a8WQY+um8x97JcUuaWFoPoBBw==", "inBundle": true, "dependencies": { - "make-fetch-happen": "^10.0.1", + "make-fetch-happen": "^10.0.2", "minipass": "^3.1.6", "minipass-fetch": "^1.4.1", "minipass-json-stream": "^1.0.1", "minizlib": "^2.1.2", - "npm-package-arg": "^8.1.5" + "npm-package-arg": "^9.0.0", + "proc-log": "^2.0.0" }, "engines": { "node": "^12.13.0 || ^14.15.0 || >=16" @@ -5922,30 +5941,32 @@ } }, "node_modules/pacote": { - "version": "12.0.3", - "resolved": "https://registry.npmjs.org/pacote/-/pacote-12.0.3.tgz", - "integrity": "sha512-CdYEl03JDrRO3x18uHjBYA9TyoW8gy+ThVcypcDkxPtKlw76e4ejhYB6i9lJ+/cebbjpqPW/CijjqxwDTts8Ow==", + "version": "13.0.2", + "resolved": "https://registry.npmjs.org/pacote/-/pacote-13.0.2.tgz", + "integrity": "sha512-3LyfvDk2BSJNFQZIcDqnLNa7IsYb6KwX3H9uZPwaHJFIX6Gv5N9QHU+s7mEs/RbN4/ta6KUT39LAi2l6EkBi5A==", "inBundle": true, "dependencies": { - "@npmcli/git": "^2.1.0", - "@npmcli/installed-package-contents": "^1.0.6", + "@npmcli/git": "^3.0.0", + "@npmcli/installed-package-contents": "^1.0.7", "@npmcli/promise-spawn": "^1.2.0", "@npmcli/run-script": "^2.0.0", - "cacache": "^15.0.5", + "cacache": "^15.3.0", "chownr": "^2.0.0", "fs-minipass": "^2.1.0", "infer-owner": "^1.0.4", - "minipass": "^3.1.3", - "mkdirp": "^1.0.3", - "npm-package-arg": "^8.0.1", + "minipass": "^3.1.6", + "mkdirp": "^1.0.4", + "npm-package-arg": "^9.0.0", "npm-packlist": "^3.0.0", - "npm-pick-manifest": "^6.0.0", - "npm-registry-fetch": "^12.0.0", + "npm-pick-manifest": "^7.0.0", + "npm-registry-fetch": "^13.0.0", + "proc-log": "^2.0.0", "promise-retry": "^2.0.1", - "read-package-json-fast": "^2.0.1", + "read-package-json": "^4.1.1", + "read-package-json-fast": "^2.0.3", "rimraf": "^3.0.2", "ssri": "^8.0.1", - "tar": "^6.1.0" + "tar": "^6.1.11" }, "bin": { "pacote": "lib/bin.js" @@ -6213,10 +6234,13 @@ } }, "node_modules/proc-log": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/proc-log/-/proc-log-1.0.0.tgz", - "integrity": "sha512-aCk8AO51s+4JyuYGg3Q/a6gnrlDO09NpVWePtjp7xwphcoQ04x5WAfCyugcsbLooWcMJ87CLkD4+604IckEdhg==", - "inBundle": true + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/proc-log/-/proc-log-2.0.0.tgz", + "integrity": "sha512-I/35MfCX2H8jBUhKN8JB8nmqvQo/nKdrBodBY7L3RhDSPPyvOHwLYNmPuhwuJq7a7C3vgFKWGQM+ecPStcvOHA==", + "inBundle": true, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16" + } }, "node_modules/process-nextick-args": { "version": "2.0.1", @@ -10397,7 +10421,7 @@ "@isaacs/string-locale-compare": "^1.1.0", "@npmcli/installed-package-contents": "^1.0.7", "@npmcli/map-workspaces": "^2.0.0", - "@npmcli/metavuln-calculator": "^2.0.0", + "@npmcli/metavuln-calculator": "^3.0.0", "@npmcli/move-file": "^1.1.0", "@npmcli/name-from-folder": "^1.0.1", "@npmcli/node-gyp": "^1.0.3", @@ -10411,12 +10435,13 @@ "mkdirp": "^1.0.4", "mkdirp-infer-owner": "^2.0.0", "npm-install-checks": "^4.0.0", - "npm-package-arg": "^8.1.5", - "npm-pick-manifest": "^6.1.0", - "npm-registry-fetch": "^12.0.1", - "pacote": "^12.0.2", + "npm-package-arg": "^9.0.0", + "npm-pick-manifest": "^7.0.0", + "npm-registry-fetch": "^13.0.0", + "npmlog": "^6.0.1", + "pacote": "^13.0.2", "parse-conflict-json": "^2.0.1", - "proc-log": "^1.0.0", + "proc-log": "^2.0.0", "promise-all-reject-late": "^1.0.0", "promise-call-limit": "^1.0.1", "read-package-json-fast": "^2.0.2", @@ -10464,8 +10489,8 @@ "dependencies": { "aproba": "^2.0.0", "minipass": "^3.1.1", - "npm-package-arg": "^8.1.2", - "npm-registry-fetch": "^12.0.1" + "npm-package-arg": "^9.0.0", + "npm-registry-fetch": "^13.0.0" }, "devDependencies": { "@npmcli/template-oss": "^2.4.2", @@ -10485,8 +10510,8 @@ "binary-extensions": "^2.2.0", "diff": "^5.0.0", "minimatch": "^3.0.4", - "npm-package-arg": "^8.1.4", - "pacote": "^12.0.0", + "npm-package-arg": "^9.0.0", + "pacote": "^13.0.2", "tar": "^6.1.0" }, "devDependencies": { @@ -10507,9 +10532,10 @@ "@npmcli/run-script": "^2.0.0", "chalk": "^4.1.0", "mkdirp-infer-owner": "^2.0.0", - "npm-package-arg": "^8.1.2", - "pacote": "^12.0.0", - "proc-log": "^1.0.0", + "npm-package-arg": "^9.0.0", + "npmlog": "^6.0.1", + "pacote": "^13.0.2", + "proc-log": "^2.0.0", "read": "^1.0.7", "read-package-json-fast": "^2.0.2", "walk-up-path": "^1.0.0" @@ -10542,7 +10568,7 @@ "license": "ISC", "dependencies": { "aproba": "^2.0.0", - "npm-registry-fetch": "^12.0.1" + "npm-registry-fetch": "^13.0.0" }, "devDependencies": { "@npmcli/template-oss": "^2.4.2", @@ -10617,7 +10643,7 @@ "license": "ISC", "dependencies": { "aproba": "^2.0.0", - "npm-registry-fetch": "^12.0.1" + "npm-registry-fetch": "^13.0.0" }, "devDependencies": { "@npmcli/template-oss": "^2.4.2", @@ -10634,8 +10660,8 @@ "license": "ISC", "dependencies": { "@npmcli/run-script": "^2.0.0", - "npm-package-arg": "^8.1.0", - "pacote": "^12.0.0" + "npm-package-arg": "^9.0.0", + "pacote": "^13.0.2" }, "devDependencies": { "@npmcli/template-oss": "^2.4.2", @@ -10666,8 +10692,8 @@ "license": "ISC", "dependencies": { "normalize-package-data": "^3.0.2", - "npm-package-arg": "^8.1.2", - "npm-registry-fetch": "^12.0.1", + "npm-package-arg": "^9.0.0", + "npm-registry-fetch": "^13.0.0", "semver": "^7.1.3", "ssri": "^8.0.1" }, @@ -10686,7 +10712,7 @@ "version": "4.0.1", "license": "ISC", "dependencies": { - "npm-registry-fetch": "^12.0.1" + "npm-registry-fetch": "^13.0.0" }, "devDependencies": { "@npmcli/template-oss": "^2.4.2", @@ -10761,7 +10787,7 @@ "license": "ISC", "dependencies": { "aproba": "^2.0.0", - "npm-registry-fetch": "^12.0.1" + "npm-registry-fetch": "^13.0.0" }, "devDependencies": { "@npmcli/template-oss": "^2.4.2", @@ -10776,9 +10802,10 @@ "version": "2.0.2", "license": "ISC", "dependencies": { - "@npmcli/git": "^2.0.7", + "@npmcli/git": "^3.0.0", "@npmcli/run-script": "^2.0.0", "json-parse-even-better-errors": "^2.3.1", + "proc-log": "^2.0.0", "semver": "^7.3.5", "stringify-package": "^1.0.1" }, @@ -11308,7 +11335,7 @@ "@isaacs/string-locale-compare": "^1.1.0", "@npmcli/installed-package-contents": "^1.0.7", "@npmcli/map-workspaces": "^2.0.0", - "@npmcli/metavuln-calculator": "^2.0.0", + "@npmcli/metavuln-calculator": "^3.0.0", "@npmcli/move-file": "^1.1.0", "@npmcli/name-from-folder": "^1.0.1", "@npmcli/node-gyp": "^1.0.3", @@ -11327,12 +11354,13 @@ "mkdirp-infer-owner": "^2.0.0", "nock": "^13.2.0", "npm-install-checks": "^4.0.0", - "npm-package-arg": "^8.1.5", - "npm-pick-manifest": "^6.1.0", - "npm-registry-fetch": "^12.0.1", - "pacote": "^12.0.2", + "npm-package-arg": "^9.0.0", + "npm-pick-manifest": "^7.0.0", + "npm-registry-fetch": "^13.0.0", + "npmlog": "^6.0.1", + "pacote": "^13.0.2", "parse-conflict-json": "^2.0.1", - "proc-log": "^1.0.0", + "proc-log": "^2.0.0", "promise-all-reject-late": "^1.0.0", "promise-call-limit": "^1.0.1", "read-package-json-fast": "^2.0.2", @@ -11366,16 +11394,17 @@ "integrity": "sha512-8yQtQ9ArHh/TzdUDKQwEvwCgpDuhSWTDAbiKMl3854PcT+Dk4UmWaiawuFTLy9n5twzXOBXVflWe+90/ffXQrA==" }, "@npmcli/config": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/@npmcli/config/-/config-3.0.0.tgz", - "integrity": "sha512-2cYe2MCGintq1s6izbLYO2gAHZwNFQ92lIb5QhtpRizwHwqrV9v4+xNpvx1EBaEaqTHFR4QuozgZLA1scao/5Q==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@npmcli/config/-/config-4.0.0.tgz", + "integrity": "sha512-iywEsUhkA6GSgTS3vHLxHttU6lovSYt7wCGD0MOsjfd1YAUlz8243TXUKhcJiPfWvQYB4FnZkn30m3KmZS8GuA==", "requires": { "@npmcli/map-workspaces": "^2.0.0", "ini": "^2.0.0", "mkdirp-infer-owner": "^2.0.0", "nopt": "^5.0.0", + "proc-log": "^2.0.0", "read-package-json-fast": "^2.0.3", - "semver": "^7.3.4", + "semver": "^7.3.5", "walk-up-path": "^1.0.0" } }, @@ -11406,18 +11435,26 @@ } }, "@npmcli/git": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/@npmcli/git/-/git-2.1.0.tgz", - "integrity": "sha512-/hBFX/QG1b+N7PZBFs0bi+evgRZcK9nWBxQKZkGoXUT5hJSwl5c4d7y8/hm+NQZRPhQ67RzFaj5UM9YeyKoryw==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@npmcli/git/-/git-3.0.0.tgz", + "integrity": "sha512-xfSBJ+KBMZWWqRHFbEgIaXG/LtELHrQZMJ72Gkb3yWdHysu/7+VGOs8ME0c3td7QNQX57Ggo3kYL6ylcd70/kA==", "requires": { "@npmcli/promise-spawn": "^1.3.2", - "lru-cache": "^6.0.0", + "lru-cache": "^7.3.1", "mkdirp": "^1.0.4", - "npm-pick-manifest": "^6.1.1", + "npm-pick-manifest": "^7.0.0", + "proc-log": "^2.0.0", "promise-inflight": "^1.0.1", "promise-retry": "^2.0.1", "semver": "^7.3.5", "which": "^2.0.2" + }, + "dependencies": { + "lru-cache": { + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.3.1.tgz", + "integrity": "sha512-nX1x4qUrKqwbIAhv4s9et4FIUVzNOpeY07bsjGUy8gwJrXH/wScImSQqXErmo/b2jZY2r0mohbLA9zVj7u1cNw==" + } } }, "@npmcli/installed-package-contents": { @@ -11441,14 +11478,14 @@ } }, "@npmcli/metavuln-calculator": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@npmcli/metavuln-calculator/-/metavuln-calculator-2.0.0.tgz", - "integrity": "sha512-VVW+JhWCKRwCTE+0xvD6p3uV4WpqocNYYtzyvenqL/u1Q3Xx6fGTJ+6UoIoii07fbuEO9U3IIyuGY0CYHDv1sg==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@npmcli/metavuln-calculator/-/metavuln-calculator-3.0.0.tgz", + "integrity": "sha512-tIzAdW3DAvlyuQyYvy7WuDKaJs55LoXFAIyglZTrHsc9DGZWP1YVL7+8WFKqx+lHyHUEkfk02Dc8ie4JWtNO6w==", "requires": { - "cacache": "^15.0.5", + "cacache": "^15.3.0", "json-parse-even-better-errors": "^2.3.1", - "pacote": "^12.0.0", - "semver": "^7.3.2" + "pacote": "^13.0.1", + "semver": "^7.3.5" } }, "@npmcli/move-file": { @@ -13686,13 +13723,13 @@ "integrity": "sha512-7PnF4oN3CvZF23ADhA5wRaYEQpJ8qygSkbtTXWBeXWXmEVRXK+1ITciHWwHhsjv1TmW0MgacIv6hEi5pX5NQdA==" }, "init-package-json": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/init-package-json/-/init-package-json-2.0.5.tgz", - "integrity": "sha512-u1uGAtEFu3VA6HNl/yUWw57jmKEMx8SKOxHhxjGnOFUiIlFnohKDFg4ZrPpv9wWqk44nDxGJAtqjdQFm+9XXQA==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/init-package-json/-/init-package-json-3.0.0.tgz", + "integrity": "sha512-b0PZaZ3lF0mKsk7QcP03LhxXttVR0kb4XIafD1HXV4JIvLhifdvFgNyXr3qSA/3DZmiskFveLP1eXfXGFybG6g==", "requires": { - "npm-package-arg": "^8.1.5", + "npm-package-arg": "^9.0.0", "promzard": "^0.3.0", - "read": "~1.0.1", + "read": "^1.0.7", "read-package-json": "^4.1.1", "semver": "^7.3.5", "validate-npm-package-license": "^3.0.4", @@ -14246,8 +14283,8 @@ "aproba": "^2.0.0", "minipass": "^3.1.1", "nock": "^12.0.1", - "npm-package-arg": "^8.1.2", - "npm-registry-fetch": "^12.0.1", + "npm-package-arg": "^9.0.0", + "npm-registry-fetch": "^13.0.0", "tap": "^15.1.0" } }, @@ -14261,8 +14298,8 @@ "diff": "^5.0.0", "eslint": "^8.1.0", "minimatch": "^3.0.4", - "npm-package-arg": "^8.1.4", - "pacote": "^12.0.0", + "npm-package-arg": "^9.0.0", + "pacote": "^13.0.2", "tap": "^15.0.9", "tar": "^6.1.0" } @@ -14277,9 +14314,10 @@ "bin-links": "^3.0.0", "chalk": "^4.1.0", "mkdirp-infer-owner": "^2.0.0", - "npm-package-arg": "^8.1.2", - "pacote": "^12.0.0", - "proc-log": "^1.0.0", + "npm-package-arg": "^9.0.0", + "npmlog": "^6.0.1", + "pacote": "^13.0.2", + "proc-log": "^2.0.0", "read": "^1.0.7", "read-package-json-fast": "^2.0.2", "tap": "^15.0.6", @@ -14300,7 +14338,7 @@ "@npmcli/template-oss": "^2.4.2", "aproba": "^2.0.0", "nock": "^9.6.1", - "npm-registry-fetch": "^12.0.1", + "npm-registry-fetch": "^13.0.0", "tap": "^15.1.0" }, "dependencies": { @@ -14360,7 +14398,7 @@ "aproba": "^2.0.0", "minipass": "^3.1.1", "nock": "^12.0.1", - "npm-registry-fetch": "^12.0.1", + "npm-registry-fetch": "^13.0.0", "tap": "^15.0.0" } }, @@ -14370,8 +14408,8 @@ "@npmcli/run-script": "^2.0.0", "@npmcli/template-oss": "^2.4.2", "nock": "^13.0.7", - "npm-package-arg": "^8.1.0", - "pacote": "^12.0.0", + "npm-package-arg": "^9.0.0", + "pacote": "^13.0.2", "tap": "^15.0.0" }, "dependencies": { @@ -14397,8 +14435,8 @@ "lodash.clonedeep": "^4.5.0", "nock": "^12.0.2", "normalize-package-data": "^3.0.2", - "npm-package-arg": "^8.1.2", - "npm-registry-fetch": "^12.0.1", + "npm-package-arg": "^9.0.0", + "npm-registry-fetch": "^13.0.0", "semver": "^7.1.3", "ssri": "^8.0.1", "tap": "^15" @@ -14409,7 +14447,7 @@ "requires": { "@npmcli/template-oss": "^2.4.2", "nock": "^9.6.1", - "npm-registry-fetch": "^12.0.1", + "npm-registry-fetch": "^13.0.0", "tap": "^15" }, "dependencies": { @@ -14468,17 +14506,18 @@ "@npmcli/template-oss": "^2.4.2", "aproba": "^2.0.0", "nock": "^12.0.1", - "npm-registry-fetch": "^12.0.1", + "npm-registry-fetch": "^13.0.0", "tap": "^15" } }, "libnpmversion": { "version": "file:workspaces/libnpmversion", "requires": { - "@npmcli/git": "^2.0.7", + "@npmcli/git": "^3.0.0", "@npmcli/run-script": "^2.0.0", "@npmcli/template-oss": "^2.4.2", "json-parse-even-better-errors": "^2.3.1", + "proc-log": "^2.0.0", "require-inject": "^1.4.4", "semver": "^7.3.5", "stringify-package": "^1.0.1", @@ -15045,12 +15084,12 @@ "integrity": "sha512-EPfafl6JL5/rU+ot6P3gRSCpPDW5VmIzX959Ob1+ySFUuuYHWHekXpwdUZcKP5C+DS4GEtdJluwBjnsNDl+fSA==" }, "npm-package-arg": { - "version": "8.1.5", - "resolved": "https://registry.npmjs.org/npm-package-arg/-/npm-package-arg-8.1.5.tgz", - "integrity": "sha512-LhgZrg0n0VgvzVdSm1oiZworPbTxYHUJCgtsJW8mGvlDpxTM1vSJc3m5QZeUkhAHIzbz3VCHd/R4osi1L1Tg/Q==", + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/npm-package-arg/-/npm-package-arg-9.0.0.tgz", + "integrity": "sha512-yhzXxeor+Zfhe5MGwPdDumz6HtNlj2pMekWB95IX3CC6uDNgde0oPKHDCLDPoJqQfd0HqAWt+y4Hs5m7CK1+9Q==", "requires": { - "hosted-git-info": "^4.0.1", - "semver": "^7.3.4", + "hosted-git-info": "^4.1.0", + "semver": "^7.3.5", "validate-npm-package-name": "^3.0.0" } }, @@ -15066,35 +15105,37 @@ } }, "npm-pick-manifest": { - "version": "6.1.1", - "resolved": "https://registry.npmjs.org/npm-pick-manifest/-/npm-pick-manifest-6.1.1.tgz", - "integrity": "sha512-dBsdBtORT84S8V8UTad1WlUyKIY9iMsAmqxHbLdeEeBNMLQDlDWWra3wYUx9EBEIiG/YwAy0XyNHDd2goAsfuA==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/npm-pick-manifest/-/npm-pick-manifest-7.0.0.tgz", + "integrity": "sha512-njM1AcdioFaKd0JSGtLO09YA1WRwctjGQJbnHGmKS+u+uwP8oFvtZtOQWPYdxrnY5eJud3wn8OpH4sEIx6+GEQ==", "requires": { "npm-install-checks": "^4.0.0", "npm-normalize-package-bin": "^1.0.1", - "npm-package-arg": "^8.1.2", - "semver": "^7.3.4" + "npm-package-arg": "^9.0.0", + "semver": "^7.3.5" } }, "npm-profile": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/npm-profile/-/npm-profile-6.0.0.tgz", - "integrity": "sha512-ZiwXx3Fq3wNqJMz+d4AVZ9X4xAw/0TqsvdiyDF5Y+h9lQ7AjYDOxY06lj7AP5vUBqB/7k/0oNFQOx03Ay0iHPw==", + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/npm-profile/-/npm-profile-6.0.2.tgz", + "integrity": "sha512-0Fq8l+A10YXnnS63E3HThWjOb7+19Wsh1nOVutC2fKuowar8t/5PpINsbcm5xQ2dA28uAu+wjFfUyiEVSMz4Jw==", "requires": { - "npm-registry-fetch": "^12.0.0" + "npm-registry-fetch": "^13.0.0", + "proc-log": "^2.0.0" } }, "npm-registry-fetch": { - "version": "12.0.2", - "resolved": "https://registry.npmjs.org/npm-registry-fetch/-/npm-registry-fetch-12.0.2.tgz", - "integrity": "sha512-Df5QT3RaJnXYuOwtXBXS9BWs+tHH2olvkCLh6jcR/b/u3DvPMlp3J0TvvYwplPKxHMOwfg287PYih9QqaVFoKA==", + "version": "13.0.0", + "resolved": "https://registry.npmjs.org/npm-registry-fetch/-/npm-registry-fetch-13.0.0.tgz", + "integrity": "sha512-MmiMuV9DU5gRuAU0jia952Qq+E4h7ZoUaeltCXivhClcqfOVKqNLZEQsRUOb6a8WQY+um8x97JcUuaWFoPoBBw==", "requires": { - "make-fetch-happen": "^10.0.1", + "make-fetch-happen": "^10.0.2", "minipass": "^3.1.6", "minipass-fetch": "^1.4.1", "minipass-json-stream": "^1.0.1", "minizlib": "^2.1.2", - "npm-package-arg": "^8.1.5" + "npm-package-arg": "^9.0.0", + "proc-log": "^2.0.0" } }, "npm-user-validate": { @@ -15352,29 +15393,31 @@ } }, "pacote": { - "version": "12.0.3", - "resolved": "https://registry.npmjs.org/pacote/-/pacote-12.0.3.tgz", - "integrity": "sha512-CdYEl03JDrRO3x18uHjBYA9TyoW8gy+ThVcypcDkxPtKlw76e4ejhYB6i9lJ+/cebbjpqPW/CijjqxwDTts8Ow==", + "version": "13.0.2", + "resolved": "https://registry.npmjs.org/pacote/-/pacote-13.0.2.tgz", + "integrity": "sha512-3LyfvDk2BSJNFQZIcDqnLNa7IsYb6KwX3H9uZPwaHJFIX6Gv5N9QHU+s7mEs/RbN4/ta6KUT39LAi2l6EkBi5A==", "requires": { - "@npmcli/git": "^2.1.0", - "@npmcli/installed-package-contents": "^1.0.6", + "@npmcli/git": "^3.0.0", + "@npmcli/installed-package-contents": "^1.0.7", "@npmcli/promise-spawn": "^1.2.0", "@npmcli/run-script": "^2.0.0", - "cacache": "^15.0.5", + "cacache": "^15.3.0", "chownr": "^2.0.0", "fs-minipass": "^2.1.0", "infer-owner": "^1.0.4", - "minipass": "^3.1.3", - "mkdirp": "^1.0.3", - "npm-package-arg": "^8.0.1", + "minipass": "^3.1.6", + "mkdirp": "^1.0.4", + "npm-package-arg": "^9.0.0", "npm-packlist": "^3.0.0", - "npm-pick-manifest": "^6.0.0", - "npm-registry-fetch": "^12.0.0", + "npm-pick-manifest": "^7.0.0", + "npm-registry-fetch": "^13.0.0", + "proc-log": "^2.0.0", "promise-retry": "^2.0.1", - "read-package-json-fast": "^2.0.1", + "read-package-json": "^4.1.1", + "read-package-json-fast": "^2.0.3", "rimraf": "^3.0.2", "ssri": "^8.0.1", - "tar": "^6.1.0" + "tar": "^6.1.11" } }, "parent-module": { @@ -15593,9 +15636,9 @@ "dev": true }, "proc-log": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/proc-log/-/proc-log-1.0.0.tgz", - "integrity": "sha512-aCk8AO51s+4JyuYGg3Q/a6gnrlDO09NpVWePtjp7xwphcoQ04x5WAfCyugcsbLooWcMJ87CLkD4+604IckEdhg==" + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/proc-log/-/proc-log-2.0.0.tgz", + "integrity": "sha512-I/35MfCX2H8jBUhKN8JB8nmqvQo/nKdrBodBY7L3RhDSPPyvOHwLYNmPuhwuJq7a7C3vgFKWGQM+ecPStcvOHA==" }, "process-nextick-args": { "version": "2.0.1", diff --git a/package.json b/package.json index 519fb22f13e4e..7adc07622e961 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "@isaacs/string-locale-compare": "^1.1.0", "@npmcli/arborist": "^4.3.1", "@npmcli/ci-detect": "^2.0.0", - "@npmcli/config": "^3.0.0", + "@npmcli/config": "^4.0.0", "@npmcli/map-workspaces": "^2.0.0", "@npmcli/package-json": "^1.0.1", "@npmcli/run-script": "^2.0.0", @@ -76,7 +76,7 @@ "graceful-fs": "^4.2.9", "hosted-git-info": "^4.1.0", "ini": "^2.0.0", - "init-package-json": "^2.0.5", + "init-package-json": "^3.0.0", "is-cidr": "^4.0.2", "json-parse-even-better-errors": "^2.3.1", "libnpmaccess": "^5.0.1", @@ -100,16 +100,16 @@ "nopt": "^5.0.0", "npm-audit-report": "^2.1.5", "npm-install-checks": "^4.0.0", - "npm-package-arg": "^8.1.5", - "npm-pick-manifest": "^6.1.1", - "npm-profile": "^6.0.0", - "npm-registry-fetch": "^12.0.2", + "npm-package-arg": "^9.0.0", + "npm-pick-manifest": "^7.0.0", + "npm-profile": "^6.0.2", + "npm-registry-fetch": "^13.0.0", "npm-user-validate": "^1.0.1", "npmlog": "^6.0.1", "opener": "^1.5.2", - "pacote": "^12.0.3", + "pacote": "^13.0.2", "parse-conflict-json": "^2.0.1", - "proc-log": "^1.0.0", + "proc-log": "^2.0.0", "qrcode-terminal": "^0.12.0", "read": "~1.0.7", "read-package-json": "^4.1.1", From 64d451c80d3385aba0f0a89736368318f2389500 Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Wed, 16 Feb 2022 18:54:12 -0700 Subject: [PATCH 22/43] feat(libnpmpack): use silent boolean instead of log.level BREAKING CHANGE: this drops support for the `log` property and the banner is shown using the silent option --- workspaces/libnpmpack/lib/index.js | 2 +- workspaces/libnpmpack/test/index.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/workspaces/libnpmpack/lib/index.js b/workspaces/libnpmpack/lib/index.js index a2c95cf938dcf..dc9cfd2c4e781 100644 --- a/workspaces/libnpmpack/lib/index.js +++ b/workspaces/libnpmpack/lib/index.js @@ -16,7 +16,7 @@ async function pack (spec = 'file:.', opts = {}) { // Default to true if no log options passed, set to false if we're in silent // mode - const banner = !opts.log || (opts.log.level !== 'silent') + const banner = !opts.silent if (spec.type === 'directory') { // prepack diff --git a/workspaces/libnpmpack/test/index.js b/workspaces/libnpmpack/test/index.js index 5f25f416655fd..b8007efe0b69e 100644 --- a/workspaces/libnpmpack/test/index.js +++ b/workspaces/libnpmpack/test/index.js @@ -49,7 +49,7 @@ t.test('writes tarball to file when dryRun === false', async t => { const tarball = await pack('file:.', { dryRun: false, packDestination: testDir, - log: { level: 'silent' }, // so the test doesn't try to log + silent: true, }) t.ok(tarball) const expectedTarball = path.join(testDir, 'my-cool-pkg-1.0.0.tgz') @@ -68,7 +68,7 @@ t.test('writes tarball to file when dryRun === false', async t => { }) }) -t.test('packs from local directory with silent loglevel', async t => { +t.test('packs from local directory with silent', async t => { const testDir = t.testdir({ 'package.json': JSON.stringify({ name: 'my-cool-pkg', @@ -79,7 +79,7 @@ t.test('packs from local directory with silent loglevel', async t => { const cwd = process.cwd() process.chdir(testDir) - const tarball = await pack('file:', { log: { level: 'silent' } }) + const tarball = await pack('file:', { silent: true }) t.ok(tarball) t.teardown(async () => { From eef16c18aacfbfed8bcfc72407d2a1b0c5ea00bc Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Mon, 21 Feb 2022 14:16:44 -0700 Subject: [PATCH 23/43] chore(arborist): remove log option BREAKING CHANGE: this drops support for the `log` property --- workspaces/arborist/lib/add-rm-pkg-deps.js | 23 ++++++------ .../arborist/lib/arborist/build-ideal-tree.js | 22 ++++++------ workspaces/arborist/lib/arborist/index.js | 4 +-- workspaces/arborist/lib/arborist/rebuild.js | 7 ++-- workspaces/arborist/lib/arborist/reify.js | 19 +++++----- workspaces/arborist/lib/audit-report.js | 13 ++++--- .../arborist/lib/get-workspace-nodes.js | 5 ++- workspaces/arborist/lib/shrinkwrap.js | 8 ++--- workspaces/arborist/lib/tracker.js | 23 ++++-------- workspaces/arborist/test/add-rm-pkg-deps.js | 9 ++--- workspaces/arborist/test/arborist/reify.js | 1 + .../arborist/test/get-workspace-nodes.js | 10 +++--- workspaces/arborist/test/tracker.js | 35 +++++++------------ 13 files changed, 80 insertions(+), 99 deletions(-) diff --git a/workspaces/arborist/lib/add-rm-pkg-deps.js b/workspaces/arborist/lib/add-rm-pkg-deps.js index ae813186fb712..f59df359e9456 100644 --- a/workspaces/arborist/lib/add-rm-pkg-deps.js +++ b/workspaces/arborist/lib/add-rm-pkg-deps.js @@ -1,10 +1,11 @@ // add and remove dependency specs to/from pkg manifest +const log = require('proc-log') const localeCompare = require('@isaacs/string-locale-compare')('en') -const add = ({ pkg, add, saveBundle, saveType, log }) => { +const add = ({ pkg, add, saveBundle, saveType }) => { for (const spec of add) { - addSingle({ pkg, spec, saveBundle, saveType, log }) + addSingle({ pkg, spec, saveBundle, saveType }) } return pkg @@ -20,7 +21,7 @@ const saveTypeMap = new Map([ ['peer', 'peerDependencies'], ]) -const addSingle = ({ pkg, spec, saveBundle, saveType, log }) => { +const addSingle = ({ pkg, spec, saveBundle, saveType }) => { const { name, rawSpec } = spec // if the user does not give us a type, we infer which type(s) @@ -34,19 +35,19 @@ const addSingle = ({ pkg, spec, saveBundle, saveType, log }) => { if (saveType === 'prod') { // a production dependency can only exist as production (rpj ensures it // doesn't coexist w/ optional) - deleteSubKey(pkg, 'devDependencies', name, 'dependencies', log) - deleteSubKey(pkg, 'peerDependencies', name, 'dependencies', log) + deleteSubKey(pkg, 'devDependencies', name, 'dependencies') + deleteSubKey(pkg, 'peerDependencies', name, 'dependencies') } else if (saveType === 'dev') { // a dev dependency may co-exist as peer, or optional, but not production - deleteSubKey(pkg, 'dependencies', name, 'devDependencies', log) + deleteSubKey(pkg, 'dependencies', name, 'devDependencies') } else if (saveType === 'optional') { // an optional dependency may co-exist as dev (rpj ensures it doesn't // coexist w/ prod) - deleteSubKey(pkg, 'peerDependencies', name, 'optionalDependencies', log) + deleteSubKey(pkg, 'peerDependencies', name, 'optionalDependencies') } else { // peer or peerOptional is all that's left // a peer dependency may coexist as dev - deleteSubKey(pkg, 'dependencies', name, 'peerDependencies', log) - deleteSubKey(pkg, 'optionalDependencies', name, 'peerDependencies', log) + deleteSubKey(pkg, 'dependencies', name, 'peerDependencies') + deleteSubKey(pkg, 'optionalDependencies', name, 'peerDependencies') } const depType = saveTypeMap.get(saveType) @@ -108,9 +109,9 @@ const hasSubKey = (pkg, depType, name) => { } // Removes a subkey and warns about it if it's being replaced -const deleteSubKey = (pkg, depType, name, replacedBy, log) => { +const deleteSubKey = (pkg, depType, name, replacedBy) => { if (hasSubKey(pkg, depType, name)) { - if (replacedBy && log) { + if (replacedBy) { log.warn('idealTree', `Removing ${depType}.${name} in favor of ${replacedBy}.${name}`) } delete pkg[depType][name] diff --git a/workspaces/arborist/lib/arborist/build-ideal-tree.js b/workspaces/arborist/lib/arborist/build-ideal-tree.js index 3fedd972f9c00..3f001f9e9eb10 100644 --- a/workspaces/arborist/lib/arborist/build-ideal-tree.js +++ b/workspaces/arborist/lib/arborist/build-ideal-tree.js @@ -14,6 +14,7 @@ const fs = require('fs') const lstat = promisify(fs.lstat) const readlink = promisify(fs.readlink) const { depth } = require('treeverse') +const log = require('proc-log') const { OK, @@ -248,7 +249,7 @@ module.exports = cls => class IdealTreeBuilder extends cls { try { c() } catch (er) { - this.log.warn(er.code, er.message, { + log.warn(er.code, er.message, { package: er.pkgid, required: er.required, current: er.current, @@ -532,7 +533,6 @@ Try using the package name instead, e.g: saveBundle, saveType, path: this.path, - log: this.log, }) }) } @@ -602,7 +602,7 @@ Try using the package name instead, e.g: // be printed by npm-audit-report as if they can be fixed, because // they can't. if (bundler) { - this.log.warn(`audit fix ${node.name}@${node.version}`, + log.warn(`audit fix ${node.name}@${node.version}`, `${node.location}\nis a bundled dependency of\n${ bundler.name}@${bundler.version} at ${bundler.location}\n` + 'It cannot be fixed automatically.\n' + @@ -637,14 +637,14 @@ Try using the package name instead, e.g: if (!node.isProjectRoot && !node.isWorkspace) { // not something we're going to fix, sorry. have to cd into // that directory and fix it yourself. - this.log.warn('audit', 'Manual fix required in linked project ' + + log.warn('audit', 'Manual fix required in linked project ' + `at ./${node.location} for ${name}@${simpleRange}.\n` + `'cd ./${node.location}' and run 'npm audit' for details.`) continue } if (!fixAvailable) { - this.log.warn('audit', `No fix available for ${name}@${simpleRange}`) + log.warn('audit', `No fix available for ${name}@${simpleRange}`) continue } @@ -652,7 +652,7 @@ Try using the package name instead, e.g: const breakingMessage = isSemVerMajor ? 'a SemVer major change' : 'outside your stated dependency range' - this.log.warn('audit', `Updating ${name} to ${version},` + + log.warn('audit', `Updating ${name} to ${version},` + `which is ${breakingMessage}.`) await this[_add](node, { add: [`${name}@${version}`] }) @@ -727,7 +727,7 @@ Try using the package name instead, e.g: const heading = ancient ? 'ancient lockfile' : 'old lockfile' if (ancient || !this.options.lockfileVersion || this.options.lockfileVersion >= defaultLockfileVersion) { - this.log.warn(heading, + log.warn(heading, ` The ${meta.type} file was created with an old version of npm, so supplemental metadata must be fetched from the registry. @@ -744,7 +744,7 @@ This is a one-time fix-up, please be patient... } queue.push(async () => { - this.log.silly('inflate', node.location) + log.silly('inflate', node.location) const { resolved, version, path, name, location, integrity } = node // don't try to hit the registry for linked deps const useResolved = resolved && ( @@ -764,7 +764,7 @@ This is a one-time fix-up, please be patient... node.package = { ...mani, _id: `${mani.name}@${mani.version}` } }).catch((er) => { const warning = `Could not fetch metadata for ${name}@${id}` - this.log.warn(heading, warning, er) + log.warn(heading, warning, er) }) this.finishTracker(t) }) @@ -793,7 +793,7 @@ This is a one-time fix-up, please be patient... this[_depsQueue].push(tree) // XXX also push anything that depends on a node with a name // in the override list - this.log.silly('idealTree', 'buildDeps') + log.silly('idealTree', 'buildDeps') this.addTracker('idealTree', tree.name, '') return this[_buildDepStep]() .then(() => process.emit('timeEnd', 'idealTree:buildDeps')) @@ -1232,7 +1232,7 @@ This is a one-time fix-up, please be patient... if (this[_manifests].has(spec.raw)) { return this[_manifests].get(spec.raw) } else { - this.log.silly('fetch manifest', spec.raw) + log.silly('fetch manifest', spec.raw) const p = pacote.manifest(spec, options) .then(mani => { this[_manifests].set(spec.raw, mani) diff --git a/workspaces/arborist/lib/arborist/index.js b/workspaces/arborist/lib/arborist/index.js index de625e9b7684f..cb6ef1e0c2ccb 100644 --- a/workspaces/arborist/lib/arborist/index.js +++ b/workspaces/arborist/lib/arborist/index.js @@ -28,7 +28,6 @@ const { resolve } = require('path') const { homedir } = require('os') -const procLog = require('proc-log') const { depth } = require('treeverse') const { saveTypeMap } = require('../add-rm-pkg-deps.js') @@ -74,7 +73,6 @@ class Arborist extends Base { path: options.path || '.', cache: options.cache || `${homedir()}/.npm/_cacache`, packumentCache: options.packumentCache || new Map(), - log: options.log || procLog, workspacesEnabled: options.workspacesEnabled !== false, lockfileVersion: lockfileVersion(options.lockfileVersion), } @@ -94,7 +92,7 @@ class Arborist extends Base { // returns an array of the actual nodes for all the workspaces workspaceNodes (tree, workspaces) { - return getWorkspaceNodes(tree, workspaces, this.log) + return getWorkspaceNodes(tree, workspaces) } // returns a set of workspace nodes and all their deps diff --git a/workspaces/arborist/lib/arborist/rebuild.js b/workspaces/arborist/lib/arborist/rebuild.js index 1a05e52735376..09b4419f5b5dc 100644 --- a/workspaces/arborist/lib/arborist/rebuild.js +++ b/workspaces/arborist/lib/arborist/rebuild.js @@ -13,6 +13,7 @@ const { isNodeGypPackage, defaultGypInstallScript, } = require('@npmcli/node-gyp') +const log = require('proc-log') const boolEnv = b => b ? '1' : '' const sortNodes = (a, b) => @@ -297,7 +298,7 @@ module.exports = cls => class Builder extends cls { const timer = `build:run:${event}:${location}` process.emit('time', timer) - this.log.info('run', pkg._id, event, location, pkg.scripts[event]) + log.info('run', pkg._id, event, location, pkg.scripts[event]) const env = { npm_package_resolved: resolved, npm_package_integrity: integrity, @@ -319,7 +320,7 @@ module.exports = cls => class Builder extends cls { } const p = runScript(runOpts).catch(er => { const { code, signal } = er - this.log.info('run', pkg._id, event, { code, signal }) + log.info('run', pkg._id, event, { code, signal }) throw er }).then(({ args, code, signal, stdout, stderr }) => { this.scriptsRun.add({ @@ -333,7 +334,7 @@ module.exports = cls => class Builder extends cls { stdout, stderr, }) - this.log.info('run', pkg._id, event, { code, signal }) + log.info('run', pkg._id, event, { code, signal }) }) await (this[_doHandleOptionalFailure] diff --git a/workspaces/arborist/lib/arborist/reify.js b/workspaces/arborist/lib/arborist/reify.js index 92e2b69606c81..4bc1c7ee4e72e 100644 --- a/workspaces/arborist/lib/arborist/reify.js +++ b/workspaces/arborist/lib/arborist/reify.js @@ -8,6 +8,7 @@ const npa = require('npm-package-arg') const semver = require('semver') const debug = require('../debug.js') const walkUp = require('walk-up-path') +const log = require('proc-log') const { dirname, resolve, relative } = require('path') const { depth: dfwalk } = require('treeverse') @@ -390,7 +391,7 @@ module.exports = cls => class Reifier extends cls { [_addNodeToTrashList] (node, retire = false) { const paths = [node.path, ...node.binPaths] const moves = this[_retiredPaths] - this.log.silly('reify', 'mark', retire ? 'retired' : 'deleted', paths) + log.silly('reify', 'mark', retire ? 'retired' : 'deleted', paths) for (const path of paths) { if (retire) { const retired = retirePath(path) @@ -413,7 +414,7 @@ module.exports = cls => class Reifier extends cls { this[_addNodeToTrashList](diff.actual, true) } } - this.log.silly('reify', 'moves', moves) + log.silly('reify', 'moves', moves) const movePromises = Object.entries(moves) .map(([from, to]) => this[_renamePath](from, to)) return promiseAllRejectLate(movePromises) @@ -532,7 +533,7 @@ module.exports = cls => class Reifier extends cls { return promiseAllRejectLate(unlinks) .then(() => { if (failures.length) { - this.log.warn('cleanup', 'Failed to remove some directories', failures) + log.warn('cleanup', 'Failed to remove some directories', failures) } }) .then(() => process.emit('timeEnd', 'reify:rollback:createSparse')) @@ -624,7 +625,7 @@ module.exports = cls => class Reifier extends cls { this[_nmValidated].add(nm) return } - this.log.warn('reify', 'Removing non-directory', nm) + log.warn('reify', 'Removing non-directory', nm) await rimraf(nm) } @@ -647,8 +648,8 @@ module.exports = cls => class Reifier extends cls { 'please re-try this operation once it completes\n' + 'so that the damage can be corrected, or perform\n' + 'a fresh install with no lockfile if the problem persists.' - this.log.warn('reify', warning) - this.log.verbose('reify', 'unrecognized node in tree', node.path) + log.warn('reify', warning) + log.verbose('reify', 'unrecognized node in tree', node.path) node.parent = null node.fsParent = null this[_addNodeToTrashList](node) @@ -691,7 +692,7 @@ module.exports = cls => class Reifier extends cls { [_warnDeprecated] (node) { const { _id, deprecated } = node.package if (deprecated) { - this.log.warn('deprecated', `${_id}: ${deprecated}`) + log.warn('deprecated', `${_id}: ${deprecated}`) } } @@ -701,7 +702,7 @@ module.exports = cls => class Reifier extends cls { return (node.optional ? p.catch(er => { const set = optionalSet(node) for (node of set) { - this.log.verbose('reify', 'failed optional dependency', node.path) + log.verbose('reify', 'failed optional dependency', node.path) this[_addNodeToTrashList](node) } }) : p).then(() => node) @@ -1129,7 +1130,7 @@ module.exports = cls => class Reifier extends cls { return promiseAllRejectLate(promises).then(() => { if (failures.length) { - this.log.warn('cleanup', 'Failed to remove some directories', failures) + log.warn('cleanup', 'Failed to remove some directories', failures) } }) .then(() => process.emit('timeEnd', 'reify:trash')) diff --git a/workspaces/arborist/lib/audit-report.js b/workspaces/arborist/lib/audit-report.js index b7d8249b12ddc..4dc6dd177c1e4 100644 --- a/workspaces/arborist/lib/audit-report.js +++ b/workspaces/arborist/lib/audit-report.js @@ -13,7 +13,7 @@ const _fixAvailable = Symbol('fixAvailable') const _checkTopNode = Symbol('checkTopNode') const _init = Symbol('init') const _omit = Symbol('omit') -const procLog = require('proc-log') +const log = require('proc-log') const fetch = require('npm-registry-fetch') @@ -98,14 +98,13 @@ class AuditReport extends Map { this.calculator = new Calculator(opts) this.error = null this.options = opts - this.log = opts.log || procLog this.tree = tree this.filterSet = opts.filterSet } async run () { this.report = await this[_getReport]() - this.log.silly('audit report', this.report) + log.silly('audit report', this.report) if (this.report) { await this[_init]() } @@ -313,7 +312,7 @@ class AuditReport extends Map { try { // first try the super fast bulk advisory listing const body = prepareBulkData(this.tree, this[_omit], this.filterSet) - this.log.silly('audit', 'bulk request', body) + log.silly('audit', 'bulk request', body) // no sense asking if we don't have anything to audit, // we know it'll be empty @@ -331,7 +330,7 @@ class AuditReport extends Map { return await res.json() } catch (er) { - this.log.silly('audit', 'bulk request failed', String(er.body)) + log.silly('audit', 'bulk request failed', String(er.body)) // that failed, try the quick audit endpoint const body = prepareData(this.tree, this.options) const res = await fetch('/-/npm/v1/security/audits/quick', { @@ -344,8 +343,8 @@ class AuditReport extends Map { return AuditReport.auditToBulk(await res.json()) } } catch (er) { - this.log.verbose('audit error', er) - this.log.silly('audit error', String(er.body)) + log.verbose('audit error', er) + log.silly('audit error', String(er.body)) this.error = er return null } finally { diff --git a/workspaces/arborist/lib/get-workspace-nodes.js b/workspaces/arborist/lib/get-workspace-nodes.js index 6db489f69c518..91002dab57085 100644 --- a/workspaces/arborist/lib/get-workspace-nodes.js +++ b/workspaces/arborist/lib/get-workspace-nodes.js @@ -1,7 +1,10 @@ // Get the actual nodes corresponding to a root node's child workspaces, // given a list of workspace names. + +const log = require('proc-log') const relpath = require('./relpath.js') -const getWorkspaceNodes = (tree, workspaces, log) => { + +const getWorkspaceNodes = (tree, workspaces) => { const wsMap = tree.workspaces if (!wsMap) { log.warn('workspaces', 'filter set, but no workspaces present') diff --git a/workspaces/arborist/lib/shrinkwrap.js b/workspaces/arborist/lib/shrinkwrap.js index f4af71f478d5a..ead9aed36492f 100644 --- a/workspaces/arborist/lib/shrinkwrap.js +++ b/workspaces/arborist/lib/shrinkwrap.js @@ -33,7 +33,7 @@ const mismatch = (a, b) => a && b && a !== b // After calling this.commit(), any nodes not present in the tree will have // been removed from the shrinkwrap data as well. -const procLog = require('proc-log') +const log = require('proc-log') const YarnLock = require('./yarn-lock.js') const { promisify } = require('util') const rimraf = promisify(require('rimraf')) @@ -329,14 +329,12 @@ class Shrinkwrap { newline = '\n', shrinkwrapOnly = false, hiddenLockfile = false, - log = procLog, lockfileVersion, } = options this.lockfileVersion = hiddenLockfile ? 3 : lockfileVersion ? parseInt(lockfileVersion, 10) : null - this.log = log this[_awaitingUpdate] = new Map() this.tree = null this.path = resolve(path || '.') @@ -479,9 +477,9 @@ class Shrinkwrap { /* istanbul ignore else */ if (typeof this.filename === 'string') { const rel = relpath(this.path, this.filename) - this.log.verbose('shrinkwrap', `failed to load ${rel}`, er) + log.verbose('shrinkwrap', `failed to load ${rel}`, er) } else { - this.log.verbose('shrinkwrap', `failed to load ${this.path}`, er) + log.verbose('shrinkwrap', `failed to load ${this.path}`, er) } this.loadingError = er this.loadedFromDisk = false diff --git a/workspaces/arborist/lib/tracker.js b/workspaces/arborist/lib/tracker.js index b50f06eaa5518..c2a456e4832cc 100644 --- a/workspaces/arborist/lib/tracker.js +++ b/workspaces/arborist/lib/tracker.js @@ -1,20 +1,14 @@ const _progress = Symbol('_progress') const _onError = Symbol('_onError') -const procLog = require('proc-log') +const npmlog = require('npmlog') module.exports = cls => class Tracker extends cls { constructor (options = {}) { super(options) - this.log = options.log || procLog this[_progress] = new Map() } addTracker (section, subsection = null, key = null) { - // TrackerGroup type object not found - if (!this.log.newGroup) { - return - } - if (section === null || section === undefined) { this[_onError](`Tracker can't be null or undefined`) } @@ -31,13 +25,13 @@ module.exports = cls => class Tracker extends cls { this[_onError](`Tracker "${section}" already exists`) } else if (!hasTracker && subsection === null) { // 1. no existing tracker, no subsection - // Create a new tracker from this.log + // Create a new tracker from npmlog // starts progress bar if (this[_progress].size === 0) { - this.log.enableProgress() + npmlog.enableProgress() } - this[_progress].set(section, this.log.newGroup(section)) + this[_progress].set(section, npmlog.newGroup(section)) } else if (!hasTracker && subsection !== null) { // 2. no parent tracker and subsection this[_onError](`Parent tracker "${section}" does not exist`) @@ -53,11 +47,6 @@ module.exports = cls => class Tracker extends cls { } finishTracker (section, subsection = null, key = null) { - // TrackerGroup type object not found - if (!this.log.newGroup) { - return - } - if (section === null || section === undefined) { this[_onError](`Tracker can't be null or undefined`) } @@ -88,7 +77,7 @@ module.exports = cls => class Tracker extends cls { // remove progress bar if all // trackers are finished if (this[_progress].size === 0) { - this.log.disableProgress() + npmlog.disableProgress() } } else if (!hasTracker && subsection === null) { // 1. no existing parent tracker, no subsection @@ -103,7 +92,7 @@ module.exports = cls => class Tracker extends cls { } [_onError] (msg) { - this.log.disableProgress() + npmlog.disableProgress() throw new Error(msg) } } diff --git a/workspaces/arborist/test/add-rm-pkg-deps.js b/workspaces/arborist/test/add-rm-pkg-deps.js index 54485f7bc84d1..77ea2bd61e550 100644 --- a/workspaces/arborist/test/add-rm-pkg-deps.js +++ b/workspaces/arborist/test/add-rm-pkg-deps.js @@ -10,13 +10,14 @@ t.test('add', t => { const file = npa('file@file:/some/path/foo.tgz', '/') const logs = [] - const log = { - warn: function (...args) { + const log = (l, ...args) => { + if (l === 'warn') { logs.push(args) - }, + } } + process.on('log', log) + t.teardown(() => process.off('log', log)) t.strictSame(add({ - log, pkg: { dependencies: { bar: '1' }, devDependencies: { foo: '2' }, diff --git a/workspaces/arborist/test/arborist/reify.js b/workspaces/arborist/test/arborist/reify.js index db4b64c9bcee8..f69547db406f7 100644 --- a/workspaces/arborist/test/arborist/reify.js +++ b/workspaces/arborist/test/arborist/reify.js @@ -1076,6 +1076,7 @@ t.test('scoped registries', async t => { registry, }) const kReify = Symbol.for('reifyNode') + a.addTracker('reify') a.idealTree = new Node({ path }) const node = new Node({ diff --git a/workspaces/arborist/test/get-workspace-nodes.js b/workspaces/arborist/test/get-workspace-nodes.js index fa259a8fea9fd..3de4d73da7b9f 100644 --- a/workspaces/arborist/test/get-workspace-nodes.js +++ b/workspaces/arborist/test/get-workspace-nodes.js @@ -4,8 +4,6 @@ const Arborist = require('../lib/arborist/index.js') const { resolve } = require('path') const path = resolve(__dirname, './fixtures/workspaces-shared-deps-virtual') -const log = require('proc-log') - const warningTracker = () => { const list = [] const onlog = (...msg) => msg[0] === 'warn' && list.push(msg) @@ -23,7 +21,7 @@ t.before(async () => { t.test('basic behavior', t => { const getLogs = warningTracker() - const wsNodes = getWorkspaceNodes(tree, ['a'], log) + const wsNodes = getWorkspaceNodes(tree, ['a']) t.equal(wsNodes.length, 1) t.equal(wsNodes[0], tree.children.get('a').target) t.same(getLogs(), []) @@ -32,7 +30,7 @@ t.test('basic behavior', t => { t.test('filter set, but no workspaces present', t => { const getLogs = warningTracker() - const wsNodes = getWorkspaceNodes(tree.children.get('b').target, ['xyz'], log) + const wsNodes = getWorkspaceNodes(tree.children.get('b').target, ['xyz']) t.same(wsNodes, []) t.same(getLogs(), [ ['warn', 'workspaces', 'filter set, but no workspaces present'], @@ -42,7 +40,7 @@ t.test('filter set, but no workspaces present', t => { t.test('name in filter set, but not in workspaces', t => { const getLogs = warningTracker() - const wsNodes = getWorkspaceNodes(tree, ['xyz'], log) + const wsNodes = getWorkspaceNodes(tree, ['xyz']) t.same(wsNodes, []) t.same(getLogs(), [ ['warn', 'workspaces', 'xyz in filter set, but not in workspaces'], @@ -57,7 +55,7 @@ t.test('name in filter set, but no workspace folder present', t => { // but if we start moving things around and make a mistake, it's // possible to get there. tree.children.get('c').target.root = null - const wsNodes = getWorkspaceNodes(tree, ['c'], log) + const wsNodes = getWorkspaceNodes(tree, ['c']) t.same(wsNodes, []) t.same(getLogs(), [ ['warn', 'workspaces', 'c in filter set, but no workspace folder present'], diff --git a/workspaces/arborist/test/tracker.js b/workspaces/arborist/test/tracker.js index 03ece91a3b0b8..0c2fbb729d45e 100644 --- a/workspaces/arborist/test/tracker.js +++ b/workspaces/arborist/test/tracker.js @@ -1,15 +1,6 @@ const Tracker = require('../lib/tracker.js')(class {}) const t = require('tap') -const npmlog = { - newGroup: () => ({ - newGroup: () => ({ finish: () => {} }), - finish: () => {}, - }), - enableProgress: () => {}, - disableProgress: () => {}, -} - t.test('no npmlog', t => { const tr = new Tracker() t.doesNotThrow(() => { @@ -24,27 +15,27 @@ t.test('no npmlog', t => { t.test('adds tracker', t => { t.doesNotThrow(() => { - const tr = new Tracker({ log: npmlog }) + const tr = new Tracker() tr.addTracker('testTracker') }) t.doesNotThrow(() => { - const tr = new Tracker({ log: npmlog }) + const tr = new Tracker() tr.addTracker('testTracker') tr.addTracker('testTracker', 'subTracker') }) t.doesNotThrow(() => { - const tr = new Tracker({ log: npmlog }) + const tr = new Tracker() tr.addTracker('testTracker') tr.addTracker('testTracker', 'subTracker') tr.addTracker('testTracker', 'subTracker') }) t.doesNotThrow(() => { - const tr = new Tracker({ log: npmlog }) + const tr = new Tracker() tr.addTracker('testTracker') tr.addTracker('testTracker', 'subTracker.name', 'subTracker.key') }) - const tr = new Tracker({ log: npmlog }) + const tr = new Tracker() t.throws(() => { tr.addTracker() }, Error, `Tracker can't be null or undefined`) @@ -70,19 +61,19 @@ t.test('adds tracker', t => { t.test('finishes tracker', t => { t.doesNotThrow(() => { - const tr = new Tracker({ log: npmlog }) + const tr = new Tracker() tr.addTracker('testTracker') tr.finishTracker('testTracker') }) t.doesNotThrow(() => { - const tr = new Tracker({ log: npmlog }) + const tr = new Tracker() tr.addTracker('testTracker') tr.addTracker('testTracker', 'subTracker') tr.finishTracker('testTracker', 'subTracker') tr.finishTracker('testTracker') }) t.doesNotThrow(() => { - const tr = new Tracker({ log: npmlog }) + const tr = new Tracker() tr.addTracker('testTracker') tr.addTracker('testTracker', 'subTracker.name', 'subTracker.key') tr.finishTracker('testTracker', 'subTracker.name', 'subTracker.key') @@ -90,14 +81,14 @@ t.test('finishes tracker', t => { }) t.doesNotThrow(() => { - const tr = new Tracker({ log: npmlog }) + const tr = new Tracker() tr.addTracker('firstTracker') tr.addTracker('secondTracker') tr.finishTracker('firstTracker') tr.finishTracker('secondTracker') }) - const tr = new Tracker({ log: npmlog }) + const tr = new Tracker() t.throws(() => { tr.finishTracker() }, Error, `Tracker can't be null or undefined`) @@ -109,19 +100,19 @@ t.test('finishes tracker', t => { }, Error, `Tracker can't be null or undefined`) t.doesNotThrow(() => { - const tr = new Tracker({ log: npmlog }) + const tr = new Tracker() tr.addTracker('testTracker') tr.addTracker('testTracker', 'testChild') tr.finishTracker('testTracker') }) t.throws(() => { - const tr = new Tracker({ log: npmlog }) + const tr = new Tracker() tr.finishTracker('testTracker') }, Error, 'Tracker "testTracker" does not exist') t.doesNotThrow(() => { - const tr = new Tracker({ log: npmlog }) + const tr = new Tracker() tr.addTracker('testTracker') tr.finishTracker('testTracker', 'nonExistentSubTracker') }) From 55e9ef01f1ee6a71489b32b31d17d2cbdc2d1a64 Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Mon, 21 Feb 2022 14:33:59 -0700 Subject: [PATCH 24/43] chore(libnpmexec): remove log option BREAKING CHANGE: this drops support for the `log` property --- workspaces/libnpmexec/README.md | 1 - workspaces/libnpmexec/lib/index.js | 9 ++--- workspaces/libnpmexec/lib/run-script.js | 11 +++--- workspaces/libnpmexec/test/index.js | 9 ++--- workspaces/libnpmexec/test/run-script.js | 44 ++++++++++-------------- 5 files changed, 31 insertions(+), 43 deletions(-) diff --git a/workspaces/libnpmexec/README.md b/workspaces/libnpmexec/README.md index a48552714d5e6..74d6f5211e61d 100644 --- a/workspaces/libnpmexec/README.md +++ b/workspaces/libnpmexec/README.md @@ -35,7 +35,6 @@ await libexec({ - `color`: Output should use color? **Boolean**, defaults to `false` - `localBin`: Location to the `node_modules/.bin` folder of the local project to start scanning for bin files **String**, defaults to `./node_modules/.bin`. **libexec** will walk up the directory structure looking for `node_modules/.bin` folders in parent folders that might satisfy the current `arg` and will use that bin if found. - `locationMsg`: Overrides "at location" message when entering interactive mode **String** - - `log`: Sets an optional logger **Object**, defaults to `proc-log` module usage. - `globalBin`: Location to the global space bin folder, same as: `$(npm bin -g)` **String**, defaults to empty string. - `output`: A function to print output to **Function** - `packages`: A list of packages to be used (possibly fetch from the registry) **Array**, defaults to `[]` diff --git a/workspaces/libnpmexec/lib/index.js b/workspaces/libnpmexec/lib/index.js index facafb035d328..3c7be114913b5 100644 --- a/workspaces/libnpmexec/lib/index.js +++ b/workspaces/libnpmexec/lib/index.js @@ -4,7 +4,8 @@ const read = promisify(require('read')) const Arborist = require('@npmcli/arborist') const ciDetect = require('@npmcli/ci-detect') -const logger = require('proc-log') +const log = require('proc-log') +const npmlog = require('npmlog') const mkdirp = require('mkdirp-infer-owner') const npa = require('npm-package-arg') const pacote = require('pacote') @@ -39,7 +40,6 @@ const exec = async (opts) => { yes = undefined, ...flatOptions } = opts - const log = flatOptions.log || logger // dereferences values because we manipulate it later const packages = [..._packages] @@ -50,7 +50,6 @@ const exec = async (opts) => { color, flatOptions, locationMsg, - log, output, path, pathArr, @@ -169,9 +168,7 @@ const exec = async (opts) => { const prompt = `Need to install the following packages:\n${ addList }Ok to proceed? ` - if (typeof log.clearProgress === 'function') { - log.clearProgress() - } + npmlog.clearProgress() const confirm = await read({ prompt, default: 'y' }) if (confirm.trim().toLowerCase().charAt(0) !== 'y') { throw new Error('canceled') diff --git a/workspaces/libnpmexec/lib/run-script.js b/workspaces/libnpmexec/lib/run-script.js index 851f5c60bd0f1..97543e6ff0d08 100644 --- a/workspaces/libnpmexec/lib/run-script.js +++ b/workspaces/libnpmexec/lib/run-script.js @@ -4,6 +4,8 @@ const chalk = require('chalk') const ciDetect = require('@npmcli/ci-detect') const runScript = require('@npmcli/run-script') const readPackageJson = require('read-package-json-fast') +const npmlog = require('npmlog') +const log = require('proc-log') const noTTY = require('./no-tty.js') const nocolor = { @@ -18,7 +20,6 @@ const run = async ({ color, flatOptions, locationMsg, - log, output = () => {}, path, pathArr, @@ -41,9 +42,7 @@ const run = async ({ }, } - if (log && log.disableProgress) { - log.disableProgress() - } + npmlog.disableProgress() try { if (script === scriptShell) { @@ -80,9 +79,7 @@ const run = async ({ stdio: 'inherit', }) } finally { - if (log && log.enableProgress) { - log.enableProgress() - } + npmlog.enableProgress() } } diff --git a/workspaces/libnpmexec/test/index.js b/workspaces/libnpmexec/test/index.js index cbd3eda727569..e44bc00c7a100 100644 --- a/workspaces/libnpmexec/test/index.js +++ b/workspaces/libnpmexec/test/index.js @@ -336,10 +336,12 @@ t.test('prompt, accepts', async t => { t.test('with clearProgress function', async t => { const libexec = t.mock('../lib/index.js', { '@npmcli/ci-detect': () => false, - 'proc-log': { + npmlog: { clearProgress () { t.ok(true, 'should call clearProgress function') }, + disableProgress () {}, + enableProgress () {}, }, read (opts, cb) { cb(null, 'y') @@ -365,7 +367,6 @@ t.test('prompt, accepts', async t => { t.test('without clearProgress function', async t => { const libexec = t.mock('../lib/index.js', { '@npmcli/ci-detect': () => false, - 'proc-log': {}, read (opts, cb) { cb(null, 'y') }, @@ -401,10 +402,11 @@ t.test('prompt, refuses', async t => { t.test('with clearProgress function', async t => { const libexec = t.mock('../lib/index.js', { '@npmcli/ci-detect': () => false, - 'proc-log': { + npmlog: { clearProgress () { t.ok(true, 'should call clearProgress function') }, + disableProgess () {}, }, read (opts, cb) { cb(null, 'n') @@ -439,7 +441,6 @@ t.test('prompt, refuses', async t => { t.test('without clearProgress function', async t => { const libexec = t.mock('../lib/index.js', { '@npmcli/ci-detect': () => false, - 'proc-log': {}, read (opts, cb) { cb(null, 'n') }, diff --git a/workspaces/libnpmexec/test/run-script.js b/workspaces/libnpmexec/test/run-script.js index c86e8e1514171..0b97a72ac04cb 100644 --- a/workspaces/libnpmexec/test/run-script.js +++ b/workspaces/libnpmexec/test/run-script.js @@ -4,9 +4,6 @@ const baseOpts = { args: [], call: '', color: false, - log: { - warn () {}, - }, path: '', pathArr: [''], runPath: '', @@ -29,20 +26,18 @@ t.test('disable, enable log progress', t => { t.ok('should call run-script') }, '../lib/no-tty.js': () => false, - }) - const log = { - ...baseOpts.log, - disableProgress () { - t.ok('should disable progress') - }, - enableProgress () { - t.ok('should enable progress') + npmlog: { + disableProgress () { + t.ok('should disable progress') + }, + enableProgress () { + t.ok('should enable progress') + }, }, - } + }) runScript({ ...baseOpts, - log, path, }) }) @@ -139,18 +134,17 @@ t.test('ci env', t => { throw new Error('should not call run-script') }, '../lib/no-tty.js': () => false, - }) - const log = { - ...baseOpts.log, - warn (title, msg) { - t.equal(title, 'exec', 'should have expected title') - t.equal( - msg, - 'Interactive mode disabled in CI environment', - 'should have expected ci environment message' - ) + 'proc-log': { + warn (title, msg) { + t.equal(title, 'exec', 'should have expected title') + t.equal( + msg, + 'Interactive mode disabled in CI environment', + 'should have expected ci environment message' + ) + }, }, - } + }) - runScript({ ...baseOpts, log }) + runScript({ ...baseOpts }) }) From 174dd88cba31b25461619fe796fe1d3ac34eae70 Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Mon, 21 Feb 2022 22:25:21 -0700 Subject: [PATCH 25/43] feat(libnpmversion): rm log opt and add silent opt to control run script BREAKING CHANGE: this removes the log option --- workspaces/libnpmversion/README.md | 1 + workspaces/libnpmversion/lib/enforce-clean.js | 3 +- workspaces/libnpmversion/lib/index.js | 5 +- workspaces/libnpmversion/lib/proc-log.js | 21 -------- workspaces/libnpmversion/lib/version.js | 9 ++-- .../tap-snapshots/test/index.js.test.cjs | 14 +---- .../libnpmversion/test/enforce-clean.js | 12 ++--- workspaces/libnpmversion/test/index.js | 1 - workspaces/libnpmversion/test/proc-log.js | 11 ---- workspaces/libnpmversion/test/version.js | 53 +++++++++---------- 10 files changed, 44 insertions(+), 86 deletions(-) delete mode 100644 workspaces/libnpmversion/lib/proc-log.js delete mode 100644 workspaces/libnpmversion/test/proc-log.js diff --git a/workspaces/libnpmversion/README.md b/workspaces/libnpmversion/README.md index e82e7cd6f8730..165d16a2b607c 100644 --- a/workspaces/libnpmversion/README.md +++ b/workspaces/libnpmversion/README.md @@ -27,6 +27,7 @@ npmVersion(arg, { ignoreScripts: false, // do not run pre/post/version lifecycle scripts scriptShell: '/bin/bash', // shell to run lifecycle scripts in message: 'v%s', // message for tag and commit, replace %s with the version + silent: false, // passed to @npmcli/run-script to control whether it logs }).then(newVersion => { console.error('version updated!', newVersion) }) diff --git a/workspaces/libnpmversion/lib/enforce-clean.js b/workspaces/libnpmversion/lib/enforce-clean.js index 6103da9bd96af..721f146221c15 100644 --- a/workspaces/libnpmversion/lib/enforce-clean.js +++ b/workspaces/libnpmversion/lib/enforce-clean.js @@ -1,9 +1,10 @@ const git = require('@npmcli/git') +const log = require('proc-log') // returns true if it's cool to do git stuff // throws if it's unclean, and not forced. module.exports = async opts => { - const { force, log } = opts + const { force } = opts let hadError = false const clean = await git.isClean(opts).catch(er => { if (er.code === 'ENOGIT') { diff --git a/workspaces/libnpmversion/lib/index.js b/workspaces/libnpmversion/lib/index.js index 683941cdea4f3..95acd11b5e433 100644 --- a/workspaces/libnpmversion/lib/index.js +++ b/workspaces/libnpmversion/lib/index.js @@ -1,6 +1,5 @@ const readJson = require('./read-json.js') const version = require('./version.js') -const proclog = require('./proc-log.js') module.exports = async (newversion, opts = {}) => { const { @@ -15,8 +14,8 @@ module.exports = async (newversion, opts = {}) => { ignoreScripts = false, scriptShell = undefined, preid = null, - log = proclog, message = 'v%s', + silent, } = opts const pkg = opts.pkg || await readJson(path + '/package.json') @@ -35,7 +34,7 @@ module.exports = async (newversion, opts = {}) => { scriptShell, preid, pkg, - log, message, + silent, }) } diff --git a/workspaces/libnpmversion/lib/proc-log.js b/workspaces/libnpmversion/lib/proc-log.js deleted file mode 100644 index a7c683ba2fd11..0000000000000 --- a/workspaces/libnpmversion/lib/proc-log.js +++ /dev/null @@ -1,21 +0,0 @@ -// default logger. -// emits 'log' events on the process -const LEVELS = [ - 'notice', - 'error', - 'warn', - 'info', - 'verbose', - 'http', - 'silly', - 'pause', - 'resume', -] - -const log = level => (...args) => process.emit('log', level, ...args) - -const logger = {} -for (const level of LEVELS) { - logger[level] = log(level) -} -module.exports = logger diff --git a/workspaces/libnpmversion/lib/version.js b/workspaces/libnpmversion/lib/version.js index 116a375553e9e..12be89b040df7 100644 --- a/workspaces/libnpmversion/lib/version.js +++ b/workspaces/libnpmversion/lib/version.js @@ -8,6 +8,7 @@ const readJson = require('./read-json.js') const git = require('@npmcli/git') const commit = require('./commit.js') const tag = require('./tag.js') +const log = require('proc-log') const runScript = require('@npmcli/run-script') @@ -19,7 +20,7 @@ module.exports = async (newversion, opts) => { ignoreScripts, preid, pkg, - log, + silent, } = opts const { valid, clean, inc } = semver @@ -64,7 +65,7 @@ module.exports = async (newversion, opts) => { pkg, stdio: 'inherit', event: 'preversion', - banner: log.level !== 'silent', + banner: !silent, env: { npm_old_version: current, npm_new_version: newV, @@ -98,7 +99,7 @@ module.exports = async (newversion, opts) => { pkg, stdio: 'inherit', event: 'version', - banner: log.level !== 'silent', + banner: !silent, env: { npm_old_version: current, npm_new_version: newV, @@ -125,7 +126,7 @@ module.exports = async (newversion, opts) => { pkg, stdio: 'inherit', event: 'postversion', - banner: log.level !== 'silent', + banner: !silent, env: { npm_old_version: current, npm_new_version: newV, diff --git a/workspaces/libnpmversion/tap-snapshots/test/index.js.test.cjs b/workspaces/libnpmversion/tap-snapshots/test/index.js.test.cjs index 6b79d41ebd691..59224e13fae45 100644 --- a/workspaces/libnpmversion/tap-snapshots/test/index.js.test.cjs +++ b/workspaces/libnpmversion/tap-snapshots/test/index.js.test.cjs @@ -15,17 +15,6 @@ Array [ "force": false, "gitTagVersion": true, "ignoreScripts": false, - "log": Object { - "error": Function (...args), - "http": Function (...args), - "info": Function (...args), - "notice": Function (...args), - "pause": Function (...args), - "resume": Function (...args), - "silly": Function (...args), - "verbose": Function (...args), - "warn": Function (...args), - }, "message": "v%s", "path": "{CWD}", "pkg": Object { @@ -35,6 +24,7 @@ Array [ "scriptShell": undefined, "signGitCommit": false, "signGitTag": false, + "silent": undefined, "tagVersionPrefix": "v", }, ] @@ -50,7 +40,6 @@ Array [ "force": true, "gitTagVersion": false, "ignoreScripts": true, - "log": Object {}, "message": "hello, i have a message for you", "path": "/some/path", "pkg": Object { @@ -60,6 +49,7 @@ Array [ "scriptShell": "/bin/bash", "signGitCommit": true, "signGitTag": true, + "silent": undefined, "tagVersionPrefix": "=", }, ] diff --git a/workspaces/libnpmversion/test/enforce-clean.js b/workspaces/libnpmversion/test/enforce-clean.js index 9a489d6f5664d..d96fb09ffa594 100644 --- a/workspaces/libnpmversion/test/enforce-clean.js +++ b/workspaces/libnpmversion/test/enforce-clean.js @@ -16,27 +16,27 @@ const enforceClean = requireInject('../lib/enforce-clean.js', { } }, }, + 'proc-log': { warn: (...msg) => warnings.push(msg) }, }) const warnings = [] -const log = { warn: (...msg) => warnings.push(msg) } t.test('clean, ok', t => - t.resolveMatch(enforceClean({ log, cwd: 'clean' }), true) + t.resolveMatch(enforceClean({ cwd: 'clean' }), true) .then(() => t.strictSame(warnings, [])) .then(() => { warnings.length = 0 })) t.test('unclean, no force, throws', t => - t.rejects(enforceClean({ log, cwd: 'unclean' })) + t.rejects(enforceClean({ cwd: 'unclean' })) .then(() => t.strictSame(warnings, [])) .then(() => { warnings.length = 0 })) t.test('unclean, forced, no throw', t => - t.resolveMatch(enforceClean({ log, cwd: 'unclean', force: true }), true) + t.resolveMatch(enforceClean({ cwd: 'unclean', force: true }), true) .then(() => t.strictSame(warnings, [ [ 'version', @@ -48,7 +48,7 @@ t.test('unclean, forced, no throw', t => })) t.test('nogit, return false, no throw', t => - t.resolveMatch(enforceClean({ log, cwd: 'nogit' }), false) + t.resolveMatch(enforceClean({ cwd: 'nogit' }), false) .then(() => t.strictSame(warnings, [ [ 'version', @@ -61,7 +61,7 @@ t.test('nogit, return false, no throw', t => })) t.test('other error, throw it', t => - t.rejects(enforceClean({ log, cwd: 'error' }), new Error('poop')) + t.rejects(enforceClean({ cwd: 'error' }), new Error('poop')) .then(() => t.strictSame(warnings, [])) .then(() => { warnings.length = 0 diff --git a/workspaces/libnpmversion/test/index.js b/workspaces/libnpmversion/test/index.js index 8c853c679219b..9dcef7b4cfa86 100644 --- a/workspaces/libnpmversion/test/index.js +++ b/workspaces/libnpmversion/test/index.js @@ -33,7 +33,6 @@ t.test('set the package ahead of time', async t => ignoreScripts: true, scriptShell: '/bin/bash', preid: 'rc', - log: {}, message: 'hello, i have a message for you', someOtherRandomField: 'this should not show up', }))) diff --git a/workspaces/libnpmversion/test/proc-log.js b/workspaces/libnpmversion/test/proc-log.js deleted file mode 100644 index 54f7d0b57df70..0000000000000 --- a/workspaces/libnpmversion/test/proc-log.js +++ /dev/null @@ -1,11 +0,0 @@ -const procLog = require('../lib/proc-log.js') -const t = require('tap') -process.once('log', (...args) => t.same(args, ['warn', 1, 2, 3])) -procLog.warn(1, 2, 3) -t.same(Object.keys(procLog), [ - 'notice', 'error', - 'warn', 'info', - 'verbose', 'http', - 'silly', 'pause', - 'resume', -]) diff --git a/workspaces/libnpmversion/test/version.js b/workspaces/libnpmversion/test/version.js index dfaa95de3bd52..19cf7ea0ab912 100644 --- a/workspaces/libnpmversion/test/version.js +++ b/workspaces/libnpmversion/test/version.js @@ -3,10 +3,6 @@ const requireInject = require('require-inject') const actionLog = [] -const log = { - verbose: (...msg) => actionLog.push(['verbose', ...msg]), -} - const gitMock = { is: async opts => !/\bnot-git$/.test(opts.path), spawn: async (args, opts) => actionLog.push(['spawn', args, opts]), @@ -26,6 +22,9 @@ const version = requireInject('../lib/version.js', { }, '@npmcli/git': gitMock, '@npmcli/run-script': async opt => actionLog.push(['run-script', opt.event, opt.env, opt]), + 'proc-log': { + verbose: (...msg) => actionLog.push(['verbose', ...msg]), + }, }) t.test('test out bumping the version in all the ways', async t => { @@ -70,7 +69,7 @@ t.test('test out bumping the version in all the ways', async t => { } throw new Error('no addy the locky fiel please & thanky i ignoring it') } - t.equal(await version('major', { path, log, pkg, gitTagVersion: true }), '2.0.0') + t.equal(await version('major', { path, pkg, gitTagVersion: true }), '2.0.0') t.match(actionLog, [ ['run-script', 'preversion', { npm_old_version: '1.2.0', npm_new_version: '2.0.0' }], ['write-json', path + '/package.json', pkg], @@ -85,7 +84,7 @@ t.test('test out bumping the version in all the ways', async t => { }) await t.test('minor (ignore scripts)', async t => { t.equal(await version('minor', - { path, log, pkg, ignoreScripts: true, gitTagVersion: true }), '2.1.0') + { path, pkg, ignoreScripts: true, gitTagVersion: true }), '2.1.0') t.match(actionLog, [ ['write-json', path + '/package.json', pkg], ['write-json', path + '/package-lock.json', pkg], @@ -97,7 +96,7 @@ t.test('test out bumping the version in all the ways', async t => { t.equal(pkg.version, '2.1.0') }) await t.test('patch', async t => { - t.equal(await version('patch', { path, log, pkg, gitTagVersion: true }), '2.1.1') + t.equal(await version('patch', { path, pkg, gitTagVersion: true }), '2.1.1') t.match(actionLog, [ ['run-script', 'preversion', { npm_old_version: '2.1.0', npm_new_version: '2.1.1' }], ['write-json', path + '/package.json', pkg], @@ -112,7 +111,7 @@ t.test('test out bumping the version in all the ways', async t => { t.equal(pkg.version, '2.1.1') }) await t.test('pre', async t => { - t.equal(await version('pre', { path, log, pkg, gitTagVersion: true }), '2.1.1-0') + t.equal(await version('pre', { path, pkg, gitTagVersion: true }), '2.1.1-0') t.match(actionLog, [ ['run-script', 'preversion', { npm_old_version: '2.1.1', npm_new_version: '2.1.1-0' }], ['write-json', path + '/package.json', pkg], @@ -127,7 +126,7 @@ t.test('test out bumping the version in all the ways', async t => { t.equal(pkg.version, '2.1.1-0') }) await t.test('pre with preid', async t => { - t.equal(await version('pre', { path, log, preid: 'alpha', pkg, gitTagVersion: true }), + t.equal(await version('pre', { path, preid: 'alpha', pkg, gitTagVersion: true }), '2.1.1-alpha.0') t.match(actionLog, [ ['run-script', 'preversion', { npm_old_version: '2.1.1-0', @@ -145,7 +144,7 @@ t.test('test out bumping the version in all the ways', async t => { t.equal(pkg.version, '2.1.1-alpha.0') }) await t.test('skips git tag when gitTagVersion is false', async t => { - t.equal(await version('minor', { path, log, pkg, ignoreScripts: true, gitTagVersion: false }), + t.equal(await version('minor', { path, pkg, ignoreScripts: true, gitTagVersion: false }), '2.2.0') t.match(actionLog, [ ['write-json', path + '/package.json', pkg], @@ -155,7 +154,7 @@ t.test('test out bumping the version in all the ways', async t => { t.equal(pkg.version, '2.2.0') }) await t.test('explicit version', async t => { - t.equal(await version('=v3.2.1', { path, log, pkg, gitTagVersion: true }), '3.2.1') + t.equal(await version('=v3.2.1', { path, pkg, gitTagVersion: true }), '3.2.1') t.match(actionLog, [ ['run-script', 'preversion', { npm_old_version: '2.2.0', npm_new_version: '3.2.1' }], ['write-json', path + '/package.json', pkg], @@ -170,14 +169,14 @@ t.test('test out bumping the version in all the ways', async t => { t.equal(pkg.version, '3.2.1') }) await t.test('invalid version', async t => { - await t.rejects(version('invalid version', { path, log, pkg }), { + await t.rejects(version('invalid version', { path, pkg }), { message: 'Invalid version: invalid version', current: '3.2.1', requested: 'invalid version', }) }) await t.test('same version, not allowed', async t => { - await t.rejects(version('=v3.2.1', { path, log, pkg }), { + await t.rejects(version('=v3.2.1', { path, pkg }), { message: 'Version not changed', current: '3.2.1', requested: '=v3.2.1', @@ -186,7 +185,7 @@ t.test('test out bumping the version in all the ways', async t => { }) await t.test('same version, is allowed', async t => { t.equal(await version('=v3.2.1', - { path, log, pkg, allowSameVersion: true, gitTagVersion: true }), '3.2.1') + { path, pkg, allowSameVersion: true, gitTagVersion: true }), '3.2.1') t.match(actionLog, [ ['run-script', 'preversion', { npm_old_version: '3.2.1', npm_new_version: '3.2.1' }], ['write-json', path + '/package.json', pkg], @@ -201,7 +200,7 @@ t.test('test out bumping the version in all the ways', async t => { t.equal(pkg.version, '3.2.1') }) await t.test('from git', async t => { - t.equal(await version('from-git', { path, log, pkg, gitTagVersion: true }), '1.2.3') + t.equal(await version('from-git', { path, pkg, gitTagVersion: true }), '1.2.3') t.match(actionLog, [ ['retrieve-tag', { path, pkg }], ['run-script', 'preversion', { npm_old_version: '3.2.1', npm_new_version: '1.2.3' }], @@ -218,7 +217,7 @@ t.test('test out bumping the version in all the ways', async t => { }) await t.test('no current version', async t => { delete pkg.version - t.equal(await version('2.3.4', { path, log, pkg, gitTagVersion: true }), '2.3.4') + t.equal(await version('2.3.4', { path, pkg, gitTagVersion: true }), '2.3.4') t.match(actionLog, [ ['run-script', 'preversion', { npm_old_version: '0.0.0', npm_new_version: '2.3.4' }], ['write-json', path + '/package.json', pkg], @@ -241,7 +240,7 @@ t.test('test out bumping the version in all the ways', async t => { }) const path = `${dir}/not-git` await t.test('major', async t => { - t.equal(await version('major', { path, log, pkg }), '2.0.0') + t.equal(await version('major', { path, pkg }), '2.0.0') t.match(actionLog, [ ['run-script', 'preversion', { npm_old_version: '1.2.0', npm_new_version: '2.0.0' }], ['write-json', path + '/package.json', pkg], @@ -253,7 +252,7 @@ t.test('test out bumping the version in all the ways', async t => { t.equal(pkg.version, '2.0.0') }) await t.test('minor (ignore scripts)', async t => { - t.equal(await version('minor', { path, log, pkg, ignoreScripts: true }), '2.1.0') + t.equal(await version('minor', { path, pkg, ignoreScripts: true }), '2.1.0') t.match(actionLog, [ ['write-json', path + '/package.json', pkg], ['write-json', path + '/npm-shrinkwrap.json', pkg], @@ -262,7 +261,7 @@ t.test('test out bumping the version in all the ways', async t => { t.equal(pkg.version, '2.1.0') }) await t.test('patch', async t => { - t.equal(await version('patch', { path, log, pkg }), '2.1.1') + t.equal(await version('patch', { path, pkg }), '2.1.1') t.match(actionLog, [ ['run-script', 'preversion', { npm_old_version: '2.1.0', npm_new_version: '2.1.1' }], ['write-json', path + '/package.json', pkg], @@ -274,7 +273,7 @@ t.test('test out bumping the version in all the ways', async t => { t.equal(pkg.version, '2.1.1') }) await t.test('pre', async t => { - t.equal(await version('pre', { path, log, pkg }), '2.1.1-0') + t.equal(await version('pre', { path, pkg }), '2.1.1-0') t.match(actionLog, [ ['run-script', 'preversion', { npm_old_version: '2.1.1', npm_new_version: '2.1.1-0' }], ['write-json', path + '/package.json', pkg], @@ -286,7 +285,7 @@ t.test('test out bumping the version in all the ways', async t => { t.equal(pkg.version, '2.1.1-0') }) await t.test('pre with preid', async t => { - t.equal(await version('pre', { path, log, preid: 'alpha', pkg }), '2.1.1-alpha.0') + t.equal(await version('pre', { path, preid: 'alpha', pkg }), '2.1.1-alpha.0') t.match(actionLog, [ ['run-script', 'preversion', { npm_old_version: '2.1.1-0', npm_new_version: '2.1.1-alpha.0' }], @@ -300,7 +299,7 @@ t.test('test out bumping the version in all the ways', async t => { t.equal(pkg.version, '2.1.1-alpha.0') }) await t.test('explicit version', async t => { - t.equal(await version('=v3.2.1', { path, log, pkg }), '3.2.1') + t.equal(await version('=v3.2.1', { path, pkg }), '3.2.1') t.match(actionLog, [ ['run-script', 'preversion', { npm_old_version: '2.1.1-alpha.0', npm_new_version: '3.2.1' }], @@ -314,14 +313,14 @@ t.test('test out bumping the version in all the ways', async t => { t.equal(pkg.version, '3.2.1') }) await t.test('invalid version', async t => { - await t.rejects(version('invalid version', { path, log, pkg }), { + await t.rejects(version('invalid version', { path, pkg }), { message: 'Invalid version: invalid version', current: '3.2.1', requested: 'invalid version', }) }) await t.test('same version, not allowed', async t => { - await t.rejects(version('=v3.2.1', { path, log, pkg }), { + await t.rejects(version('=v3.2.1', { path, pkg }), { message: 'Version not changed', current: '3.2.1', requested: '=v3.2.1', @@ -329,7 +328,7 @@ t.test('test out bumping the version in all the ways', async t => { }) }) await t.test('same version, is allowed', async t => { - t.equal(await version('=v3.2.1', { path, log, pkg, allowSameVersion: true }), '3.2.1') + t.equal(await version('=v3.2.1', { path, pkg, allowSameVersion: true }), '3.2.1') t.match(actionLog, [ ['run-script', 'preversion', { npm_old_version: '3.2.1', npm_new_version: '3.2.1' }, { banner: true }], @@ -345,7 +344,7 @@ t.test('test out bumping the version in all the ways', async t => { }) await t.test('same version, is allowed (silent mode)', async t => { t.equal(await version('=v3.2.1', - { path, log: { ...log, level: 'silent' }, pkg, allowSameVersion: true }), '3.2.1') + { path, silent: true, pkg, allowSameVersion: true }), '3.2.1') t.match(actionLog, [ ['run-script', 'preversion', { npm_old_version: '3.2.1', npm_new_version: '3.2.1' }, { banner: false }], @@ -360,7 +359,7 @@ t.test('test out bumping the version in all the ways', async t => { t.equal(pkg.version, '3.2.1') }) await t.test('from git', async t => { - await t.rejects(version('from-git', { path, log, pkg }), { + await t.rejects(version('from-git', { path, pkg }), { message: 'not a git dir', }) }) From ce1c2bf4bade53df66efff03415d29a828a3d47a Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Mon, 21 Feb 2022 21:58:12 -0700 Subject: [PATCH 26/43] chore(cli): remove log option from being passed anywhere --- lib/commands/access.js | 2 - lib/commands/adduser.js | 1 - lib/commands/ci.js | 3 +- lib/commands/dedupe.js | 2 - lib/commands/deprecate.js | 3 - lib/commands/diff.js | 2 - lib/commands/dist-tag.js | 1 - lib/commands/doctor.js | 3 +- lib/commands/exec.js | 2 - lib/commands/fund.js | 2 - lib/commands/hook.js | 10 ++-- lib/commands/init.js | 1 - lib/commands/install.js | 3 +- lib/commands/link.js | 6 -- lib/commands/logout.js | 1 - lib/commands/org.js | 8 +-- lib/commands/owner.js | 2 - lib/commands/ping.js | 2 +- lib/commands/profile.js | 8 +-- lib/commands/prune.js | 2 - lib/commands/publish.js | 6 +- lib/commands/run-script.js | 6 +- lib/commands/star.js | 4 +- lib/commands/team.js | 15 +++-- lib/commands/token.js | 2 +- lib/commands/uninstall.js | 2 - lib/commands/unpublish.js | 7 +-- lib/commands/update.js | 1 - lib/commands/whoami.js | 3 +- lib/npm.js | 6 +- lib/utils/config/definitions.js | 3 + lib/utils/display.js | 4 +- lib/utils/exit-handler.js | 6 +- lib/utils/reify-output.js | 6 +- lib/utils/update-notifier.js | 3 +- .../test/lib/utils/exit-handler.js.test.cjs | 8 +-- test/fixtures/mock-npm.js | 53 ++++++++++------ test/fixtures/sandbox.js | 45 +++++--------- test/lib/commands/access.js | 5 +- test/lib/commands/adduser.js | 7 --- test/lib/commands/deprecate.js | 7 --- test/lib/commands/diff.js | 3 +- test/lib/commands/dist-tag.js | 10 ---- test/lib/commands/doctor.js | 12 ++-- test/lib/commands/hook.js | 47 +++++---------- test/lib/commands/logout.js | 9 +-- test/lib/commands/org.js | 41 ++++--------- test/lib/commands/owner.js | 26 ++------ test/lib/commands/ping.js | 9 +-- test/lib/commands/publish.js | 60 ++++++------------- test/lib/commands/run-script.js | 28 ++++----- test/lib/commands/star.js | 6 +- test/lib/commands/team.js | 21 ++++--- test/lib/commands/unpublish.js | 7 +-- test/lib/commands/update.js | 10 +--- test/lib/utils/config/definitions.js | 9 +++ test/lib/utils/exit-handler.js | 6 +- test/lib/utils/reify-output.js | 11 ++-- test/lib/utils/update-notifier.js | 3 +- 59 files changed, 223 insertions(+), 358 deletions(-) diff --git a/lib/commands/access.js b/lib/commands/access.js index 7d3930dacbce9..206d6de9c22c4 100644 --- a/lib/commands/access.js +++ b/lib/commands/access.js @@ -3,7 +3,6 @@ const path = require('path') const libaccess = require('libnpmaccess') const readPackageJson = require('read-package-json-fast') -const log = require('../utils/log-shim.js') const otplease = require('../utils/otplease.js') const getIdentity = require('../utils/get-identity.js') const BaseCommand = require('../base-command.js') @@ -79,7 +78,6 @@ class Access extends BaseCommand { return this[cmd](args, { ...this.npm.flatOptions, - log, }) } diff --git a/lib/commands/adduser.js b/lib/commands/adduser.js index 1cf70fffbf541..cbeaaaf0f28be 100644 --- a/lib/commands/adduser.js +++ b/lib/commands/adduser.js @@ -31,7 +31,6 @@ class AddUser extends BaseCommand { creds, registry, scope, - log, }) await this.updateConfig({ diff --git a/lib/commands/ci.js b/lib/commands/ci.js index 5e862a473a70f..e054bee51679c 100644 --- a/lib/commands/ci.js +++ b/lib/commands/ci.js @@ -40,7 +40,6 @@ class CI extends ArboristWorkspaceCmd { ...this.npm.flatOptions, packageLock: true, // npm ci should never skip lock files path: where, - log, save: false, // npm ci should never modify the lockfile or package.json workspaces: this.workspaceNames, } @@ -101,7 +100,7 @@ class CI extends ArboristWorkspaceCmd { scriptShell, stdio: 'inherit', stdioString: true, - banner: log.level !== 'silent', + banner: !this.npm.silent, event, }) } diff --git a/lib/commands/dedupe.js b/lib/commands/dedupe.js index 1c270249adb3f..4662ce3241b24 100644 --- a/lib/commands/dedupe.js +++ b/lib/commands/dedupe.js @@ -1,7 +1,6 @@ // dedupe duplicated packages, or find them in the tree const Arborist = require('@npmcli/arborist') const reifyFinish = require('../utils/reify-finish.js') -const log = require('../utils/log-shim.js') const ArboristWorkspaceCmd = require('../arborist-cmd.js') @@ -40,7 +39,6 @@ class Dedupe extends ArboristWorkspaceCmd { const where = this.npm.prefix const opts = { ...this.npm.flatOptions, - log, path: where, dryRun, save, diff --git a/lib/commands/deprecate.js b/lib/commands/deprecate.js index 5505b9bf77cf7..839e974caf09b 100644 --- a/lib/commands/deprecate.js +++ b/lib/commands/deprecate.js @@ -1,5 +1,4 @@ const fetch = require('npm-registry-fetch') -const log = require('../utils/log-shim.js') const otplease = require('../utils/otplease.js') const npa = require('npm-package-arg') const semver = require('semver') @@ -51,7 +50,6 @@ class Deprecate extends BaseCommand { ...this.npm.flatOptions, spec: p, query: { write: true }, - log, }) Object.keys(packument.versions) @@ -66,7 +64,6 @@ class Deprecate extends BaseCommand { method: 'PUT', body: packument, ignoreBody: true, - log, })) } } diff --git a/lib/commands/diff.js b/lib/commands/diff.js index b3855aa08f3f1..d737a58dc43d8 100644 --- a/lib/commands/diff.js +++ b/lib/commands/diff.js @@ -61,7 +61,6 @@ class Diff extends BaseCommand { ...this.npm.flatOptions, diffFiles: args, where: this.top, - log, }) return this.npm.output(res) } @@ -194,7 +193,6 @@ class Diff extends BaseCommand { const packument = await pacote.packument(spec, { ...this.npm.flatOptions, preferOnline: true, - log, }) bSpec = pickManifest( packument, diff --git a/lib/commands/dist-tag.js b/lib/commands/dist-tag.js index e2b013206d3aa..bb36f3f72bfb2 100644 --- a/lib/commands/dist-tag.js +++ b/lib/commands/dist-tag.js @@ -31,7 +31,6 @@ class DistTag extends BaseCommand { async exec ([cmdName, pkg, tag]) { const opts = { ...this.npm.flatOptions, - log, } if (['add', 'a', 'set', 's'].includes(cmdName)) { diff --git a/lib/commands/doctor.js b/lib/commands/doctor.js index 47a522eb676d0..508faa57aa5e9 100644 --- a/lib/commands/doctor.js +++ b/lib/commands/doctor.js @@ -125,8 +125,7 @@ class Doctor extends BaseCommand { stringLength: s => ansiTrim(s).length, } - const silent = log.levels[log.level] > log.levels.error - if (!silent) { + if (!this.npm.silent) { this.npm.output(table(outTable, tableOpts)) if (!allOk) { console.error('') diff --git a/lib/commands/exec.js b/lib/commands/exec.js index 61a6d965954aa..52fb1f8eb7229 100644 --- a/lib/commands/exec.js +++ b/lib/commands/exec.js @@ -1,7 +1,6 @@ const libexec = require('libnpmexec') const BaseCommand = require('../base-command.js') const getLocationMsg = require('../exec/get-workspace-location-msg.js') -const log = require('../utils/log-shim') // it's like this: // @@ -77,7 +76,6 @@ class Exec extends BaseCommand { call, localBin, locationMsg, - log, globalBin, output, packages, diff --git a/lib/commands/fund.js b/lib/commands/fund.js index 47a51c33a6841..787a5193f0155 100644 --- a/lib/commands/fund.js +++ b/lib/commands/fund.js @@ -5,7 +5,6 @@ const pacote = require('pacote') const semver = require('semver') const npa = require('npm-package-arg') const { depth } = require('treeverse') -const log = require('../utils/log-shim.js') const { readTree: getFundingInfo, normalizeFunding, isValidFunding } = require('libnpmfund') const completion = require('../utils/completion/installed-deep.js') @@ -69,7 +68,6 @@ class Fund extends ArboristWorkspaceCmd { // TODO: add !workspacesEnabled option handling to libnpmfund const fundingInfo = getFundingInfo(tree, { ...this.flatOptions, - log, workspaces: this.workspaceNames, }) diff --git a/lib/commands/hook.js b/lib/commands/hook.js index c99a99585897a..2ff6ac01ce527 100644 --- a/lib/commands/hook.js +++ b/lib/commands/hook.js @@ -2,7 +2,6 @@ const hookApi = require('libnpmhook') const otplease = require('../utils/otplease.js') const relativeDate = require('tiny-relative-date') const Table = require('cli-table3') -const log = require('../utils/log-shim.js') const BaseCommand = require('../base-command.js') class Hook extends BaseCommand { @@ -23,7 +22,6 @@ class Hook extends BaseCommand { async exec (args) { return otplease({ ...this.npm.flatOptions, - log, }, (opts) => { switch (args[0]) { case 'add': @@ -48,7 +46,7 @@ class Hook extends BaseCommand { } else if (opts.parseable) { this.npm.output(Object.keys(hook).join('\t')) this.npm.output(Object.keys(hook).map(k => hook[k]).join('\t')) - } else if (!opts.silent && opts.loglevel !== 'silent') { + } else if (!this.npm.silent) { this.npm.output(`+ ${this.hookName(hook)} ${ opts.unicode ? ' ➜ ' : ' -> ' } ${hook.endpoint}`) @@ -66,7 +64,7 @@ class Hook extends BaseCommand { }) } else if (!hooks.length) { this.npm.output("You don't have any hooks configured yet.") - } else if (!opts.silent && opts.loglevel !== 'silent') { + } else if (!this.npm.silent) { if (hooks.length === 1) { this.npm.output('You have one hook configured.') } else { @@ -103,7 +101,7 @@ class Hook extends BaseCommand { } else if (opts.parseable) { this.npm.output(Object.keys(hook).join('\t')) this.npm.output(Object.keys(hook).map(k => hook[k]).join('\t')) - } else if (!opts.silent && opts.loglevel !== 'silent') { + } else if (!this.npm.silent) { this.npm.output(`- ${this.hookName(hook)} ${ opts.unicode ? ' ✘ ' : ' X ' } ${hook.endpoint}`) @@ -117,7 +115,7 @@ class Hook extends BaseCommand { } else if (opts.parseable) { this.npm.output(Object.keys(hook).join('\t')) this.npm.output(Object.keys(hook).map(k => hook[k]).join('\t')) - } else if (!opts.silent && opts.loglevel !== 'silent') { + } else if (!this.npm.silent) { this.npm.output(`+ ${this.hookName(hook)} ${ opts.unicode ? ' ➜ ' : ' -> ' } ${hook.endpoint}`) diff --git a/lib/commands/init.js b/lib/commands/init.js index 7e8a8f7a5c8ab..367533f8259f5 100644 --- a/lib/commands/init.js +++ b/lib/commands/init.js @@ -114,7 +114,6 @@ class Init extends BaseCommand { color, localBin, locationMsg, - log, globalBin, output, path, diff --git a/lib/commands/install.js b/lib/commands/install.js index a92a5edc5ebb7..61526abb7879b 100644 --- a/lib/commands/install.js +++ b/lib/commands/install.js @@ -147,7 +147,6 @@ class Install extends ArboristWorkspaceCmd { const opts = { ...this.npm.flatOptions, - log, auditLevel: null, path: where, add: args, @@ -173,7 +172,7 @@ class Install extends ArboristWorkspaceCmd { scriptShell, stdio: 'inherit', stdioString: true, - banner: log.level !== 'silent', + banner: !this.npm.silent, event, }) } diff --git a/lib/commands/link.js b/lib/commands/link.js index e8e2c6b349aa9..d656791469a64 100644 --- a/lib/commands/link.js +++ b/lib/commands/link.js @@ -7,7 +7,6 @@ const Arborist = require('@npmcli/arborist') const npa = require('npm-package-arg') const rpj = require('read-package-json-fast') const semver = require('semver') -const log = require('../utils/log-shim.js') const reifyFinish = require('../utils/reify-finish.js') @@ -69,7 +68,6 @@ class Link extends ArboristWorkspaceCmd { const globalOpts = { ...this.npm.flatOptions, path: globalTop, - log, global: true, prune: false, } @@ -118,7 +116,6 @@ class Link extends ArboristWorkspaceCmd { const localArb = new Arborist({ ...this.npm.flatOptions, prune: false, - log, path: this.npm.prefix, save, }) @@ -126,7 +123,6 @@ class Link extends ArboristWorkspaceCmd { ...this.npm.flatOptions, prune: false, path: this.npm.prefix, - log, add: names.map(l => `file:${resolve(globalTop, 'node_modules', l)}`), save, workspaces: this.workspaceNames, @@ -143,12 +139,10 @@ class Link extends ArboristWorkspaceCmd { const arb = new Arborist({ ...this.npm.flatOptions, path: globalTop, - log, global: true, }) await arb.reify({ add, - log, }) await reifyFinish(this.npm, arb) } diff --git a/lib/commands/logout.js b/lib/commands/logout.js index 34fbace583562..aea5e93652b0e 100644 --- a/lib/commands/logout.js +++ b/lib/commands/logout.js @@ -25,7 +25,6 @@ class Logout extends BaseCommand { ...this.npm.flatOptions, method: 'DELETE', ignoreBody: true, - log, }) } else if (auth.isBasicAuth) { log.verbose('logout', `clearing user credentials for ${reg}`) diff --git a/lib/commands/org.js b/lib/commands/org.js index 89859200fed6b..f3d344ca33e3d 100644 --- a/lib/commands/org.js +++ b/lib/commands/org.js @@ -2,7 +2,6 @@ const liborg = require('libnpmorg') const otplease = require('../utils/otplease.js') const Table = require('cli-table3') const BaseCommand = require('../base-command.js') -const log = require('../utils/log-shim.js') class Org extends BaseCommand { static description = 'Manage orgs' @@ -35,7 +34,6 @@ class Org extends BaseCommand { async exec ([cmd, orgname, username, role], cb) { return otplease({ ...this.npm.flatOptions, - log, }, opts => { switch (cmd) { case 'add': @@ -76,7 +74,7 @@ class Org extends BaseCommand { this.npm.output( [memDeets.org.name, memDeets.org.size, memDeets.user, memDeets.role].join('\t') ) - } else if (!opts.silent && opts.loglevel !== 'silent') { + } else if (!this.npm.silent) { this.npm.output( `Added ${memDeets.user} as ${memDeets.role} to ${memDeets.org.name}. You now have ${ memDeets.org.size @@ -118,7 +116,7 @@ class Org extends BaseCommand { } else if (opts.parseable) { this.npm.output(['user', 'org', 'userCount', 'deleted'].join('\t')) this.npm.output([user, org, userCount, true].join('\t')) - } else if (!opts.silent && opts.loglevel !== 'silent') { + } else if (!this.npm.silent) { this.npm.output( `Successfully removed ${user} from ${org}. You now have ${userCount} member${ userCount === 1 ? '' : 's' @@ -149,7 +147,7 @@ class Org extends BaseCommand { Object.keys(roster).forEach(user => { this.npm.output([user, roster[user]].join('\t')) }) - } else if (!opts.silent && opts.loglevel !== 'silent') { + } else if (!this.npm.silent) { const table = new Table({ head: ['user', 'role'] }) Object.keys(roster) .sort() diff --git a/lib/commands/owner.js b/lib/commands/owner.js index 7b76b7be42ec6..effaaa6a53d3a 100644 --- a/lib/commands/owner.js +++ b/lib/commands/owner.js @@ -59,7 +59,6 @@ class Owner extends BaseCommand { async exec ([action, ...args]) { const opts = { ...this.npm.flatOptions, - log, } switch (action) { case 'ls': @@ -198,7 +197,6 @@ class Owner extends BaseCommand { method: 'PUT', body, spec, - log, }) }) diff --git a/lib/commands/ping.js b/lib/commands/ping.js index 27089be4e1714..5a651c4a6ab09 100644 --- a/lib/commands/ping.js +++ b/lib/commands/ping.js @@ -10,7 +10,7 @@ class Ping extends BaseCommand { async exec (args) { log.notice('PING', this.npm.config.get('registry')) const start = Date.now() - const details = await pingUtil({ ...this.npm.flatOptions, log }) + const details = await pingUtil({ ...this.npm.flatOptions }) const time = Date.now() - start log.notice('PONG', `${time}ms`) if (this.npm.config.get('json')) { diff --git a/lib/commands/profile.js b/lib/commands/profile.js index 9786e9ba4d4cf..6b4d1407f7919 100644 --- a/lib/commands/profile.js +++ b/lib/commands/profile.js @@ -108,7 +108,7 @@ class Profile extends BaseCommand { async get (args) { const tfa = 'two-factor auth' const info = await pulseTillDone.withPromise( - npmProfile.get({ ...this.npm.flatOptions, log }) + npmProfile.get({ ...this.npm.flatOptions }) ) if (!info.cidr_whitelist) { @@ -170,7 +170,7 @@ class Profile extends BaseCommand { } async set (args) { - const conf = { ...this.npm.flatOptions, log } + const conf = { ...this.npm.flatOptions } const prop = (args[0] || '').toLowerCase().trim() let value = args.length > 1 ? args.slice(1).join(' ') : null @@ -285,7 +285,7 @@ class Profile extends BaseCommand { if (auth.basic) { log.info('profile', 'Updating authentication to bearer token') const result = await npmProfile.createToken( - auth.basic.password, false, [], { ...this.npm.flatOptions, log } + auth.basic.password, false, [], { ...this.npm.flatOptions } ) if (!result.token) { @@ -309,7 +309,7 @@ class Profile extends BaseCommand { log.info('profile', 'Determine if tfa is pending') const userInfo = await pulseTillDone.withPromise( - npmProfile.get({ ...this.npm.flatOptions, log }) + npmProfile.get({ ...this.npm.flatOptions }) ) const conf = { ...this.npm.flatOptions } diff --git a/lib/commands/prune.js b/lib/commands/prune.js index 5831df62859c2..16c8b6d4329ac 100644 --- a/lib/commands/prune.js +++ b/lib/commands/prune.js @@ -1,6 +1,5 @@ // prune extraneous packages const Arborist = require('@npmcli/arborist') -const log = require('../utils/log-shim.js') const reifyFinish = require('../utils/reify-finish.js') const ArboristWorkspaceCmd = require('../arborist-cmd.js') @@ -15,7 +14,6 @@ class Prune extends ArboristWorkspaceCmd { const opts = { ...this.npm.flatOptions, path: where, - log, workspaces: this.workspaceNames, } const arb = new Arborist(opts) diff --git a/lib/commands/publish.js b/lib/commands/publish.js index 63106c520bd58..d1f0ee743cfcc 100644 --- a/lib/commands/publish.js +++ b/lib/commands/publish.js @@ -55,13 +55,13 @@ class Publish extends BaseCommand { const json = this.npm.config.get('json') const defaultTag = this.npm.config.get('tag') const ignoreScripts = this.npm.config.get('ignore-scripts') - const silent = log.level === 'silent' + const { silent } = this.npm if (semver.validRange(defaultTag)) { throw new Error('Tag name must not be a valid SemVer range: ' + defaultTag.trim()) } - const opts = { ...this.npm.flatOptions, log } + const opts = { ...this.npm.flatOptions } // you can publish name@version, ./foo.tgz, etc. // even though the default is the 'file:.' cwd. @@ -152,7 +152,7 @@ class Publish extends BaseCommand { const results = {} const json = this.npm.config.get('json') - const silent = log.level === 'silent' + const { silent } = this.npm const noop = a => a const color = this.npm.color ? chalk : { green: noop, bold: noop } await this.setWorkspaces(filters) diff --git a/lib/commands/run-script.js b/lib/commands/run-script.js index cd877e0b3dfa4..edba95821b44c 100644 --- a/lib/commands/run-script.js +++ b/lib/commands/run-script.js @@ -116,7 +116,7 @@ class RunScript extends BaseCommand { stdio: 'inherit', stdioString: true, pkg, - banner: log.level !== 'silent', + banner: !this.npm.silent, } for (const [event, args] of events) { @@ -139,7 +139,7 @@ class RunScript extends BaseCommand { } const allScripts = Object.keys(scripts) - if (log.level === 'silent') { + if (this.npm.silent) { return allScripts } @@ -233,7 +233,7 @@ class RunScript extends BaseCommand { async listWorkspaces (args, filters) { await this.setWorkspaces(filters) - if (log.level === 'silent') { + if (this.npm.silent) { return } diff --git a/lib/commands/star.js b/lib/commands/star.js index 4974c39883e43..2d08747aa7719 100644 --- a/lib/commands/star.js +++ b/lib/commands/star.js @@ -29,13 +29,12 @@ class Star extends BaseCommand { const pkgs = args.map(npa) for (const pkg of pkgs) { const [username, fullData] = await Promise.all([ - getIdentity(this.npm, { ...this.npm.flatOptions, log }), + getIdentity(this.npm, { ...this.npm.flatOptions }), fetch.json(pkg.escapedName, { ...this.npm.flatOptions, spec: pkg, query: { write: true }, preferOnline: true, - log, }), ]) @@ -64,7 +63,6 @@ class Star extends BaseCommand { spec: pkg, method: 'PUT', body, - log, }) this.npm.output(show + ' ' + pkg.name) diff --git a/lib/commands/team.js b/lib/commands/team.js index e3fb9b83c5a27..1e13a83f52b09 100644 --- a/lib/commands/team.js +++ b/lib/commands/team.js @@ -1,7 +1,6 @@ const columns = require('cli-columns') const libteam = require('libnpmteam') -const log = require('../utils/log-shim.js') const otplease = require('../utils/otplease.js') const BaseCommand = require('../base-command.js') @@ -43,7 +42,7 @@ class Team extends BaseCommand { // XXX: "description" option to libnpmteam is used as a description of the // team, but in npm's options, this is a boolean meaning "show the // description in npm search output". Hence its being set to null here. - await otplease({ ...this.npm.flatOptions, log }, opts => { + await otplease({ ...this.npm.flatOptions }, opts => { entity = entity.replace(/^@/, '') switch (cmd) { case 'create': return this.create(entity, opts) @@ -73,7 +72,7 @@ class Team extends BaseCommand { })) } else if (opts.parseable) { this.npm.output(`${entity}\tcreated`) - } else if (!opts.silent && opts.loglevel !== 'silent') { + } else if (!this.npm.silent) { this.npm.output(`+@${entity}`) } } @@ -87,7 +86,7 @@ class Team extends BaseCommand { })) } else if (opts.parseable) { this.npm.output(`${entity}\tdeleted`) - } else if (!opts.silent && opts.loglevel !== 'silent') { + } else if (!this.npm.silent) { this.npm.output(`-@${entity}`) } } @@ -102,7 +101,7 @@ class Team extends BaseCommand { })) } else if (opts.parseable) { this.npm.output(`${user}\t${entity}\tadded`) - } else if (!opts.silent && opts.loglevel !== 'silent') { + } else if (!this.npm.silent) { this.npm.output(`${user} added to @${entity}`) } } @@ -117,7 +116,7 @@ class Team extends BaseCommand { })) } else if (opts.parseable) { this.npm.output(`${user}\t${entity}\tremoved`) - } else if (!opts.silent && opts.loglevel !== 'silent') { + } else if (!this.npm.silent) { this.npm.output(`${user} removed from @${entity}`) } } @@ -128,7 +127,7 @@ class Team extends BaseCommand { this.npm.output(JSON.stringify(users, null, 2)) } else if (opts.parseable) { this.npm.output(users.join('\n')) - } else if (!opts.silent && opts.loglevel !== 'silent') { + } else if (!this.npm.silent) { const plural = users.length === 1 ? '' : 's' const more = users.length === 0 ? '' : ':\n' this.npm.output(`\n@${entity} has ${users.length} user${plural}${more}`) @@ -142,7 +141,7 @@ class Team extends BaseCommand { this.npm.output(JSON.stringify(teams, null, 2)) } else if (opts.parseable) { this.npm.output(teams.join('\n')) - } else if (!opts.silent && opts.loglevel !== 'silent') { + } else if (!this.npm.silent) { const plural = teams.length === 1 ? '' : 's' const more = teams.length === 0 ? '' : ':\n' this.npm.output(`\n@${entity} has ${teams.length} team${plural}${more}`) diff --git a/lib/commands/token.js b/lib/commands/token.js index cfb5ab666565a..df80f1afec44e 100644 --- a/lib/commands/token.js +++ b/lib/commands/token.js @@ -168,7 +168,7 @@ class Token extends BaseCommand { } config () { - const conf = { ...this.npm.flatOptions, log } + const conf = { ...this.npm.flatOptions } const creds = this.npm.config.getCredentialsByURI(conf.registry) if (creds.token) { conf.auth = { token: creds.token } diff --git a/lib/commands/uninstall.js b/lib/commands/uninstall.js index b40c59bda4419..587968e3bbba9 100644 --- a/lib/commands/uninstall.js +++ b/lib/commands/uninstall.js @@ -1,5 +1,4 @@ const { resolve } = require('path') -const log = require('../utils/log-shim.js') const Arborist = require('@npmcli/arborist') const rpj = require('read-package-json-fast') @@ -49,7 +48,6 @@ class Uninstall extends ArboristWorkspaceCmd { const opts = { ...this.npm.flatOptions, path, - log, rm: args, workspaces: this.workspaceNames, } diff --git a/lib/commands/unpublish.js b/lib/commands/unpublish.js index d8410cc13481b..c848b6389d1b8 100644 --- a/lib/commands/unpublish.js +++ b/lib/commands/unpublish.js @@ -32,7 +32,7 @@ class Unpublish extends BaseCommand { return [] } - const opts = { ...this.npm.flatOptions, log } + const opts = { ...this.npm.flatOptions } const username = await getIdentity(this.npm, { ...opts }).catch(() => null) if (!username) { return [] @@ -68,8 +68,7 @@ class Unpublish extends BaseCommand { const spec = args.length && npa(args[0]) const force = this.npm.config.get('force') - const loglevel = this.npm.config.get('loglevel') - const silent = loglevel === 'silent' + const { silent } = this.npm const dryRun = this.npm.config.get('dry-run') let pkgName let pkgVersion @@ -84,7 +83,7 @@ class Unpublish extends BaseCommand { ) } - const opts = { ...this.npm.flatOptions, log } + const opts = { ...this.npm.flatOptions } if (!spec || path.resolve(spec.name) === this.npm.localPrefix) { // if there's a package.json in the current folder, then // read the package name and version out of that. diff --git a/lib/commands/update.js b/lib/commands/update.js index c55d7cf575d88..025ebbaf815f0 100644 --- a/lib/commands/update.js +++ b/lib/commands/update.js @@ -54,7 +54,6 @@ class Update extends ArboristWorkspaceCmd { const opts = { ...this.npm.flatOptions, - log, path: where, save, workspaces: this.workspaceNames, diff --git a/lib/commands/whoami.js b/lib/commands/whoami.js index 07ebe2e244753..154cc870391ba 100644 --- a/lib/commands/whoami.js +++ b/lib/commands/whoami.js @@ -1,5 +1,4 @@ const getIdentity = require('../utils/get-identity.js') -const log = require('../utils/log-shim.js') const BaseCommand = require('../base-command.js') class Whoami extends BaseCommand { @@ -8,7 +7,7 @@ class Whoami extends BaseCommand { static params = ['registry'] async exec (args) { - const username = await getIdentity(this.npm, { ...this.npm.flatOptions, log }) + const username = await getIdentity(this.npm, { ...this.npm.flatOptions }) this.npm.output( this.npm.config.get('json') ? JSON.stringify(username) : username ) diff --git a/lib/npm.js b/lib/npm.js index 4d22b531a4662..ce8f6aee8f575 100644 --- a/lib/npm.js +++ b/lib/npm.js @@ -52,7 +52,6 @@ class Npm extends EventEmitter { definitions, flatten, shorthands, - log, }) this[_title] = process.title this.updateNotification = null @@ -251,6 +250,7 @@ class Npm extends EventEmitter { // Use logColor since that is based on stderr color: this.logColor, progress: this.flatOptions.progress, + silent: this.silent, timing: this.config.get('timing'), loglevel: this.config.get('loglevel'), unicode: this.config.get('unicode'), @@ -300,6 +300,10 @@ class Npm extends EventEmitter { return this.flatOptions.logColor } + get silent () { + return this.flatOptions.silent + } + get lockfileVersion () { return 2 } diff --git a/lib/utils/config/definitions.js b/lib/utils/config/definitions.js index 79e686ca75134..c5c129eb3d495 100644 --- a/lib/utils/config/definitions.js +++ b/lib/utils/config/definitions.js @@ -1222,6 +1222,9 @@ define('loglevel', { See also the \`foreground-scripts\` config. `, + flatten (key, obj, flatOptions) { + flatOptions.silent = obj[key] === 'silent' + }, }) define('logs-max', { diff --git a/lib/utils/display.js b/lib/utils/display.js index aae51e8806f8a..a19f72297e838 100644 --- a/lib/utils/display.js +++ b/lib/utils/display.js @@ -35,6 +35,7 @@ class Display { loglevel, unicode, progress, + silent, heading = 'npm', } = config @@ -59,8 +60,7 @@ class Display { log.disableUnicode() } - // if it's more than error, don't show progress - const silent = log.levels[log.level] > log.levels.error + // if it's silent, don't show progress if (progress && !silent) { log.enableProgress() } else { diff --git a/lib/utils/exit-handler.js b/lib/utils/exit-handler.js index 22c774101751b..6186ea81dcc02 100644 --- a/lib/utils/exit-handler.js +++ b/lib/utils/exit-handler.js @@ -49,8 +49,8 @@ process.on('exit', code => { // npm must be loaded to know where the log file was written if (showLogFileMessage && hasLoadedNpm) { - // just a line break - if (log.levels[log.level] <= log.levels.error) { + // just a line break if not in silent mode + if (!npm.silent) { console.error('') } @@ -175,7 +175,7 @@ const exitHandler = err => { log.verbose('exit', exitCode || 0) - showLogFileMessage = log.level === 'silent' || noLogMessage + showLogFileMessage = (hasLoadedNpm && npm.silent) || noLogMessage ? false : !!exitCode diff --git a/lib/utils/reify-output.js b/lib/utils/reify-output.js index b4114c1b2fe04..b5c3a593b8db0 100644 --- a/lib/utils/reify-output.js +++ b/lib/utils/reify-output.js @@ -27,7 +27,7 @@ const reifyOutput = (npm, arb) => { // don't print any info in --silent mode, but we still need to // set the exitCode properly from the audit report, if we have one. - if (log.levels[log.level] > log.levels.error) { + if (npm.silent) { getAuditReport(npm, auditReport) return } @@ -88,7 +88,7 @@ const reifyOutput = (npm, arb) => { // at the end if there's still stuff, because it's silly for `npm audit` // to tell you to run `npm audit` for details. otherwise, use the summary // report. if we get here, we know it's not quiet or json. -// If the loglevel is set higher than 'error', then we just run the report +// If the loglevel is silent, then we just run the report // to get the exitCode set appropriately. const printAuditReport = (npm, report) => { const res = getAuditReport(npm, report) @@ -105,7 +105,7 @@ const getAuditReport = (npm, report) => { // when in silent mode, we print nothing. the JSON output is // going to just JSON.stringify() the report object. - const reporter = log.levels[log.level] > log.levels.error ? 'quiet' + const reporter = npm.silent ? 'quiet' : npm.flatOptions.json ? 'quiet' : npm.command !== 'audit' ? 'install' : 'detail' diff --git a/lib/utils/update-notifier.js b/lib/utils/update-notifier.js index 44b6a5433c09a..875c3a99a2579 100644 --- a/lib/utils/update-notifier.js +++ b/lib/utils/update-notifier.js @@ -10,7 +10,6 @@ const { promisify } = require('util') const stat = promisify(require('fs').stat) const writeFile = promisify(require('fs').writeFile) const { resolve } = require('path') -const log = require('./log-shim.js') const isGlobalNpmUpdate = npm => { return npm.flatOptions.global && @@ -62,7 +61,7 @@ const updateNotifier = async (npm, spec = 'latest') => { // if they're currently using a prerelease, nudge to the next prerelease // otherwise, nudge to latest. - const useColor = log.useColor() + const useColor = npm.logColor const mani = await pacote.manifest(`npm@${spec}`, { // always prefer latest, even if doing --tag=whatever on the cmd diff --git a/tap-snapshots/test/lib/utils/exit-handler.js.test.cjs b/tap-snapshots/test/lib/utils/exit-handler.js.test.cjs index 523aabca29b50..0aaf235fd14b6 100644 --- a/tap-snapshots/test/lib/utils/exit-handler.js.test.cjs +++ b/tap-snapshots/test/lib/utils/exit-handler.js.test.cjs @@ -26,10 +26,10 @@ exports[`test/lib/utils/exit-handler.js TAP handles unknown error with logs and 32 error ERR SUMMARY Unknown error 33 error ERR DETAIL Unknown error 34 verbose exit 1 -35 timing npm Completed in {TIME}ms -36 verbose code 1 -37 error A complete log of this run can be found in: -37 error {CWD}/test/lib/utils/tap-testdir-exit-handler-handles-unknown-error-with-logs-and-debug-file/cache/_logs/{DATE}-debug-0.log +36 timing npm Completed in {TIME}ms +37 verbose code 1 +38 error A complete log of this run can be found in: +38 error {CWD}/test/lib/utils/tap-testdir-exit-handler-handles-unknown-error-with-logs-and-debug-file/cache/_logs/{DATE}-debug-0.log ` exports[`test/lib/utils/exit-handler.js TAP handles unknown error with logs and debug file > logs 1`] = ` diff --git a/test/fixtures/mock-npm.js b/test/fixtures/mock-npm.js index c3dc47f5dde4f..4846d9a485841 100644 --- a/test/fixtures/mock-npm.js +++ b/test/fixtures/mock-npm.js @@ -31,6 +31,18 @@ const RealMockNpm = (t, otherMocks = {}) => { return mock } +const setLoglevel = (t, loglevel, reset = true) => { + if (t && reset) { + const _level = log.level + t.teardown(() => log.level = _level) + } + + if (loglevel) { + // Set log level on the npmlog singleton and shared across everything + log.level = loglevel + } +} + // Resolve some options to a function call with supplied args const result = (fn, ...args) => typeof fn === 'function' ? fn(...args) : fn @@ -62,14 +74,8 @@ const LoadMockNpm = async (t, { throw new Error('cant `load` without `init`') } - const _level = log.level - t.teardown(() => log.level = _level) - - if (config.loglevel) { - // Set log level as early as possible since it is set - // on the npmlog singleton and shared across everything - log.level = config.loglevel - } + // Set log level as early as possible since + setLoglevel(t, config.loglevel) const dir = t.testdir({ root: testdir, cache: {} }) const prefix = path.join(dir, 'root') @@ -93,11 +99,9 @@ const LoadMockNpm = async (t, { for (const [k, v] of Object.entries(result(config, { npm, prefix, cache }))) { npm.config.set(k, v) } - if (config.loglevel) { - // Set global loglevel *again* since it possibly got reset during load - // XXX: remove with npmlog - log.level = config.loglevel - } + // Set global loglevel *again* since it possibly got reset during load + // XXX: remove with npmlog + setLoglevel(t, config.loglevel, false) npm.prefix = prefix npm.cache = cache } @@ -129,7 +133,7 @@ const realConfig = require('../../lib/utils/config') // npm.config You still need a separate flatOptions. Tests should migrate to // using the real npm mock above class MockNpm { - constructor (base = {}) { + constructor (base = {}, t) { this._mockOutputs = [] this.isMockNpm = true this.base = base @@ -150,9 +154,24 @@ class MockNpm { // for now isDefault is going to just return false if a value was defined isDefault: (k) => !Object.prototype.hasOwnProperty.call(config, k), get: (k) => ({ ...realConfig.defaults, ...config })[k], - set: (k, v) => config[k] = v, + set: (k, v) => { + config[k] = v + // mock how real npm derives silent + if (k === 'loglevel') { + this.flatOptions.silent = v === 'silent' + this.silent = v === 'silent' + } + }, list: [{ ...realConfig.defaults, ...config }], } + + if (t && config.loglevel) { + setLoglevel(t, config.loglevel) + } + + if (config.loglevel) { + this.config.set('loglevel', config.loglevel) + } } output (...msg) { @@ -163,8 +182,8 @@ class MockNpm { } } -const FakeMockNpm = (base = {}) => { - return new MockNpm(base) +const FakeMockNpm = (base = {}, t) => { + return new MockNpm(base, t) } module.exports = { diff --git a/test/fixtures/sandbox.js b/test/fixtures/sandbox.js index 701d9cea72397..d51281d41d104 100644 --- a/test/fixtures/sandbox.js +++ b/test/fixtures/sandbox.js @@ -193,6 +193,8 @@ class Sandbox extends EventEmitter { // test.teardown hook teardown () { if (this[_parent]) { + const sandboxProcess = sandboxes.get(this[_parent]) + sandboxProcess.removeAllListeners('log') sandboxes.delete(this[_parent]) } if (this[_npm]) { @@ -211,20 +213,7 @@ class Sandbox extends EventEmitter { return Reflect.get(this, prop, this) } - const actual = Reflect.get(target, prop, receiver) - if (typeof actual === 'function') { - // in node 10.1 there's an interesting bug where if a function on process - // is called without explicitly forcing the 'this' arg to something, we - // get 'Illegal invocation' errors. wrapping function properties in their - // own proxy so that we can make sure the context is right fixes it - return new Proxy(actual, { - apply: (target, context, args) => { - return Reflect.apply(target, _process, args) - }, - }) - } - - return actual + return Reflect.get(target, prop, receiver) } // proxy set handler @@ -278,17 +267,15 @@ class Sandbox extends EventEmitter { ...this[_mocks], ...mockedLogs.logMocks, }) + this.process.on('log', (l, ...args) => { + if (l !== 'pause' && l !== 'resume') { + this[_logs].push([l, ...args]) + } + }) + this[_npm] = new Npm() this[_npm].output = (...args) => this[_output].push(args) await this[_npm].load() - // in some node versions (later 10.x) our executionAsyncId at this point - // will for some reason appear to have been triggered by a different parent - // so immediately after load, if we can see that we lost our ancestry, we - // fix it here with a hammer - if (chain.get(executionAsyncId()) !== this[_parent]) { - chain.set(executionAsyncId(), this[_parent]) - process = this[_proxy] - } const cmd = this[_npm].argv.shift() return this[_npm].exec(cmd, this[_npm].argv) @@ -330,17 +317,15 @@ class Sandbox extends EventEmitter { ...this[_mocks], ...mockedLogs.logMocks, }) + this.process.on('log', (l, ...args) => { + if (l !== 'pause' && l !== 'resume') { + this[_logs].push([l, ...args]) + } + }) + this[_npm] = new Npm() this[_npm].output = (...args) => this[_output].push(args) await this[_npm].load() - // in some node versions (later 10.x) our executionAsyncId at this point - // will for some reason appear to have been triggered by a different parent - // so immediately after load, if we can see that we lost our ancestry, we - // fix it here with a hammer - if (chain.get(executionAsyncId()) !== this[_parent]) { - chain.set(executionAsyncId(), this[_parent]) - process = this[_proxy] - } const impl = await this[_npm].cmd(command) return impl.completion({ diff --git a/test/lib/commands/access.js b/test/lib/commands/access.js index c4e6f3167aa01..298897e4f5ffc 100644 --- a/test/lib/commands/access.js +++ b/test/lib/commands/access.js @@ -75,13 +75,12 @@ t.test('access public on unscoped package', async t => { }) t.test('access public on scoped package', async t => { - t.plan(3) + t.plan(2) const name = '@scoped/npm-access-public-pkg' const { npm } = await loadMockNpm(t, { mocks: { libnpmaccess: { - public: (pkg, { registry, log }) => { - t.ok(log, 'should pass a logger') + public: (pkg, { registry }) => { t.equal(pkg, name, 'should use pkg name ref') t.equal( registry, diff --git a/test/lib/commands/adduser.js b/test/lib/commands/adduser.js index 8a9358f9ab21a..f88508d15a6fe 100644 --- a/test/lib/commands/adduser.js +++ b/test/lib/commands/adduser.js @@ -20,13 +20,6 @@ const authDummy = (npm, options) => { throw new Error('did not pass full flatOptions to auth function') } - if (!options.log) { - // A quick to test to make sure a log gets passed to auth - // XXX: should be refactored with change to real mock npm - // https://github.com/npm/statusboard/issues/411 - throw new Error('pass log to auth') - } - return Promise.resolve({ message: 'success', newCreds: { diff --git a/test/lib/commands/deprecate.js b/test/lib/commands/deprecate.js index aa158cca3a1a1..180629a7488f9 100644 --- a/test/lib/commands/deprecate.js +++ b/test/lib/commands/deprecate.js @@ -2,15 +2,12 @@ const t = require('tap') let getIdentityImpl = () => 'someperson' let npmFetchBody = null -let npmFetchLog = null const npmFetch = async (uri, opts) => { npmFetchBody = opts.body - npmFetchLog = opts.log } npmFetch.json = async (uri, opts) => { - npmFetchLog = opts.log return { versions: { '1.0.0': {}, @@ -87,10 +84,8 @@ t.test('invalid semver range', async t => { t.test('undeprecate', async t => { t.teardown(() => { npmFetchBody = null - npmFetchLog = null }) await deprecate.exec(['foo', '']) - t.ok(npmFetchLog, 'was passed a logger') t.match(npmFetchBody, { versions: { '1.0.0': { deprecated: '' }, @@ -103,11 +98,9 @@ t.test('undeprecate', async t => { t.test('deprecates given range', async t => { t.teardown(() => { npmFetchBody = null - npmFetchLog = null }) await deprecate.exec(['foo@1.0.0', 'this version is deprecated']) - t.ok(npmFetchLog, 'was passed a logger') t.match(npmFetchBody, { versions: { '1.0.0': { diff --git a/test/lib/commands/diff.js b/test/lib/commands/diff.js index f73a543cb4c51..ed0702e3784a6 100644 --- a/test/lib/commands/diff.js +++ b/test/lib/commands/diff.js @@ -61,10 +61,9 @@ const diff = new Diff(npm) t.test('no args', t => { t.test('in a project dir', async t => { - t.plan(4) + t.plan(3) libnpmdiff = async ([a, b], opts) => { - t.ok(opts.log, 'should be passed a logger') t.equal(a, 'foo@latest', 'should have default spec comparison') t.equal(b, `file:${fooPath}`, 'should compare to cwd') t.match(opts, npm.flatOptions, 'should forward flat options') diff --git a/test/lib/commands/dist-tag.js b/test/lib/commands/dist-tag.js index b83c30e9c64ea..eb13c7ff02fbe 100644 --- a/test/lib/commands/dist-tag.js +++ b/test/lib/commands/dist-tag.js @@ -43,7 +43,6 @@ const routeMap = { // XXX overriding this does not appear to do anything, adding t.plan to things // that use it fails the test let npmRegistryFetchMock = (url, opts) => { - npmRegistryFetchLog = opts.log if (url === '/-/package/foo/dist-tags') { throw new Error('no package found') } @@ -51,9 +50,7 @@ let npmRegistryFetchMock = (url, opts) => { return routeMap[url] } -let npmRegistryFetchLog npmRegistryFetchMock.json = async (url, opts) => { - npmRegistryFetchLog = opts.log return routeMap[url] } @@ -86,10 +83,6 @@ const npm = mockNpm({ }) const distTag = new DistTag(npm) -t.afterEach(() => { - npmRegistryFetchLog = null -}) - t.test('ls in current package', async t => { npm.prefix = t.testdir({ 'package.json': JSON.stringify({ @@ -97,7 +90,6 @@ t.test('ls in current package', async t => { }), }) await distTag.exec(['ls']) - t.ok(npmRegistryFetchLog, 'is passed a logger') t.matchSnapshot( result, 'should list available tags for current package' @@ -299,7 +291,6 @@ t.test('add new tag', async t => { }) npmRegistryFetchMock = async (url, opts) => { - t.ok(opts.log, 'is passed a logger') t.equal(opts.method, 'PUT', 'should trigger request to add new tag') t.equal(opts.body, '7.7.7', 'should point to expected version') } @@ -366,7 +357,6 @@ t.test('remove existing tag', async t => { } npm.prefix = t.testdir({}) await distTag.exec(['rm', '@scoped/another', 'c']) - t.ok(npmRegistryFetchLog, 'is passed a logger') t.matchSnapshot(log, 'should log remove info') t.matchSnapshot(result, 'should return success msg') }) diff --git a/test/lib/commands/doctor.js b/test/lib/commands/doctor.js index 51b6111a0ae70..dee2110ff3c89 100644 --- a/test/lib/commands/doctor.js +++ b/test/lib/commands/doctor.js @@ -4,6 +4,7 @@ const { join } = require('path') const fs = require('fs') const ansiTrim = require('../../../lib/utils/ansi-trim.js') const isWindows = require('../../../lib/utils/is-windows.js') +const { fake: mockNpm } = require('../../fixtures/mock-npm') // getuid and getgid do not exist in windows, so we shim them // to return 0, as that is the value that lstat will assign the @@ -61,15 +62,18 @@ const clearLogs = () => { } } -const npm = { +const npm = mockNpm({ flatOptions: { registry: 'https://registry.npmjs.org/', }, + config: { + loglevel: 'info', + }, version: '7.1.0', output: data => { output.push(data) }, -} +}) let latestNpm = npm.version const pacote = { @@ -211,7 +215,7 @@ t.test('node versions', t => { npm.globalDir = dir npm.localBin = dir npm.globalBin = dir - mocks.npmlog.level = 'info' + npm.config.set('loglevel', 'silent') st.teardown(() => { delete npm.cache @@ -220,7 +224,7 @@ t.test('node versions', t => { delete npm.globalDir delete npm.localBin delete npm.globalBin - mocks.npmlog.level = 'error' + npm.config.set('loglevel', 'info') clearLogs() }) diff --git a/test/lib/commands/hook.js b/test/lib/commands/hook.js index a4eee711fe8e0..60a59a3fe7a3b 100644 --- a/test/lib/commands/hook.js +++ b/test/lib/commands/hook.js @@ -1,18 +1,20 @@ const t = require('tap') +const { fake: mockNpm } = require('../../fixtures/mock-npm') const output = [] -const npm = { +const npm = mockNpm({ flatOptions: { json: false, parseable: false, - silent: false, - loglevel: 'info', unicode: false, }, + config: { + loglevel: 'info', + }, output: msg => { output.push(msg) }, -} +}) const pkgTypes = { semver: 'package', @@ -78,7 +80,6 @@ t.test('npm hook add', async t => { await hook.exec(['add', 'semver', 'https://google.com', 'some-secret']) - t.ok(hookArgs.opts.log, 'is passed a logger') t.match( hookArgs, { @@ -102,7 +103,6 @@ t.test('npm hook add - unicode output', async t => { await hook.exec(['add', 'semver', 'https://google.com', 'some-secret']) - t.ok(hookArgs.opts.log, 'is passed a logger') t.match( hookArgs, { @@ -126,7 +126,6 @@ t.test('npm hook add - json output', async t => { await hook.exec(['add', '@npmcli', 'https://google.com', 'some-secret']) - t.ok(hookArgs.opts.log, 'is passed a logger') t.match( hookArgs, { @@ -159,7 +158,6 @@ t.test('npm hook add - parseable output', async t => { await hook.exec(['add', '@npmcli', 'https://google.com', 'some-secret']) - t.ok(hookArgs.opts.log, 'is passed a logger') t.match( hookArgs, { @@ -183,16 +181,15 @@ t.test('npm hook add - parseable output', async t => { }) t.test('npm hook add - silent output', async t => { - npm.flatOptions.silent = true + npm.config.set('loglevel', 'silent') t.teardown(() => { - npm.flatOptions.silent = false + npm.config.set('loglevel', 'info') hookArgs = null output.length = 0 }) await hook.exec(['add', '@npmcli', 'https://google.com', 'some-secret']) - t.ok(hookArgs.opts.log, 'is passed a logger') t.match( hookArgs, { @@ -214,7 +211,6 @@ t.test('npm hook ls', async t => { await hook.exec(['ls']) - t.ok(hookArgs.log, 'is passed a logger') t.match( hookArgs, { @@ -240,7 +236,6 @@ t.test('npm hook ls, no results', async t => { await hook.exec(['ls']) - t.ok(hookArgs.log, 'is passed a logger') t.match( hookArgs, { @@ -270,7 +265,6 @@ t.test('npm hook ls, single result', async t => { await hook.exec(['ls']) - t.ok(hookArgs.log, 'is passed a logger') t.match( hookArgs, { @@ -294,7 +288,6 @@ t.test('npm hook ls - json output', async t => { await hook.exec(['ls']) - t.ok(hookArgs.log, 'is passed a logger') t.match( hookArgs, { @@ -340,7 +333,6 @@ t.test('npm hook ls - parseable output', async t => { await hook.exec(['ls']) - t.ok(hookArgs.log, 'is passed a logger') t.match( hookArgs, { @@ -362,16 +354,15 @@ t.test('npm hook ls - parseable output', async t => { }) t.test('npm hook ls - silent output', async t => { - npm.flatOptions.silent = true + npm.config.set('loglevel', 'silent') t.teardown(() => { - npm.flatOptions.silent = false + npm.config.set('loglevel', 'info') hookArgs = null output.length = 0 }) await hook.exec(['ls']) - t.ok(hookArgs.log, 'is passed a logger') t.match( hookArgs, { @@ -391,7 +382,6 @@ t.test('npm hook rm', async t => { await hook.exec(['rm', '1']) - t.ok(hookArgs.opts.log, 'is passed a logger') t.match( hookArgs, { @@ -413,7 +403,6 @@ t.test('npm hook rm - unicode output', async t => { await hook.exec(['rm', '1']) - t.ok(hookArgs.opts.log, 'is passed a logger') t.match( hookArgs, { @@ -426,16 +415,15 @@ t.test('npm hook rm - unicode output', async t => { }) t.test('npm hook rm - silent output', async t => { - npm.flatOptions.silent = true + npm.config.set('loglevel', 'silent') t.teardown(() => { - npm.flatOptions.silent = false + npm.config.set('loglevel', 'info') hookArgs = null output.length = 0 }) await hook.exec(['rm', '1']) - t.ok(hookArgs.opts.log, 'is passed a logger') t.match( hookArgs, { @@ -457,7 +445,6 @@ t.test('npm hook rm - json output', async t => { await hook.exec(['rm', '1']) - t.ok(hookArgs.opts.log, 'is passed a logger') t.match( hookArgs, { @@ -488,7 +475,6 @@ t.test('npm hook rm - parseable output', async t => { await hook.exec(['rm', '1']) - t.ok(hookArgs.opts.log, 'is passed a logger') t.match( hookArgs, { @@ -515,7 +501,6 @@ t.test('npm hook update', async t => { await hook.exec(['update', '1', 'https://google.com', 'some-secret']) - t.ok(hookArgs.opts.log, 'is passed a logger') t.match( hookArgs, { @@ -539,7 +524,6 @@ t.test('npm hook update - unicode', async t => { await hook.exec(['update', '1', 'https://google.com', 'some-secret']) - t.ok(hookArgs.opts.log, 'is passed a logger') t.match( hookArgs, { @@ -563,7 +547,6 @@ t.test('npm hook update - json output', async t => { await hook.exec(['update', '1', 'https://google.com', 'some-secret']) - t.ok(hookArgs.opts.log, 'is passed a logger') t.match( hookArgs, { @@ -596,7 +579,6 @@ t.test('npm hook update - parseable output', async t => { await hook.exec(['update', '1', 'https://google.com', 'some-secret']) - t.ok(hookArgs.opts.log, 'is passed a logger') t.match( hookArgs, { @@ -618,16 +600,15 @@ t.test('npm hook update - parseable output', async t => { }) t.test('npm hook update - silent output', async t => { - npm.flatOptions.silent = true + npm.config.set('loglevel', 'silent') t.teardown(() => { - npm.flatOptions.silent = false + npm.config.set('loglevel', 'info') hookArgs = null output.length = 0 }) await hook.exec(['update', '1', 'https://google.com', 'some-secret']) - t.ok(hookArgs.opts.log, 'is passed a logger') t.match( hookArgs, { diff --git a/test/lib/commands/logout.js b/test/lib/commands/logout.js index 1a1fbb785c808..73fe8028c7853 100644 --- a/test/lib/commands/logout.js +++ b/test/lib/commands/logout.js @@ -31,7 +31,7 @@ t.afterEach(() => { }) t.test('token logout', async t => { - t.plan(6) + t.plan(5) flatOptions['//registry.npmjs.org/:_authToken'] = '@foo/' @@ -62,7 +62,6 @@ t.test('token logout', async t => { await logout.exec([]) - t.ok(result.opts.log, 'should pass a logger') t.match( result, { @@ -92,7 +91,7 @@ t.test('token scoped logout', async t => { config.save = null }) - t.plan(8) + t.plan(7) flatOptions['//diff-registry.npmjs.com/:_authToken'] = '@bar/' flatOptions['//registry.npmjs.org/:_authToken'] = '@foo/' @@ -133,7 +132,6 @@ t.test('token scoped logout', async t => { await logout.exec([]) - t.ok(result.opts.log, 'should pass a logger') t.match( result, { @@ -204,7 +202,7 @@ t.test('ignore invalid scoped registry config', async t => { config.delete = null config.save = null }) - t.plan(5) + t.plan(4) flatOptions['//registry.npmjs.org/:_authToken'] = '@foo/' config.scope = '@myscope' @@ -236,7 +234,6 @@ t.test('ignore invalid scoped registry config', async t => { await logout.exec([]) - t.ok(result.opts.log, 'should pass a logger') t.match( result, { diff --git a/test/lib/commands/org.js b/test/lib/commands/org.js index b716adc097523..3ae951dd5c453 100644 --- a/test/lib/commands/org.js +++ b/test/lib/commands/org.js @@ -1,18 +1,20 @@ const t = require('tap') const ansiTrim = require('../../../lib/utils/ansi-trim.js') +const { fake: mockNpm } = require('../../fixtures/mock-npm') const output = [] -const npm = { +const npm = mockNpm({ flatOptions: { json: false, parseable: false, - silent: false, + }, + config: { loglevel: 'info', }, output: msg => { output.push(msg) }, -} +}) let orgSize = 1 let orgSetArgs = null @@ -83,7 +85,6 @@ t.test('npm org add', async t => { await org.exec(['add', 'orgname', 'username']) - t.ok(orgSetArgs.opts.log, 'got passed a logger') t.match( orgSetArgs, { @@ -149,7 +150,6 @@ t.test('npm org add - more users', async t => { }) await org.exec(['add', 'orgname', 'username']) - t.ok(orgSetArgs.opts.log, 'got passed a logger') t.match( orgSetArgs, { @@ -177,7 +177,6 @@ t.test('npm org add - json output', async t => { await org.exec(['add', 'orgname', 'username']) - t.ok(orgSetArgs.opts.log, 'got passed a logger') t.match( orgSetArgs, { @@ -212,7 +211,6 @@ t.test('npm org add - parseable output', async t => { await org.exec(['add', 'orgname', 'username']) - t.ok(orgSetArgs.opts.log, 'got passed a logger') t.match( orgSetArgs, { @@ -234,16 +232,15 @@ t.test('npm org add - parseable output', async t => { }) t.test('npm org add - silent output', async t => { - npm.flatOptions.silent = true + npm.config.set('loglevel', 'silent') t.teardown(() => { - npm.flatOptions.silent = false + npm.config.set('loglevel', 'info') orgSetArgs = null output.length = 0 }) await org.exec(['add', 'orgname', 'username']) - t.ok(orgSetArgs.opts.log, 'got passed a logger') t.match( orgSetArgs, { @@ -266,7 +263,6 @@ t.test('npm org rm', async t => { await org.exec(['rm', 'orgname', 'username']) - t.ok(orgRmArgs.opts.log, 'got passed a logger') t.match( orgRmArgs, { @@ -276,7 +272,6 @@ t.test('npm org rm', async t => { }, 'libnpmorg.rm received the correct args' ) - t.ok(orgLsArgs.opts.log, 'got passed a logger') t.match( orgLsArgs, { @@ -330,7 +325,6 @@ t.test('npm org rm - one user left', async t => { await org.exec(['rm', 'orgname', 'username']) - t.ok(orgRmArgs.opts.log, 'got passed a logger') t.match( orgRmArgs, { @@ -340,7 +334,6 @@ t.test('npm org rm - one user left', async t => { }, 'libnpmorg.rm received the correct args' ) - t.ok(orgLsArgs.opts.log, 'got passed a logger') t.match( orgLsArgs, { @@ -367,7 +360,6 @@ t.test('npm org rm - json output', async t => { await org.exec(['rm', 'orgname', 'username']) - t.ok(orgRmArgs.opts.log, 'got passed a logger') t.match( orgRmArgs, { @@ -377,7 +369,6 @@ t.test('npm org rm - json output', async t => { }, 'libnpmorg.rm received the correct args' ) - t.ok(orgLsArgs.opts.log, 'got passed a logger') t.match( orgLsArgs, { @@ -409,7 +400,6 @@ t.test('npm org rm - parseable output', async t => { await org.exec(['rm', 'orgname', 'username']) - t.ok(orgRmArgs.opts.log, 'got passed a logger') t.match( orgRmArgs, { @@ -419,7 +409,6 @@ t.test('npm org rm - parseable output', async t => { }, 'libnpmorg.rm received the correct args' ) - t.ok(orgLsArgs.opts.log, 'got passed a logger') t.match( orgLsArgs, { @@ -439,9 +428,9 @@ t.test('npm org rm - parseable output', async t => { }) t.test('npm org rm - silent output', async t => { - npm.flatOptions.silent = true + npm.config.set('loglevel', 'silent') t.teardown(() => { - npm.flatOptions.silent = false + npm.config.set('loglevel', 'info') orgRmArgs = null orgLsArgs = null output.length = 0 @@ -449,7 +438,6 @@ t.test('npm org rm - silent output', async t => { await org.exec(['rm', 'orgname', 'username']) - t.ok(orgRmArgs.opts.log, 'got passed a logger') t.match( orgRmArgs, { @@ -459,7 +447,6 @@ t.test('npm org rm - silent output', async t => { }, 'libnpmorg.rm received the correct args' ) - t.ok(orgLsArgs.opts.log, 'got passed a logger') t.match( orgLsArgs, { @@ -485,7 +472,6 @@ t.test('npm org ls', async t => { await org.exec(['ls', 'orgname']) - t.ok(orgLsArgs.opts.log, 'got passed a logger') t.match( orgLsArgs, { @@ -513,7 +499,6 @@ t.test('npm org ls - user filter', async t => { await org.exec(['ls', 'orgname', 'username']) - t.ok(orgLsArgs.opts.log, 'got passed a logger') t.match( orgLsArgs, { @@ -539,7 +524,6 @@ t.test('npm org ls - user filter, missing user', async t => { await org.exec(['ls', 'orgname', 'username']) - t.ok(orgLsArgs.opts.log, 'got passed a logger') t.match( orgLsArgs, { @@ -578,7 +562,6 @@ t.test('npm org ls - json output', async t => { await org.exec(['ls', 'orgname']) - t.ok(orgLsArgs.opts.log, 'got passed a logger') t.match( orgLsArgs, { @@ -606,7 +589,6 @@ t.test('npm org ls - parseable output', async t => { await org.exec(['ls', 'orgname']) - t.ok(orgLsArgs.opts.log, 'got passed a logger') t.match( orgLsArgs, { @@ -628,14 +610,14 @@ t.test('npm org ls - parseable output', async t => { }) t.test('npm org ls - silent output', async t => { - npm.flatOptions.silent = true + npm.config.set('loglevel', 'silent') orgList = { one: 'developer', two: 'admin', three: 'owner', } t.teardown(() => { - npm.flatOptions.silent = false + npm.config.set('loglevel', 'info') orgList = {} orgLsArgs = null output.length = 0 @@ -643,7 +625,6 @@ t.test('npm org ls - silent output', async t => { await org.exec(['ls', 'orgname']) - t.ok(orgLsArgs.opts.log, 'got passed a logger') t.match( orgLsArgs, { diff --git a/test/lib/commands/owner.js b/test/lib/commands/owner.js index a32a3df9b7dde..b5d4d1584289d 100644 --- a/test/lib/commands/owner.js +++ b/test/lib/commands/owner.js @@ -51,14 +51,13 @@ t.test('owner no args', async t => { }) t.test('owner ls no args', async t => { - t.plan(5) + t.plan(4) result = '' readPackageNameResponse = '@npmcli/map-workspaces' pacote.packument = async (spec, opts) => { t.equal(spec.name, '@npmcli/map-workspaces', 'should use expect pkg name') - t.ok(opts.log, 'is passed a logger') t.match( opts, { @@ -173,11 +172,10 @@ t.test('owner ls no maintainers', async t => { }) t.test('owner add ', async t => { - t.plan(11) + t.plan(8) result = '' npmFetch.json = async (uri, opts) => { - t.ok(opts.log, 'is passed a logger') // retrieve user info from couchdb request if (uri === '/-/user/org.couchdb.user:foo') { t.ok('should request user info') @@ -218,7 +216,6 @@ t.test('owner add ', async t => { } } pacote.packument = async (spec, opts) => { - t.ok(opts.log, 'is passed a logger') t.equal(spec.name, '@npmcli/map-workspaces', 'should use expect pkg name') t.match( opts, @@ -247,7 +244,6 @@ t.test('owner add cwd package', async t => { result = '' readPackageNameResponse = '@npmcli/map-workspaces' npmFetch.json = async (uri, opts) => { - t.ok(opts.log, 'is passed a logger') // retrieve user info from couchdb request if (uri === '/-/user/org.couchdb.user:foo') { return { @@ -277,7 +273,7 @@ t.test('owner add cwd package', async t => { }) t.test('owner add already an owner', async t => { - t.plan(3) + t.plan(2) result = '' log.info = (title, msg) => { @@ -289,7 +285,6 @@ t.test('owner add already an owner', async t => { ) } npmFetch.json = async (uri, opts) => { - t.ok(opts.log, 'is passed a logger') // retrieve user info from couchdb request if (uri === '/-/user/org.couchdb.user:ruyadorno') { return { @@ -321,7 +316,6 @@ t.test('owner add fails to retrieve user', async t => { result = '' readPackageNameResponse = npmFetch.json = async (uri, opts) => { - t.ok(opts.log, 'is passed a logger') // retrieve borked user info from couchdb request if (uri === '/-/user/org.couchdb.user:foo') { return { ok: false } @@ -352,7 +346,6 @@ t.test('owner add fails to retrieve user', async t => { t.test('owner add fails to PUT updates', async t => { result = '' npmFetch.json = async (uri, opts) => { - t.ok(opts.log, 'is passed a logger') // retrieve user info from couchdb request if (uri === '/-/user/org.couchdb.user:foo') { return { @@ -389,7 +382,7 @@ t.test('owner add fails to PUT updates', async t => { }) t.test('owner add fails to retrieve user info', async t => { - t.plan(4) + t.plan(3) result = '' log.error = (title, msg) => { @@ -397,7 +390,6 @@ t.test('owner add fails to retrieve user info', async t => { t.equal(msg, 'Error getting user data for foo') } npmFetch.json = async (uri, opts) => { - t.ok(opts.log, 'is passed a logger') // retrieve user info from couchdb request if (uri === '/-/user/org.couchdb.user:foo') { throw Object.assign( @@ -429,7 +421,6 @@ t.test('owner add fails to retrieve user info', async t => { t.test('owner add no previous maintainers property from server', async t => { result = '' npmFetch.json = async (uri, opts) => { - t.ok(opts.log, 'is passed a logger') // retrieve user info from couchdb request if (uri === '/-/user/org.couchdb.user:foo') { return { @@ -496,11 +487,10 @@ t.test('owner add no cwd package', async t => { }) t.test('owner rm ', async t => { - t.plan(11) + t.plan(8) result = '' npmFetch.json = async (uri, opts) => { - t.ok(opts.log, 'is passed a logger') // retrieve user info from couchdb request if (uri === '/-/user/org.couchdb.user:ruyadorno') { t.ok('should request user info') @@ -534,7 +524,6 @@ t.test('owner rm ', async t => { } } pacote.packument = async (spec, opts) => { - t.ok(opts.log, 'is passed a logger') t.equal(spec.name, '@npmcli/map-workspaces', 'should use expect pkg name') t.match( opts, @@ -560,7 +549,7 @@ t.test('owner rm ', async t => { }) t.test('owner rm not a current owner', async t => { - t.plan(3) + t.plan(2) result = '' log.info = (title, msg) => { @@ -568,7 +557,6 @@ t.test('owner rm not a current owner', async t => { t.equal(msg, 'Not a package owner: foo', 'should log.info not a package owner msg') } npmFetch.json = async (uri, opts) => { - t.ok(opts.log, 'is passed a logger') // retrieve user info from couchdb request if (uri === '/-/user/org.couchdb.user:foo') { return { @@ -602,7 +590,6 @@ t.test('owner rm cwd package', async t => { result = '' readPackageNameResponse = '@npmcli/map-workspaces' npmFetch.json = async (uri, opts) => { - t.ok(opts.log, 'is passed a logger') // retrieve user info from couchdb request if (uri === '/-/user/org.couchdb.user:ruyadorno') { return { @@ -635,7 +622,6 @@ t.test('owner rm only user', async t => { result = '' readPackageNameResponse = 'ipt' npmFetch.json = async (uri, opts) => { - t.ok(opts.log, 'is passed a logger') // retrieve user info from couchdb request if (uri === '/-/user/org.couchdb.user:ruyadorno') { return { diff --git a/test/lib/commands/ping.js b/test/lib/commands/ping.js index 19ba9d586b763..f808e0ac3ba2a 100644 --- a/test/lib/commands/ping.js +++ b/test/lib/commands/ping.js @@ -2,13 +2,12 @@ const t = require('tap') const { fake: mockNpm } = require('../../fixtures/mock-npm') t.test('pings', async t => { - t.plan(7) + t.plan(6) const registry = 'https://registry.npmjs.org' let noticeCalls = 0 const Ping = t.mock('../../../lib/commands/ping.js', { '../../../lib/utils/ping.js': function (spec) { - t.ok(spec.log, 'is passed a logger') t.equal(spec.registry, registry, 'passes flatOptions') return {} }, @@ -36,14 +35,13 @@ t.test('pings', async t => { }) t.test('pings and logs details', async t => { - t.plan(9) + t.plan(8) const registry = 'https://registry.npmjs.org' const details = { extra: 'data' } let noticeCalls = 0 const Ping = t.mock('../../../lib/commands/ping.js', { '../../../lib/utils/ping.js': function (spec) { - t.ok(spec.log, 'is passed a logger') t.equal(spec.registry, registry, 'passes flatOptions') return details }, @@ -75,14 +73,13 @@ t.test('pings and logs details', async t => { }) t.test('pings and returns json', async t => { - t.plan(10) + t.plan(9) const registry = 'https://registry.npmjs.org' const details = { extra: 'data' } let noticeCalls = 0 const Ping = t.mock('../../../lib/commands/ping.js', { '../../../lib/utils/ping.js': function (spec) { - t.ok(spec.log, 'is passed a logger') t.equal(spec.registry, registry, 'passes flatOptions') return details }, diff --git a/test/lib/commands/publish.js b/test/lib/commands/publish.js index 52d4c1b342908..0a7f961bfbdc9 100644 --- a/test/lib/commands/publish.js +++ b/test/lib/commands/publish.js @@ -1,15 +1,6 @@ const t = require('tap') const { fake: mockNpm } = require('../../fixtures/mock-npm') const fs = require('fs') -const log = require('../../../lib/utils/log-shim') - -// The way we set loglevel is kind of convoluted, and there is no way to affect -// it from these tests, which only interact with lib/publish.js, which assumes -// that the code that is requiring and calling lib/publish.js has already -// taken care of the loglevel -const _level = log.level -t.beforeEach(() => (log.level = 'silent')) -t.teardown(() => (log.level = _level)) t.cleanSnapshot = data => { return data.replace(/^ *"gitHead": .*$\n/gm, '') @@ -25,7 +16,7 @@ t.test( /* eslint-disable-next-line max-len */ 'should publish with libnpmpublish, passing through flatOptions and respecting publishConfig.registry', async t => { - t.plan(7) + t.plan(6) const registry = 'https://some.registry' const publishConfig = { registry } @@ -59,7 +50,6 @@ t.test( t.match(manifest, { name: 'my-cool-pkg', version: '1.0.0' }, 'gets manifest') t.type(tarData, Buffer, 'tarData is a buffer') t.ok(opts, 'gets opts object') - t.ok(opts.log, 'gets passed a logger') t.same(opts.customValue, true, 'flatOptions values are passed through') t.same(opts.registry, registry, 'publishConfig.registry is passed through') }, @@ -82,7 +72,7 @@ t.test( ) t.test('re-loads publishConfig.registry if added during script process', async t => { - t.plan(6) + t.plan(5) const registry = 'https://some.registry' const publishConfig = { registry } const testDir = t.testdir({ @@ -113,7 +103,6 @@ t.test('re-loads publishConfig.registry if added during script process', async t t.match(manifest, { name: 'my-cool-pkg', version: '1.0.0' }, 'gets manifest') t.type(tarData, Buffer, 'tarData is a buffer') t.ok(opts, 'gets opts object') - t.ok(opts.log, 'gets passed a logger') t.same(opts.registry, registry, 'publishConfig.registry is passed through') }, }, @@ -142,7 +131,6 @@ t.test('if loglevel=info and json, should not output package contents', async t ), }) - log.level = 'info' const Publish = t.mock('../../../lib/commands/publish.js', { '../../../lib/utils/tar.js': { getContents: () => ({ @@ -159,11 +147,11 @@ t.test('if loglevel=info and json, should not output package contents', async t }, }) const npm = mockNpm({ - config: { json: true }, + config: { json: true, loglevel: 'info' }, output: () => { t.pass('output is called') }, - }) + }, t) npm.config.getCredentialsByURI = uri => { t.same(uri, npm.config.get('registry'), 'gets credentials for expected registry') return { token: 'some.registry.token' } @@ -206,11 +194,11 @@ t.test( }, }) const npm = mockNpm({ - config: { 'dry-run': true }, + config: { 'dry-run': true, loglevel: 'silent' }, output: () => { throw new Error('should not output in dry run mode') }, - }) + }, t) npm.config.getCredentialsByURI = () => { throw new Error('should not call getCredentialsByURI in dry run') } @@ -238,7 +226,6 @@ t.test( ), }) - log.level = 'info' const Publish = t.mock('../../../lib/commands/publish.js', { '../../../lib/utils/tar.js': { getContents: () => ({ @@ -255,11 +242,11 @@ t.test( }, }) const npm = mockNpm({ - config: { 'dry-run': true }, + config: { 'dry-run': true, loglevel: 'info' }, output: () => { t.pass('output fn is called') }, - }) + }, t) npm.config.getCredentialsByURI = () => { throw new Error('should not call getCredentialsByURI in dry run') } @@ -294,7 +281,7 @@ t.test('throws when invalid tag', async t => { }) t.test('can publish a tarball', async t => { - t.plan(4) + t.plan(3) const testDir = t.testdir({ tarball: {}, @@ -319,7 +306,6 @@ t.test('can publish a tarball', async t => { const Publish = t.mock('../../../lib/commands/publish.js', { libnpmpublish: { publish: (manifest, tarData, opts) => { - t.ok(opts.log, 'gets passed a logger') t.match( manifest, { @@ -415,7 +401,7 @@ t.test('should check auth for scope specific registry', async t => { }) t.test('should use auth for scope specific registry', async t => { - t.plan(4) + t.plan(3) const registry = 'https://some.registry' const testDir = t.testdir({ 'package.json': JSON.stringify( @@ -432,7 +418,6 @@ t.test('should use auth for scope specific registry', async t => { libnpmpublish: { publish: (manifest, tarData, opts) => { t.ok(opts, 'gets opts object') - t.ok(opts.log, 'gets passed a logger') t.same(opts['@npm:registry'], registry, 'scope specific registry is passed through') }, }, @@ -450,7 +435,7 @@ t.test('should use auth for scope specific registry', async t => { }) t.test('read registry only from publishConfig', async t => { - t.plan(4) + t.plan(3) const registry = 'https://some.registry' const publishConfig = { registry } @@ -469,7 +454,6 @@ t.test('read registry only from publishConfig', async t => { const Publish = t.mock('../../../lib/commands/publish.js', { libnpmpublish: { publish: (manifest, tarData, opts) => { - t.ok(opts.log, 'gets passed a logger') t.match(manifest, { name: 'my-cool-pkg', version: '1.0.0' }, 'gets manifest') t.same(opts.registry, registry, 'publishConfig is passed through') }, @@ -486,7 +470,7 @@ t.test('read registry only from publishConfig', async t => { }) t.test('able to publish after if encountered multiple configs', async t => { - t.plan(3) + t.plan(2) const registry = 'https://some.registry' const tag = 'better-tag' @@ -515,7 +499,6 @@ t.test('able to publish after if encountered multiple configs', async t => { const Publish = t.mock('../../../lib/commands/publish.js', { libnpmpublish: { publish: (manifest, tarData, opts) => { - t.ok(opts.log, 'gets passed a logger') t.same(opts.defaultTag, tag, 'gets option for expected tag') }, }, @@ -526,6 +509,7 @@ t.test('able to publish after if encountered multiple configs', async t => { defaultTag: 'better-tag', registry: 'https://other.registry', }, + output () {}, config: { get: key => configList[0][key], list: configList, @@ -604,14 +588,12 @@ t.test('workspaces', t => { const publish = new Publish(npm) t.test('all workspaces', async t => { - log.level = 'info' await publish.execWorkspaces([], []) t.matchSnapshot(publishes, 'should publish all workspaces') t.matchSnapshot(outputs, 'should output all publishes') }) t.test('one workspace', async t => { - log.level = 'info' await publish.execWorkspaces([], ['workspace-a']) t.matchSnapshot(publishes, 'should publish given workspace') t.matchSnapshot(outputs, 'should output one publish') @@ -623,7 +605,6 @@ t.test('workspaces', t => { }) t.test('json', async t => { - log.level = 'info' npm.config.set('json', true) await publish.execWorkspaces([], []) t.matchSnapshot(publishes, 'should publish all workspaces') @@ -680,10 +661,11 @@ t.test('private workspaces', async t => { }, } const npm = mockNpm({ + config: { loglevel: 'info' }, output: o => { outputs.push(o) }, - }) + }, t) npm.localPrefix = testDir npm.config.getCredentialsByURI = uri => { return { token: 'some.registry.token' } @@ -692,7 +674,6 @@ t.test('private workspaces', async t => { t.test('with color', async t => { t.plan(4) - log.level = 'info' const Publish = t.mock('../../../lib/commands/publish.js', { ...mocks, 'proc-log': { @@ -721,7 +702,6 @@ t.test('private workspaces', async t => { t.test('colorless', async t => { t.plan(4) - log.level = 'info' const Publish = t.mock('../../../lib/commands/publish.js', { ...mocks, 'proc-log': { @@ -754,7 +734,6 @@ t.test('private workspaces', async t => { if (manifest.private) { throw new Error('ERR') } - t.ok(opts.log, 'gets passed a logger') publishes.push(manifest) }, }, @@ -794,7 +773,6 @@ t.test('runs correct lifecycle scripts', async t => { }) const scripts = [] - log.level = 'info' const Publish = t.mock('../../../lib/commands/publish.js', { '@npmcli/run-script': args => { scripts.push(args) @@ -814,10 +792,11 @@ t.test('runs correct lifecycle scripts', async t => { }, }) const npm = mockNpm({ + config: { loglevel: 'info' }, output: () => { t.pass('output is called') }, - }) + }, t) npm.config.getCredentialsByURI = uri => { t.same(uri, npm.config.get('registry'), 'gets credentials for expected registry') return { token: 'some.registry.token' } @@ -845,7 +824,6 @@ t.test('does not run scripts on --ignore-scripts', async t => { ), }) - log.level = 'info' const Publish = t.mock('../../../lib/commands/publish.js', { '@npmcli/run-script': () => { t.fail('should not call run-script') @@ -865,11 +843,11 @@ t.test('does not run scripts on --ignore-scripts', async t => { }, }) const npm = mockNpm({ - config: { 'ignore-scripts': true }, + config: { 'ignore-scripts': true, loglevel: 'info' }, output: () => { t.pass('output is called') }, - }) + }, t) npm.config.getCredentialsByURI = uri => { t.same(uri, npm.config.get('registry'), 'gets credentials for expected registry') return { token: 'some.registry.token' } diff --git a/test/lib/commands/run-script.js b/test/lib/commands/run-script.js index ea0227cda08ca..834b61e7474c4 100644 --- a/test/lib/commands/run-script.js +++ b/test/lib/commands/run-script.js @@ -10,10 +10,12 @@ const RUN_SCRIPTS = [] const flatOptions = { scriptShell: undefined, } +const defaultLoglevel = 'info' const config = { json: false, parseable: false, 'if-present': false, + loglevel: defaultLoglevel, } const npm = mockNpm({ @@ -26,20 +28,21 @@ const npm = mockNpm({ output: (...msg) => output.push(msg), }) -const output = [] - -const npmlog = { - disableProgress: () => null, - level: 'warn', +const setLoglevel = (t, level) => { + npm.config.set('loglevel', level) + t.teardown(() => { + npm.config.set('loglevel', defaultLoglevel) + }) } +const output = [] + const log = { error: () => null, } t.afterEach(() => { npm.color = false - npmlog.level = 'warn' log.error = () => null output.length = 0 RUN_SCRIPTS.length = 0 @@ -58,7 +61,6 @@ const getRS = windows => { isServerPackage: require('@npmcli/run-script').isServerPackage, } ), - npmlog, 'proc-log': log, '../../../lib/utils/is-windows-shell.js': windows, }) @@ -359,10 +361,7 @@ t.test('skip pre/post hooks when using ignoreScripts', async t => { }) t.test('run silent', async t => { - npmlog.level = 'silent' - t.teardown(() => { - npmlog.level = 'warn' - }) + setLoglevel(t, 'silent') npm.localPrefix = t.testdir({ 'package.json': JSON.stringify({ @@ -440,12 +439,11 @@ t.test('list scripts', t => { }) t.test('silent', async t => { - npmlog.level = 'silent' + setLoglevel(t, 'silent') await runScript.exec([]) t.strictSame(output, []) }) t.test('warn json', async t => { - npmlog.level = 'warn' config.json = true await runScript.exec([]) t.strictSame(output, [[JSON.stringify(scripts, 0, 2)]], 'json report') @@ -723,7 +721,7 @@ t.test('workspaces', t => { }) t.test('list no scripts --loglevel=silent', async t => { - npmlog.level = 'silent' + setLoglevel(t, 'silent') await runScript.execWorkspaces([], []) t.strictSame(output, []) }) @@ -860,7 +858,6 @@ t.test('workspaces', t => { '@npmcli/run-script': () => { throw new Error('err') }, - npmlog, 'proc-log': log, '../../../lib/utils/is-windows-shell.js': false, }) @@ -879,7 +876,6 @@ t.test('workspaces', t => { RUN_SCRIPTS.push(opts) }, - npmlog, 'proc-log': log, '../../../lib/utils/is-windows-shell.js': false, }) diff --git a/test/lib/commands/star.js b/test/lib/commands/star.js index 2f4ddc9dc6439..4d19b32e1d258 100644 --- a/test/lib/commands/star.js +++ b/test/lib/commands/star.js @@ -42,10 +42,9 @@ t.test('no args', async t => { }) t.test('star a package', async t => { - t.plan(6) + t.plan(4) const pkgName = '@npmcli/arborist' npmFetch.json = async (uri, opts) => { - t.ok(opts.log, 'is passed a logger') return { _id: pkgName, _rev: 'hash', @@ -70,11 +69,10 @@ t.test('star a package', async t => { }) t.test('unstar a package', async t => { - t.plan(6) + t.plan(4) const pkgName = '@npmcli/arborist' config['star.unstar'] = true npmFetch.json = async (uri, opts) => { - t.ok(opts.log, 'is passed a logger') return { _id: pkgName, _rev: 'hash', diff --git a/test/lib/commands/team.js b/test/lib/commands/team.js index 96260835fa2b6..0d5378b530647 100644 --- a/test/lib/commands/team.js +++ b/test/lib/commands/team.js @@ -1,4 +1,5 @@ const t = require('tap') +const { fake: mockNpm } = require('../../fixtures/mock-npm') let result = '' const libnpmteam = { @@ -9,12 +10,15 @@ const libnpmteam = { async lsUsers () {}, async rm () {}, } -const npm = { +const npm = mockNpm({ flatOptions: {}, + config: { + loglevel: 'info', + }, output: (...msg) => { result += msg.join('\n') }, -} +}) const mocks = { libnpmteam, 'cli-columns': a => a.join(' '), @@ -25,6 +29,7 @@ const mocks = { t.afterEach(() => { result = '' npm.flatOptions = {} + npm.config.set('loglevel', 'info') }) const Team = t.mock('../../../lib/commands/team.js', mocks) @@ -73,7 +78,7 @@ t.test('team add ', async t => { }) t.test('--silent', async t => { - npm.flatOptions.silent = true + npm.config.set('loglevel', 'silent') await team.exec(['add', '@npmcli:developers', 'foo']) @@ -115,7 +120,7 @@ t.test('team create ', async t => { }) t.test('--silent', async t => { - npm.flatOptions.silent = true + npm.config.set('loglevel', 'silent') await team.exec(['create', '@npmcli:newteam']) @@ -149,7 +154,7 @@ t.test('team destroy ', async t => { }) t.test('--silent', async t => { - npm.flatOptions.silent = true + npm.config.set('loglevel', 'silent') await team.exec(['destroy', '@npmcli:newteam']) t.same(result, '', 'should not output destroy if silent') }) @@ -198,7 +203,7 @@ t.test('team ls ', async t => { }) t.test('--silent', async t => { - npm.flatOptions.silent = true + npm.config.set('loglevel', 'silent') await team.exec(['ls', '@npmcli']) t.same(result, '', 'should not list teams if silent') }) @@ -278,7 +283,7 @@ t.test('team ls ', async t => { }) t.test('--silent', async t => { - npm.flatOptions.silent = true + npm.config.set('loglevel', 'silent') await team.exec(['ls', '@npmcli:developers']) t.same(result, '', 'should not output users if silent') }) @@ -345,7 +350,7 @@ t.test('team rm ', async t => { }) t.test('--silent', async t => { - npm.flatOptions.silent = true + npm.config.set('loglevel', 'silent') await team.exec(['rm', '@npmcli:newteam', 'foo']) t.same(result, '', 'should not output rm result if silent') }) diff --git a/test/lib/commands/unpublish.js b/test/lib/commands/unpublish.js index 99d55294fbacf..b9c94e5d5265f 100644 --- a/test/lib/commands/unpublish.js +++ b/test/lib/commands/unpublish.js @@ -22,7 +22,6 @@ const singleVersion = async () => { const config = { force: false, - loglevel: 'silly', } const testDir = t.testdir({ @@ -54,7 +53,7 @@ t.afterEach(() => { result = '' config['dry-run'] = false config.force = false - config.loglevel = 'silly' + npm.config.set('loglevel', 'info') }) t.test('no args --force', async t => { @@ -76,7 +75,6 @@ t.test('no args --force', async t => { const libnpmpublish = { unpublish (spec, opts) { - t.ok(opts.log, 'gets passed a logger') t.equal(spec.raw, 'pkg@1.0.0', 'should unpublish expected spec') t.match( opts, @@ -178,7 +176,6 @@ t.test('unpublish @version', async t => { const libnpmpublish = { unpublish (spec, opts) { - t.ok(opts.log, 'gets passed a logger') t.equal(spec.raw, 'pkg@1.0.0', 'should unpublish expected parsed spec') }, } @@ -240,7 +237,7 @@ t.test('unpublish --force no version set', async t => { }) t.test('silent', async t => { - config.loglevel = 'silent' + npm.config.set('loglevel', 'silent') const Unpublish = t.mock('../../../lib/commands/unpublish.js', { ...mocks, diff --git a/test/lib/commands/update.js b/test/lib/commands/update.js index 2b464bfabbfcd..ae9376466128a 100644 --- a/test/lib/commands/update.js +++ b/test/lib/commands/update.js @@ -27,7 +27,7 @@ t.afterEach(() => { }) t.test('no args', async t => { - t.plan(5) + t.plan(4) npm.prefix = '/project/a' @@ -44,7 +44,6 @@ t.test('no args', async t => { }, 'should call arborist contructor with expected args' ) - t.match(log, {}, 'log is passed in') } reify ({ save, update }) { @@ -66,7 +65,7 @@ t.test('no args', async t => { }) t.test('with args', async t => { - t.plan(5) + t.plan(4) npm.prefix = '/project/a' config.save = true @@ -84,7 +83,6 @@ t.test('with args', async t => { }, 'should call arborist contructor with expected args' ) - t.match(log, {}, 'log is passed in') } reify ({ save, update }) { @@ -130,7 +128,7 @@ t.test('update --depth=', async t => { }) t.test('update --global', async t => { - t.plan(3) + t.plan(2) const normalizePath = p => p.replace(/\\+/g, '/') const redactCwd = (path) => normalizePath(path) @@ -149,8 +147,6 @@ t.test('update --global', async t => { 'should call arborist contructor with expected options' ) - t.match(log, {}, 'log is passed in') - t.equal( redactCwd(path), '{CWD}/global/lib', diff --git a/test/lib/utils/config/definitions.js b/test/lib/utils/config/definitions.js index bf4b48709ae7b..a5b34a7499fbe 100644 --- a/test/lib/utils/config/definitions.js +++ b/test/lib/utils/config/definitions.js @@ -929,3 +929,12 @@ t.test('lockfile version', t => { t.match(flat.lockfileVersion, 3, 'flattens to a number') t.end() }) + +t.test('loglevel silent', t => { + const flat = {} + definitions.loglevel.flatten('loglevel', { + loglevel: 'silent', + }, flat) + t.match(flat.silent, true, 'flattens to assign silent') + t.end() +}) diff --git a/test/lib/utils/exit-handler.js b/test/lib/utils/exit-handler.js index 54bf48f89b0dd..6a96d92ddb250 100644 --- a/test/lib/utils/exit-handler.js +++ b/test/lib/utils/exit-handler.js @@ -89,9 +89,9 @@ const mockExitHandler = async (t, { init, load, testdir, config } = {}) => { ...rest, errors, npm, - // // Make it async to make testing ergonomics a little - // // easier so we dont need to t.plan() every test to - // // make sure we get process.exit called + // Make it async to make testing ergonomics a little + // easier so we dont need to t.plan() every test to + // make sure we get process.exit called exitHandler: (...args) => new Promise(resolve => { process.once('exit', resolve) exitHandler(...args) diff --git a/test/lib/utils/reify-output.js b/test/lib/utils/reify-output.js index 4e9ed7133c18c..b38a14de33909 100644 --- a/test/lib/utils/reify-output.js +++ b/test/lib/utils/reify-output.js @@ -1,9 +1,4 @@ const t = require('tap') -const log = require('../../../lib/utils/log-shim') - -const _level = log.level -t.beforeEach(() => log.level = 'warn') -t.teardown(() => log.level = _level) t.cleanSnapshot = str => str.replace(/in [0-9]+m?s/g, 'in {TIME}') @@ -13,6 +8,7 @@ const settings = { const npm = { started: Date.now(), flatOptions: settings, + silent: false, } const reifyOutput = require('../../../lib/utils/reify-output.js') t.test('missing info', (t) => { @@ -236,10 +232,13 @@ t.test('showing and not showing audit report', async t => { } t.test('no output when silent', t => { + t.teardown(() => { + delete npm.silent + }) + npm.silent = true npm.output = out => { t.fail('should not get output when silent', { actual: out }) } - log.level = 'silent' reifyOutput(npm, { actualTree: { inventory: { size: 999 }, children: [] }, auditReport, diff --git a/test/lib/utils/update-notifier.js b/test/lib/utils/update-notifier.js index a7a800c602fd6..fa4af29476f12 100644 --- a/test/lib/utils/update-notifier.js +++ b/test/lib/utils/update-notifier.js @@ -84,12 +84,11 @@ t.afterEach(() => { }) const runUpdateNotifier = async ({ color = true, ...npmOptions } = {}) => { - const _npm = { ...defaultNpm, ...npmOptions } + const _npm = { ...defaultNpm, ...npmOptions, logColor: color } await t.mock('../../../lib/utils/update-notifier.js', { '@npmcli/ci-detect': () => ciMock, pacote, fs, - npmlog: { useColor: () => color }, })(_npm) return _npm.updateNotification } From d438d61d4f689966de8f964afe212d1319b8d460 Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Tue, 22 Feb 2022 00:41:31 -0700 Subject: [PATCH 27/43] feat(arborist): refactor arborist bin to use consistent timing/logging This attempts to make the arborist bin script behave more like the npm cli with regards to the handing of timing and logging. It also adds the a `logfile` argument to write logs to a file instead of (or in addition to) stderr. This can be helpful for benchmarking performance of loggins or terminal display. --- package-lock.json | 2 + workspaces/arborist/README.md | 10 ++ workspaces/arborist/bin/actual.js | 36 ++--- workspaces/arborist/bin/audit.js | 49 +++---- workspaces/arborist/bin/funding.js | 66 +++++---- workspaces/arborist/bin/ideal.js | 29 ++-- workspaces/arborist/bin/index.js | 155 ++++++++++++-------- workspaces/arborist/bin/lib/logging.js | 88 +++++++---- workspaces/arborist/bin/lib/options.js | 170 +++++++++++++++------- workspaces/arborist/bin/lib/print-tree.js | 5 +- workspaces/arborist/bin/lib/timers.js | 32 ++-- workspaces/arborist/bin/license.js | 79 +++++----- workspaces/arborist/bin/prune.js | 43 +++--- workspaces/arborist/bin/reify.js | 43 +++--- workspaces/arborist/bin/shrinkwrap.js | 15 +- workspaces/arborist/bin/virtual.js | 26 ++-- workspaces/arborist/package.json | 1 + 17 files changed, 490 insertions(+), 359 deletions(-) diff --git a/package-lock.json b/package-lock.json index 69a9daa868a47..fec11a53ff6a7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10434,6 +10434,7 @@ "json-stringify-nice": "^1.1.4", "mkdirp": "^1.0.4", "mkdirp-infer-owner": "^2.0.0", + "nopt": "^5.0.0", "npm-install-checks": "^4.0.0", "npm-package-arg": "^9.0.0", "npm-pick-manifest": "^7.0.0", @@ -11353,6 +11354,7 @@ "mkdirp": "^1.0.4", "mkdirp-infer-owner": "^2.0.0", "nock": "^13.2.0", + "nopt": "^5.0.0", "npm-install-checks": "^4.0.0", "npm-package-arg": "^9.0.0", "npm-pick-manifest": "^7.0.0", diff --git a/workspaces/arborist/README.md b/workspaces/arborist/README.md index 8722b7a43cc2f..ee79a3bf2f7ae 100644 --- a/workspaces/arborist/README.md +++ b/workspaces/arborist/README.md @@ -333,3 +333,13 @@ pruning nodes from the tree. Note: `devOptional` is only set in the shrinkwrap/package-lock file if _neither_ `dev` nor `optional` are set, as it would be redundant. + +## BIN + +Arborist ships with a cli that can be used to run arborist specific commands outside of the context of the npm CLI. This script is currently not part of the public API and is subject to breaking changes outside of major version bumps. + +To see the usage run: + +``` +npx @npmcli/arborist --help +``` diff --git a/workspaces/arborist/bin/actual.js b/workspaces/arborist/bin/actual.js index eb0495997a1b9..866b2cd82fa47 100644 --- a/workspaces/arborist/bin/actual.js +++ b/workspaces/arborist/bin/actual.js @@ -1,23 +1,19 @@ const Arborist = require('../') -const print = require('./lib/print-tree.js') -const options = require('./lib/options.js') -require('./lib/logging.js') -require('./lib/timers.js') -const start = process.hrtime() -new Arborist(options).loadActual(options).then(tree => { - const end = process.hrtime(start) - if (!process.argv.includes('--quiet')) { - print(tree) - } +const printTree = require('./lib/print-tree.js') - console.error(`read ${tree.inventory.size} deps in ${end[0] * 1000 + end[1] / 1e6}ms`) - if (options.save) { - tree.meta.save() - } - if (options.saveHidden) { - tree.meta.hiddenLockfile = true - tree.meta.filename = options.path + '/node_modules/.package-lock.json' - tree.meta.save() - } -}).catch(er => console.error(er)) +module.exports = (options, time) => new Arborist(options) + .loadActual(options) + .then(time) + .then(async ({ timing, result: tree }) => { + printTree(tree) + if (options.save) { + await tree.meta.save() + } + if (options.saveHidden) { + tree.meta.hiddenLockfile = true + tree.meta.filename = options.path + '/node_modules/.package-lock.json' + await tree.meta.save() + } + return `read ${tree.inventory.size} deps in ${timing.ms}` + }) diff --git a/workspaces/arborist/bin/audit.js b/workspaces/arborist/bin/audit.js index d9ac532d3ed70..0e32833d4aa3a 100644 --- a/workspaces/arborist/bin/audit.js +++ b/workspaces/arborist/bin/audit.js @@ -1,19 +1,17 @@ const Arborist = require('../') -const print = require('./lib/print-tree.js') -const options = require('./lib/options.js') -require('./lib/timers.js') -require('./lib/logging.js') +const printTree = require('./lib/print-tree.js') +const log = require('./lib/logging.js') const Vuln = require('../lib/vuln.js') const printReport = report => { for (const vuln of report.values()) { - console.log(printVuln(vuln)) + log.info(printVuln(vuln)) } if (report.topVulns.size) { - console.log('\n# top-level vulnerabilities') + log.info('\n# top-level vulnerabilities') for (const vuln of report.topVulns.values()) { - console.log(printVuln(vuln)) + log.info(printVuln(vuln)) } } } @@ -33,22 +31,21 @@ const printVuln = vuln => { const printAdvisory = a => `${a.title}${a.url ? ' ' + a.url : ''}` -const start = process.hrtime() -process.emit('time', 'audit script') -const arb = new Arborist(options) -arb.audit(options).then(tree => { - process.emit('timeEnd', 'audit script') - const end = process.hrtime(start) - if (options.fix) { - print(tree) - } - if (!options.quiet) { - printReport(arb.auditReport) - } - if (options.fix) { - console.error(`resolved ${tree.inventory.size} deps in ${end[0] + end[1] / 1e9}s`) - } - if (tree.meta && options.save) { - tree.meta.save() - } -}).catch(er => console.error(er)) +module.exports = (options, time) => { + const arb = new Arborist(options) + return arb + .audit(options) + .then(time) + .then(async ({ timing, result: tree }) => { + if (options.fix) { + printTree(tree) + } + printReport(arb.auditReport) + if (tree.meta && options.save) { + await tree.meta.save() + } + return options.fix + ? `resolved ${tree.inventory.size} deps in ${timing.seconds}` + : `done in ${timing.seconds}` + }) +} diff --git a/workspaces/arborist/bin/funding.js b/workspaces/arborist/bin/funding.js index d0f4f31654ae0..cf25976d94ca6 100644 --- a/workspaces/arborist/bin/funding.js +++ b/workspaces/arborist/bin/funding.js @@ -1,34 +1,38 @@ -const options = require('./lib/options.js') -require('./lib/logging.js') -require('./lib/timers.js') - const Arborist = require('../') -const a = new Arborist(options) -const query = options._.shift() -const start = process.hrtime() -a.loadVirtual().then(tree => { - // only load the actual tree if the virtual one doesn't have modern metadata - if (!tree.meta || !(tree.meta.originalLockfileVersion >= 2)) { - console.error('old metadata, load actual') - throw 'load actual' - } else { - console.error('meta ok, return virtual tree') - return tree - } -}).catch(() => a.loadActual()).then(tree => { - const end = process.hrtime(start) - if (!query) { - for (const node of tree.inventory.values()) { - if (node.package.funding) { - console.log(node.name, node.location, node.package.funding) + +const log = require('./lib/logging.js') + +module.exports = (options, time) => { + const query = options._.shift() + const a = new Arborist(options) + return a + .loadVirtual() + .then(tree => { + // only load the actual tree if the virtual one doesn't have modern metadata + if (!tree.meta || !(tree.meta.originalLockfileVersion >= 2)) { + log.error('old metadata, load actual') + throw 'load actual' + } else { + log.error('meta ok, return virtual tree') + return tree } - } - } else { - for (const node of tree.inventory.query('name', query)) { - if (node.package.funding) { - console.log(node.name, node.location, node.package.funding) + }) + .catch(() => a.loadActual()) + .then(time) + .then(({ timing, result: tree }) => { + if (!query) { + for (const node of tree.inventory.values()) { + if (node.package.funding) { + log.info(node.name, node.location, node.package.funding) + } + } + } else { + for (const node of tree.inventory.query('name', query)) { + if (node.package.funding) { + log.info(node.name, node.location, node.package.funding) + } + } } - } - } - console.error(`read ${tree.inventory.size} deps in ${end[0] * 1000 + end[1] / 1e6}ms`) -}) + return `read ${tree.inventory.size} deps in ${timing.ms}` + }) +} diff --git a/workspaces/arborist/bin/ideal.js b/workspaces/arborist/bin/ideal.js index 5d1ed0dcd9dc6..1dd206e81ff1b 100644 --- a/workspaces/arborist/bin/ideal.js +++ b/workspaces/arborist/bin/ideal.js @@ -1,21 +1,14 @@ const Arborist = require('../') -const { inspect } = require('util') -const options = require('./lib/options.js') -const print = require('./lib/print-tree.js') -require('./lib/logging.js') -require('./lib/timers.js') +const printTree = require('./lib/print-tree.js') -const start = process.hrtime() -new Arborist(options).buildIdealTree(options).then(tree => { - const end = process.hrtime(start) - print(tree) - console.error(`resolved ${tree.inventory.size} deps in ${end[0] + end[1] / 10e9}s`) - if (tree.meta && options.save) { - tree.meta.save() - } -}).catch(er => { - const opt = { depth: Infinity, color: true } - console.error(er.code === 'ERESOLVE' ? inspect(er, opt) : er) - process.exitCode = 1 -}) +module.exports = (options, time) => new Arborist(options) + .buildIdealTree(options) + .then(time) + .then(async ({ timing, result: tree }) => { + printTree(tree) + if (tree.meta && options.save) { + await tree.meta.save() + } + return `resolved ${tree.inventory.size} deps in ${timing.seconds}` + }) diff --git a/workspaces/arborist/bin/index.js b/workspaces/arborist/bin/index.js index 5449a50e67f62..0c1e98445341f 100755 --- a/workspaces/arborist/bin/index.js +++ b/workspaces/arborist/bin/index.js @@ -1,81 +1,110 @@ #!/usr/bin/env node -const [cmd] = process.argv.splice(2, 1) -const usage = () => `Arborist - the npm tree doctor +const fs = require('fs') +const path = require('path') -Version: ${require('../package.json').version} +const { bin, arb: options } = require('./lib/options') +const version = require('../package.json').version +const usage = (message = '') => `Arborist - the npm tree doctor + +Version: ${version} +${message && '\n' + message + '\n'} # USAGE arborist [path] [options...] # COMMANDS -* reify: reify ideal tree to node_modules (install, update, rm, ...) -* prune: prune the ideal tree and reify (like npm prune) -* ideal: generate and print the ideal tree -* actual: read and print the actual tree in node_modules -* virtual: read and print the virtual tree in the local shrinkwrap file -* shrinkwrap: load a local shrinkwrap and print its data -* audit: perform a security audit on project dependencies -* funding: query funding information in the local package tree. A second - positional argument after the path name can limit to a package name. -* license: query license information in the local package tree. A second - positional argument after the path name can limit to a license type. -* help: print this text + * reify: reify ideal tree to node_modules (install, update, rm, ...) + * prune: prune the ideal tree and reify (like npm prune) + * ideal: generate and print the ideal tree + * actual: read and print the actual tree in node_modules + * virtual: read and print the virtual tree in the local shrinkwrap file + * shrinkwrap: load a local shrinkwrap and print its data + * audit: perform a security audit on project dependencies + * funding: query funding information in the local package tree. A second + positional argument after the path name can limit to a package name. + * license: query license information in the local package tree. A second + positional argument after the path name can limit to a license type. + * help: print this text + * version: print the version # OPTIONS -Most npm options are supported, but in camelCase rather than css-case. For -example, instead of '--dry-run', use '--dryRun'. + Most npm options are supported, but in camelCase rather than css-case. For + example, instead of '--dry-run', use '--dryRun'. -Additionally: + Additionally: -* --quiet will supppress the printing of package trees -* Instead of 'npm install ', use 'arborist reify --add='. - The '--add=' option can be specified multiple times. -* Instead of 'npm rm ', use 'arborist reify --rm='. - The '--rm=' option can be specified multiple times. -* Instead of 'npm update', use 'arborist reify --update-all'. -* 'npm audit fix' is 'arborist audit --fix' + * --loglevel=warn|--quiet will supppress the printing of package trees + * --logfile will output logs to a file + * --timing will show timing information + * Instead of 'npm install ', use 'arborist reify --add='. + The '--add=' option can be specified multiple times. + * Instead of 'npm rm ', use 'arborist reify --rm='. + The '--rm=' option can be specified multiple times. + * Instead of 'npm update', use 'arborist reify --update-all'. + * 'npm audit fix' is 'arborist audit --fix' ` -const help = () => console.log(usage()) - -switch (cmd) { - case 'actual': - require('./actual.js') - break - case 'virtual': - require('./virtual.js') - break - case 'ideal': - require('./ideal.js') - break - case 'prune': - require('./prune.js') - break - case 'reify': - require('./reify.js') - break - case 'audit': - require('./audit.js') - break - case 'funding': - require('./funding.js') - break - case 'license': - require('./license.js') - break - case 'shrinkwrap': - require('./shrinkwrap.js') - break - case 'help': - case '-h': - case '--help': - help() - break - default: +const commands = { + version: () => console.log(version), + help: () => console.log(usage()), + exit: () => { process.exitCode = 1 - console.error(usage()) - break + console.error( + usage(`Error: command '${bin.command}' does not exist.`) + ) + }, +} + +const commandFiles = fs.readdirSync(__dirname).filter((f) => path.extname(f) === '.js' && f !== __filename) + +for (const file of commandFiles) { + const command = require(`./${file}`) + const name = path.basename(file, '.js') + const totalTime = `bin:${name}:init` + const scriptTime = `bin:${name}:script` + + commands[name] = () => { + const timers = require('./lib/timers') + const log = require('./lib/logging') + + log.info(name, options) + + process.emit('time', totalTime) + process.emit('time', scriptTime) + + return command(options, (result) => { + process.emit('timeEnd', scriptTime) + return { + result, + timing: { + seconds: `${timers.get(scriptTime) / 1e9}s`, + ms: `${timers.get(scriptTime) / 1e6}ms`, + }, + } + }) + .then((result) => { + log.info(result) + return result + }) + .catch((err) => { + process.exitCode = 1 + log.error(err) + return err + }) + .then((r) => { + process.emit('timeEnd', totalTime) + if (bin.loglevel !== 'silent') { + console[process.exitCode ? 'error' : 'log'](r) + } + }) + } +} + +if (commands[bin.command]) { + commands[bin.command]() +} else { + commands.exit() } diff --git a/workspaces/arborist/bin/lib/logging.js b/workspaces/arborist/bin/lib/logging.js index 8183ece1fd119..8b04d6370e66c 100644 --- a/workspaces/arborist/bin/lib/logging.js +++ b/workspaces/arborist/bin/lib/logging.js @@ -1,42 +1,78 @@ -const options = require('./options.js') -const { quiet = false } = options -const { loglevel = quiet ? 'warn' : 'silly' } = options +const log = require('proc-log') +const mkdirp = require('mkdirp') +const fs = require('fs') +const { dirname } = require('path') +const os = require('os') +const { inspect, format } = require('util') + +const { bin: options } = require('./options.js') -const levels = [ +// add a meta method to proc-log for passing optional +// metadata through to log handlers +const META = Symbol('meta') +const parseArgs = (...args) => { + const { [META]: isMeta } = args[args.length - 1] || {} + return isMeta + ? [args[args.length - 1], ...args.slice(0, args.length - 1)] + : [{}, ...args] +} +log.meta = (meta = {}) => ({ [META]: true, ...meta }) + +const levels = new Map([ 'silly', 'verbose', 'info', - 'timing', 'http', 'notice', 'warn', 'error', 'silent', -] +].map((level, index) => [level, index])) -const levelMap = new Map(levels.reduce((set, level, index) => { - set.push([level, index], [index, level]) - return set -}, [])) +const addLogListener = (write, { eol = os.EOL, loglevel = 'silly', colors = false } = {}) => { + const levelIndex = levels.get(loglevel) -const { inspect, format } = require('util') -const colors = process.stderr.isTTY -const magenta = colors ? msg => `\x1B[35m${msg}\x1B[39m` : m => m -if (loglevel !== 'silent') { - process.on('log', (level, ...args) => { - if (levelMap.get(level) < levelMap.get(loglevel)) { - return + const magenta = m => colors ? `\x1B[35m${m}\x1B[39m` : m + const dim = m => colors ? `\x1B[2m${m}\x1B[22m` : m + const red = m => colors ? `\x1B[31m${m}\x1B[39m` : m + + const formatter = (level, ...args) => { + const depth = level === 'error' && args[0] && args[0].code === 'ERESOLVE' ? Infinity : 10 + + if (level === 'info' && args[0] === 'timeEnd') { + args[1] = dim(args[1]) + } else if (level === 'error' && args[0] === 'timeError') { + args[1] = red(args[1]) } + + const messages = args.map(a => typeof a === 'string' ? a : inspect(a, { depth, colors })) const pref = `${process.pid} ${magenta(level)} ` - if (level === 'warn' && args[0] === 'ERESOLVE') { - args[2] = inspect(args[2], { depth: 10, colors }) - } else { - args = args.map(a => { - return typeof a === 'string' ? a - : inspect(a, { depth: 10, colors }) - }) + + return pref + format(...messages).trim().split('\n').join(`${eol}${pref}`) + eol + } + + process.on('log', (...args) => { + const [meta, level, ...logArgs] = parseArgs(...args) + + if (levelIndex <= levels.get(level) || meta.force) { + write(formatter(level, ...logArgs)) } - const msg = pref + format(...args).trim().split('\n').join(`\n${pref}`) - console.error(msg) }) } + +if (options.loglevel !== 'silent') { + addLogListener((v) => process.stderr.write(v), { + eol: '\n', + colors: options.colors, + loglevel: options.loglevel, + }) +} + +if (options.logfile) { + log.silly('logfile', options.logfile) + mkdirp.sync(dirname(options.logfile)) + const fd = fs.openSync(options.logfile, 'a') + addLogListener((str) => fs.writeSync(fd, str)) +} + +module.exports = log diff --git a/workspaces/arborist/bin/lib/options.js b/workspaces/arborist/bin/lib/options.js index 23e89ddce698b..8dbaf13dac03a 100644 --- a/workspaces/arborist/bin/lib/options.js +++ b/workspaces/arborist/bin/lib/options.js @@ -1,59 +1,123 @@ -const options = module.exports = { - path: undefined, - cache: `${process.env.HOME}/.npm/_cacache`, - _: [], +const nopt = require('nopt') +const path = require('path') + +const has = (o, k) => Object.prototype.hasOwnProperty.call(o, k) + +const cleanPath = (val) => { + const k = Symbol('key') + const data = {} + nopt.typeDefs.path.validate(data, k, val) + return data[k] } -for (const arg of process.argv.slice(2)) { - if (/^--add=/.test(arg)) { - options.add = options.add || [] - options.add.push(arg.substr('--add='.length)) - } else if (/^--rm=/.test(arg)) { - options.rm = options.rm || [] - options.rm.push(arg.substr('--rm='.length)) - } else if (arg === '--global') { - options.global = true - } else if (arg === '--global-style') { - options.globalStyle = true - } else if (arg === '--prefer-dedupe') { - options.preferDedupe = true - } else if (arg === '--legacy-peer-deps') { - options.legacyPeerDeps = true - } else if (arg === '--force') { - options.force = true - } else if (arg === '--update-all') { - options.update = options.update || {} - options.update.all = true - } else if (/^--update=/.test(arg)) { - options.update = options.update || {} - options.update.names = options.update.names || [] - options.update.names.push(arg.substr('--update='.length)) - } else if (/^--omit=/.test(arg)) { - options.omit = options.omit || [] - options.omit.push(arg.substr('--omit='.length)) - } else if (/^--before=/.test(arg)) { - options.before = new Date(arg.substr('--before='.length)) - } else if (/^-w.+/.test(arg)) { - options.workspaces = options.workspaces || [] - options.workspaces.push(arg.replace(/^-w/, '')) - } else if (/^--workspace=/.test(arg)) { - options.workspaces = options.workspaces || [] - options.workspaces.push(arg.replace(/^--workspace=/, '')) - } else if (/^--[^=]+=/.test(arg)) { - const [key, ...v] = arg.replace(/^--/, '').split('=') - const val = v.join('=') - options[key] = val === 'false' ? false : val === 'true' ? true : val - } else if (/^--.+/.test(arg)) { - options[arg.replace(/^--/, '')] = true - } else if (options.path === undefined) { - options.path = arg - } else { - options._.push(arg) +const parse = (...noptArgs) => { + const binOnlyOpts = { + command: String, + loglevel: String, + colors: Boolean, + timing: ['always', Boolean], + logfile: String, + } + + const arbOpts = { + add: Array, + rm: Array, + omit: Array, + update: Array, + workspaces: Array, + global: Boolean, + force: Boolean, + 'global-style': Boolean, + 'prefer-dedupe': Boolean, + 'legacy-peer-deps': Boolean, + 'update-all': Boolean, + before: Date, + path: path, + cache: path, + ...binOnlyOpts, + } + + const short = { + quiet: ['--loglevel', 'warn'], + logs: ['--logfile', 'true'], + w: '--workspaces', + g: '--global', + f: '--force', + } + + const defaults = { + // key order is important for command and path + // since they shift positional args + // command is 1st, path is 2nd + command: (o) => o.argv.remain.shift(), + path: (o) => cleanPath(o.argv.remain.shift() || '.'), + colors: has(process.env, 'NO_COLOR') ? false : !!process.stderr.isTTY, + loglevel: 'silly', + timing: (o) => o.loglevel === 'silly', + cache: `${process.env.HOME}/.npm/_cacache`, + } + + const derived = [ + // making update either `all` or an array of names but not both + ({ updateAll: all, update: names, ...o }) => { + if (all || names) { + o.update = all != null ? { all } : { names } + } + return o + }, + ({ logfile, ...o }) => { + // logfile is parsed as a string so if its true or set but empty + // then set the default logfile + if (logfile === 'true' || logfile === '') { + logfile = `arb-log-${new Date().toISOString().replace(/[.:]/g, '_')}.log` + } + // then parse it the same as nopt parses other paths + if (logfile) { + o.logfile = cleanPath(logfile) + } + return o + }, + ] + + const transforms = [ + // Camelcase all top level keys + (o) => { + const entries = Object.entries(o).map(([k, v]) => [ + k.replace(/-./g, s => s[1].toUpperCase()), + v, + ]) + return Object.fromEntries(entries) + }, + // Set defaults on unset keys + (o) => { + for (const [k, v] of Object.entries(defaults)) { + if (!has(o, k)) { + o[k] = typeof v === 'function' ? v(o) : v + } + } + return o + }, + // Set/unset derived values + ...derived.map((derive) => (o) => derive(o) || o), + // Separate bin and arborist options + ({ argv: { remain: _ }, ...o }) => { + const bin = { _ } + for (const k of Object.keys(binOnlyOpts)) { + if (has(o, k)) { + bin[k] = o[k] + delete o[k] + } + } + return { bin, arb: o } + }, + ] + + let options = nopt(arbOpts, short, ...noptArgs) + for (const t of transforms) { + options = t(options) } -} -if (options.path === undefined) { - options.path = '.' + return options } -console.error(options) +module.exports = parse() diff --git a/workspaces/arborist/bin/lib/print-tree.js b/workspaces/arborist/bin/lib/print-tree.js index 1ea2a72187332..55398190b99cb 100644 --- a/workspaces/arborist/bin/lib/print-tree.js +++ b/workspaces/arborist/bin/lib/print-tree.js @@ -1,5 +1,4 @@ const { inspect } = require('util') -const { quiet } = require('./options.js') +const log = require('./logging.js') -module.exports = quiet ? () => {} - : tree => console.log(inspect(tree.toJSON(), { depth: Infinity })) +module.exports = tree => log.info(inspect(tree.toJSON(), { depth: Infinity })) diff --git a/workspaces/arborist/bin/lib/timers.js b/workspaces/arborist/bin/lib/timers.js index 242431980e55c..586dee7806dd0 100644 --- a/workspaces/arborist/bin/lib/timers.js +++ b/workspaces/arborist/bin/lib/timers.js @@ -1,31 +1,33 @@ -const timers = Object.create(null) -const { format } = require('util') -const options = require('./options.js') +const { bin: options } = require('./options.js') +const log = require('./logging.js') + +const timers = new Map() +const finished = new Map() process.on('time', name => { - if (timers[name]) { + if (timers.has(name)) { throw new Error('conflicting timer! ' + name) } - timers[name] = process.hrtime() + timers.set(name, process.hrtime.bigint()) }) -const dim = process.stderr.isTTY ? msg => `\x1B[2m${msg}\x1B[22m` : m => m -const red = process.stderr.isTTY ? msg => `\x1B[31m${msg}\x1B[39m` : m => m process.on('timeEnd', name => { - if (!timers[name]) { + if (!timers.has(name)) { throw new Error('timer not started! ' + name) } - const res = process.hrtime(timers[name]) - delete timers[name] - const msg = format(`${process.pid} ${name}`, res[0] * 1e3 + res[1] / 1e6) - if (options.timers !== false) { - console.error(dim(msg)) + const elapsed = Number(process.hrtime.bigint() - timers.get(name)) + timers.delete(name) + finished.set(name, elapsed) + if (options.timing) { + log.info('timeEnd', `${name} ${elapsed / 1e9}s`, log.meta({ force: options.timing === 'always' })) } }) process.on('exit', () => { - for (const name of Object.keys(timers)) { - console.error(red('Dangling timer:'), name) + for (const name of timers.keys()) { + log.error('timeError', 'Dangling timer:', name) process.exitCode = 1 } }) + +module.exports = finished diff --git a/workspaces/arborist/bin/license.js b/workspaces/arborist/bin/license.js index af34fece67a46..77d5796793a46 100644 --- a/workspaces/arborist/bin/license.js +++ b/workspaces/arborist/bin/license.js @@ -1,39 +1,48 @@ -const Arborist = require('../') const localeCompare = require('@isaacs/string-locale-compare')('en') -const options = require('./lib/options.js') -require('./lib/logging.js') -require('./lib/timers.js') +const Arborist = require('../') +const log = require('./lib/logging.js') -const a = new Arborist(options) -const query = options._.shift() +module.exports = (options, time) => { + const query = options._.shift() + const a = new Arborist(options) + return a + .loadVirtual() + .then(tree => { + // only load the actual tree if the virtual one doesn't have modern metadata + if (!tree.meta || !(tree.meta.originalLockfileVersion >= 2)) { + throw 'load actual' + } else { + return tree + } + }).catch((er) => { + log.error('loading actual tree', er) + return a.loadActual() + }) + .then(time) + .then(({ result: tree }) => { + const output = [] + if (!query) { + const set = [] + for (const license of tree.inventory.query('license')) { + set.push([tree.inventory.query('license', license).size, license]) + } -a.loadVirtual().then(tree => { - // only load the actual tree if the virtual one doesn't have modern metadata - if (!tree.meta || !(tree.meta.originalLockfileVersion >= 2)) { - throw 'load actual' - } else { - return tree - } -}).catch((er) => { - console.error('loading actual tree', er) - return a.loadActual() -}).then(tree => { - if (!query) { - const set = [] - for (const license of tree.inventory.query('license')) { - set.push([tree.inventory.query('license', license).size, license]) - } + for (const [count, license] of set.sort((a, b) => + a[1] && b[1] ? b[0] - a[0] || localeCompare(a[1], b[1]) + : a[1] ? -1 + : b[1] ? 1 + : 0)) { + output.push(`${count} ${license}`) + log.info(count, license) + } + } else { + for (const node of tree.inventory.query('license', query === 'undefined' ? undefined : query)) { + const msg = `${node.name} ${node.location} ${node.package.description || ''}` + output.push(msg) + log.info(msg) + } + } - for (const [count, license] of set.sort((a, b) => - a[1] && b[1] ? b[0] - a[0] || localeCompare(a[1], b[1]) - : a[1] ? -1 - : b[1] ? 1 - : 0)) { - console.log(count, license) - } - } else { - for (const node of tree.inventory.query('license', query === 'undefined' ? undefined : query)) { - console.log(`${node.name} ${node.location} ${node.package.description || ''}`) - } - } -}) + return output.join('\n') + }) +} diff --git a/workspaces/arborist/bin/prune.js b/workspaces/arborist/bin/prune.js index e11858c209f25..3c52bc13af1e1 100644 --- a/workspaces/arborist/bin/prune.js +++ b/workspaces/arborist/bin/prune.js @@ -1,9 +1,7 @@ const Arborist = require('../') -const options = require('./lib/options.js') -const print = require('./lib/print-tree.js') -require('./lib/logging.js') -require('./lib/timers.js') +const printTree = require('./lib/print-tree.js') +const log = require('./lib/logging.js') const printDiff = diff => { const { depth } = require('treeverse') @@ -15,13 +13,13 @@ const printDiff = diff => { } switch (d.action) { case 'REMOVE': - console.error('REMOVE', d.actual.location) + log.info('REMOVE', d.actual.location) break case 'ADD': - console.error('ADD', d.ideal.location, d.ideal.resolved) + log.info('ADD', d.ideal.location, d.ideal.resolved) break case 'CHANGE': - console.error('CHANGE', d.actual.location, { + log.info('CHANGE', d.actual.location, { from: d.actual.resolved, to: d.ideal.resolved, }) @@ -32,18 +30,19 @@ const printDiff = diff => { }) } -const start = process.hrtime() -process.emit('time', 'install') -const arb = new Arborist(options) -arb.prune(options).then(tree => { - process.emit('timeEnd', 'install') - const end = process.hrtime(start) - print(tree) - if (options.dryRun) { - printDiff(arb.diff) - } - console.error(`resolved ${tree.inventory.size} deps in ${end[0] + end[1] / 1e9}s`) - if (tree.meta && options.save) { - tree.meta.save() - } -}).catch(er => console.error(require('util').inspect(er, { depth: Infinity }))) +module.exports = (options, time) => { + const arb = new Arborist(options) + return arb + .prune(options) + .then(time) + .then(async ({ timing, result: tree }) => { + printTree(tree) + if (options.dryRun) { + printDiff(arb.diff) + } + if (tree.meta && options.save) { + await tree.meta.save() + } + return `resolved ${tree.inventory.size} deps in ${timing.seconds}` + }) +} diff --git a/workspaces/arborist/bin/reify.js b/workspaces/arborist/bin/reify.js index 9dc26d2b96835..3f3aafe8ab9bb 100644 --- a/workspaces/arborist/bin/reify.js +++ b/workspaces/arborist/bin/reify.js @@ -1,9 +1,7 @@ const Arborist = require('../') -const options = require('./lib/options.js') -const print = require('./lib/print-tree.js') -require('./lib/logging.js') -require('./lib/timers.js') +const printTree = require('./lib/print-tree.js') +const log = require('./lib/logging.js') const printDiff = diff => { const { depth } = require('treeverse') @@ -15,13 +13,13 @@ const printDiff = diff => { } switch (d.action) { case 'REMOVE': - console.error('REMOVE', d.actual.location) + log.info('REMOVE', d.actual.location) break case 'ADD': - console.error('ADD', d.ideal.location, d.ideal.resolved) + log.info('ADD', d.ideal.location, d.ideal.resolved) break case 'CHANGE': - console.error('CHANGE', d.actual.location, { + log.info('CHANGE', d.actual.location, { from: d.actual.resolved, to: d.ideal.resolved, }) @@ -32,18 +30,19 @@ const printDiff = diff => { }) } -const start = process.hrtime() -process.emit('time', 'install') -const arb = new Arborist(options) -arb.reify(options).then(tree => { - process.emit('timeEnd', 'install') - const end = process.hrtime(start) - print(tree) - if (options.dryRun) { - printDiff(arb.diff) - } - console.error(`resolved ${tree.inventory.size} deps in ${end[0] + end[1] / 1e9}s`) - if (tree.meta && options.save) { - tree.meta.save() - } -}).catch(er => console.error(require('util').inspect(er, { depth: Infinity }))) +module.exports = (options, time) => { + const arb = new Arborist(options) + return arb + .reify(options) + .then(time) + .then(async ({ timing, result: tree }) => { + printTree(tree) + if (options.dryRun) { + printDiff(arb.diff) + } + if (tree.meta && options.save) { + await tree.meta.save() + } + return `resolved ${tree.inventory.size} deps in ${timing.seconds}` + }) +} diff --git a/workspaces/arborist/bin/shrinkwrap.js b/workspaces/arborist/bin/shrinkwrap.js index b40416b7b9e1f..56603224e9988 100644 --- a/workspaces/arborist/bin/shrinkwrap.js +++ b/workspaces/arborist/bin/shrinkwrap.js @@ -1,12 +1,7 @@ const Shrinkwrap = require('../lib/shrinkwrap.js') -const options = require('./lib/options.js') -require('./lib/logging.js') -require('./lib/timers.js') -const { quiet } = options -Shrinkwrap.load(options) - .then(s => quiet || console.log(JSON.stringify(s.commit(), 0, 2))) - .catch(er => { - console.error('shrinkwrap load failure', er) - process.exit(1) - }) +module.exports = (options, time) => Shrinkwrap + .load(options) + .then((s) => s.commit()) + .then(time) + .then(({ result: s }) => JSON.stringify(s, 0, 2)) diff --git a/workspaces/arborist/bin/virtual.js b/workspaces/arborist/bin/virtual.js index 457c945e72c21..95b1de282e603 100644 --- a/workspaces/arborist/bin/virtual.js +++ b/workspaces/arborist/bin/virtual.js @@ -1,18 +1,14 @@ const Arborist = require('../') -const print = require('./lib/print-tree.js') -const options = require('./lib/options.js') -require('./lib/logging.js') -require('./lib/timers.js') +const printTree = require('./lib/print-tree.js') -const start = process.hrtime() -new Arborist(options).loadVirtual().then(tree => { - const end = process.hrtime(start) - if (!options.quiet) { - print(tree) - } - if (options.save) { - tree.meta.save() - } - console.error(`read ${tree.inventory.size} deps in ${end[0] * 1000 + end[1] / 1e6}ms`) -}).catch(er => console.error(er)) +module.exports = (options, time) => new Arborist(options) + .loadVirtual() + .then(time) + .then(async ({ timing, result: tree }) => { + printTree(tree) + if (options.save) { + await tree.meta.save() + } + return `read ${tree.inventory.size} deps in ${timing.ms}` + }) diff --git a/workspaces/arborist/package.json b/workspaces/arborist/package.json index 3864d55d94568..d8d27bcfcc3a2 100644 --- a/workspaces/arborist/package.json +++ b/workspaces/arborist/package.json @@ -19,6 +19,7 @@ "json-stringify-nice": "^1.1.4", "mkdirp": "^1.0.4", "mkdirp-infer-owner": "^2.0.0", + "nopt": "^5.0.0", "npm-install-checks": "^4.0.0", "npm-package-arg": "^9.0.0", "npm-pick-manifest": "^7.0.0", From 6b68c1aaa282205eb4d47dbc81909c11851f7e06 Mon Sep 17 00:00:00 2001 From: Wassim Chegham <1699357+manekinekko@users.noreply.github.com> Date: Thu, 24 Feb 2022 18:46:37 +0100 Subject: [PATCH 28/43] docs: auto-generate npm usage for each command (#4450) Closes #4189 * docs: auto-generate synopsis sections * feat: improve usage auto-generation' * chore: auto-generate npm usage for each command * docs: print default usage when usage is missing * docs: add special case for npx * fix: remove optional chaining --- docs/content/commands/npm-access.md | 12 +- docs/content/commands/npm-adduser.md | 11 +- docs/content/commands/npm-audit.md | 14 ++- docs/content/commands/npm-bin.md | 11 +- docs/content/commands/npm-bugs.md | 13 ++- docs/content/commands/npm-cache.md | 24 ++-- docs/content/commands/npm-ci.md | 11 ++ docs/content/commands/npm-completion.md | 11 +- docs/content/commands/npm-config.md | 11 +- docs/content/commands/npm-dedupe.md | 30 ++++- docs/content/commands/npm-deprecate.md | 11 +- docs/content/commands/npm-diff.md | 13 ++- docs/content/commands/npm-dist-tag.md | 11 +- docs/content/commands/npm-docs.md | 11 +- docs/content/commands/npm-doctor.md | 9 ++ docs/content/commands/npm-edit.md | 11 +- docs/content/commands/npm-exec.md | 21 ++-- docs/content/commands/npm-explain.md | 9 ++ docs/content/commands/npm-explore.md | 9 ++ docs/content/commands/npm-find-dupes.md | 11 ++ docs/content/commands/npm-fund.md | 12 +- docs/content/commands/npm-help-search.md | 9 ++ docs/content/commands/npm-help.md | 11 ++ docs/content/commands/npm-hook.md | 13 ++- docs/content/commands/npm-init.md | 18 ++- docs/content/commands/npm-install-ci-test.md | 11 +- docs/content/commands/npm-install-test.md | 37 +++++-- docs/content/commands/npm-install.md | 38 ++++--- docs/content/commands/npm-link.md | 22 +++- docs/content/commands/npm-logout.md | 11 +- docs/content/commands/npm-ls.md | 11 +- docs/content/commands/npm-org.md | 17 ++- docs/content/commands/npm-outdated.md | 9 ++ docs/content/commands/npm-owner.md | 11 +- docs/content/commands/npm-pack.md | 11 +- docs/content/commands/npm-ping.md | 11 +- docs/content/commands/npm-pkg.md | 15 ++- docs/content/commands/npm-prefix.md | 9 ++ docs/content/commands/npm-profile.md | 16 ++- docs/content/commands/npm-prune.md | 11 +- docs/content/commands/npm-publish.md | 14 ++- docs/content/commands/npm-rebuild.md | 9 ++ docs/content/commands/npm-repo.md | 9 ++ docs/content/commands/npm-restart.md | 9 ++ docs/content/commands/npm-root.md | 11 +- docs/content/commands/npm-run-script.md | 13 ++- docs/content/commands/npm-search.md | 11 +- docs/content/commands/npm-set-script.md | 9 ++ docs/content/commands/npm-shrinkwrap.md | 9 ++ docs/content/commands/npm-star.md | 9 ++ docs/content/commands/npm-stars.md | 10 ++ docs/content/commands/npm-start.md | 9 ++ docs/content/commands/npm-stop.md | 9 ++ docs/content/commands/npm-team.md | 19 +++- docs/content/commands/npm-test.md | 11 +- docs/content/commands/npm-token.md | 16 ++- docs/content/commands/npm-uninstall.md | 22 +++- docs/content/commands/npm-unstar.md | 9 ++ docs/content/commands/npm-update.md | 31 +++++- docs/content/commands/npm-version.md | 15 ++- docs/content/commands/npm-view.md | 13 ++- docs/content/commands/npm-whoami.md | 11 +- docs/content/commands/npm.md | 5 +- docs/content/commands/npx.md | 24 ++-- scripts/config-doc-command.js | 111 ++++++++++++++++--- 65 files changed, 821 insertions(+), 164 deletions(-) diff --git a/docs/content/commands/npm-access.md b/docs/content/commands/npm-access.md index 1f661c911f47d..162e94f1fec02 100644 --- a/docs/content/commands/npm-access.md +++ b/docs/content/commands/npm-access.md @@ -6,21 +6,27 @@ description: Set access level on published packages ### Synopsis + + + + ```bash npm access public [] npm access restricted [] - npm access grant [] npm access revoke [] - npm access 2fa-required [] npm access 2fa-not-required [] - npm access ls-packages [||] npm access ls-collaborators [ []] npm access edit [] ``` + + + + + ### Description Used to set access controls on private packages. diff --git a/docs/content/commands/npm-adduser.md b/docs/content/commands/npm-adduser.md index 21a31ca940e52..06eeb379c4dd8 100644 --- a/docs/content/commands/npm-adduser.md +++ b/docs/content/commands/npm-adduser.md @@ -6,12 +6,21 @@ description: Add a registry user account ### Synopsis + + + + ```bash -npm adduser [--registry=url] [--scope=@orgname] [--auth-type=legacy] +npm adduser aliases: login, add-user ``` + + + + + Note: This command is unaware of workspaces. ### Description diff --git a/docs/content/commands/npm-audit.md b/docs/content/commands/npm-audit.md index 58c614d793db2..323d38f64c14f 100644 --- a/docs/content/commands/npm-audit.md +++ b/docs/content/commands/npm-audit.md @@ -6,13 +6,19 @@ description: Run a security audit ### Synopsis -```bash -npm audit [--json] [--production] [--audit-level=(low|moderate|high|critical)] -npm audit fix [--force|--package-lock-only|--dry-run|--production|--only=(dev|prod)] + + + -common options: [--production] [--only=(dev|prod)] +```bash +npm audit [fix] ``` + + + + + ### Description The audit command submits a description of the dependencies configured in diff --git a/docs/content/commands/npm-bin.md b/docs/content/commands/npm-bin.md index 2d7c1d5b8149e..94b72cfd5c81c 100644 --- a/docs/content/commands/npm-bin.md +++ b/docs/content/commands/npm-bin.md @@ -6,10 +6,19 @@ description: Display npm bin folder ### Synopsis + + + + ```bash -npm bin [-g|--global] +npm bin ``` + + + + + Note: This command is unaware of workspaces. ### Description diff --git a/docs/content/commands/npm-bugs.md b/docs/content/commands/npm-bugs.md index f92241a14b95c..aeddeb848e81b 100644 --- a/docs/content/commands/npm-bugs.md +++ b/docs/content/commands/npm-bugs.md @@ -6,12 +6,21 @@ description: Report bugs for a package in a web browser ### Synopsis + + + + ```bash -npm bugs [ [ ...]] +npm bugs [] -aliases: issues +alias: issues ``` + + + + + ### Description This command tries to guess at the likely location of a package's bug diff --git a/docs/content/commands/npm-cache.md b/docs/content/commands/npm-cache.md index 6497a3988c938..091e26e8a7182 100644 --- a/docs/content/commands/npm-cache.md +++ b/docs/content/commands/npm-cache.md @@ -6,18 +6,26 @@ description: Manipulates packages cache ### Synopsis -```bash -npm cache add ... -npm cache add ... -npm cache add ... -npm cache add @... - -npm cache clean -aliases: npm cache clear, npm cache rm + + + +```bash +npm cache add +npm cache add +npm cache add +npm cache add +npm cache add @ +npm cache clean [] +npm cache ls [@] npm cache verify ``` + + + + + Note: This command is unaware of workspaces. ### Description diff --git a/docs/content/commands/npm-ci.md b/docs/content/commands/npm-ci.md index 1ce50c66d5faf..4490fea9a0bb7 100644 --- a/docs/content/commands/npm-ci.md +++ b/docs/content/commands/npm-ci.md @@ -6,10 +6,21 @@ description: Install a project with a clean slate ### Synopsis + + + + ```bash npm ci + +aliases: clean-install, ic, install-clean, isntall-clean ``` + + + + + ### Description This command is similar to [`npm install`](/commands/npm-install), except diff --git a/docs/content/commands/npm-completion.md b/docs/content/commands/npm-completion.md index 9dbd960913f27..d73a98f2e50f7 100644 --- a/docs/content/commands/npm-completion.md +++ b/docs/content/commands/npm-completion.md @@ -6,10 +6,19 @@ description: Tab Completion for npm ### Synopsis + + + + ```bash -source <(npm completion) +npm completion ``` + + + + + Note: This command is unaware of workspaces. ### Description diff --git a/docs/content/commands/npm-config.md b/docs/content/commands/npm-config.md index 2d77f045cbc47..a66a198ce42d1 100644 --- a/docs/content/commands/npm-config.md +++ b/docs/content/commands/npm-config.md @@ -6,18 +6,25 @@ description: Manage the npm configuration files ### Synopsis + + + + ```bash npm config set = [= ...] npm config get [ [ ...]] npm config delete [ ...] npm config list [--json] npm config edit -npm set = [= ...] -npm get [ [ ...]] alias: c ``` + + + + + Note: This command is unaware of workspaces. ### Description diff --git a/docs/content/commands/npm-dedupe.md b/docs/content/commands/npm-dedupe.md index 53d2e64272a67..b5a64831c0bba 100644 --- a/docs/content/commands/npm-dedupe.md +++ b/docs/content/commands/npm-dedupe.md @@ -6,13 +6,21 @@ description: Reduce duplication in the package tree ### Synopsis + + + + ```bash npm dedupe -npm ddp -aliases: ddp +alias: ddp ``` + + + + + ### Description Searches the local package tree and attempts to simplify the overall @@ -145,6 +153,24 @@ When package package-locks are disabled, automatic pruning of extraneous modules will also be disabled. To remove extraneous modules with package-locks disabled use `npm prune`. +This configuration does not affect `npm ci`. + + + + +#### `save` + +* Default: `true` unless when using `npm update` or `npm dedupe` where it + defaults to `false` +* Type: Boolean + +Save installed packages to a `package.json` file as dependencies. + +When used with the `npm rm` command, removes the dependency from +`package.json`. + +Will also prevent writing to `package-lock.json` if set to `false`. + diff --git a/docs/content/commands/npm-deprecate.md b/docs/content/commands/npm-deprecate.md index 438a54ec6e4f3..4345120d3744b 100644 --- a/docs/content/commands/npm-deprecate.md +++ b/docs/content/commands/npm-deprecate.md @@ -6,10 +6,19 @@ description: Deprecate a version of a package ### Synopsis + + + + ```bash -npm deprecate [@] +npm deprecate [@] ``` + + + + + Note: This command is unaware of workspaces. ### Description diff --git a/docs/content/commands/npm-diff.md b/docs/content/commands/npm-diff.md index 8d05df779f3ca..c4c9eafdb3524 100644 --- a/docs/content/commands/npm-diff.md +++ b/docs/content/commands/npm-diff.md @@ -6,14 +6,19 @@ description: The registry diff command ### Synopsis + + + + ```bash npm diff [...] -npm diff --diff= [...] -npm diff --diff= [--diff=] [...] -npm diff --diff= [--diff=] [...] -npm diff [--diff-ignore-all-space] [--diff-name-only] [...] ``` + + + + + ### Description Similar to its `git diff` counterpart, this command will print diff patches diff --git a/docs/content/commands/npm-dist-tag.md b/docs/content/commands/npm-dist-tag.md index a4e0243aac87b..a0f306cd4970d 100644 --- a/docs/content/commands/npm-dist-tag.md +++ b/docs/content/commands/npm-dist-tag.md @@ -6,14 +6,23 @@ description: Modify package distribution tags ### Synopsis + + + + ```bash npm dist-tag add @ [] npm dist-tag rm npm dist-tag ls [] -aliases: dist-tags +alias: dist-tags ``` + + + + + ### Description Add, remove, and enumerate distribution tags on a package: diff --git a/docs/content/commands/npm-docs.md b/docs/content/commands/npm-docs.md index 970d17aa829c6..8d5a278286a88 100644 --- a/docs/content/commands/npm-docs.md +++ b/docs/content/commands/npm-docs.md @@ -6,12 +6,21 @@ description: Open documentation for a package in a web browser ### Synopsis + + + + ```bash npm docs [ [ ...]] -aliases: home +alias: home ``` + + + + + ### Description This command tries to guess at the likely location of a package's diff --git a/docs/content/commands/npm-doctor.md b/docs/content/commands/npm-doctor.md index 0cce60c7b7b15..7fb63bab16e83 100644 --- a/docs/content/commands/npm-doctor.md +++ b/docs/content/commands/npm-doctor.md @@ -6,10 +6,19 @@ description: Check your npm environment ### Synopsis + + + + ```bash npm doctor ``` + + + + + Note: This command is unaware of workspaces. ### Description diff --git a/docs/content/commands/npm-edit.md b/docs/content/commands/npm-edit.md index 5ae7f2481ae45..39fc49592c571 100644 --- a/docs/content/commands/npm-edit.md +++ b/docs/content/commands/npm-edit.md @@ -6,10 +6,19 @@ description: Edit an installed package ### Synopsis + + + + ```bash -npm edit +npm edit [/...] ``` + + + + + Note: This command is unaware of workspaces. ### Description diff --git a/docs/content/commands/npm-exec.md b/docs/content/commands/npm-exec.md index d154f5780b9c9..3645e336b9da9 100644 --- a/docs/content/commands/npm-exec.md +++ b/docs/content/commands/npm-exec.md @@ -6,26 +6,23 @@ description: Run a command from a local or remote npm package ### Synopsis + + + + ```bash npm exec -- [@] [args...] npm exec --package=[@] -- [args...] npm exec -c ' [args...]' npm exec --package=foo -c ' [args...]' -npm exec [--ws] [-w [@] [args...] -npx -p [@] [args...] -npx -c ' [args...]' -npx -p [@] -c ' [args...]' -Run without --call or positional args to open interactive subshell +alias: x +``` -alias: npm x, npx + + -common options: ---package= (may be specified multiple times) --p is a shorthand for --package only when using npx executable --c --call= (may not be mixed with positional arguments) -``` + ### Description diff --git a/docs/content/commands/npm-explain.md b/docs/content/commands/npm-explain.md index 5f05cac0f906b..765221056585d 100644 --- a/docs/content/commands/npm-explain.md +++ b/docs/content/commands/npm-explain.md @@ -6,12 +6,21 @@ description: Explain installed packages ### Synopsis + + + + ```bash npm explain alias: why ``` + + + + + ### Description This command will print the chain of dependencies causing a given package diff --git a/docs/content/commands/npm-explore.md b/docs/content/commands/npm-explore.md index 3979da9573db0..90753c7e09199 100644 --- a/docs/content/commands/npm-explore.md +++ b/docs/content/commands/npm-explore.md @@ -6,10 +6,19 @@ description: Browse an installed package ### Synopsis + + + + ```bash npm explore [ -- ] ``` + + + + + Note: This command is unaware of workspaces. ### Description diff --git a/docs/content/commands/npm-find-dupes.md b/docs/content/commands/npm-find-dupes.md index f7dc84f9c5306..f7366fa6375d1 100644 --- a/docs/content/commands/npm-find-dupes.md +++ b/docs/content/commands/npm-find-dupes.md @@ -6,10 +6,19 @@ description: Find duplication in the package tree ### Synopsis + + + + ```bash npm find-dupes ``` + + + + + ### Description Runs `npm dedupe` in `--dry-run` mode, making npm only output the @@ -82,6 +91,8 @@ When package package-locks are disabled, automatic pruning of extraneous modules will also be disabled. To remove extraneous modules with package-locks disabled use `npm prune`. +This configuration does not affect `npm ci`. + diff --git a/docs/content/commands/npm-fund.md b/docs/content/commands/npm-fund.md index 606b0a188c554..5b96e91ab8ccb 100644 --- a/docs/content/commands/npm-fund.md +++ b/docs/content/commands/npm-fund.md @@ -6,11 +6,19 @@ description: Retrieve funding information ### Synopsis + + + + ```bash -npm fund [] -npm fund [-w ] +npm fund [[<@scope>/]] ``` + + + + + ### Description This command retrieves information on how to fund the dependencies of a diff --git a/docs/content/commands/npm-help-search.md b/docs/content/commands/npm-help-search.md index 78553a14ecb01..152f9f6bec16f 100644 --- a/docs/content/commands/npm-help-search.md +++ b/docs/content/commands/npm-help-search.md @@ -6,10 +6,19 @@ description: Search npm help documentation ### Synopsis + + + + ```bash npm help-search ``` + + + + + Note: This command is unaware of workspaces. ### Description diff --git a/docs/content/commands/npm-help.md b/docs/content/commands/npm-help.md index a8002eef17156..83c595db696b9 100644 --- a/docs/content/commands/npm-help.md +++ b/docs/content/commands/npm-help.md @@ -6,10 +6,21 @@ description: Get help on npm ### Synopsis + + + + ```bash npm help [] + +alias: hlep ``` + + + + + Note: This command is unaware of workspaces. ### Description diff --git a/docs/content/commands/npm-hook.md b/docs/content/commands/npm-hook.md index c91bce3075e7b..4a9805d02f9d4 100644 --- a/docs/content/commands/npm-hook.md +++ b/docs/content/commands/npm-hook.md @@ -6,13 +6,22 @@ description: Manage registry hooks ### Synopsis + + + + ```bash +npm hook add [--type=] npm hook ls [pkg] -npm hook add -npm hook update [secret] npm hook rm +npm hook update ``` + + + + + Note: This command is unaware of workspaces. ### Description diff --git a/docs/content/commands/npm-init.md b/docs/content/commands/npm-init.md index e9212a37e0f25..d9c03aef41504 100644 --- a/docs/content/commands/npm-init.md +++ b/docs/content/commands/npm-init.md @@ -6,13 +6,23 @@ description: Create a package.json file ### Synopsis + + + + ```bash -npm init [--yes|-y|--scope] -npm init <@scope> (same as `npm exec <@scope>/create`) -npm init [<@scope>/] (same as `npm exec [<@scope>/]create-`) -npm init [-w ] [args...] +npm init [--force|-f|--yes|-y|--scope] +npm init <@scope> (same as `npx <@scope>/create`) +npm init [<@scope>/] (same as `npx [<@scope>/]create-`) + +aliases: create, innit ``` + + + + + ### Description `npm init ` can be used to set up a new or existing npm diff --git a/docs/content/commands/npm-install-ci-test.md b/docs/content/commands/npm-install-ci-test.md index 5c37ed8f56128..5ad67604541d1 100644 --- a/docs/content/commands/npm-install-ci-test.md +++ b/docs/content/commands/npm-install-ci-test.md @@ -6,12 +6,21 @@ description: Install a project with a clean slate and run tests ### Synopsis + + + + ```bash npm install-ci-test -alias: npm cit +alias: cit ``` + + + + + ### Description This command runs `npm ci` followed immediately by `npm test`. diff --git a/docs/content/commands/npm-install-test.md b/docs/content/commands/npm-install-test.md index c464e5bd0b8c6..ed39c6705a484 100644 --- a/docs/content/commands/npm-install-test.md +++ b/docs/content/commands/npm-install-test.md @@ -6,20 +6,30 @@ description: Install package(s) and run tests ### Synopsis + + + + ```bash -npm install-test (with no args, in package dir) -npm install-test [<@scope>/] -npm install-test [<@scope>/]@ -npm install-test [<@scope>/]@ -npm install-test [<@scope>/]@ +npm install-test [<@scope>/] +npm install-test [<@scope>/]@ +npm install-test [<@scope>/]@ +npm install-test [<@scope>/]@ +npm install-test @npm: +npm install-test npm install-test npm install-test -npm install-test +npm install-test +npm install-test / -alias: npm it -common options: [--save|--save-dev|--save-optional] [--save-exact] [--dry-run] +alias: it ``` + + + + + ### Description This command runs an `npm install` followed immediately by an `npm test`. It @@ -32,13 +42,16 @@ takes exactly the same arguments as `npm install`. #### `save` -* Default: true +* Default: `true` unless when using `npm update` or `npm dedupe` where it + defaults to `false` * Type: Boolean -Save installed packages to a package.json file as dependencies. +Save installed packages to a `package.json` file as dependencies. When used with the `npm rm` command, removes the dependency from -package.json. +`package.json`. + +Will also prevent writing to `package-lock.json` if set to `false`. @@ -133,6 +146,8 @@ When package package-locks are disabled, automatic pruning of extraneous modules will also be disabled. To remove extraneous modules with package-locks disabled use `npm prune`. +This configuration does not affect `npm ci`. + diff --git a/docs/content/commands/npm-install.md b/docs/content/commands/npm-install.md index b4f8da8373d05..66193e733133b 100644 --- a/docs/content/commands/npm-install.md +++ b/docs/content/commands/npm-install.md @@ -6,23 +6,30 @@ description: Install a package ### Synopsis + + + + ```bash -npm install (with no args, in package dir) -npm install [<@scope>/] -npm install [<@scope>/]@ -npm install [<@scope>/]@ -npm install [<@scope>/]@ +npm install [<@scope>/] +npm install [<@scope>/]@ +npm install [<@scope>/]@ +npm install [<@scope>/]@ npm install @npm: -npm install :/ -npm install +npm install npm install npm install -npm install +npm install +npm install / -aliases: npm i, npm add -common options: [-P|--save-prod|-D|--save-dev|-O|--save-optional|--save-peer] [-E|--save-exact] [-B|--save-bundle] [--no-save] [--dry-run] +aliases: i, in, ins, inst, insta, instal, isnt, isnta, isntal, add ``` + + + + + ### Description This command installs a package and any packages that it depends on. If the @@ -425,13 +432,16 @@ These are some of the most common options related to installation. #### `save` -* Default: true +* Default: `true` unless when using `npm update` or `npm dedupe` where it + defaults to `false` * Type: Boolean -Save installed packages to a package.json file as dependencies. +Save installed packages to a `package.json` file as dependencies. When used with the `npm rm` command, removes the dependency from -package.json. +`package.json`. + +Will also prevent writing to `package-lock.json` if set to `false`. @@ -526,6 +536,8 @@ When package package-locks are disabled, automatic pruning of extraneous modules will also be disabled. To remove extraneous modules with package-locks disabled use `npm prune`. +This configuration does not affect `npm ci`. + diff --git a/docs/content/commands/npm-link.md b/docs/content/commands/npm-link.md index d4ef41ae96462..892b55496c9b6 100644 --- a/docs/content/commands/npm-link.md +++ b/docs/content/commands/npm-link.md @@ -6,13 +6,22 @@ description: Symlink a package folder ### Synopsis + + + + ```bash npm link (in package dir) npm link [<@scope>/][@] -alias: npm ln +alias: ln ``` + + + + + ### Description This is handy for installing your own stuff, so that you can work on it and @@ -116,13 +125,16 @@ workspace(s). #### `save` -* Default: true +* Default: `true` unless when using `npm update` or `npm dedupe` where it + defaults to `false` * Type: Boolean -Save installed packages to a package.json file as dependencies. +Save installed packages to a `package.json` file as dependencies. When used with the `npm rm` command, removes the dependency from -package.json. +`package.json`. + +Will also prevent writing to `package-lock.json` if set to `false`. @@ -217,6 +229,8 @@ When package package-locks are disabled, automatic pruning of extraneous modules will also be disabled. To remove extraneous modules with package-locks disabled use `npm prune`. +This configuration does not affect `npm ci`. + diff --git a/docs/content/commands/npm-logout.md b/docs/content/commands/npm-logout.md index cb7c8496fb479..f0dd5cb856eae 100644 --- a/docs/content/commands/npm-logout.md +++ b/docs/content/commands/npm-logout.md @@ -6,10 +6,19 @@ description: Log out of the registry ### Synopsis + + + + ```bash -npm logout [--registry=] [--scope=<@scope>] +npm logout ``` + + + + + Note: This command is unaware of workspaces. ### Description diff --git a/docs/content/commands/npm-ls.md b/docs/content/commands/npm-ls.md index 3b33f0a3605e0..0f06e131f414b 100644 --- a/docs/content/commands/npm-ls.md +++ b/docs/content/commands/npm-ls.md @@ -6,12 +6,21 @@ description: List installed packages ### Synopsis + + + + ```bash npm ls [[<@scope>/] ...] -aliases: list, la, ll +alias: list ``` + + + + + ### Description This command will print to stdout all the versions of packages that are diff --git a/docs/content/commands/npm-org.md b/docs/content/commands/npm-org.md index 2f08f61152992..975581c860df6 100644 --- a/docs/content/commands/npm-org.md +++ b/docs/content/commands/npm-org.md @@ -6,12 +6,23 @@ description: Manage orgs ### Synopsis + + + + ```bash -npm org set [developer | admin | owner] -npm org rm -npm org ls [] +npm org set orgname username [developer | admin | owner] +npm org rm orgname username +npm org ls orgname [] + +alias: ogr ``` + + + + + Note: This command is unaware of workspaces. ### Example diff --git a/docs/content/commands/npm-outdated.md b/docs/content/commands/npm-outdated.md index 1b58a6afda64b..6fa026550e747 100644 --- a/docs/content/commands/npm-outdated.md +++ b/docs/content/commands/npm-outdated.md @@ -6,10 +6,19 @@ description: Check for outdated packages ### Synopsis + + + + ```bash npm outdated [[<@scope>/] ...] ``` + + + + + ### Description This command will check the registry to see if any (or, specific) installed diff --git a/docs/content/commands/npm-owner.md b/docs/content/commands/npm-owner.md index 74e7f84af6c80..0779984e19a9d 100644 --- a/docs/content/commands/npm-owner.md +++ b/docs/content/commands/npm-owner.md @@ -6,14 +6,23 @@ description: Manage package owners ### Synopsis + + + + ```bash npm owner add [<@scope>/] npm owner rm [<@scope>/] npm owner ls [<@scope>/] -aliases: author +alias: author ``` + + + + + Note: This command is unaware of workspaces. ### Description diff --git a/docs/content/commands/npm-pack.md b/docs/content/commands/npm-pack.md index 53945986837b9..c834f643ac0bb 100644 --- a/docs/content/commands/npm-pack.md +++ b/docs/content/commands/npm-pack.md @@ -6,10 +6,19 @@ description: Create a tarball from a package ### Synopsis + + + + ```bash -npm pack [[<@scope>/]...] [--dry-run] [--json] +npm pack [[<@scope>/]...] ``` + + + + + ### Configuration diff --git a/docs/content/commands/npm-ping.md b/docs/content/commands/npm-ping.md index c59a56e611e54..161d7292f8c97 100644 --- a/docs/content/commands/npm-ping.md +++ b/docs/content/commands/npm-ping.md @@ -6,10 +6,19 @@ description: Ping npm registry ### Synopsis + + + + ```bash -npm ping [--registry ] +npm ping ``` + + + + + Note: This command is unaware of workspaces. ### Description diff --git a/docs/content/commands/npm-pkg.md b/docs/content/commands/npm-pkg.md index beee9c1c4e78a..8f6cbecf958fd 100644 --- a/docs/content/commands/npm-pkg.md +++ b/docs/content/commands/npm-pkg.md @@ -6,12 +6,21 @@ description: Manages your package.json ### Synopsis + + + + ```bash -npm pkg get [ [. ...]] -npm pkg set = [.= ...] -npm pkg delete [. ...] +npm pkg set = [= ...] +npm pkg get [ [ ...]] +npm pkg delete [ ...] ``` + + + + + ### Description A command that automates the management of `package.json` files. diff --git a/docs/content/commands/npm-prefix.md b/docs/content/commands/npm-prefix.md index 276a9e9e69910..39328bcc88a14 100644 --- a/docs/content/commands/npm-prefix.md +++ b/docs/content/commands/npm-prefix.md @@ -6,10 +6,19 @@ description: Display prefix ### Synopsis + + + + ```bash npm prefix [-g] ``` + + + + + Note: This command is unaware of workspaces. ### Description diff --git a/docs/content/commands/npm-profile.md b/docs/content/commands/npm-profile.md index cecc48518dbdb..af1f9d8aa1063 100644 --- a/docs/content/commands/npm-profile.md +++ b/docs/content/commands/npm-profile.md @@ -6,14 +6,22 @@ description: Change settings on your registry profile ### Synopsis + + + + ```bash -npm profile get [--json|--parseable] [] -npm profile set [--json|--parseable] -npm profile set password -npm profile enable-2fa [auth-and-writes|auth-only] +npm profile enable-2fa [auth-only|auth-and-writes] npm profile disable-2fa +npm profile get [] +npm profile set ``` + + + + + Note: This command is unaware of workspaces. ### Description diff --git a/docs/content/commands/npm-prune.md b/docs/content/commands/npm-prune.md index 658ab2610e0ed..49420e5b9d99c 100644 --- a/docs/content/commands/npm-prune.md +++ b/docs/content/commands/npm-prune.md @@ -6,10 +6,19 @@ description: Remove extraneous packages ### Synopsis + + + + ```bash -npm prune [[<@scope>/]...] [--production] [--dry-run] [--json] +npm prune [[<@scope>/]...] ``` + + + + + ### Description This command removes "extraneous" packages. If a package name is provided, diff --git a/docs/content/commands/npm-publish.md b/docs/content/commands/npm-publish.md index 6958b1066de7f..ce6e1c1012c8e 100644 --- a/docs/content/commands/npm-publish.md +++ b/docs/content/commands/npm-publish.md @@ -6,13 +6,19 @@ description: Publish a package ### Synopsis -```bash -npm publish [|] [--tag ] [--access ] [--otp otpcode] [--dry-run] + + + -Publishes '.' if no argument supplied -Sets tag 'latest' if no --tag specified +```bash +npm publish [] ``` + + + + + ### Description Publishes a package to the registry so that it can be installed by name. diff --git a/docs/content/commands/npm-rebuild.md b/docs/content/commands/npm-rebuild.md index 75e71c60e6810..ecb4a7ce34c62 100644 --- a/docs/content/commands/npm-rebuild.md +++ b/docs/content/commands/npm-rebuild.md @@ -6,12 +6,21 @@ description: Rebuild a package ### Synopsis + + + + ```bash npm rebuild [[<@scope>/][@] ...] alias: rb ``` + + + + + ### Description This command runs the `npm build` command on the matched folders. This is diff --git a/docs/content/commands/npm-repo.md b/docs/content/commands/npm-repo.md index cd47fde47127e..e14f07012a248 100644 --- a/docs/content/commands/npm-repo.md +++ b/docs/content/commands/npm-repo.md @@ -6,10 +6,19 @@ description: Open package repository page in the browser ### Synopsis + + + + ```bash npm repo [ [ ...]] ``` + + + + + ### Description This command tries to guess at the likely location of a package's diff --git a/docs/content/commands/npm-restart.md b/docs/content/commands/npm-restart.md index 80f8ab77ef018..f01cd014e7435 100644 --- a/docs/content/commands/npm-restart.md +++ b/docs/content/commands/npm-restart.md @@ -6,10 +6,19 @@ description: Restart a package ### Synopsis + + + + ```bash npm restart [-- ] ``` + + + + + ### Description This restarts a project. It is equivalent to running `npm run-script diff --git a/docs/content/commands/npm-root.md b/docs/content/commands/npm-root.md index 98d1108d33f75..40b58e4b33d0b 100644 --- a/docs/content/commands/npm-root.md +++ b/docs/content/commands/npm-root.md @@ -6,10 +6,19 @@ description: Display npm root ### Synopsis + + + + ```bash -npm root [-g] +npm root ``` + + + + + ### Description Print the effective `node_modules` folder to standard out. diff --git a/docs/content/commands/npm-run-script.md b/docs/content/commands/npm-run-script.md index 6dd602d03e00a..79b7c9a25780e 100644 --- a/docs/content/commands/npm-run-script.md +++ b/docs/content/commands/npm-run-script.md @@ -6,14 +6,21 @@ description: Run arbitrary package scripts ### Synopsis + + + + ```bash -npm run-script [--if-present] [--silent] [-- ] -npm run-script [--workspace=] -npm run-script [--workspaces] +npm run-script [-- ] aliases: run, rum, urn ``` + + + + + ### Description This runs an arbitrary command from a package's `"scripts"` object. If no diff --git a/docs/content/commands/npm-search.md b/docs/content/commands/npm-search.md index 252822e719844..db6a12bafabf1 100644 --- a/docs/content/commands/npm-search.md +++ b/docs/content/commands/npm-search.md @@ -6,12 +6,21 @@ description: Search for packages ### Synopsis + + + + ```bash -npm search [-l|--long] [--json] [--parseable] [--no-description] [search terms ...] +npm search [search terms ...] aliases: s, se, find ``` + + + + + Note: This command is unaware of workspaces. ### Description diff --git a/docs/content/commands/npm-set-script.md b/docs/content/commands/npm-set-script.md index 869ceede045ae..2d8e87db85219 100644 --- a/docs/content/commands/npm-set-script.md +++ b/docs/content/commands/npm-set-script.md @@ -7,10 +7,19 @@ description: Set tasks in the scripts section of package.json ### Synopsis An npm command that lets you create a task in the `scripts` section of the `package.json`. + + + + ```bash npm set-script [