From 898b4751e9ea5761ac3be17407c2e7f2078985c6 Mon Sep 17 00:00:00 2001 From: npm team Date: Thu, 31 Mar 2022 22:43:17 +0000 Subject: [PATCH 01/16] deps: upgrade npm to 8.6.0 PR-URL: https://github.com/nodejs/node/pull/42550 Reviewed-By: Rich Trott Reviewed-By: Mestery Reviewed-By: Mohammed Keyvanzadeh Reviewed-By: Tierney Cyren Reviewed-By: Richard Lau Reviewed-By: Colin Ihrig Reviewed-By: Darshan Sen --- deps/npm/docs/content/commands/npm-install.md | 2 +- deps/npm/docs/content/commands/npm-search.md | 2 +- .../docs/content/commands/npm-uninstall.md | 2 +- deps/npm/docs/content/commands/npm-version.md | 11 + deps/npm/docs/content/commands/npm-view.md | 2 +- deps/npm/docs/content/using-npm/config.md | 30 +- deps/npm/docs/content/using-npm/logging.md | 33 +- deps/npm/docs/content/using-npm/scripts.md | 2 +- .../npm/docs/output/commands/npm-install.html | 2 +- deps/npm/docs/output/commands/npm-ls.html | 2 +- deps/npm/docs/output/commands/npm-search.html | 2 +- .../docs/output/commands/npm-uninstall.html | 2 +- .../npm/docs/output/commands/npm-version.html | 11 +- deps/npm/docs/output/commands/npm-view.html | 2 +- deps/npm/docs/output/commands/npm.html | 2 +- deps/npm/docs/output/using-npm/config.html | 27 +- deps/npm/docs/output/using-npm/logging.html | 25 +- deps/npm/docs/output/using-npm/scripts.html | 2 +- deps/npm/lib/base-command.js | 48 +- deps/npm/lib/cli.js | 32 +- deps/npm/lib/commands/bin.js | 12 +- deps/npm/lib/commands/birthday.js | 2 + deps/npm/lib/commands/completion.js | 9 +- deps/npm/lib/commands/doctor.js | 4 - deps/npm/lib/commands/edit.js | 27 +- deps/npm/lib/commands/exec.js | 1 + deps/npm/lib/commands/help.js | 28 +- deps/npm/lib/commands/owner.js | 2 +- deps/npm/lib/commands/run-script.js | 3 +- deps/npm/lib/commands/unpublish.js | 90 +-- deps/npm/lib/commands/version.js | 35 + deps/npm/lib/commands/view.js | 3 + deps/npm/lib/lifecycle-cmd.js | 1 + deps/npm/lib/npm.js | 346 +++++---- deps/npm/lib/utils/cmd-list.js | 172 ++--- deps/npm/lib/utils/config/definitions.js | 30 +- deps/npm/lib/utils/deref-command.js | 31 - deps/npm/lib/utils/error-message.js | 2 +- deps/npm/lib/utils/exit-handler.js | 103 ++- deps/npm/lib/utils/is-windows-bash.js | 3 - deps/npm/lib/utils/is-windows-shell.js | 3 - deps/npm/lib/utils/is-windows.js | 7 +- deps/npm/lib/utils/log-file.js | 74 +- deps/npm/lib/utils/npm-usage.js | 2 +- deps/npm/lib/utils/otplease.js | 10 +- deps/npm/lib/utils/path.js | 4 - deps/npm/lib/utils/replace-info.js | 46 +- deps/npm/lib/utils/split-package-names.js | 25 - deps/npm/lib/utils/timers.js | 45 +- deps/npm/lib/utils/unsupported.js | 39 - deps/npm/lib/utils/update-notifier.js | 2 +- deps/npm/lib/utils/usage.js | 32 - deps/npm/lib/utils/with-chown-sync.js | 13 - deps/npm/man/man1/npm-install.1 | 2 +- deps/npm/man/man1/npm-ls.1 | 2 +- deps/npm/man/man1/npm-search.1 | 2 +- deps/npm/man/man1/npm-uninstall.1 | 2 +- deps/npm/man/man1/npm-version.1 | 11 + deps/npm/man/man1/npm-view.1 | 2 +- deps/npm/man/man1/npm.1 | 2 +- deps/npm/man/man7/config.7 | 30 +- deps/npm/man/man7/logging.7 | 38 +- deps/npm/man/man7/scripts.7 | 2 +- .../arborist/lib/arborist/build-ideal-tree.js | 24 +- .../arborist/lib/arborist/load-virtual.js | 5 +- .../@npmcli/arborist/lib/arborist/reify.js | 2 +- .../@npmcli/arborist/lib/tracker.js | 10 +- .../@npmcli/arborist/package.json | 26 +- .../@npmcli/fs/lib/common/owner-sync.js | 92 +++ .../node_modules/@npmcli/fs/lib/copy-file.js | 12 +- deps/npm/node_modules/@npmcli/fs/lib/fs.js | 12 +- deps/npm/node_modules/@npmcli/fs/lib/index.js | 2 + .../@npmcli/fs/lib/mkdir/index.js | 17 +- .../node_modules/@npmcli/fs/lib/mkdtemp.js | 11 +- .../@npmcli/fs/lib/with-owner-sync.js | 21 + .../node_modules/@npmcli/fs/lib/with-owner.js | 21 + .../@npmcli/fs/lib/with-temp-dir.js | 2 +- .../node_modules/@npmcli/fs/lib/write-file.js | 11 +- deps/npm/node_modules/@npmcli/fs/package.json | 29 +- deps/npm/node_modules/builtins/History.md | 39 - deps/npm/node_modules/builtins/Readme.md | 35 +- deps/npm/node_modules/builtins/builtins.json | 35 - deps/npm/node_modules/builtins/index.js | 79 ++ deps/npm/node_modules/builtins/package.json | 18 +- deps/npm/node_modules/builtins/test.js | 5 - deps/npm/node_modules/cacache/package.json | 33 +- deps/npm/node_modules/debug/package.json | 2 +- deps/npm/node_modules/debug/src/common.js | 2 +- deps/npm/node_modules/gauge/lib/index.js | 3 +- deps/npm/node_modules/gauge/package.json | 24 +- .../init-package-json/lib/default-input.js | 34 +- .../lib/init-package-json.js | 54 +- .../init-package-json/package.json | 26 +- .../node_modules/just-diff-apply/index.d.ts | 17 + .../npm/node_modules/just-diff-apply/index.js | 78 +- .../node_modules/just-diff-apply/index.mjs | 25 +- .../just-diff-apply/index.tests.ts | 108 +++ .../node_modules/just-diff-apply/package.json | 3 +- .../node_modules/libnpmaccess/lib/index.js | 2 +- .../node_modules/libnpmaccess/package.json | 22 +- deps/npm/node_modules/libnpmdiff/package.json | 21 +- .../libnpmexec/lib/file-exists.js | 2 +- deps/npm/node_modules/libnpmexec/lib/index.js | 4 +- deps/npm/node_modules/libnpmexec/package.json | 20 +- deps/npm/node_modules/libnpmfund/lib/index.js | 4 +- deps/npm/node_modules/libnpmfund/package.json | 20 +- deps/npm/node_modules/libnpmhook/package.json | 22 +- deps/npm/node_modules/libnpmorg/package.json | 22 +- deps/npm/node_modules/libnpmpack/package.json | 20 +- .../node_modules/libnpmpublish/package.json | 22 +- .../node_modules/libnpmsearch/package.json | 22 +- deps/npm/node_modules/libnpmteam/package.json | 22 +- .../node_modules/libnpmversion/package.json | 20 +- deps/npm/node_modules/lru-cache/index.js | 262 +++++-- deps/npm/node_modules/lru-cache/package.json | 3 +- .../make-fetch-happen/lib/agent.js | 5 + .../make-fetch-happen/lib/cache/index.js | 4 +- .../node_modules/make-fetch-happen/lib/dns.js | 49 ++ .../make-fetch-happen/lib/options.js | 4 + .../make-fetch-happen/package.json | 32 +- .../node_modules/minipass-fetch/lib/body.js | 6 +- .../node_modules/minipass-fetch/lib/index.js | 5 +- .../node_modules/minipass-fetch/package.json | 26 +- .../npm-audit-report/lib/colors.js | 2 +- .../npm-audit-report/lib/exit-code.js | 2 +- .../npm-audit-report/lib/index.js | 12 +- .../npm-audit-report/lib/reporters/detail.js | 22 +- .../npm-audit-report/lib/reporters/install.js | 10 +- .../npm-audit-report/package.json | 27 +- .../node_modules/npm-package-arg/README.md | 86 +++ .../node_modules/npm-package-arg/package.json | 26 +- .../npm-registry-fetch/lib/check-response.js | 15 +- .../npm-registry-fetch/lib/clean-url.js | 24 + .../npm-registry-fetch/lib/index.js | 6 +- .../npm-registry-fetch/lib/silentlog.js | 14 - .../npm-registry-fetch/package.json | 33 +- .../parse-conflict-json/package.json | 29 +- deps/npm/node_modules/proc-log/package.json | 29 +- .../{ => lib}/index.js | 22 +- .../validate-npm-package-name/package.json | 44 +- .../validate-npm-package-name/test/index.js | 109 --- deps/npm/package.json | 58 +- .../test/lib/commands/completion.js.test.cjs | 136 ++-- .../test/lib/commands/config.js.test.cjs | 4 + .../test/lib/commands/unpublish.js.test.cjs | 14 - .../test/lib/commands/version.js.test.cjs | 94 +++ .../test/lib/load-all-commands.js.test.cjs | 163 +--- .../test/lib/utils/cmd-list.js.test.cjs | 517 ++++++++++--- .../lib/utils/config/definitions.js.test.cjs | 30 +- .../lib/utils/config/describe-all.js.test.cjs | 30 +- .../test/lib/utils/error-message.js.test.cjs | 96 +++ .../test/lib/utils/exit-handler.js.test.cjs | 54 +- .../test/lib/utils/log-file.js.test.cjs | 118 +-- .../test/lib/utils/npm-usage.js.test.cjs | 274 ++----- deps/npm/test/coverage-map.js | 27 +- deps/npm/test/fixtures/mock-npm.js | 33 +- deps/npm/test/fixtures/sandbox.js | 2 + deps/npm/test/fixtures/tnock.js | 10 +- deps/npm/test/fixtures/tspawk.js | 16 + deps/npm/test/lib/cli.js | 194 +++-- deps/npm/test/lib/commands/access.js | 16 +- deps/npm/test/lib/commands/bin.js | 86 +-- deps/npm/test/lib/commands/cache.js | 2 +- deps/npm/test/lib/commands/completion.js | 2 +- deps/npm/test/lib/commands/config.js | 12 +- deps/npm/test/lib/commands/diff.js | 1 - deps/npm/test/lib/commands/doctor.js | 14 - deps/npm/test/lib/commands/edit.js | 201 +++-- deps/npm/test/lib/commands/exec.js | 8 +- deps/npm/test/lib/commands/explore.js | 1 - deps/npm/test/lib/commands/help.js | 38 + deps/npm/test/lib/commands/init.js | 1 - deps/npm/test/lib/commands/owner.js | 1 - deps/npm/test/lib/commands/profile.js | 1 - deps/npm/test/lib/commands/restart.js | 7 +- deps/npm/test/lib/commands/run-script.js | 6 +- deps/npm/test/lib/commands/search.js | 1 - deps/npm/test/lib/commands/star.js | 5 +- deps/npm/test/lib/commands/stars.js | 1 - deps/npm/test/lib/commands/start.js | 7 +- deps/npm/test/lib/commands/stop.js | 7 +- deps/npm/test/lib/commands/team.js | 1 - deps/npm/test/lib/commands/test.js | 7 +- deps/npm/test/lib/commands/unpublish.js | 720 +++++++++--------- deps/npm/test/lib/commands/update.js | 1 - deps/npm/test/lib/commands/version.js | 117 ++- deps/npm/test/lib/load-all-commands.js | 7 +- deps/npm/test/lib/load-all.js | 31 - deps/npm/test/lib/npm.js | 305 ++++---- deps/npm/test/lib/utils/config/definitions.js | 18 +- deps/npm/test/lib/utils/deref-command.js | 9 - deps/npm/test/lib/utils/exit-handler.js | 83 +- deps/npm/test/lib/utils/is-windows-bash.js | 30 - deps/npm/test/lib/utils/is-windows-shell.js | 8 - deps/npm/test/lib/utils/is-windows.js | 43 +- deps/npm/test/lib/utils/log-file.js | 17 +- deps/npm/test/lib/utils/otplease.js | 22 + deps/npm/test/lib/utils/path.js | 12 - deps/npm/test/lib/utils/replace-info.js | 40 +- .../npm/test/lib/utils/split-package-names.js | 18 - deps/npm/test/lib/utils/timers.js | 32 +- deps/npm/test/lib/utils/unsupported.js | 102 --- deps/npm/test/lib/utils/update-notifier.js | 3 +- 203 files changed, 4389 insertions(+), 3135 deletions(-) delete mode 100644 deps/npm/lib/utils/deref-command.js delete mode 100644 deps/npm/lib/utils/is-windows-bash.js delete mode 100644 deps/npm/lib/utils/is-windows-shell.js delete mode 100644 deps/npm/lib/utils/path.js delete mode 100644 deps/npm/lib/utils/split-package-names.js delete mode 100644 deps/npm/lib/utils/unsupported.js delete mode 100644 deps/npm/lib/utils/usage.js delete mode 100644 deps/npm/lib/utils/with-chown-sync.js create mode 100644 deps/npm/node_modules/@npmcli/fs/lib/common/owner-sync.js create mode 100644 deps/npm/node_modules/@npmcli/fs/lib/with-owner-sync.js create mode 100644 deps/npm/node_modules/@npmcli/fs/lib/with-owner.js delete mode 100644 deps/npm/node_modules/builtins/History.md delete mode 100644 deps/npm/node_modules/builtins/builtins.json create mode 100644 deps/npm/node_modules/builtins/index.js delete mode 100644 deps/npm/node_modules/builtins/test.js create mode 100644 deps/npm/node_modules/just-diff-apply/index.d.ts create mode 100644 deps/npm/node_modules/just-diff-apply/index.tests.ts create mode 100644 deps/npm/node_modules/make-fetch-happen/lib/dns.js create mode 100644 deps/npm/node_modules/npm-package-arg/README.md create mode 100644 deps/npm/node_modules/npm-registry-fetch/lib/clean-url.js delete mode 100644 deps/npm/node_modules/npm-registry-fetch/lib/silentlog.js rename deps/npm/node_modules/validate-npm-package-name/{ => lib}/index.js (83%) delete mode 100644 deps/npm/node_modules/validate-npm-package-name/test/index.js delete mode 100644 deps/npm/tap-snapshots/test/lib/commands/unpublish.js.test.cjs create mode 100644 deps/npm/tap-snapshots/test/lib/commands/version.js.test.cjs create mode 100644 deps/npm/test/fixtures/tspawk.js delete mode 100644 deps/npm/test/lib/load-all.js delete mode 100644 deps/npm/test/lib/utils/deref-command.js delete mode 100644 deps/npm/test/lib/utils/is-windows-bash.js delete mode 100644 deps/npm/test/lib/utils/is-windows-shell.js delete mode 100644 deps/npm/test/lib/utils/path.js delete mode 100644 deps/npm/test/lib/utils/split-package-names.js delete mode 100644 deps/npm/test/lib/utils/unsupported.js diff --git a/deps/npm/docs/content/commands/npm-install.md b/deps/npm/docs/content/commands/npm-install.md index 2ffd3e3e9fff14..c85a592ededaec 100644 --- a/deps/npm/docs/content/commands/npm-install.md +++ b/deps/npm/docs/content/commands/npm-install.md @@ -22,7 +22,7 @@ npm install npm install npm install / -aliases: i, in, ins, inst, insta, instal, isnt, isnta, isntal, isntall, add +aliases: add, i, in, ins, inst, insta, instal, isnt, isnta, isntal, isntall ``` diff --git a/deps/npm/docs/content/commands/npm-search.md b/deps/npm/docs/content/commands/npm-search.md index db6a12bafabf13..340dea9684d005 100644 --- a/deps/npm/docs/content/commands/npm-search.md +++ b/deps/npm/docs/content/commands/npm-search.md @@ -13,7 +13,7 @@ description: Search for packages ```bash npm search [search terms ...] -aliases: s, se, find +aliases: find, s, se ``` diff --git a/deps/npm/docs/content/commands/npm-uninstall.md b/deps/npm/docs/content/commands/npm-uninstall.md index 8132bf6bc40b6e..9316c686d4095c 100644 --- a/deps/npm/docs/content/commands/npm-uninstall.md +++ b/deps/npm/docs/content/commands/npm-uninstall.md @@ -13,7 +13,7 @@ description: Remove a package ```bash npm uninstall [<@scope>/]... -aliases: un, unlink, remove, rm, r +aliases: unlink, remove, rm, r, un ``` diff --git a/deps/npm/docs/content/commands/npm-version.md b/deps/npm/docs/content/commands/npm-version.md index 86e2ce90e9bea7..713e5ae410dfc4 100644 --- a/deps/npm/docs/content/commands/npm-version.md +++ b/deps/npm/docs/content/commands/npm-version.md @@ -144,6 +144,17 @@ This value is not exported to the environment for child processes. +#### `workspaces-update` + +* Default: true +* Type: Boolean + +If set to true, the npm cli will run an update after operations that may +possibly change the workspaces installed to the `node_modules` folder. + + + + #### `include-workspace-root` * Default: false diff --git a/deps/npm/docs/content/commands/npm-view.md b/deps/npm/docs/content/commands/npm-view.md index 53ca408a01224f..b50b4bfb56c5d6 100644 --- a/deps/npm/docs/content/commands/npm-view.md +++ b/deps/npm/docs/content/commands/npm-view.md @@ -13,7 +13,7 @@ description: View registry info ```bash npm view [<@scope>/][@] [[.subfield]...] -aliases: v, info, show +aliases: info, show, v ``` diff --git a/deps/npm/docs/content/using-npm/config.md b/deps/npm/docs/content/using-npm/config.md index df259715f08f2e..39870922c0253c 100644 --- a/deps/npm/docs/content/using-npm/config.md +++ b/deps/npm/docs/content/using-npm/config.md @@ -1027,6 +1027,17 @@ See also the `foreground-scripts` config. +#### `logs-dir` + +* Default: A directory named `_logs` inside the cache +* Type: null or Path + +The location of npm's log directory. See [`npm logging`](/using-npm/logging) +for more information. + + + + #### `logs-max` * Default: 10 @@ -1034,6 +1045,8 @@ See also the `foreground-scripts` config. The maximum number of log files to store. +If set to 0, no log files will be written for the current run. + @@ -1628,9 +1641,9 @@ particular, use care when overriding this setting for public packages. * Default: false * Type: Boolean -If true, writes an `npm-debug` log to `_logs` and timing information to -`_timing.json`, both in your cache, even if the command completes -successfully. `_timing.json` is a newline delimited list of JSON objects. +If true, writes a debug log to `logs-dir` and timing information to +`_timing.json` in the cache, even if the command completes successfully. +`_timing.json` is a newline delimited list of JSON objects. You can quickly view it with this [json](https://npm.im/json) command line: `npm exec -- json -g < ~/.npm/_timing.json`. @@ -1823,6 +1836,17 @@ This value is not exported to the environment for child processes. +#### `workspaces-update` + +* Default: true +* Type: Boolean + +If set to true, the npm cli will run an update after operations that may +possibly change the workspaces installed to the `node_modules` folder. + + + + #### `yes` * Default: null diff --git a/deps/npm/docs/content/using-npm/logging.md b/deps/npm/docs/content/using-npm/logging.md index b7c5e899778997..eb83b167e698b1 100644 --- a/deps/npm/docs/content/using-npm/logging.md +++ b/deps/npm/docs/content/using-npm/logging.md @@ -1,13 +1,24 @@ --- title: Logging section: 7 -description: Why, What & How we Log +description: Why, What & How We Log --- ### Description The `npm` CLI has various mechanisms for showing different levels of information back to end-users for certain commands, configurations & environments. +### Setting Log File Location + +All logs are written to a debug log, with the path to that file printed if the execution of a command fails. + +The default location of the logs directory is a directory named `_logs` inside the npm cache. This can be changed +with the `logs-dir` config option. + +Log files will be removed from the `logs-dir` when the number of log files exceeds `logs-max`, with the oldest logs being deleted first. + +To turn off logs completely set `--logs-max=0`. + ### Setting Log Levels #### `loglevel` @@ -28,8 +39,6 @@ The default value of `loglevel` is `"notice"` but there are several levels/types All logs pertaining to a level proceeding the current setting will be shown. -All logs are written to a debug log, with the path to that file printed if the execution of a command fails. - ##### Aliases The log levels listed above have various corresponding aliases, including: @@ -47,6 +56,15 @@ The log levels listed above have various corresponding aliases, including: The `npm` CLI began hiding the output of lifecycle scripts for `npm install` as of `v7`. Notably, this means you will not see logs/output from packages that may be using "install scripts" to display information back to you or from your own project's scripts defined in `package.json`. If you'd like to change this behavior & log this output you can set `foreground-scripts` to `true`. +### Timing Information + +The `--timing` config can be set which does two things: + +1. Always shows the full path to the debug log regardless of command exit status +1. Write timing information to a timing file in the cache or `logs-dir` + +This file is a newline delimited list of JSON objects that can be inspected to see timing data for each task in a `npm` CLI run. + ### Registry Response Headers #### `npm-notice` @@ -55,6 +73,15 @@ The `npm` CLI reads from & logs any `npm-notice` headers that are returned from This header is not cached, and will not be logged if the request is served from the cache. +### Logs and Sensitive Information + +The `npm` CLI makes a best effort to redact the following from terminal output and log files: + +- Passwords inside basic auth URLs +- npm tokens + +However, this behavior should not be relied on to keep all possible sensitive information redacted. If you are concerned about secrets in your log file or terminal output, you can use `--loglevel=silent` and `--logs-max=0` to ensure no logs are written to your terminal or filesystem. + ### See also * [config](/using-npm/config) diff --git a/deps/npm/docs/content/using-npm/scripts.md b/deps/npm/docs/content/using-npm/scripts.md index f79ddc65e9be86..b37ca593e4ce63 100644 --- a/deps/npm/docs/content/using-npm/scripts.md +++ b/deps/npm/docs/content/using-npm/scripts.md @@ -339,7 +339,7 @@ file. * Don't prefix your script commands with "sudo". If root permissions are required for some reason, then it'll fail with that error, and the user will sudo the npm command in question. -* Don't use `install`. Use a `.gyp` file for compilation, and `prepublish` +* Don't use `install`. Use a `.gyp` file for compilation, and `prepare` for anything else. You should almost never have to explicitly set a preinstall or install script. If you are doing this, please consider if there is another option. The only valid use of `install` or `preinstall` diff --git a/deps/npm/docs/output/commands/npm-install.html b/deps/npm/docs/output/commands/npm-install.html index 755dee22402fdd..3fcc2ddf9cb821 100644 --- a/deps/npm/docs/output/commands/npm-install.html +++ b/deps/npm/docs/output/commands/npm-install.html @@ -160,7 +160,7 @@

Table of contents

npm install <git:// url> npm install <github username>/<github project> -aliases: i, in, ins, inst, insta, instal, isnt, isnta, isntal, isntall, add +aliases: add, i, in, ins, inst, insta, instal, isnt, isnta, isntal, isntall diff --git a/deps/npm/docs/output/commands/npm-ls.html b/deps/npm/docs/output/commands/npm-ls.html index 19bf6080bf1a86..798b6f0f2ce357 100644 --- a/deps/npm/docs/output/commands/npm-ls.html +++ b/deps/npm/docs/output/commands/npm-ls.html @@ -166,7 +166,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@8.5.5 /path/to/npm
+
npm@8.6.0 /path/to/npm
 └─┬ init-package-json@0.0.4
   └── promzard@0.1.5
 
diff --git a/deps/npm/docs/output/commands/npm-search.html b/deps/npm/docs/output/commands/npm-search.html index 2e224afec52d91..4976e2d8a6371c 100644 --- a/deps/npm/docs/output/commands/npm-search.html +++ b/deps/npm/docs/output/commands/npm-search.html @@ -151,7 +151,7 @@

Table of contents

npm search [search terms ...]
 
-aliases: s, se, find
+aliases: find, s, se
 
diff --git a/deps/npm/docs/output/commands/npm-uninstall.html b/deps/npm/docs/output/commands/npm-uninstall.html index f7f7760da74abd..d8d6f7b5e6cc34 100644 --- a/deps/npm/docs/output/commands/npm-uninstall.html +++ b/deps/npm/docs/output/commands/npm-uninstall.html @@ -151,7 +151,7 @@

Table of contents

npm uninstall [<@scope>/]<pkg>...
 
-aliases: un, unlink, remove, rm, r
+aliases: unlink, remove, rm, r, un
 
diff --git a/deps/npm/docs/output/commands/npm-version.html b/deps/npm/docs/output/commands/npm-version.html index a4e8ff6dbdc0b4..2cb99f3bc07a66 100644 --- a/deps/npm/docs/output/commands/npm-version.html +++ b/deps/npm/docs/output/commands/npm-version.html @@ -142,7 +142,7 @@

npm-version

Table of contents

- +

Synopsis

@@ -258,6 +258,15 @@

workspaces

This value is not exported to the environment for child processes.

+

workspaces-update

+
    +
  • Default: true
  • +
  • Type: Boolean
  • +
+

If set to true, the npm cli will run an update after operations that may +possibly change the workspaces installed to the node_modules folder.

+ +

include-workspace-root

-

If true, writes an npm-debug log to _logs and timing information to -_timing.json, both in your cache, even if the command completes -successfully. _timing.json is a newline delimited list of JSON objects.

+

If true, writes a debug log to logs-dir and timing information to +_timing.json in the cache, even if the command completes successfully. +_timing.json is a newline delimited list of JSON objects.

You can quickly view it with this json command line: npm exec -- json -g < ~/.npm/_timing.json.

@@ -1605,6 +1615,15 @@

workspaces

This value is not exported to the environment for child processes.

+

workspaces-update

+
    +
  • Default: true
  • +
  • Type: Boolean
  • +
+

If set to true, the npm cli will run an update after operations that may +possibly change the workspaces installed to the node_modules folder.

+ +

yes

  • Default: null
  • diff --git a/deps/npm/docs/output/using-npm/logging.html b/deps/npm/docs/output/using-npm/logging.html index d4b9760967a018..078ebde7b8501b 100644 --- a/deps/npm/docs/output/using-npm/logging.html +++ b/deps/npm/docs/output/using-npm/logging.html @@ -137,16 +137,22 @@

    Logging

    -Why, What & How we Log +Why, What & How We Log

    Table of contents

    - +

    Description

    The npm CLI has various mechanisms for showing different levels of information back to end-users for certain commands, configurations & environments.

    +

    Setting Log File Location

    +

    All logs are written to a debug log, with the path to that file printed if the execution of a command fails.

    +

    The default location of the logs directory is a directory named _logs inside the npm cache. This can be changed +with the logs-dir config option.

    +

    Log files will be removed from the logs-dir when the number of log files exceeds logs-max, with the oldest logs being deleted first.

    +

    To turn off logs completely set --logs-max=0.

    Setting Log Levels

    loglevel

    loglevel is a global argument/config that can be set to determine the type of information to be displayed.

    @@ -163,7 +169,6 @@

    loglevel

  • "silly"

All logs pertaining to a level proceeding the current setting will be shown.

-

All logs are written to a debug log, with the path to that file printed if the execution of a command fails.

Aliases

The log levels listed above have various corresponding aliases, including:

    @@ -178,10 +183,24 @@
    Aliases

foreground-scripts

The npm CLI began hiding the output of lifecycle scripts for npm install as of v7. Notably, this means you will not see logs/output from packages that may be using "install scripts" to display information back to you or from your own project's scripts defined in package.json. If you'd like to change this behavior & log this output you can set foreground-scripts to true.

+

Timing Information

+

The --timing config can be set which does two things:

+
    +
  1. Always shows the full path to the debug log regardless of command exit status
  2. +
  3. Write timing information to a timing file in the cache or logs-dir
  4. +
+

This file is a newline delimited list of JSON objects that can be inspected to see timing data for each task in a npm CLI run.

Registry Response Headers

npm-notice

The npm CLI reads from & logs any npm-notice headers that are returned from the configured registry. This mechanism can be used by third-party registries to provide useful information when network-dependent requests occur.

This header is not cached, and will not be logged if the request is served from the cache.

+

Logs and Sensitive Information

+

The npm CLI makes a best effort to redact the following from terminal output and log files:

+
    +
  • Passwords inside basic auth URLs
  • +
  • npm tokens
  • +
+

However, this behavior should not be relied on to keep all possible sensitive information redacted. If you are concerned about secrets in your log file or terminal output, you can use --loglevel=silent and --logs-max=0 to ensure no logs are written to your terminal or filesystem.

See also

  • config
  • diff --git a/deps/npm/docs/output/using-npm/scripts.html b/deps/npm/docs/output/using-npm/scripts.html index a1b691f3768dbd..e13d0c488ee8a9 100644 --- a/deps/npm/docs/output/using-npm/scripts.html +++ b/deps/npm/docs/output/using-npm/scripts.html @@ -442,7 +442,7 @@

    Best Practices

  • Don't prefix your script commands with "sudo". If root permissions are required for some reason, then it'll fail with that error, and the user will sudo the npm command in question.
  • -
  • Don't use install. Use a .gyp file for compilation, and prepublish +
  • Don't use install. Use a .gyp file for compilation, and prepare for anything else. You should almost never have to explicitly set a preinstall or install script. If you are doing this, please consider if there is another option. The only valid use of install or preinstall diff --git a/deps/npm/lib/base-command.js b/deps/npm/lib/base-command.js index b6e3d6d2318606..3ab800adbfd98d 100644 --- a/deps/npm/lib/base-command.js +++ b/deps/npm/lib/base-command.js @@ -2,10 +2,11 @@ const { relative } = require('path') -const usageUtil = require('./utils/usage.js') const ConfigDefinitions = require('./utils/config/definitions.js') const getWorkspaces = require('./workspaces/get-workspaces.js') +const cmdAliases = require('./utils/cmd-list').aliases + class BaseCommand { constructor (npm) { this.wrapWidth = 80 @@ -25,28 +26,43 @@ class BaseCommand { } get usage () { - let usage = `npm ${this.constructor.name}\n\n` - if (this.constructor.description) { - usage = `${usage}${this.constructor.description}\n\n` - } + const usage = [ + `${this.constructor.description}`, + '', + 'Usage:', + ] - usage = `${usage}Usage:\n` if (!this.constructor.usage) { - usage = `${usage}npm ${this.constructor.name}` + usage.push(`npm ${this.constructor.name}`) } else { - usage = `${usage}${this.constructor.usage - .map(u => `npm ${this.constructor.name} ${u}`) - .join('\n')}` + usage.push(...this.constructor.usage.map(u => `npm ${this.constructor.name} ${u}`)) } if (this.constructor.params) { - usage = `${usage}\n\nOptions:\n${this.wrappedParams}` + usage.push('') + usage.push('Options:') + usage.push(this.wrappedParams) + } + + const aliases = Object.keys(cmdAliases).reduce((p, c) => { + if (cmdAliases[c] === this.constructor.name) { + p.push(c) + } + return p + }, []) + + if (aliases.length === 1) { + usage.push('') + usage.push(`alias: ${aliases.join(', ')}`) + } else if (aliases.length > 1) { + usage.push('') + usage.push(`aliases: ${aliases.join(', ')}`) } - // Mostly this just appends aliases, this could be more clear - usage = usageUtil(this.constructor.name, usage) - usage = `${usage}\n\nRun "npm help ${this.constructor.name}" for more info` - return usage + usage.push('') + usage.push(`Run "npm help ${this.constructor.name}" for more info`) + + return usage.join('\n') } get wrappedParams () { @@ -69,7 +85,7 @@ class BaseCommand { if (prefix) { prefix += '\n\n' } - return Object.assign(new Error(`\nUsage: ${prefix}${this.usage}`), { + return Object.assign(new Error(`\n${prefix}${this.usage}`), { code: 'EUSAGE', }) } diff --git a/deps/npm/lib/cli.js b/deps/npm/lib/cli.js index 3d0c32d4beda30..7b87b94452eade 100644 --- a/deps/npm/lib/cli.js +++ b/deps/npm/lib/cli.js @@ -11,9 +11,25 @@ module.exports = async process => { // so now both broken and unsupported use console, but only broken // will process.exit. It is important to now perform *both* of these // checks as early as possible so the user gets the error message. - const { checkForBrokenNode, checkForUnsupportedNode } = require('./utils/unsupported.js') - checkForBrokenNode() - checkForUnsupportedNode() + const semver = require('semver') + const supported = require('../package.json').engines.node + const knownBroken = '<12.5.0' + + const nodejsVersion = process.version.replace(/-.*$/, '') + /* eslint-disable no-console */ + if (semver.satisfies(nodejsVersion, knownBroken)) { + console.error('ERROR: npm is known not to run on Node.js ' + process.version) + console.error("You'll need to upgrade to a newer Node.js version in order to use this") + console.error('version of npm. You can find the latest version at https://nodejs.org/') + process.exit(1) + } + if (!semver.satisfies(nodejsVersion, supported)) { + console.error('npm does not support Node.js ' + process.version) + console.error('You should probably upgrade to a newer version of node as we') + console.error("can't make any promises that npm will work with this version.") + console.error('You can find the latest version at https://nodejs.org/') + } + /* eslint-enable no-console */ const exitHandler = require('./utils/exit-handler.js') process.on('uncaughtException', exitHandler) @@ -30,14 +46,12 @@ module.exports = async process => { } const log = require('./utils/log-shim.js') - const replaceInfo = require('./utils/replace-info.js') - log.verbose('cli', replaceInfo(process.argv)) - + // only log node and npm paths in argv initially since argv can contain + // sensitive info. a cleaned version will be logged later + log.verbose('cli', process.argv.slice(0, 2).join(' ')) log.info('using', 'npm@%s', npm.version) log.info('using', 'node@%s', process.version) - const updateNotifier = require('./utils/update-notifier.js') - let cmd // now actually fire up npm and run the command. // this is how to use npm programmatically: @@ -54,8 +68,6 @@ module.exports = async process => { npm.config.set('usage', false, 'cli') } - updateNotifier(npm) - cmd = npm.argv.shift() if (!cmd) { npm.output(await npm.usage) diff --git a/deps/npm/lib/commands/bin.js b/deps/npm/lib/commands/bin.js index 77028f06dd49a8..4200d5b8ca556a 100644 --- a/deps/npm/lib/commands/bin.js +++ b/deps/npm/lib/commands/bin.js @@ -1,5 +1,10 @@ -const envPath = require('../utils/path.js') +const log = require('../utils/log-shim.js') const BaseCommand = require('../base-command.js') +// TODO this may not be needed at all. Ignoring because our tests normalize +// process.env.path already +/* istanbul ignore next */ +const path = process.env.path || process.env.Path || process.env.PATH +const { delimiter } = require('path') class Bin extends BaseCommand { static description = 'Display npm bin folder' @@ -10,9 +15,8 @@ class Bin extends BaseCommand { async exec (args) { const b = this.npm.bin this.npm.output(b) - if (this.npm.config.get('global') && !envPath.includes(b)) { - // XXX: does this need to be console? - console.error('(not in PATH env variable)') + if (this.npm.config.get('global') && !path.split(delimiter).includes(b)) { + log.error('bin', '(not in PATH env variable)') } } } diff --git a/deps/npm/lib/commands/birthday.js b/deps/npm/lib/commands/birthday.js index e889b39f253779..c7b5b31c54a62a 100644 --- a/deps/npm/lib/commands/birthday.js +++ b/deps/npm/lib/commands/birthday.js @@ -2,7 +2,9 @@ const BaseCommand = require('../base-command.js') class Birthday extends BaseCommand { static name = 'birthday' + static description = 'Birthday' static ignoreImplicitWorkspace = true + static isShellout = true async exec () { this.npm.config.set('yes', true) diff --git a/deps/npm/lib/commands/completion.js b/deps/npm/lib/commands/completion.js index 0317753a15aaff..d0c68af6cebfc8 100644 --- a/deps/npm/lib/commands/completion.js +++ b/deps/npm/lib/commands/completion.js @@ -30,7 +30,6 @@ // const { definitions, shorthands } = require('../utils/config/index.js') -const deref = require('../utils/deref-command.js') const { aliases, cmdList, plumbing } = require('../utils/cmd-list.js') const aliasNames = Object.keys(aliases) const fullList = cmdList.concat(aliasNames).filter(c => !plumbing.includes(c)) @@ -38,7 +37,7 @@ const nopt = require('nopt') const configNames = Object.keys(definitions) const shorthandNames = Object.keys(shorthands) const allConfs = configNames.concat(shorthandNames) -const isWindowsShell = require('../utils/is-windows-shell.js') +const { isWindowsShell } = require('../utils/is-windows.js') const fileExists = require('../utils/file-exists.js') const { promisify } = require('util') @@ -152,7 +151,7 @@ class Completion extends BaseCommand { // check if there's a command already. const cmd = parsed.argv.remain[1] if (!cmd) { - return this.wrap(opts, cmdCompl(opts)) + return this.wrap(opts, cmdCompl(opts, this.npm)) } Object.keys(parsed).forEach(k => this.npm.config.set(k, parsed[k])) @@ -269,13 +268,13 @@ const isFlag = word => { // complete against the npm commands // if they all resolve to the same thing, just return the thing it already is -const cmdCompl = opts => { +const cmdCompl = (opts, npm) => { const matches = fullList.filter(c => c.startsWith(opts.partialWord)) if (!matches.length) { return matches } - const derefs = new Set([...matches.map(c => deref(c))]) + const derefs = new Set([...matches.map(c => npm.deref(c))]) if (derefs.size === 1) { return [...derefs] } diff --git a/deps/npm/lib/commands/doctor.js b/deps/npm/lib/commands/doctor.js index 630150c0886fed..22a25477e22e03 100644 --- a/deps/npm/lib/commands/doctor.js +++ b/deps/npm/lib/commands/doctor.js @@ -131,10 +131,6 @@ class Doctor extends BaseCommand { if (!this.npm.silent) { this.npm.output(table(outTable, tableOpts)) - if (!allOk) { - // TODO is this really needed? - console.error('') - } } if (!allOk) { throw new Error('Some problems found. See above for recommendations.') diff --git a/deps/npm/lib/commands/edit.js b/deps/npm/lib/commands/edit.js index ce74ff79b2b7ea..0256f4f3a6f010 100644 --- a/deps/npm/lib/commands/edit.js +++ b/deps/npm/lib/commands/edit.js @@ -3,11 +3,32 @@ const { resolve } = require('path') const fs = require('graceful-fs') -const { spawn } = require('child_process') -const splitPackageNames = require('../utils/split-package-names.js') +const cp = require('child_process') const completion = require('../utils/completion/installed-shallow.js') const BaseCommand = require('../base-command.js') +const splitPackageNames = (path) => { + return path.split('/') + // combine scoped parts + .reduce((parts, part) => { + if (parts.length === 0) { + return [part] + } + + const lastPart = parts[parts.length - 1] + // check if previous part is the first part of a scoped package + if (lastPart[0] === '@' && !lastPart.includes('/')) { + parts[parts.length - 1] += '/' + part + } else { + parts.push(part) + } + + return parts + }, []) + .join('/node_modules/') + .replace(/(\/node_modules)+/, '/node_modules') +} + class Edit extends BaseCommand { static description = 'Edit an installed package' static name = 'edit' @@ -36,7 +57,7 @@ class Edit extends BaseCommand { return reject(err) } const [bin, ...args] = this.npm.config.get('editor').split(/\s+/) - const editor = spawn(bin, [...args, dir], { stdio: 'inherit' }) + const editor = cp.spawn(bin, [...args, dir], { stdio: 'inherit' }) editor.on('exit', (code) => { if (code) { return reject(new Error(`editor process exited with code: ${code}`)) diff --git a/deps/npm/lib/commands/exec.js b/deps/npm/lib/commands/exec.js index 6b402c856ab1e9..5e6a94296d2872 100644 --- a/deps/npm/lib/commands/exec.js +++ b/deps/npm/lib/commands/exec.js @@ -46,6 +46,7 @@ class Exec extends BaseCommand { ] static ignoreImplicitWorkspace = false + static isShellout = true async exec (_args, { locationMsg, path, runPath } = {}) { if (!path) { diff --git a/deps/npm/lib/commands/help.js b/deps/npm/lib/commands/help.js index 40f5ad9b300926..d31b3ca697651d 100644 --- a/deps/npm/lib/commands/help.js +++ b/deps/npm/lib/commands/help.js @@ -11,6 +11,8 @@ const BaseCommand = require('../base-command.js') // We don't currently compress our man pages but if we ever did this would // seemlessly continue supporting it const manNumberRegex = /\.(\d+)(\.[^/\\]*)?$/ +// Searches for the "npm-" prefix in page names, to prefer those. +const manNpmPrefixRegex = /\/npm-/ class Help extends BaseCommand { static description = 'Get help on npm' @@ -61,13 +63,27 @@ class Help extends BaseCommand { const f = `${manroot}/${manSearch}/?(npm-)${section}.[0-9]*` let mans = await glob(f) mans = mans.sort((a, b) => { - // Because of the glob we know the manNumberRegex will pass - const aManNumber = a.match(manNumberRegex)[1] - const bManNumber = b.match(manNumberRegex)[1] + // Prefer the page with an npm prefix, if there's only one. + const aHasPrefix = manNpmPrefixRegex.test(a) + const bHasPrefix = manNpmPrefixRegex.test(b) + if (aHasPrefix !== bHasPrefix) { + return aHasPrefix ? -1 : 1 + } - // man number sort first so that 1 aka commands are preferred - if (aManNumber !== bManNumber) { - return aManNumber - bManNumber + // Because the glob is (subtly) different from manNumberRegex, + // we can't rely on it passing. + const aManNumberMatch = a.match(manNumberRegex) + const bManNumberMatch = b.match(manNumberRegex) + if (aManNumberMatch) { + if (!bManNumberMatch) { + return -1 + } + // man number sort first so that 1 aka commands are preferred + if (aManNumberMatch[1] !== bManNumberMatch[1]) { + return aManNumberMatch[1] - bManNumberMatch[1] + } + } else if (bManNumberMatch) { + return 1 } return localeCompare(a, b) diff --git a/deps/npm/lib/commands/owner.js b/deps/npm/lib/commands/owner.js index e74efac1baf6a2..07f71c5974768f 100644 --- a/deps/npm/lib/commands/owner.js +++ b/deps/npm/lib/commands/owner.js @@ -125,7 +125,7 @@ class Owner extends BaseCommand { throw err } - if (user && (!u || !u.name || u.error)) { + if (!u || !u.name || u.error) { throw Object.assign( new Error( "Couldn't get user data for " + user + ': ' + JSON.stringify(u) diff --git a/deps/npm/lib/commands/run-script.js b/deps/npm/lib/commands/run-script.js index 74757e984aeedd..a1591c7900b446 100644 --- a/deps/npm/lib/commands/run-script.js +++ b/deps/npm/lib/commands/run-script.js @@ -5,7 +5,7 @@ const { isServerPackage } = runScript const rpj = require('read-package-json-fast') const log = require('../utils/log-shim.js') const didYouMean = require('../utils/did-you-mean.js') -const isWindowsShell = require('../utils/is-windows-shell.js') +const { isWindowsShell } = require('../utils/is-windows.js') const cmdList = [ 'publish', @@ -41,6 +41,7 @@ class RunScript extends BaseCommand { static name = 'run-script' static usage = [' [-- ]'] static ignoreImplicitWorkspace = false + static isShellout = true async completion (opts) { const argv = opts.conf.argv.remain diff --git a/deps/npm/lib/commands/unpublish.js b/deps/npm/lib/commands/unpublish.js index d8de9edfa6ba75..f27be2e41c1078 100644 --- a/deps/npm/lib/commands/unpublish.js +++ b/deps/npm/lib/commands/unpublish.js @@ -1,13 +1,15 @@ -const path = require('path') -const util = require('util') -const npa = require('npm-package-arg') const libaccess = require('libnpmaccess') -const npmFetch = require('npm-registry-fetch') const libunpub = require('libnpmpublish').unpublish +const npa = require('npm-package-arg') +const npmFetch = require('npm-registry-fetch') +const path = require('path') +const util = require('util') const readJson = util.promisify(require('read-package-json')) + +const flatten = require('../utils/config/flatten.js') +const getIdentity = require('../utils/get-identity.js') const log = require('../utils/log-shim') const otplease = require('../utils/otplease.js') -const getIdentity = require('../utils/get-identity.js') const LAST_REMAINING_VERSION_ERROR = 'Refusing to delete the last version of the package. ' + 'It will block from republishing a new version for 24 hours.\n' + @@ -22,7 +24,8 @@ class Unpublish extends BaseCommand { static ignoreImplicitWorkspace = false async getKeysOfVersions (name, opts) { - const json = await npmFetch.json(npa(name).escapedName, opts) + const pkgUri = npa(name).escapedName + const json = await npmFetch.json(`${pkgUri}?write=true`, opts) return Object.keys(json.versions) } @@ -67,12 +70,10 @@ class Unpublish extends BaseCommand { throw this.usageError() } - const spec = args.length && npa(args[0]) + let spec = args.length && npa(args[0]) const force = this.npm.config.get('force') const { silent } = this.npm const dryRun = this.npm.config.get('dry-run') - let pkgName - let pkgVersion log.silly('unpublish', 'args[0]', args[0]) log.silly('unpublish', 'spec', spec) @@ -85,53 +86,52 @@ class Unpublish extends BaseCommand { } const opts = { ...this.npm.flatOptions } - if (!spec || path.resolve(spec.name) === this.npm.localPrefix) { - // if there's a package.json in the current folder, then - // read the package name and version out of that. + + let pkgName + let pkgVersion + let manifest + let manifestErr + try { const pkgJson = path.join(this.npm.localPrefix, 'package.json') - let manifest - try { - manifest = await readJson(pkgJson) - } catch (err) { - if (err && err.code !== 'ENOENT' && err.code !== 'ENOTDIR') { - throw err - } else { + manifest = await readJson(pkgJson) + } catch (err) { + manifestErr = err + } + if (spec) { + // If cwd has a package.json with a name that matches the package being + // unpublished, load up the publishConfig + if (manifest && manifest.name === spec.name && manifest.publishConfig) { + flatten(manifest.publishConfig, opts) + } + const versions = await this.getKeysOfVersions(spec.name, opts) + if (versions.length === 1 && !force) { + throw this.usageError(LAST_REMAINING_VERSION_ERROR) + } + pkgName = spec.name + pkgVersion = spec.type === 'version' ? `@${spec.rawSpec}` : '' + } else { + if (manifestErr) { + if (manifestErr.code === 'ENOENT' || manifestErr.code === 'ENOTDIR') { throw this.usageError() + } else { + throw manifestErr } } log.verbose('unpublish', manifest) - const { name, version, publishConfig } = manifest - const pkgJsonSpec = npa.resolve(name, version) - const optsWithPub = { ...opts, publishConfig } - - const versions = await this.getKeysOfVersions(name, optsWithPub) - if (versions.length === 1 && !force) { - throw this.usageError( - LAST_REMAINING_VERSION_ERROR - ) + spec = npa.resolve(manifest.name, manifest.version) + if (manifest.publishConfig) { + flatten(manifest.publishConfig, opts) } - if (!dryRun) { - await otplease(opts, opts => libunpub(pkgJsonSpec, optsWithPub)) - } - pkgName = name - pkgVersion = version ? `@${version}` : '' - } else { - const versions = await this.getKeysOfVersions(spec.name, opts) - if (versions.length === 1 && !force) { - throw this.usageError( - LAST_REMAINING_VERSION_ERROR - ) - } - if (!dryRun) { - await otplease(opts, opts => libunpub(spec, opts)) - } - pkgName = spec.name - pkgVersion = spec.type === 'version' ? `@${spec.rawSpec}` : '' + pkgName = manifest.name + pkgVersion = manifest.version ? `@${manifest.version}` : '' } + if (!dryRun) { + await otplease(opts, opts => libunpub(spec, opts)) + } if (!silent) { this.npm.output(`- ${pkgName}${pkgVersion}`) } diff --git a/deps/npm/lib/commands/version.js b/deps/npm/lib/commands/version.js index f49a309a74ff6b..ed506f663e89fd 100644 --- a/deps/npm/lib/commands/version.js +++ b/deps/npm/lib/commands/version.js @@ -3,6 +3,9 @@ const { resolve } = require('path') const { promisify } = require('util') const readFile = promisify(require('fs').readFile) +const Arborist = require('@npmcli/arborist') +const reifyFinish = require('../utils/reify-finish.js') + const BaseCommand = require('../base-command.js') class Version extends BaseCommand { @@ -17,6 +20,7 @@ class Version extends BaseCommand { 'sign-git-tag', 'workspace', 'workspaces', + 'workspaces-update', 'include-workspace-root', ] @@ -81,6 +85,7 @@ class Version extends BaseCommand { async changeWorkspaces (args, filters) { const prefix = this.npm.config.get('tag-version-prefix') await this.setWorkspaces(filters) + const updatedWorkspaces = [] for (const [name, path] of this.workspaces) { this.npm.output(name) const version = await libnpmversion(args[0], { @@ -88,8 +93,10 @@ class Version extends BaseCommand { 'git-tag-version': false, path, }) + updatedWorkspaces.push(name) this.npm.output(`${prefix}${version}`) } + return this.update(updatedWorkspaces) } async list (results = {}) { @@ -129,6 +136,34 @@ class Version extends BaseCommand { } return this.list(results) } + + async update (args) { + if (!this.npm.flatOptions.workspacesUpdate || !args.length) { + return + } + + // default behavior is to not save by default in order to avoid + // race condition problems when publishing multiple workspaces + // that have dependencies on one another, it might still be useful + // in some cases, which then need to set --save + const save = this.npm.config.isDefault('save') + ? false + : this.npm.config.get('save') + + // runs a minimalistic reify update, targetting only the workspaces + // that had version updates and skipping fund/audit/save + const opts = { + ...this.npm.flatOptions, + audit: false, + fund: false, + path: this.npm.localPrefix, + save, + } + const arb = new Arborist(opts) + + await arb.reify({ ...opts, update: args }) + await reifyFinish(this.npm, arb) + } } module.exports = Version diff --git a/deps/npm/lib/commands/view.js b/deps/npm/lib/commands/view.js index 85087057d65e9b..99cf2981306fa5 100644 --- a/deps/npm/lib/commands/view.js +++ b/deps/npm/lib/commands/view.js @@ -1,3 +1,6 @@ +/* eslint-disable no-console */ +// XXX: remove console.log later + // npm view [pkg [pkg ...]] const color = require('ansicolors') diff --git a/deps/npm/lib/lifecycle-cmd.js b/deps/npm/lib/lifecycle-cmd.js index e2190c2de1c0f8..41633a4ba389c9 100644 --- a/deps/npm/lib/lifecycle-cmd.js +++ b/deps/npm/lib/lifecycle-cmd.js @@ -4,6 +4,7 @@ const BaseCommand = require('./base-command.js') class LifecycleCmd extends BaseCommand { static usage = ['[-- ]'] + static isShellout = true async exec (args, cb) { return this.npm.exec('run-script', [this.constructor.name, ...args]) diff --git a/deps/npm/lib/npm.js b/deps/npm/lib/npm.js index 9999cf195d7b1e..74825c97c2355f 100644 --- a/deps/npm/lib/npm.js +++ b/deps/npm/lib/npm.js @@ -1,72 +1,83 @@ const EventEmitter = require('events') -const { resolve, dirname } = require('path') +const { resolve, dirname, join } = require('path') const Config = require('@npmcli/config') // Patch the global fs module here at the app level require('graceful-fs').gracefulify(require('fs')) const { definitions, flatten, shorthands } = require('./utils/config/index.js') -const { shellouts } = require('./utils/cmd-list.js') const usage = require('./utils/npm-usage.js') const which = require('which') +const fs = require('@npmcli/fs') -const deref = require('./utils/deref-command.js') const LogFile = require('./utils/log-file.js') const Timers = require('./utils/timers.js') const Display = require('./utils/display.js') const log = require('./utils/log-shim') const replaceInfo = require('./utils/replace-info.js') +const updateNotifier = require('./utils/update-notifier.js') +const pkg = require('../package.json') +const cmdList = require('./utils/cmd-list.js') let warnedNonDashArg = false const _load = Symbol('_load') -const _tmpFolder = Symbol('_tmpFolder') -const _title = Symbol('_title') -const pkg = require('../package.json') class Npm extends EventEmitter { static get version () { return pkg.version } - #unloaded = false - #timers = null - #logFile = null - #display = null - - constructor () { - super() - this.command = null - this.#logFile = new LogFile() - this.#display = new Display() - this.#timers = new Timers({ - start: 'npm', - listener: (name, ms) => { - const args = ['timing', name, `Completed in ${ms}ms`] - this.#logFile.log(...args) - this.#display.log(...args) - }, - }) - this.config = new Config({ - npmPath: dirname(__dirname), - definitions, - flatten, - shorthands, - }) - this[_title] = process.title - this.updateNotification = null - } + command = null + updateNotification = null + loadErr = null + argv = [] + + #loadPromise = null + #tmpFolder = null + #title = 'npm' + #argvClean = [] + + #logFile = new LogFile() + #display = new Display() + #timers = new Timers({ + start: 'npm', + listener: (name, ms) => { + const args = ['timing', name, `Completed in ${ms}ms`] + this.#logFile.log(...args) + this.#display.log(...args) + }, + }) + + config = new Config({ + npmPath: dirname(__dirname), + definitions, + flatten, + shorthands, + }) get version () { return this.constructor.version } - get shelloutCommands () { - return shellouts - } - deref (c) { - return deref(c) + if (!c) { + return + } + if (c.match(/[A-Z]/)) { + c = c.replace(/([A-Z])/g, m => '-' + m.toLowerCase()) + } + if (cmdList.plumbing.indexOf(c) !== -1) { + return c + } + // first deref the abbrev, if there is one + // then resolve any aliases + // so `npm install-cl` will resolve to `install-clean` then to `ci` + let a = cmdList.abbrevs[c] + while (cmdList.aliases[a]) { + a = cmdList.aliases[a] + } + return a } // Get an instantiated npm command @@ -88,15 +99,21 @@ class Npm extends EventEmitter { // Call an npm command async exec (cmd, args) { const command = await this.cmd(cmd) - process.emit('time', `command:${cmd}`) + const timeEnd = this.time(`command:${cmd}`) // since 'test', 'start', 'stop', etc. commands re-enter this function // to call the run-script command, we need to only set it one time. if (!this.command) { process.env.npm_command = command.name this.command = command.name + this.commandInstance = command } + // this is async but we dont await it, since its ok if it doesnt + // finish before the command finishes running. it uses command and argv + // so it must be initiated here, after the command name is set + updateNotifier(this).then((msg) => (this.updateNotification = msg)) + // Options are prefixed by a hyphen-minus (-, \u2d). // Other dash-type chars look similar but are invalid. if (!warnedNonDashArg) { @@ -112,68 +129,60 @@ class Npm extends EventEmitter { }) } + const isGlobal = this.config.get('global') const workspacesEnabled = this.config.get('workspaces') const implicitWorkspace = this.config.get('workspace', 'default').length > 0 const workspacesFilters = this.config.get('workspace') - if (workspacesEnabled === false && workspacesFilters.length > 0) { - throw new Error('Can not use --no-workspaces and --workspace at the same time') - } - + const includeWorkspaceRoot = this.config.get('include-workspace-root') // only call execWorkspaces when we have workspaces explicitly set // or when it is implicit and not in our ignore list - const filterByWorkspaces = - (workspacesEnabled || workspacesFilters.length > 0) - && (!implicitWorkspace || !command.ignoreImplicitWorkspace) + const hasWorkspaceFilters = workspacesFilters.length > 0 + const invalidWorkspaceConfig = workspacesEnabled === false && hasWorkspaceFilters + const filterByWorkspaces = (workspacesEnabled || hasWorkspaceFilters) && + (!implicitWorkspace || !command.ignoreImplicitWorkspace) // normally this would go in the constructor, but our tests don't // actually use a real npm object so this.npm.config isn't always // populated. this is the compromise until we can make that a reality // and then move this into the constructor. - command.workspaces = this.config.get('workspaces') + command.workspaces = workspacesEnabled command.workspacePaths = null // normally this would be evaluated in base-command#setWorkspaces, see // above for explanation - command.includeWorkspaceRoot = this.config.get('include-workspace-root') + command.includeWorkspaceRoot = includeWorkspaceRoot + let execPromise = Promise.resolve() if (this.config.get('usage')) { this.output(command.usage) - return - } - if (filterByWorkspaces) { - if (this.config.get('global')) { - throw new Error('Workspaces not supported for global packages') + } else if (invalidWorkspaceConfig) { + execPromise = Promise.reject( + new Error('Can not use --no-workspaces and --workspace at the same time')) + } else if (filterByWorkspaces) { + if (isGlobal) { + execPromise = Promise.reject(new Error('Workspaces not supported for global packages')) + } else { + execPromise = command.execWorkspaces(args, workspacesFilters) } - - return command.execWorkspaces(args, this.config.get('workspace')).finally(() => { - process.emit('timeEnd', `command:${cmd}`) - }) } else { - return command.exec(args).finally(() => { - process.emit('timeEnd', `command:${cmd}`) - }) + execPromise = command.exec(args) } + + return execPromise.finally(timeEnd) } async load () { - if (!this.loadPromise) { - process.emit('time', 'npm:load') - this.loadPromise = new Promise((resolve, reject) => { - this[_load]() - .catch(er => er) - .then(er => { - this.loadErr = er - if (!er && this.config.get('force')) { - log.warn('using --force', 'Recommended protections disabled.') - } - - process.emit('timeEnd', 'npm:load') - if (er) { - return reject(er) - } - resolve() - }) - }) + if (!this.#loadPromise) { + this.#loadPromise = this.time('npm:load', () => this[_load]().catch(er => er).then((er) => { + this.loadErr = er + if (!er) { + if (this.config.get('force')) { + log.warn('using --force', 'Recommended protections disabled.') + } + } else { + throw er + } + })) } - return this.loadPromise + return this.#loadPromise } get loaded () { @@ -184,106 +193,115 @@ class Npm extends EventEmitter { // during any tests to cleanup all of our listeners // Everything in here should be synchronous unload () { - // Track if we've already unloaded so we dont - // write multiple timing files. This is only an - // issue in tests right now since we unload - // in both tap teardowns and the exit handler - if (this.#unloaded) { - return - } this.#timers.off() this.#display.off() this.#logFile.off() - if (this.loaded && this.config.get('timing')) { - this.#timers.writeFile({ - command: process.argv.slice(2), - // We used to only ever report a single log file - // so to be backwards compatible report the last logfile - // XXX: remove this in npm 9 or just keep it forever - logfile: this.logFiles[this.logFiles.length - 1], - logfiles: this.logFiles, - version: this.version, - }) - } - this.#unloaded = true + } + + time (name, fn) { + return this.#timers.time(name, fn) + } + + writeTimingFile () { + this.#timers.writeFile({ + command: this.#argvClean, + // We used to only ever report a single log file + // so to be backwards compatible report the last logfile + // XXX: remove this in npm 9 or just keep it forever + logfile: this.logFiles[this.logFiles.length - 1], + logfiles: this.logFiles, + version: this.version, + }) } get title () { - return this[_title] + return this.#title } set title (t) { process.title = t - this[_title] = t + this.#title = t } async [_load] () { - process.emit('time', 'npm:load:whichnode') - let node - try { - node = which.sync(process.argv[0]) - } catch { - // TODO should we throw here? - } - process.emit('timeEnd', 'npm:load:whichnode') + const node = this.time('npm:load:whichnode', () => { + try { + return which.sync(process.argv[0]) + } catch {} // TODO should we throw here? + }) + if (node && node.toUpperCase() !== process.execPath.toUpperCase()) { log.verbose('node symlink', node) process.execPath = node this.config.execPath = node } - process.emit('time', 'npm:load:configload') - await this.config.load() - process.emit('timeEnd', 'npm:load:configload') + await this.time('npm:load:configload', () => this.config.load()) + + // mkdir this separately since the logs dir can be set to + // a different location. an error here should be surfaced + // right away since it will error in cacache later + await this.time('npm:load:mkdirpcache', () => + fs.mkdir(this.cache, { recursive: true, owner: 'inherit' })) + + // its ok if this fails. user might have specified an invalid dir + // which we will tell them about at the end + await this.time('npm:load:mkdirplogs', () => + fs.mkdir(this.logsDir, { recursive: true, owner: 'inherit' }) + .catch((e) => log.warn('logfile', `could not create logs-dir: ${e}`))) - this.argv = this.config.parsedArgv.remain // note: this MUST be shorter than the actual argv length, because it // uses the same memory, so node will truncate it if it's too long. - // if it's a token revocation, then the argv contains a secret, so - // don't show that. (Regrettable historical choice to put it there.) - // Any other secrets are configs only, so showing only the positional - // args keeps those from being leaked. - process.emit('time', 'npm:load:setTitle') - const tokrev = deref(this.argv[0]) === 'token' && this.argv[1] === 'revoke' - this.title = tokrev - ? 'npm token revoke' + (this.argv[2] ? ' ***' : '') - : replaceInfo(['npm', ...this.argv].join(' ')) - process.emit('timeEnd', 'npm:load:setTitle') - - process.emit('time', 'npm:load:display') - this.#display.load({ - // Use logColor since that is based on stderr - color: this.logColor, - progress: this.flatOptions.progress, - silent: this.silent, - timing: this.config.get('timing'), - loglevel: this.config.get('loglevel'), - unicode: this.config.get('unicode'), - heading: this.config.get('heading'), + this.time('npm:load:setTitle', () => { + const { parsedArgv: { cooked, remain } } = this.config + this.argv = remain + // Secrets are mostly in configs, so title is set using only the positional args + // to keep those from being leaked. + this.title = ['npm'].concat(replaceInfo(remain)).join(' ').trim() + // The cooked argv is also logged separately for debugging purposes. It is + // cleaned as a best effort by replacing known secrets like basic auth + // password and strings that look like npm tokens. XXX: for this to be + // safer the config should create a sanitized version of the argv as it + // has the full context of what each option contains. + this.#argvClean = replaceInfo(cooked) + log.verbose('title', this.title) + log.verbose('argv', this.#argvClean.map(JSON.stringify).join(' ')) }) - process.emit('timeEnd', 'npm:load:display') - process.env.COLOR = this.color ? '1' : '0' - process.emit('time', 'npm:load:logFile') - this.#logFile.load({ - dir: resolve(this.cache, '_logs'), - logsMax: this.config.get('logs-max'), + this.time('npm:load:display', () => { + this.#display.load({ + // Use logColor since that is based on stderr + color: this.logColor, + progress: this.flatOptions.progress, + silent: this.silent, + timing: this.config.get('timing'), + loglevel: this.config.get('loglevel'), + unicode: this.config.get('unicode'), + heading: this.config.get('heading'), + }) + process.env.COLOR = this.color ? '1' : '0' }) - log.verbose('logfile', this.#logFile.files[0]) - process.emit('timeEnd', 'npm:load:logFile') - process.emit('time', 'npm:load:timers') - this.#timers.load({ - dir: this.cache, + this.time('npm:load:logFile', () => { + this.#logFile.load({ + dir: this.logsDir, + logsMax: this.config.get('logs-max'), + }) + log.verbose('logfile', this.#logFile.files[0] || 'no logfile created') }) - process.emit('timeEnd', 'npm:load:timers') - process.emit('time', 'npm:load:configScope') - const configScope = this.config.get('scope') - if (configScope && !/^@/.test(configScope)) { - this.config.set('scope', `@${configScope}`, this.config.find('scope')) - } - process.emit('timeEnd', 'npm:load:configScope') + this.time('npm:load:timers', () => + this.#timers.load({ + dir: this.config.get('timing') ? this.timingDir : null, + }) + ) + + this.time('npm:load:configScope', () => { + const configScope = this.config.get('scope') + if (configScope && !/^@/.test(configScope)) { + this.config.set('scope', `@${configScope}`, this.config.find('scope')) + } + }) } get flatOptions () { @@ -329,6 +347,19 @@ class Npm extends EventEmitter { return this.#logFile.files } + get logsDir () { + return this.config.get('logs-dir') || join(this.cache, '_logs') + } + + get timingFile () { + return this.#timers.file + } + + get timingDir () { + // XXX(npm9): make this always in logs-dir + return this.config.get('logs-dir') || this.cache + } + get cache () { return this.config.get('cache') } @@ -395,11 +426,11 @@ class Npm extends EventEmitter { // XXX add logging to see if we actually use this get tmp () { - if (!this[_tmpFolder]) { + if (!this.#tmpFolder) { const rand = require('crypto').randomBytes(4).toString('hex') - this[_tmpFolder] = `npm-${process.pid}-${rand}` + this.#tmpFolder = `npm-${process.pid}-${rand}` } - return resolve(this.config.get('tmp'), this[_tmpFolder]) + return resolve(this.config.get('tmp'), this.#tmpFolder) } // output to stdout in a progress bar compatible way @@ -409,5 +440,12 @@ class Npm extends EventEmitter { console.log(...msg) log.showProgress() } + + outputError (...msg) { + log.clearProgress() + // eslint-disable-next-line no-console + console.error(...msg) + log.showProgress() + } } module.exports = Npm diff --git a/deps/npm/lib/utils/cmd-list.js b/deps/npm/lib/utils/cmd-list.js index b3089a62c60d26..c1d20186a82a6d 100644 --- a/deps/npm/lib/utils/cmd-list.js +++ b/deps/npm/lib/utils/cmd-list.js @@ -1,5 +1,23 @@ -// short names for common things -const shorthands = { +const abbrev = require('abbrev') + +// plumbing should not have any aliases +const aliases = { + + // aliases + login: 'adduser', + author: 'owner', + home: 'docs', + issues: 'bugs', + info: 'view', + show: 'view', + find: 'search', + add: 'install', + unlink: 'uninstall', + remove: 'uninstall', + rm: 'uninstall', + r: 'uninstall', + + // short names for common things un: 'uninstall', rb: 'rebuild', list: 'ls', @@ -21,12 +39,11 @@ const shorthands = { 'clean-install-test': 'cit', x: 'exec', why: 'explain', -} - -const affordances = { la: 'll', verison: 'version', ic: 'ci', + + // typos innit: 'init', // manually abbrev so that install-test doesn't make insta stop working in: 'install', @@ -44,119 +61,90 @@ const affordances = { 'dist-tags': 'dist-tag', upgrade: 'update', udpate: 'update', - login: 'adduser', - 'add-user': 'adduser', - author: 'owner', - home: 'docs', - issues: 'bugs', - info: 'view', - show: 'view', - find: 'search', - add: 'install', - unlink: 'uninstall', - remove: 'uninstall', - rm: 'uninstall', - r: 'uninstall', rum: 'run-script', sit: 'cit', urn: 'run-script', ogr: 'org', + 'add-user': 'adduser', } // these are filenames in . +// Keep these sorted so that lib/utils/npm-usage.js outputs in order const cmdList = [ - 'ci', - 'install-ci-test', - 'install', - 'install-test', - 'uninstall', + 'access', + 'adduser', + 'audit', + 'bin', + 'bugs', 'cache', + 'ci', + 'completion', 'config', - 'set', - 'get', - 'update', - 'outdated', - 'prune', - 'pack', - 'find-dupes', 'dedupe', + 'deprecate', + 'diff', + 'dist-tag', + 'docs', + 'doctor', + 'edit', + 'exec', + 'explain', + 'explore', + 'find-dupes', + 'fund', + 'get', + 'help', 'hook', - - 'rebuild', + 'init', + 'install', + 'install-ci-test', + 'install-test', 'link', - - 'publish', - 'star', - 'stars', - 'unstar', - 'adduser', + 'll', 'login', // This is an alias for `adduser` but it can be confusing 'logout', - 'unpublish', - 'owner', - 'access', - 'team', - 'deprecate', - 'shrinkwrap', - 'token', - 'profile', - 'audit', - 'fund', - 'org', - - 'help', 'ls', - 'll', - 'search', - 'view', - 'init', - 'version', - 'edit', - 'explore', - 'docs', - 'repo', - 'bugs', - 'root', - 'prefix', - 'bin', - 'whoami', - 'diff', - 'dist-tag', + 'org', + 'outdated', + 'owner', + 'pack', 'ping', 'pkg', - - 'test', - 'stop', - 'start', + 'prefix', + 'profile', + 'prune', + 'publish', + 'rebuild', + 'repo', 'restart', + 'root', 'run-script', + 'search', + 'set', 'set-script', - 'completion', - 'doctor', - 'exec', - 'explain', -] - -const plumbing = ['birthday', 'help-search'] - -// these commands just shell out to something else or handle the -// error themselves, so it's confusing and weird to write out -// our full error log banner when they exit non-zero -const shellouts = [ - 'exec', - 'run-script', - 'test', + 'shrinkwrap', + 'star', + 'stars', 'start', 'stop', - 'restart', - 'birthday', + 'team', + 'test', + 'token', + 'uninstall', + 'unpublish', + 'unstar', + 'update', + 'version', + 'view', + 'whoami', ] +const plumbing = ['birthday', 'help-search'] +const abbrevs = abbrev(cmdList.concat(Object.keys(aliases))) + module.exports = { - aliases: Object.assign({}, shorthands, affordances), - shorthands, - affordances, + abbrevs, + aliases, cmdList, plumbing, - shellouts, } diff --git a/deps/npm/lib/utils/config/definitions.js b/deps/npm/lib/utils/config/definitions.js index ddccb147586f4f..efc1f72a020594 100644 --- a/deps/npm/lib/utils/config/definitions.js +++ b/deps/npm/lib/utils/config/definitions.js @@ -7,7 +7,7 @@ const { version: npmVersion } = require('../../../package.json') const ciDetect = require('@npmcli/ci-detect') const ciName = ciDetect() const querystring = require('querystring') -const isWindows = require('../is-windows.js') +const { isWindows } = require('../is-windows.js') const { join } = require('path') // used by cafile flattening to flatOptions.ca @@ -1229,11 +1229,25 @@ define('loglevel', { }, }) +define('logs-dir', { + default: null, + type: [null, path], + defaultDescription: ` + A directory named \`_logs\` inside the cache +`, + description: ` + The location of npm's log directory. See [\`npm + logging\`](/using-npm/logging) for more information. + `, +}) + define('logs-max', { default: 10, type: Number, description: ` The maximum number of log files to store. + + If set to 0, no log files will be written for the current run. `, }) @@ -2025,8 +2039,8 @@ define('timing', { default: false, type: Boolean, description: ` - If true, writes an \`npm-debug\` log to \`_logs\` and timing information - to \`_timing.json\`, both in your cache, even if the command completes + If true, writes a debug log to \`logs-dir\` and timing information + to \`_timing.json\` in the cache, even if the command completes successfully. \`_timing.json\` is a newline delimited list of JSON objects. @@ -2270,6 +2284,16 @@ define('workspaces', { }, }) +define('workspaces-update', { + default: true, + type: Boolean, + description: ` + If set to true, the npm cli will run an update after operations that may + possibly change the workspaces installed to the \`node_modules\` folder. + `, + flatten, +}) + define('yes', { default: null, type: [null, Boolean], diff --git a/deps/npm/lib/utils/deref-command.js b/deps/npm/lib/utils/deref-command.js deleted file mode 100644 index 0a3c8c90bc903d..00000000000000 --- a/deps/npm/lib/utils/deref-command.js +++ /dev/null @@ -1,31 +0,0 @@ -// de-reference abbreviations and shorthands into canonical command name - -const { aliases, cmdList, plumbing } = require('./cmd-list.js') -const aliasNames = Object.keys(aliases) -const fullList = cmdList.concat(aliasNames).filter(c => !plumbing.includes(c)) -const abbrev = require('abbrev') -const abbrevs = abbrev(fullList) - -module.exports = c => { - if (!c || typeof c !== 'string') { - return '' - } - - if (c.match(/[A-Z]/)) { - c = c.replace(/([A-Z])/g, m => '-' + m.toLowerCase()) - } - - if (plumbing.indexOf(c) !== -1) { - return c - } - - // first deref the abbrev, if there is one - // then resolve any aliases - // so `npm install-cl` will resolve to `install-clean` then to `ci` - let a = abbrevs[c] - while (aliases[a]) { - a = aliases[a] - } - - return a || '' -} diff --git a/deps/npm/lib/utils/error-message.js b/deps/npm/lib/utils/error-message.js index 5fa361efcd3da5..adf10a56f6d663 100644 --- a/deps/npm/lib/utils/error-message.js +++ b/deps/npm/lib/utils/error-message.js @@ -60,7 +60,7 @@ module.exports = (er, npm) => { npm.config.loaded && er.dest.startsWith(npm.config.get('cache')) - const isWindows = require('./is-windows.js') + const { isWindows } = require('./is-windows.js') if (!isWindows && (isCachePath || isCacheDest)) { // user probably doesn't need this, but still add it to the debug log diff --git a/deps/npm/lib/utils/exit-handler.js b/deps/npm/lib/utils/exit-handler.js index 6186ea81dcc025..d8ae9994dfecce 100644 --- a/deps/npm/lib/utils/exit-handler.js +++ b/deps/npm/lib/utils/exit-handler.js @@ -1,14 +1,15 @@ const os = require('os') -const log = require('./log-shim.js') +const log = require('./log-shim.js') const errorMessage = require('./error-message.js') const replaceInfo = require('./replace-info.js') const messageText = msg => msg.map(line => line.slice(1).join(' ')).join('\n') +const indent = (val) => Array.isArray(val) ? val.map(v => indent(v)) : ` ${val}` let npm = null // set by the cli let exitHandlerCalled = false -let showLogFileMessage = false +let showLogFileError = false process.on('exit', code => { log.disableProgress() @@ -36,42 +37,73 @@ process.on('exit', code => { if (!exitHandlerCalled) { process.exitCode = code || 1 log.error('', 'Exit handler never called!') + // eslint-disable-next-line no-console console.error('') log.error('', 'This is an error with npm itself. Please report this error at:') log.error('', ' ') - showLogFileMessage = true - } - - // In timing mode we always show the log file message - if (hasLoadedNpm && npm.config.get('timing')) { - showLogFileMessage = true + showLogFileError = true } // npm must be loaded to know where the log file was written - if (showLogFileMessage && hasLoadedNpm) { - // just a line break if not in silent mode - if (!npm.silent) { - console.error('') - } + if (hasLoadedNpm) { + // write the timing file now, this might do nothing based on the configs set. + // we need to call it here in case it errors so we dont tell the user + // about a timing file that doesn't exist + npm.writeTimingFile() - log.error( - '', - [ - 'A complete log of this run can be found in:', - ...npm.logFiles.map(f => ' ' + f), - ].join('\n') - ) - } + const logsDir = npm.logsDir + const logFiles = npm.logFiles - // This removes any listeners npm setup and writes files if necessary - // This is mostly used for tests to avoid max listener warnings - if (hasLoadedNpm) { + const timingDir = npm.timingDir + const timingFile = npm.timingFile + + const timing = npm.config.get('timing') + const logsMax = npm.config.get('logs-max') + + // Determine whether to show log file message and why it is + // being shown since in timing mode we always show the log file message + const logMethod = showLogFileError ? 'error' : timing ? 'info' : null + + if (logMethod) { + if (!npm.silent) { + // just a line break if not in silent mode + // eslint-disable-next-line no-console + console.error('') + } + + const message = [] + + if (timingFile) { + message.push('Timing info written to:', indent(timingFile)) + } else if (timing) { + message.push( + `The timing file was not written due to an error writing to the directory: ${timingDir}` + ) + } + + if (logFiles.length) { + message.push('A complete log of this run can be found in:', ...indent(logFiles)) + } else if (logsMax <= 0) { + // user specified no log file + message.push(`Log files were not written due to the config logs-max=${logsMax}`) + } else { + // could be an error writing to the directory + message.push( + `Log files were not written due to an error writing to the directory: ${logsDir}`, + 'You can rerun the command with `--loglevel=verbose` to see the logs in your terminal' + ) + } + + log[logMethod]('', message.join('\n')) + } + + // This removes any listeners npm setup, mostly for tests to avoid max listener warnings npm.unload() } // these are needed for the tests to have a clean slate in each test case exitHandlerCalled = false - showLogFileMessage = false + showLogFileError = false }) const exitHandler = err => { @@ -84,12 +116,14 @@ const exitHandler = err => { if (!hasNpm) { err = err || new Error('Exit prior to setting npm in exit handler') + // eslint-disable-next-line no-console console.error(err.stack || err.message) return process.exit(1) } if (!hasLoadedNpm) { err = err || new Error('Exit prior to config file resolving.') + // eslint-disable-next-line no-console console.error(err.stack || err.message) } @@ -110,7 +144,7 @@ const exitHandler = err => { // will presumably print its own errors and exit with a proper status // code if there's a problem. If we got an error with a code=0, then... // something else went wrong along the way, so maybe an npm problem? - const isShellout = npm.shelloutCommands.includes(npm.command) + const isShellout = npm.commandInstance && npm.commandInstance.constructor.isShellout const quietShellout = isShellout && typeof err.code === 'number' && err.code if (quietShellout) { exitCode = err.code @@ -135,10 +169,8 @@ const exitHandler = err => { } } - const args = replaceInfo(process.argv) log.verbose('cwd', process.cwd()) log.verbose('', os.type() + ' ' + os.release()) - log.verbose('argv', args.map(JSON.stringify).join(' ')) log.verbose('node', process.version) log.verbose('npm ', 'v' + npm.version) @@ -162,7 +194,7 @@ const exitHandler = err => { detail: messageText(msg.detail), }, } - console.error(JSON.stringify(error, null, 2)) + npm.outputError(JSON.stringify(error, null, 2)) } if (typeof err.errno === 'number') { @@ -175,17 +207,18 @@ const exitHandler = err => { log.verbose('exit', exitCode || 0) - showLogFileMessage = (hasLoadedNpm && npm.silent) || noLogMessage + showLogFileError = (hasLoadedNpm && npm.silent) || noLogMessage ? false : !!exitCode // explicitly call process.exit now so we don't hang on things like the - // update notifier, also flush stdout beforehand because process.exit doesn't + // update notifier, also flush stdout/err beforehand because process.exit doesn't // wait for that to happen. - process.stdout.write('', () => process.exit(exitCode)) + let flushed = 0 + const flush = [process.stderr, process.stdout] + const exit = () => ++flushed === flush.length && process.exit(exitCode) + flush.forEach((f) => f.write('', exit)) } module.exports = exitHandler -module.exports.setNpm = n => { - npm = n -} +module.exports.setNpm = n => (npm = n) diff --git a/deps/npm/lib/utils/is-windows-bash.js b/deps/npm/lib/utils/is-windows-bash.js deleted file mode 100644 index 0ae99e212cc08d..00000000000000 --- a/deps/npm/lib/utils/is-windows-bash.js +++ /dev/null @@ -1,3 +0,0 @@ -const isWindows = require('./is-windows.js') -module.exports = isWindows && - (/^MINGW(32|64)$/.test(process.env.MSYSTEM) || process.env.TERM === 'cygwin') diff --git a/deps/npm/lib/utils/is-windows-shell.js b/deps/npm/lib/utils/is-windows-shell.js deleted file mode 100644 index 477bd43cc10cc5..00000000000000 --- a/deps/npm/lib/utils/is-windows-shell.js +++ /dev/null @@ -1,3 +0,0 @@ -const isWindows = require('./is-windows.js') -const isWindowsBash = require('./is-windows-bash.js') -module.exports = isWindows && !isWindowsBash diff --git a/deps/npm/lib/utils/is-windows.js b/deps/npm/lib/utils/is-windows.js index fbece90ad74964..57f6599b6ae192 100644 --- a/deps/npm/lib/utils/is-windows.js +++ b/deps/npm/lib/utils/is-windows.js @@ -1 +1,6 @@ -module.exports = process.platform === 'win32' +const isWindows = process.platform === 'win32' +const isWindowsShell = isWindows && + !/^MINGW(32|64)$/.test(process.env.MSYSTEM) && process.env.TERM !== 'cygwin' + +exports.isWindows = isWindows +exports.isWindowsShell = isWindowsShell diff --git a/deps/npm/lib/utils/log-file.js b/deps/npm/lib/utils/log-file.js index 0bf1e0054ea2bf..282c72700e58e2 100644 --- a/deps/npm/lib/utils/log-file.js +++ b/deps/npm/lib/utils/log-file.js @@ -5,8 +5,8 @@ const rimraf = promisify(require('rimraf')) const glob = promisify(require('glob')) const MiniPass = require('minipass') const fsMiniPass = require('fs-minipass') +const fs = require('@npmcli/fs') const log = require('./log-shim') -const withChownSync = require('./with-chown-sync') const padZero = (n, length) => n.toString().padStart(length.toString().length, '0') @@ -82,7 +82,9 @@ class LogFiles { this[_endStream]() } - load ({ dir, logsMax } = {}) { + load ({ dir, logsMax = Infinity } = {}) { + // dir is user configurable and is required to exist so + // this can error if the dir is missing or not configured correctly this.#dir = dir this.#logsMax = logsMax @@ -90,16 +92,22 @@ class LogFiles { if (!this.#logStream) { return } + + log.verbose('logfile', `logs-max:${logsMax} dir:${dir}`) + // Pipe our initial stream to our new file stream and // set that as the new log logstream for future writes - const initialFile = this[_openLogFile]() - if (initialFile) { - this.#logStream = this.#logStream.pipe(initialFile) + // if logs max is 0 then the user does not want a log file + if (this.#logsMax > 0) { + const initialFile = this[_openLogFile]() + if (initialFile) { + this.#logStream = this.#logStream.pipe(initialFile) + } } - // Kickoff cleaning process. This is async but it wont delete - // our next log file since it deletes oldest first. Return the - // result so it can be awaited in tests + // Kickoff cleaning process, even if we aren't writing a logfile. + // This is async but it will always ignore the current logfile + // Return the result so it can be awaited in tests return this[_cleanLogs]() } @@ -164,8 +172,8 @@ class LogFiles { return LogFiles.format(this.#totalLogCount++, ...args) } - [_getLogFilePath] (prefix, suffix, sep = '-') { - return path.resolve(this.#dir, prefix + sep + 'debug' + sep + suffix + '.log') + [_getLogFilePath] (count = '') { + return path.resolve(this.#dir, `${this.#logId}-debug-${count}.log`) } [_openLogFile] () { @@ -173,17 +181,19 @@ class LogFiles { const count = this.#files.length try { - const logStream = withChownSync( - // Pad with zeros so that our log files are always sorted properly - // We never want to write files ending in `-9.log` and `-10.log` because - // log file cleaning is done by deleting the oldest so in this example - // `-10.log` would be deleted next - this[_getLogFilePath](this.#logId, padZero(count, this.#MAX_FILES_PER_PROCESS)), - // Some effort was made to make the async, but we need to write logs - // during process.on('exit') which has to be synchronous. So in order - // to never drop log messages, it is easiest to make it sync all the time - // and this was measured to be about 1.5% slower for 40k lines of output - (f) => new fsMiniPass.WriteStreamSync(f, { flags: 'a' }) + // Pad with zeros so that our log files are always sorted properly + // We never want to write files ending in `-9.log` and `-10.log` because + // log file cleaning is done by deleting the oldest so in this example + // `-10.log` would be deleted next + const f = this[_getLogFilePath](padZero(count, this.#MAX_FILES_PER_PROCESS)) + // Some effort was made to make the async, but we need to write logs + // during process.on('exit') which has to be synchronous. So in order + // to never drop log messages, it is easiest to make it sync all the time + // and this was measured to be about 1.5% slower for 40k lines of output + const logStream = fs.withOwnerSync( + f, + () => new fsMiniPass.WriteStreamSync(f, { flags: 'a' }), + { owner: 'inherit' } ) if (count > 0) { // Reset file log count if we are opening @@ -193,9 +203,7 @@ class LogFiles { this.#files.push(logStream.path) return logStream } catch (e) { - // XXX: do something here for errors? - // log to display only? - return null + log.warn('logfile', `could not be created: ${e}`) } } @@ -206,14 +214,16 @@ class LogFiles { // Promise that succeeds when we've tried to delete everything, // just for the benefit of testing this function properly. - if (typeof this.#logsMax !== 'number') { - return - } - try { - // Handle the old (prior to 8.2.0) log file names which did not have an counter suffix - // so match by anything after `-debug` and before `.log` (including nothing) - const logGlob = this[_getLogFilePath]('*-', '*', '') + const logPath = this[_getLogFilePath]() + const logGlob = path.join(path.dirname(logPath), path.basename(logPath) + // tell glob to only match digits + .replace(/\d/g, '[0123456789]') + // Handle the old (prior to 8.2.0) log file names which did not have a + // counter suffix + .replace(/-\.log$/, '*.log') + ) + // Always ignore the currently written files const files = await glob(logGlob, { ignore: this.#files }) const toDelete = files.length - this.#logsMax @@ -233,6 +243,8 @@ class LogFiles { } } catch (e) { log.warn('logfile', 'error cleaning log files', e) + } finally { + log.silly('logfile', 'done cleaning log files') } } } diff --git a/deps/npm/lib/utils/npm-usage.js b/deps/npm/lib/utils/npm-usage.js index b0c98b2ae6c0b4..8d31f0155098bd 100644 --- a/deps/npm/lib/utils/npm-usage.js +++ b/deps/npm/lib/utils/npm-usage.js @@ -45,7 +45,7 @@ const wrap = (arr) => { : Math.min(60, Math.max(process.stdout.columns - 16, 24)) let l = 0 - for (const c of arr.sort((a, b) => a < b ? -1 : 1)) { + for (const c of arr) { if (out[l].length + c.length + 2 < line) { out[l] += ', ' + c } else { diff --git a/deps/npm/lib/utils/otplease.js b/deps/npm/lib/utils/otplease.js index 566c24ef2e293b..83985b6bc170d0 100644 --- a/deps/npm/lib/utils/otplease.js +++ b/deps/npm/lib/utils/otplease.js @@ -1,17 +1,17 @@ -const readUserInfo = require('./read-user-info.js') - -module.exports = otplease async function otplease (opts, fn) { try { - await fn(opts) + return await fn(opts) } catch (err) { + const readUserInfo = require('./read-user-info.js') if (err.code !== 'EOTP' && (err.code !== 'E401' || !/one-time pass/.test(err.body))) { throw err } else if (!process.stdin.isTTY || !process.stdout.isTTY) { throw err } else { const otp = await readUserInfo.otp('This operation requires a one-time password.\nEnter OTP:') - return fn({ ...opts, otp }) + return await fn({ ...opts, otp }) } } } + +module.exports = otplease diff --git a/deps/npm/lib/utils/path.js b/deps/npm/lib/utils/path.js deleted file mode 100644 index ad0065a2c52f36..00000000000000 --- a/deps/npm/lib/utils/path.js +++ /dev/null @@ -1,4 +0,0 @@ -// return the PATH array in a cross-platform way -const PATH = process.env.PATH || process.env.Path || process.env.path -const { delimiter } = require('path') -module.exports = PATH.split(delimiter) diff --git a/deps/npm/lib/utils/replace-info.js b/deps/npm/lib/utils/replace-info.js index e9d19ef5fb2ba4..b9ce61935ffb76 100644 --- a/deps/npm/lib/utils/replace-info.js +++ b/deps/npm/lib/utils/replace-info.js @@ -1,33 +1,31 @@ -const URL = require('url').URL +const { cleanUrl } = require('npm-registry-fetch') +const isString = (v) => typeof v === 'string' -// replaces auth info in an array of arguments or in a strings -function replaceInfo (arg) { - const isArray = Array.isArray(arg) - const isString = str => typeof str === 'string' - - if (!isArray && !isString(arg)) { - return arg - } +// split on \s|= similar to how nopt parses options +const splitAndReplace = (str) => { + // stateful regex, don't move out of this scope + const splitChars = /[\s=]/g - const testUrlAndReplace = str => { - try { - const url = new URL(str) - return url.password === '' ? str : str.replace(url.password, '***') - } catch (e) { - return str - } + let match = null + let result = '' + let index = 0 + while (match = splitChars.exec(str)) { + result += cleanUrl(str.slice(index, match.index)) + match[0] + index = splitChars.lastIndex } - const args = isString(arg) ? arg.split(' ') : arg - const info = args.map(a => { - if (isString(a) && a.indexOf(' ') > -1) { - return a.split(' ').map(testUrlAndReplace).join(' ') - } + return result + cleanUrl(str.slice(index)) +} - return testUrlAndReplace(a) - }) +// replaces auth info in an array of arguments or in a strings +function replaceInfo (arg) { + if (isString(arg)) { + return splitAndReplace(arg) + } else if (Array.isArray(arg)) { + return arg.map((a) => isString(a) ? splitAndReplace(a) : a) + } - return isString(arg) ? info.join(' ') : info + return arg } module.exports = replaceInfo diff --git a/deps/npm/lib/utils/split-package-names.js b/deps/npm/lib/utils/split-package-names.js deleted file mode 100644 index 395c2517d59345..00000000000000 --- a/deps/npm/lib/utils/split-package-names.js +++ /dev/null @@ -1,25 +0,0 @@ -'use strict' - -const splitPackageNames = (path) => { - return path.split('/') - // combine scoped parts - .reduce((parts, part) => { - if (parts.length === 0) { - return [part] - } - - const lastPart = parts[parts.length - 1] - // check if previous part is the first part of a scoped package - if (lastPart[0] === '@' && !lastPart.includes('/')) { - parts[parts.length - 1] += '/' + part - } else { - parts.push(part) - } - - return parts - }, []) - .join('/node_modules/') - .replace(/(\/node_modules)+/, '/node_modules') -} - -module.exports = splitPackageNames diff --git a/deps/npm/lib/utils/timers.js b/deps/npm/lib/utils/timers.js index acff29eb0521bb..3336c3b519259c 100644 --- a/deps/npm/lib/utils/timers.js +++ b/deps/npm/lib/utils/timers.js @@ -1,8 +1,7 @@ const EE = require('events') -const path = require('path') -const fs = require('graceful-fs') +const { resolve } = require('path') +const fs = require('@npmcli/fs') const log = require('./log-shim') -const withChownSync = require('./with-chown-sync.js') const _timeListener = Symbol('timeListener') const _timeEndListener = Symbol('timeEndListener') @@ -12,10 +11,11 @@ const _init = Symbol('init') // only listen on a single internal event that gets // emitted whenever a timer ends class Timers extends EE { + file = null + #unfinished = new Map() #finished = {} #onTimeEnd = Symbol('onTimeEnd') - #dir = null #initialListener = null #initialTimer = null @@ -62,11 +62,27 @@ class Timers extends EE { } } - load ({ dir }) { - this.#dir = dir + time (name, fn) { + process.emit('time', name) + const end = () => process.emit('timeEnd', name) + if (typeof fn === 'function') { + const res = fn() + return res && res.finally ? res.finally(end) : (end(), res) + } + return end + } + + load ({ dir } = {}) { + if (dir) { + this.file = resolve(dir, '_timing.json') + } } writeFile (fileData) { + if (!this.file) { + return + } + try { const globalStart = this.started const globalEnd = this.#finished.npm || Date.now() @@ -79,16 +95,17 @@ class Timers extends EE { return acc }, {}), } - withChownSync( - path.resolve(this.#dir, '_timing.json'), - (f) => - // we append line delimited json to this file...forever - // XXX: should we also write a process specific timing file? - // with similar rules to the debug log (max files, etc) - fs.appendFileSync(f, JSON.stringify(content) + '\n') + // we append line delimited json to this file...forever + // XXX: should we also write a process specific timing file? + // with similar rules to the debug log (max files, etc) + fs.withOwnerSync( + this.file, + () => fs.appendFileSync(this.file, JSON.stringify(content) + '\n'), + { owner: 'inherit' } ) } catch (e) { - log.warn('timing', 'could not write timing file', e) + this.file = null + log.warn('timing', `could not write timing file: ${e}`) } } diff --git a/deps/npm/lib/utils/unsupported.js b/deps/npm/lib/utils/unsupported.js deleted file mode 100644 index 75aad5e780ec41..00000000000000 --- a/deps/npm/lib/utils/unsupported.js +++ /dev/null @@ -1,39 +0,0 @@ -/* eslint-disable no-console */ -const semver = require('semver') -const supported = require('../../package.json').engines.node -const knownBroken = '<6.2.0 || 9 <9.3.0' - -// Keep this file compatible with all practical versions of node -// so we dont get syntax errors when trying to give the users -// a nice error message. Don't use our log handler because -// if we encounter a syntax error early on, that will never -// get displayed to the user. - -const checkVersion = exports.checkVersion = version => { - const versionNoPrerelease = version.replace(/-.*$/, '') - return { - version: versionNoPrerelease, - broken: semver.satisfies(versionNoPrerelease, knownBroken), - unsupported: !semver.satisfies(versionNoPrerelease, supported), - } -} - -exports.checkForBrokenNode = () => { - const nodejs = checkVersion(process.version) - if (nodejs.broken) { - console.error('ERROR: npm is known not to run on Node.js ' + process.version) - console.error("You'll need to upgrade to a newer Node.js version in order to use this") - console.error('version of npm. You can find the latest version at https://nodejs.org/') - process.exit(1) - } -} - -exports.checkForUnsupportedNode = () => { - const nodejs = checkVersion(process.version) - if (nodejs.unsupported) { - console.error('npm does not support Node.js ' + process.version) - console.error('You should probably upgrade to a newer version of node as we') - console.error("can't make any promises that npm will work with this version.") - console.error('You can find the latest version at https://nodejs.org/') - } -} diff --git a/deps/npm/lib/utils/update-notifier.js b/deps/npm/lib/utils/update-notifier.js index 875c3a99a25799..dde0202b76fe26 100644 --- a/deps/npm/lib/utils/update-notifier.js +++ b/deps/npm/lib/utils/update-notifier.js @@ -122,5 +122,5 @@ module.exports = async npm => { // fails, it's ok. might be using /dev/null as the cache or something weird // like that. writeFile(lastCheckedFile(npm), '').catch(() => {}) - npm.updateNotification = notification + return notification } diff --git a/deps/npm/lib/utils/usage.js b/deps/npm/lib/utils/usage.js deleted file mode 100644 index 39eaa45e4101e1..00000000000000 --- a/deps/npm/lib/utils/usage.js +++ /dev/null @@ -1,32 +0,0 @@ -const aliases = require('./cmd-list').aliases - -module.exports = function usage (cmd, txt, opt) { - const post = Object.keys(aliases).reduce(function (p, c) { - var val = aliases[c] - if (val !== cmd) { - return p - } - return p.concat(c) - }, []) - - if (opt || post.length > 0) { - txt += '\n\n' - } - - if (post.length === 1) { - txt += 'alias: ' - txt += post.join(', ') - } else if (post.length > 1) { - txt += 'aliases: ' - txt += post.join(', ') - } - - if (opt) { - if (post.length > 0) { - txt += '\n' - } - txt += 'common options: ' + opt - } - - return txt -} diff --git a/deps/npm/lib/utils/with-chown-sync.js b/deps/npm/lib/utils/with-chown-sync.js deleted file mode 100644 index 481b5696ddabf7..00000000000000 --- a/deps/npm/lib/utils/with-chown-sync.js +++ /dev/null @@ -1,13 +0,0 @@ -const mkdirp = require('mkdirp-infer-owner') -const fs = require('graceful-fs') -const path = require('path') - -module.exports = (file, method) => { - const dir = path.dirname(file) - mkdirp.sync(dir) - const result = method(file) - const st = fs.lstatSync(dir) - fs.chownSync(dir, st.uid, st.gid) - fs.chownSync(file, st.uid, st.gid) - return result -} diff --git a/deps/npm/man/man1/npm-install.1 b/deps/npm/man/man1/npm-install.1 index cb36d9f8543969..2f47c0865d6be3 100644 --- a/deps/npm/man/man1/npm-install.1 +++ b/deps/npm/man/man1/npm-install.1 @@ -16,7 +16,7 @@ npm install npm install npm install / -aliases: i, in, ins, inst, insta, instal, isnt, isnta, isntal, isntall, add +aliases: add, i, in, ins, inst, insta, instal, isnt, isnta, isntal, isntall .fi .RE .SS Description diff --git a/deps/npm/man/man1/npm-ls.1 b/deps/npm/man/man1/npm-ls.1 index 29d10078180d6e..6e7e9acae0b61e 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@8\.5\.5 /path/to/npm +npm@8\.6\.0 /path/to/npm └─┬ init\-package\-json@0\.0\.4 └── promzard@0\.1\.5 .fi diff --git a/deps/npm/man/man1/npm-search.1 b/deps/npm/man/man1/npm-search.1 index 73e3a471cec8cd..da2d25f5cfdff6 100644 --- a/deps/npm/man/man1/npm-search.1 +++ b/deps/npm/man/man1/npm-search.1 @@ -7,7 +7,7 @@ .nf npm search [search terms \.\.\.] -aliases: s, se, find +aliases: find, s, se .fi .RE .P diff --git a/deps/npm/man/man1/npm-uninstall.1 b/deps/npm/man/man1/npm-uninstall.1 index bb741021628a28..0638b2f728ac79 100644 --- a/deps/npm/man/man1/npm-uninstall.1 +++ b/deps/npm/man/man1/npm-uninstall.1 @@ -7,7 +7,7 @@ .nf npm uninstall [<@scope>/]\.\.\. -aliases: un, unlink, remove, rm, r +aliases: unlink, remove, rm, r, un .fi .RE .SS Description diff --git a/deps/npm/man/man1/npm-version.1 b/deps/npm/man/man1/npm-version.1 index 9b6b81c8a95508..39bd8465b05845 100644 --- a/deps/npm/man/man1/npm-version.1 +++ b/deps/npm/man/man1/npm-version.1 @@ -140,6 +140,17 @@ other things (test, exec, publish, etc\.) will operate on the root project, .RE .P This value is not exported to the environment for child processes\. +.SS \fBworkspaces\-update\fP +.RS 0 +.IP \(bu 2 +Default: true +.IP \(bu 2 +Type: Boolean + +.RE +.P +If set to true, the npm cli will run an update after operations that may +possibly change the workspaces installed to the \fBnode_modules\fP folder\. .SS \fBinclude\-workspace\-root\fP .RS 0 .IP \(bu 2 diff --git a/deps/npm/man/man1/npm-view.1 b/deps/npm/man/man1/npm-view.1 index dd0ac192d2fac2..f255dc4edb4a20 100644 --- a/deps/npm/man/man1/npm-view.1 +++ b/deps/npm/man/man1/npm-view.1 @@ -7,7 +7,7 @@ .nf npm view [<@scope>/][@] [[\.subfield]\.\.\.] -aliases: v, info, show +aliases: info, show, v .fi .RE .SS Description diff --git a/deps/npm/man/man1/npm.1 b/deps/npm/man/man1/npm.1 index 3b5d8e9e336e51..cabc07a0110a85 100644 --- a/deps/npm/man/man1/npm.1 +++ b/deps/npm/man/man1/npm.1 @@ -4,7 +4,7 @@ .SS Synopsis .SS Version .P -8\.5\.5 +8\.6\.0 .SS Description .P npm is the package manager for the Node JavaScript platform\. It puts diff --git a/deps/npm/man/man7/config.7 b/deps/npm/man/man7/config.7 index 23150ebadfbd90..e5e112c5ab0a5e 100644 --- a/deps/npm/man/man7/config.7 +++ b/deps/npm/man/man7/config.7 @@ -1088,6 +1088,17 @@ Any logs of a higher level than the setting are shown\. The default is "notice"\. .P See also the \fBforeground\-scripts\fP config\. +.SS \fBlogs\-dir\fP +.RS 0 +.IP \(bu 2 +Default: A directory named \fB_logs\fP inside the cache +.IP \(bu 2 +Type: null or Path + +.RE +.P +The location of npm's log directory\. See npm help \fBlogging\fP +for more information\. .SS \fBlogs\-max\fP .RS 0 .IP \(bu 2 @@ -1098,6 +1109,8 @@ Type: Number .RE .P The maximum number of log files to store\. +.P +If set to 0, no log files will be written for the current run\. .SS \fBlong\fP .RS 0 .IP \(bu 2 @@ -1696,9 +1709,9 @@ Type: Boolean .RE .P -If true, writes an \fBnpm\-debug\fP log to \fB_logs\fP and timing information to -\fB_timing\.json\fP, both in your cache, even if the command completes -successfully\. \fB_timing\.json\fP is a newline delimited list of JSON objects\. +If true, writes a debug log to \fBlogs\-dir\fP and timing information to +\fB_timing\.json\fP in the cache, even if the command completes successfully\. +\fB_timing\.json\fP is a newline delimited list of JSON objects\. .P You can quickly view it with this json \fIhttps://npm\.im/json\fR command line: \fBnpm exec \-\- json \-g < ~/\.npm/_timing\.json\fP\|\. @@ -1903,6 +1916,17 @@ other things (test, exec, publish, etc\.) will operate on the root project, .RE .P This value is not exported to the environment for child processes\. +.SS \fBworkspaces\-update\fP +.RS 0 +.IP \(bu 2 +Default: true +.IP \(bu 2 +Type: Boolean + +.RE +.P +If set to true, the npm cli will run an update after operations that may +possibly change the workspaces installed to the \fBnode_modules\fP folder\. .SS \fByes\fP .RS 0 .IP \(bu 2 diff --git a/deps/npm/man/man7/logging.7 b/deps/npm/man/man7/logging.7 index 06eb4c6a79445c..c410678f5daad7 100644 --- a/deps/npm/man/man7/logging.7 +++ b/deps/npm/man/man7/logging.7 @@ -1,9 +1,19 @@ .TH "LOGGING" "7" "March 2022" "" "" .SH "NAME" -\fBLogging\fR \- Why, What & How we Log +\fBLogging\fR \- Why, What & How We Log .SS Description .P The \fBnpm\fP CLI has various mechanisms for showing different levels of information back to end\-users for certain commands, configurations & environments\. +.SS Setting Log File Location +.P +All logs are written to a debug log, with the path to that file printed if the execution of a command fails\. +.P +The default location of the logs directory is a directory named \fB_logs\fP inside the npm cache\. This can be changed +with the \fBlogs\-dir\fP config option\. +.P +Log files will be removed from the \fBlogs\-dir\fP when the number of log files exceeds \fBlogs\-max\fP, with the oldest logs being deleted first\. +.P +To turn off logs completely set \fB\-\-logs\-max=0\fP\|\. .SS Setting Log Levels .SS \fBloglevel\fP .P @@ -33,8 +43,6 @@ The default value of \fBloglevel\fP is \fB"notice"\fP but there are several leve .RE .P All logs pertaining to a level proceeding the current setting will be shown\. -.P -All logs are written to a debug log, with the path to that file printed if the execution of a command fails\. .SS Aliases .P The log levels listed above have various corresponding aliases, including: @@ -60,12 +68,36 @@ The log levels listed above have various corresponding aliases, including: .SS \fBforeground\-scripts\fP .P The \fBnpm\fP CLI began hiding the output of lifecycle scripts for \fBnpm install\fP as of \fBv7\fP\|\. Notably, this means you will not see logs/output from packages that may be using "install scripts" to display information back to you or from your own project's scripts defined in \fBpackage\.json\fP\|\. If you'd like to change this behavior & log this output you can set \fBforeground\-scripts\fP to \fBtrue\fP\|\. +.SS Timing Information +.P +The \fB\-\-timing\fP config can be set which does two things: +.RS 0 +.IP 1. 3 +Always shows the full path to the debug log regardless of command exit status +.IP 2. 3 +Write timing information to a timing file in the cache or \fBlogs\-dir\fP + +.RE +.P +This file is a newline delimited list of JSON objects that can be inspected to see timing data for each task in a \fBnpm\fP CLI run\. .SS Registry Response Headers .SS \fBnpm\-notice\fP .P The \fBnpm\fP CLI reads from & logs any \fBnpm\-notice\fP headers that are returned from the configured registry\. This mechanism can be used by third\-party registries to provide useful information when network\-dependent requests occur\. .P This header is not cached, and will not be logged if the request is served from the cache\. +.SS Logs and Sensitive Information +.P +The \fBnpm\fP CLI makes a best effort to redact the following from terminal output and log files: +.RS 0 +.IP \(bu 2 +Passwords inside basic auth URLs +.IP \(bu 2 +npm tokens + +.RE +.P +However, this behavior should not be relied on to keep all possible sensitive information redacted\. If you are concerned about secrets in your log file or terminal output, you can use \fB\-\-loglevel=silent\fP and \fB\-\-logs\-max=0\fP to ensure no logs are written to your terminal or filesystem\. .SS See also .RS 0 .IP \(bu 2 diff --git a/deps/npm/man/man7/scripts.7 b/deps/npm/man/man7/scripts.7 index 8be91e805dcfa9..722faa7b165c96 100644 --- a/deps/npm/man/man7/scripts.7 +++ b/deps/npm/man/man7/scripts.7 @@ -438,7 +438,7 @@ Don't prefix your script commands with "sudo"\. If root permissions are required for some reason, then it'll fail with that error, and the user will sudo the npm command in question\. .IP \(bu 2 -Don't use \fBinstall\fP\|\. Use a \fB\|\.gyp\fP file for compilation, and \fBprepublish\fP +Don't use \fBinstall\fP\|\. Use a \fB\|\.gyp\fP file for compilation, and \fBprepare\fP for anything else\. You should almost never have to explicitly set a preinstall or install script\. If you are doing this, please consider if there is another option\. The only valid use of \fBinstall\fP or \fBpreinstall\fP diff --git a/deps/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js b/deps/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js index 3f001f9e9eb100..f3166c37e14753 100644 --- a/deps/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js +++ b/deps/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js @@ -355,6 +355,21 @@ Try using the package name instead, e.g: }) .then(tree => { + // search the virtual tree for invalid edges, if any are found add their source to + // the depsQueue so that we'll fix it later + depth({ + tree, + getChildren: (node) => [...node.edgesOut.values()].map(edge => edge.to), + filter: node => node, + visit: node => { + for (const edge of node.edgesOut.values()) { + if (!edge.valid) { + this[_depsQueue].push(node) + break // no need to continue the loop after the first hit + } + } + }, + }) // null the virtual tree, because we're about to hack away at it // if you want another one, load another copy. this.idealTree = tree @@ -743,6 +758,12 @@ This is a one-time fix-up, please be patient... continue } + // if the node's location isn't within node_modules then this is actually + // a link target, so skip it. the link node itself will be queued later. + if (!node.location.startsWith('node_modules')) { + continue + } + queue.push(async () => { log.silly('inflate', node.location) const { resolved, version, path, name, location, integrity } = node @@ -750,8 +771,7 @@ This is a one-time fix-up, please be patient... const useResolved = resolved && ( !version || resolved.startsWith('file:') ) - const id = useResolved ? resolved - : version || `file:${node.path}` + const id = useResolved ? resolved : version const spec = npa.resolve(name, id, dirname(path)) const t = `idealTree:inflate:${location}` this.addTracker(t) diff --git a/deps/npm/node_modules/@npmcli/arborist/lib/arborist/load-virtual.js b/deps/npm/node_modules/@npmcli/arborist/lib/arborist/load-virtual.js index 4d65e3da6f6831..8a41e7686e7e19 100644 --- a/deps/npm/node_modules/@npmcli/arborist/lib/arborist/load-virtual.js +++ b/deps/npm/node_modules/@npmcli/arborist/lib/arborist/load-virtual.js @@ -79,7 +79,7 @@ module.exports = cls => class VirtualLoader extends cls { async [loadRoot] (s) { const pj = this.path + '/package.json' const pkg = await rpj(pj).catch(() => s.data.packages['']) || {} - return this[loadWorkspaces](this[loadNode]('', pkg)) + return this[loadWorkspaces](this[loadNode]('', pkg, true)) } async [loadFromShrinkwrap] (s, root) { @@ -264,7 +264,7 @@ module.exports = cls => class VirtualLoader extends cls { } } - [loadNode] (location, sw) { + [loadNode] (location, sw, loadOverrides) { const p = this.virtualTree ? this.virtualTree.realpath : this.path const path = resolve(p, location) // shrinkwrap doesn't include package name unless necessary @@ -290,6 +290,7 @@ module.exports = cls => class VirtualLoader extends cls { optional, devOptional, peer, + loadOverrides, }) // cast to boolean because they're undefined in the lock file when false node.extraneous = !!sw.extraneous diff --git a/deps/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js b/deps/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js index acb889cebca3dd..7fd0ca7f607403 100644 --- a/deps/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js +++ b/deps/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js @@ -1308,7 +1308,7 @@ module.exports = cls => class Reifier extends cls { // to only names that are found in this list const retrieveUpdatedNodes = names => { const filterDirectDependencies = node => - !node.isRoot && node.resolveParent.isRoot + !node.isRoot && node.resolveParent && node.resolveParent.isRoot && (!names || names.includes(node.name)) && exactVersion(node) // skip update for exact ranges diff --git a/deps/npm/node_modules/@npmcli/arborist/lib/tracker.js b/deps/npm/node_modules/@npmcli/arborist/lib/tracker.js index c2a456e4832cc6..42c401e8799e85 100644 --- a/deps/npm/node_modules/@npmcli/arborist/lib/tracker.js +++ b/deps/npm/node_modules/@npmcli/arborist/lib/tracker.js @@ -1,10 +1,12 @@ const _progress = Symbol('_progress') const _onError = Symbol('_onError') +const _setProgress = Symbol('_setProgess') const npmlog = require('npmlog') module.exports = cls => class Tracker extends cls { constructor (options = {}) { super(options) + this[_setProgress] = !!options.progress this[_progress] = new Map() } @@ -27,7 +29,7 @@ module.exports = cls => class Tracker extends cls { // 1. no existing tracker, no subsection // Create a new tracker from npmlog // starts progress bar - if (this[_progress].size === 0) { + if (this[_setProgress] && this[_progress].size === 0) { npmlog.enableProgress() } @@ -76,7 +78,7 @@ module.exports = cls => class Tracker extends cls { // remove progress bar if all // trackers are finished - if (this[_progress].size === 0) { + if (this[_setProgress] && this[_progress].size === 0) { npmlog.disableProgress() } } else if (!hasTracker && subsection === null) { @@ -92,7 +94,9 @@ module.exports = cls => class Tracker extends cls { } [_onError] (msg) { - npmlog.disableProgress() + if (this[_setProgress]) { + npmlog.disableProgress() + } throw new Error(msg) } } diff --git a/deps/npm/node_modules/@npmcli/arborist/package.json b/deps/npm/node_modules/@npmcli/arborist/package.json index 258234b977ea81..8913b4449e2381 100644 --- a/deps/npm/node_modules/@npmcli/arborist/package.json +++ b/deps/npm/node_modules/@npmcli/arborist/package.json @@ -1,6 +1,6 @@ { "name": "@npmcli/arborist", - "version": "5.0.3", + "version": "5.0.4", "description": "Manage node_modules trees", "dependencies": { "@isaacs/string-locale-compare": "^1.1.0", @@ -39,7 +39,8 @@ "walk-up-path": "^1.0.0" }, "devDependencies": { - "@npmcli/template-oss": "^2.4.2", + "@npmcli/eslint-config": "^3.0.1", + "@npmcli/template-oss": "3.2.2", "benchmark": "^2.1.4", "chalk": "^4.1.0", "minify-registry-metadata": "^2.1.0", @@ -57,24 +58,24 @@ "postversion": "npm publish", "prepublishOnly": "git push origin --follow-tags", "eslint": "eslint", - "lint": "eslint '**/*.js'", + "lint": "eslint \"**/*.js\"", "lintfix": "npm run lint -- --fix", "benchmark": "node scripts/benchmark.js", "benchclean": "rm -rf scripts/benchmark/*/", "npmclilint": "npmcli-lint", - "postlint": "npm-template-check", - "template-copy": "npm-template-copy --force" + "postlint": "template-oss-check", + "template-oss-apply": "template-oss-apply --force" }, "repository": { "type": "git", - "url": "https://github.com/npm/cli", + "url": "https://github.com/npm/cli.git", "directory": "workspaces/arborist" }, "author": "GitHub Inc.", "license": "ISC", "files": [ - "bin", - "lib" + "bin/", + "lib/" ], "main": "lib/index.js", "bin": { @@ -96,13 +97,10 @@ "timeout": "360" }, "engines": { - "node": "^12.13.0 || ^14.15.0 || >=16" + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" }, - "eslintIgnore": [ - "test/fixtures/", - "!test/fixtures/*.js" - ], "templateOSS": { - "version": "2.9.2" + "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", + "version": "3.2.2" } } diff --git a/deps/npm/node_modules/@npmcli/fs/lib/common/owner-sync.js b/deps/npm/node_modules/@npmcli/fs/lib/common/owner-sync.js new file mode 100644 index 00000000000000..2055c4b21dec90 --- /dev/null +++ b/deps/npm/node_modules/@npmcli/fs/lib/common/owner-sync.js @@ -0,0 +1,92 @@ +const { dirname, resolve } = require('path') + +const fileURLToPath = require('./file-url-to-path/index.js') +const fs = require('../fs.js') + +// given a path, find the owner of the nearest parent +const find = (path) => { + // if we have no getuid, permissions are irrelevant on this platform + if (!process.getuid) { + return {} + } + + // fs methods accept URL objects with a scheme of file: so we need to unwrap + // those into an actual path string before we can resolve it + const resolved = path != null && path.href && path.origin + ? resolve(fileURLToPath(path)) + : resolve(path) + + let stat + + try { + stat = fs.lstatSync(resolved) + } finally { + // if we got a stat, return its contents + if (stat) { + return { uid: stat.uid, gid: stat.gid } + } + + // try the parent directory + if (resolved !== dirname(resolved)) { + return find(dirname(resolved)) + } + + // no more parents, never got a stat, just return an empty object + return {} + } +} + +// given a path, uid, and gid update the ownership of the path if necessary +const update = (path, uid, gid) => { + // nothing to update, just exit + if (uid === undefined && gid === undefined) { + return + } + + try { + // see if the permissions are already the same, if they are we don't + // need to do anything, so return early + const stat = fs.statSync(path) + if (uid === stat.uid && gid === stat.gid) { + return + } + } catch (err) {} + + try { + fs.chownSync(path, uid, gid) + } catch (err) {} +} + +// accepts a `path` and the `owner` property of an options object and normalizes +// it into an object with numerical `uid` and `gid` +const validate = (path, input) => { + let uid + let gid + + if (typeof input === 'string' || typeof input === 'number') { + uid = input + gid = input + } else if (input && typeof input === 'object') { + uid = input.uid + gid = input.gid + } + + if (uid === 'inherit' || gid === 'inherit') { + const owner = find(path) + if (uid === 'inherit') { + uid = owner.uid + } + + if (gid === 'inherit') { + gid = owner.gid + } + } + + return { uid, gid } +} + +module.exports = { + find, + update, + validate, +} diff --git a/deps/npm/node_modules/@npmcli/fs/lib/copy-file.js b/deps/npm/node_modules/@npmcli/fs/lib/copy-file.js index d9875aba11f793..8888266d627f08 100644 --- a/deps/npm/node_modules/@npmcli/fs/lib/copy-file.js +++ b/deps/npm/node_modules/@npmcli/fs/lib/copy-file.js @@ -1,22 +1,16 @@ const fs = require('./fs.js') const getOptions = require('./common/get-options.js') -const owner = require('./common/owner.js') +const withOwner = require('./with-owner.js') const copyFile = async (src, dest, opts) => { const options = getOptions(opts, { - copy: ['mode', 'owner'], + copy: ['mode'], wrap: 'mode', }) - const { uid, gid } = await owner.validate(dest, options.owner) - // the node core method as of 16.5.0 does not support the mode being in an // object, so we have to pass the mode value directly - const result = await fs.copyFile(src, dest, options.mode) - - await owner.update(dest, uid, gid) - - return result + return withOwner(dest, () => fs.copyFile(src, dest, options.mode), opts) } module.exports = copyFile diff --git a/deps/npm/node_modules/@npmcli/fs/lib/fs.js b/deps/npm/node_modules/@npmcli/fs/lib/fs.js index 29e5fb57356836..457da10eed03ee 100644 --- a/deps/npm/node_modules/@npmcli/fs/lib/fs.js +++ b/deps/npm/node_modules/@npmcli/fs/lib/fs.js @@ -1,8 +1,14 @@ const fs = require('fs') const promisify = require('@gar/promisify') -// this module returns the core fs module wrapped in a proxy that promisifies +const isLower = (s) => s === s.toLowerCase() && s !== s.toUpperCase() + +const fsSync = Object.fromEntries(Object.entries(fs).filter(([k, v]) => + typeof v === 'function' && (k.endsWith('Sync') || !isLower(k[0])) +)) + +// this module returns the core fs async fns wrapped in a proxy that promisifies // method calls within the getter. we keep it in a separate module so that the // overridden methods have a consistent way to get to promisified fs methods -// without creating a circular dependency -module.exports = promisify(fs) +// without creating a circular dependency. the ctors and sync methods are kept untouched +module.exports = { ...promisify(fs), ...fsSync } diff --git a/deps/npm/node_modules/@npmcli/fs/lib/index.js b/deps/npm/node_modules/@npmcli/fs/lib/index.js index e40d748a7da607..43892df5fee076 100644 --- a/deps/npm/node_modules/@npmcli/fs/lib/index.js +++ b/deps/npm/node_modules/@npmcli/fs/lib/index.js @@ -6,5 +6,7 @@ module.exports = { mkdtemp: require('./mkdtemp.js'), rm: require('./rm/index.js'), withTempDir: require('./with-temp-dir.js'), + withOwner: require('./with-owner.js'), + withOwnerSync: require('./with-owner-sync.js'), writeFile: require('./write-file.js'), } diff --git a/deps/npm/node_modules/@npmcli/fs/lib/mkdir/index.js b/deps/npm/node_modules/@npmcli/fs/lib/mkdir/index.js index 04ff4479034545..e2691042daa26f 100644 --- a/deps/npm/node_modules/@npmcli/fs/lib/mkdir/index.js +++ b/deps/npm/node_modules/@npmcli/fs/lib/mkdir/index.js @@ -1,7 +1,7 @@ const fs = require('../fs.js') const getOptions = require('../common/get-options.js') const node = require('../common/node.js') -const owner = require('../common/owner.js') +const withOwner = require('../with-owner.js') const polyfill = require('./polyfill.js') @@ -12,21 +12,18 @@ const useNative = node.satisfies('>=10.12.0') // extends mkdir with the ability to specify an owner of the new dir const mkdir = async (path, opts) => { const options = getOptions(opts, { - copy: ['mode', 'recursive', 'owner'], + copy: ['mode', 'recursive'], wrap: 'mode', }) - const { uid, gid } = await owner.validate(path, options.owner) // the polyfill is tested separately from this module, no need to hack // process.version to try to trigger it just for coverage // istanbul ignore next - const result = useNative - ? await fs.mkdir(path, options) - : await polyfill(path, options) - - await owner.update(path, uid, gid) - - return result + return withOwner( + path, + () => useNative ? fs.mkdir(path, options) : polyfill(path, options), + opts + ) } module.exports = mkdir diff --git a/deps/npm/node_modules/@npmcli/fs/lib/mkdtemp.js b/deps/npm/node_modules/@npmcli/fs/lib/mkdtemp.js index b7f078029d1111..60b12a788de90b 100644 --- a/deps/npm/node_modules/@npmcli/fs/lib/mkdtemp.js +++ b/deps/npm/node_modules/@npmcli/fs/lib/mkdtemp.js @@ -2,11 +2,11 @@ const { dirname, sep } = require('path') const fs = require('./fs.js') const getOptions = require('./common/get-options.js') -const owner = require('./common/owner.js') +const withOwner = require('./with-owner.js') const mkdtemp = async (prefix, opts) => { const options = getOptions(opts, { - copy: ['encoding', 'owner'], + copy: ['encoding'], wrap: 'encoding', }) @@ -16,13 +16,8 @@ const mkdtemp = async (prefix, opts) => { // /tmp -> /tmpABCDEF, infers from / // /tmp/ -> /tmp/ABCDEF, infers from /tmp const root = prefix.endsWith(sep) ? prefix : dirname(prefix) - const { uid, gid } = await owner.validate(root, options.owner) - const result = await fs.mkdtemp(prefix, options) - - await owner.update(result, uid, gid) - - return result + return withOwner(root, () => fs.mkdtemp(prefix, options), opts) } module.exports = mkdtemp diff --git a/deps/npm/node_modules/@npmcli/fs/lib/with-owner-sync.js b/deps/npm/node_modules/@npmcli/fs/lib/with-owner-sync.js new file mode 100644 index 00000000000000..3597d1c810475a --- /dev/null +++ b/deps/npm/node_modules/@npmcli/fs/lib/with-owner-sync.js @@ -0,0 +1,21 @@ +const getOptions = require('./common/get-options.js') +const owner = require('./common/owner-sync.js') + +const withOwnerSync = (path, fn, opts) => { + const options = getOptions(opts, { + copy: ['owner'], + }) + + const { uid, gid } = owner.validate(path, options.owner) + + const result = fn({ uid, gid }) + + owner.update(path, uid, gid) + if (typeof result === 'string') { + owner.update(result, uid, gid) + } + + return result +} + +module.exports = withOwnerSync diff --git a/deps/npm/node_modules/@npmcli/fs/lib/with-owner.js b/deps/npm/node_modules/@npmcli/fs/lib/with-owner.js new file mode 100644 index 00000000000000..a679102883dbb3 --- /dev/null +++ b/deps/npm/node_modules/@npmcli/fs/lib/with-owner.js @@ -0,0 +1,21 @@ +const getOptions = require('./common/get-options.js') +const owner = require('./common/owner.js') + +const withOwner = async (path, fn, opts) => { + const options = getOptions(opts, { + copy: ['owner'], + }) + + const { uid, gid } = await owner.validate(path, options.owner) + + const result = await fn({ uid, gid }) + + await Promise.all([ + owner.update(path, uid, gid), + typeof result === 'string' ? owner.update(result, uid, gid) : null, + ]) + + return result +} + +module.exports = withOwner diff --git a/deps/npm/node_modules/@npmcli/fs/lib/with-temp-dir.js b/deps/npm/node_modules/@npmcli/fs/lib/with-temp-dir.js index 353d5555d10f69..ac9ebb714b9892 100644 --- a/deps/npm/node_modules/@npmcli/fs/lib/with-temp-dir.js +++ b/deps/npm/node_modules/@npmcli/fs/lib/with-temp-dir.js @@ -27,7 +27,7 @@ const withTempDir = async (root, fn, opts) => { try { await rm(target, { force: true, recursive: true }) - } catch (err) {} + } catch {} if (err) { throw err diff --git a/deps/npm/node_modules/@npmcli/fs/lib/write-file.js b/deps/npm/node_modules/@npmcli/fs/lib/write-file.js index 01de531d980c4d..ff900571a1f28b 100644 --- a/deps/npm/node_modules/@npmcli/fs/lib/write-file.js +++ b/deps/npm/node_modules/@npmcli/fs/lib/write-file.js @@ -1,19 +1,14 @@ const fs = require('./fs.js') const getOptions = require('./common/get-options.js') -const owner = require('./common/owner.js') +const withOwner = require('./with-owner.js') const writeFile = async (file, data, opts) => { const options = getOptions(opts, { - copy: ['encoding', 'mode', 'flag', 'signal', 'owner'], + copy: ['encoding', 'mode', 'flag', 'signal'], wrap: 'encoding', }) - const { uid, gid } = await owner.validate(file, options.owner) - const result = await fs.writeFile(file, data, options) - - await owner.update(file, uid, gid) - - return result + return withOwner(file, () => fs.writeFile(file, data, options), opts) } module.exports = writeFile diff --git a/deps/npm/node_modules/@npmcli/fs/package.json b/deps/npm/node_modules/@npmcli/fs/package.json index cb64ac82023f2a..799bf514f200b5 100644 --- a/deps/npm/node_modules/@npmcli/fs/package.json +++ b/deps/npm/node_modules/@npmcli/fs/package.json @@ -1,11 +1,11 @@ { "name": "@npmcli/fs", - "version": "1.1.0", + "version": "2.1.0", "description": "filesystem utilities for the npm cli", "main": "lib/index.js", "files": [ - "bin", - "lib" + "bin/", + "lib/" ], "scripts": { "preversion": "npm test", @@ -14,11 +14,16 @@ "snap": "tap", "test": "tap", "npmclilint": "npmcli-lint", - "lint": "eslint '**/*.js'", + "lint": "eslint \"**/*.js\"", "lintfix": "npm run lint -- --fix", "posttest": "npm run lint", "postsnap": "npm run lintfix --", - "postlint": "npm-template-check" + "postlint": "template-oss-check", + "template-oss-apply": "template-oss-apply --force" + }, + "repository": { + "type": "git", + "url": "https://github.com/npm/fs.git" }, "keywords": [ "npm", @@ -27,15 +32,19 @@ "author": "GitHub Inc.", "license": "ISC", "devDependencies": { - "@npmcli/template-oss": "^2.3.1", - "tap": "^15.0.9" + "@npmcli/eslint-config": "^3.0.1", + "@npmcli/template-oss": "3.1.2", + "tap": "^15.1.6" }, "dependencies": { - "@gar/promisify": "^1.0.1", + "@gar/promisify": "^1.1.3", "semver": "^7.3.5" }, - "templateVersion": "2.3.1", "engines": { - "node": "^12.13.0 || ^14.15.0 || >=16" + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + }, + "templateOSS": { + "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", + "version": "3.1.2" } } diff --git a/deps/npm/node_modules/builtins/History.md b/deps/npm/node_modules/builtins/History.md deleted file mode 100644 index 0eb45c420775eb..00000000000000 --- a/deps/npm/node_modules/builtins/History.md +++ /dev/null @@ -1,39 +0,0 @@ - -0.0.7 / 2014-09-01 -================== - - * update .repository - -0.0.6 / 2014-09-01 -================== - - * add travis - * add test script - * add constants - -0.0.5 / 2014-06-27 -================== - - * add module - * publish to public npm - -0.0.4 / 2014-04-25 -================== - - * add timers - -0.0.3 / 2014-02-22 -================== - - * add buffer - -0.0.2 / 2014-02-11 -================== - - * add assert - -0.0.1 / 2014-02-11 -================== - - * add main - * initial commit diff --git a/deps/npm/node_modules/builtins/Readme.md b/deps/npm/node_modules/builtins/Readme.md index 96f4b1f6c4a83e..b1c0007d6f5e4a 100644 --- a/deps/npm/node_modules/builtins/Readme.md +++ b/deps/npm/node_modules/builtins/Readme.md @@ -1,18 +1,39 @@ - # builtins - List of node.js [builtin modules](http://nodejs.org/api/). +[![CI](https://github.com/juliangruber/builtins/actions/workflows/ci.yml/badge.svg)](https://github.com/juliangruber/builtins/actions/workflows/ci.yml) + +List of node.js [builtin modules](http://nodejs.org/api/). + +## Usage + +```js +const builtins = require('builtins') +``` + +Get list of core modules for current Node.js version: + +```js +assert(builtins().includes('http')) +``` - [![build status](https://secure.travis-ci.org/juliangruber/builtins.svg)](http://travis-ci.org/juliangruber/builtins) +Get list of core modules for specific Node.js version: + +```js +assert(builtins({ version: '6.0.0' }).includes('http')) +``` -## Example +Get list of core modules present in one or mode Node.js versions: ```js -var builtins = require('builtins'); +assert(builtins({ version: '*' }).includes('worker_threads')) +``` -assert(builtins.indexOf('http') > -1); +Add experimental modules to the list: + +```js +assert(builtins({ experimental: true }).includes('wasi')) ``` ## License - MIT +MIT diff --git a/deps/npm/node_modules/builtins/builtins.json b/deps/npm/node_modules/builtins/builtins.json deleted file mode 100644 index 45c05225644bde..00000000000000 --- a/deps/npm/node_modules/builtins/builtins.json +++ /dev/null @@ -1,35 +0,0 @@ -[ - "assert", - "buffer", - "child_process", - "cluster", - "console", - "constants", - "crypto", - "dgram", - "dns", - "domain", - "events", - "fs", - "http", - "https", - "module", - "net", - "os", - "path", - "process", - "punycode", - "querystring", - "readline", - "repl", - "stream", - "string_decoder", - "timers", - "tls", - "tty", - "url", - "util", - "v8", - "vm", - "zlib" -] diff --git a/deps/npm/node_modules/builtins/index.js b/deps/npm/node_modules/builtins/index.js new file mode 100644 index 00000000000000..3c781da7354192 --- /dev/null +++ b/deps/npm/node_modules/builtins/index.js @@ -0,0 +1,79 @@ +'use strict' + +const semver = require('semver') + +const permanentModules = [ + 'assert', + 'buffer', + 'child_process', + 'cluster', + 'console', + 'constants', + 'crypto', + 'dgram', + 'dns', + 'domain', + 'events', + 'fs', + 'http', + 'https', + 'module', + 'net', + 'os', + 'path', + 'punycode', + 'querystring', + 'readline', + 'repl', + 'stream', + 'string_decoder', + 'sys', + 'timers', + 'tls', + 'tty', + 'url', + 'util', + 'vm', + 'zlib' +] + +const versionLockedModules = { + freelist: '<6.0.0', + v8: '>=1.0.0', + process: '>=1.1.0', + inspector: '>=8.0.0', + async_hooks: '>=8.1.0', + http2: '>=8.4.0', + perf_hooks: '>=8.5.0', + trace_events: '>=10.0.0', + worker_threads: '>=12.0.0' +} + +const experimentalModules = { + worker_threads: '>=10.5.0', + wasi: '>=12.16.0', + diagnostics_channel: '^14.17.0 || >=15.1.0' +} + +module.exports = ({ version = process.version, experimental = false } = {}) => { + const builtins = [...permanentModules] + + for (const [name, semverRange] of Object.entries(versionLockedModules)) { + if (version === '*' || semver.satisfies(version, semverRange)) { + builtins.push(name) + } + } + + if (experimental) { + for (const [name, semverRange] of Object.entries(experimentalModules)) { + if ( + !builtins.includes(name) && + (version === '*' || semver.satisfies(version, semverRange)) + ) { + builtins.push(name) + } + } + } + + return builtins +} diff --git a/deps/npm/node_modules/builtins/package.json b/deps/npm/node_modules/builtins/package.json index 819996532d5ffa..9c6c108d3ff5e7 100644 --- a/deps/npm/node_modules/builtins/package.json +++ b/deps/npm/node_modules/builtins/package.json @@ -1,14 +1,20 @@ { "name": "builtins", - "version": "1.0.3", + "version": "5.0.0", "description": "List of node.js builtin modules", "repository": "juliangruber/builtins", "license": "MIT", - "main": "builtins.json", - "publishConfig": { - "registry": "https://registry.npmjs.org" - }, + "main": "index.js", + "files": [], "scripts": { - "test": "node test.js" + "test": "prettier-standard && standard && node test.js" + }, + "dependencies": { + "semver": "^7.0.0" + }, + "devDependencies": { + "node-core-test": "^1.1.1", + "prettier-standard": "^15.0.1", + "standard": "^14.3.4" } } diff --git a/deps/npm/node_modules/builtins/test.js b/deps/npm/node_modules/builtins/test.js deleted file mode 100644 index ffbe8389c14d6c..00000000000000 --- a/deps/npm/node_modules/builtins/test.js +++ /dev/null @@ -1,5 +0,0 @@ -var builtins = require('./builtins'); - -builtins.forEach(function(name){ - require(name); -}); diff --git a/deps/npm/node_modules/cacache/package.json b/deps/npm/node_modules/cacache/package.json index c240fa446df48e..edae9a4f995b4e 100644 --- a/deps/npm/node_modules/cacache/package.json +++ b/deps/npm/node_modules/cacache/package.json @@ -1,6 +1,6 @@ { "name": "cacache", - "version": "16.0.2", + "version": "16.0.3", "cache-version": { "content": "2", "index": "5" @@ -8,8 +8,8 @@ "description": "Fast, fault-tolerant, cross-platform, disk-based, data-agnostic, content-addressable cache.", "main": "lib/index.js", "files": [ - "bin", - "lib" + "bin/", + "lib/" ], "scripts": { "benchmarks": "node test/benchmarks", @@ -20,15 +20,18 @@ "snap": "tap", "coverage": "tap", "test-docker": "docker run -it --rm --name pacotest -v \"$PWD\":/tmp -w /tmp node:latest npm test", - "lint": "eslint '**/*.js'", + "lint": "eslint \"**/*.js\"", "npmclilint": "npmcli-lint", "lintfix": "npm run lint -- --fix", "postsnap": "npm run lintfix --", - "postlint": "npm-template-check", - "template-copy": "npm-template-copy --force", - "posttest": "npm run lint" + "postlint": "template-oss-check", + "posttest": "npm run lint", + "template-oss-apply": "template-oss-apply --force" + }, + "repository": { + "type": "git", + "url": "https://github.com/npm/cacache.git" }, - "repository": "https://github.com/npm/cacache", "keywords": [ "cache", "caching", @@ -46,13 +49,13 @@ ], "license": "ISC", "dependencies": { - "@npmcli/fs": "^1.0.0", + "@npmcli/fs": "^2.1.0", "@npmcli/move-file": "^1.1.2", "chownr": "^2.0.0", "fs-minipass": "^2.1.0", "glob": "^7.2.0", "infer-owner": "^1.0.4", - "lru-cache": "^7.5.1", + "lru-cache": "^7.7.1", "minipass": "^3.1.6", "minipass-collect": "^1.0.2", "minipass-flush": "^1.0.5", @@ -66,23 +69,25 @@ "unique-filename": "^1.1.1" }, "devDependencies": { - "@npmcli/template-oss": "^2.9.2", + "@npmcli/eslint-config": "^3.0.1", + "@npmcli/template-oss": "3.1.2", "benchmark": "^2.1.4", "chalk": "^4.1.2", "require-inject": "^1.4.4", "tacks": "^1.3.0", - "tap": "^15.0.9" + "tap": "^16.0.0" }, "tap": { "100": true, "test-regex": "test/[^/]*.js" }, "engines": { - "node": "^12.13.0 || ^14.15.0 || >=16" + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" }, "templateOSS": { + "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", "windowsCI": false, - "version": "2.9.2" + "version": "3.1.2" }, "author": "GitHub Inc." } diff --git a/deps/npm/node_modules/debug/package.json b/deps/npm/node_modules/debug/package.json index cb7efa8eec32da..3bcdc242fc0675 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.3", + "version": "4.3.4", "repository": { "type": "git", "url": "git://github.com/debug-js/debug.git" diff --git a/deps/npm/node_modules/debug/src/common.js b/deps/npm/node_modules/debug/src/common.js index 6d571d2844dd95..e3291b20faa1a6 100644 --- a/deps/npm/node_modules/debug/src/common.js +++ b/deps/npm/node_modules/debug/src/common.js @@ -179,7 +179,7 @@ function setup(env) { namespaces = split[i].replace(/\*/g, '.*?'); if (namespaces[0] === '-') { - createDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$')); + createDebug.skips.push(new RegExp('^' + namespaces.slice(1) + '$')); } else { createDebug.names.push(new RegExp('^' + namespaces + '$')); } diff --git a/deps/npm/node_modules/gauge/lib/index.js b/deps/npm/node_modules/gauge/lib/index.js index ce9ba7d638ee24..37fc5ac60a16fd 100644 --- a/deps/npm/node_modules/gauge/lib/index.js +++ b/deps/npm/node_modules/gauge/lib/index.js @@ -91,8 +91,7 @@ Gauge.prototype._computeTheme = function (theme) { if (typeof theme === 'string') { theme = this._themes.getTheme(theme) } else if ( - theme && - (Object.keys(theme).length === 0 || theme.hasUnicode != null || theme.hasColor != null) + 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 diff --git a/deps/npm/node_modules/gauge/package.json b/deps/npm/node_modules/gauge/package.json index 431d906a9e481c..bce3e68a33f699 100644 --- a/deps/npm/node_modules/gauge/package.json +++ b/deps/npm/node_modules/gauge/package.json @@ -1,23 +1,23 @@ { "name": "gauge", - "version": "4.0.3", + "version": "4.0.4", "description": "A terminal based horizontal gauge", "main": "lib", "scripts": { "test": "tap", - "lint": "eslint '**/*.js'", - "postlint": "npm-template-check", + "lint": "eslint \"**/*.js\"", + "postlint": "template-oss-check", "lintfix": "npm run lint -- --fix", "preversion": "npm test", "postversion": "npm publish", "prepublishOnly": "git push origin --follow-tags", "snap": "tap", "posttest": "npm run lint", - "template-copy": "npm-template-copy --force" + "template-oss-apply": "template-oss-apply --force" }, "repository": { "type": "git", - "url": "https://github.com/npm/gauge" + "url": "https://github.com/npm/gauge.git" }, "keywords": [ "progressbar", @@ -41,16 +41,17 @@ "wide-align": "^1.1.5" }, "devDependencies": { - "@npmcli/template-oss": "^2.9.2", + "@npmcli/eslint-config": "^3.0.1", + "@npmcli/template-oss": "3.2.0", "readable-stream": "^3.6.0", - "tap": "^15.1.6" + "tap": "^16.0.1" }, "files": [ - "bin", - "lib" + "bin/", + "lib/" ], "engines": { - "node": "^12.13.0 || ^14.15.0 || >=16" + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" }, "tap": { "branches": 79, @@ -59,6 +60,7 @@ "lines": 90 }, "templateOSS": { - "version": "2.9.2" + "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", + "version": "3.2.0" } } diff --git a/deps/npm/node_modules/init-package-json/lib/default-input.js b/deps/npm/node_modules/init-package-json/lib/default-input.js index 0003472975760b..fe5abfdd85e45d 100644 --- a/deps/npm/node_modules/init-package-json/lib/default-input.js +++ b/deps/npm/node_modules/init-package-json/lib/default-input.js @@ -17,8 +17,8 @@ function niceName (n) { function readDeps (test, excluded) { return function (cb) { - fs.readdir('node_modules', function (er, dir) { - if (er) { + fs.readdir('node_modules', function (readdirErr, dir) { + if (readdirErr) { return cb() } var deps = {} @@ -35,8 +35,8 @@ function readDeps (test, excluded) { } var dp = path.join(dirname, 'node_modules', d, 'package.json') - fs.readFile(dp, 'utf8', function (er, p) { - if (er) { + fs.readFile(dp, 'utf8', function (readFileErr, p) { + if (readFileErr) { return next() } try { @@ -108,11 +108,11 @@ var version = package.version || '1.0.0' exports.version = yes ? version : - prompt('version', version, function (version) { - if (semver.valid(version)) { - return version + prompt('version', version, function (promptedVersion) { + if (semver.valid(promptedVersion)) { + return promptedVersion } - var er = new Error('Invalid version: "' + version + '"') + var er = new Error('Invalid version: "' + promptedVersion + '"') er.notValid = true return er }) @@ -128,8 +128,8 @@ if (!package.main) { f = [] } - f = f.filter(function (f) { - return f.match(/\.js$/) + f = f.filter(function (filtered) { + return filtered.match(/\.js$/) }) if (f.indexOf('index.js') !== -1) { @@ -261,17 +261,17 @@ if (!package.repository) { } if (!package.keywords) { - exports.keywords = yes ? '' : prompt('keywords', function (s) { - if (!s) { + exports.keywords = yes ? '' : prompt('keywords', function (promptedKeywords) { + if (!promptedKeywords) { return undefined } - if (Array.isArray(s)) { - s = s.join(' ') + if (Array.isArray(promptedKeywords)) { + promptedKeywords = promptedKeywords.join(' ') } - if (typeof s !== 'string') { - return s + if (typeof promptedKeywords !== 'string') { + return promptedKeywords } - return s.split(/[\s,]+/) + return promptedKeywords.split(/[\s,]+/) }) } diff --git a/deps/npm/node_modules/init-package-json/lib/init-package-json.js b/deps/npm/node_modules/init-package-json/lib/init-package-json.js index f13a34ce6ff4e5..230bcd81747bdc 100644 --- a/deps/npm/node_modules/init-package-json/lib/init-package-json.js +++ b/deps/npm/node_modules/init-package-json/lib/init-package-json.js @@ -74,62 +74,62 @@ function init (dir, input, config, cb) { var pz = new PZ(input, ctx) pz.backupFile = def pz.on('error', cb) - pz.on('data', function (data) { - Object.keys(data).forEach(function (k) { - if (data[k] !== undefined && data[k] !== null) { - pkg[k] = data[k] + pz.on('data', function (pzData) { + Object.keys(pzData).forEach(function (k) { + if (pzData[k] !== undefined && pzData[k] !== null) { + pkg[k] = pzData[k] } }) // only do a few of these. // no need for mans or contributors if they're in the files - var es = readJson.extraSet + es = readJson.extraSet readJson.extraSet = es.filter(function (fn) { return fn.name !== 'authors' && fn.name !== 'mans' }) - readJson.extras(packageFile, pkg, function (er, pkg) { - if (er) { - return cb(er, pkg) + readJson.extras(packageFile, pkg, function (extrasErr, pkgWithExtras) { + if (extrasErr) { + return cb(extrasErr, pkgWithExtras) } readJson.extraSet = es - pkg = unParsePeople(pkg) + pkgWithExtras = unParsePeople(pkgWithExtras) // no need for the readme now. - delete pkg.readme - delete pkg.readmeFilename + delete pkgWithExtras.readme + delete pkgWithExtras.readmeFilename // really don't want to have this lying around in the file - delete pkg._id + delete pkgWithExtras._id // ditto - delete pkg.gitHead + delete pkgWithExtras.gitHead // if the repo is empty, remove it. - if (!pkg.repository) { - delete pkg.repository + if (!pkgWithExtras.repository) { + delete pkgWithExtras.repository } // readJson filters out empty descriptions, but init-package-json // traditionally leaves them alone - if (!pkg.description) { - pkg.description = data.description + if (!pkgWithExtras.description) { + pkgWithExtras.description = pzData.description } - var d = JSON.stringify(updateDeps(pkg), null, 2) + '\n' - function write (yes) { - fs.writeFile(packageFile, d, 'utf8', function (er) { - if (!er && yes && !config.get('silent')) { - console.log('Wrote to %s:\n\n%s\n', packageFile, d) + var stringified = JSON.stringify(updateDeps(pkgWithExtras), null, 2) + '\n' + function write (writeYes) { + fs.writeFile(packageFile, stringified, 'utf8', function (writeFileErr) { + if (!writeFileErr && writeYes && !config.get('silent')) { + console.log('Wrote to %s:\n\n%s\n', packageFile, stringified) } - return cb(er, pkg) + return cb(writeFileErr, pkgWithExtras) }) } if (ctx.yes) { return write(true) } - console.log('About to write to %s:\n\n%s\n', packageFile, d) - read({ prompt: 'Is this OK? ', default: 'yes' }, function (er, ok) { - if (er) { - return cb(er) + console.log('About to write to %s:\n\n%s\n', packageFile, stringified) + read({ prompt: 'Is this OK? ', default: 'yes' }, function (promptErr, ok) { + if (promptErr) { + return cb(promptErr) } if (!ok || ok.toLowerCase().charAt(0) !== 'y') { console.log('Aborted.') diff --git a/deps/npm/node_modules/init-package-json/package.json b/deps/npm/node_modules/init-package-json/package.json index 9219863cb67203..91d4b7a109f088 100644 --- a/deps/npm/node_modules/init-package-json/package.json +++ b/deps/npm/node_modules/init-package-json/package.json @@ -1,18 +1,18 @@ { "name": "init-package-json", - "version": "3.0.1", + "version": "3.0.2", "main": "lib/init-package-json.js", "scripts": { "test": "tap", "preversion": "npm test", "postversion": "npm publish", "prepublishOnly": "git push origin --follow-tags", - "lint": "eslint '**/*.js'", - "postlint": "npm-template-check", + "lint": "eslint \"**/*.js\"", + "postlint": "template-oss-check", "lintfix": "npm run lint -- --fix", "snap": "tap", "posttest": "npm run lint", - "template-copy": "npm-template-copy --force" + "template-oss-apply": "template-oss-apply --force" }, "repository": { "type": "git", @@ -22,21 +22,22 @@ "license": "ISC", "description": "A node module to get your node module started", "dependencies": { - "npm-package-arg": "^9.0.0", + "npm-package-arg": "^9.0.1", "promzard": "^0.3.0", "read": "^1.0.7", "read-package-json": "^5.0.0", "semver": "^7.3.5", "validate-npm-package-license": "^3.0.4", - "validate-npm-package-name": "^3.0.0" + "validate-npm-package-name": "^4.0.0" }, "devDependencies": { "@npmcli/config": "^4.0.1", - "@npmcli/template-oss": "^2.9.2", - "tap": "^15.1.6" + "@npmcli/eslint-config": "^3.0.1", + "@npmcli/template-oss": "3.2.1", + "tap": "^16.0.1" }, "engines": { - "node": "^12.13.0 || ^14.15.0 || >=16" + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" }, "tap": { "statements": "94", @@ -54,10 +55,11 @@ "start" ], "files": [ - "bin", - "lib" + "bin/", + "lib/" ], "templateOSS": { - "version": "2.9.2" + "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", + "version": "3.2.1" } } diff --git a/deps/npm/node_modules/just-diff-apply/index.d.ts b/deps/npm/node_modules/just-diff-apply/index.d.ts new file mode 100644 index 00000000000000..9fc05257af0aab --- /dev/null +++ b/deps/npm/node_modules/just-diff-apply/index.d.ts @@ -0,0 +1,17 @@ +// Definitions by: Eddie Atkinson + +type Operation = "add" | "replace" | "remove"; + +type DiffOps = Array<{ + op: Operation; + path: Array; + value?: any; +}>; +type PathConverter = (path: string) => string[]; + +export function diffApply( + obj: T, + diff: DiffOps, + pathConverter?: PathConverter +): T; +export const jsonPatchPathConverter: PathConverter; diff --git a/deps/npm/node_modules/just-diff-apply/index.js b/deps/npm/node_modules/just-diff-apply/index.js index ceb32681172a8a..c5d2c3265a8520 100644 --- a/deps/npm/node_modules/just-diff-apply/index.js +++ b/deps/npm/node_modules/just-diff-apply/index.js @@ -47,6 +47,7 @@ module.exports = { var REMOVE = 'remove'; var REPLACE = 'replace'; var ADD = 'add'; +var MOVE = 'move'; function diffApply(obj, diff, pathConverter) { if (!obj || typeof obj != 'object') { @@ -62,44 +63,99 @@ function diffApply(obj, diff, pathConverter) { var thisDiff = diff[i]; var subObject = obj; var thisOp = thisDiff.op; - var thisPath = thisDiff.path; - if (pathConverter) { - thisPath = pathConverter(thisPath); - if (!Array.isArray(thisPath)) { - throw new Error('pathConverter must return an array'); + + var thisPath = transformPath(pathConverter, thisDiff.path); + var thisFromPath = thisDiff.from && transformPath(pathConverter, thisDiff.from); + var toPath, toPathCopy, lastToProp, subToObject, valueToMove; + + if (thisFromPath) { + // MOVE only, "fromPath" is effectively path and "path" is toPath + toPath = thisPath; + thisPath = thisFromPath; + + toPathCopy = toPath.slice(); + lastToProp = toPathCopy.pop(); + prototypeCheck(lastToProp); + if (lastToProp == null) { + return false; } - } else { - if (!Array.isArray(thisPath)) { - throw new Error('diff path must be an array, consider supplying a path converter'); + + var thisToProp; + while (((thisToProp = toPathCopy.shift())) != null) { + prototypeCheck(thisToProp); + if (!(thisToProp in subToObject)) { + subToObject[thisToProp] = {}; + } + subToObject = subToObject[thisToProp]; } } + var pathCopy = thisPath.slice(); var lastProp = pathCopy.pop(); + prototypeCheck(lastProp); if (lastProp == null) { return false; } + var thisProp; while (((thisProp = pathCopy.shift())) != null) { + prototypeCheck(thisProp); if (!(thisProp in subObject)) { subObject[thisProp] = {}; } subObject = subObject[thisProp]; } - if (thisOp === REMOVE || thisOp === REPLACE) { + if (thisOp === REMOVE || thisOp === REPLACE || thisOp === MOVE) { + var path = thisOp === MOVE ? thisDiff.from : thisDiff.path; if (!subObject.hasOwnProperty(lastProp)) { - throw new Error(['expected to find property', thisDiff.path, 'in object', obj].join(' ')); + throw new Error(['expected to find property', path, 'in object', obj].join(' ')); } } - if (thisOp === REMOVE) { + if (thisOp === REMOVE || thisOp === MOVE) { + if (thisOp === MOVE) { + valueToMove = subObject[lastProp]; + } Array.isArray(subObject) ? subObject.splice(lastProp, 1) : delete subObject[lastProp]; } if (thisOp === REPLACE || thisOp === ADD) { subObject[lastProp] = thisDiff.value; } + + if (thisOp === MOVE) { + subObject[lastToProp] = valueToMove; + } } return subObject; } +function transformPath(pathConverter, thisPath) { + if(pathConverter) { + thisPath = pathConverter(thisPath); + if(!Array.isArray(thisPath)) { + throw new Error([ + 'pathConverter must return an array, returned:', + thisPath, + ].join(' ')); + } + } else { + if(!Array.isArray(thisPath)) { + throw new Error([ + 'diff path', + thisPath, + 'must be an array, consider supplying a path converter'] + .join(' ')); + } + } + return thisPath; +} + function jsonPatchPathConverter(stringPath) { return stringPath.split('/').slice(1); } + +function prototypeCheck(prop) { + // coercion is intentional to catch prop values like `['__proto__']` + if (prop == '__proto__' || prop == 'constructor' || prop == 'prototype') { + throw new Error('setting of prototype values not supported'); + } +} diff --git a/deps/npm/node_modules/just-diff-apply/index.mjs b/deps/npm/node_modules/just-diff-apply/index.mjs index fcd26c2f5a23e8..045830507cd177 100644 --- a/deps/npm/node_modules/just-diff-apply/index.mjs +++ b/deps/npm/node_modules/just-diff-apply/index.mjs @@ -65,18 +65,18 @@ function diffApply(obj, diff, pathConverter) { } } else { if (!Array.isArray(thisPath)) { - throw new Error( - 'diff path must be an array, consider supplying a path converter' - ); + throw new Error('diff path must be an array, consider supplying a path converter'); } } var pathCopy = thisPath.slice(); var lastProp = pathCopy.pop(); + prototypeCheck(lastProp); if (lastProp == null) { return false; } var thisProp; - while ((thisProp = pathCopy.shift()) != null) { + while (((thisProp = pathCopy.shift())) != null) { + prototypeCheck(thisProp); if (!(thisProp in subObject)) { subObject[thisProp] = {}; } @@ -84,17 +84,11 @@ function diffApply(obj, diff, pathConverter) { } if (thisOp === REMOVE || thisOp === REPLACE) { if (!subObject.hasOwnProperty(lastProp)) { - throw new Error( - ['expected to find property', thisDiff.path, 'in object', obj].join( - ' ' - ) - ); + throw new Error(['expected to find property', thisDiff.path, 'in object', obj].join(' ')); } } if (thisOp === REMOVE) { - Array.isArray(subObject) - ? subObject.splice(lastProp, 1) - : delete subObject[lastProp]; + Array.isArray(subObject) ? subObject.splice(lastProp, 1) : delete subObject[lastProp]; } if (thisOp === REPLACE || thisOp === ADD) { subObject[lastProp] = thisDiff.value; @@ -107,4 +101,11 @@ function jsonPatchPathConverter(stringPath) { return stringPath.split('/').slice(1); } +function prototypeCheck(prop) { + // coercion is intentional to catch prop values like `['__proto__']` + if (prop == '__proto__' || prop == 'constructor' || prop == 'prototype') { + throw new Error('setting of prototype values not supported'); + } +} + export {diffApply, jsonPatchPathConverter}; diff --git a/deps/npm/node_modules/just-diff-apply/index.tests.ts b/deps/npm/node_modules/just-diff-apply/index.tests.ts new file mode 100644 index 00000000000000..d02ba89b838cdd --- /dev/null +++ b/deps/npm/node_modules/just-diff-apply/index.tests.ts @@ -0,0 +1,108 @@ +import * as diffObj from "./index"; + +const { diffApply, jsonPatchPathConverter } = diffObj; +const obj1 = { + a: 2, + b: 3, + c: { + d: 5 + } +}; +const arr1 = [1, "bee"]; + +const objOps: diffObj.DiffOps = [ + { + op: "replace", + path: ["a"], + value: 10 + }, + { + op: "remove", + path: ["b"] + }, + { + op: "add", + path: ["e"], + value: 15 + }, + { + op: "remove", + path: ["c", "d"] + } +]; + +const arrOps: diffObj.DiffOps = [ + { + op: "replace", + path: [1], + value: 10 + }, + { + op: "remove", + path: [2] + }, + { + op: "add", + path: [7], + value: 15 + } +]; + +//OK +diffApply(obj1, objOps); +diffApply(obj1, []); +diffApply(arr1, arrOps); +diffApply(arr1, []); +diffApply(obj1, objOps, jsonPatchPathConverter); +diffApply(arr1, arrOps, jsonPatchPathConverter); + +// not OK +// @ts-expect-error +diffApply(obj1); +// @ts-expect-error +diffApply(arr2); +// @ts-expect-error +diffApply("a"); +// @ts-expect-error +diffApply(true); + +// @ts-expect-error +diffApply(obj1, 1); +// @ts-expect-error +diffApply(3, arr2); +// @ts-expect-error +diffApply(obj1, "a"); +// @ts-expect-error +diffApply("b", arr2); + +// @ts-expect-error +diffApply(obj1, [{ op: "delete", path: ["a"] }]); +// @ts-expect-error +diffApply(obj1, [{ op: "delete", path: ["a"] }], jsonPatchPathConverter); +// @ts-expect-error +diffApply(obj1, "a", jsonPatchPathConverter); +// @ts-expect-error +diffApply(obj1, ["a", "b", "c"], jsonPatchPathConverter); + +// @ts-expect-error +diff("a", jsonPatchPathConverter); +// @ts-expect-error +diff(true, jsonPatchPathConverter); + +// @ts-expect-error +diff(obj1, 1, jsonPatchPathConverter); +// @ts-expect-error +diff(3, arr2, jsonPatchPathConverter); +// @ts-expect-error +diff(obj1, "a", jsonPatchPathConverter); +// @ts-expect-error +diff("b", arr2, jsonPatchPathConverter); + +// @ts-expect-error +diff(obj1, obj2, "a"); +// @ts-expect-error +diff(arr1, arr2, 1); +// @ts-expect-error +diff(obj1, arr1, "bee"); +// @ts-expect-error +diff(obj2, arr2, "nope"); diff --git a/deps/npm/node_modules/just-diff-apply/package.json b/deps/npm/node_modules/just-diff-apply/package.json index c38bd47aa6990d..b8e5012ff83b15 100644 --- a/deps/npm/node_modules/just-diff-apply/package.json +++ b/deps/npm/node_modules/just-diff-apply/package.json @@ -1,6 +1,6 @@ { "name": "just-diff-apply", - "version": "4.0.1", + "version": "5.2.0", "description": "Apply a diff to an object. Optionally supports jsonPatch protocol", "main": "index.js", "module": "index.mjs", @@ -10,6 +10,7 @@ "default": "./index.mjs" } }, + "types": "index.d.ts", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "build": "rollup -c" diff --git a/deps/npm/node_modules/libnpmaccess/lib/index.js b/deps/npm/node_modules/libnpmaccess/lib/index.js index 925f742921ad46..71219d0098cfe9 100644 --- a/deps/npm/node_modules/libnpmaccess/lib/index.js +++ b/deps/npm/node_modules/libnpmaccess/lib/index.js @@ -116,7 +116,7 @@ cmd.lsPackages.stream = (entity, opts = {}) => { if (err.code === 'E404' && !team) { uri = `/-/user/${eu(scope)}/package` npmFetch.json.stream(uri, '*', nextOpts) - .on('error', err => ret.emit('error', err)) + .on('error', streamErr => ret.emit('error', streamErr)) .pipe(ret) } else { ret.emit('error', err) diff --git a/deps/npm/node_modules/libnpmaccess/package.json b/deps/npm/node_modules/libnpmaccess/package.json index 72fcfaf586a05d..68ac1c28902f7f 100644 --- a/deps/npm/node_modules/libnpmaccess/package.json +++ b/deps/npm/node_modules/libnpmaccess/package.json @@ -9,23 +9,24 @@ "preversion": "npm test", "postversion": "npm publish", "postpublish": "git push origin --follow-tags", - "lint": "eslint '**/*.js'", + "lint": "eslint \"**/*.js\"", "test": "tap", - "postlint": "npm-template-check", + "postlint": "template-oss-check", "lintfix": "npm run lint -- --fix", "prepublishOnly": "git push origin --follow-tags", "snap": "tap", "posttest": "npm run lint", - "template-copy": "npm-template-copy --force" + "template-oss-apply": "template-oss-apply --force" }, "devDependencies": { - "@npmcli/template-oss": "^2.4.2", - "nock": "^12.0.1", + "@npmcli/eslint-config": "^3.0.1", + "@npmcli/template-oss": "3.2.2", + "nock": "^13.2.4", "tap": "^15.1.0" }, "repository": { "type": "git", - "url": "https://github.com/npm/cli", + "url": "https://github.com/npm/cli.git", "directory": "workspaces/libnpmaccess" }, "bugs": "https://github.com/npm/libnpmaccess/issues", @@ -37,16 +38,17 @@ "npm-registry-fetch": "^13.0.0" }, "engines": { - "node": "^12.13.0 || ^14.15.0 || >=16" + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" }, "tap": { "check-coverage": true }, "files": [ - "bin", - "lib" + "bin/", + "lib/" ], "templateOSS": { - "version": "2.9.2" + "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", + "version": "3.2.2" } } diff --git a/deps/npm/node_modules/libnpmdiff/package.json b/deps/npm/node_modules/libnpmdiff/package.json index 11d0f5887bb815..eeddaf09fdc774 100644 --- a/deps/npm/node_modules/libnpmdiff/package.json +++ b/deps/npm/node_modules/libnpmdiff/package.json @@ -4,16 +4,16 @@ "description": "The registry diff", "repository": { "type": "git", - "url": "https://github.com/npm/cli", + "url": "https://github.com/npm/cli.git", "directory": "workspaces/libnpmdiff" }, "main": "lib/index.js", "files": [ - "bin", - "lib" + "bin/", + "lib/" ], "engines": { - "node": "^12.13.0 || ^14.15.0 || >=16" + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" }, "keywords": [ "npm", @@ -33,7 +33,7 @@ "license": "ISC", "scripts": { "eslint": "eslint", - "lint": "eslint '**/*.js'", + "lint": "eslint \"**/*.js\"", "lintfix": "npm run lint -- --fix", "test": "tap", "posttest": "npm run lint", @@ -41,15 +41,15 @@ "preversion": "npm test", "postversion": "npm publish", "prepublishOnly": "git push origin --follow-tags", - "postlint": "npm-template-check", - "template-copy": "npm-template-copy --force" + "postlint": "template-oss-check", + "template-oss-apply": "template-oss-apply --force" }, "tap": { "check-coverage": true }, "devDependencies": { - "@npmcli/template-oss": "^2.4.2", - "eslint": "^8.1.0", + "@npmcli/eslint-config": "^3.0.1", + "@npmcli/template-oss": "3.2.2", "tap": "^15.0.9" }, "dependencies": { @@ -63,6 +63,7 @@ "tar": "^6.1.0" }, "templateOSS": { - "version": "2.9.2" + "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", + "version": "3.2.2" } } diff --git a/deps/npm/node_modules/libnpmexec/lib/file-exists.js b/deps/npm/node_modules/libnpmexec/lib/file-exists.js index 05dddc89f08f9b..f89cfc217d61d7 100644 --- a/deps/npm/node_modules/libnpmexec/lib/file-exists.js +++ b/deps/npm/node_modules/libnpmexec/lib/file-exists.js @@ -4,7 +4,7 @@ const stat = promisify(require('fs').stat) const walkUp = require('walk-up-path') const fileExists = (file) => stat(file) - .then((stat) => stat.isFile()) + .then((res) => res.isFile()) .catch(() => false) const localFileExists = async (dir, binName, root = '/') => { diff --git a/deps/npm/node_modules/libnpmexec/lib/index.js b/deps/npm/node_modules/libnpmexec/lib/index.js index 3c7be114913b50..81d152a20bd6e7 100644 --- a/deps/npm/node_modules/libnpmexec/lib/index.js +++ b/deps/npm/node_modules/libnpmexec/lib/index.js @@ -119,11 +119,11 @@ const exec = async (opts) => { ...flatOptions, path, }) - const tree = await localArb.loadActual() + const localTree = await localArb.loadActual() // do we have all the packages in manifest list? const needInstall = - manis.some(manifest => manifestMissing({ tree, manifest })) + manis.some(manifest => manifestMissing({ tree: localTree, manifest })) if (needInstall) { const { npxCache } = flatOptions diff --git a/deps/npm/node_modules/libnpmexec/package.json b/deps/npm/node_modules/libnpmexec/package.json index 9af42b29942e67..7245f15b2ed912 100644 --- a/deps/npm/node_modules/libnpmexec/package.json +++ b/deps/npm/node_modules/libnpmexec/package.json @@ -2,17 +2,17 @@ "name": "libnpmexec", "version": "4.0.2", "files": [ - "bin", - "lib" + "bin/", + "lib/" ], "main": "lib/index.js", "engines": { - "node": "^12.13.0 || ^14.15.0 || >=16" + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" }, "description": "npm exec (npx) programmatic API", "repository": { "type": "git", - "url": "https://github.com/npm/cli", + "url": "https://github.com/npm/cli.git", "directory": "workspaces/libnpmexec" }, "keywords": [ @@ -33,16 +33,16 @@ ], "license": "ISC", "scripts": { - "lint": "eslint '**/*.js'", + "lint": "eslint \"**/*.js\"", "posttest": "npm run lint", "test": "tap", "snap": "tap", "preversion": "npm test", "postversion": "npm publish", "prepublishOnly": "git push origin --follow-tags", - "postlint": "npm-template-check", + "postlint": "template-oss-check", "lintfix": "npm run lint -- --fix", - "template-copy": "npm-template-copy --force" + "template-oss-apply": "template-oss-apply --force" }, "tap": { "color": true, @@ -50,7 +50,8 @@ "files": "test/*.js" }, "devDependencies": { - "@npmcli/template-oss": "^2.4.2", + "@npmcli/eslint-config": "^3.0.1", + "@npmcli/template-oss": "3.2.2", "bin-links": "^3.0.0", "tap": "^15.0.6" }, @@ -69,6 +70,7 @@ "walk-up-path": "^1.0.0" }, "templateOSS": { - "version": "2.9.2" + "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", + "version": "3.2.2" } } diff --git a/deps/npm/node_modules/libnpmfund/lib/index.js b/deps/npm/node_modules/libnpmfund/lib/index.js index a3d2d8223ca4e0..a53893dc1cf87b 100644 --- a/deps/npm/node_modules/libnpmfund/lib/index.js +++ b/deps/npm/node_modules/libnpmfund/lib/index.js @@ -91,8 +91,8 @@ function readTree (tree, opts) { } } - function getFundingDependencies (tree) { - const edges = tree && tree.edgesOut && tree.edgesOut.values() + function getFundingDependencies (t) { + const edges = t && t.edgesOut && t.edgesOut.values() if (!edges) { return empty() } diff --git a/deps/npm/node_modules/libnpmfund/package.json b/deps/npm/node_modules/libnpmfund/package.json index 2abf897eefeb86..ddc95f2f0a3b7b 100644 --- a/deps/npm/node_modules/libnpmfund/package.json +++ b/deps/npm/node_modules/libnpmfund/package.json @@ -3,13 +3,13 @@ "version": "3.0.1", "main": "lib/index.js", "files": [ - "bin", - "lib" + "bin/", + "lib/" ], "description": "Programmatic API for npm fund", "repository": { "type": "git", - "url": "https://github.com/npm/cli", + "url": "https://github.com/npm/cli.git", "directory": "workspaces/libnpmfund" }, "keywords": [ @@ -32,7 +32,7 @@ "license": "ISC", "scripts": { "eslint": "eslint", - "lint": "eslint '**/*.js'", + "lint": "eslint \"**/*.js\"", "lintfix": "npm run lint -- --fix", "posttest": "npm run lint", "test": "tap", @@ -40,23 +40,25 @@ "preversion": "npm test", "postversion": "npm publish", "prepublishOnly": "git push origin --follow-tags", - "postlint": "npm-template-check", - "template-copy": "npm-template-copy --force" + "postlint": "template-oss-check", + "template-oss-apply": "template-oss-apply --force" }, "tap": { "check-coverage": true }, "devDependencies": { - "@npmcli/template-oss": "^2.4.2", + "@npmcli/eslint-config": "^3.0.1", + "@npmcli/template-oss": "3.2.2", "tap": "^15.0.9" }, "dependencies": { "@npmcli/arborist": "^5.0.0" }, "engines": { - "node": "^12.13.0 || ^14.15.0 || >=16" + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" }, "templateOSS": { - "version": "2.9.2" + "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", + "version": "3.2.2" } } diff --git a/deps/npm/node_modules/libnpmhook/package.json b/deps/npm/node_modules/libnpmhook/package.json index c95230114cb7f4..4071d38ee5250b 100644 --- a/deps/npm/node_modules/libnpmhook/package.json +++ b/deps/npm/node_modules/libnpmhook/package.json @@ -4,29 +4,29 @@ "description": "programmatic API for managing npm registry hooks", "main": "lib/index.js", "files": [ - "bin", - "lib" + "bin/", + "lib/" ], "scripts": { "prerelease": "npm t", "postrelease": "npm publish && git push --follow-tags", "test": "tap", - "lint": "eslint '**/*.js'", - "postlint": "npm-template-check", + "lint": "eslint \"**/*.js\"", + "postlint": "template-oss-check", "lintfix": "npm run lint -- --fix", "preversion": "npm test", "postversion": "npm publish", "prepublishOnly": "git push origin --follow-tags", "snap": "tap", "posttest": "npm run lint", - "template-copy": "npm-template-copy --force" + "template-oss-apply": "template-oss-apply --force" }, "tap": { "check-coverage": true }, "repository": { "type": "git", - "url": "https://github.com/npm/cli", + "url": "https://github.com/npm/cli.git", "directory": "workspaces/libnpmhook" }, "keywords": [ @@ -42,14 +42,16 @@ "npm-registry-fetch": "^13.0.0" }, "devDependencies": { - "@npmcli/template-oss": "^2.4.2", - "nock": "^9.6.1", + "@npmcli/eslint-config": "^3.0.1", + "@npmcli/template-oss": "3.2.2", + "nock": "^13.2.4", "tap": "^15.1.0" }, "engines": { - "node": "^12.13.0 || ^14.15.0 || >=16" + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" }, "templateOSS": { - "version": "2.9.2" + "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", + "version": "3.2.2" } } diff --git a/deps/npm/node_modules/libnpmorg/package.json b/deps/npm/node_modules/libnpmorg/package.json index 582a60e2ded1da..58ca5ec42e3af1 100644 --- a/deps/npm/node_modules/libnpmorg/package.json +++ b/deps/npm/node_modules/libnpmorg/package.json @@ -17,30 +17,31 @@ "preversion": "npm test", "postversion": "npm publish", "prepublishOnly": "git push origin --follow-tags", - "lint": "eslint '**/*.js'", + "lint": "eslint \"**/*.js\"", "test": "tap", "posttest": "npm run lint", - "postlint": "npm-template-check", + "postlint": "template-oss-check", "lintfix": "npm run lint -- --fix", "snap": "tap", - "template-copy": "npm-template-copy --force" + "template-oss-apply": "template-oss-apply --force" }, "files": [ - "bin", - "lib" + "bin/", + "lib/" ], "tap": { "check-coverage": true }, "devDependencies": { - "@npmcli/template-oss": "^2.4.2", + "@npmcli/eslint-config": "^3.0.1", + "@npmcli/template-oss": "3.2.2", "minipass": "^3.1.1", - "nock": "^12.0.1", + "nock": "^13.2.4", "tap": "^15.0.0" }, "repository": { "type": "git", - "url": "https://github.com/npm/cli", + "url": "https://github.com/npm/cli.git", "directory": "workspaces/libnpmorg" }, "bugs": "https://github.com/npm/libnpmorg/issues", @@ -50,9 +51,10 @@ "npm-registry-fetch": "^13.0.0" }, "engines": { - "node": "^12.13.0 || ^14.15.0 || >=16" + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" }, "templateOSS": { - "version": "2.9.2" + "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", + "version": "3.2.2" } } diff --git a/deps/npm/node_modules/libnpmpack/package.json b/deps/npm/node_modules/libnpmpack/package.json index f98f0269b0f223..4ee093c74d6163 100644 --- a/deps/npm/node_modules/libnpmpack/package.json +++ b/deps/npm/node_modules/libnpmpack/package.json @@ -8,33 +8,34 @@ "Claudia Hernández " ], "files": [ - "bin", - "lib" + "bin/", + "lib/" ], "license": "ISC", "scripts": { "preversion": "npm test", "postversion": "npm publish", "prepublishOnly": "git push origin --follow-tags", - "lint": "eslint '**/*.js'", + "lint": "eslint \"**/*.js\"", "test": "tap", "posttest": "npm run lint", - "postlint": "npm-template-check", + "postlint": "template-oss-check", "lintfix": "npm run lint -- --fix", "snap": "tap", - "template-copy": "npm-template-copy --force" + "template-oss-apply": "template-oss-apply --force" }, "tap": { "check-coverage": true }, "devDependencies": { - "@npmcli/template-oss": "^2.4.2", + "@npmcli/eslint-config": "^3.0.1", + "@npmcli/template-oss": "3.2.2", "nock": "^13.0.7", "tap": "^15.0.0" }, "repository": { "type": "git", - "url": "https://github.com/npm/cli", + "url": "https://github.com/npm/cli.git", "directory": "workspaces/libnpmpack" }, "bugs": "https://github.com/npm/libnpmpack/issues", @@ -45,9 +46,10 @@ "pacote": "^13.0.5" }, "engines": { - "node": "^12.13.0 || ^14.15.0 || >=16" + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" }, "templateOSS": { - "version": "2.9.2" + "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", + "version": "3.2.2" } } diff --git a/deps/npm/node_modules/libnpmpublish/package.json b/deps/npm/node_modules/libnpmpublish/package.json index 2ad8baf3d4a540..bb911039e309c3 100644 --- a/deps/npm/node_modules/libnpmpublish/package.json +++ b/deps/npm/node_modules/libnpmpublish/package.json @@ -9,36 +9,37 @@ "Claudia Hernández " ], "files": [ - "bin", - "lib" + "bin/", + "lib/" ], "license": "ISC", "scripts": { "eslint": "eslint", - "lint": "eslint '**/*.js'", + "lint": "eslint \"**/*.js\"", "lintfix": "npm run lint -- --fix", "preversion": "npm test", "postversion": "npm publish", "prepublishOnly": "git push origin --follow-tags", "test": "tap", "posttest": "npm run lint", - "postlint": "npm-template-check", + "postlint": "template-oss-check", "snap": "tap", - "template-copy": "npm-template-copy --force" + "template-oss-apply": "template-oss-apply --force" }, "tap": { "check-coverage": true }, "devDependencies": { - "@npmcli/template-oss": "^2.4.2", + "@npmcli/eslint-config": "^3.0.1", + "@npmcli/template-oss": "3.2.2", "libnpmpack": "^4.0.0", "lodash.clonedeep": "^4.5.0", - "nock": "^12.0.2", + "nock": "^13.2.4", "tap": "^15" }, "repository": { "type": "git", - "url": "https://github.com/npm/cli", + "url": "https://github.com/npm/cli.git", "directory": "workspaces/libnpmpublish" }, "bugs": "https://github.com/npm/cli/issues", @@ -51,9 +52,10 @@ "ssri": "^8.0.1" }, "engines": { - "node": "^12.13.0 || ^14.15.0 || >=16" + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" }, "templateOSS": { - "version": "2.9.2" + "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", + "version": "3.2.2" } } diff --git a/deps/npm/node_modules/libnpmsearch/package.json b/deps/npm/node_modules/libnpmsearch/package.json index 25e730395aeb76..7bf69ecb8af457 100644 --- a/deps/npm/node_modules/libnpmsearch/package.json +++ b/deps/npm/node_modules/libnpmsearch/package.json @@ -5,8 +5,8 @@ "author": "GitHub Inc.", "main": "lib/index.js", "files": [ - "bin", - "lib" + "bin/", + "lib/" ], "keywords": [ "npm", @@ -21,23 +21,24 @@ "prepublishOnly": "git push origin --follow-tags", "posttest": "npm run lint", "test": "tap", - "lint": "eslint '**/*.js'", - "postlint": "npm-template-check", + "lint": "eslint \"**/*.js\"", + "postlint": "template-oss-check", "lintfix": "npm run lint -- --fix", "snap": "tap", - "template-copy": "npm-template-copy --force" + "template-oss-apply": "template-oss-apply --force" }, "tap": { "check-coverage": true }, "devDependencies": { - "@npmcli/template-oss": "^2.4.2", - "nock": "^9.6.1", + "@npmcli/eslint-config": "^3.0.1", + "@npmcli/template-oss": "3.2.2", + "nock": "^13.2.4", "tap": "^15" }, "repository": { "type": "git", - "url": "https://github.com/npm/cli", + "url": "https://github.com/npm/cli.git", "directory": "workspaces/libnpmsearch" }, "bugs": "https://github.com/npm/libnpmsearch/issues", @@ -46,9 +47,10 @@ "npm-registry-fetch": "^13.0.0" }, "engines": { - "node": "^12.13.0 || ^14.15.0 || >=16" + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" }, "templateOSS": { - "version": "2.9.2" + "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", + "version": "3.2.2" } } diff --git a/deps/npm/node_modules/libnpmteam/package.json b/deps/npm/node_modules/libnpmteam/package.json index 485ab59735bcf8..7f8ee98f2868d3 100644 --- a/deps/npm/node_modules/libnpmteam/package.json +++ b/deps/npm/node_modules/libnpmteam/package.json @@ -9,27 +9,28 @@ "preversion": "npm test", "postversion": "npm publish", "prepublishOnly": "git push origin --follow-tags", - "lint": "eslint '**/*.js'", + "lint": "eslint \"**/*.js\"", "test": "tap", "posttest": "npm run lint", - "postlint": "npm-template-check", + "postlint": "template-oss-check", "lintfix": "npm run lint -- --fix", "snap": "tap", - "template-copy": "npm-template-copy --force" + "template-oss-apply": "template-oss-apply --force" }, "devDependencies": { - "@npmcli/template-oss": "^2.4.2", - "nock": "^12.0.1", + "@npmcli/eslint-config": "^3.0.1", + "@npmcli/template-oss": "3.2.2", + "nock": "^13.2.4", "tap": "^15" }, "repository": { "type": "git", - "url": "https://github.com/npm/cli", + "url": "https://github.com/npm/cli.git", "directory": "workspaces/libnpmteam" }, "files": [ - "bin", - "lib" + "bin/", + "lib/" ], "homepage": "https://npmjs.com/package/libnpmteam", "dependencies": { @@ -37,12 +38,13 @@ "npm-registry-fetch": "^13.0.0" }, "engines": { - "node": "^12.13.0 || ^14.15.0 || >=16" + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" }, "tap": { "check-coverage": true }, "templateOSS": { - "version": "2.9.2" + "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", + "version": "3.2.2" } } diff --git a/deps/npm/node_modules/libnpmversion/package.json b/deps/npm/node_modules/libnpmversion/package.json index ddb56c1cf32cf3..2a3a7716a13e27 100644 --- a/deps/npm/node_modules/libnpmversion/package.json +++ b/deps/npm/node_modules/libnpmversion/package.json @@ -3,35 +3,36 @@ "version": "3.0.1", "main": "lib/index.js", "files": [ - "bin", - "lib" + "bin/", + "lib/" ], "description": "library to do the things that 'npm version' does", "repository": { "type": "git", - "url": "https://github.com/npm/cli", + "url": "https://github.com/npm/cli.git", "directory": "workspaces/libnpmversion" }, "author": "GitHub Inc.", "license": "ISC", "scripts": { - "lint": "eslint '**/*.js'", + "lint": "eslint \"**/*.js\"", "test": "tap", "posttest": "npm run lint", "snap": "tap", "preversion": "npm test", "postversion": "npm publish", "prepublishOnly": "git push origin --follow-tags", - "postlint": "npm-template-check", + "postlint": "template-oss-check", "lintfix": "npm run lint -- --fix", - "template-copy": "npm-template-copy --force" + "template-oss-apply": "template-oss-apply --force" }, "tap": { "coverage-map": "map.js", "check-coverage": true }, "devDependencies": { - "@npmcli/template-oss": "^2.4.2", + "@npmcli/eslint-config": "^3.0.1", + "@npmcli/template-oss": "3.2.2", "require-inject": "^1.4.4", "tap": "^15" }, @@ -44,9 +45,10 @@ "stringify-package": "^1.0.1" }, "engines": { - "node": "^12.13.0 || ^14.15.0 || >=16" + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" }, "templateOSS": { - "version": "2.9.2" + "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", + "version": "3.2.2" } } diff --git a/deps/npm/node_modules/lru-cache/index.js b/deps/npm/node_modules/lru-cache/index.js index e37f51616452e3..978b8f4ee95955 100644 --- a/deps/npm/node_modules/lru-cache/index.js +++ b/deps/npm/node_modules/lru-cache/index.js @@ -1,6 +1,17 @@ const perf = typeof performance === 'object' && performance && typeof performance.now === 'function' ? performance : Date +const hasAbortController = typeof AbortController !== 'undefined' + +/* istanbul ignore next - minimal backwards compatibility polyfill */ +const AC = hasAbortController ? AbortController : Object.assign( + class AbortController { + constructor () { this.signal = new AC.AbortSignal } + abort () { this.signal.aborted = true } + }, + { AbortSignal: class AbortSignal { constructor () { this.aborted = false }}} +) + const warned = new Set() const deprecatedOption = (opt, instead) => { const code = `LRU_CACHE_OPTION_${opt}` @@ -24,12 +35,15 @@ const deprecatedProperty = (field, instead) => { warn(code, `${field} property`, `cache.${instead}`, get) } } -const shouldWarn = (code) => typeof process === 'object' && + +const shouldWarn = code => typeof process === 'object' && process && - !(process.noDeprecation || warned.has(code)) + !warned.has(code) + const warn = (code, what, instead, fn) => { warned.add(code) - process.emitWarning(`The ${what} is deprecated. Please use ${instead} instead.`, 'DeprecationWarning', code, fn) + const msg = `The ${what} is deprecated. Please use ${instead} instead.` + process.emitWarning(msg, 'DeprecationWarning', code, fn) } const isPosInt = n => n && n === Math.floor(n) && n > 0 && isFinite(n) @@ -58,7 +72,7 @@ class ZeroArray extends Array { class Stack { constructor (max) { - const UintArray = getUintArray(max) + const UintArray = max ? getUintArray(max) : Array this.heap = new UintArray(max) this.length = 0 } @@ -73,7 +87,7 @@ class Stack { class LRUCache { constructor (options = {}) { const { - max, + max = 0, ttl, ttlResolution = 1, ttlAutopurge, @@ -83,8 +97,9 @@ class LRUCache { disposeAfter, noDisposeOnSet, noUpdateTTL, - maxSize, + maxSize = 0, sizeCalculation, + fetchMethod, } = options // deprecated options, don't trigger a warning for getting them if @@ -95,17 +110,17 @@ class LRUCache { stale, } = options instanceof LRUCache ? {} : options - if (!isPosInt(max)) { - throw new TypeError('max option must be an integer') + if (max !== 0 && !isPosInt(max)) { + throw new TypeError('max option must be a nonnegative integer') } - const UintArray = getUintArray(max) + const UintArray = max ? getUintArray(max) : Array if (!UintArray) { throw new Error('invalid max value: ' + max) } this.max = max - this.maxSize = maxSize || 0 + this.maxSize = maxSize this.sizeCalculation = sizeCalculation || length if (this.sizeCalculation) { if (!this.maxSize) { @@ -115,6 +130,13 @@ class LRUCache { throw new TypeError('sizeCalculating set to non-function') } } + + this.fetchMethod = fetchMethod || null + if (this.fetchMethod && typeof this.fetchMethod !== 'function') { + throw new TypeError('fetchMethod must be a function if specified') + } + + this.keyMap = new Map() this.keyList = new Array(max).fill(null) this.valList = new Array(max).fill(null) @@ -139,7 +161,7 @@ class LRUCache { this.noDisposeOnSet = !!noDisposeOnSet this.noUpdateTTL = !!noUpdateTTL - if (this.maxSize) { + if (this.maxSize !== 0) { if (!isPosInt(this.maxSize)) { throw new TypeError('maxSize must be a positive integer if specified') } @@ -159,6 +181,20 @@ class LRUCache { this.initializeTTLTracking() } + // do not allow completely unbounded caches + if (this.max === 0 && this.ttl === 0 && this.maxSize === 0) { + throw new TypeError('At least one of max, maxSize, or ttl is required') + } + if (!this.ttlAutopurge && !this.max && !this.maxSize) { + const code = 'LRU_CACHE_UNBOUNDED' + if (shouldWarn(code)) { + warned.add(code) + const msg = 'TTL caching without ttlAutopurge, max, or maxSize can ' + + 'result in unbounded memory consumption.' + process.emitWarning(msg, 'UnboundedCacheWarning', code, LRUCache) + } + } + if (stale) { deprecatedOption('stale', 'allowStale') } @@ -170,9 +206,14 @@ class LRUCache { } } + getRemainingTTL (key) { + return this.has(key) ? Infinity : 0 + } + initializeTTLTracking () { this.ttls = new ZeroArray(this.max) this.starts = new ZeroArray(this.max) + this.setItemTTL = (index, ttl) => { this.starts[index] = ttl !== 0 ? perf.now() : 0 this.ttls[index] = ttl @@ -188,9 +229,11 @@ class LRUCache { } } } + this.updateItemAge = (index) => { this.starts[index] = this.ttls[index] !== 0 ? perf.now() : 0 } + // debounce calls to perf.now() to 1s so we're not hitting // that costly call repeatedly. let cachedNow = 0 @@ -206,6 +249,16 @@ class LRUCache { } return n } + + this.getRemainingTTL = (key) => { + const index = this.keyMap.get(key) + if (index === undefined) { + return 0 + } + return this.ttls[index] === 0 || this.starts[index] === 0 ? Infinity + : ((this.starts[index] + this.ttls[index]) - (cachedNow || getNow())) + } + this.isStale = (index) => { return this.ttls[index] !== 0 && this.starts[index] !== 0 && ((cachedNow || getNow()) - this.starts[index] > this.ttls[index]) @@ -219,9 +272,17 @@ class LRUCache { this.calculatedSize = 0 this.sizes = new ZeroArray(this.max) this.removeItemSize = index => this.calculatedSize -= this.sizes[index] - this.addItemSize = (index, v, k, size, sizeCalculation) => { - const s = size || (sizeCalculation ? sizeCalculation(v, k) : 0) - this.sizes[index] = isPosInt(s) ? s : 0 + this.requireSize = (k, v, size, sizeCalculation) => { + if (sizeCalculation && !size) { + size = sizeCalculation(v, k) + } + if (!isPosInt(size)) { + throw new TypeError('size must be positive integer') + } + return size + } + this.addItemSize = (index, v, k, size) => { + this.sizes[index] = size const maxSize = this.maxSize - this.sizes[index] while (this.calculatedSize > maxSize) { this.evict() @@ -239,15 +300,19 @@ class LRUCache { } } removeItemSize (index) {} - addItemSize (index, v, k, size, sizeCalculation) {} + addItemSize (index, v, k, size) {} + requireSize (k, v, size, sizeCalculation) { + if (size || sizeCalculation) { + throw new TypeError('cannot set size without setting maxSize on cache') + } + } *indexes ({ allowStale = this.allowStale } = {}) { if (this.size) { - for (let i = this.tail, j; true; ) { + for (let i = this.tail; true; ) { if (!this.isValidIndex(i)) { break } - j = i === this.head if (allowStale || !this.isStale(i)) { yield i } @@ -262,14 +327,13 @@ class LRUCache { *rindexes ({ allowStale = this.allowStale } = {}) { if (this.size) { - for (let i = this.head, j; true; ) { + for (let i = this.head; true; ) { if (!this.isValidIndex(i)) { break } if (allowStale || !this.isStale(i)) { yield i } - // either the tail now, or WAS the tail, and deleted if (i === this.tail) { break } else { @@ -389,6 +453,7 @@ class LRUCache { sizeCalculation = this.sizeCalculation, noUpdateTTL = this.noUpdateTTL, } = {}) { + size = this.requireSize(k, v, size, sizeCalculation) let index = this.size === 0 ? undefined : this.keyMap.get(k) if (index === undefined) { // addition @@ -400,21 +465,25 @@ class LRUCache { this.prev[index] = this.tail this.tail = index this.size ++ - this.addItemSize(index, v, k, size, sizeCalculation) + this.addItemSize(index, v, k, size) noUpdateTTL = false } else { // update const oldVal = this.valList[index] if (v !== oldVal) { - if (!noDisposeOnSet) { - this.dispose(oldVal, k, 'set') - if (this.disposeAfter) { - this.disposed.push([oldVal, k, 'set']) + if (this.isBackgroundFetch(oldVal)) { + oldVal.__abortController.abort() + } else { + if (!noDisposeOnSet) { + this.dispose(oldVal, k, 'set') + if (this.disposeAfter) { + this.disposed.push([oldVal, k, 'set']) + } } } this.removeItemSize(index) this.valList[index] = v - this.addItemSize(index, v, k, size, sizeCalculation) + this.addItemSize(index, v, k, size) } this.moveToTail(index) } @@ -458,9 +527,13 @@ class LRUCache { const head = this.head const k = this.keyList[head] const v = this.valList[head] - this.dispose(v, k, 'evict') - if (this.disposeAfter) { - this.disposed.push([v, k, 'evict']) + if (this.isBackgroundFetch(v)) { + v.__abortController.abort() + } else { + this.dispose(v, k, 'evict') + if (this.disposeAfter) { + this.disposed.push([v, k, 'evict']) + } } this.removeItemSize(head) this.head = this.next[head] @@ -481,22 +554,117 @@ class LRUCache { } } + backgroundFetch (k, index, options) { + const v = index === undefined ? undefined : this.valList[index] + if (this.isBackgroundFetch(v)) { + return v + } + const ac = new AbortController() + const fetchOpts = { + signal: ac.signal, + options, + } + const p = Promise.resolve(this.fetchMethod(k, v, fetchOpts)).then(v => { + if (!ac.signal.aborted) { + this.set(k, v, fetchOpts.options) + } + return v + }) + p.__abortController = ac + p.__staleWhileFetching = v + if (index === undefined) { + this.set(k, p, fetchOpts.options) + index = this.keyMap.get(k) + } else { + this.valList[index] = p + } + return p + } + + isBackgroundFetch (p) { + return p && typeof p === 'object' && typeof p.then === 'function' && + Object.prototype.hasOwnProperty.call(p, '__staleWhileFetching') + } + + // this takes the union of get() and set() opts, because it does both + async fetch (k, { + allowStale = this.allowStale, + updateAgeOnGet = this.updateAgeOnGet, + ttl = this.ttl, + noDisposeOnSet = this.noDisposeOnSet, + size = 0, + sizeCalculation = this.sizeCalculation, + noUpdateTTL = this.noUpdateTTL, + } = {}) { + if (!this.fetchMethod) { + return this.get(k, {allowStale, updateAgeOnGet}) + } + + const options = { + allowStale, + updateAgeOnGet, + ttl, + noDisposeOnSet, + size, + sizeCalculation, + noUpdateTTL, + } + + let index = this.keyMap.get(k) + if (index === undefined) { + return this.backgroundFetch(k, index, options) + } else { + // in cache, maybe already fetching + const v = this.valList[index] + if (this.isBackgroundFetch(v)) { + return allowStale && v.__staleWhileFetching !== undefined + ? v.__staleWhileFetching : v + } + + if (!this.isStale(index)) { + this.moveToTail(index) + if (updateAgeOnGet) { + this.updateItemAge(index) + } + return v + } + + // ok, it is stale, and not already fetching + // refresh the cache. + const p = this.backgroundFetch(k, index, options) + return allowStale && p.__staleWhileFetching !== undefined + ? p.__staleWhileFetching : p + } + } + get (k, { allowStale = this.allowStale, updateAgeOnGet = this.updateAgeOnGet, } = {}) { const index = this.keyMap.get(k) if (index !== undefined) { + const value = this.valList[index] + const fetching = this.isBackgroundFetch(value) if (this.isStale(index)) { - const value = allowStale ? this.valList[index] : undefined - this.delete(k) - return value + // delete only if not an in-flight background fetch + if (!fetching) { + this.delete(k) + return allowStale ? value : undefined + } else { + return allowStale ? value.__staleWhileFetching : undefined + } } else { + // if we're currently fetching it, we don't actually have it yet + // it's not stale, which means this isn't a staleWhileRefetching, + // so we just return undefined + if (fetching) { + return undefined + } this.moveToTail(index) if (updateAgeOnGet) { this.updateItemAge(index) } - return this.valList[index] + return value } } } @@ -540,9 +708,14 @@ class LRUCache { this.clear() } else { this.removeItemSize(index) - this.dispose(this.valList[index], k, 'delete') - if (this.disposeAfter) { - this.disposed.push([this.valList[index], k, 'delete']) + const v = this.valList[index] + if (this.isBackgroundFetch(v)) { + v.__abortController.abort() + } else { + this.dispose(v, k, 'delete') + if (this.disposeAfter) { + this.disposed.push([v, k, 'delete']) + } } this.keyMap.delete(k) this.keyList[index] = null @@ -569,16 +742,19 @@ class LRUCache { } clear () { - if (this.dispose !== LRUCache.prototype.dispose) { - for (const index of this.rindexes({ allowStale: true })) { - this.dispose(this.valList[index], this.keyList[index], 'delete') - } - } - if (this.disposeAfter) { - for (const index of this.rindexes({ allowStale: true })) { - this.disposed.push([this.valList[index], this.keyList[index], 'delete']) + for (const index of this.rindexes({ allowStale: true })) { + const v = this.valList[index] + if (this.isBackgroundFetch(v)) { + v.__abortController.abort() + } else { + const k = this.keyList[index] + this.dispose(v, k, 'delete') + if (this.disposeAfter) { + this.disposed.push([v, k, 'delete']) + } } } + this.keyMap.clear() this.valList.fill(null) this.keyList.fill(null) diff --git a/deps/npm/node_modules/lru-cache/package.json b/deps/npm/node_modules/lru-cache/package.json index a62f74c2b648ac..84d199c2b21b35 100644 --- a/deps/npm/node_modules/lru-cache/package.json +++ b/deps/npm/node_modules/lru-cache/package.json @@ -1,7 +1,7 @@ { "name": "lru-cache", "description": "A cache object that deletes the least-recently-used items.", - "version": "7.5.1", + "version": "7.7.1", "author": "Isaac Z. Schlueter ", "keywords": [ "mru", @@ -22,6 +22,7 @@ "devDependencies": { "@size-limit/preset-small-lib": "^7.0.8", "benchmark": "^2.1.4", + "clock-mock": "^1.0.3", "size-limit": "^7.0.8", "tap": "^15.1.6" }, diff --git a/deps/npm/node_modules/make-fetch-happen/lib/agent.js b/deps/npm/node_modules/make-fetch-happen/lib/agent.js index d28a31bfbda0cb..f64644ff611a57 100644 --- a/deps/npm/node_modules/make-fetch-happen/lib/agent.js +++ b/deps/npm/node_modules/make-fetch-happen/lib/agent.js @@ -2,6 +2,7 @@ const LRU = require('lru-cache') const url = require('url') const isLambda = require('is-lambda') +const dns = require('./dns.js') const AGENT_CACHE = new LRU({ max: 50 }) const HttpAgent = require('agentkeepalive') @@ -77,11 +78,13 @@ function getAgent (uri, opts) { rejectUnauthorized: opts.rejectUnauthorized, timeout: agentTimeout, freeSocketTimeout: 15000, + lookup: dns.getLookup(opts.dns), }) : new HttpAgent({ maxSockets: agentMaxSockets, localAddress: opts.localAddress, timeout: agentTimeout, freeSocketTimeout: 15000, + lookup: dns.getLookup(opts.dns), }) AGENT_CACHE.set(key, agent) return agent @@ -171,6 +174,8 @@ const HttpsProxyAgent = require('https-proxy-agent') const SocksProxyAgent = require('socks-proxy-agent') module.exports.getProxy = getProxy function getProxy (proxyUrl, opts, isHttps) { + // our current proxy agents do not support an overridden dns lookup method, so will not + // benefit from the dns cache const popts = { host: proxyUrl.hostname, port: proxyUrl.port, diff --git a/deps/npm/node_modules/make-fetch-happen/lib/cache/index.js b/deps/npm/node_modules/make-fetch-happen/lib/cache/index.js index 17a6425592bcf7..0de49d23fb9336 100644 --- a/deps/npm/node_modules/make-fetch-happen/lib/cache/index.js +++ b/deps/npm/node_modules/make-fetch-happen/lib/cache/index.js @@ -14,8 +14,8 @@ const cacheFetch = async (request, options) => { // otherwise, we make a request, store it and return it const response = await remote(request, options) - const entry = new CacheEntry({ request, response, options }) - return entry.store('miss') + const newEntry = new CacheEntry({ request, response, options }) + return newEntry.store('miss') } // we have a cached response that satisfies this request, however if the cache diff --git a/deps/npm/node_modules/make-fetch-happen/lib/dns.js b/deps/npm/node_modules/make-fetch-happen/lib/dns.js new file mode 100644 index 00000000000000..13102b57c4aa06 --- /dev/null +++ b/deps/npm/node_modules/make-fetch-happen/lib/dns.js @@ -0,0 +1,49 @@ +const LRUCache = require('lru-cache') +const dns = require('dns') + +const defaultOptions = exports.defaultOptions = { + family: undefined, + hints: dns.ADDRCONFIG, + all: false, + verbatim: undefined, +} + +const lookupCache = exports.lookupCache = new LRUCache({ max: 50 }) + +// this is a factory so that each request can have its own opts (i.e. ttl) +// while still sharing the cache across all requests +exports.getLookup = (dnsOptions) => { + return (hostname, options, callback) => { + if (typeof options === 'function') { + callback = options + options = null + } else if (typeof options === 'number') { + options = { family: options } + } + + options = { ...defaultOptions, ...options } + + const key = JSON.stringify({ + hostname, + family: options.family, + hints: options.hints, + all: options.all, + verbatim: options.verbatim, + }) + + if (lookupCache.has(key)) { + const [address, family] = lookupCache.get(key) + process.nextTick(callback, null, address, family) + return + } + + dnsOptions.lookup(hostname, options, (err, address, family) => { + if (err) { + return callback(err) + } + + lookupCache.set(key, [address, family], { ttl: dnsOptions.ttl }) + return callback(null, address, family) + }) + } +} diff --git a/deps/npm/node_modules/make-fetch-happen/lib/options.js b/deps/npm/node_modules/make-fetch-happen/lib/options.js index a0c8664adf02aa..daa9ecd9d5d5f2 100644 --- a/deps/npm/node_modules/make-fetch-happen/lib/options.js +++ b/deps/npm/node_modules/make-fetch-happen/lib/options.js @@ -1,3 +1,5 @@ +const dns = require('dns') + const conditionalHeaders = [ 'if-modified-since', 'if-none-match', @@ -26,6 +28,8 @@ const configureOptions = (opts) => { options.retry = { retries: 0, ...options.retry } } + options.dns = { ttl: 5 * 60 * 1000, lookup: dns.lookup, ...options.dns } + options.cache = options.cache || 'default' if (options.cache === 'default') { const hasConditionalHeader = Object.keys(options.headers || {}).some((name) => { diff --git a/deps/npm/node_modules/make-fetch-happen/package.json b/deps/npm/node_modules/make-fetch-happen/package.json index e52131b8a8e01d..0e147be69889d2 100644 --- a/deps/npm/node_modules/make-fetch-happen/package.json +++ b/deps/npm/node_modules/make-fetch-happen/package.json @@ -1,11 +1,11 @@ { "name": "make-fetch-happen", - "version": "10.0.6", + "version": "10.1.1", "description": "Opinionated, caching, retrying fetch client", "main": "lib/index.js", "files": [ - "bin", - "lib" + "bin/", + "lib/" ], "scripts": { "preversion": "npm test", @@ -14,13 +14,16 @@ "test": "tap", "posttest": "npm run lint", "eslint": "eslint", - "lint": "eslint '**/*.js'", + "lint": "eslint \"**/*.js\"", "lintfix": "npm run lint -- --fix", - "postlint": "npm-template-check", + "postlint": "template-oss-check", "snap": "tap", - "template-copy": "npm-template-copy --force" + "template-oss-apply": "template-oss-apply --force" + }, + "repository": { + "type": "git", + "url": "https://github.com/npm/make-fetch-happen.git" }, - "repository": "https://github.com/npm/make-fetch-happen", "keywords": [ "http", "request", @@ -34,12 +37,12 @@ "license": "ISC", "dependencies": { "agentkeepalive": "^4.2.1", - "cacache": "^16.0.0", + "cacache": "^16.0.2", "http-cache-semantics": "^4.1.0", "http-proxy-agent": "^5.0.0", "https-proxy-agent": "^5.0.0", "is-lambda": "^1.0.1", - "lru-cache": "^7.5.1", + "lru-cache": "^7.7.1", "minipass": "^3.1.6", "minipass-collect": "^1.0.2", "minipass-fetch": "^2.0.3", @@ -51,17 +54,17 @@ "ssri": "^8.0.1" }, "devDependencies": { - "@npmcli/template-oss": "^2.9.2", - "eslint": "^8.11.0", + "@npmcli/eslint-config": "^3.0.1", + "@npmcli/template-oss": "3.2.0", "mkdirp": "^1.0.4", "nock": "^13.2.4", "rimraf": "^3.0.2", "safe-buffer": "^5.2.1", "standard-version": "^9.3.2", - "tap": "^15.1.6" + "tap": "^16.0.0" }, "engines": { - "node": "^12.13.0 || ^14.15.0 || >=16" + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" }, "tap": { "color": 1, @@ -69,6 +72,7 @@ "check-coverage": true }, "templateOSS": { - "version": "2.9.2" + "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", + "version": "3.2.0" } } diff --git a/deps/npm/node_modules/minipass-fetch/lib/body.js b/deps/npm/node_modules/minipass-fetch/lib/body.js index 2b8e3bd2f9e83e..c7ffa5babcbc60 100644 --- a/deps/npm/node_modules/minipass-fetch/lib/body.js +++ b/deps/npm/node_modules/minipass-fetch/lib/body.js @@ -127,8 +127,10 @@ class Body { : this.size ? new MinipassSized({ size: this.size }) : new Minipass() - // allow timeout on slow response body - const resTimeout = this.timeout ? setTimeout(() => { + // allow timeout on slow response body, but only if the stream is still writable. this + // makes the timeout center on the socket stream from lib/index.js rather than the + // intermediary minipass stream we create to receive the data + const resTimeout = this.timeout && stream.writable ? setTimeout(() => { stream.emit('error', new FetchError( `Response timeout while trying to fetch ${ this.url} (over ${this.timeout}ms)`, 'body-timeout')) diff --git a/deps/npm/node_modules/minipass-fetch/lib/index.js b/deps/npm/node_modules/minipass-fetch/lib/index.js index 22257a417aff84..b1878ac0c06b50 100644 --- a/deps/npm/node_modules/minipass-fetch/lib/index.js +++ b/deps/npm/node_modules/minipass-fetch/lib/index.js @@ -255,8 +255,8 @@ const fetch = async (url, opts) => { size: request.size, timeout: request.timeout, counter: request.counter, - trailer: new Promise(resolve => - res.on('end', () => resolve(createHeadersLenient(res.trailers)))), + trailer: new Promise(resolveTrailer => + res.on('end', () => resolveTrailer(createHeadersLenient(res.trailers)))), } // HTTP-network fetch step 12.1.1.3 @@ -362,3 +362,4 @@ fetch.Headers = Headers fetch.Request = Request fetch.Response = Response fetch.FetchError = FetchError +fetch.AbortError = AbortError diff --git a/deps/npm/node_modules/minipass-fetch/package.json b/deps/npm/node_modules/minipass-fetch/package.json index 68e1ce134cd26c..1f663b9245dea0 100644 --- a/deps/npm/node_modules/minipass-fetch/package.json +++ b/deps/npm/node_modules/minipass-fetch/package.json @@ -1,6 +1,6 @@ { "name": "minipass-fetch", - "version": "2.0.3", + "version": "2.1.0", "description": "An implementation of window.fetch in Node.js using Minipass streams", "license": "MIT", "main": "lib/index.js", @@ -10,19 +10,20 @@ "preversion": "npm test", "postversion": "npm publish", "postpublish": "git push origin --follow-tags", - "lint": "eslint '**/*.js'", - "postlint": "npm-template-check", - "template-copy": "npm-template-copy --force", + "lint": "eslint \"**/*.js\"", + "postlint": "template-oss-check", "lintfix": "npm run lint -- --fix", "prepublishOnly": "git push origin --follow-tags", - "posttest": "npm run lint" + "posttest": "npm run lint", + "template-oss-apply": "template-oss-apply --force" }, "tap": { "coverage-map": "map.js", "check-coverage": true }, "devDependencies": { - "@npmcli/template-oss": "^2.9.2", + "@npmcli/eslint-config": "^3.0.1", + "@npmcli/template-oss": "3.1.2", "@ungap/url-search-params": "^0.2.2", "abort-controller": "^3.0.0", "abortcontroller-polyfill": "~1.7.3", @@ -30,7 +31,7 @@ "nock": "^13.2.4", "parted": "^0.1.1", "string-to-arraybuffer": "^1.0.2", - "tap": "^15.1.6" + "tap": "^16.0.0" }, "dependencies": { "minipass": "^3.1.6", @@ -42,7 +43,7 @@ }, "repository": { "type": "git", - "url": "git+https://github.com/npm/minipass-fetch.git" + "url": "https://github.com/npm/minipass-fetch.git" }, "keywords": [ "fetch", @@ -51,14 +52,15 @@ "window.fetch" ], "files": [ - "bin", - "lib" + "bin/", + "lib/" ], "engines": { - "node": "^12.13.0 || ^14.15.0 || >=16" + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" }, "author": "GitHub Inc.", "templateOSS": { - "version": "2.9.2" + "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", + "version": "3.1.2" } } diff --git a/deps/npm/node_modules/npm-audit-report/lib/colors.js b/deps/npm/node_modules/npm-audit-report/lib/colors.js index ad76870fd6fda6..2fbf5c36093ded 100644 --- a/deps/npm/node_modules/npm-audit-report/lib/colors.js +++ b/deps/npm/node_modules/npm-audit-report/lib/colors.js @@ -19,6 +19,6 @@ module.exports = color => { magenta, yellow, white, - severity + severity, } } diff --git a/deps/npm/node_modules/npm-audit-report/lib/exit-code.js b/deps/npm/node_modules/npm-audit-report/lib/exit-code.js index 7a32ac6db47703..fcb580b5126716 100644 --- a/deps/npm/node_modules/npm-audit-report/lib/exit-code.js +++ b/deps/npm/node_modules/npm-audit-report/lib/exit-code.js @@ -5,7 +5,7 @@ const severities = new Map(Object.entries([ 'moderate', 'high', 'critical', - 'none' + 'none', ]).map(s => s.reverse())) module.exports = (data, level) => diff --git a/deps/npm/node_modules/npm-audit-report/lib/index.js b/deps/npm/node_modules/npm-audit-report/lib/index.js index 9ee86be7915d8d..63063f92526a1b 100644 --- a/deps/npm/node_modules/npm-audit-report/lib/index.js +++ b/deps/npm/node_modules/npm-audit-report/lib/index.js @@ -4,7 +4,7 @@ const reporters = { install: require('./reporters/install'), detail: require('./reporters/detail'), json: require('./reporters/json'), - quiet: require('./reporters/quiet') + quiet: require('./reporters/quiet'), } const exitCode = require('./exit-code.js') @@ -20,20 +20,22 @@ module.exports = Object.assign((data, options = {}) => { // CLI defaults this to `null` so the defaulting method above doesn't work const auditLevel = options.auditLevel || 'low' - if (!data) + if (!data) { throw Object.assign( new TypeError('ENOAUDITDATA'), { code: 'ENOAUDITDATA', - message: 'missing audit data' + message: 'missing audit data', } ) + } - if (typeof data.toJSON === 'function') + if (typeof data.toJSON === 'function') { data = data.toJSON() + } return { report: reporters[reporter](data, { color, unicode, indent }), - exitCode: exitCode(data, auditLevel) + exitCode: exitCode(data, auditLevel), } }, { reporters }) diff --git a/deps/npm/node_modules/npm-audit-report/lib/reporters/detail.js b/deps/npm/node_modules/npm-audit-report/lib/reporters/detail.js index 50451f057972df..ba2f013836d9da 100644 --- a/deps/npm/node_modules/npm-audit-report/lib/reporters/detail.js +++ b/deps/npm/node_modules/npm-audit-report/lib/reporters/detail.js @@ -6,7 +6,7 @@ const install = require('./install.js') module.exports = (data, { color }) => { const summary = install.summary(data, { color }) const none = data.metadata.vulnerabilities.total === 0 - return none ? summary : fullReport(data, {color, summary}) + return none ? summary : fullReport(data, { color, summary }) } const fullReport = (data, { color, summary }) => { @@ -14,10 +14,11 @@ const fullReport = (data, { color, summary }) => { const output = [c.white('# npm audit report'), ''] const printed = new Set() - for (const [name, vuln] of Object.entries(data.vulnerabilities)) { + for (const [, vuln] of Object.entries(data.vulnerabilities)) { // only print starting from the top-level advisories - if (vuln.via.filter(v => typeof v !== 'string').length !== 0) - output.push(printVuln(vuln, c, data.vulnerabilities)) + if (vuln.via.filter(v => typeof v !== 'string').length !== 0) { + output.push(printVuln(vuln, c, data.vulnerabilities, printed)) + } } output.push(summary) @@ -25,9 +26,10 @@ const fullReport = (data, { color, summary }) => { return output.join('\n') } -const printVuln = (vuln, c, vulnerabilities, printed = new Set(), indent = '') => { - if (printed.has(vuln)) +const printVuln = (vuln, c, vulnerabilities, printed, indent = '') => { + if (printed.has(vuln)) { return null + } printed.add(vuln) const output = [] @@ -59,7 +61,7 @@ const printVuln = (vuln, c, vulnerabilities, printed = new Set(), indent = '') = `${c.yellow('fix available')} via \`npm audit fix --force\``, `Will install ${fa.name}@${fa.version}` + `, which is ${fa.isSemVerMajor ? 'a breaking change' : - 'outside the stated dependency range' }` + 'outside the stated dependency range'}` ) } } @@ -70,10 +72,10 @@ const printVuln = (vuln, c, vulnerabilities, printed = new Set(), indent = '') = } for (const effect of vuln.effects) { - const vuln = vulnerabilities[effect] - const e = printVuln(vuln, c, vulnerabilities, printed, ' ') - if (e) + const e = printVuln(vulnerabilities[effect], c, vulnerabilities, printed, ' ') + if (e) { output.push(...e.split('\n')) + } } if (indent === '') { diff --git a/deps/npm/node_modules/npm-audit-report/lib/reporters/install.js b/deps/npm/node_modules/npm-audit-report/lib/reporters/install.js index fe53be3adad76b..cb8a249691e299 100644 --- a/deps/npm/node_modules/npm-audit-report/lib/reporters/install.js +++ b/deps/npm/node_modules/npm-audit-report/lib/reporters/install.js @@ -3,7 +3,7 @@ const colors = require('../colors.js') const calculate = (data, { color }) => { const c = colors(color) const output = [] - const { metadata: { vulnerabilities }} = data + const { metadata: { vulnerabilities } } = data const vulnCount = vulnerabilities.total let someFixable = false @@ -14,7 +14,7 @@ const calculate = (data, { color }) => { if (vulnCount === 0) { output.push(`found ${c.green('0')} vulnerabilities`) } else { - for (const [name, vuln] of Object.entries(data.vulnerabilities)) { + for (const [, vuln] of Object.entries(data.vulnerabilities)) { const { fixAvailable } = vuln someFixable = someFixable || fixAvailable === true someUnfixable = someUnfixable || fixAvailable === false @@ -45,7 +45,7 @@ const calculate = (data, { color }) => { if (someFixable) { output.push('', 'To address ' + (someForceFixable || someUnfixable ? 'issues that do not require attention' - : 'all issues') + ', run:\n npm audit fix') + : 'all issues') + ', run:\n npm audit fix') } if (someForceFixable) { @@ -66,10 +66,10 @@ const calculate = (data, { color }) => { return { summary, report: vulnCount > 0 ? `${summary}\n\nRun \`npm audit\` for details.` - : summary + : summary, } } module.exports = Object.assign((data, opt) => calculate(data, opt).report, { - summary: (data, opt) => calculate(data, opt).summary + summary: (data, opt) => calculate(data, opt).summary, }) diff --git a/deps/npm/node_modules/npm-audit-report/package.json b/deps/npm/node_modules/npm-audit-report/package.json index c819b9608412ac..8749c14582fa90 100644 --- a/deps/npm/node_modules/npm-audit-report/package.json +++ b/deps/npm/node_modules/npm-audit-report/package.json @@ -1,6 +1,6 @@ { "name": "npm-audit-report", - "version": "2.1.5", + "version": "3.0.0", "description": "Given a response from the npm security api, render it into a variety of security reports", "main": "lib/index.js", "scripts": { @@ -8,7 +8,12 @@ "snap": "tap", "preversion": "npm test", "postversion": "npm publish", - "prepublishOnly": "git push origin --follow-tags" + "prepublishOnly": "git push origin --follow-tags", + "lint": "eslint \"**/*.js\"", + "postlint": "template-oss-check", + "template-oss-apply": "template-oss-apply --force", + "lintfix": "npm run lint -- --fix", + "posttest": "npm run lint" }, "tap": { "check-coverage": true, @@ -20,14 +25,16 @@ "report", "audit" ], - "author": "Adam Baldwin", + "author": "GitHub Inc.", "license": "ISC", "dependencies": { "chalk": "^4.0.0" }, "devDependencies": { + "@npmcli/eslint-config": "^3.0.1", + "@npmcli/template-oss": "3.1.2", "require-inject": "^1.4.4", - "tap": "^14.10.7" + "tap": "^16.0.0" }, "directories": { "lib": "lib", @@ -35,18 +42,22 @@ }, "repository": { "type": "git", - "url": "git+https://github.com/npm/npm-audit-report.git" + "url": "https://github.com/npm/npm-audit-report.git" }, "bugs": { "url": "https://github.com/npm/npm-audit-report/issues" }, "homepage": "https://github.com/npm/npm-audit-report#readme", "files": [ - "index.js", - "lib", + "bin/", + "lib/", "reporters" ], "engines": { - "node": ">=10" + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + }, + "templateOSS": { + "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", + "version": "3.1.2" } } diff --git a/deps/npm/node_modules/npm-package-arg/README.md b/deps/npm/node_modules/npm-package-arg/README.md new file mode 100644 index 00000000000000..3f00b61d54dfa4 --- /dev/null +++ b/deps/npm/node_modules/npm-package-arg/README.md @@ -0,0 +1,86 @@ +# npm-package-arg + +[![Build Status](https://travis-ci.org/npm/npm-package-arg.svg?branch=master)](https://travis-ci.org/npm/npm-package-arg) + +Parses package name and specifier passed to commands like `npm install` or +`npm cache add`, or as found in `package.json` dependency sections. + +## EXAMPLES + +```javascript +var assert = require("assert") +var npa = require("npm-package-arg") + +// Pass in the descriptor, and it'll return an object +try { + var parsed = npa("@bar/foo@1.2") +} catch (ex) { + … +} +``` + +## USING + +`var npa = require('npm-package-arg')` + +### var result = npa(*arg*[, *where*]) + +* *arg* - a string that you might pass to `npm install`, like: +`foo@1.2`, `@bar/foo@1.2`, `foo@user/foo`, `http://x.com/foo.tgz`, +`git+https://github.com/user/foo`, `bitbucket:user/foo`, `foo.tar.gz`, +`../foo/bar/` or `bar`. If the *arg* you provide doesn't have a specifier +part, eg `foo` then the specifier will default to `latest`. +* *where* - Optionally the path to resolve file paths relative to. Defaults to `process.cwd()` + +**Throws** if the package name is invalid, a dist-tag is invalid or a URL's protocol is not supported. + +### var result = npa.resolve(*name*, *spec*[, *where*]) + +* *name* - The name of the module you want to install. For example: `foo` or `@bar/foo`. +* *spec* - The specifier indicating where and how you can get this module. Something like: +`1.2`, `^1.7.17`, `http://x.com/foo.tgz`, `git+https://github.com/user/foo`, +`bitbucket:user/foo`, `file:foo.tar.gz` or `file:../foo/bar/`. If not +included then the default is `latest`. +* *where* - Optionally the path to resolve file paths relative to. Defaults to `process.cwd()` + +**Throws** if the package name is invalid, a dist-tag is invalid or a URL's protocol is not supported. + +## RESULT OBJECT + +The objects that are returned by npm-package-arg contain the following +keys: + +* `type` - One of the following strings: + * `git` - A git repo + * `tag` - A tagged version, like `"foo@latest"` + * `version` - A specific version number, like `"foo@1.2.3"` + * `range` - A version range, like `"foo@2.x"` + * `file` - A local `.tar.gz`, `.tar` or `.tgz` file. + * `directory` - A local directory. + * `remote` - An http url (presumably to a tgz) + * `alias` - A specifier with an alias, like `myalias@npm:foo@1.2.3` +* `registry` - If true this specifier refers to a resource hosted on a + registry. This is true for `tag`, `version` and `range` types. +* `name` - If known, the `name` field expected in the resulting pkg. +* `scope` - If a name is something like `@org/module` then the `scope` + field will be set to `@org`. If it doesn't have a scoped name, then + scope is `null`. +* `escapedName` - A version of `name` escaped to match the npm scoped packages + specification. Mostly used when making requests against a registry. When + `name` is `null`, `escapedName` will also be `null`. +* `rawSpec` - The specifier part that was parsed out in calls to `npa(arg)`, + or the value of `spec` in calls to `npa.resolve(name, spec). +* `saveSpec` - The normalized specifier, for saving to package.json files. + `null` for registry dependencies. +* `fetchSpec` - The version of the specifier to be used to fetch this + resource. `null` for shortcuts to hosted git dependencies as there isn't + just one URL to try with them. +* `gitRange` - If set, this is a semver specifier to match against git tags with +* `gitCommittish` - If set, this is the specific committish to use with a git dependency. +* `hosted` - If `from === 'hosted'` then this will be a `hosted-git-info` + object. This property is not included when serializing the object as + JSON. +* `raw` - The original un-modified string that was provided. If called as + `npa.resolve(name, spec)` then this will be `name + '@' + spec`. +* `subSpec` - If `type === 'alias'`, this is a Result Object for parsing the + target specifier for the alias. diff --git a/deps/npm/node_modules/npm-package-arg/package.json b/deps/npm/node_modules/npm-package-arg/package.json index 25356af3739824..457f1d8a2f83d3 100644 --- a/deps/npm/node_modules/npm-package-arg/package.json +++ b/deps/npm/node_modules/npm-package-arg/package.json @@ -1,23 +1,24 @@ { "name": "npm-package-arg", - "version": "9.0.1", + "version": "9.0.2", "description": "Parse the things that can be arguments to `npm install`", "main": "./lib/npa.js", "directories": { "test": "test" }, "files": [ - "bin", - "lib" + "bin/", + "lib/" ], "dependencies": { "hosted-git-info": "^5.0.0", "semver": "^7.3.5", - "validate-npm-package-name": "^3.0.0" + "validate-npm-package-name": "^4.0.0" }, "devDependencies": { - "@npmcli/template-oss": "^2.9.2", - "tap": "^15.1.6" + "@npmcli/eslint-config": "^3.0.1", + "@npmcli/template-oss": "3.2.1", + "tap": "^16.0.1" }, "scripts": { "preversion": "npm test", @@ -26,16 +27,16 @@ "test": "tap", "snap": "tap", "npmclilint": "npmcli-lint", - "lint": "eslint '**/*.js'", + "lint": "eslint \"**/*.js\"", "lintfix": "npm run lint -- --fix", "posttest": "npm run lint", "postsnap": "npm run lintfix --", - "postlint": "npm-template-check", - "template-copy": "npm-template-copy --force" + "postlint": "template-oss-check", + "template-oss-apply": "template-oss-apply --force" }, "repository": { "type": "git", - "url": "https://github.com/npm/npm-package-arg" + "url": "https://github.com/npm/npm-package-arg.git" }, "author": "GitHub Inc.", "license": "ISC", @@ -44,12 +45,13 @@ }, "homepage": "https://github.com/npm/npm-package-arg", "engines": { - "node": "^12.13.0 || ^14.15.0 || >=16" + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" }, "tap": { "branches": 97 }, "templateOSS": { - "version": "2.9.2" + "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", + "version": "3.2.1" } } diff --git a/deps/npm/node_modules/npm-registry-fetch/lib/check-response.js b/deps/npm/node_modules/npm-registry-fetch/lib/check-response.js index 872ec8a8886940..714513908df40c 100644 --- a/deps/npm/node_modules/npm-registry-fetch/lib/check-response.js +++ b/deps/npm/node_modules/npm-registry-fetch/lib/check-response.js @@ -4,6 +4,7 @@ const errors = require('./errors.js') const { Response } = require('minipass-fetch') const defaultOpts = require('./default-opts.js') const log = require('proc-log') +const cleanUrl = require('./clean-url.js') /* eslint-disable-next-line max-len */ const moreInfoUrl = 'https://github.com/npm/cli/wiki/No-auth-for-URI,-but-auth-present-for-scoped-registry' @@ -45,19 +46,7 @@ function logRequest (method, res, startTime) { const attemptStr = attempt && attempt > 1 ? ` attempt #${attempt}` : '' const cacheStatus = res.headers.get('x-local-cache-status') const cacheStr = cacheStatus ? ` (cache ${cacheStatus})` : '' - - let urlStr - try { - const { URL } = require('url') - const url = new URL(res.url) - if (url.password) { - url.password = '***' - } - - urlStr = url.toString() - } catch (er) { - urlStr = res.url - } + const urlStr = cleanUrl(res.url) log.http( 'fetch', diff --git a/deps/npm/node_modules/npm-registry-fetch/lib/clean-url.js b/deps/npm/node_modules/npm-registry-fetch/lib/clean-url.js new file mode 100644 index 00000000000000..ba31dc462f3c5d --- /dev/null +++ b/deps/npm/node_modules/npm-registry-fetch/lib/clean-url.js @@ -0,0 +1,24 @@ +const { URL } = require('url') + +const replace = '***' +const tokenRegex = /\bnpm_[a-zA-Z0-9]{36}\b/g +const guidRegex = /\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b/g + +const cleanUrl = (str) => { + if (typeof str !== 'string' || !str) { + return str + } + + try { + const url = new URL(str) + if (url.password) { + str = str.replace(url.password, replace) + } + } catch {} + + return str + .replace(tokenRegex, `npm_${replace}`) + .replace(guidRegex, `npm_${replace}`) +} + +module.exports = cleanUrl diff --git a/deps/npm/node_modules/npm-registry-fetch/lib/index.js b/deps/npm/node_modules/npm-registry-fetch/lib/index.js index 19c921403e5cd0..6c834aa4af5ef0 100644 --- a/deps/npm/node_modules/npm-registry-fetch/lib/index.js +++ b/deps/npm/node_modules/npm-registry-fetch/lib/index.js @@ -104,11 +104,11 @@ function regFetch (uri, /* istanbul ignore next */ opts_ = {}) { opts.preferOnline = true } - const doFetch = async body => { + const doFetch = async fetchBody => { const p = fetch(uri, { agent: opts.agent, algorithms: opts.algorithms, - body, + body: fetchBody, cache: getCacheMode(opts), cachePath: opts.cache, ca: opts.ca, @@ -239,3 +239,5 @@ function getHeaders (uri, auth, opts) { return headers } + +module.exports.cleanUrl = require('./clean-url.js') diff --git a/deps/npm/node_modules/npm-registry-fetch/lib/silentlog.js b/deps/npm/node_modules/npm-registry-fetch/lib/silentlog.js deleted file mode 100644 index 483bd44c7086af..00000000000000 --- a/deps/npm/node_modules/npm-registry-fetch/lib/silentlog.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict' - -const noop = Function.prototype -module.exports = { - error: noop, - warn: noop, - notice: noop, - info: noop, - verbose: noop, - silly: noop, - http: noop, - pause: noop, - resume: noop, -} diff --git a/deps/npm/node_modules/npm-registry-fetch/package.json b/deps/npm/node_modules/npm-registry-fetch/package.json index 75236be2a9015f..9e15f627cd5a73 100644 --- a/deps/npm/node_modules/npm-registry-fetch/package.json +++ b/deps/npm/node_modules/npm-registry-fetch/package.json @@ -1,15 +1,15 @@ { "name": "npm-registry-fetch", - "version": "13.0.1", + "version": "13.1.0", "description": "Fetch-based http client for use with npm registry APIs", "main": "lib", "files": [ - "bin", - "lib" + "bin/", + "lib/" ], "scripts": { "eslint": "eslint", - "lint": "eslint '**/*.js'", + "lint": "eslint \"**/*.js\"", "lintfix": "npm run lint -- --fix", "prepublishOnly": "git push origin --follow-tags", "preversion": "npm test", @@ -18,11 +18,14 @@ "posttest": "npm run lint", "npmclilint": "npmcli-lint", "postsnap": "npm run lintfix --", - "postlint": "npm-template-check", + "postlint": "template-oss-check", "snap": "tap", - "template-copy": "npm-template-copy --force" + "template-oss-apply": "template-oss-apply --force" + }, + "repository": { + "type": "git", + "url": "https://github.com/npm/npm-registry-fetch.git" }, - "repository": "https://github.com/npm/npm-registry-fetch", "keywords": [ "npm", "registry", @@ -31,17 +34,18 @@ "author": "GitHub Inc.", "license": "ISC", "dependencies": { - "make-fetch-happen": "^10.0.3", + "make-fetch-happen": "^10.0.6", "minipass": "^3.1.6", - "minipass-fetch": "^2.0.1", + "minipass-fetch": "^2.0.3", "minipass-json-stream": "^1.0.1", "minizlib": "^2.1.2", - "npm-package-arg": "^9.0.0", + "npm-package-arg": "^9.0.1", "proc-log": "^2.0.0" }, "devDependencies": { - "@npmcli/template-oss": "^2.8.1", - "cacache": "^15.3.0", + "@npmcli/eslint-config": "^3.0.1", + "@npmcli/template-oss": "3.1.2", + "cacache": "^16.0.2", "nock": "^13.2.4", "require-inject": "^1.4.4", "ssri": "^8.0.1", @@ -52,9 +56,10 @@ "test-ignore": "test[\\\\/](util|cache)[\\\\/]" }, "engines": { - "node": "^12.13.0 || ^14.15.0 || >=16" + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" }, "templateOSS": { - "version": "2.8.1" + "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", + "version": "3.1.2" } } diff --git a/deps/npm/node_modules/parse-conflict-json/package.json b/deps/npm/node_modules/parse-conflict-json/package.json index bb633e158b5d13..5dab68d52f7cad 100644 --- a/deps/npm/node_modules/parse-conflict-json/package.json +++ b/deps/npm/node_modules/parse-conflict-json/package.json @@ -1,6 +1,6 @@ { "name": "parse-conflict-json", - "version": "2.0.1", + "version": "2.0.2", "description": "Parse a JSON string that has git merge conflicts, resolving if possible", "author": "GitHub Inc.", "license": "ISC", @@ -11,34 +11,39 @@ "preversion": "npm test", "postversion": "npm publish", "postpublish": "git push origin --follow-tags", - "lint": "eslint '**/*.js'", - "postlint": "npm-template-check", + "lint": "eslint \"**/*.js\"", + "postlint": "template-oss-check", "lintfix": "npm run lint -- --fix", "prepublishOnly": "git push origin --follow-tags", - "posttest": "npm run lint" + "posttest": "npm run lint", + "template-oss-apply": "template-oss-apply --force" }, "tap": { "check-coverage": true }, "devDependencies": { - "@npmcli/template-oss": "^2.3.1", - "tap": "^15.1.5" + "@npmcli/eslint-config": "^3.0.1", + "@npmcli/template-oss": "3.2.0", + "tap": "^16.0.1" }, "dependencies": { "json-parse-even-better-errors": "^2.3.1", "just-diff": "^5.0.1", - "just-diff-apply": "^4.0.1" + "just-diff-apply": "^5.2.0" }, "repository": { "type": "git", - "url": "git+https://github.com/npm/parse-conflict-json.git" + "url": "https://github.com/npm/parse-conflict-json.git" }, "files": [ - "bin", - "lib" + "bin/", + "lib/" ], - "templateVersion": "2.3.1", "engines": { - "node": "^12.13.0 || ^14.15.0 || >=16" + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + }, + "templateOSS": { + "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", + "version": "3.2.0" } } diff --git a/deps/npm/node_modules/proc-log/package.json b/deps/npm/node_modules/proc-log/package.json index 17e9249b7ca469..ca2f1c771d8e90 100644 --- a/deps/npm/node_modules/proc-log/package.json +++ b/deps/npm/node_modules/proc-log/package.json @@ -1,13 +1,16 @@ { "name": "proc-log", - "version": "2.0.0", + "version": "2.0.1", "files": [ - "bin", - "lib" + "bin/", + "lib/" ], "main": "lib/index.js", "description": "just emit 'log' events on the process object", - "repository": "https://github.com/npm/proc-log", + "repository": { + "type": "git", + "url": "https://github.com/npm/proc-log.git" + }, "author": "GitHub Inc.", "license": "ISC", "scripts": { @@ -18,19 +21,21 @@ "preversion": "npm test", "postversion": "npm publish", "prepublishOnly": "git push origin --follow-tags", - "lint": "eslint '**/*.js'", - "postlint": "npm-template-check", - "template-copy": "npm-template-copy --force", - "lintfix": "npm run lint -- --fix" + "lint": "eslint \"**/*.js\"", + "postlint": "template-oss-check", + "lintfix": "npm run lint -- --fix", + "template-oss-apply": "template-oss-apply --force" }, "devDependencies": { - "@npmcli/template-oss": "^2.7.1", - "tap": "^15.1.6" + "@npmcli/eslint-config": "^3.0.1", + "@npmcli/template-oss": "3.2.0", + "tap": "^16.0.1" }, "engines": { - "node": "^12.13.0 || ^14.15.0 || >=16" + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" }, "templateOSS": { - "version": "2.7.1" + "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", + "version": "3.2.0" } } diff --git a/deps/npm/node_modules/validate-npm-package-name/index.js b/deps/npm/node_modules/validate-npm-package-name/lib/index.js similarity index 83% rename from deps/npm/node_modules/validate-npm-package-name/index.js rename to deps/npm/node_modules/validate-npm-package-name/lib/index.js index eb43fa25e56aee..e7e612bfbdf4d5 100644 --- a/deps/npm/node_modules/validate-npm-package-name/index.js +++ b/deps/npm/node_modules/validate-npm-package-name/lib/index.js @@ -4,10 +4,10 @@ var scopedPackagePattern = new RegExp('^(?:@([^/]+?)[/])?([^/]+?)$') var builtins = require('builtins') var blacklist = [ 'node_modules', - 'favicon.ico' + 'favicon.ico', ] -var validate = module.exports = function (name) { +function validate (name) { var warnings = [] var errors = [] @@ -52,14 +52,12 @@ var validate = module.exports = function (name) { // Generate warnings for stuff that used to be allowed // core module names like http, events, util, etc - builtins.forEach(function (builtin) { + builtins({ version: '*' }).forEach(function (builtin) { if (name.toLowerCase() === builtin) { warnings.push(builtin + ' is a core module name') } }) - // really-long-package-names-------------------------------such--length-----many---wow - // the thisisareallyreallylongpackagenameitshouldpublishdowenowhavealimittothelengthofpackagenames-poch. if (name.length > 214) { warnings.push('name can no longer contain more than 214 characters') } @@ -90,16 +88,20 @@ var validate = module.exports = function (name) { return done(warnings, errors) } -validate.scopedPackagePattern = scopedPackagePattern - var done = function (warnings, errors) { var result = { validForNewPackages: errors.length === 0 && warnings.length === 0, validForOldPackages: errors.length === 0, warnings: warnings, - errors: errors + errors: errors, + } + if (!result.warnings.length) { + delete result.warnings + } + if (!result.errors.length) { + delete result.errors } - if (!result.warnings.length) delete result.warnings - if (!result.errors.length) delete result.errors return result } + +module.exports = validate diff --git a/deps/npm/node_modules/validate-npm-package-name/package.json b/deps/npm/node_modules/validate-npm-package-name/package.json index b72e9ef03b08c7..fa9a6920d411fd 100644 --- a/deps/npm/node_modules/validate-npm-package-name/package.json +++ b/deps/npm/node_modules/validate-npm-package-name/package.json @@ -1,27 +1,37 @@ { "name": "validate-npm-package-name", - "version": "3.0.0", + "version": "4.0.0", "description": "Give me a string and I'll tell you if it's a valid npm package name", - "main": "index.js", + "main": "lib/", "directories": { "test": "test" }, "dependencies": { - "builtins": "^1.0.3" + "builtins": "^5.0.0" }, "devDependencies": { - "standard": "^8.6.0", - "tap": "^10.0.0" + "@npmcli/eslint-config": "^3.0.1", + "@npmcli/template-oss": "3.2.1", + "tap": "^16.0.1" }, "scripts": { "cov:test": "TAP_FLAGS='--cov' npm run test:code", "test:code": "tap ${TAP_FLAGS:-'--'} test/*.js", "test:style": "standard", - "test": "npm run test:code && npm run test:style" + "test": "tap", + "lint": "eslint \"**/*.js\"", + "postlint": "template-oss-check", + "template-oss-apply": "template-oss-apply --force", + "lintfix": "npm run lint -- --fix", + "preversion": "npm test", + "postversion": "npm publish", + "prepublishOnly": "git push origin --follow-tags", + "snap": "tap", + "posttest": "npm run lint" }, "repository": { "type": "git", - "url": "https://github.com/npm/validate-npm-package-name" + "url": "https://github.com/npm/validate-npm-package-name.git" }, "keywords": [ "npm", @@ -29,10 +39,26 @@ "names", "validation" ], - "author": "zeke", + "author": "GitHub Inc.", "license": "ISC", "bugs": { "url": "https://github.com/npm/validate-npm-package-name/issues" }, - "homepage": "https://github.com/npm/validate-npm-package-name" + "homepage": "https://github.com/npm/validate-npm-package-name", + "files": [ + "bin/", + "lib/" + ], + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + }, + "templateOSS": { + "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", + "version": "3.2.1" + }, + "tap": { + "statements": 88, + "branches": 92, + "lines": 88 + } } diff --git a/deps/npm/node_modules/validate-npm-package-name/test/index.js b/deps/npm/node_modules/validate-npm-package-name/test/index.js deleted file mode 100644 index 1f0bc61235087f..00000000000000 --- a/deps/npm/node_modules/validate-npm-package-name/test/index.js +++ /dev/null @@ -1,109 +0,0 @@ -'use strict' - -var validate = require('..') -var test = require('tap').test - -test('validate-npm-package-name', function (t) { - // Traditional - - t.deepEqual(validate('some-package'), {validForNewPackages: true, validForOldPackages: true}) - t.deepEqual(validate('example.com'), {validForNewPackages: true, validForOldPackages: true}) - t.deepEqual(validate('under_score'), {validForNewPackages: true, validForOldPackages: true}) - t.deepEqual(validate('period.js'), {validForNewPackages: true, validForOldPackages: true}) - t.deepEqual(validate('123numeric'), {validForNewPackages: true, validForOldPackages: true}) - t.deepEqual(validate('crazy!'), { - validForNewPackages: false, - validForOldPackages: true, - warnings: ['name can no longer contain special characters ("~\'!()*")'] - }) - - // Scoped (npm 2+) - - t.deepEqual(validate('@npm/thingy'), {validForNewPackages: true, validForOldPackages: true}) - t.deepEqual(validate('@npm-zors/money!time.js'), { - validForNewPackages: false, - validForOldPackages: true, - warnings: ['name can no longer contain special characters ("~\'!()*")'] - }) - - // Invalid - - t.deepEqual(validate(''), { - validForNewPackages: false, - validForOldPackages: false, - errors: ['name length must be greater than zero']}) - - t.deepEqual(validate(''), { - validForNewPackages: false, - validForOldPackages: false, - errors: ['name length must be greater than zero']}) - - t.deepEqual(validate('.start-with-period'), { - validForNewPackages: false, - validForOldPackages: false, - errors: ['name cannot start with a period']}) - - t.deepEqual(validate('_start-with-underscore'), { - validForNewPackages: false, - validForOldPackages: false, - errors: ['name cannot start with an underscore']}) - - t.deepEqual(validate('contain:colons'), { - validForNewPackages: false, - validForOldPackages: false, - errors: ['name can only contain URL-friendly characters']}) - - t.deepEqual(validate(' leading-space'), { - validForNewPackages: false, - validForOldPackages: false, - errors: ['name cannot contain leading or trailing spaces', 'name can only contain URL-friendly characters']}) - - t.deepEqual(validate('trailing-space '), { - validForNewPackages: false, - validForOldPackages: false, - errors: ['name cannot contain leading or trailing spaces', 'name can only contain URL-friendly characters']}) - - t.deepEqual(validate('s/l/a/s/h/e/s'), { - validForNewPackages: false, - validForOldPackages: false, - errors: ['name can only contain URL-friendly characters']}) - - t.deepEqual(validate('node_modules'), { - validForNewPackages: false, - validForOldPackages: false, - errors: ['node_modules is a blacklisted name']}) - - t.deepEqual(validate('favicon.ico'), { - validForNewPackages: false, - validForOldPackages: false, - errors: ['favicon.ico is a blacklisted name']}) - - // Node/IO Core - - t.deepEqual(validate('http'), { - validForNewPackages: false, - validForOldPackages: true, - warnings: ['http is a core module name']}) - - // Long Package Names - - t.deepEqual(validate('ifyouwanttogetthesumoftwonumberswherethosetwonumbersarechosenbyfindingthelargestoftwooutofthreenumbersandsquaringthemwhichismultiplyingthembyitselfthenyoushouldinputthreenumbersintothisfunctionanditwilldothatforyou-'), { - validForNewPackages: false, - validForOldPackages: true, - warnings: ['name can no longer contain more than 214 characters'] - }) - - t.deepEqual(validate('ifyouwanttogetthesumoftwonumberswherethosetwonumbersarechosenbyfindingthelargestoftwooutofthreenumbersandsquaringthemwhichismultiplyingthembyitselfthenyoushouldinputthreenumbersintothisfunctionanditwilldothatforyou'), { - validForNewPackages: true, - validForOldPackages: true - }) - - // Legacy Mixed-Case - - t.deepEqual(validate('CAPITAL-LETTERS'), { - validForNewPackages: false, - validForOldPackages: true, - warnings: ['name can no longer contain capital letters']}) - - t.end() -}) diff --git a/deps/npm/package.json b/deps/npm/package.json index d51ffcd4dc4fba..9d4ff2f1de31be 100644 --- a/deps/npm/package.json +++ b/deps/npm/package.json @@ -1,5 +1,5 @@ { - "version": "8.5.5", + "version": "8.6.0", "name": "npm", "description": "a package manager for JavaScript", "workspaces": [ @@ -55,9 +55,10 @@ }, "dependencies": { "@isaacs/string-locale-compare": "^1.1.0", - "@npmcli/arborist": "^5.0.3", + "@npmcli/arborist": "^5.0.4", "@npmcli/ci-detect": "^2.0.0", "@npmcli/config": "^4.0.1", + "@npmcli/fs": "^2.1.0", "@npmcli/map-workspaces": "^2.0.2", "@npmcli/package-json": "^1.0.1", "@npmcli/run-script": "^3.0.1", @@ -65,7 +66,7 @@ "ansicolors": "~0.3.2", "ansistyles": "~0.1.3", "archy": "~1.0.0", - "cacache": "^16.0.2", + "cacache": "^16.0.3", "chalk": "^4.1.2", "chownr": "^2.0.0", "cli-columns": "^4.0.0", @@ -76,7 +77,7 @@ "graceful-fs": "^4.2.9", "hosted-git-info": "^5.0.0", "ini": "^2.0.0", - "init-package-json": "^3.0.1", + "init-package-json": "^3.0.2", "is-cidr": "^4.0.2", "json-parse-even-better-errors": "^2.3.1", "libnpmaccess": "^6.0.2", @@ -90,7 +91,7 @@ "libnpmsearch": "^5.0.2", "libnpmteam": "^4.0.2", "libnpmversion": "^3.0.1", - "make-fetch-happen": "^10.0.6", + "make-fetch-happen": "^10.1.1", "minipass": "^3.1.6", "minipass-pipeline": "^1.2.4", "mkdirp": "^1.0.4", @@ -98,18 +99,18 @@ "ms": "^2.1.2", "node-gyp": "^9.0.0", "nopt": "^5.0.0", - "npm-audit-report": "^2.1.5", + "npm-audit-report": "^3.0.0", "npm-install-checks": "^4.0.0", "npm-package-arg": "^9.0.1", "npm-pick-manifest": "^7.0.0", "npm-profile": "^6.0.2", - "npm-registry-fetch": "^13.0.1", + "npm-registry-fetch": "^13.1.0", "npm-user-validate": "^1.0.1", "npmlog": "^6.0.1", "opener": "^1.5.2", "pacote": "^13.0.5", - "parse-conflict-json": "^2.0.1", - "proc-log": "^2.0.0", + "parse-conflict-json": "^2.0.2", + "proc-log": "^2.0.1", "qrcode-terminal": "^0.12.0", "read": "~1.0.7", "read-package-json": "^5.0.0", @@ -122,7 +123,7 @@ "text-table": "~0.2.0", "tiny-relative-date": "^1.3.0", "treeverse": "^1.0.4", - "validate-npm-package-name": "~3.0.0", + "validate-npm-package-name": "^4.0.0", "which": "^2.0.2", "write-file-atomic": "^4.0.1" }, @@ -131,6 +132,7 @@ "@npmcli/arborist", "@npmcli/ci-detect", "@npmcli/config", + "@npmcli/fs", "@npmcli/map-workspaces", "@npmcli/package-json", "@npmcli/run-script", @@ -200,13 +202,12 @@ "write-file-atomic" ], "devDependencies": { - "@npmcli/eslint-config": "^2.0.0", - "@npmcli/template-oss": "^2.9.2", - "eslint": "^8.3.0", + "@npmcli/eslint-config": "^3.0.1", + "@npmcli/template-oss": "3.2.2", "licensee": "^8.2.0", "nock": "^13.2.4", "spawk": "^1.7.1", - "tap": "^15.1.6" + "tap": "^15.2.3" }, "scripts": { "dumpconf": "env | grep npm | sort | uniq", @@ -214,19 +215,18 @@ "licenses": "licensee --production --errors-only", "test": "tap", "test-all": "npm run test --if-present --workspaces --include-workspace-root", - "check-coverage": "tap", "snap": "tap", "postsnap": "make -s mandocs", "test:nocleanup": "NO_TEST_CLEANUP=1 npm run test --", "sudotest": "sudo npm run test --", "sudotest:nocleanup": "sudo NO_TEST_CLEANUP=1 npm run test --", "posttest": "npm run lint", - "eslint": "eslint", - "lint": "npm run eslint -- bin lib scripts smoke-tests test ./*.js", + "lint": "eslint \"**/*.js\"", "lintfix": "npm run lint -- --fix", + "lint-all": "npm run lint --if-present --workspaces --include-workspace-root", "prelint": "rimraf test/npm_cache*", "resetdeps": "bash scripts/resetdeps.sh", - "smoke-tests": "tap smoke-tests/index.js" + "smoke-tests": "tap smoke-tests/index.js --no-coverage" }, "tap": { "test-env": [ @@ -235,28 +235,12 @@ "color": 1, "files": "test/{lib,bin,index.js}", "coverage-map": "test/coverage-map.js", - "check-coverage": true, "timeout": 600 }, "templateOSS": { - "applyRootRepoFiles": false, - "applyWorkspaceRepoFiles": true, - "applyRootModuleFiles": false, - "workspaces": [ - "@npmcli/arborist", - "libnpmaccess", - "libnpmdiff", - "libnpmfund", - "libnpmexec", - "libnpmorg", - "libnpmhook", - "libnpmpack", - "libnpmpublish", - "libnpmsearch", - "libnpmteam", - "libnpmversion" - ], - "version": "2.9.2" + "rootRepo": false, + "rootModule": false, + "version": "3.2.2" }, "license": "Artistic-2.0", "engines": { diff --git a/deps/npm/tap-snapshots/test/lib/commands/completion.js.test.cjs b/deps/npm/tap-snapshots/test/lib/commands/completion.js.test.cjs index 4fa3a2179e6ee5..232cfec669778f 100644 --- a/deps/npm/tap-snapshots/test/lib/commands/completion.js.test.cjs +++ b/deps/npm/tap-snapshots/test/lib/commands/completion.js.test.cjs @@ -44,72 +44,84 @@ exports[`test/lib/commands/completion.js TAP completion double dashes escape fro Array [ Array [ String( - ci - install-ci-test - install - install-test - uninstall + access + adduser + audit + bin + bugs cache + ci + completion config - set - get - update - outdated - prune - pack - find-dupes dedupe + deprecate + diff + dist-tag + docs + doctor + edit + exec + explain + explore + find-dupes + fund + get + help hook - rebuild + init + install + install-ci-test + install-test link - publish - star - stars - unstar - adduser + ll login logout - unpublish - owner - access - team - deprecate - shrinkwrap - token - profile - audit - fund - org - help ls - ll - search - view - init - version - edit - explore - docs - repo - bugs - root - prefix - bin - whoami - diff - dist-tag + org + outdated + owner + pack ping pkg - test - stop - start + prefix + profile + prune + publish + rebuild + repo restart + root run-script + search + set set-script - completion - doctor - exec - explain + shrinkwrap + star + stars + start + stop + team + test + token + uninstall + unpublish + unstar + update + version + view + whoami + login + author + home + issues + info + show + find + add + unlink + remove + rm + r un rb list @@ -150,23 +162,11 @@ Array [ dist-tags upgrade udpate - login - add-user - author - home - issues - info - show - find - add - unlink - remove - rm - r rum sit urn ogr + add-user ), ], ] @@ -198,12 +198,12 @@ exports[`test/lib/commands/completion.js TAP completion multiple command names > Array [ Array [ String( - adduser access + adduser audit - add-user author add + add-user ), ], ] diff --git a/deps/npm/tap-snapshots/test/lib/commands/config.js.test.cjs b/deps/npm/tap-snapshots/test/lib/commands/config.js.test.cjs index 35c8e616591379..8d62c7ff7e15f7 100644 --- a/deps/npm/tap-snapshots/test/lib/commands/config.js.test.cjs +++ b/deps/npm/tap-snapshots/test/lib/commands/config.js.test.cjs @@ -89,6 +89,7 @@ exports[`test/lib/commands/config.js TAP config list --json > output matches sna "location": "user", "lockfile-version": null, "loglevel": "notice", + "logs-dir": null, "logs-max": 10, "long": false, "maxsockets": 15, @@ -155,6 +156,7 @@ exports[`test/lib/commands/config.js TAP config list --json > output matches sna "which": null, "workspace": [], "workspaces": null, + "workspaces-update": true, "yes": null, "metrics-registry": "https://registry.npmjs.org/" } @@ -241,6 +243,7 @@ local-address = null location = "user" lockfile-version = null loglevel = "notice" +logs-dir = null logs-max = 10 ; long = false ; overridden by cli maxsockets = 15 @@ -308,6 +311,7 @@ viewer = "{VIEWER}" which = null workspace = [] workspaces = null +workspaces-update = true yes = null ; "global" config from {GLOBALPREFIX}/npmrc diff --git a/deps/npm/tap-snapshots/test/lib/commands/unpublish.js.test.cjs b/deps/npm/tap-snapshots/test/lib/commands/unpublish.js.test.cjs deleted file mode 100644 index d84f26f299868f..00000000000000 --- a/deps/npm/tap-snapshots/test/lib/commands/unpublish.js.test.cjs +++ /dev/null @@ -1,14 +0,0 @@ -/* IMPORTANT - * This snapshot file is auto-generated, but designed for humans. - * It should be checked into source control and tracked carefully. - * Re-generate by setting TAP_SNAPSHOT=1 and running tests. - * Make sure to inspect the output below. Do not ignore changes! - */ -'use strict' -exports[`test/lib/commands/unpublish.js TAP workspaces all workspaces --force > should output all workspaces 1`] = ` -- workspace-a- workspace-b- workspace-n -` - -exports[`test/lib/commands/unpublish.js TAP workspaces one workspace --force > should output one workspaces 1`] = ` -- workspace-a -` diff --git a/deps/npm/tap-snapshots/test/lib/commands/version.js.test.cjs b/deps/npm/tap-snapshots/test/lib/commands/version.js.test.cjs new file mode 100644 index 00000000000000..e19f9b8eef14e6 --- /dev/null +++ b/deps/npm/tap-snapshots/test/lib/commands/version.js.test.cjs @@ -0,0 +1,94 @@ +/* IMPORTANT + * This snapshot file is auto-generated, but designed for humans. + * It should be checked into source control and tracked carefully. + * Re-generate by setting TAP_SNAPSHOT=1 and running tests. + * Make sure to inspect the output below. Do not ignore changes! + */ +'use strict' +exports[`test/lib/commands/version.js TAP empty versions workspaces with one arg, all workspaces > must match snapshot 1`] = ` +{ + "name": "workspaces-test", + "version": "1.0.0", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "workspaces-test", + "version": "1.0.0", + "workspaces": [ + "workspace-a", + "workspace-b" + ] + }, + "node_modules/workspace-a": { + "resolved": "workspace-a", + "link": true + }, + "node_modules/workspace-b": { + "resolved": "workspace-b", + "link": true + }, + "workspace-a": { + "version": "2.0.0" + }, + "workspace-b": { + "version": "2.0.0" + } + }, + "dependencies": { + "workspace-a": { + "version": "file:workspace-a" + }, + "workspace-b": { + "version": "file:workspace-b" + } + } +} + +` + +exports[`test/lib/commands/version.js TAP empty versions workspaces with one arg, all workspaces, saves package.json > must match snapshot 1`] = ` +{ + "name": "workspaces-test", + "version": "1.0.0", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "workspaces-test", + "version": "1.0.0", + "workspaces": [ + "workspace-a", + "workspace-b" + ], + "dependencies": { + "workspace-a": "^2.0.0", + "workspace-b": "^2.0.0" + } + }, + "node_modules/workspace-a": { + "resolved": "workspace-a", + "link": true + }, + "node_modules/workspace-b": { + "resolved": "workspace-b", + "link": true + }, + "workspace-a": { + "version": "2.0.0" + }, + "workspace-b": { + "version": "2.0.0" + } + }, + "dependencies": { + "workspace-a": { + "version": "file:workspace-a" + }, + "workspace-b": { + "version": "file:workspace-b" + } + } +} + +` diff --git a/deps/npm/tap-snapshots/test/lib/load-all-commands.js.test.cjs b/deps/npm/tap-snapshots/test/lib/load-all-commands.js.test.cjs index 1ad8aee29f087e..0ad87b945fce75 100644 --- a/deps/npm/tap-snapshots/test/lib/load-all-commands.js.test.cjs +++ b/deps/npm/tap-snapshots/test/lib/load-all-commands.js.test.cjs @@ -6,8 +6,6 @@ */ 'use strict' exports[`test/lib/load-all-commands.js TAP load each command access > must match snapshot 1`] = ` -npm access - Set access level on published packages Usage: @@ -28,8 +26,6 @@ Run "npm help access" for more info ` exports[`test/lib/load-all-commands.js TAP load each command adduser > must match snapshot 1`] = ` -npm adduser - Add a registry user account Usage: @@ -44,8 +40,6 @@ Run "npm help adduser" for more info ` exports[`test/lib/load-all-commands.js TAP load each command audit > must match snapshot 1`] = ` -npm audit - Run a security audit Usage: @@ -63,8 +57,6 @@ Run "npm help audit" for more info ` exports[`test/lib/load-all-commands.js TAP load each command bin > must match snapshot 1`] = ` -npm bin - Display npm bin folder Usage: @@ -76,9 +68,16 @@ Options: Run "npm help bin" for more info ` -exports[`test/lib/load-all-commands.js TAP load each command bugs > must match snapshot 1`] = ` -npm bugs +exports[`test/lib/load-all-commands.js TAP load each command birthday > must match snapshot 1`] = ` +Birthday + +Usage: +npm birthday +Run "npm help birthday" for more info +` + +exports[`test/lib/load-all-commands.js TAP load each command bugs > must match snapshot 1`] = ` Report bugs for a package in a web browser Usage: @@ -93,8 +92,6 @@ Run "npm help bugs" for more info ` exports[`test/lib/load-all-commands.js TAP load each command cache > must match snapshot 1`] = ` -npm cache - Manipulates packages cache Usage: @@ -114,8 +111,6 @@ Run "npm help cache" for more info ` exports[`test/lib/load-all-commands.js TAP load each command ci > must match snapshot 1`] = ` -npm ci - Install a project with a clean slate Usage: @@ -131,8 +126,6 @@ Run "npm help ci" for more info ` exports[`test/lib/load-all-commands.js TAP load each command completion > must match snapshot 1`] = ` -npm completion - Tab Completion for npm Usage: @@ -142,8 +135,6 @@ Run "npm help completion" for more info ` exports[`test/lib/load-all-commands.js TAP load each command config > must match snapshot 1`] = ` -npm config - Manage the npm configuration files Usage: @@ -163,8 +154,6 @@ Run "npm help config" for more info ` exports[`test/lib/load-all-commands.js TAP load each command dedupe > must match snapshot 1`] = ` -npm dedupe - Reduce duplication in the package tree Usage: @@ -184,8 +173,6 @@ Run "npm help dedupe" for more info ` exports[`test/lib/load-all-commands.js TAP load each command deprecate > must match snapshot 1`] = ` -npm deprecate - Deprecate a version of a package Usage: @@ -198,8 +185,6 @@ Run "npm help deprecate" for more info ` exports[`test/lib/load-all-commands.js TAP load each command diff > must match snapshot 1`] = ` -npm diff - The registry diff command Usage: @@ -217,8 +202,6 @@ Run "npm help diff" for more info ` exports[`test/lib/load-all-commands.js TAP load each command dist-tag > must match snapshot 1`] = ` -npm dist-tag - Modify package distribution tags Usage: @@ -236,8 +219,6 @@ Run "npm help dist-tag" for more info ` exports[`test/lib/load-all-commands.js TAP load each command docs > must match snapshot 1`] = ` -npm docs - Open documentation for a package in a web browser Usage: @@ -254,8 +235,6 @@ Run "npm help docs" for more info ` exports[`test/lib/load-all-commands.js TAP load each command doctor > must match snapshot 1`] = ` -npm doctor - Check your npm environment Usage: @@ -268,8 +247,6 @@ Run "npm help doctor" for more info ` exports[`test/lib/load-all-commands.js TAP load each command edit > must match snapshot 1`] = ` -npm edit - Edit an installed package Usage: @@ -282,8 +259,6 @@ Run "npm help edit" for more info ` exports[`test/lib/load-all-commands.js TAP load each command exec > must match snapshot 1`] = ` -npm exec - Run a command from a local or remote npm package Usage: @@ -304,8 +279,6 @@ Run "npm help exec" for more info ` exports[`test/lib/load-all-commands.js TAP load each command explain > must match snapshot 1`] = ` -npm explain - Explain installed packages Usage: @@ -320,8 +293,6 @@ Run "npm help explain" for more info ` exports[`test/lib/load-all-commands.js TAP load each command explore > must match snapshot 1`] = ` -npm explore - Browse an installed package Usage: @@ -334,8 +305,6 @@ Run "npm help explore" for more info ` exports[`test/lib/load-all-commands.js TAP load each command find-dupes > must match snapshot 1`] = ` -npm find-dupes - Find duplication in the package tree Usage: @@ -352,8 +321,6 @@ Run "npm help find-dupes" for more info ` exports[`test/lib/load-all-commands.js TAP load each command fund > must match snapshot 1`] = ` -npm fund - Retrieve funding information Usage: @@ -368,8 +335,6 @@ Run "npm help fund" for more info ` exports[`test/lib/load-all-commands.js TAP load each command get > must match snapshot 1`] = ` -npm get - Get a value from the npm configuration Usage: @@ -379,8 +344,6 @@ Run "npm help get" for more info ` exports[`test/lib/load-all-commands.js TAP load each command help > must match snapshot 1`] = ` -npm help - Get help on npm Usage: @@ -394,9 +357,19 @@ alias: hlep Run "npm help help" for more info ` -exports[`test/lib/load-all-commands.js TAP load each command hook > must match snapshot 1`] = ` -npm hook +exports[`test/lib/load-all-commands.js TAP load each command help-search > must match snapshot 1`] = ` +Search npm help documentation +Usage: +npm help-search + +Options: +[-l|--long] + +Run "npm help help-search" for more info +` + +exports[`test/lib/load-all-commands.js TAP load each command hook > must match snapshot 1`] = ` Manage registry hooks Usage: @@ -412,8 +385,6 @@ Run "npm help hook" for more info ` exports[`test/lib/load-all-commands.js TAP load each command init > must match snapshot 1`] = ` -npm init - Create a package.json file Usage: @@ -432,8 +403,6 @@ Run "npm help init" for more info ` exports[`test/lib/load-all-commands.js TAP load each command install > must match snapshot 1`] = ` -npm install - Install a package Usage: @@ -457,14 +426,12 @@ Options: [-w|--workspace [-w|--workspace ...]] [-ws|--workspaces] [--include-workspace-root] -aliases: i, in, ins, inst, insta, instal, isnt, isnta, isntal, isntall, add +aliases: add, i, in, ins, inst, insta, instal, isnt, isnta, isntal, isntall Run "npm help install" for more info ` exports[`test/lib/load-all-commands.js TAP load each command install-ci-test > must match snapshot 1`] = ` -npm install-ci-test - Install a project with a clean slate and run tests Usage: @@ -480,8 +447,6 @@ Run "npm help install-ci-test" for more info ` exports[`test/lib/load-all-commands.js TAP load each command install-test > must match snapshot 1`] = ` -npm install-test - Install package(s) and run tests Usage: @@ -511,8 +476,6 @@ Run "npm help install-test" for more info ` exports[`test/lib/load-all-commands.js TAP load each command link > must match snapshot 1`] = ` -npm link - Symlink a package folder Usage: @@ -534,8 +497,6 @@ Run "npm help link" for more info ` exports[`test/lib/load-all-commands.js TAP load each command ll > must match snapshot 1`] = ` -npm ll - List installed packages Usage: @@ -554,8 +515,6 @@ Run "npm help ll" for more info ` exports[`test/lib/load-all-commands.js TAP load each command login > must match snapshot 1`] = ` -npm adduser - Add a registry user account Usage: @@ -570,8 +529,6 @@ Run "npm help adduser" for more info ` exports[`test/lib/load-all-commands.js TAP load each command logout > must match snapshot 1`] = ` -npm logout - Log out of the registry Usage: @@ -584,8 +541,6 @@ Run "npm help logout" for more info ` exports[`test/lib/load-all-commands.js TAP load each command ls > must match snapshot 1`] = ` -npm ls - List installed packages Usage: @@ -604,8 +559,6 @@ Run "npm help ls" for more info ` exports[`test/lib/load-all-commands.js TAP load each command org > must match snapshot 1`] = ` -npm org - Manage orgs Usage: @@ -622,8 +575,6 @@ Run "npm help org" for more info ` exports[`test/lib/load-all-commands.js TAP load each command outdated > must match snapshot 1`] = ` -npm outdated - Check for outdated packages Usage: @@ -637,8 +588,6 @@ Run "npm help outdated" for more info ` exports[`test/lib/load-all-commands.js TAP load each command owner > must match snapshot 1`] = ` -npm owner - Manage package owners Usage: @@ -655,8 +604,6 @@ Run "npm help owner" for more info ` exports[`test/lib/load-all-commands.js TAP load each command pack > must match snapshot 1`] = ` -npm pack - Create a tarball from a package Usage: @@ -671,8 +618,6 @@ Run "npm help pack" for more info ` exports[`test/lib/load-all-commands.js TAP load each command ping > must match snapshot 1`] = ` -npm ping - Ping npm registry Usage: @@ -685,8 +630,6 @@ Run "npm help ping" for more info ` exports[`test/lib/load-all-commands.js TAP load each command pkg > must match snapshot 1`] = ` -npm pkg - Manages your package.json Usage: @@ -705,8 +648,6 @@ Run "npm help pkg" for more info ` exports[`test/lib/load-all-commands.js TAP load each command prefix > must match snapshot 1`] = ` -npm prefix - Display prefix Usage: @@ -719,8 +660,6 @@ Run "npm help prefix" for more info ` exports[`test/lib/load-all-commands.js TAP load each command profile > must match snapshot 1`] = ` -npm profile - Change settings on your registry profile Usage: @@ -736,8 +675,6 @@ Run "npm help profile" for more info ` exports[`test/lib/load-all-commands.js TAP load each command prune > must match snapshot 1`] = ` -npm prune - Remove extraneous packages Usage: @@ -753,8 +690,6 @@ Run "npm help prune" for more info ` exports[`test/lib/load-all-commands.js TAP load each command publish > must match snapshot 1`] = ` -npm publish - Publish a package Usage: @@ -769,8 +704,6 @@ Run "npm help publish" for more info ` exports[`test/lib/load-all-commands.js TAP load each command rebuild > must match snapshot 1`] = ` -npm rebuild - Rebuild a package Usage: @@ -787,8 +720,6 @@ Run "npm help rebuild" for more info ` exports[`test/lib/load-all-commands.js TAP load each command repo > must match snapshot 1`] = ` -npm repo - Open package repository page in the browser Usage: @@ -803,8 +734,6 @@ Run "npm help repo" for more info ` exports[`test/lib/load-all-commands.js TAP load each command restart > must match snapshot 1`] = ` -npm restart - Restart a package Usage: @@ -817,8 +746,6 @@ Run "npm help restart" for more info ` exports[`test/lib/load-all-commands.js TAP load each command root > must match snapshot 1`] = ` -npm root - Display npm root Usage: @@ -831,8 +758,6 @@ Run "npm help root" for more info ` exports[`test/lib/load-all-commands.js TAP load each command run-script > must match snapshot 1`] = ` -npm run-script - Run arbitrary package scripts Usage: @@ -849,8 +774,6 @@ Run "npm help run-script" for more info ` exports[`test/lib/load-all-commands.js TAP load each command search > must match snapshot 1`] = ` -npm search - Search for packages Usage: @@ -861,14 +784,12 @@ Options: [--no-description] [--searchopts ] [--searchexclude ] [--registry ] [--prefer-online] [--prefer-offline] [--offline] -aliases: s, se, find +aliases: find, s, se Run "npm help search" for more info ` exports[`test/lib/load-all-commands.js TAP load each command set > must match snapshot 1`] = ` -npm set - Set a value in the npm configuration Usage: @@ -878,8 +799,6 @@ Run "npm help set" for more info ` exports[`test/lib/load-all-commands.js TAP load each command set-script > must match snapshot 1`] = ` -npm set-script - Set tasks in the scripts section of package.json Usage: @@ -893,8 +812,6 @@ Run "npm help set-script" for more info ` exports[`test/lib/load-all-commands.js TAP load each command shrinkwrap > must match snapshot 1`] = ` -npm shrinkwrap - Lock down dependency versions for publication Usage: @@ -904,8 +821,6 @@ Run "npm help shrinkwrap" for more info ` exports[`test/lib/load-all-commands.js TAP load each command star > must match snapshot 1`] = ` -npm star - Mark your favorite packages Usage: @@ -918,8 +833,6 @@ Run "npm help star" for more info ` exports[`test/lib/load-all-commands.js TAP load each command stars > must match snapshot 1`] = ` -npm stars - View packages marked as favorites Usage: @@ -932,8 +845,6 @@ Run "npm help stars" for more info ` exports[`test/lib/load-all-commands.js TAP load each command start > must match snapshot 1`] = ` -npm start - Start a package Usage: @@ -946,8 +857,6 @@ Run "npm help start" for more info ` exports[`test/lib/load-all-commands.js TAP load each command stop > must match snapshot 1`] = ` -npm stop - Stop a package Usage: @@ -960,8 +869,6 @@ Run "npm help stop" for more info ` exports[`test/lib/load-all-commands.js TAP load each command team > must match snapshot 1`] = ` -npm team - Manage organization teams and team memberships Usage: @@ -978,8 +885,6 @@ Run "npm help team" for more info ` exports[`test/lib/load-all-commands.js TAP load each command test > must match snapshot 1`] = ` -npm test - Test a package Usage: @@ -994,8 +899,6 @@ Run "npm help test" for more info ` exports[`test/lib/load-all-commands.js TAP load each command token > must match snapshot 1`] = ` -npm token - Manage your authentication tokens Usage: @@ -1011,8 +914,6 @@ Run "npm help token" for more info ` exports[`test/lib/load-all-commands.js TAP load each command uninstall > must match snapshot 1`] = ` -npm uninstall - Remove a package Usage: @@ -1023,14 +924,12 @@ Options: [-w|--workspace [-w|--workspace ...]] [-ws|--workspaces] [--include-workspace-root] -aliases: un, unlink, remove, rm, r +aliases: unlink, remove, rm, r, un Run "npm help uninstall" for more info ` exports[`test/lib/load-all-commands.js TAP load each command unpublish > must match snapshot 1`] = ` -npm unpublish - Remove a package from the registry Usage: @@ -1045,8 +944,6 @@ Run "npm help unpublish" for more info ` exports[`test/lib/load-all-commands.js TAP load each command unstar > must match snapshot 1`] = ` -npm unstar - Remove an item from your favorite packages Usage: @@ -1059,8 +956,6 @@ Run "npm help unstar" for more info ` exports[`test/lib/load-all-commands.js TAP load each command update > must match snapshot 1`] = ` -npm update - Update packages Usage: @@ -1081,8 +976,6 @@ Run "npm help update" for more info ` exports[`test/lib/load-all-commands.js TAP load each command version > must match snapshot 1`] = ` -npm version - Bump a package version Usage: @@ -1092,7 +985,7 @@ Options: [--allow-same-version] [--no-commit-hooks] [--no-git-tag-version] [--json] [--preid prerelease-id] [--sign-git-tag] [-w|--workspace [-w|--workspace ...]] -[-ws|--workspaces] [--include-workspace-root] +[-ws|--workspaces] [--no-workspaces-update] [--include-workspace-root] alias: verison @@ -1100,8 +993,6 @@ Run "npm help version" for more info ` exports[`test/lib/load-all-commands.js TAP load each command view > must match snapshot 1`] = ` -npm view - View registry info Usage: @@ -1111,14 +1002,12 @@ Options: [--json] [-w|--workspace [-w|--workspace ...]] [-ws|--workspaces] [--include-workspace-root] -aliases: v, info, show +aliases: info, show, v Run "npm help view" for more info ` exports[`test/lib/load-all-commands.js TAP load each command whoami > must match snapshot 1`] = ` -npm whoami - Display npm username Usage: diff --git a/deps/npm/tap-snapshots/test/lib/utils/cmd-list.js.test.cjs b/deps/npm/tap-snapshots/test/lib/utils/cmd-list.js.test.cjs index f842e689f16310..9413f8e9a6d520 100644 --- a/deps/npm/tap-snapshots/test/lib/utils/cmd-list.js.test.cjs +++ b/deps/npm/tap-snapshots/test/lib/utils/cmd-list.js.test.cjs @@ -7,43 +7,348 @@ 'use strict' exports[`test/lib/utils/cmd-list.js TAP > must match snapshot 1`] = ` Object { - "affordances": Object { - "add": "install", - "add-user": "adduser", - "author": "owner", - "dist-tags": "dist-tag", - "find": "search", - "hlep": "help", - "home": "docs", - "ic": "ci", - "in": "install", - "info": "view", - "innit": "init", - "ins": "install", - "inst": "install", - "insta": "install", - "instal": "install", - "install-clean": "ci", - "isnt": "install", - "isnta": "install", - "isntal": "install", - "isntall": "install", - "isntall-clean": "ci", - "issues": "bugs", - "la": "ll", - "login": "adduser", - "ogr": "org", - "r": "uninstall", - "remove": "uninstall", - "rm": "uninstall", - "rum": "run-script", - "show": "view", - "sit": "cit", - "udpate": "update", - "unlink": "uninstall", - "upgrade": "update", - "urn": "run-script", - "verison": "version", + "abbrevs": Object { + "ac": "access", + "acc": "access", + "acce": "access", + "acces": "access", + "access": "access", + "add": "add", + "add-": "add-user", + "add-u": "add-user", + "add-us": "add-user", + "add-use": "add-user", + "add-user": "add-user", + "addu": "adduser", + "addus": "adduser", + "adduse": "adduser", + "adduser": "adduser", + "aud": "audit", + "audi": "audit", + "audit": "audit", + "aut": "author", + "auth": "author", + "autho": "author", + "author": "author", + "bi": "bin", + "bin": "bin", + "bu": "bugs", + "bug": "bugs", + "bugs": "bugs", + "c": "c", + "ca": "cache", + "cac": "cache", + "cach": "cache", + "cache": "cache", + "ci": "ci", + "cit": "cit", + "clean-install": "clean-install", + "clean-install-": "clean-install-test", + "clean-install-t": "clean-install-test", + "clean-install-te": "clean-install-test", + "clean-install-tes": "clean-install-test", + "clean-install-test": "clean-install-test", + "com": "completion", + "comp": "completion", + "compl": "completion", + "comple": "completion", + "complet": "completion", + "completi": "completion", + "completio": "completion", + "completion": "completion", + "con": "config", + "conf": "config", + "confi": "config", + "config": "config", + "cr": "create", + "cre": "create", + "crea": "create", + "creat": "create", + "create": "create", + "dd": "ddp", + "ddp": "ddp", + "ded": "dedupe", + "dedu": "dedupe", + "dedup": "dedupe", + "dedupe": "dedupe", + "dep": "deprecate", + "depr": "deprecate", + "depre": "deprecate", + "deprec": "deprecate", + "depreca": "deprecate", + "deprecat": "deprecate", + "deprecate": "deprecate", + "dif": "diff", + "diff": "diff", + "dist-tag": "dist-tag", + "dist-tags": "dist-tags", + "docs": "docs", + "doct": "doctor", + "docto": "doctor", + "doctor": "doctor", + "ed": "edit", + "edi": "edit", + "edit": "edit", + "exe": "exec", + "exec": "exec", + "expla": "explain", + "explai": "explain", + "explain": "explain", + "explo": "explore", + "explor": "explore", + "explore": "explore", + "find": "find", + "find-": "find-dupes", + "find-d": "find-dupes", + "find-du": "find-dupes", + "find-dup": "find-dupes", + "find-dupe": "find-dupes", + "find-dupes": "find-dupes", + "fu": "fund", + "fun": "fund", + "fund": "fund", + "g": "get", + "ge": "get", + "get": "get", + "he": "help", + "hel": "help", + "help": "help", + "hl": "hlep", + "hle": "hlep", + "hlep": "hlep", + "hom": "home", + "home": "home", + "hoo": "hook", + "hook": "hook", + "i": "i", + "ic": "ic", + "in": "in", + "inf": "info", + "info": "info", + "ini": "init", + "init": "init", + "inn": "innit", + "inni": "innit", + "innit": "innit", + "ins": "ins", + "inst": "inst", + "insta": "insta", + "instal": "instal", + "install": "install", + "install-ci": "install-ci-test", + "install-ci-": "install-ci-test", + "install-ci-t": "install-ci-test", + "install-ci-te": "install-ci-test", + "install-ci-tes": "install-ci-test", + "install-ci-test": "install-ci-test", + "install-cl": "install-clean", + "install-cle": "install-clean", + "install-clea": "install-clean", + "install-clean": "install-clean", + "install-t": "install-test", + "install-te": "install-test", + "install-tes": "install-test", + "install-test": "install-test", + "isnt": "isnt", + "isnta": "isnta", + "isntal": "isntal", + "isntall": "isntall", + "isntall-": "isntall-clean", + "isntall-c": "isntall-clean", + "isntall-cl": "isntall-clean", + "isntall-cle": "isntall-clean", + "isntall-clea": "isntall-clean", + "isntall-clean": "isntall-clean", + "iss": "issues", + "issu": "issues", + "issue": "issues", + "issues": "issues", + "it": "it", + "la": "la", + "lin": "link", + "link": "link", + "lis": "list", + "list": "list", + "ll": "ll", + "ln": "ln", + "logi": "login", + "login": "login", + "logo": "logout", + "logou": "logout", + "logout": "logout", + "ls": "ls", + "og": "ogr", + "ogr": "ogr", + "or": "org", + "org": "org", + "ou": "outdated", + "out": "outdated", + "outd": "outdated", + "outda": "outdated", + "outdat": "outdated", + "outdate": "outdated", + "outdated": "outdated", + "ow": "owner", + "own": "owner", + "owne": "owner", + "owner": "owner", + "pa": "pack", + "pac": "pack", + "pack": "pack", + "pi": "ping", + "pin": "ping", + "ping": "ping", + "pk": "pkg", + "pkg": "pkg", + "pre": "prefix", + "pref": "prefix", + "prefi": "prefix", + "prefix": "prefix", + "pro": "profile", + "prof": "profile", + "profi": "profile", + "profil": "profile", + "profile": "profile", + "pru": "prune", + "prun": "prune", + "prune": "prune", + "pu": "publish", + "pub": "publish", + "publ": "publish", + "publi": "publish", + "publis": "publish", + "publish": "publish", + "r": "r", + "rb": "rb", + "reb": "rebuild", + "rebu": "rebuild", + "rebui": "rebuild", + "rebuil": "rebuild", + "rebuild": "rebuild", + "rem": "remove", + "remo": "remove", + "remov": "remove", + "remove": "remove", + "rep": "repo", + "repo": "repo", + "res": "restart", + "rest": "restart", + "resta": "restart", + "restar": "restart", + "restart": "restart", + "rm": "rm", + "ro": "root", + "roo": "root", + "root": "root", + "rum": "rum", + "run": "run", + "run-": "run-script", + "run-s": "run-script", + "run-sc": "run-script", + "run-scr": "run-script", + "run-scri": "run-script", + "run-scrip": "run-script", + "run-script": "run-script", + "s": "s", + "se": "se", + "sea": "search", + "sear": "search", + "searc": "search", + "search": "search", + "set": "set", + "set-": "set-script", + "set-s": "set-script", + "set-sc": "set-script", + "set-scr": "set-script", + "set-scri": "set-script", + "set-scrip": "set-script", + "set-script": "set-script", + "sho": "show", + "show": "show", + "shr": "shrinkwrap", + "shri": "shrinkwrap", + "shrin": "shrinkwrap", + "shrink": "shrinkwrap", + "shrinkw": "shrinkwrap", + "shrinkwr": "shrinkwrap", + "shrinkwra": "shrinkwrap", + "shrinkwrap": "shrinkwrap", + "si": "sit", + "sit": "sit", + "star": "star", + "stars": "stars", + "start": "start", + "sto": "stop", + "stop": "stop", + "t": "t", + "tea": "team", + "team": "team", + "tes": "test", + "test": "test", + "to": "token", + "tok": "token", + "toke": "token", + "token": "token", + "ts": "tst", + "tst": "tst", + "ud": "udpate", + "udp": "udpate", + "udpa": "udpate", + "udpat": "udpate", + "udpate": "udpate", + "un": "un", + "uni": "uninstall", + "unin": "uninstall", + "unins": "uninstall", + "uninst": "uninstall", + "uninsta": "uninstall", + "uninstal": "uninstall", + "uninstall": "uninstall", + "unl": "unlink", + "unli": "unlink", + "unlin": "unlink", + "unlink": "unlink", + "unp": "unpublish", + "unpu": "unpublish", + "unpub": "unpublish", + "unpubl": "unpublish", + "unpubli": "unpublish", + "unpublis": "unpublish", + "unpublish": "unpublish", + "uns": "unstar", + "unst": "unstar", + "unsta": "unstar", + "unstar": "unstar", + "up": "up", + "upd": "update", + "upda": "update", + "updat": "update", + "update": "update", + "upg": "upgrade", + "upgr": "upgrade", + "upgra": "upgrade", + "upgrad": "upgrade", + "upgrade": "upgrade", + "ur": "urn", + "urn": "urn", + "v": "v", + "veri": "verison", + "veris": "verison", + "veriso": "verison", + "verison": "verison", + "vers": "version", + "versi": "version", + "versio": "version", + "version": "version", + "vi": "view", + "vie": "view", + "view": "view", + "who": "whoami", + "whoa": "whoami", + "whoam": "whoami", + "whoami": "whoami", + "why": "why", + "x": "x", }, "aliases": Object { "add": "install", @@ -105,108 +410,76 @@ Object { "x": "exec", }, "cmdList": Array [ - "ci", - "install-ci-test", - "install", - "install-test", - "uninstall", + "access", + "adduser", + "audit", + "bin", + "bugs", "cache", + "ci", + "completion", "config", - "set", - "get", - "update", - "outdated", - "prune", - "pack", - "find-dupes", "dedupe", + "deprecate", + "diff", + "dist-tag", + "docs", + "doctor", + "edit", + "exec", + "explain", + "explore", + "find-dupes", + "fund", + "get", + "help", "hook", - "rebuild", + "init", + "install", + "install-ci-test", + "install-test", "link", - "publish", - "star", - "stars", - "unstar", - "adduser", + "ll", "login", "logout", - "unpublish", - "owner", - "access", - "team", - "deprecate", - "shrinkwrap", - "token", - "profile", - "audit", - "fund", - "org", - "help", "ls", - "ll", - "search", - "view", - "init", - "version", - "edit", - "explore", - "docs", - "repo", - "bugs", - "root", - "prefix", - "bin", - "whoami", - "diff", - "dist-tag", + "org", + "outdated", + "owner", + "pack", "ping", "pkg", - "test", - "stop", - "start", + "prefix", + "profile", + "prune", + "publish", + "rebuild", + "repo", "restart", + "root", "run-script", + "search", + "set", "set-script", - "completion", - "doctor", - "exec", - "explain", + "shrinkwrap", + "star", + "stars", + "start", + "stop", + "team", + "test", + "token", + "uninstall", + "unpublish", + "unstar", + "update", + "version", + "view", + "whoami", ], "plumbing": Array [ "birthday", "help-search", ], - "shellouts": Array [ - "exec", - "run-script", - "test", - "start", - "stop", - "restart", - "birthday", - ], - "shorthands": Object { - "c": "config", - "cit": "install-ci-test", - "clean-install": "ci", - "clean-install-test": "cit", - "create": "init", - "ddp": "dedupe", - "i": "install", - "it": "install-test", - "list": "ls", - "ln": "link", - "rb": "rebuild", - "run": "run-script", - "s": "search", - "se": "search", - "t": "test", - "tst": "test", - "un": "uninstall", - "up": "update", - "v": "view", - "why": "explain", - "x": "exec", - }, } ` diff --git a/deps/npm/tap-snapshots/test/lib/utils/config/definitions.js.test.cjs b/deps/npm/tap-snapshots/test/lib/utils/config/definitions.js.test.cjs index 373f094a59af93..d7c43080298eb0 100644 --- a/deps/npm/tap-snapshots/test/lib/utils/config/definitions.js.test.cjs +++ b/deps/npm/tap-snapshots/test/lib/utils/config/definitions.js.test.cjs @@ -85,6 +85,7 @@ Array [ "location", "lockfile-version", "loglevel", + "logs-dir", "logs-max", "long", "maxsockets", @@ -151,6 +152,7 @@ Array [ "which", "workspace", "workspaces", + "workspaces-update", "yes", ] ` @@ -1098,6 +1100,16 @@ Any logs of a higher level than the setting are shown. The default is See also the \`foreground-scripts\` config. ` +exports[`test/lib/utils/config/definitions.js TAP > config description for logs-dir 1`] = ` +#### \`logs-dir\` + +* Default: A directory named \`_logs\` inside the cache +* Type: null or Path + +The location of npm's log directory. See [\`npm logging\`](/using-npm/logging) +for more information. +` + exports[`test/lib/utils/config/definitions.js TAP > config description for logs-max 1`] = ` #### \`logs-max\` @@ -1105,6 +1117,8 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for logs- * Type: Number The maximum number of log files to store. + +If set to 0, no log files will be written for the current run. ` exports[`test/lib/utils/config/definitions.js TAP > config description for long 1`] = ` @@ -1720,9 +1734,9 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for timin * Default: false * Type: Boolean -If true, writes an \`npm-debug\` log to \`_logs\` and timing information to -\`_timing.json\`, both in your cache, even if the command completes -successfully. \`_timing.json\` is a newline delimited list of JSON objects. +If true, writes a debug log to \`logs-dir\` and timing information to +\`_timing.json\` in the cache, even if the command completes successfully. +\`_timing.json\` is a newline delimited list of JSON objects. You can quickly view it with this [json](https://npm.im/json) command line: \`npm exec -- json -g < ~/.npm/_timing.json\`. @@ -1915,6 +1929,16 @@ _unless_ one or more workspaces are specified in the \`workspace\` config. This value is not exported to the environment for child processes. ` +exports[`test/lib/utils/config/definitions.js TAP > config description for workspaces-update 1`] = ` +#### \`workspaces-update\` + +* Default: true +* Type: Boolean + +If set to true, the npm cli will run an update after operations that may +possibly change the workspaces installed to the \`node_modules\` folder. +` + exports[`test/lib/utils/config/definitions.js TAP > config description for yes 1`] = ` #### \`yes\` diff --git a/deps/npm/tap-snapshots/test/lib/utils/config/describe-all.js.test.cjs b/deps/npm/tap-snapshots/test/lib/utils/config/describe-all.js.test.cjs index 3a7d90db01be69..2647bc31bcdb85 100644 --- a/deps/npm/tap-snapshots/test/lib/utils/config/describe-all.js.test.cjs +++ b/deps/npm/tap-snapshots/test/lib/utils/config/describe-all.js.test.cjs @@ -901,6 +901,17 @@ See also the \`foreground-scripts\` config. +#### \`logs-dir\` + +* Default: A directory named \`_logs\` inside the cache +* Type: null or Path + +The location of npm's log directory. See [\`npm logging\`](/using-npm/logging) +for more information. + + + + #### \`logs-max\` * Default: 10 @@ -908,6 +919,8 @@ See also the \`foreground-scripts\` config. The maximum number of log files to store. +If set to 0, no log files will be written for the current run. + @@ -1502,9 +1515,9 @@ particular, use care when overriding this setting for public packages. * Default: false * Type: Boolean -If true, writes an \`npm-debug\` log to \`_logs\` and timing information to -\`_timing.json\`, both in your cache, even if the command completes -successfully. \`_timing.json\` is a newline delimited list of JSON objects. +If true, writes a debug log to \`logs-dir\` and timing information to +\`_timing.json\` in the cache, even if the command completes successfully. +\`_timing.json\` is a newline delimited list of JSON objects. You can quickly view it with this [json](https://npm.im/json) command line: \`npm exec -- json -g < ~/.npm/_timing.json\`. @@ -1697,6 +1710,17 @@ This value is not exported to the environment for child processes. +#### \`workspaces-update\` + +* Default: true +* Type: Boolean + +If set to true, the npm cli will run an update after operations that may +possibly change the workspaces installed to the \`node_modules\` folder. + + + + #### \`yes\` * Default: null diff --git a/deps/npm/tap-snapshots/test/lib/utils/error-message.js.test.cjs b/deps/npm/tap-snapshots/test/lib/utils/error-message.js.test.cjs index 8c6a17ad2f96fc..312c814ea72e48 100644 --- a/deps/npm/tap-snapshots/test/lib/utils/error-message.js.test.cjs +++ b/deps/npm/tap-snapshots/test/lib/utils/error-message.js.test.cjs @@ -499,6 +499,18 @@ Object { exports[`test/lib/utils/error-message.js TAP eacces/eperm {"windows":false,"loaded":true,"cachePath":false,"cacheDest":false} > must match snapshot 2`] = ` Array [ + Array [ + "title", + "npm", + ], + Array [ + "argv", + "", + ], + Array [ + "logfile", + "logs-max:10 dir:{CWD}/test/lib/utils/tap-testdir-error-message-eacces-eperm--windows-false-loaded-true-cachePath-false-cacheDest-false-/cache/_logs", + ], Array [ "logfile", "{CWD}/test/lib/utils/tap-testdir-error-message-eacces-eperm--windows-false-loaded-true-cachePath-false-cacheDest-false-/cache/_logs/{DATE}-debug-0.log", @@ -527,6 +539,18 @@ Object { exports[`test/lib/utils/error-message.js TAP eacces/eperm {"windows":false,"loaded":true,"cachePath":false,"cacheDest":true} > must match snapshot 2`] = ` Array [ + Array [ + "title", + "npm", + ], + Array [ + "argv", + "", + ], + Array [ + "logfile", + "logs-max:10 dir:{CWD}/test/lib/utils/tap-testdir-error-message-eacces-eperm--windows-false-loaded-true-cachePath-false-cacheDest-true-/cache/_logs", + ], Array [ "logfile", "{CWD}/test/lib/utils/tap-testdir-error-message-eacces-eperm--windows-false-loaded-true-cachePath-false-cacheDest-true-/cache/_logs/{DATE}-debug-0.log", @@ -558,6 +582,18 @@ Object { exports[`test/lib/utils/error-message.js TAP eacces/eperm {"windows":false,"loaded":true,"cachePath":true,"cacheDest":false} > must match snapshot 2`] = ` Array [ + Array [ + "title", + "npm", + ], + Array [ + "argv", + "", + ], + Array [ + "logfile", + "logs-max:10 dir:{CWD}/test/lib/utils/tap-testdir-error-message-eacces-eperm--windows-false-loaded-true-cachePath-true-cacheDest-false-/cache/_logs", + ], Array [ "logfile", "{CWD}/test/lib/utils/tap-testdir-error-message-eacces-eperm--windows-false-loaded-true-cachePath-true-cacheDest-false-/cache/_logs/{DATE}-debug-0.log", @@ -589,6 +625,18 @@ Object { exports[`test/lib/utils/error-message.js TAP eacces/eperm {"windows":false,"loaded":true,"cachePath":true,"cacheDest":true} > must match snapshot 2`] = ` Array [ + Array [ + "title", + "npm", + ], + Array [ + "argv", + "", + ], + Array [ + "logfile", + "logs-max:10 dir:{CWD}/test/lib/utils/tap-testdir-error-message-eacces-eperm--windows-false-loaded-true-cachePath-true-cacheDest-true-/cache/_logs", + ], Array [ "logfile", "{CWD}/test/lib/utils/tap-testdir-error-message-eacces-eperm--windows-false-loaded-true-cachePath-true-cacheDest-true-/cache/_logs/{DATE}-debug-0.log", @@ -767,6 +815,18 @@ Object { exports[`test/lib/utils/error-message.js TAP eacces/eperm {"windows":true,"loaded":true,"cachePath":false,"cacheDest":false} > must match snapshot 2`] = ` Array [ + Array [ + "title", + "npm", + ], + Array [ + "argv", + "", + ], + Array [ + "logfile", + "logs-max:10 dir:{CWD}/test/lib/utils/tap-testdir-error-message-eacces-eperm--windows-true-loaded-true-cachePath-false-cacheDest-false-/cache/_logs", + ], Array [ "logfile", "{CWD}/test/lib/utils/tap-testdir-error-message-eacces-eperm--windows-true-loaded-true-cachePath-false-cacheDest-false-/cache/_logs/{DATE}-debug-0.log", @@ -806,6 +866,18 @@ Object { exports[`test/lib/utils/error-message.js TAP eacces/eperm {"windows":true,"loaded":true,"cachePath":false,"cacheDest":true} > must match snapshot 2`] = ` Array [ + Array [ + "title", + "npm", + ], + Array [ + "argv", + "", + ], + Array [ + "logfile", + "logs-max:10 dir:{CWD}/test/lib/utils/tap-testdir-error-message-eacces-eperm--windows-true-loaded-true-cachePath-false-cacheDest-true-/cache/_logs", + ], Array [ "logfile", "{CWD}/test/lib/utils/tap-testdir-error-message-eacces-eperm--windows-true-loaded-true-cachePath-false-cacheDest-true-/cache/_logs/{DATE}-debug-0.log", @@ -845,6 +917,18 @@ Object { exports[`test/lib/utils/error-message.js TAP eacces/eperm {"windows":true,"loaded":true,"cachePath":true,"cacheDest":false} > must match snapshot 2`] = ` Array [ + Array [ + "title", + "npm", + ], + Array [ + "argv", + "", + ], + Array [ + "logfile", + "logs-max:10 dir:{CWD}/test/lib/utils/tap-testdir-error-message-eacces-eperm--windows-true-loaded-true-cachePath-true-cacheDest-false-/cache/_logs", + ], Array [ "logfile", "{CWD}/test/lib/utils/tap-testdir-error-message-eacces-eperm--windows-true-loaded-true-cachePath-true-cacheDest-false-/cache/_logs/{DATE}-debug-0.log", @@ -884,6 +968,18 @@ Object { exports[`test/lib/utils/error-message.js TAP eacces/eperm {"windows":true,"loaded":true,"cachePath":true,"cacheDest":true} > must match snapshot 2`] = ` Array [ + Array [ + "title", + "npm", + ], + Array [ + "argv", + "", + ], + Array [ + "logfile", + "logs-max:10 dir:{CWD}/test/lib/utils/tap-testdir-error-message-eacces-eperm--windows-true-loaded-true-cachePath-true-cacheDest-true-/cache/_logs", + ], Array [ "logfile", "{CWD}/test/lib/utils/tap-testdir-error-message-eacces-eperm--windows-true-loaded-true-cachePath-true-cacheDest-true-/cache/_logs/{DATE}-debug-0.log", diff --git a/deps/npm/tap-snapshots/test/lib/utils/exit-handler.js.test.cjs b/deps/npm/tap-snapshots/test/lib/utils/exit-handler.js.test.cjs index 0aaf235fd14b6a..e19a2571d642c3 100644 --- a/deps/npm/tap-snapshots/test/lib/utils/exit-handler.js.test.cjs +++ b/deps/npm/tap-snapshots/test/lib/utils/exit-handler.js.test.cjs @@ -9,44 +9,54 @@ exports[`test/lib/utils/exit-handler.js TAP handles unknown error with logs and 0 timing npm:load:whichnode Completed in {TIME}ms 15 timing config:load Completed in {TIME}ms 16 timing npm:load:configload Completed in {TIME}ms -17 timing npm:load:setTitle Completed in {TIME}ms -19 timing npm:load:display Completed in {TIME}ms -20 verbose logfile {CWD}/test/lib/utils/tap-testdir-exit-handler-handles-unknown-error-with-logs-and-debug-file/cache/_logs/{DATE}-debug-0.log -21 timing npm:load:logFile Completed in {TIME}ms -22 timing npm:load:timers Completed in {TIME}ms -23 timing npm:load:configScope Completed in {TIME}ms -24 timing npm:load Completed in {TIME}ms -25 verbose stack Error: Unknown error -26 verbose cwd {CWD} -27 verbose Foo 1.0.0 -28 verbose argv "/node" "{CWD}/test/lib/utils/exit-handler.js" -29 verbose node v1.0.0 -30 verbose npm v1.0.0 -31 error code ECODE -32 error ERR SUMMARY Unknown error -33 error ERR DETAIL Unknown error -34 verbose exit 1 -36 timing npm Completed in {TIME}ms -37 verbose code 1 -38 error A complete log of this run can be found in: -38 error {CWD}/test/lib/utils/tap-testdir-exit-handler-handles-unknown-error-with-logs-and-debug-file/cache/_logs/{DATE}-debug-0.log +17 timing npm:load:mkdirpcache Completed in {TIME}ms +18 timing npm:load:mkdirplogs Completed in {TIME}ms +19 verbose title npm +20 verbose argv +21 timing npm:load:setTitle Completed in {TIME}ms +23 timing npm:load:display Completed in {TIME}ms +24 verbose logfile logs-max:10 dir:{CWD}/test/lib/utils/tap-testdir-exit-handler-handles-unknown-error-with-logs-and-debug-file/cache/_logs +25 verbose logfile {CWD}/test/lib/utils/tap-testdir-exit-handler-handles-unknown-error-with-logs-and-debug-file/cache/_logs/{DATE}-debug-0.log +26 timing npm:load:logFile Completed in {TIME}ms +27 timing npm:load:timers Completed in {TIME}ms +28 timing npm:load:configScope Completed in {TIME}ms +29 timing npm:load Completed in {TIME}ms +30 silly logfile done cleaning log files +31 verbose stack Error: Unknown error +32 verbose cwd {CWD} +33 verbose Foo 1.0.0 +34 verbose node v1.0.0 +35 verbose npm v1.0.0 +36 error code ECODE +37 error ERR SUMMARY Unknown error +38 error ERR DETAIL Unknown error +39 verbose exit 1 +41 timing npm Completed in {TIME}ms +42 verbose code 1 +43 error A complete log of this run can be found in: +43 error {CWD}/test/lib/utils/tap-testdir-exit-handler-handles-unknown-error-with-logs-and-debug-file/cache/_logs/{DATE}-debug-0.log ` exports[`test/lib/utils/exit-handler.js TAP handles unknown error with logs and debug file > logs 1`] = ` timing npm:load:whichnode Completed in {TIME}ms timing config:load Completed in {TIME}ms timing npm:load:configload Completed in {TIME}ms +timing npm:load:mkdirpcache Completed in {TIME}ms +timing npm:load:mkdirplogs Completed in {TIME}ms +verbose title npm +verbose argv timing npm:load:setTitle Completed in {TIME}ms timing npm:load:display Completed in {TIME}ms +verbose logfile logs-max:10 dir:{CWD}/test/lib/utils/tap-testdir-exit-handler-handles-unknown-error-with-logs-and-debug-file/cache/_logs verbose logfile {CWD}/test/lib/utils/tap-testdir-exit-handler-handles-unknown-error-with-logs-and-debug-file/cache/_logs/{DATE}-debug-0.log timing npm:load:logFile Completed in {TIME}ms timing npm:load:timers Completed in {TIME}ms timing npm:load:configScope Completed in {TIME}ms timing npm:load Completed in {TIME}ms +silly logfile done cleaning log files verbose stack Error: Unknown error verbose cwd {CWD} verbose Foo 1.0.0 -verbose argv "/node" "{CWD}/test/lib/utils/exit-handler.js" verbose node v1.0.0 verbose npm v1.0.0 error code ECODE diff --git a/deps/npm/tap-snapshots/test/lib/utils/log-file.js.test.cjs b/deps/npm/tap-snapshots/test/lib/utils/log-file.js.test.cjs index ecce9eafcc925b..7a39184939026a 100644 --- a/deps/npm/tap-snapshots/test/lib/utils/log-file.js.test.cjs +++ b/deps/npm/tap-snapshots/test/lib/utils/log-file.js.test.cjs @@ -6,63 +6,65 @@ */ 'use strict' exports[`test/lib/utils/log-file.js TAP snapshot > must match snapshot 1`] = ` -0 error no prefix -1 error prefix with prefix -2 error prefix 1 2 3 -3 verbose { obj: { with: { many: [Object] } } } -4 verbose {"obj":{"with":{"many":{"props":1}}}} -5 verbose { -5 verbose "obj": { -5 verbose "with": { -5 verbose "many": { -5 verbose "props": 1 -5 verbose } -5 verbose } -5 verbose } -5 verbose } -6 verbose [ 'test', 'with', 'an', 'array' ] -7 verbose ["test","with","an","array"] -8 verbose [ -8 verbose "test", -8 verbose "with", -8 verbose "an", -8 verbose "array" -8 verbose ] -9 verbose [ 'test', [ 'with', [ 'an', [Array] ] ] ] -10 verbose ["test",["with",["an",["array"]]]] -11 verbose [ -11 verbose "test", -11 verbose [ -11 verbose "with", -11 verbose [ -11 verbose "an", -11 verbose [ -11 verbose "array" -11 verbose ] -11 verbose ] -11 verbose ] -11 verbose ] -12 error pre has many errors Error: message -12 error pre at stack trace line 0 -12 error pre at stack trace line 1 -12 error pre at stack trace line 2 -12 error pre at stack trace line 3 -12 error pre at stack trace line 4 -12 error pre at stack trace line 5 -12 error pre at stack trace line 6 -12 error pre at stack trace line 7 -12 error pre at stack trace line 8 -12 error pre at stack trace line 9 Error: message2 -12 error pre at stack trace line 0 -12 error pre at stack trace line 1 -12 error pre at stack trace line 2 -12 error pre at stack trace line 3 -12 error pre at stack trace line 4 -12 error pre at stack trace line 5 -12 error pre at stack trace line 6 -12 error pre at stack trace line 7 -12 error pre at stack trace line 8 -12 error pre at stack trace line 9 -13 error nostack [Error: message] +0 verbose logfile logs-max:10 dir:{CWD}/test/lib/utils/tap-testdir-log-file-snapshot +1 silly logfile done cleaning log files +2 error no prefix +3 error prefix with prefix +4 error prefix 1 2 3 +5 verbose { obj: { with: { many: [Object] } } } +6 verbose {"obj":{"with":{"many":{"props":1}}}} +7 verbose { +7 verbose "obj": { +7 verbose "with": { +7 verbose "many": { +7 verbose "props": 1 +7 verbose } +7 verbose } +7 verbose } +7 verbose } +8 verbose [ 'test', 'with', 'an', 'array' ] +9 verbose ["test","with","an","array"] +10 verbose [ +10 verbose "test", +10 verbose "with", +10 verbose "an", +10 verbose "array" +10 verbose ] +11 verbose [ 'test', [ 'with', [ 'an', [Array] ] ] ] +12 verbose ["test",["with",["an",["array"]]]] +13 verbose [ +13 verbose "test", +13 verbose [ +13 verbose "with", +13 verbose [ +13 verbose "an", +13 verbose [ +13 verbose "array" +13 verbose ] +13 verbose ] +13 verbose ] +13 verbose ] +14 error pre has many errors Error: message +14 error pre at stack trace line 0 +14 error pre at stack trace line 1 +14 error pre at stack trace line 2 +14 error pre at stack trace line 3 +14 error pre at stack trace line 4 +14 error pre at stack trace line 5 +14 error pre at stack trace line 6 +14 error pre at stack trace line 7 +14 error pre at stack trace line 8 +14 error pre at stack trace line 9 Error: message2 +14 error pre at stack trace line 0 +14 error pre at stack trace line 1 +14 error pre at stack trace line 2 +14 error pre at stack trace line 3 +14 error pre at stack trace line 4 +14 error pre at stack trace line 5 +14 error pre at stack trace line 6 +14 error pre at stack trace line 7 +14 error pre at stack trace line 8 +14 error pre at stack trace line 9 +15 error nostack [Error: message] ` diff --git a/deps/npm/tap-snapshots/test/lib/utils/npm-usage.js.test.cjs b/deps/npm/tap-snapshots/test/lib/utils/npm-usage.js.test.cjs index 2db10df46e2f78..d1de45413a93fc 100644 --- a/deps/npm/tap-snapshots/test/lib/utils/npm-usage.js.test.cjs +++ b/deps/npm/tap-snapshots/test/lib/utils/npm-usage.js.test.cjs @@ -165,9 +165,7 @@ npm help npm more involved overview All commands: - access npm access - - Set access level on published packages + access Set access level on published packages Usage: npm access public [] @@ -185,9 +183,7 @@ All commands: Run "npm help access" for more info - adduser npm adduser - - Add a registry user account + adduser Add a registry user account Usage: npm adduser @@ -199,9 +195,7 @@ All commands: Run "npm help adduser" for more info - audit npm audit - - Run a security audit + audit Run a security audit Usage: npm audit [fix] @@ -216,9 +210,7 @@ All commands: Run "npm help audit" for more info - bin npm bin - - Display npm bin folder + bin Display npm bin folder Usage: npm bin @@ -228,9 +220,7 @@ All commands: Run "npm help bin" for more info - bugs npm bugs - - Report bugs for a package in a web browser + bugs Report bugs for a package in a web browser Usage: npm bugs [] @@ -242,9 +232,7 @@ All commands: Run "npm help bugs" for more info - cache npm cache - - Manipulates packages cache + cache Manipulates packages cache Usage: npm cache add @@ -261,9 +249,7 @@ All commands: Run "npm help cache" for more info - ci npm ci - - Install a project with a clean slate + ci Install a project with a clean slate Usage: npm ci @@ -276,18 +262,14 @@ All commands: Run "npm help ci" for more info - completion npm completion - - Tab Completion for npm + completion Tab Completion for npm Usage: npm completion Run "npm help completion" for more info - config npm config - - Manage the npm configuration files + config Manage the npm configuration files Usage: npm config set = [= ...] @@ -304,9 +286,7 @@ All commands: Run "npm help config" for more info - dedupe npm dedupe - - Reduce duplication in the package tree + dedupe Reduce duplication in the package tree Usage: npm dedupe @@ -323,9 +303,7 @@ All commands: Run "npm help dedupe" for more info - deprecate npm deprecate - - Deprecate a version of a package + deprecate Deprecate a version of a package Usage: npm deprecate [@] @@ -335,9 +313,7 @@ All commands: Run "npm help deprecate" for more info - diff npm diff - - The registry diff command + diff The registry diff command Usage: npm diff [...] @@ -352,9 +328,7 @@ All commands: Run "npm help diff" for more info - dist-tag npm dist-tag - - Modify package distribution tags + dist-tag Modify package distribution tags Usage: npm dist-tag add @ [] @@ -369,9 +343,7 @@ All commands: Run "npm help dist-tag" for more info - docs npm docs - - Open documentation for a package in a web browser + docs Open documentation for a package in a web browser Usage: npm docs [ [ ...]] @@ -385,9 +357,7 @@ All commands: Run "npm help docs" for more info - doctor npm doctor - - Check your npm environment + doctor Check your npm environment Usage: npm doctor @@ -397,9 +367,7 @@ All commands: Run "npm help doctor" for more info - edit npm edit - - Edit an installed package + edit Edit an installed package Usage: npm edit [/...] @@ -409,9 +377,7 @@ All commands: Run "npm help edit" for more info - exec npm exec - - Run a command from a local or remote npm package + exec Run a command from a local or remote npm package Usage: npm exec -- [@] [args...] @@ -429,9 +395,7 @@ All commands: Run "npm help exec" for more info - explain npm explain - - Explain installed packages + explain Explain installed packages Usage: npm explain @@ -443,9 +407,7 @@ All commands: Run "npm help explain" for more info - explore npm explore - - Browse an installed package + explore Browse an installed package Usage: npm explore [ -- ] @@ -455,9 +417,7 @@ All commands: Run "npm help explore" for more info - find-dupes npm find-dupes - - Find duplication in the package tree + find-dupes Find duplication in the package tree Usage: npm find-dupes @@ -471,9 +431,7 @@ All commands: Run "npm help find-dupes" for more info - fund npm fund - - Retrieve funding information + fund Retrieve funding information Usage: npm fund [[<@scope>/]] @@ -485,18 +443,14 @@ All commands: Run "npm help fund" for more info - get npm get - - Get a value from the npm configuration + get Get a value from the npm configuration Usage: npm get [ ...] (See \`npm config\`) Run "npm help get" for more info - help npm help - - Get help on npm + help Get help on npm Usage: npm help [] @@ -508,9 +462,7 @@ All commands: Run "npm help help" for more info - hook npm hook - - Manage registry hooks + hook Manage registry hooks Usage: npm hook add [--type=] @@ -523,9 +475,7 @@ All commands: Run "npm help hook" for more info - init npm init - - Create a package.json file + init Create a package.json file Usage: npm init [--force|-f|--yes|-y|--scope] @@ -541,9 +491,7 @@ All commands: Run "npm help init" for more info - install npm install - - Install a package + install Install a package Usage: npm install [<@scope>/] @@ -566,13 +514,11 @@ All commands: [-w|--workspace [-w|--workspace ...]] [-ws|--workspaces] [--include-workspace-root] - aliases: i, in, ins, inst, insta, instal, isnt, isnta, isntal, isntall, add + aliases: add, i, in, ins, inst, insta, instal, isnt, isnta, isntal, isntall Run "npm help install" for more info - install-ci-test npm install-ci-test - - Install a project with a clean slate and run tests + install-ci-test Install a project with a clean slate and run tests Usage: npm install-ci-test @@ -585,9 +531,7 @@ All commands: Run "npm help install-ci-test" for more info - install-test npm install-test - - Install package(s) and run tests + install-test Install package(s) and run tests Usage: npm install-test [<@scope>/] @@ -614,9 +558,7 @@ All commands: Run "npm help install-test" for more info - link npm link - - Symlink a package folder + link Symlink a package folder Usage: npm link (in package dir) @@ -635,9 +577,7 @@ All commands: Run "npm help link" for more info - ll npm ll - - List installed packages + ll List installed packages Usage: npm ll [[<@scope>/] ...] @@ -653,9 +593,7 @@ All commands: Run "npm help ll" for more info - login npm adduser - - Add a registry user account + login Add a registry user account Usage: npm adduser @@ -667,9 +605,7 @@ All commands: Run "npm help adduser" for more info - logout npm logout - - Log out of the registry + logout Log out of the registry Usage: npm logout @@ -679,9 +615,7 @@ All commands: Run "npm help logout" for more info - ls npm ls - - List installed packages + ls List installed packages Usage: npm ls [[<@scope>/] ...] @@ -697,9 +631,7 @@ All commands: Run "npm help ls" for more info - org npm org - - Manage orgs + org Manage orgs Usage: npm org set orgname username [developer | admin | owner] @@ -713,9 +645,7 @@ All commands: Run "npm help org" for more info - outdated npm outdated - - Check for outdated packages + outdated Check for outdated packages Usage: npm outdated [[<@scope>/] ...] @@ -726,9 +656,7 @@ All commands: Run "npm help outdated" for more info - owner npm owner - - Manage package owners + owner Manage package owners Usage: npm owner add [<@scope>/] @@ -742,9 +670,7 @@ All commands: Run "npm help owner" for more info - pack npm pack - - Create a tarball from a package + pack Create a tarball from a package Usage: npm pack [[<@scope>/]...] @@ -756,9 +682,7 @@ All commands: Run "npm help pack" for more info - ping npm ping - - Ping npm registry + ping Ping npm registry Usage: npm ping @@ -768,9 +692,7 @@ All commands: Run "npm help ping" for more info - pkg npm pkg - - Manages your package.json + pkg Manages your package.json Usage: npm pkg set = [= ...] @@ -786,9 +708,7 @@ All commands: Run "npm help pkg" for more info - prefix npm prefix - - Display prefix + prefix Display prefix Usage: npm prefix [-g] @@ -798,9 +718,7 @@ All commands: Run "npm help prefix" for more info - profile npm profile - - Change settings on your registry profile + profile Change settings on your registry profile Usage: npm profile enable-2fa [auth-only|auth-and-writes] @@ -813,9 +731,7 @@ All commands: Run "npm help profile" for more info - prune npm prune - - Remove extraneous packages + prune Remove extraneous packages Usage: npm prune [[<@scope>/]...] @@ -828,9 +744,7 @@ All commands: Run "npm help prune" for more info - publish npm publish - - Publish a package + publish Publish a package Usage: npm publish [] @@ -842,9 +756,7 @@ All commands: Run "npm help publish" for more info - rebuild npm rebuild - - Rebuild a package + rebuild Rebuild a package Usage: npm rebuild [[<@scope>/][@] ...] @@ -858,9 +770,7 @@ All commands: Run "npm help rebuild" for more info - repo npm repo - - Open package repository page in the browser + repo Open package repository page in the browser Usage: npm repo [ [ ...]] @@ -872,9 +782,7 @@ All commands: Run "npm help repo" for more info - restart npm restart - - Restart a package + restart Restart a package Usage: npm restart [-- ] @@ -884,9 +792,7 @@ All commands: Run "npm help restart" for more info - root npm root - - Display npm root + root Display npm root Usage: npm root @@ -896,9 +802,7 @@ All commands: Run "npm help root" for more info - run-script npm run-script - - Run arbitrary package scripts + run-script Run arbitrary package scripts Usage: npm run-script [-- ] @@ -912,9 +816,7 @@ All commands: Run "npm help run-script" for more info - search npm search - - Search for packages + search Search for packages Usage: npm search [search terms ...] @@ -924,22 +826,18 @@ All commands: [--no-description] [--searchopts ] [--searchexclude ] [--registry ] [--prefer-online] [--prefer-offline] [--offline] - aliases: s, se, find + aliases: find, s, se Run "npm help search" for more info - set npm set - - Set a value in the npm configuration + set Set a value in the npm configuration Usage: npm set = [= ...] (See \`npm config\`) Run "npm help set" for more info - set-script npm set-script - - Set tasks in the scripts section of package.json + set-script Set tasks in the scripts section of package.json Usage: npm set-script [