diff --git a/deps/npm/docs/content/commands/npm-pkg.md b/deps/npm/docs/content/commands/npm-pkg.md index 78b13cf9e9a000..bc96eb8c3af945 100644 --- a/deps/npm/docs/content/commands/npm-pkg.md +++ b/deps/npm/docs/content/commands/npm-pkg.md @@ -16,7 +16,7 @@ npm pkg delete [. ...] A command that automates the management of `package.json` files. `npm pkg` provide 3 different sub commands that allow you to modify or retrieve -values for given object keys in your `packge.json`. +values for given object keys in your `package.json`. The syntax to retrieve and set fields is a dot separated representation of the nested object properties to be found within your `package.json`, it's the diff --git a/deps/npm/docs/content/commands/npm-unpublish.md b/deps/npm/docs/content/commands/npm-unpublish.md index 82779ab65938c9..b17ff45406829b 100644 --- a/deps/npm/docs/content/commands/npm-unpublish.md +++ b/deps/npm/docs/content/commands/npm-unpublish.md @@ -7,7 +7,7 @@ description: Remove a package from the registry ### Synopsis To learn more about how the npm registry treats unpublish, see our unpublish policies #### Unpublishing a single version of a package diff --git a/deps/npm/docs/content/commands/npm.md b/deps/npm/docs/content/commands/npm.md index 7ff1cc490707ee..de510870640d1c 100644 --- a/deps/npm/docs/content/commands/npm.md +++ b/deps/npm/docs/content/commands/npm.md @@ -31,7 +31,7 @@ Run `npm help` to get a list of available commands. npm comes preconfigured to use npm's public registry at https://registry.npmjs.org by default. Use of the npm public registry is subject to terms of use available at -https://www.npmjs.com/policies/terms. +https://docs.npmjs.com/policies/terms. You can configure npm to use any compatible registry you like, and even run your own registry. Use of someone else's registry is governed by diff --git a/deps/npm/docs/content/using-npm/registry.md b/deps/npm/docs/content/using-npm/registry.md index c07fa7a48e888f..3b07ab11c5bdc2 100644 --- a/deps/npm/docs/content/using-npm/registry.md +++ b/deps/npm/docs/content/using-npm/registry.md @@ -12,7 +12,7 @@ package info. npm is configured to use the **npm public registry** at by default. Use of the npm public registry is -subject to terms of use available at . +subject to terms of use available at . You can configure npm to use any compatible registry you like, and even run your own registry. Use of someone else's registry may be governed by their diff --git a/deps/npm/docs/output/commands/npm-ls.html b/deps/npm/docs/output/commands/npm-ls.html index 8af88b78dd57b3..82d671e2b2dbe8 100644 --- a/deps/npm/docs/output/commands/npm-ls.html +++ b/deps/npm/docs/output/commands/npm-ls.html @@ -159,7 +159,7 @@

Description

the results to only the paths to the packages named. Note that nested packages will also show the paths to the specified packages. For example, running npm ls promzard in npm’s source tree will show:

-
npm@7.20.0 /path/to/npm
+
npm@7.20.1 /path/to/npm
 └─┬ init-package-json@0.0.4
   └── promzard@0.1.5
 
diff --git a/deps/npm/docs/output/commands/npm-pkg.html b/deps/npm/docs/output/commands/npm-pkg.html index 1f8a86e76e5725..f837cb310a6980 100644 --- a/deps/npm/docs/output/commands/npm-pkg.html +++ b/deps/npm/docs/output/commands/npm-pkg.html @@ -152,7 +152,7 @@

Table of contents

Description

A command that automates the management of package.json files. npm pkg provide 3 different sub commands that allow you to modify or retrieve -values for given object keys in your packge.json.

+values for given object keys in your package.json.

The syntax to retrieve and set fields is a dot separated representation of the nested object properties to be found within your package.json, it’s the same notation used in npm view to retrieve information diff --git a/deps/npm/docs/output/commands/npm.html b/deps/npm/docs/output/commands/npm.html index e5e0b82ad352c4..4c721b30c85380 100644 --- a/deps/npm/docs/output/commands/npm.html +++ b/deps/npm/docs/output/commands/npm.html @@ -148,7 +148,7 @@

Table of contents

npm <command> [args]
 

Version

-

7.20.0

+

7.20.1

Description

npm is the package manager for the Node JavaScript platform. It puts modules in place so that node can find them, and manages dependency @@ -161,7 +161,7 @@

Important

npm comes preconfigured to use npm’s public registry at https://registry.npmjs.org by default. Use of the npm public registry is subject to terms of use available at -https://www.npmjs.com/policies/terms.

+https://docs.npmjs.com/policies/terms.

You can configure npm to use any compatible registry you like, and even run your own registry. Use of someone else’s registry is governed by their terms of use.

diff --git a/deps/npm/docs/output/using-npm/registry.html b/deps/npm/docs/output/using-npm/registry.html index 451b9ac5338cc9..3514ac72cd4214 100644 --- a/deps/npm/docs/output/using-npm/registry.html +++ b/deps/npm/docs/output/using-npm/registry.html @@ -150,7 +150,7 @@

Table of contents

package info.

npm is configured to use the npm public registry at https://registry.npmjs.org by default. Use of the npm public registry is -subject to terms of use available at https://www.npmjs.com/policies/terms.

+subject to terms of use available at https://docs.npmjs.com/policies/terms.

You can configure npm to use any compatible registry you like, and even run your own registry. Use of someone else’s registry may be governed by their terms of use.

diff --git a/deps/npm/lib/exec.js b/deps/npm/lib/exec.js index 959fab66634bdf..8c64c2f2405813 100644 --- a/deps/npm/lib/exec.js +++ b/deps/npm/lib/exec.js @@ -68,7 +68,6 @@ class Exec extends BaseCommand { async _exec (_args, { locationMsg, path, runPath }) { const args = [..._args] const call = this.npm.config.get('call') - const color = this.npm.config.get('color') const { flatOptions, localBin, @@ -87,7 +86,6 @@ class Exec extends BaseCommand { ...flatOptions, args, call, - color, localBin, locationMsg, log, @@ -103,7 +101,7 @@ class Exec extends BaseCommand { async _execWorkspaces (args, filters) { await this.setWorkspaces(filters) - const color = this.npm.config.get('color') + const color = this.npm.color for (const path of this.workspacePaths) { const locationMsg = await getLocationMsg({ color, path }) diff --git a/deps/npm/lib/fund.js b/deps/npm/lib/fund.js index 92580a756e8af8..1e0fa1ecb9d73a 100644 --- a/deps/npm/lib/fund.js +++ b/deps/npm/lib/fund.js @@ -109,7 +109,7 @@ class Fund extends ArboristWorkspaceCmd { } printHuman (fundingInfo) { - const color = !!this.npm.color + const color = this.npm.color const unicode = this.npm.config.get('unicode') const seenUrls = new Map() diff --git a/deps/npm/lib/ls.js b/deps/npm/lib/ls.js index 91e9a9dd3dba8d..7e41892c53442a 100644 --- a/deps/npm/lib/ls.js +++ b/deps/npm/lib/ls.js @@ -67,7 +67,7 @@ class LS extends ArboristWorkspaceCmd { async ls (args) { const all = this.npm.config.get('all') - const color = !!this.npm.color + const color = this.npm.color const depth = this.npm.config.get('depth') const dev = this.npm.config.get('dev') const development = this.npm.config.get('development') diff --git a/deps/npm/lib/npm.js b/deps/npm/lib/npm.js index db3559a384bd7e..966d11210c2753 100644 --- a/deps/npm/lib/npm.js +++ b/deps/npm/lib/npm.js @@ -232,7 +232,7 @@ const npm = module.exports = new class extends EventEmitter { process.emit('timeEnd', 'npm:load:setTitle') process.emit('time', 'npm:load:setupLog') - this.color = setupLog(this.config) + setupLog(this.config) process.emit('timeEnd', 'npm:load:setupLog') process.env.COLOR = this.color ? '1' : '0' @@ -261,6 +261,12 @@ const npm = module.exports = new class extends EventEmitter { return flat } + get color () { + // This is a special derived value that takes into consideration not only + // the config, but whether or not we are operating in a tty. + return this.flatOptions.color + } + get lockfileVersion () { return 2 } diff --git a/deps/npm/lib/run-script.js b/deps/npm/lib/run-script.js index b94d2fce071805..1daaeb9900de11 100644 --- a/deps/npm/lib/run-script.js +++ b/deps/npm/lib/run-script.js @@ -137,7 +137,7 @@ class RunScript extends BaseCommand { path = path || this.npm.localPrefix const { scripts, name, _id } = await rpj(`${path}/package.json`) const pkgid = _id || name - const color = !!this.npm.color + const color = this.npm.color if (!scripts) return [] diff --git a/deps/npm/lib/utils/config/definitions.js b/deps/npm/lib/utils/config/definitions.js index abe6bda70d8bc5..36b8a84a61c471 100644 --- a/deps/npm/lib/utils/config/definitions.js +++ b/deps/npm/lib/utils/config/definitions.js @@ -438,6 +438,9 @@ define('cidr', { flatten, }) +// This should never be directly used, the flattened value is the derived value +// and is sent to other modules, and is also exposed as `npm.color` for use +// inside npm itself. define('color', { default: !process.env.NO_COLOR || process.env.NO_COLOR === '0', usage: '--color|--no-color|--color always', diff --git a/deps/npm/lib/utils/exit-handler.js b/deps/npm/lib/utils/exit-handler.js index 95c9655a716cf3..7be138d2c361f1 100644 --- a/deps/npm/lib/utils/exit-handler.js +++ b/deps/npm/lib/utils/exit-handler.js @@ -52,16 +52,17 @@ process.on('exit', code => { if (!code) npm.log.info('ok') - else { + else npm.log.verbose('code', code) - if (!exitHandlerCalled) { - npm.log.error('', 'Exit handler never called!') - console.error('') - npm.log.error('', 'This is an error with npm itself. Please report this error at:') - npm.log.error('', ' ') - // TODO this doesn't have an npm.config.loaded guard - writeLogFile() - } + + if (!exitHandlerCalled) { + process.exitCode = code || 1 + npm.log.error('', 'Exit handler never called!') + console.error('') + npm.log.error('', 'This is an error with npm itself. Please report this error at:') + npm.log.error('', ' ') + // TODO this doesn't have an npm.config.loaded guard + writeLogFile() } // In timing mode we always write the log file if (npm.config.loaded && npm.config.get('timing') && !wroteLogFile) diff --git a/deps/npm/lib/utils/setup-log.js b/deps/npm/lib/utils/setup-log.js index 9ee79d192d9ea1..aaf7fa47e266dd 100644 --- a/deps/npm/lib/utils/setup-log.js +++ b/deps/npm/lib/utils/setup-log.js @@ -18,6 +18,7 @@ module.exports = (config) => { const stderrTTY = process.stderr.isTTY const dumbTerm = process.env.TERM === 'dumb' const stderrNotDumb = stderrTTY && !dumbTerm + // this logic is duplicated in the config 'color' flattener const enableColorStderr = color === 'always' ? true : color === false ? false : stderrTTY @@ -58,6 +59,4 @@ module.exports = (config) => { log.enableProgress() else log.disableProgress() - - return enableColorStdout } diff --git a/deps/npm/man/man1/npm-ls.1 b/deps/npm/man/man1/npm-ls.1 index a1814ca4633e3a..3e0830e7cace76 100644 --- a/deps/npm/man/man1/npm-ls.1 +++ b/deps/npm/man/man1/npm-ls.1 @@ -26,7 +26,7 @@ example, running \fBnpm ls promzard\fP in npm's source tree will show: .P .RS 2 .nf -npm@7\.20\.0 /path/to/npm +npm@7\.20\.1 /path/to/npm └─┬ init\-package\-json@0\.0\.4 └── promzard@0\.1\.5 .fi diff --git a/deps/npm/man/man1/npm-pkg.1 b/deps/npm/man/man1/npm-pkg.1 index 48044b58ae77a2..8652df525ebf25 100644 --- a/deps/npm/man/man1/npm-pkg.1 +++ b/deps/npm/man/man1/npm-pkg.1 @@ -14,7 +14,7 @@ npm pkg delete [\. \.\.\.] .P A command that automates the management of \fBpackage\.json\fP files\. \fBnpm pkg\fP provide 3 different sub commands that allow you to modify or retrieve -values for given object keys in your \fBpackge\.json\fP\|\. +values for given object keys in your \fBpackage\.json\fP\|\. .P The syntax to retrieve and set fields is a dot separated representation of the nested object properties to be found within your \fBpackage\.json\fP, it's the diff --git a/deps/npm/man/man1/npm-unpublish.1 b/deps/npm/man/man1/npm-unpublish.1 index edef7115fc040a..50b4bd5e3b49e1 100644 --- a/deps/npm/man/man1/npm-unpublish.1 +++ b/deps/npm/man/man1/npm-unpublish.1 @@ -4,7 +4,7 @@ .SS Synopsis .P To learn more about how the npm registry treats unpublish, see our unpublish policies .SS Unpublishing a single version of a package .P diff --git a/deps/npm/man/man1/npm.1 b/deps/npm/man/man1/npm.1 index 36f677399d49b1..3fe0c0d93f8de2 100644 --- a/deps/npm/man/man1/npm.1 +++ b/deps/npm/man/man1/npm.1 @@ -10,7 +10,7 @@ npm [args] .RE .SS Version .P -7\.20\.0 +7\.20\.1 .SS Description .P npm is the package manager for the Node JavaScript platform\. It puts @@ -27,7 +27,7 @@ Run \fBnpm help\fP to get a list of available commands\. npm comes preconfigured to use npm's public registry at https://registry\.npmjs\.org by default\. Use of the npm public registry is subject to terms of use available at -https://www\.npmjs\.com/policies/terms\. +https://docs\.npmjs\.com/policies/terms\. .P You can configure npm to use any compatible registry you like, and even run your own registry\. Use of someone else's registry is governed by diff --git a/deps/npm/man/man7/registry.7 b/deps/npm/man/man7/registry.7 index 64658eab2a37ab..772d4b48220b5a 100644 --- a/deps/npm/man/man7/registry.7 +++ b/deps/npm/man/man7/registry.7 @@ -9,7 +9,7 @@ package info\. .P npm is configured to use the \fBnpm public registry\fR at https://registry\.npmjs\.org by default\. Use of the npm public registry is -subject to terms of use available at https://www\.npmjs\.com/policies/terms\|\. +subject to terms of use available at https://docs\.npmjs\.com/policies/terms\|\. .P You can configure npm to use any compatible registry you like, and even run your own registry\. Use of someone else's registry may be governed by their diff --git a/deps/npm/node_modules/color-support/LICENSE b/deps/npm/node_modules/color-support/LICENSE new file mode 100644 index 00000000000000..19129e315fe593 --- /dev/null +++ b/deps/npm/node_modules/color-support/LICENSE @@ -0,0 +1,15 @@ +The ISC License + +Copyright (c) Isaac Z. Schlueter and Contributors + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR +IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/deps/npm/node_modules/color-support/README.md b/deps/npm/node_modules/color-support/README.md new file mode 100644 index 00000000000000..f89aa17d3526a3 --- /dev/null +++ b/deps/npm/node_modules/color-support/README.md @@ -0,0 +1,129 @@ +# color-support + +A module which will endeavor to guess your terminal's level of color +support. + +[![Build Status](https://travis-ci.org/isaacs/color-support.svg?branch=master)](https://travis-ci.org/isaacs/color-support) [![Coverage Status](https://coveralls.io/repos/github/isaacs/color-support/badge.svg?branch=master)](https://coveralls.io/github/isaacs/color-support?branch=master) + +This is similar to `supports-color`, but it does not read +`process.argv`. + +1. If not in a node environment, not supported. + +2. If stdout is not a TTY, not supported, unless the `ignoreTTY` + option is set. + +3. If the `TERM` environ is `dumb`, not supported, unless the + `ignoreDumb` option is set. + +4. If on Windows, then support 16 colors. + +5. If using Tmux, then support 256 colors. + +7. Handle continuous-integration servers. If `CI` or + `TEAMCITY_VERSION` are set in the environment, and `TRAVIS` is not + set, then color is not supported, unless `ignoreCI` option is set. + +6. Guess based on the `TERM_PROGRAM` environ. These terminals support + 16m colors: + + - `iTerm.app` version 3.x supports 16m colors, below support 256 + - `MacTerm` supports 16m colors + - `Apple_Terminal` supports 256 colors + - Have more things that belong on this list? Send a PR! + +8. Make a guess based on the `TERM` environment variable. Any + `xterm-256color` will get 256 colors. Any screen, xterm, vt100, + color, ansi, cygwin, or linux `TERM` will get 16 colors. + +9. If `COLORTERM` environment variable is set, then support 16 colors. + +10. At this point, we assume that color is not supported. + +## USAGE + +```javascript +var testColorSupport = require('color-support') +var colorSupport = testColorSupport(/* options object */) + +if (!colorSupport) { + console.log('color is not supported') +} else if (colorSupport.has16m) { + console.log('\x1b[38;2;102;194;255m16m colors\x1b[0m') +} else if (colorSupport.has256) { + console.log('\x1b[38;5;119m256 colors\x1b[0m') +} else if (colorSupport.hasBasic) { + console.log('\x1b[31mbasic colors\x1b[0m') +} else { + console.log('this is impossible, but colors are not supported') +} +``` + +If you don't have any options to set, you can also just look at the +flags which will all be set on the test function itself. (Of course, +this doesn't return a falsey value when colors aren't supported, and +doesn't allow you to set options.) + +```javascript +var colorSupport = require('color-support') + +if (colorSupport.has16m) { + console.log('\x1b[38;2;102;194;255m16m colors\x1b[0m') +} else if (colorSupport.has256) { + console.log('\x1b[38;5;119m256 colors\x1b[0m') +} else if (colorSupport.hasBasic) { + console.log('\x1b[31mbasic colors\x1b[0m') +} else { + console.log('colors are not supported') +} +``` + +## Options + +You can pass in the following options. + +* ignoreTTY - default false. Ignore the `isTTY` check. +* ignoreDumb - default false. Ignore `TERM=dumb` environ check. +* ignoreCI - default false. Ignore `CI` environ check. +* env - Object for environment vars. Defaults to `process.env`. +* stream - Stream for `isTTY` check. Defaults to `process.stdout`. +* term - String for `TERM` checking. Defaults to `env.TERM`. +* alwaysReturn - default false. Return an object when colors aren't + supported (instead of returning `false`). +* level - A number from 0 to 3. This will return a result for the + specified level. This is useful if you want to be able to set the + color support level explicitly as a number in an environment + variable or config, but then use the object flags in your program. + Except for `alwaysReturn` to return an object for level 0, all other + options are ignored, since no checking is done if a level is + explicitly set. + +## Return Value + +If no color support is available, then `false` is returned by default, +unless the `alwaysReturn` flag is set to `true`. This is so that the +simple question of "can I use colors or not" can treat any truthy +return as "yes". + +Otherwise, the return object has the following fields: + +* `level` - A number from 0 to 3 + * `0` - No color support + * `1` - Basic (16) color support + * `2` - 256 color support + * `3` - 16 million (true) color support +* `hasBasic` - Boolean +* `has256` - Boolean +* `has16m` - Boolean + +## CLI + +You can run the `color-support` bin from the command line which will +just dump the values as this module calculates them in whatever env +it's run. It takes no command line arguments. + +## Credits + +This is a spiritual, if not actual, fork of +[supports-color](http://npm.im/supports-color) by the ever prolific +[Sindre Sorhus](http://npm.im/~sindresorhus). diff --git a/deps/npm/node_modules/color-support/bin.js b/deps/npm/node_modules/color-support/bin.js new file mode 100755 index 00000000000000..3c0a9672180835 --- /dev/null +++ b/deps/npm/node_modules/color-support/bin.js @@ -0,0 +1,3 @@ +#!/usr/bin/env node +var colorSupport = require('./')({alwaysReturn: true }) +console.log(JSON.stringify(colorSupport, null, 2)) diff --git a/deps/npm/node_modules/color-support/browser.js b/deps/npm/node_modules/color-support/browser.js new file mode 100644 index 00000000000000..ab5c6631a35b80 --- /dev/null +++ b/deps/npm/node_modules/color-support/browser.js @@ -0,0 +1,14 @@ +module.exports = colorSupport({ alwaysReturn: true }, colorSupport) + +function colorSupport(options, obj) { + obj = obj || {} + options = options || {} + obj.level = 0 + obj.hasBasic = false + obj.has256 = false + obj.has16m = false + if (!options.alwaysReturn) { + return false + } + return obj +} diff --git a/deps/npm/node_modules/color-support/index.js b/deps/npm/node_modules/color-support/index.js new file mode 100644 index 00000000000000..6b6f3b28194243 --- /dev/null +++ b/deps/npm/node_modules/color-support/index.js @@ -0,0 +1,134 @@ +// call it on itself so we can test the export val for basic stuff +module.exports = colorSupport({ alwaysReturn: true }, colorSupport) + +function hasNone (obj, options) { + obj.level = 0 + obj.hasBasic = false + obj.has256 = false + obj.has16m = false + if (!options.alwaysReturn) { + return false + } + return obj +} + +function hasBasic (obj) { + obj.hasBasic = true + obj.has256 = false + obj.has16m = false + obj.level = 1 + return obj +} + +function has256 (obj) { + obj.hasBasic = true + obj.has256 = true + obj.has16m = false + obj.level = 2 + return obj +} + +function has16m (obj) { + obj.hasBasic = true + obj.has256 = true + obj.has16m = true + obj.level = 3 + return obj +} + +function colorSupport (options, obj) { + options = options || {} + + obj = obj || {} + + // if just requesting a specific level, then return that. + if (typeof options.level === 'number') { + switch (options.level) { + case 0: + return hasNone(obj, options) + case 1: + return hasBasic(obj) + case 2: + return has256(obj) + case 3: + return has16m(obj) + } + } + + obj.level = 0 + obj.hasBasic = false + obj.has256 = false + obj.has16m = false + + if (typeof process === 'undefined' || + !process || + !process.stdout || + !process.env || + !process.platform) { + return hasNone(obj, options) + } + + var env = options.env || process.env + var stream = options.stream || process.stdout + var term = options.term || env.TERM || '' + var platform = options.platform || process.platform + + if (!options.ignoreTTY && !stream.isTTY) { + return hasNone(obj, options) + } + + if (!options.ignoreDumb && term === 'dumb' && !env.COLORTERM) { + return hasNone(obj, options) + } + + if (platform === 'win32') { + return hasBasic(obj) + } + + if (env.TMUX) { + return has256(obj) + } + + if (!options.ignoreCI && (env.CI || env.TEAMCITY_VERSION)) { + if (env.TRAVIS) { + return has256(obj) + } else { + return hasNone(obj, options) + } + } + + // TODO: add more term programs + switch (env.TERM_PROGRAM) { + case 'iTerm.app': + var ver = env.TERM_PROGRAM_VERSION || '0.' + if (/^[0-2]\./.test(ver)) { + return has256(obj) + } else { + return has16m(obj) + } + + case 'HyperTerm': + case 'Hyper': + return has16m(obj) + + case 'MacTerm': + return has16m(obj) + + case 'Apple_Terminal': + return has256(obj) + } + + if (/^xterm-256/.test(term)) { + return has256(obj) + } + + if (/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(term)) { + return hasBasic(obj) + } + + if (env.COLORTERM) { + return hasBasic(obj) + } + + return hasNone(obj, options) +} diff --git a/deps/npm/node_modules/color-support/package.json b/deps/npm/node_modules/color-support/package.json new file mode 100644 index 00000000000000..f3e3b77145d6ba --- /dev/null +++ b/deps/npm/node_modules/color-support/package.json @@ -0,0 +1,36 @@ +{ + "name": "color-support", + "version": "1.1.3", + "description": "A module which will endeavor to guess your terminal's level of color support.", + "main": "index.js", + "browser": "browser.js", + "bin": "bin.js", + "devDependencies": { + "tap": "^10.3.3" + }, + "scripts": { + "test": "tap test/*.js --100 -J", + "preversion": "npm test", + "postversion": "npm publish", + "postpublish": "git push origin --all; git push origin --tags" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/isaacs/color-support.git" + }, + "keywords": [ + "terminal", + "color", + "support", + "xterm", + "truecolor", + "256" + ], + "author": "Isaac Z. Schlueter (http://blog.izs.me/)", + "license": "ISC", + "files": [ + "browser.js", + "index.js", + "bin.js" + ] +} diff --git a/deps/npm/node_modules/debug/package.json b/deps/npm/node_modules/debug/package.json index da809d2b8d28b2..b7d70acb9bee82 100644 --- a/deps/npm/node_modules/debug/package.json +++ b/deps/npm/node_modules/debug/package.json @@ -1,6 +1,6 @@ { "name": "debug", - "version": "4.3.1", + "version": "4.3.2", "repository": { "type": "git", "url": "git://github.com/visionmedia/debug.git" diff --git a/deps/npm/node_modules/debug/src/common.js b/deps/npm/node_modules/debug/src/common.js index 392a8e005a063a..50ce2925101d73 100644 --- a/deps/npm/node_modules/debug/src/common.js +++ b/deps/npm/node_modules/debug/src/common.js @@ -60,6 +60,8 @@ function setup(env) { function createDebug(namespace) { let prevTime; let enableOverride = null; + let namespacesCache; + let enabledCache; function debug(...args) { // Disabled? @@ -120,7 +122,17 @@ function setup(env) { Object.defineProperty(debug, 'enabled', { enumerable: true, configurable: false, - get: () => enableOverride === null ? createDebug.enabled(namespace) : enableOverride, + get: () => { + if (enableOverride !== null) { + return enableOverride; + } + if (namespacesCache !== createDebug.namespaces) { + namespacesCache = createDebug.namespaces; + enabledCache = createDebug.enabled(namespace); + } + + return enabledCache; + }, set: v => { enableOverride = v; } @@ -149,6 +161,7 @@ function setup(env) { */ function enable(namespaces) { createDebug.save(namespaces); + createDebug.namespaces = namespaces; createDebug.names = []; createDebug.skips = []; diff --git a/deps/npm/node_modules/gauge/has-color.js b/deps/npm/node_modules/gauge/has-color.js index e283a256f26b74..16cba0eb47d332 100644 --- a/deps/npm/node_modules/gauge/has-color.js +++ b/deps/npm/node_modules/gauge/has-color.js @@ -1,12 +1,4 @@ 'use strict' +var colorSupport = require('color-support') -module.exports = isWin32() || isColorTerm() - -function isWin32 () { - return process.platform === 'win32' -} - -function isColorTerm () { - var termHasColor = /^screen|^xterm|^vt100|color|ansi|cygwin|linux/i - return !!process.env.COLORTERM || termHasColor.test(process.env.TERM) -} +module.exports = colorSupport().hasBasic diff --git a/deps/npm/node_modules/gauge/index.js b/deps/npm/node_modules/gauge/index.js index c55324008cbfaf..87a4bb930834ed 100644 --- a/deps/npm/node_modules/gauge/index.js +++ b/deps/npm/node_modules/gauge/index.js @@ -188,7 +188,7 @@ Gauge.prototype.show = function (section, completed) { Gauge.prototype.pulse = function (subsection) { this._status.subsection = subsection || '' - this._status.spun ++ + this._status.spun++ if (this._disabled) return if (!this._showing) return this._requestRedraw() diff --git a/deps/npm/node_modules/gauge/node_modules/is-fullwidth-code-point/readme.md b/deps/npm/node_modules/gauge/node_modules/is-fullwidth-code-point/readme.md deleted file mode 100644 index 4936464b1b4155..00000000000000 --- a/deps/npm/node_modules/gauge/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 --save is-fullwidth-code-point -``` - - -## Usage - -```js -var isFullwidthCodePoint = require('is-fullwidth-code-point'); - -isFullwidthCodePoint('谢'.codePointAt()); -//=> true - -isFullwidthCodePoint('a'.codePointAt()); -//=> false -``` - - -## API - -### isFullwidthCodePoint(input) - -#### input - -Type: `number` - -[Code point](https://en.wikipedia.org/wiki/Code_point) of a character. - - -## License - -MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/deps/npm/node_modules/gauge/node_modules/string-width/readme.md b/deps/npm/node_modules/gauge/node_modules/string-width/readme.md deleted file mode 100644 index 1ab42c93580ecb..00000000000000 --- a/deps/npm/node_modules/gauge/node_modules/string-width/readme.md +++ /dev/null @@ -1,42 +0,0 @@ -# string-width [![Build Status](https://travis-ci.org/sindresorhus/string-width.svg?branch=master)](https://travis-ci.org/sindresorhus/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](http://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 --save string-width -``` - - -## Usage - -```js -const stringWidth = require('string-width'); - -stringWidth('古'); -//=> 2 - -stringWidth('\u001b[1m古\u001b[22m'); -//=> 2 - -stringWidth('a'); -//=> 1 -``` - - -## 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 - - -## License - -MIT © [Sindre Sorhus](https://sindresorhus.com) diff --git a/deps/npm/node_modules/gauge/package.json b/deps/npm/node_modules/gauge/package.json index 4882cff8390d87..8f1c0af6445fee 100644 --- a/deps/npm/node_modules/gauge/package.json +++ b/deps/npm/node_modules/gauge/package.json @@ -1,11 +1,10 @@ { "name": "gauge", - "version": "2.7.4", + "version": "3.0.0", "description": "A terminal based horizontal guage", "main": "index.js", "scripts": { - "test": "standard && tap test/*.js --coverage", - "prepublish": "rm -f *~" + "test": "standard && tap test/*.js --coverage" }, "repository": { "type": "git", @@ -19,24 +18,24 @@ "author": "Rebecca Turner ", "license": "ISC", "bugs": { - "url": "https://github.com/iarna/gauge/issues" + "url": "https://github.com/npm/gauge/issues" }, - "homepage": "https://github.com/iarna/gauge", + "homepage": "https://github.com/npm/gauge", "dependencies": { - "aproba": "^1.0.3", + "aproba": "^1.0.3 || ^2.0.0", + "color-support": "^1.1.2", "console-control-strings": "^1.0.0", - "has-unicode": "^2.0.0", - "object-assign": "^4.1.0", + "has-unicode": "^2.0.1", "signal-exit": "^3.0.0", - "string-width": "^1.0.1", - "strip-ansi": "^3.0.1", - "wide-align": "^1.1.0" + "string-width": "^1.0.1 || ^2.0.0", + "strip-ansi": "^3.0.1 || ^4.0.0", + "wide-align": "^1.1.2" }, "devDependencies": { "readable-stream": "^2.0.6", "require-inject": "^1.4.0", - "standard": "^7.1.2", - "tap": "^5.7.2", + "standard": "^11.0.1", + "tap": "^12.0.1", "through2": "^2.0.0" }, "files": [ @@ -59,5 +58,8 @@ "theme-set.js", "themes.js", "wide-truncate.js" - ] + ], + "engines": { + "node": ">=10" + } } diff --git a/deps/npm/node_modules/gauge/progress-bar.js b/deps/npm/node_modules/gauge/progress-bar.js index 7f8dd68be24cf0..1780a8a54d1cb5 100644 --- a/deps/npm/node_modules/gauge/progress-bar.js +++ b/deps/npm/node_modules/gauge/progress-bar.js @@ -27,7 +27,7 @@ function repeat (string, width) { result += string } n = Math.floor(n / 2) - /*eslint no-self-assign: 0*/ + /* eslint no-self-assign: 0 */ string += string } while (n && stringWidth(result) < width) diff --git a/deps/npm/node_modules/gauge/render-template.js b/deps/npm/node_modules/gauge/render-template.js index 3261bfbe6f4be5..9764c6e0a1556d 100644 --- a/deps/npm/node_modules/gauge/render-template.js +++ b/deps/npm/node_modules/gauge/render-template.js @@ -1,7 +1,6 @@ 'use strict' var align = require('wide-align') var validate = require('aproba') -var objectAssign = require('object-assign') var wideTruncate = require('./wide-truncate') var error = require('./error') var TemplateItem = require('./template-item') @@ -34,7 +33,7 @@ function hasPreOrPost (item, values) { } function generatePreAndPost (baseItem, parentValues) { - var item = objectAssign({}, baseItem) + var item = Object.assign({}, baseItem) var values = Object.create(parentValues) var template = [] var pre = preType(item) @@ -82,13 +81,11 @@ function prepareItems (width, template, values) { var output = template.map(cloneAndObjectify).filter(function (item) { return item != null }) - var outputLength = 0 var remainingSpace = width var variableCount = output.length function consumeSpace (length) { if (length > remainingSpace) length = remainingSpace - outputLength += length remainingSpace -= length } diff --git a/deps/npm/node_modules/gauge/template-item.js b/deps/npm/node_modules/gauge/template-item.js index e46f447c941d38..4f02fefaa23eca 100644 --- a/deps/npm/node_modules/gauge/template-item.js +++ b/deps/npm/node_modules/gauge/template-item.js @@ -70,4 +70,3 @@ TemplateItem.prototype.getMinLength = function () { if (this.minLength == null) return null return this.minLength + this.padLeft + this.padRight } - diff --git a/deps/npm/node_modules/gauge/theme-set.js b/deps/npm/node_modules/gauge/theme-set.js index 68971d5d231b07..c022d61cf13cb0 100644 --- a/deps/npm/node_modules/gauge/theme-set.js +++ b/deps/npm/node_modules/gauge/theme-set.js @@ -112,4 +112,3 @@ ThemeSetProto.newThemeSet = function () { defaults: JSON.parse(JSON.stringify(this.defaults || {})) }) } - diff --git a/deps/npm/node_modules/gauge/themes.js b/deps/npm/node_modules/gauge/themes.js index eb5a4f5b5e1034..df1184db51f2cd 100644 --- a/deps/npm/node_modules/gauge/themes.js +++ b/deps/npm/node_modules/gauge/themes.js @@ -1,5 +1,5 @@ 'use strict' -var consoleControl = require('console-control-strings') +var color = require('console-control-strings').color var ThemeSet = require('./theme-set.js') var themes = module.exports = new ThemeSet() @@ -17,12 +17,12 @@ themes.addTheme('ASCII', { themes.addTheme('colorASCII', themes.getTheme('ASCII'), { progressbarTheme: { - preComplete: consoleControl.color('inverse'), - complete: ' ', - postComplete: consoleControl.color('stopInverse'), - preRemaining: consoleControl.color('brightBlack'), + preComplete: color('bgBrightWhite', 'brightWhite'), + complete: '#', + postComplete: color('reset'), + preRemaining: color('bgBrightBlack', 'brightBlack'), remaining: '.', - postRemaining: consoleControl.color('reset') + postRemaining: color('reset') } }) @@ -30,7 +30,7 @@ themes.addTheme('brailleSpinner', { preProgressbar: '⸨', postProgressbar: '⸩', progressbarTheme: { - complete: '░', + complete: '#', remaining: '⠂' }, activityIndicatorTheme: '⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏', @@ -39,12 +39,12 @@ themes.addTheme('brailleSpinner', { themes.addTheme('colorBrailleSpinner', themes.getTheme('brailleSpinner'), { progressbarTheme: { - preComplete: consoleControl.color('inverse'), - complete: ' ', - postComplete: consoleControl.color('stopInverse'), - preRemaining: consoleControl.color('brightBlack'), - remaining: '░', - postRemaining: consoleControl.color('reset') + preComplete: color('bgBrightWhite', 'brightWhite'), + complete: '#', + postComplete: color('reset'), + preRemaining: color('bgBrightBlack', 'brightBlack'), + remaining: '⠂', + postRemaining: color('reset') } }) @@ -52,3 +52,5 @@ themes.setDefault({}, 'ASCII') themes.setDefault({hasColor: true}, 'colorASCII') themes.setDefault({platform: 'darwin', hasUnicode: true}, 'brailleSpinner') themes.setDefault({platform: 'darwin', hasUnicode: true, hasColor: true}, 'colorBrailleSpinner') +themes.setDefault({platform: 'linux', hasUnicode: true}, 'brailleSpinner') +themes.setDefault({platform: 'linux', hasUnicode: true, hasColor: true}, 'colorBrailleSpinner') diff --git a/deps/npm/node_modules/is-core-module/core.json b/deps/npm/node_modules/is-core-module/core.json index 44a92a1a414b97..773222f6ba3bcd 100644 --- a/deps/npm/node_modules/is-core-module/core.json +++ b/deps/npm/node_modules/is-core-module/core.json @@ -102,6 +102,8 @@ "node:stream": ">= 16", "stream/promises": ">= 15", "node:stream/promises": ">= 16", + "stream/web": ">= 16.5", + "node:stream/web": ">= 16.5", "string_decoder": true, "node:string_decoder": ">= 16", "sys": [">= 0.6 && < 0.7", ">= 0.8"], diff --git a/deps/npm/node_modules/is-core-module/package.json b/deps/npm/node_modules/is-core-module/package.json index 0442e92cd2065a..464294eae96bef 100644 --- a/deps/npm/node_modules/is-core-module/package.json +++ b/deps/npm/node_modules/is-core-module/package.json @@ -1,6 +1,6 @@ { "name": "is-core-module", - "version": "2.4.0", + "version": "2.5.0", "description": "Is this specifier a node.js core module?", "main": "index.js", "exports": { @@ -50,8 +50,8 @@ "devDependencies": { "@ljharb/eslint-config": "^17.6.0", "aud": "^1.1.5", - "auto-changelog": "^2.2.1", - "eslint": "^7.26.0", + "auto-changelog": "^2.3.0", + "eslint": "^7.30.0", "nyc": "^10.3.2", "safe-publish-latest": "^1.1.4", "semver": "^6.3.0", diff --git a/deps/npm/node_modules/libnpmdiff/README.md b/deps/npm/node_modules/libnpmdiff/README.md index da6bf538421967..d48ac092ca3646 100644 --- a/deps/npm/node_modules/libnpmdiff/README.md +++ b/deps/npm/node_modules/libnpmdiff/README.md @@ -61,7 +61,7 @@ hesitate to jump in if you'd like to, or even ask us questions if something isn't clear. All participants and maintainers in this project are expected to follow the -[npm Code of Conduct](https://www.npmjs.com/policies/conduct), and just +[npm Code of Conduct](https://docs.npmjs.com/policies/conduct), and just generally be excellent to each other. Please refer to the [Changelog](CHANGELOG.md) for project history details, too. diff --git a/deps/npm/node_modules/gauge/node_modules/aproba/LICENSE b/deps/npm/node_modules/node-gyp/node_modules/aproba/LICENSE similarity index 99% rename from deps/npm/node_modules/gauge/node_modules/aproba/LICENSE rename to deps/npm/node_modules/node-gyp/node_modules/aproba/LICENSE index f4be44d881b2d9..2a4982dc40cb69 100644 --- a/deps/npm/node_modules/gauge/node_modules/aproba/LICENSE +++ b/deps/npm/node_modules/node-gyp/node_modules/aproba/LICENSE @@ -11,4 +11,3 @@ 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/deps/npm/node_modules/gauge/node_modules/aproba/index.js b/deps/npm/node_modules/node-gyp/node_modules/aproba/index.js similarity index 100% rename from deps/npm/node_modules/gauge/node_modules/aproba/index.js rename to deps/npm/node_modules/node-gyp/node_modules/aproba/index.js diff --git a/deps/npm/node_modules/gauge/node_modules/aproba/package.json b/deps/npm/node_modules/node-gyp/node_modules/aproba/package.json similarity index 100% rename from deps/npm/node_modules/gauge/node_modules/aproba/package.json rename to deps/npm/node_modules/node-gyp/node_modules/aproba/package.json diff --git a/deps/npm/node_modules/node-gyp/node_modules/gauge/LICENSE b/deps/npm/node_modules/node-gyp/node_modules/gauge/LICENSE new file mode 100644 index 00000000000000..e756052969b780 --- /dev/null +++ b/deps/npm/node_modules/node-gyp/node_modules/gauge/LICENSE @@ -0,0 +1,13 @@ +Copyright (c) 2014, Rebecca Turner + +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/deps/npm/node_modules/node-gyp/node_modules/gauge/base-theme.js b/deps/npm/node_modules/node-gyp/node_modules/gauge/base-theme.js new file mode 100644 index 00000000000000..0b67638e0211d0 --- /dev/null +++ b/deps/npm/node_modules/node-gyp/node_modules/gauge/base-theme.js @@ -0,0 +1,14 @@ +'use strict' +var spin = require('./spin.js') +var progressBar = require('./progress-bar.js') + +module.exports = { + activityIndicator: function (values, theme, width) { + if (values.spun == null) return + return spin(theme, values.spun) + }, + progressbar: function (values, theme, width) { + if (values.completed == null) return + return progressBar(theme, width, values.completed) + } +} diff --git a/deps/npm/node_modules/node-gyp/node_modules/gauge/error.js b/deps/npm/node_modules/node-gyp/node_modules/gauge/error.js new file mode 100644 index 00000000000000..d9914ba5335d25 --- /dev/null +++ b/deps/npm/node_modules/node-gyp/node_modules/gauge/error.js @@ -0,0 +1,24 @@ +'use strict' +var util = require('util') + +var User = exports.User = function User (msg) { + var err = new Error(msg) + Error.captureStackTrace(err, User) + err.code = 'EGAUGE' + return err +} + +exports.MissingTemplateValue = function MissingTemplateValue (item, values) { + var err = new User(util.format('Missing template value "%s"', item.type)) + Error.captureStackTrace(err, MissingTemplateValue) + err.template = item + err.values = values + return err +} + +exports.Internal = function Internal (msg) { + var err = new Error(msg) + Error.captureStackTrace(err, Internal) + err.code = 'EGAUGEINTERNAL' + return err +} diff --git a/deps/npm/node_modules/node-gyp/node_modules/gauge/has-color.js b/deps/npm/node_modules/node-gyp/node_modules/gauge/has-color.js new file mode 100644 index 00000000000000..e283a256f26b74 --- /dev/null +++ b/deps/npm/node_modules/node-gyp/node_modules/gauge/has-color.js @@ -0,0 +1,12 @@ +'use strict' + +module.exports = isWin32() || isColorTerm() + +function isWin32 () { + return process.platform === 'win32' +} + +function isColorTerm () { + var termHasColor = /^screen|^xterm|^vt100|color|ansi|cygwin|linux/i + return !!process.env.COLORTERM || termHasColor.test(process.env.TERM) +} diff --git a/deps/npm/node_modules/node-gyp/node_modules/gauge/index.js b/deps/npm/node_modules/node-gyp/node_modules/gauge/index.js new file mode 100644 index 00000000000000..c55324008cbfaf --- /dev/null +++ b/deps/npm/node_modules/node-gyp/node_modules/gauge/index.js @@ -0,0 +1,233 @@ +'use strict' +var Plumbing = require('./plumbing.js') +var hasUnicode = require('has-unicode') +var hasColor = require('./has-color.js') +var onExit = require('signal-exit') +var defaultThemes = require('./themes') +var setInterval = require('./set-interval.js') +var process = require('./process.js') +var setImmediate = require('./set-immediate') + +module.exports = Gauge + +function callWith (obj, method) { + return function () { + return method.call(obj) + } +} + +function Gauge (arg1, arg2) { + var options, writeTo + if (arg1 && arg1.write) { + writeTo = arg1 + options = arg2 || {} + } else if (arg2 && arg2.write) { + writeTo = arg2 + options = arg1 || {} + } else { + writeTo = process.stderr + options = arg1 || arg2 || {} + } + + this._status = { + spun: 0, + section: '', + subsection: '' + } + this._paused = false // are we paused for back pressure? + this._disabled = true // are all progress bar updates disabled? + this._showing = false // do we WANT the progress bar on screen + this._onScreen = false // IS the progress bar on screen + this._needsRedraw = false // should we print something at next tick? + this._hideCursor = options.hideCursor == null ? true : options.hideCursor + this._fixedFramerate = options.fixedFramerate == null + ? !(/^v0\.8\./.test(process.version)) + : options.fixedFramerate + this._lastUpdateAt = null + this._updateInterval = options.updateInterval == null ? 50 : options.updateInterval + + this._themes = options.themes || defaultThemes + this._theme = options.theme + var theme = this._computeTheme(options.theme) + var template = options.template || [ + {type: 'progressbar', length: 20}, + {type: 'activityIndicator', kerning: 1, length: 1}, + {type: 'section', kerning: 1, default: ''}, + {type: 'subsection', kerning: 1, default: ''} + ] + this.setWriteTo(writeTo, options.tty) + var PlumbingClass = options.Plumbing || Plumbing + this._gauge = new PlumbingClass(theme, template, this.getWidth()) + + this._$$doRedraw = callWith(this, this._doRedraw) + this._$$handleSizeChange = callWith(this, this._handleSizeChange) + + this._cleanupOnExit = options.cleanupOnExit == null || options.cleanupOnExit + this._removeOnExit = null + + if (options.enabled || (options.enabled == null && this._tty && this._tty.isTTY)) { + this.enable() + } else { + this.disable() + } +} +Gauge.prototype = {} + +Gauge.prototype.isEnabled = function () { + return !this._disabled +} + +Gauge.prototype.setTemplate = function (template) { + this._gauge.setTemplate(template) + if (this._showing) this._requestRedraw() +} + +Gauge.prototype._computeTheme = function (theme) { + if (!theme) theme = {} + if (typeof theme === 'string') { + theme = this._themes.getTheme(theme) + } else if (theme && (Object.keys(theme).length === 0 || theme.hasUnicode != null || theme.hasColor != null)) { + var useUnicode = theme.hasUnicode == null ? hasUnicode() : theme.hasUnicode + var useColor = theme.hasColor == null ? hasColor : theme.hasColor + theme = this._themes.getDefault({hasUnicode: useUnicode, hasColor: useColor, platform: theme.platform}) + } + return theme +} + +Gauge.prototype.setThemeset = function (themes) { + this._themes = themes + this.setTheme(this._theme) +} + +Gauge.prototype.setTheme = function (theme) { + this._gauge.setTheme(this._computeTheme(theme)) + if (this._showing) this._requestRedraw() + this._theme = theme +} + +Gauge.prototype._requestRedraw = function () { + this._needsRedraw = true + if (!this._fixedFramerate) this._doRedraw() +} + +Gauge.prototype.getWidth = function () { + return ((this._tty && this._tty.columns) || 80) - 1 +} + +Gauge.prototype.setWriteTo = function (writeTo, tty) { + var enabled = !this._disabled + if (enabled) this.disable() + this._writeTo = writeTo + this._tty = tty || + (writeTo === process.stderr && process.stdout.isTTY && process.stdout) || + (writeTo.isTTY && writeTo) || + this._tty + if (this._gauge) this._gauge.setWidth(this.getWidth()) + if (enabled) this.enable() +} + +Gauge.prototype.enable = function () { + if (!this._disabled) return + this._disabled = false + if (this._tty) this._enableEvents() + if (this._showing) this.show() +} + +Gauge.prototype.disable = function () { + if (this._disabled) return + if (this._showing) { + this._lastUpdateAt = null + this._showing = false + this._doRedraw() + this._showing = true + } + this._disabled = true + if (this._tty) this._disableEvents() +} + +Gauge.prototype._enableEvents = function () { + if (this._cleanupOnExit) { + this._removeOnExit = onExit(callWith(this, this.disable)) + } + this._tty.on('resize', this._$$handleSizeChange) + if (this._fixedFramerate) { + this.redrawTracker = setInterval(this._$$doRedraw, this._updateInterval) + if (this.redrawTracker.unref) this.redrawTracker.unref() + } +} + +Gauge.prototype._disableEvents = function () { + this._tty.removeListener('resize', this._$$handleSizeChange) + if (this._fixedFramerate) clearInterval(this.redrawTracker) + if (this._removeOnExit) this._removeOnExit() +} + +Gauge.prototype.hide = function (cb) { + if (this._disabled) return cb && process.nextTick(cb) + if (!this._showing) return cb && process.nextTick(cb) + this._showing = false + this._doRedraw() + cb && setImmediate(cb) +} + +Gauge.prototype.show = function (section, completed) { + this._showing = true + if (typeof section === 'string') { + this._status.section = section + } else if (typeof section === 'object') { + var sectionKeys = Object.keys(section) + for (var ii = 0; ii < sectionKeys.length; ++ii) { + var key = sectionKeys[ii] + this._status[key] = section[key] + } + } + if (completed != null) this._status.completed = completed + if (this._disabled) return + this._requestRedraw() +} + +Gauge.prototype.pulse = function (subsection) { + this._status.subsection = subsection || '' + this._status.spun ++ + if (this._disabled) return + if (!this._showing) return + this._requestRedraw() +} + +Gauge.prototype._handleSizeChange = function () { + this._gauge.setWidth(this._tty.columns - 1) + this._requestRedraw() +} + +Gauge.prototype._doRedraw = function () { + if (this._disabled || this._paused) return + if (!this._fixedFramerate) { + var now = Date.now() + if (this._lastUpdateAt && now - this._lastUpdateAt < this._updateInterval) return + this._lastUpdateAt = now + } + if (!this._showing && this._onScreen) { + this._onScreen = false + var result = this._gauge.hide() + if (this._hideCursor) { + result += this._gauge.showCursor() + } + return this._writeTo.write(result) + } + if (!this._showing && !this._onScreen) return + if (this._showing && !this._onScreen) { + this._onScreen = true + this._needsRedraw = true + if (this._hideCursor) { + this._writeTo.write(this._gauge.hideCursor()) + } + } + if (!this._needsRedraw) return + if (!this._writeTo.write(this._gauge.show(this._status))) { + this._paused = true + this._writeTo.on('drain', callWith(this, function () { + this._paused = false + this._doRedraw() + })) + } +} diff --git a/deps/npm/node_modules/node-gyp/node_modules/gauge/package.json b/deps/npm/node_modules/node-gyp/node_modules/gauge/package.json new file mode 100644 index 00000000000000..4882cff8390d87 --- /dev/null +++ b/deps/npm/node_modules/node-gyp/node_modules/gauge/package.json @@ -0,0 +1,63 @@ +{ + "name": "gauge", + "version": "2.7.4", + "description": "A terminal based horizontal guage", + "main": "index.js", + "scripts": { + "test": "standard && tap test/*.js --coverage", + "prepublish": "rm -f *~" + }, + "repository": { + "type": "git", + "url": "https://github.com/iarna/gauge" + }, + "keywords": [ + "progressbar", + "progress", + "gauge" + ], + "author": "Rebecca Turner ", + "license": "ISC", + "bugs": { + "url": "https://github.com/iarna/gauge/issues" + }, + "homepage": "https://github.com/iarna/gauge", + "dependencies": { + "aproba": "^1.0.3", + "console-control-strings": "^1.0.0", + "has-unicode": "^2.0.0", + "object-assign": "^4.1.0", + "signal-exit": "^3.0.0", + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1", + "wide-align": "^1.1.0" + }, + "devDependencies": { + "readable-stream": "^2.0.6", + "require-inject": "^1.4.0", + "standard": "^7.1.2", + "tap": "^5.7.2", + "through2": "^2.0.0" + }, + "files": [ + "base-theme.js", + "CHANGELOG.md", + "error.js", + "has-color.js", + "index.js", + "LICENSE", + "package.json", + "plumbing.js", + "process.js", + "progress-bar.js", + "README.md", + "render-template.js", + "set-immediate.js", + "set-interval.js", + "spin.js", + "template-item.js", + "theme-set.js", + "themes.js", + "wide-truncate.js" + ] +} diff --git a/deps/npm/node_modules/node-gyp/node_modules/gauge/plumbing.js b/deps/npm/node_modules/node-gyp/node_modules/gauge/plumbing.js new file mode 100644 index 00000000000000..1afb4af6d50174 --- /dev/null +++ b/deps/npm/node_modules/node-gyp/node_modules/gauge/plumbing.js @@ -0,0 +1,48 @@ +'use strict' +var consoleControl = require('console-control-strings') +var renderTemplate = require('./render-template.js') +var validate = require('aproba') + +var Plumbing = module.exports = function (theme, template, width) { + if (!width) width = 80 + validate('OAN', [theme, template, width]) + this.showing = false + this.theme = theme + this.width = width + this.template = template +} +Plumbing.prototype = {} + +Plumbing.prototype.setTheme = function (theme) { + validate('O', [theme]) + this.theme = theme +} + +Plumbing.prototype.setTemplate = function (template) { + validate('A', [template]) + this.template = template +} + +Plumbing.prototype.setWidth = function (width) { + validate('N', [width]) + this.width = width +} + +Plumbing.prototype.hide = function () { + return consoleControl.gotoSOL() + consoleControl.eraseLine() +} + +Plumbing.prototype.hideCursor = consoleControl.hideCursor + +Plumbing.prototype.showCursor = consoleControl.showCursor + +Plumbing.prototype.show = function (status) { + var values = Object.create(this.theme) + for (var key in status) { + values[key] = status[key] + } + + return renderTemplate(this.width, this.template, values).trim() + + consoleControl.color('reset') + + consoleControl.eraseLine() + consoleControl.gotoSOL() +} diff --git a/deps/npm/node_modules/node-gyp/node_modules/gauge/process.js b/deps/npm/node_modules/node-gyp/node_modules/gauge/process.js new file mode 100644 index 00000000000000..05e85694d755b6 --- /dev/null +++ b/deps/npm/node_modules/node-gyp/node_modules/gauge/process.js @@ -0,0 +1,3 @@ +'use strict' +// this exists so we can replace it during testing +module.exports = process diff --git a/deps/npm/node_modules/node-gyp/node_modules/gauge/progress-bar.js b/deps/npm/node_modules/node-gyp/node_modules/gauge/progress-bar.js new file mode 100644 index 00000000000000..7f8dd68be24cf0 --- /dev/null +++ b/deps/npm/node_modules/node-gyp/node_modules/gauge/progress-bar.js @@ -0,0 +1,35 @@ +'use strict' +var validate = require('aproba') +var renderTemplate = require('./render-template.js') +var wideTruncate = require('./wide-truncate') +var stringWidth = require('string-width') + +module.exports = function (theme, width, completed) { + validate('ONN', [theme, width, completed]) + if (completed < 0) completed = 0 + if (completed > 1) completed = 1 + if (width <= 0) return '' + var sofar = Math.round(width * completed) + var rest = width - sofar + var template = [ + {type: 'complete', value: repeat(theme.complete, sofar), length: sofar}, + {type: 'remaining', value: repeat(theme.remaining, rest), length: rest} + ] + return renderTemplate(width, template, theme) +} + +// lodash's way of repeating +function repeat (string, width) { + var result = '' + var n = width + do { + if (n % 2) { + result += string + } + n = Math.floor(n / 2) + /*eslint no-self-assign: 0*/ + string += string + } while (n && stringWidth(result) < width) + + return wideTruncate(result, width) +} diff --git a/deps/npm/node_modules/node-gyp/node_modules/gauge/render-template.js b/deps/npm/node_modules/node-gyp/node_modules/gauge/render-template.js new file mode 100644 index 00000000000000..3261bfbe6f4be5 --- /dev/null +++ b/deps/npm/node_modules/node-gyp/node_modules/gauge/render-template.js @@ -0,0 +1,181 @@ +'use strict' +var align = require('wide-align') +var validate = require('aproba') +var objectAssign = require('object-assign') +var wideTruncate = require('./wide-truncate') +var error = require('./error') +var TemplateItem = require('./template-item') + +function renderValueWithValues (values) { + return function (item) { + return renderValue(item, values) + } +} + +var renderTemplate = module.exports = function (width, template, values) { + var items = prepareItems(width, template, values) + var rendered = items.map(renderValueWithValues(values)).join('') + return align.left(wideTruncate(rendered, width), width) +} + +function preType (item) { + var cappedTypeName = item.type[0].toUpperCase() + item.type.slice(1) + return 'pre' + cappedTypeName +} + +function postType (item) { + var cappedTypeName = item.type[0].toUpperCase() + item.type.slice(1) + return 'post' + cappedTypeName +} + +function hasPreOrPost (item, values) { + if (!item.type) return + return values[preType(item)] || values[postType(item)] +} + +function generatePreAndPost (baseItem, parentValues) { + var item = objectAssign({}, baseItem) + var values = Object.create(parentValues) + var template = [] + var pre = preType(item) + var post = postType(item) + if (values[pre]) { + template.push({value: values[pre]}) + values[pre] = null + } + item.minLength = null + item.length = null + item.maxLength = null + template.push(item) + values[item.type] = values[item.type] + if (values[post]) { + template.push({value: values[post]}) + values[post] = null + } + return function ($1, $2, length) { + return renderTemplate(length, template, values) + } +} + +function prepareItems (width, template, values) { + function cloneAndObjectify (item, index, arr) { + var cloned = new TemplateItem(item, width) + var type = cloned.type + if (cloned.value == null) { + if (!(type in values)) { + if (cloned.default == null) { + throw new error.MissingTemplateValue(cloned, values) + } else { + cloned.value = cloned.default + } + } else { + cloned.value = values[type] + } + } + if (cloned.value == null || cloned.value === '') return null + cloned.index = index + cloned.first = index === 0 + cloned.last = index === arr.length - 1 + if (hasPreOrPost(cloned, values)) cloned.value = generatePreAndPost(cloned, values) + return cloned + } + + var output = template.map(cloneAndObjectify).filter(function (item) { return item != null }) + + var outputLength = 0 + var remainingSpace = width + var variableCount = output.length + + function consumeSpace (length) { + if (length > remainingSpace) length = remainingSpace + outputLength += length + remainingSpace -= length + } + + function finishSizing (item, length) { + if (item.finished) throw new error.Internal('Tried to finish template item that was already finished') + if (length === Infinity) throw new error.Internal('Length of template item cannot be infinity') + if (length != null) item.length = length + item.minLength = null + item.maxLength = null + --variableCount + item.finished = true + if (item.length == null) item.length = item.getBaseLength() + if (item.length == null) throw new error.Internal('Finished template items must have a length') + consumeSpace(item.getLength()) + } + + output.forEach(function (item) { + if (!item.kerning) return + var prevPadRight = item.first ? 0 : output[item.index - 1].padRight + if (!item.first && prevPadRight < item.kerning) item.padLeft = item.kerning - prevPadRight + if (!item.last) item.padRight = item.kerning + }) + + // Finish any that have a fixed (literal or intuited) length + output.forEach(function (item) { + if (item.getBaseLength() == null) return + finishSizing(item) + }) + + var resized = 0 + var resizing + var hunkSize + do { + resizing = false + hunkSize = Math.round(remainingSpace / variableCount) + output.forEach(function (item) { + if (item.finished) return + if (!item.maxLength) return + if (item.getMaxLength() < hunkSize) { + finishSizing(item, item.maxLength) + resizing = true + } + }) + } while (resizing && resized++ < output.length) + if (resizing) throw new error.Internal('Resize loop iterated too many times while determining maxLength') + + resized = 0 + do { + resizing = false + hunkSize = Math.round(remainingSpace / variableCount) + output.forEach(function (item) { + if (item.finished) return + if (!item.minLength) return + if (item.getMinLength() >= hunkSize) { + finishSizing(item, item.minLength) + resizing = true + } + }) + } while (resizing && resized++ < output.length) + if (resizing) throw new error.Internal('Resize loop iterated too many times while determining minLength') + + hunkSize = Math.round(remainingSpace / variableCount) + output.forEach(function (item) { + if (item.finished) return + finishSizing(item, hunkSize) + }) + + return output +} + +function renderFunction (item, values, length) { + validate('OON', arguments) + if (item.type) { + return item.value(values, values[item.type + 'Theme'] || {}, length) + } else { + return item.value(values, {}, length) + } +} + +function renderValue (item, values) { + var length = item.getBaseLength() + var value = typeof item.value === 'function' ? renderFunction(item, values, length) : item.value + if (value == null || value === '') return '' + var alignWith = align[item.align] || align.left + var leftPadding = item.padLeft ? align.left('', item.padLeft) : '' + var rightPadding = item.padRight ? align.right('', item.padRight) : '' + var truncated = wideTruncate(String(value), length) + var aligned = alignWith(truncated, length) + return leftPadding + aligned + rightPadding +} diff --git a/deps/npm/node_modules/node-gyp/node_modules/gauge/set-immediate.js b/deps/npm/node_modules/node-gyp/node_modules/gauge/set-immediate.js new file mode 100644 index 00000000000000..6650a485c49933 --- /dev/null +++ b/deps/npm/node_modules/node-gyp/node_modules/gauge/set-immediate.js @@ -0,0 +1,7 @@ +'use strict' +var process = require('./process') +try { + module.exports = setImmediate +} catch (ex) { + module.exports = process.nextTick +} diff --git a/deps/npm/node_modules/node-gyp/node_modules/gauge/set-interval.js b/deps/npm/node_modules/node-gyp/node_modules/gauge/set-interval.js new file mode 100644 index 00000000000000..576198793c5504 --- /dev/null +++ b/deps/npm/node_modules/node-gyp/node_modules/gauge/set-interval.js @@ -0,0 +1,3 @@ +'use strict' +// this exists so we can replace it during testing +module.exports = setInterval diff --git a/deps/npm/node_modules/node-gyp/node_modules/gauge/spin.js b/deps/npm/node_modules/node-gyp/node_modules/gauge/spin.js new file mode 100644 index 00000000000000..34142ee31acc7c --- /dev/null +++ b/deps/npm/node_modules/node-gyp/node_modules/gauge/spin.js @@ -0,0 +1,5 @@ +'use strict' + +module.exports = function spin (spinstr, spun) { + return spinstr[spun % spinstr.length] +} diff --git a/deps/npm/node_modules/node-gyp/node_modules/gauge/template-item.js b/deps/npm/node_modules/node-gyp/node_modules/gauge/template-item.js new file mode 100644 index 00000000000000..4f02fefaa23eca --- /dev/null +++ b/deps/npm/node_modules/node-gyp/node_modules/gauge/template-item.js @@ -0,0 +1,72 @@ +'use strict' +var stringWidth = require('string-width') + +module.exports = TemplateItem + +function isPercent (num) { + if (typeof num !== 'string') return false + return num.slice(-1) === '%' +} + +function percent (num) { + return Number(num.slice(0, -1)) / 100 +} + +function TemplateItem (values, outputLength) { + this.overallOutputLength = outputLength + this.finished = false + this.type = null + this.value = null + this.length = null + this.maxLength = null + this.minLength = null + this.kerning = null + this.align = 'left' + this.padLeft = 0 + this.padRight = 0 + this.index = null + this.first = null + this.last = null + if (typeof values === 'string') { + this.value = values + } else { + for (var prop in values) this[prop] = values[prop] + } + // Realize percents + if (isPercent(this.length)) { + this.length = Math.round(this.overallOutputLength * percent(this.length)) + } + if (isPercent(this.minLength)) { + this.minLength = Math.round(this.overallOutputLength * percent(this.minLength)) + } + if (isPercent(this.maxLength)) { + this.maxLength = Math.round(this.overallOutputLength * percent(this.maxLength)) + } + return this +} + +TemplateItem.prototype = {} + +TemplateItem.prototype.getBaseLength = function () { + var length = this.length + if (length == null && typeof this.value === 'string' && this.maxLength == null && this.minLength == null) { + length = stringWidth(this.value) + } + return length +} + +TemplateItem.prototype.getLength = function () { + var length = this.getBaseLength() + if (length == null) return null + return length + this.padLeft + this.padRight +} + +TemplateItem.prototype.getMaxLength = function () { + if (this.maxLength == null) return null + return this.maxLength + this.padLeft + this.padRight +} + +TemplateItem.prototype.getMinLength = function () { + if (this.minLength == null) return null + return this.minLength + this.padLeft + this.padRight +} diff --git a/deps/npm/node_modules/node-gyp/node_modules/gauge/theme-set.js b/deps/npm/node_modules/node-gyp/node_modules/gauge/theme-set.js new file mode 100644 index 00000000000000..c022d61cf13cb0 --- /dev/null +++ b/deps/npm/node_modules/node-gyp/node_modules/gauge/theme-set.js @@ -0,0 +1,114 @@ +'use strict' +var objectAssign = require('object-assign') + +module.exports = function () { + return ThemeSetProto.newThemeSet() +} + +var ThemeSetProto = {} + +ThemeSetProto.baseTheme = require('./base-theme.js') + +ThemeSetProto.newTheme = function (parent, theme) { + if (!theme) { + theme = parent + parent = this.baseTheme + } + return objectAssign({}, parent, theme) +} + +ThemeSetProto.getThemeNames = function () { + return Object.keys(this.themes) +} + +ThemeSetProto.addTheme = function (name, parent, theme) { + this.themes[name] = this.newTheme(parent, theme) +} + +ThemeSetProto.addToAllThemes = function (theme) { + var themes = this.themes + Object.keys(themes).forEach(function (name) { + objectAssign(themes[name], theme) + }) + objectAssign(this.baseTheme, theme) +} + +ThemeSetProto.getTheme = function (name) { + if (!this.themes[name]) throw this.newMissingThemeError(name) + return this.themes[name] +} + +ThemeSetProto.setDefault = function (opts, name) { + if (name == null) { + name = opts + opts = {} + } + var platform = opts.platform == null ? 'fallback' : opts.platform + var hasUnicode = !!opts.hasUnicode + var hasColor = !!opts.hasColor + if (!this.defaults[platform]) this.defaults[platform] = {true: {}, false: {}} + this.defaults[platform][hasUnicode][hasColor] = name +} + +ThemeSetProto.getDefault = function (opts) { + if (!opts) opts = {} + var platformName = opts.platform || process.platform + var platform = this.defaults[platformName] || this.defaults.fallback + var hasUnicode = !!opts.hasUnicode + var hasColor = !!opts.hasColor + if (!platform) throw this.newMissingDefaultThemeError(platformName, hasUnicode, hasColor) + if (!platform[hasUnicode][hasColor]) { + if (hasUnicode && hasColor && platform[!hasUnicode][hasColor]) { + hasUnicode = false + } else if (hasUnicode && hasColor && platform[hasUnicode][!hasColor]) { + hasColor = false + } else if (hasUnicode && hasColor && platform[!hasUnicode][!hasColor]) { + hasUnicode = false + hasColor = false + } else if (hasUnicode && !hasColor && platform[!hasUnicode][hasColor]) { + hasUnicode = false + } else if (!hasUnicode && hasColor && platform[hasUnicode][!hasColor]) { + hasColor = false + } else if (platform === this.defaults.fallback) { + throw this.newMissingDefaultThemeError(platformName, hasUnicode, hasColor) + } + } + if (platform[hasUnicode][hasColor]) { + return this.getTheme(platform[hasUnicode][hasColor]) + } else { + return this.getDefault(objectAssign({}, opts, {platform: 'fallback'})) + } +} + +ThemeSetProto.newMissingThemeError = function newMissingThemeError (name) { + var err = new Error('Could not find a gauge theme named "' + name + '"') + Error.captureStackTrace.call(err, newMissingThemeError) + err.theme = name + err.code = 'EMISSINGTHEME' + return err +} + +ThemeSetProto.newMissingDefaultThemeError = function newMissingDefaultThemeError (platformName, hasUnicode, hasColor) { + var err = new Error( + 'Could not find a gauge theme for your platform/unicode/color use combo:\n' + + ' platform = ' + platformName + '\n' + + ' hasUnicode = ' + hasUnicode + '\n' + + ' hasColor = ' + hasColor) + Error.captureStackTrace.call(err, newMissingDefaultThemeError) + err.platform = platformName + err.hasUnicode = hasUnicode + err.hasColor = hasColor + err.code = 'EMISSINGTHEME' + return err +} + +ThemeSetProto.newThemeSet = function () { + var themeset = function (opts) { + return themeset.getDefault(opts) + } + return objectAssign(themeset, ThemeSetProto, { + themes: objectAssign({}, this.themes), + baseTheme: objectAssign({}, this.baseTheme), + defaults: JSON.parse(JSON.stringify(this.defaults || {})) + }) +} diff --git a/deps/npm/node_modules/node-gyp/node_modules/gauge/themes.js b/deps/npm/node_modules/node-gyp/node_modules/gauge/themes.js new file mode 100644 index 00000000000000..eb5a4f5b5e1034 --- /dev/null +++ b/deps/npm/node_modules/node-gyp/node_modules/gauge/themes.js @@ -0,0 +1,54 @@ +'use strict' +var consoleControl = require('console-control-strings') +var ThemeSet = require('./theme-set.js') + +var themes = module.exports = new ThemeSet() + +themes.addTheme('ASCII', { + preProgressbar: '[', + postProgressbar: ']', + progressbarTheme: { + complete: '#', + remaining: '.' + }, + activityIndicatorTheme: '-\\|/', + preSubsection: '>' +}) + +themes.addTheme('colorASCII', themes.getTheme('ASCII'), { + progressbarTheme: { + preComplete: consoleControl.color('inverse'), + complete: ' ', + postComplete: consoleControl.color('stopInverse'), + preRemaining: consoleControl.color('brightBlack'), + remaining: '.', + postRemaining: consoleControl.color('reset') + } +}) + +themes.addTheme('brailleSpinner', { + preProgressbar: '⸨', + postProgressbar: '⸩', + progressbarTheme: { + complete: '░', + remaining: '⠂' + }, + activityIndicatorTheme: '⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏', + preSubsection: '>' +}) + +themes.addTheme('colorBrailleSpinner', themes.getTheme('brailleSpinner'), { + progressbarTheme: { + preComplete: consoleControl.color('inverse'), + complete: ' ', + postComplete: consoleControl.color('stopInverse'), + preRemaining: consoleControl.color('brightBlack'), + remaining: '░', + postRemaining: consoleControl.color('reset') + } +}) + +themes.setDefault({}, 'ASCII') +themes.setDefault({hasColor: true}, 'colorASCII') +themes.setDefault({platform: 'darwin', hasUnicode: true}, 'brailleSpinner') +themes.setDefault({platform: 'darwin', hasUnicode: true, hasColor: true}, 'colorBrailleSpinner') diff --git a/deps/npm/node_modules/node-gyp/node_modules/gauge/wide-truncate.js b/deps/npm/node_modules/node-gyp/node_modules/gauge/wide-truncate.js new file mode 100644 index 00000000000000..c531bc491fbb58 --- /dev/null +++ b/deps/npm/node_modules/node-gyp/node_modules/gauge/wide-truncate.js @@ -0,0 +1,25 @@ +'use strict' +var stringWidth = require('string-width') +var stripAnsi = require('strip-ansi') + +module.exports = wideTruncate + +function wideTruncate (str, target) { + if (stringWidth(str) === 0) return str + if (target <= 0) return '' + if (stringWidth(str) <= target) return str + + // We compute the number of bytes of ansi sequences here and add + // that to our initial truncation to ensure that we don't slice one + // that we want to keep in half. + var noAnsi = stripAnsi(str) + var ansiSize = str.length + noAnsi.length + var truncated = str.slice(0, target + ansiSize) + + // we have to shrink the result to account for our ansi sequence buffer + // (if an ansi sequence was truncated) and double width characters. + while (stringWidth(truncated) > target) { + truncated = truncated.slice(0, -1) + } + return truncated +} diff --git a/deps/npm/node_modules/gauge/node_modules/is-fullwidth-code-point/index.js b/deps/npm/node_modules/node-gyp/node_modules/is-fullwidth-code-point/index.js similarity index 100% rename from deps/npm/node_modules/gauge/node_modules/is-fullwidth-code-point/index.js rename to deps/npm/node_modules/node-gyp/node_modules/is-fullwidth-code-point/index.js diff --git a/deps/npm/node_modules/gauge/node_modules/is-fullwidth-code-point/license b/deps/npm/node_modules/node-gyp/node_modules/is-fullwidth-code-point/license similarity index 100% rename from deps/npm/node_modules/gauge/node_modules/is-fullwidth-code-point/license rename to deps/npm/node_modules/node-gyp/node_modules/is-fullwidth-code-point/license diff --git a/deps/npm/node_modules/gauge/node_modules/is-fullwidth-code-point/package.json b/deps/npm/node_modules/node-gyp/node_modules/is-fullwidth-code-point/package.json similarity index 100% rename from deps/npm/node_modules/gauge/node_modules/is-fullwidth-code-point/package.json rename to deps/npm/node_modules/node-gyp/node_modules/is-fullwidth-code-point/package.json diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/LICENSE b/deps/npm/node_modules/node-gyp/node_modules/npmlog/LICENSE new file mode 100644 index 00000000000000..19129e315fe593 --- /dev/null +++ b/deps/npm/node_modules/node-gyp/node_modules/npmlog/LICENSE @@ -0,0 +1,15 @@ +The ISC License + +Copyright (c) Isaac Z. Schlueter and Contributors + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR +IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/log.js b/deps/npm/node_modules/node-gyp/node_modules/npmlog/log.js new file mode 100644 index 00000000000000..341f3313ab354c --- /dev/null +++ b/deps/npm/node_modules/node-gyp/node_modules/npmlog/log.js @@ -0,0 +1,309 @@ +'use strict' +var Progress = require('are-we-there-yet') +var Gauge = require('gauge') +var EE = require('events').EventEmitter +var log = exports = module.exports = new EE() +var util = require('util') + +var setBlocking = require('set-blocking') +var consoleControl = require('console-control-strings') + +setBlocking(true) +var stream = process.stderr +Object.defineProperty(log, 'stream', { + set: function (newStream) { + stream = newStream + if (this.gauge) this.gauge.setWriteTo(stream, stream) + }, + get: function () { + return stream + } +}) + +// by default, decide based on tty-ness. +var colorEnabled +log.useColor = function () { + return colorEnabled != null ? colorEnabled : stream.isTTY +} + +log.enableColor = function () { + colorEnabled = true + this.gauge.setTheme({hasColor: colorEnabled, hasUnicode: unicodeEnabled}) +} +log.disableColor = function () { + colorEnabled = false + this.gauge.setTheme({hasColor: colorEnabled, hasUnicode: unicodeEnabled}) +} + +// default level +log.level = 'info' + +log.gauge = new Gauge(stream, { + enabled: false, // no progress bars unless asked + theme: {hasColor: log.useColor()}, + template: [ + {type: 'progressbar', length: 20}, + {type: 'activityIndicator', kerning: 1, length: 1}, + {type: 'section', default: ''}, + ':', + {type: 'logline', kerning: 1, default: ''} + ] +}) + +log.tracker = new Progress.TrackerGroup() + +// we track this separately as we may need to temporarily disable the +// display of the status bar for our own loggy purposes. +log.progressEnabled = log.gauge.isEnabled() + +var unicodeEnabled + +log.enableUnicode = function () { + unicodeEnabled = true + this.gauge.setTheme({hasColor: this.useColor(), hasUnicode: unicodeEnabled}) +} + +log.disableUnicode = function () { + unicodeEnabled = false + this.gauge.setTheme({hasColor: this.useColor(), hasUnicode: unicodeEnabled}) +} + +log.setGaugeThemeset = function (themes) { + this.gauge.setThemeset(themes) +} + +log.setGaugeTemplate = function (template) { + this.gauge.setTemplate(template) +} + +log.enableProgress = function () { + if (this.progressEnabled) return + this.progressEnabled = true + this.tracker.on('change', this.showProgress) + if (this._pause) return + this.gauge.enable() +} + +log.disableProgress = function () { + if (!this.progressEnabled) return + this.progressEnabled = false + this.tracker.removeListener('change', this.showProgress) + this.gauge.disable() +} + +var trackerConstructors = ['newGroup', 'newItem', 'newStream'] + +var mixinLog = function (tracker) { + // mixin the public methods from log into the tracker + // (except: conflicts and one's we handle specially) + Object.keys(log).forEach(function (P) { + if (P[0] === '_') return + if (trackerConstructors.filter(function (C) { return C === P }).length) return + if (tracker[P]) return + if (typeof log[P] !== 'function') return + var func = log[P] + tracker[P] = function () { + return func.apply(log, arguments) + } + }) + // if the new tracker is a group, make sure any subtrackers get + // mixed in too + if (tracker instanceof Progress.TrackerGroup) { + trackerConstructors.forEach(function (C) { + var func = tracker[C] + tracker[C] = function () { return mixinLog(func.apply(tracker, arguments)) } + }) + } + return tracker +} + +// Add tracker constructors to the top level log object +trackerConstructors.forEach(function (C) { + log[C] = function () { return mixinLog(this.tracker[C].apply(this.tracker, arguments)) } +}) + +log.clearProgress = function (cb) { + if (!this.progressEnabled) return cb && process.nextTick(cb) + this.gauge.hide(cb) +} + +log.showProgress = function (name, completed) { + if (!this.progressEnabled) return + var values = {} + if (name) values.section = name + var last = log.record[log.record.length - 1] + if (last) { + values.subsection = last.prefix + var disp = log.disp[last.level] || last.level + var logline = this._format(disp, log.style[last.level]) + if (last.prefix) logline += ' ' + this._format(last.prefix, this.prefixStyle) + logline += ' ' + last.message.split(/\r?\n/)[0] + values.logline = logline + } + values.completed = completed || this.tracker.completed() + this.gauge.show(values) +}.bind(log) // bind for use in tracker's on-change listener + +// temporarily stop emitting, but don't drop +log.pause = function () { + this._paused = true + if (this.progressEnabled) this.gauge.disable() +} + +log.resume = function () { + if (!this._paused) return + this._paused = false + + var b = this._buffer + this._buffer = [] + b.forEach(function (m) { + this.emitLog(m) + }, this) + if (this.progressEnabled) this.gauge.enable() +} + +log._buffer = [] + +var id = 0 +log.record = [] +log.maxRecordSize = 10000 +log.log = function (lvl, prefix, message) { + var l = this.levels[lvl] + if (l === undefined) { + return this.emit('error', new Error(util.format( + 'Undefined log level: %j', lvl))) + } + + var a = new Array(arguments.length - 2) + var stack = null + for (var i = 2; i < arguments.length; i++) { + var arg = a[i - 2] = arguments[i] + + // resolve stack traces to a plain string. + if (typeof arg === 'object' && arg && + (arg instanceof Error) && arg.stack) { + + Object.defineProperty(arg, 'stack', { + value: stack = arg.stack + '', + enumerable: true, + writable: true + }) + } + } + if (stack) a.unshift(stack + '\n') + message = util.format.apply(util, a) + + var m = { id: id++, + level: lvl, + prefix: String(prefix || ''), + message: message, + messageRaw: a } + + this.emit('log', m) + this.emit('log.' + lvl, m) + if (m.prefix) this.emit(m.prefix, m) + + this.record.push(m) + var mrs = this.maxRecordSize + var n = this.record.length - mrs + if (n > mrs / 10) { + var newSize = Math.floor(mrs * 0.9) + this.record = this.record.slice(-1 * newSize) + } + + this.emitLog(m) +}.bind(log) + +log.emitLog = function (m) { + if (this._paused) { + this._buffer.push(m) + return + } + if (this.progressEnabled) this.gauge.pulse(m.prefix) + var l = this.levels[m.level] + if (l === undefined) return + if (l < this.levels[this.level]) return + if (l > 0 && !isFinite(l)) return + + // If 'disp' is null or undefined, use the lvl as a default + // Allows: '', 0 as valid disp + var disp = log.disp[m.level] != null ? log.disp[m.level] : m.level + this.clearProgress() + m.message.split(/\r?\n/).forEach(function (line) { + if (this.heading) { + this.write(this.heading, this.headingStyle) + this.write(' ') + } + this.write(disp, log.style[m.level]) + var p = m.prefix || '' + if (p) this.write(' ') + this.write(p, this.prefixStyle) + this.write(' ' + line + '\n') + }, this) + this.showProgress() +} + +log._format = function (msg, style) { + if (!stream) return + + var output = '' + if (this.useColor()) { + style = style || {} + var settings = [] + if (style.fg) settings.push(style.fg) + if (style.bg) settings.push('bg' + style.bg[0].toUpperCase() + style.bg.slice(1)) + if (style.bold) settings.push('bold') + if (style.underline) settings.push('underline') + if (style.inverse) settings.push('inverse') + if (settings.length) output += consoleControl.color(settings) + if (style.beep) output += consoleControl.beep() + } + output += msg + if (this.useColor()) { + output += consoleControl.color('reset') + } + return output +} + +log.write = function (msg, style) { + if (!stream) return + + stream.write(this._format(msg, style)) +} + +log.addLevel = function (lvl, n, style, disp) { + // If 'disp' is null or undefined, use the lvl as a default + if (disp == null) disp = lvl + this.levels[lvl] = n + this.style[lvl] = style + if (!this[lvl]) { + this[lvl] = function () { + var a = new Array(arguments.length + 1) + a[0] = lvl + for (var i = 0; i < arguments.length; i++) { + a[i + 1] = arguments[i] + } + return this.log.apply(this, a) + }.bind(this) + } + this.disp[lvl] = disp +} + +log.prefixStyle = { fg: 'magenta' } +log.headingStyle = { fg: 'white', bg: 'black' } + +log.style = {} +log.levels = {} +log.disp = {} +log.addLevel('silly', -Infinity, { inverse: true }, 'sill') +log.addLevel('verbose', 1000, { fg: 'blue', bg: 'black' }, 'verb') +log.addLevel('info', 2000, { fg: 'green' }) +log.addLevel('timing', 2500, { fg: 'green', bg: 'black' }) +log.addLevel('http', 3000, { fg: 'green', bg: 'black' }) +log.addLevel('notice', 3500, { fg: 'blue', bg: 'black' }) +log.addLevel('warn', 4000, { fg: 'black', bg: 'yellow' }, 'WARN') +log.addLevel('error', 5000, { fg: 'red', bg: 'black' }, 'ERR!') +log.addLevel('silent', Infinity) + +// allow 'error' prefix +log.on('error', function () {}) diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/package.json b/deps/npm/node_modules/node-gyp/node_modules/npmlog/package.json new file mode 100644 index 00000000000000..7220f8e72a3c79 --- /dev/null +++ b/deps/npm/node_modules/node-gyp/node_modules/npmlog/package.json @@ -0,0 +1,28 @@ +{ + "author": "Isaac Z. Schlueter (http://blog.izs.me/)", + "name": "npmlog", + "description": "logger for npm", + "version": "4.1.2", + "repository": { + "type": "git", + "url": "https://github.com/npm/npmlog.git" + }, + "main": "log.js", + "files": [ + "log.js" + ], + "scripts": { + "test": "standard && tap test/*.js" + }, + "dependencies": { + "are-we-there-yet": "~1.1.2", + "console-control-strings": "~1.1.0", + "gauge": "~2.7.3", + "set-blocking": "~2.0.0" + }, + "devDependencies": { + "standard": "~7.1.2", + "tap": "~5.7.3" + }, + "license": "ISC" +} diff --git a/deps/npm/node_modules/gauge/node_modules/string-width/index.js b/deps/npm/node_modules/node-gyp/node_modules/string-width/index.js similarity index 100% rename from deps/npm/node_modules/gauge/node_modules/string-width/index.js rename to deps/npm/node_modules/node-gyp/node_modules/string-width/index.js diff --git a/deps/npm/node_modules/gauge/node_modules/string-width/license b/deps/npm/node_modules/node-gyp/node_modules/string-width/license similarity index 100% rename from deps/npm/node_modules/gauge/node_modules/string-width/license rename to deps/npm/node_modules/node-gyp/node_modules/string-width/license diff --git a/deps/npm/node_modules/gauge/node_modules/string-width/package.json b/deps/npm/node_modules/node-gyp/node_modules/string-width/package.json similarity index 100% rename from deps/npm/node_modules/gauge/node_modules/string-width/package.json rename to deps/npm/node_modules/node-gyp/node_modules/string-width/package.json diff --git a/deps/npm/node_modules/npmlog/log.js b/deps/npm/node_modules/npmlog/log.js index 341f3313ab354c..069154262e4da9 100644 --- a/deps/npm/node_modules/npmlog/log.js +++ b/deps/npm/node_modules/npmlog/log.js @@ -13,11 +13,12 @@ var stream = process.stderr Object.defineProperty(log, 'stream', { set: function (newStream) { stream = newStream - if (this.gauge) this.gauge.setWriteTo(stream, stream) + if (this.gauge) + this.gauge.setWriteTo(stream, stream) }, get: function () { return stream - } + }, }) // by default, decide based on tty-ness. @@ -46,8 +47,8 @@ log.gauge = new Gauge(stream, { {type: 'activityIndicator', kerning: 1, length: 1}, {type: 'section', default: ''}, ':', - {type: 'logline', kerning: 1, default: ''} - ] + {type: 'logline', kerning: 1, default: ''}, + ], }) log.tracker = new Progress.TrackerGroup() @@ -77,15 +78,20 @@ log.setGaugeTemplate = function (template) { } log.enableProgress = function () { - if (this.progressEnabled) return + if (this.progressEnabled) + return + this.progressEnabled = true this.tracker.on('change', this.showProgress) - if (this._pause) return + if (this._paused) + return + this.gauge.enable() } log.disableProgress = function () { - if (!this.progressEnabled) return + if (!this.progressEnabled) + return this.progressEnabled = false this.tracker.removeListener('change', this.showProgress) this.gauge.disable() @@ -97,10 +103,20 @@ var mixinLog = function (tracker) { // mixin the public methods from log into the tracker // (except: conflicts and one's we handle specially) Object.keys(log).forEach(function (P) { - if (P[0] === '_') return - if (trackerConstructors.filter(function (C) { return C === P }).length) return - if (tracker[P]) return - if (typeof log[P] !== 'function') return + if (P[0] === '_') + return + + if (trackerConstructors.filter(function (C) { + return C === P + }).length) + return + + if (tracker[P]) + return + + if (typeof log[P] !== 'function') + return + var func = log[P] tracker[P] = function () { return func.apply(log, arguments) @@ -111,7 +127,9 @@ var mixinLog = function (tracker) { if (tracker instanceof Progress.TrackerGroup) { trackerConstructors.forEach(function (C) { var func = tracker[C] - tracker[C] = function () { return mixinLog(func.apply(tracker, arguments)) } + tracker[C] = function () { + return mixinLog(func.apply(tracker, arguments)) + } }) } return tracker @@ -119,24 +137,34 @@ var mixinLog = function (tracker) { // Add tracker constructors to the top level log object trackerConstructors.forEach(function (C) { - log[C] = function () { return mixinLog(this.tracker[C].apply(this.tracker, arguments)) } + log[C] = function () { + return mixinLog(this.tracker[C].apply(this.tracker, arguments)) + } }) log.clearProgress = function (cb) { - if (!this.progressEnabled) return cb && process.nextTick(cb) + if (!this.progressEnabled) + return cb && process.nextTick(cb) + this.gauge.hide(cb) } log.showProgress = function (name, completed) { - if (!this.progressEnabled) return + if (!this.progressEnabled) + return + var values = {} - if (name) values.section = name + if (name) + values.section = name + var last = log.record[log.record.length - 1] if (last) { values.subsection = last.prefix var disp = log.disp[last.level] || last.level var logline = this._format(disp, log.style[last.level]) - if (last.prefix) logline += ' ' + this._format(last.prefix, this.prefixStyle) + if (last.prefix) + logline += ' ' + this._format(last.prefix, this.prefixStyle) + logline += ' ' + last.message.split(/\r?\n/)[0] values.logline = logline } @@ -147,11 +175,14 @@ log.showProgress = function (name, completed) { // temporarily stop emitting, but don't drop log.pause = function () { this._paused = true - if (this.progressEnabled) this.gauge.disable() + if (this.progressEnabled) + this.gauge.disable() } log.resume = function () { - if (!this._paused) return + if (!this._paused) + return + this._paused = false var b = this._buffer @@ -159,7 +190,8 @@ log.resume = function () { b.forEach(function (m) { this.emitLog(m) }, this) - if (this.progressEnabled) this.gauge.enable() + if (this.progressEnabled) + this.gauge.enable() } log._buffer = [] @@ -180,28 +212,30 @@ log.log = function (lvl, prefix, message) { var arg = a[i - 2] = arguments[i] // resolve stack traces to a plain string. - if (typeof arg === 'object' && arg && - (arg instanceof Error) && arg.stack) { - + if (typeof arg === 'object' && arg instanceof Error && arg.stack) { Object.defineProperty(arg, 'stack', { value: stack = arg.stack + '', enumerable: true, - writable: true + writable: true, }) } } - if (stack) a.unshift(stack + '\n') + if (stack) + a.unshift(stack + '\n') message = util.format.apply(util, a) - var m = { id: id++, - level: lvl, - prefix: String(prefix || ''), - message: message, - messageRaw: a } + var m = { + id: id++, + level: lvl, + prefix: String(prefix || ''), + message: message, + messageRaw: a, + } this.emit('log', m) this.emit('log.' + lvl, m) - if (m.prefix) this.emit(m.prefix, m) + if (m.prefix) + this.emit(m.prefix, m) this.record.push(m) var mrs = this.maxRecordSize @@ -219,11 +253,18 @@ log.emitLog = function (m) { this._buffer.push(m) return } - if (this.progressEnabled) this.gauge.pulse(m.prefix) + if (this.progressEnabled) + this.gauge.pulse(m.prefix) + var l = this.levels[m.level] - if (l === undefined) return - if (l < this.levels[this.level]) return - if (l > 0 && !isFinite(l)) return + if (l === undefined) + return + + if (l < this.levels[this.level]) + return + + if (l > 0 && !isFinite(l)) + return // If 'disp' is null or undefined, use the lvl as a default // Allows: '', 0 as valid disp @@ -236,7 +277,9 @@ log.emitLog = function (m) { } this.write(disp, log.style[m.level]) var p = m.prefix || '' - if (p) this.write(' ') + if (p) + this.write(' ') + this.write(p, this.prefixStyle) this.write(' ' + line + '\n') }, this) @@ -244,45 +287,62 @@ log.emitLog = function (m) { } log._format = function (msg, style) { - if (!stream) return + if (!stream) + return var output = '' if (this.useColor()) { style = style || {} var settings = [] - if (style.fg) settings.push(style.fg) - if (style.bg) settings.push('bg' + style.bg[0].toUpperCase() + style.bg.slice(1)) - if (style.bold) settings.push('bold') - if (style.underline) settings.push('underline') - if (style.inverse) settings.push('inverse') - if (settings.length) output += consoleControl.color(settings) - if (style.beep) output += consoleControl.beep() + if (style.fg) + settings.push(style.fg) + + if (style.bg) + settings.push('bg' + style.bg[0].toUpperCase() + style.bg.slice(1)) + + if (style.bold) + settings.push('bold') + + if (style.underline) + settings.push('underline') + + if (style.inverse) + settings.push('inverse') + + if (settings.length) + output += consoleControl.color(settings) + + if (style.beep) + output += consoleControl.beep() } output += msg - if (this.useColor()) { + if (this.useColor()) output += consoleControl.color('reset') - } + return output } log.write = function (msg, style) { - if (!stream) return + if (!stream) + return stream.write(this._format(msg, style)) } log.addLevel = function (lvl, n, style, disp) { // If 'disp' is null or undefined, use the lvl as a default - if (disp == null) disp = lvl + if (disp == null) + disp = lvl + this.levels[lvl] = n this.style[lvl] = style if (!this[lvl]) { this[lvl] = function () { var a = new Array(arguments.length + 1) a[0] = lvl - for (var i = 0; i < arguments.length; i++) { + for (var i = 0; i < arguments.length; i++) a[i + 1] = arguments[i] - } + return this.log.apply(this, a) }.bind(this) } diff --git a/deps/npm/node_modules/npmlog/package.json b/deps/npm/node_modules/npmlog/package.json index 7220f8e72a3c79..5288b9ca062569 100644 --- a/deps/npm/node_modules/npmlog/package.json +++ b/deps/npm/node_modules/npmlog/package.json @@ -2,7 +2,7 @@ "author": "Isaac Z. Schlueter (http://blog.izs.me/)", "name": "npmlog", "description": "logger for npm", - "version": "4.1.2", + "version": "5.0.0", "repository": { "type": "git", "url": "https://github.com/npm/npmlog.git" @@ -12,17 +12,22 @@ "log.js" ], "scripts": { - "test": "standard && tap test/*.js" + "test": "tap test/*.js --branches=95", + "npmclilint": "npmcli-lint", + "lint": "npm run npmclilint -- \"*.*js\" \"test/**/*.*js\"", + "lintfix": "npm run lint -- --fix", + "posttest": "npm run lint --", + "postsnap": "npm run lintfix --" }, "dependencies": { - "are-we-there-yet": "~1.1.2", - "console-control-strings": "~1.1.0", - "gauge": "~2.7.3", - "set-blocking": "~2.0.0" + "are-we-there-yet": "^1.1.5", + "console-control-strings": "^1.1.0", + "gauge": "^3.0.0", + "set-blocking": "^2.0.0" }, "devDependencies": { - "standard": "~7.1.2", - "tap": "~5.7.3" + "@npmcli/lint": "^1.0.1", + "tap": "^15.0.9" }, "license": "ISC" } diff --git a/deps/npm/node_modules/read-package-json-fast/index.js b/deps/npm/node_modules/read-package-json-fast/index.js index bc1c059272c049..646ff7dfbbd761 100644 --- a/deps/npm/node_modules/read-package-json-fast/index.js +++ b/deps/npm/node_modules/read-package-json-fast/index.js @@ -1,15 +1,56 @@ const {promisify} = require('util') const fs = require('fs') const readFile = promisify(fs.readFile) +const lstat = promisify(fs.lstat) +const readdir = promisify(fs.readdir) const parse = require('json-parse-even-better-errors') + +const { resolve, dirname, join, relative } = require('path') + const rpj = path => readFile(path, 'utf8') - .then(data => normalize(stripUnderscores(parse(data)))) + .then(data => readBinDir(path, normalize(stripUnderscores(parse(data))))) .catch(er => { er.path = path throw er }) + const normalizePackageBin = require('npm-normalize-package-bin') +// load the directories.bin folder as a 'bin' object +const readBinDir = async (path, data) => { + if (data.bin) + return data + + const m = data.directories && data.directories.bin + if (!m || typeof m !== 'string') + return data + + // cut off any monkey business, like setting directories.bin + // to ../../../etc/passwd or /etc/passwd or something like that. + const root = dirname(path) + const dir = join('.', join('/', m)) + data.bin = await walkBinDir(root, dir, {}) + return data +} + +const walkBinDir = async (root, dir, obj) => { + const entries = await readdir(resolve(root, dir)).catch(() => []) + for (const entry of entries) { + if (entry.charAt(0) === '.') + continue + const f = resolve(root, dir, entry) + // ignore stat errors, weird file types, symlinks, etc. + const st = await lstat(f).catch(() => null) + if (!st) + continue + else if (st.isFile()) + obj[entry] = relative(root, f) + else if (st.isDirectory()) + await walkBinDir(root, join(dir, entry), obj) + } + return obj +} + // do not preserve _fields set in files, they are sus const stripUnderscores = data => { for (const key of Object.keys(data).filter(k => /^_/.test(k))) diff --git a/deps/npm/node_modules/read-package-json-fast/package.json b/deps/npm/node_modules/read-package-json-fast/package.json index 388e76595833ec..c3a9f7dc5c37bf 100644 --- a/deps/npm/node_modules/read-package-json-fast/package.json +++ b/deps/npm/node_modules/read-package-json-fast/package.json @@ -1,6 +1,6 @@ { "name": "read-package-json-fast", - "version": "2.0.2", + "version": "2.0.3", "description": "Like read-package-json, but faster", "author": "Isaac Z. Schlueter (https://izs.me)", "license": "ISC", @@ -18,7 +18,7 @@ "check-coverage": true }, "devDependencies": { - "tap": "^14.10.1" + "tap": "^15.0.9" }, "dependencies": { "json-parse-even-better-errors": "^2.3.0", diff --git a/deps/npm/package.json b/deps/npm/package.json index f0b9642905cede..fd60267ed1f02d 100644 --- a/deps/npm/package.json +++ b/deps/npm/package.json @@ -1,5 +1,5 @@ { - "version": "7.20.0", + "version": "7.20.1", "name": "npm", "description": "a package manager for JavaScript", "workspaces": [ @@ -102,14 +102,14 @@ "npm-profile": "^5.0.3", "npm-registry-fetch": "^11.0.0", "npm-user-validate": "^1.0.1", - "npmlog": "~4.1.2", + "npmlog": "^5.0.0", "opener": "^1.5.2", "pacote": "^11.3.5", "parse-conflict-json": "^1.1.1", "qrcode-terminal": "^0.12.0", "read": "~1.0.7", "read-package-json": "^3.0.1", - "read-package-json-fast": "^2.0.2", + "read-package-json-fast": "^2.0.3", "readdir-scoped-modules": "^1.1.0", "rimraf": "^3.0.2", "semver": "^7.3.5", @@ -193,7 +193,7 @@ "write-file-atomic" ], "devDependencies": { - "eslint": "^7.30.0", + "eslint": "^7.31.0", "eslint-plugin-import": "^2.23.4", "eslint-plugin-node": "^11.1.0", "eslint-plugin-promise": "^5.1.0", diff --git a/deps/npm/test/lib/exec.js b/deps/npm/test/lib/exec.js index 6d99c7959d88e8..03a1bedf97e506 100644 --- a/deps/npm/test/lib/exec.js +++ b/deps/npm/test/lib/exec.js @@ -25,6 +25,7 @@ const LOG_WARN = [] let PROGRESS_IGNORED = false const flatOptions = { npxCache: 'npx-cache-dir', + color: false, cache: 'cache-dir', legacyPeerDeps: false, package: [], @@ -109,12 +110,13 @@ t.afterEach(() => { LOG_WARN.length = 0 PROGRESS_IGNORED = false flatOptions.legacyPeerDeps = false - config.color = false + flatOptions.color = false config['script-shell'] = 'shell-cmd' config.package = [] flatOptions.package = [] config.call = '' config.yes = true + npm.color = false npm.localBin = 'local-bin' npm.globalBin = 'global-bin' }) @@ -268,7 +270,8 @@ t.test('npm exec , run interactive shell', t => { t.test('print message with color when tty and not in CI', t => { CI_NAME = null process.stdin.isTTY = true - config.color = true + npm.color = true + flatOptions.color = true run(t, true, () => { t.strictSame(LOG_WARN, []) @@ -1204,7 +1207,8 @@ t.test('workspaces', t => { }) }) - config.color = true + npm.color = true + flatOptions.color = true npm._mockOutputs.length = 0 await new Promise((res, rej) => { exec.execWorkspaces([], ['a'], er => { diff --git a/deps/npm/test/lib/utils/error-message.js b/deps/npm/test/lib/utils/error-message.js index 3fdfb8cc250898..908d70fc3924db 100644 --- a/deps/npm/test/lib/utils/error-message.js +++ b/deps/npm/test/lib/utils/error-message.js @@ -15,6 +15,9 @@ const { resolve } = require('path') const npm = require('../../../lib/npm.js') const CACHE = '/some/cache/dir' npm.config = { + flat: { + color: false, + }, loaded: false, localPrefix: '/some/prefix/dir', get: key => { @@ -467,7 +470,7 @@ t.test('explain ERESOLVE errors', t => { t.matchSnapshot(errorMessage(er, npm)) t.match(EXPLAIN_CALLED, [[ er, - undefined, + false, path.resolve(npm.cache, 'eresolve-report.txt'), ]]) t.end() diff --git a/deps/npm/test/lib/utils/exit-handler.js b/deps/npm/test/lib/utils/exit-handler.js index 981ac9a32b6845..c88a1aef67927d 100644 --- a/deps/npm/test/lib/utils/exit-handler.js +++ b/deps/npm/test/lib/utils/exit-handler.js @@ -336,15 +336,14 @@ t.test('defaults to log error msg if stack is missing', (t) => { t.end() }) -t.test('exits cleanly when emitting exit event', (t) => { - t.plan(1) +t.test('exits uncleanly when only emitting exit event', (t) => { + t.plan(2) npm.log.level = 'silent' process.emit('exit') - t.match( - npm.log.record.find(r => r.level === 'info'), - { prefix: 'ok', message: '' } - ) + const logData = fs.readFileSync(logFile, 'utf8') + t.match(logData, 'Exit handler never called!') + t.match(process.exitCode, 1, 'exitCode coerced to 1') t.end() }) diff --git a/deps/npm/test/lib/utils/setup-log.js b/deps/npm/test/lib/utils/setup-log.js index 86befe6e292972..7f907bc7e41482 100644 --- a/deps/npm/test/lib/utils/setup-log.js +++ b/deps/npm/test/lib/utils/setup-log.js @@ -84,12 +84,12 @@ t.test('setup with color=always and unicode', t => { t.strictSame(WARN_CALLED, [['ERESOLVE', 'hello', { some: 'object' }]]) WARN_CALLED.length = 0 - t.equal(setupLog(config({ + setupLog(config({ loglevel: 'warn', color: 'always', unicode: true, progress: false, - })), true) + })) npmlog.warn('ERESOLVE', 'hello', { some: { other: 'object' } }) t.strictSame(EXPLAIN_CALLED, [[{ some: { other: 'object' } }, true, 2]], @@ -125,12 +125,12 @@ t.test('setup with color=true, no unicode, and non-TTY terminal', t => { process.stderr.isTTY = false process.stdout.isTTY = false - t.equal(setupLog(config({ + setupLog(config({ loglevel: 'warn', color: false, progress: false, heading: 'asdf', - })), false) + })) t.strictSame(settings, { level: 'warn', @@ -156,12 +156,12 @@ t.test('setup with color=true, no unicode, and dumb TTY terminal', t => { process.stdout.isTTY = true process.env.TERM = 'dumb' - t.equal(setupLog(config({ + setupLog(config({ loglevel: 'warn', color: true, progress: false, heading: 'asdf', - })), true) + })) t.strictSame(settings, { level: 'warn', @@ -187,12 +187,12 @@ t.test('setup with color=true, no unicode, and non-dumb TTY terminal', t => { process.stdout.isTTY = true process.env.TERM = 'totes not dum' - t.equal(setupLog(config({ + setupLog(config({ loglevel: 'warn', color: true, progress: true, heading: 'asdf', - })), true) + })) t.strictSame(settings, { level: 'warn', @@ -218,12 +218,12 @@ t.test('setup with non-TTY stdout, TTY stderr', t => { process.stdout.isTTY = false process.env.TERM = 'definitely not a dummy' - t.equal(setupLog(config({ + setupLog(config({ loglevel: 'warn', color: true, progress: true, heading: 'asdf', - })), false) + })) t.strictSame(settings, { level: 'warn', @@ -248,12 +248,12 @@ t.test('setup with TTY stdout, non-TTY stderr', t => { process.stderr.isTTY = false process.stdout.isTTY = true - t.equal(setupLog(config({ + setupLog(config({ loglevel: 'warn', color: true, progress: true, heading: 'asdf', - })), true) + })) t.strictSame(settings, { level: 'warn',