diff --git a/.mailmap b/.mailmap index df1b4d34998d40..c1c8ad0ea55401 100644 --- a/.mailmap +++ b/.mailmap @@ -221,7 +221,7 @@ James Hartig James Ide James M Snell James Nimlos -James Sumners +James Sumners Jan Krems Jem Bezooyen Jem Bezooyen @@ -239,7 +239,7 @@ Jesús Leganés-Combarro 'piranna Jimb Esser Jithil P Ponnan Jithil P Ponnan -Jochen Eisinger +Jochen Eisinger Joe Shaw Johan Bergström Johan Dahlberg @@ -372,6 +372,9 @@ Nils Kuhnhenn Nitzan Uziely Nitzan Uziely Noah Rose Ledesma +npm team +npm team +npm team Oliver Chang Oluwaseun Omoyajowo Onne Gorter diff --git a/CHANGELOG.md b/CHANGELOG.md index 9134a7085104cc..d9b61229e18fd9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,7 +33,9 @@ release. -17.8.0
+17.9.1
+17.9.0
+17.8.0
17.7.2
17.7.1
17.7.0
diff --git a/deps/npm/README.md b/deps/npm/README.md index 46846fa0087b50..7e4a5f38a7607f 100644 --- a/deps/npm/README.md +++ b/deps/npm/README.md @@ -1,7 +1,10 @@ -[![GitHub Workflow Status (branch)](https://img.shields.io/github/workflow/status/npm/cli/Node%20CI/latest)](https://github.com/npm/cli/actions?query=workflow%3A%22Node+CI%22+branch%3Alatest) [![Coveralls github branch](https://img.shields.io/coveralls/github/npm/cli/latest)](https://coveralls.io/github/npm/cli?branch=latest) - # npm - a JavaScript package manager +[![npm version](https://img.shields.io/npm/v/npm.svg)](https://npm.im/npm) +[![license](https://img.shields.io/npm/l/npm.svg)](https://npm.im/npm) +[![CI - cli](https://github.com/npm/cli/actions/workflows/ci.yml/badge.svg)](https://github.com/npm/cli/actions/workflows/ci.yml) +[![Benchmark Suite](https://github.com/npm/cli/actions/workflows/benchmark.yml/badge.svg)](https://github.com/npm/cli/actions/workflows/benchmark.yml) + ### Requirements One of the following versions of [Node.js](https://nodejs.org/en/download/) must be installed to run **`npm`**: @@ -34,6 +37,7 @@ If you're looking to manage multiple versions of **`node`** &/or **`npm`**, cons * [**`nodenv`**](https://github.com/nodenv/nodenv) * [**`asdf-nodejs`**](https://github.com/asdf-vm/asdf-nodejs) * [**`nvm-windows`**](https://github.com/coreybutler/nvm-windows) +* [**`fnm`**](https://github.com/Schniz/fnm) ### Usage @@ -46,7 +50,7 @@ npm * [**Documentation**](https://docs.npmjs.com/) - Official docs & how-tos for all things **npm** * Note: you can also search docs locally with `npm help-search ` * [**Bug Tracker**](https://github.com/npm/cli/issues) - Search or submit bugs against the CLI -* [**Roadmap**](https://github.com/npm/roadmap) - Track & follow along with our public roadmap +* [**Roadmap**](https://github.com/orgs/github/projects/4247/views/1?filterQuery=npm) - Track & follow along with our public roadmap * [**Feedback**](https://github.com/npm/feedback) - Contribute ideas & discussion around the npm registry, website & CLI * [**RFCs**](https://github.com/npm/rfcs) - Contribute ideas & specifications for the API/design of the npm CLI * [**Service Status**](https://status.npmjs.org/) - Monitor the current status & see incident reports for the website & registry diff --git a/deps/npm/bin/npx b/deps/npm/bin/npx index 4b58a104b9e421..a34e3459b5a701 100755 --- a/deps/npm/bin/npx +++ b/deps/npm/bin/npx @@ -12,6 +12,9 @@ case `uname` in esac NODE_EXE="$basedir/node.exe" +if ! [ -x "$NODE_EXE" ]; then + NODE_EXE="$basedir/node" +fi if ! [ -x "$NODE_EXE" ]; then NODE_EXE=node fi diff --git a/deps/npm/docs/content/commands/npm-audit.md b/deps/npm/docs/content/commands/npm-audit.md index 24b700ff5abd85..9d09a4107fdc7d 100644 --- a/deps/npm/docs/content/commands/npm-audit.md +++ b/deps/npm/docs/content/commands/npm-audit.md @@ -394,6 +394,20 @@ When false, specifying individual workspaces via the `workspace` config, or all workspaces via the `workspaces` flag, will cause npm to operate only on the specified workspaces, and not on the root project. +This value is not exported to the environment for child processes. + + + + +#### `install-links` + +* Default: false +* Type: Boolean + +When set file: protocol dependencies that exist outside of the project root +will be packed and installed as regular dependencies instead of creating a +symlink. This option has no effect on workspaces. + diff --git a/deps/npm/docs/content/commands/npm-bin.md b/deps/npm/docs/content/commands/npm-bin.md index 94b72cfd5c81ce..b344ea2fc94159 100644 --- a/deps/npm/docs/content/commands/npm-bin.md +++ b/deps/npm/docs/content/commands/npm-bin.md @@ -34,6 +34,8 @@ Print the folder where npm will install executables. * Default: false * Type: Boolean +* DEPRECATED: `--global`, `--local` are deprecated. Use `--location=global` + instead. Operates in "global" mode, so that packages are installed into the `prefix` folder instead of the current working directory. See diff --git a/deps/npm/docs/content/commands/npm-bugs.md b/deps/npm/docs/content/commands/npm-bugs.md index aeddeb848e81b8..6b45f1f18ac660 100644 --- a/deps/npm/docs/content/commands/npm-bugs.md +++ b/deps/npm/docs/content/commands/npm-bugs.md @@ -11,7 +11,7 @@ description: Report bugs for a package in a web browser ```bash -npm bugs [] +npm bugs [ [ ...]] alias: issues ``` @@ -58,6 +58,68 @@ The base URL of the npm registry. +#### `workspace` + +* Default: +* Type: String (can be set multiple times) + +Enable running a command in the context of the configured workspaces of the +current project while filtering by running only the workspaces defined by +this configuration option. + +Valid values for the `workspace` config are either: + +* Workspace names +* Path to a workspace directory +* Path to a parent workspace directory (will result in selecting all + workspaces within that folder) + +When set for the `npm init` command, this may be set to the folder of a +workspace which does not yet exist, to create the folder and set it up as a +brand new workspace within the project. + +This value is not exported to the environment for child processes. + + + + +#### `workspaces` + +* Default: null +* Type: null or Boolean + +Set to true to run the command in the context of **all** configured +workspaces. + +Explicitly setting this to false will cause commands like `install` to +ignore workspaces altogether. When not set explicitly: + +- Commands that operate on the `node_modules` tree (install, update, etc.) +will link workspaces into the `node_modules` folder. - Commands that do +other things (test, exec, publish, etc.) will operate on the root project, +_unless_ one or more workspaces are specified in the `workspace` config. + +This value is not exported to the environment for child processes. + + + + +#### `include-workspace-root` + +* Default: false +* Type: Boolean + +Include the workspace root when workspaces are enabled for a command. + +When false, specifying individual workspaces via the `workspace` config, or +all workspaces via the `workspaces` flag, will cause npm to operate only on +the specified workspaces, and not on the root project. + +This value is not exported to the environment for child processes. + + + + ### See Also diff --git a/deps/npm/docs/content/commands/npm-ci.md b/deps/npm/docs/content/commands/npm-ci.md index 97d1aa5523dd72..3374bf1e25136b 100644 --- a/deps/npm/docs/content/commands/npm-ci.md +++ b/deps/npm/docs/content/commands/npm-ci.md @@ -1,7 +1,7 @@ --- title: npm-ci section: 1 -description: Install a project with a clean slate +description: Clean install a project --- ### Synopsis @@ -28,12 +28,7 @@ it's meant to be used in automated environments such as test platforms, continuous integration, and deployment -- or any situation where you want to make sure you're doing a clean install of your dependencies. -`npm ci` will be significantly faster when: - -- There is a `package-lock.json` or `npm-shrinkwrap.json` file. -- The `node_modules` folder is missing or empty. - -In short, the main differences between using `npm install` and `npm ci` are: +The main differences between using `npm install` and `npm ci` are: * The project **must** have an existing `package-lock.json` or `npm-shrinkwrap.json`. @@ -46,6 +41,14 @@ In short, the main differences between using `npm install` and `npm ci` are: * It will never write to `package.json` or any of the package-locks: installs are essentially frozen. +NOTE: If you create your `package-lock.json` file by running `npm install` +with flags that can affect the shape of your dependency tree, such as +`--legacy-peer-deps` or `--install-links`, you _must_ provide the same +flags to `npm ci` or you are likely to encounter errors. An easy way to do +this is to run, for example, +`npm config set legacy-peer-deps=true --location=project` and commit the +`.npmrc` file to your repo. + ### Example Make sure you have a package-lock and an up-to-date install: diff --git a/deps/npm/docs/content/commands/npm-config.md b/deps/npm/docs/content/commands/npm-config.md index a66a198ce42d17..809e42a1be1cdb 100644 --- a/deps/npm/docs/content/commands/npm-config.md +++ b/deps/npm/docs/content/commands/npm-config.md @@ -124,6 +124,8 @@ Not supported by all npm commands. * Default: false * Type: Boolean +* DEPRECATED: `--global`, `--local` are deprecated. Use `--location=global` + instead. Operates in "global" mode, so that packages are installed into the `prefix` folder instead of the current working directory. See @@ -156,6 +158,15 @@ The command to run for `npm edit` and `npm config edit`. When passed to `npm config` this refers to which config file to use. +When set to "global" mode, packages are installed into the `prefix` folder +instead of the current working directory. See +[folders](/configuring-npm/folders) for more on the differences in behavior. + +* packages are installed into the `{prefix}/lib/node_modules` folder, instead + of the current working directory. +* bin files are linked to `{prefix}/bin` +* man pages are linked to `{prefix}/share/man` + diff --git a/deps/npm/docs/content/commands/npm-dedupe.md b/deps/npm/docs/content/commands/npm-dedupe.md index b5a64831c0bbaa..570e018342f276 100644 --- a/deps/npm/docs/content/commands/npm-dedupe.md +++ b/deps/npm/docs/content/commands/npm-dedupe.md @@ -80,11 +80,9 @@ result in new modules being installed. Using `npm find-dupes` will run the command in `--dry-run` mode. -Note that by default `npm dedupe` will not update the semver values of direct -dependencies in your project `package.json`, if you want to also update -values in `package.json` you can run: `npm dedupe --save` (or add the -`save=true` option to a [configuration file](/configuring-npm/npmrc) -to make that the default behavior). +Note: `npm dedupe` will never update the semver values of direct +dependencies in your project `package.json`, if you want to update +values in `package.json` you can run: `npm update --save` instead. ### Configuration @@ -149,31 +147,11 @@ this warning is treated as a failure. If set to false, then ignore `package-lock.json` files when installing. This will also prevent _writing_ `package-lock.json` if `save` is true. -When package package-locks are disabled, automatic pruning of extraneous -modules will also be disabled. To remove extraneous modules with -package-locks disabled use `npm prune`. - This configuration does not affect `npm ci`. -#### `save` - -* Default: `true` unless when using `npm update` or `npm dedupe` where it - defaults to `false` -* Type: Boolean - -Save installed packages to a `package.json` file as dependencies. - -When used with the `npm rm` command, removes the dependency from -`package.json`. - -Will also prevent writing to `package-lock.json` if set to `false`. - - - - #### `omit` * Default: 'dev' if the `NODE_ENV` environment variable is set to @@ -323,6 +301,20 @@ When false, specifying individual workspaces via the `workspace` config, or all workspaces via the `workspaces` flag, will cause npm to operate only on the specified workspaces, and not on the root project. +This value is not exported to the environment for child processes. + + + + +#### `install-links` + +* Default: false +* Type: Boolean + +When set file: protocol dependencies that exist outside of the project root +will be packed and installed as regular dependencies instead of creating a +symlink. This option has no effect on workspaces. + diff --git a/deps/npm/docs/content/commands/npm-diff.md b/deps/npm/docs/content/commands/npm-diff.md index c4c9eafdb3524d..7183e4a2b752e3 100644 --- a/deps/npm/docs/content/commands/npm-diff.md +++ b/deps/npm/docs/content/commands/npm-diff.md @@ -248,6 +248,8 @@ Treat all files as text in `npm diff`. * Default: false * Type: Boolean +* DEPRECATED: `--global`, `--local` are deprecated. Use `--location=global` + instead. Operates in "global" mode, so that packages are installed into the `prefix` folder instead of the current working directory. See @@ -335,6 +337,8 @@ When false, specifying individual workspaces via the `workspace` config, or all workspaces via the `workspaces` flag, will cause npm to operate only on the specified workspaces, and not on the root project. +This value is not exported to the environment for child processes. + diff --git a/deps/npm/docs/content/commands/npm-dist-tag.md b/deps/npm/docs/content/commands/npm-dist-tag.md index a0f306cd4970d5..b9caf1fbe7fa9c 100644 --- a/deps/npm/docs/content/commands/npm-dist-tag.md +++ b/deps/npm/docs/content/commands/npm-dist-tag.md @@ -159,6 +159,8 @@ When false, specifying individual workspaces via the `workspace` config, or all workspaces via the `workspaces` flag, will cause npm to operate only on the specified workspaces, and not on the root project. +This value is not exported to the environment for child processes. + diff --git a/deps/npm/docs/content/commands/npm-docs.md b/deps/npm/docs/content/commands/npm-docs.md index 8d5a278286a88b..790d563bdb1fb7 100644 --- a/deps/npm/docs/content/commands/npm-docs.md +++ b/deps/npm/docs/content/commands/npm-docs.md @@ -116,6 +116,8 @@ When false, specifying individual workspaces via the `workspace` config, or all workspaces via the `workspaces` flag, will cause npm to operate only on the specified workspaces, and not on the root project. +This value is not exported to the environment for child processes. + diff --git a/deps/npm/docs/content/commands/npm-exec.md b/deps/npm/docs/content/commands/npm-exec.md index 3645e336b9da97..8ccfa75c73386c 100644 --- a/deps/npm/docs/content/commands/npm-exec.md +++ b/deps/npm/docs/content/commands/npm-exec.md @@ -205,6 +205,8 @@ When false, specifying individual workspaces via the `workspace` config, or all workspaces via the `workspaces` flag, will cause npm to operate only on the specified workspaces, and not on the root project. +This value is not exported to the environment for child processes. + diff --git a/deps/npm/docs/content/commands/npm-find-dupes.md b/deps/npm/docs/content/commands/npm-find-dupes.md index f7366fa6375d1e..4da6c296c6bf6d 100644 --- a/deps/npm/docs/content/commands/npm-find-dupes.md +++ b/deps/npm/docs/content/commands/npm-find-dupes.md @@ -87,10 +87,6 @@ this warning is treated as a failure. If set to false, then ignore `package-lock.json` files when installing. This will also prevent _writing_ `package-lock.json` if `save` is true. -When package package-locks are disabled, automatic pruning of extraneous -modules will also be disabled. To remove extraneous modules with -package-locks disabled use `npm prune`. - This configuration does not affect `npm ci`. @@ -229,6 +225,20 @@ When false, specifying individual workspaces via the `workspace` config, or all workspaces via the `workspaces` flag, will cause npm to operate only on the specified workspaces, and not on the root project. +This value is not exported to the environment for child processes. + + + + +#### `install-links` + +* Default: false +* Type: Boolean + +When set file: protocol dependencies that exist outside of the project root +will be packed and installed as regular dependencies instead of creating a +symlink. This option has no effect on workspaces. + diff --git a/deps/npm/docs/content/commands/npm-init.md b/deps/npm/docs/content/commands/npm-init.md index 71109cd360511d..5a7dd4c97ac60e 100644 --- a/deps/npm/docs/content/commands/npm-init.md +++ b/deps/npm/docs/content/commands/npm-init.md @@ -264,6 +264,8 @@ When false, specifying individual workspaces via the `workspace` config, or all workspaces via the `workspaces` flag, will cause npm to operate only on the specified workspaces, and not on the root project. +This value is not exported to the environment for child processes. + diff --git a/deps/npm/docs/content/commands/npm-install-test.md b/deps/npm/docs/content/commands/npm-install-test.md index 5ac31cbf08e25c..18e374869d5a60 100644 --- a/deps/npm/docs/content/commands/npm-install-test.md +++ b/deps/npm/docs/content/commands/npm-install-test.md @@ -42,8 +42,7 @@ takes exactly the same arguments as `npm install`. #### `save` -* Default: `true` unless when using `npm update` or `npm dedupe` where it - defaults to `false` +* Default: `true` unless when using `npm update` where it defaults to `false` * Type: Boolean Save installed packages to a `package.json` file as dependencies. @@ -71,6 +70,8 @@ rather than using npm's default semver range operator. * Default: false * Type: Boolean +* DEPRECATED: `--global`, `--local` are deprecated. Use `--location=global` + instead. Operates in "global" mode, so that packages are installed into the `prefix` folder instead of the current working directory. See @@ -163,10 +164,6 @@ this warning is treated as a failure. If set to false, then ignore `package-lock.json` files when installing. This will also prevent _writing_ `package-lock.json` if `save` is true. -When package package-locks are disabled, automatic pruning of extraneous -modules will also be disabled. To remove extraneous modules with -package-locks disabled use `npm prune`. - This configuration does not affect `npm ci`. @@ -315,6 +312,20 @@ When false, specifying individual workspaces via the `workspace` config, or all workspaces via the `workspaces` flag, will cause npm to operate only on the specified workspaces, and not on the root project. +This value is not exported to the environment for child processes. + + + + +#### `install-links` + +* Default: false +* Type: Boolean + +When set file: protocol dependencies that exist outside of the project root +will be packed and installed as regular dependencies instead of creating a +symlink. This option has no effect on workspaces. + diff --git a/deps/npm/docs/content/commands/npm-install.md b/deps/npm/docs/content/commands/npm-install.md index 2ffd3e3e9fff14..318df5780e8dba 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 ``` @@ -91,12 +91,12 @@ into a tarball (b). *npm will not install the package dependencies* in the directory ``, but it will create a symlink to ``. - > NOTE: If you want to install the content of a directory like a package from the registry instead of creating a link, you would need to use [`npm pack`](/commands/npm-pack) while in the `` directory, and then install the resulting tarball instead of the `` using `npm install ` + > NOTE: If you want to install the content of a directory like a package from the registry instead of creating a link, you would need to use the `--install-links` option. Example: ```bash - npm install ../../other-package + npm install ../../other-package --install-links npm install ./sub-package ``` @@ -432,8 +432,7 @@ These are some of the most common options related to installation. #### `save` -* Default: `true` unless when using `npm update` or `npm dedupe` where it - defaults to `false` +* Default: `true` unless when using `npm update` where it defaults to `false` * Type: Boolean Save installed packages to a `package.json` file as dependencies. @@ -461,6 +460,8 @@ rather than using npm's default semver range operator. * Default: false * Type: Boolean +* DEPRECATED: `--global`, `--local` are deprecated. Use `--location=global` + instead. Operates in "global" mode, so that packages are installed into the `prefix` folder instead of the current working directory. See @@ -553,10 +554,6 @@ this warning is treated as a failure. If set to false, then ignore `package-lock.json` files when installing. This will also prevent _writing_ `package-lock.json` if `save` is true. -When package package-locks are disabled, automatic pruning of extraneous -modules will also be disabled. To remove extraneous modules with -package-locks disabled use `npm prune`. - This configuration does not affect `npm ci`. @@ -705,6 +702,20 @@ When false, specifying individual workspaces via the `workspace` config, or all workspaces via the `workspaces` flag, will cause npm to operate only on the specified workspaces, and not on the root project. +This value is not exported to the environment for child processes. + + + + +#### `install-links` + +* Default: false +* Type: Boolean + +When set file: protocol dependencies that exist outside of the project root +will be packed and installed as regular dependencies instead of creating a +symlink. This option has no effect on workspaces. + diff --git a/deps/npm/docs/content/commands/npm-link.md b/deps/npm/docs/content/commands/npm-link.md index 892b55496c9b6f..34c67aa3def81d 100644 --- a/deps/npm/docs/content/commands/npm-link.md +++ b/deps/npm/docs/content/commands/npm-link.md @@ -125,8 +125,7 @@ workspace(s). #### `save` -* Default: `true` unless when using `npm update` or `npm dedupe` where it - defaults to `false` +* Default: `true` unless when using `npm update` where it defaults to `false` * Type: Boolean Save installed packages to a `package.json` file as dependencies. @@ -154,6 +153,8 @@ rather than using npm's default semver range operator. * Default: false * Type: Boolean +* DEPRECATED: `--global`, `--local` are deprecated. Use `--location=global` + instead. Operates in "global" mode, so that packages are installed into the `prefix` folder instead of the current working directory. See @@ -225,10 +226,6 @@ this warning is treated as a failure. If set to false, then ignore `package-lock.json` files when installing. This will also prevent _writing_ `package-lock.json` if `save` is true. -When package package-locks are disabled, automatic pruning of extraneous -modules will also be disabled. To remove extraneous modules with -package-locks disabled use `npm prune`. - This configuration does not affect `npm ci`. @@ -383,6 +380,20 @@ When false, specifying individual workspaces via the `workspace` config, or all workspaces via the `workspaces` flag, will cause npm to operate only on the specified workspaces, and not on the root project. +This value is not exported to the environment for child processes. + + + + +#### `install-links` + +* Default: false +* Type: Boolean + +When set file: protocol dependencies that exist outside of the project root +will be packed and installed as regular dependencies instead of creating a +symlink. This option has no effect on workspaces. + diff --git a/deps/npm/docs/content/commands/npm-ls.md b/deps/npm/docs/content/commands/npm-ls.md index 0f06e131f414b2..5ad4593bfa2f6a 100644 --- a/deps/npm/docs/content/commands/npm-ls.md +++ b/deps/npm/docs/content/commands/npm-ls.md @@ -137,6 +137,8 @@ Output parseable results from commands that write to standard output. For * Default: false * Type: Boolean +* DEPRECATED: `--global`, `--local` are deprecated. Use `--location=global` + instead. Operates in "global" mode, so that packages are installed into the `prefix` folder instead of the current working directory. See @@ -280,6 +282,20 @@ When false, specifying individual workspaces via the `workspace` config, or all workspaces via the `workspaces` flag, will cause npm to operate only on the specified workspaces, and not on the root project. +This value is not exported to the environment for child processes. + + + + +#### `install-links` + +* Default: false +* Type: Boolean + +When set file: protocol dependencies that exist outside of the project root +will be packed and installed as regular dependencies instead of creating a +symlink. This option has no effect on workspaces. + diff --git a/deps/npm/docs/content/commands/npm-outdated.md b/deps/npm/docs/content/commands/npm-outdated.md index 6fa026550e7477..1bf2de039c3159 100644 --- a/deps/npm/docs/content/commands/npm-outdated.md +++ b/deps/npm/docs/content/commands/npm-outdated.md @@ -150,6 +150,8 @@ Output parseable results from commands that write to standard output. For * Default: false * Type: Boolean +* DEPRECATED: `--global`, `--local` are deprecated. Use `--location=global` + instead. Operates in "global" mode, so that packages are installed into the `prefix` folder instead of the current working directory. See diff --git a/deps/npm/docs/content/commands/npm-owner.md b/deps/npm/docs/content/commands/npm-owner.md index 0779984e19a9db..72dfe6a22d01b0 100644 --- a/deps/npm/docs/content/commands/npm-owner.md +++ b/deps/npm/docs/content/commands/npm-owner.md @@ -73,6 +73,52 @@ password, npm will prompt on the command line for one. +#### `workspace` + +* Default: +* Type: String (can be set multiple times) + +Enable running a command in the context of the configured workspaces of the +current project while filtering by running only the workspaces defined by +this configuration option. + +Valid values for the `workspace` config are either: + +* Workspace names +* Path to a workspace directory +* Path to a parent workspace directory (will result in selecting all + workspaces within that folder) + +When set for the `npm init` command, this may be set to the folder of a +workspace which does not yet exist, to create the folder and set it up as a +brand new workspace within the project. + +This value is not exported to the environment for child processes. + + + + +#### `workspaces` + +* Default: null +* Type: null or Boolean + +Set to true to run the command in the context of **all** configured +workspaces. + +Explicitly setting this to false will cause commands like `install` to +ignore workspaces altogether. When not set explicitly: + +- Commands that operate on the `node_modules` tree (install, update, etc.) +will link workspaces into the `node_modules` folder. - Commands that do +other things (test, exec, publish, etc.) will operate on the root project, +_unless_ one or more workspaces are specified in the `workspace` config. + +This value is not exported to the environment for child processes. + + + + ### See Also diff --git a/deps/npm/docs/content/commands/npm-pack.md b/deps/npm/docs/content/commands/npm-pack.md index c834f643ac0bb1..fa6c005e9d2287 100644 --- a/deps/npm/docs/content/commands/npm-pack.md +++ b/deps/npm/docs/content/commands/npm-pack.md @@ -122,6 +122,8 @@ When false, specifying individual workspaces via the `workspace` config, or all workspaces via the `workspaces` flag, will cause npm to operate only on the specified workspaces, and not on the root project. +This value is not exported to the environment for child processes. + diff --git a/deps/npm/docs/content/commands/npm-pkg.md b/deps/npm/docs/content/commands/npm-pkg.md index 576e1335efbba9..deff7e82c694dd 100644 --- a/deps/npm/docs/content/commands/npm-pkg.md +++ b/deps/npm/docs/content/commands/npm-pkg.md @@ -76,6 +76,14 @@ Returned values are always in **json** format. npm pkg get contributors[0].email ``` + For complex fields you can also name a property in square brackets + to specifically select a child field. This is especially helpful + with the exports object: + + ```bash + npm pkg get "exports[.].require" + ``` + * `npm pkg set =` Sets a `value` in your `package.json` based on the `field` value. When diff --git a/deps/npm/docs/content/commands/npm-prefix.md b/deps/npm/docs/content/commands/npm-prefix.md index 39328bcc88a143..6f08e43fa8c0c4 100644 --- a/deps/npm/docs/content/commands/npm-prefix.md +++ b/deps/npm/docs/content/commands/npm-prefix.md @@ -51,6 +51,8 @@ npm prefix -g * Default: false * Type: Boolean +* DEPRECATED: `--global`, `--local` are deprecated. Use `--location=global` + instead. Operates in "global" mode, so that packages are installed into the `prefix` folder instead of the current working directory. See diff --git a/deps/npm/docs/content/commands/npm-prune.md b/deps/npm/docs/content/commands/npm-prune.md index a10a353801b7cd..28f02f6add1908 100644 --- a/deps/npm/docs/content/commands/npm-prune.md +++ b/deps/npm/docs/content/commands/npm-prune.md @@ -186,6 +186,20 @@ When false, specifying individual workspaces via the `workspace` config, or all workspaces via the `workspaces` flag, will cause npm to operate only on the specified workspaces, and not on the root project. +This value is not exported to the environment for child processes. + + + + +#### `install-links` + +* Default: false +* Type: Boolean + +When set file: protocol dependencies that exist outside of the project root +will be packed and installed as regular dependencies instead of creating a +symlink. This option has no effect on workspaces. + diff --git a/deps/npm/docs/content/commands/npm-publish.md b/deps/npm/docs/content/commands/npm-publish.md index ce6e1c1012c8e2..2995f6bc81551e 100644 --- a/deps/npm/docs/content/commands/npm-publish.md +++ b/deps/npm/docs/content/commands/npm-publish.md @@ -238,6 +238,8 @@ When false, specifying individual workspaces via the `workspace` config, or all workspaces via the `workspaces` flag, will cause npm to operate only on the specified workspaces, and not on the root project. +This value is not exported to the environment for child processes. + diff --git a/deps/npm/docs/content/commands/npm-rebuild.md b/deps/npm/docs/content/commands/npm-rebuild.md index d63e00b79d3867..fa5b0cfa97d7c1 100644 --- a/deps/npm/docs/content/commands/npm-rebuild.md +++ b/deps/npm/docs/content/commands/npm-rebuild.md @@ -42,6 +42,8 @@ will be rebuilt. * Default: false * Type: Boolean +* DEPRECATED: `--global`, `--local` are deprecated. Use `--location=global` + instead. Operates in "global" mode, so that packages are installed into the `prefix` folder instead of the current working directory. See @@ -157,6 +159,20 @@ When false, specifying individual workspaces via the `workspace` config, or all workspaces via the `workspaces` flag, will cause npm to operate only on the specified workspaces, and not on the root project. +This value is not exported to the environment for child processes. + + + + +#### `install-links` + +* Default: false +* Type: Boolean + +When set file: protocol dependencies that exist outside of the project root +will be packed and installed as regular dependencies instead of creating a +symlink. This option has no effect on workspaces. + diff --git a/deps/npm/docs/content/commands/npm-repo.md b/deps/npm/docs/content/commands/npm-repo.md index e14f07012a2484..fc540a9382b235 100644 --- a/deps/npm/docs/content/commands/npm-repo.md +++ b/deps/npm/docs/content/commands/npm-repo.md @@ -46,6 +46,16 @@ Set to `true` to use default system URL opener. +#### `registry` + +* Default: "https://registry.npmjs.org/" +* Type: URL + +The base URL of the npm registry. + + + + #### `workspace` * Default: @@ -103,6 +113,8 @@ When false, specifying individual workspaces via the `workspace` config, or all workspaces via the `workspaces` flag, will cause npm to operate only on the specified workspaces, and not on the root project. +This value is not exported to the environment for child processes. + diff --git a/deps/npm/docs/content/commands/npm-root.md b/deps/npm/docs/content/commands/npm-root.md index 40b58e4b33d0b2..80545235fc9693 100644 --- a/deps/npm/docs/content/commands/npm-root.md +++ b/deps/npm/docs/content/commands/npm-root.md @@ -41,6 +41,8 @@ echo "Global packages installed in: ${global_node_modules}" * Default: false * Type: Boolean +* DEPRECATED: `--global`, `--local` are deprecated. Use `--location=global` + instead. Operates in "global" mode, so that packages are installed into the `prefix` folder instead of the current working directory. See diff --git a/deps/npm/docs/content/commands/npm-run-script.md b/deps/npm/docs/content/commands/npm-run-script.md index 79b7c9a25780e6..73c4b1c7a748a7 100644 --- a/deps/npm/docs/content/commands/npm-run-script.md +++ b/deps/npm/docs/content/commands/npm-run-script.md @@ -203,6 +203,8 @@ When false, specifying individual workspaces via the `workspace` config, or all workspaces via the `workspaces` flag, will cause npm to operate only on the specified workspaces, and not on the root project. +This value is not exported to the environment for child processes. + @@ -218,6 +220,8 @@ it's present and fail if the script fails. This is useful, for example, when running scripts that may only apply for some builds in an otherwise generic CI setup. +This value is not exported to the environment for child processes. + 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-set-script.md b/deps/npm/docs/content/commands/npm-set-script.md index 2d8e87db852196..8695b43f14423e 100644 --- a/deps/npm/docs/content/commands/npm-set-script.md +++ b/deps/npm/docs/content/commands/npm-set-script.md @@ -7,6 +7,8 @@ description: Set tasks in the scripts section of package.json ### Synopsis An npm command that lets you create a task in the `scripts` section of the `package.json`. +Deprecated. + @@ -97,6 +99,8 @@ When false, specifying individual workspaces via the `workspace` config, or all workspaces via the `workspaces` flag, will cause npm to operate only on the specified workspaces, and not on the root project. +This value is not exported to the environment for child processes. + diff --git a/deps/npm/docs/content/commands/npm-star.md b/deps/npm/docs/content/commands/npm-star.md index bbec7ac5f9263f..00ef17a816b4ae 100644 --- a/deps/npm/docs/content/commands/npm-star.md +++ b/deps/npm/docs/content/commands/npm-star.md @@ -69,6 +69,20 @@ false, it uses ascii characters instead of unicode glyphs. +#### `otp` + +* Default: null +* Type: null or String + +This is a one-time password from a two-factor authenticator. It's needed +when publishing or changing package permissions with `npm access`. + +If not set, and a registry response fails with a challenge for a one-time +password, npm will prompt on the command line for one. + + + + ### See Also diff --git a/deps/npm/docs/content/commands/npm-uninstall.md b/deps/npm/docs/content/commands/npm-uninstall.md index 8132bf6bc40b6e..e39c7e328b20ad 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 ``` @@ -30,7 +30,7 @@ It also removes the package from the `dependencies`, `devDependencies`, `optionalDependencies`, and `peerDependencies` objects in your `package.json`. -Futher, if you have an `npm-shrinkwrap.json` or `package-lock.json`, npm +Further, if you have an `npm-shrinkwrap.json` or `package-lock.json`, npm will update those files as well. `--no-save` will tell npm not to remove the package from your @@ -70,8 +70,7 @@ npm uninstall lodash --no-save #### `save` -* Default: `true` unless when using `npm update` or `npm dedupe` where it - defaults to `false` +* Default: `true` unless when using `npm update` where it defaults to `false` * Type: Boolean Save installed packages to a `package.json` file as dependencies. @@ -141,6 +140,20 @@ When false, specifying individual workspaces via the `workspace` config, or all workspaces via the `workspaces` flag, will cause npm to operate only on the specified workspaces, and not on the root project. +This value is not exported to the environment for child processes. + + + + +#### `install-links` + +* Default: false +* Type: Boolean + +When set file: protocol dependencies that exist outside of the project root +will be packed and installed as regular dependencies instead of creating a +symlink. This option has no effect on workspaces. + diff --git a/deps/npm/docs/content/commands/npm-update.md b/deps/npm/docs/content/commands/npm-update.md index aff46b1e5b5576..55aad182fcafe8 100644 --- a/deps/npm/docs/content/commands/npm-update.md +++ b/deps/npm/docs/content/commands/npm-update.md @@ -171,8 +171,7 @@ be _downgraded_. #### `save` -* Default: `true` unless when using `npm update` or `npm dedupe` where it - defaults to `false` +* Default: `true` unless when using `npm update` where it defaults to `false` * Type: Boolean Save installed packages to a `package.json` file as dependencies. @@ -189,6 +188,8 @@ Will also prevent writing to `package-lock.json` if set to `false`. * Default: false * Type: Boolean +* DEPRECATED: `--global`, `--local` are deprecated. Use `--location=global` + instead. Operates in "global" mode, so that packages are installed into the `prefix` folder instead of the current working directory. See @@ -281,10 +282,6 @@ this warning is treated as a failure. If set to false, then ignore `package-lock.json` files when installing. This will also prevent _writing_ `package-lock.json` if `save` is true. -When package package-locks are disabled, automatic pruning of extraneous -modules will also be disabled. To remove extraneous modules with -package-locks disabled use `npm prune`. - This configuration does not affect `npm ci`. @@ -433,6 +430,20 @@ When false, specifying individual workspaces via the `workspace` config, or all workspaces via the `workspaces` flag, will cause npm to operate only on the specified workspaces, and not on the root project. +This value is not exported to the environment for child processes. + + + + +#### `install-links` + +* Default: false +* Type: Boolean + +When set file: protocol dependencies that exist outside of the project root +will be packed and installed as regular dependencies instead of creating a +symlink. This option has no effect on workspaces. + diff --git a/deps/npm/docs/content/commands/npm-version.md b/deps/npm/docs/content/commands/npm-version.md index 86e2ce90e9bea7..8e3334d7889848 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 @@ -155,6 +166,8 @@ When false, specifying individual workspaces via the `workspace` config, or all workspaces via the `workspaces` flag, will cause npm to operate only on the specified workspaces, and not on the root project. +This value is not exported to the environment for child processes. + diff --git a/deps/npm/docs/content/commands/npm-view.md b/deps/npm/docs/content/commands/npm-view.md index 53ca408a01224f..0ef17d8adfb39b 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 ``` @@ -180,6 +180,8 @@ When false, specifying individual workspaces via the `workspace` config, or all workspaces via the `workspaces` flag, will cause npm to operate only on the specified workspaces, and not on the root project. +This value is not exported to the environment for child processes. + diff --git a/deps/npm/docs/content/using-npm/config.md b/deps/npm/docs/content/using-npm/config.md index df259715f08f2e..12b508582af1c3 100644 --- a/deps/npm/docs/content/using-npm/config.md +++ b/deps/npm/docs/content/using-npm/config.md @@ -68,6 +68,7 @@ The following shorthands are parsed on the command-line: * `--desc`: `--description` * `-f`: `--force` * `-g`: `--global` +* `--iwr`: `--include-workspace-root` * `-L`: `--location` * `-d`: `--loglevel info` * `-s`: `--loglevel silent` @@ -138,6 +139,8 @@ npm ls --global --parseable --long --loglevel info * Type: null or String A basic-auth string to use when authenticating against the npm registry. +This will ONLY be used to authenticate against the npm registry. For other +registries you will need to scope it like "//other-registry.tld/:_auth" Warning: This should generally not be set via a command-line option. It is safer to use a registry-provided authentication bearer token stored in the @@ -684,23 +687,6 @@ results in no commit being made at all. -#### `global` - -* Default: false -* Type: Boolean - -Operates in "global" mode, so that packages are installed into the `prefix` -folder instead of the current working directory. See -[folders](/configuring-npm/folders) for more on the differences in behavior. - -* packages are installed into the `{prefix}/lib/node_modules` folder, instead - of the current working directory. -* bin files are linked to `{prefix}/bin` -* man pages are linked to `{prefix}/share/man` - - - - #### `global-style` * Default: false @@ -762,6 +748,8 @@ it's present and fail if the script fails. This is useful, for example, when running scripts that may only apply for some builds in an otherwise generic CI setup. +This value is not exported to the environment for child processes. + @@ -819,6 +807,8 @@ When false, specifying individual workspaces via the `workspace` config, or all workspaces via the `workspaces` flag, will cause npm to operate only on the specified workspaces, and not on the root project. +This value is not exported to the environment for child processes. + @@ -887,6 +877,18 @@ number, if not already set in package.json. +#### `install-links` + +* Default: false +* Type: Boolean + +When set file: protocol dependencies that exist outside of the project root +will be packed and installed as regular dependencies instead of creating a +symlink. This option has no effect on workspaces. + + + + #### `json` * Default: false @@ -982,6 +984,15 @@ npm registry. Must be IPv4 in versions of Node prior to 0.12. When passed to `npm config` this refers to which config file to use. +When set to "global" mode, packages are installed into the `prefix` folder +instead of the current working directory. See +[folders](/configuring-npm/folders) for more on the differences in behavior. + +* packages are installed into the `{prefix}/lib/node_modules` folder, instead + of the current working directory. +* bin files are linked to `{prefix}/bin` +* man pages are linked to `{prefix}/share/man` + @@ -1027,6 +1038,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 +1056,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. + @@ -1146,6 +1170,19 @@ variable will be set to `'production'` for all lifecycle scripts. +#### `omit-lockfile-registry-resolved` + +* Default: false +* Type: Boolean + +This option causes npm to create lock files without a `resolved` key for +registry dependencies. Subsequent installs will need to resolve tarball +endpoints with the configured registry, likely resulting in a longer install +time. + + + + #### `otp` * Default: null @@ -1188,10 +1225,6 @@ The package to install for [`npm exec`](/commands/npm-exec) If set to false, then ignore `package-lock.json` files when installing. This will also prevent _writing_ `package-lock.json` if `save` is true. -When package package-locks are disabled, automatic pruning of extraneous -modules will also be disabled. To remove extraneous modules with -package-locks disabled use `npm prune`. - This configuration does not affect `npm ci`. @@ -1330,8 +1363,7 @@ The base URL of the npm registry. #### `save` -* Default: `true` unless when using `npm update` or `npm dedupe` where it - defaults to `false` +* Default: `true` unless when using `npm update` where it defaults to `false` * Type: Boolean Save installed packages to a `package.json` file as dependencies. @@ -1628,9 +1660,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 +1855,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 @@ -1890,6 +1933,25 @@ Alias for `--include=dev`. +#### `global` + +* Default: false +* Type: Boolean +* DEPRECATED: `--global`, `--local` are deprecated. Use `--location=global` + instead. + +Operates in "global" mode, so that packages are installed into the `prefix` +folder instead of the current working directory. See +[folders](/configuring-npm/folders) for more on the differences in behavior. + +* packages are installed into the `{prefix}/lib/node_modules` folder, instead + of the current working directory. +* bin files are linked to `{prefix}/bin` +* man pages are linked to `{prefix}/share/man` + + + + #### `init.author.email` * Default: "" 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/scope.md b/deps/npm/docs/content/using-npm/scope.md index 911d7ea5177c94..ca5903e78c0d95 100644 --- a/deps/npm/docs/content/using-npm/scope.md +++ b/deps/npm/docs/content/using-npm/scope.md @@ -79,9 +79,23 @@ If you wish, you may associate a scope with a registry; see below. #### Publishing public scoped packages to the primary npm registry -To publish a public scoped package, you must specify `--access public` with -the initial publication. This will publish the package and set access -to `public` as if you had run `npm access public` after publishing. +Publishing to a scope, you have two options: + +- Publishing to your user scope (example: `@username/module`) +- Publishing to an organization scope (example: `@org/module`) + +If publishing a public module to an organization scope, you must +first either create an organization with the name of the scope +that you'd like to publish to or be added to an existing organization +with the appropriate permisssions. For example, if you'd like to +publish to `@org`, you would need to create the `org` organization +on npmjs.com prior to trying to publish. + +Scoped packages are not public by default. You will need to specify +`--access public` with the initial `npm publish` command. This will publish +the package and set access to `public` as if you had run `npm access public` +after publishing. You do not need to do this when publishing new versions of +an existing scoped package. #### Publishing private scoped packages to the npm registry 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-audit.html b/deps/npm/docs/output/commands/npm-audit.html index 33c2a803c2a876..af627aff7701a1 100644 --- a/deps/npm/docs/output/commands/npm-audit.html +++ b/deps/npm/docs/output/commands/npm-audit.html @@ -142,7 +142,7 @@

npm-audit

Table of contents

- +

Synopsis

@@ -439,6 +439,17 @@

include-workspace-root

When false, specifying individual workspaces via the workspace config, or all workspaces via the workspaces flag, will cause npm to operate only on the specified workspaces, and not on the root project.

+

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

+ + + +
    +
  • Default: false
  • +
  • Type: Boolean
  • +
+

When set file: protocol dependencies that exist outside of the project root +will be packed and installed as regular dependencies instead of creating a +symlink. This option has no effect on workspaces.

diff --git a/deps/npm/docs/output/commands/npm-bin.html b/deps/npm/docs/output/commands/npm-bin.html index 5961ea7e50fb74..7b957b6014dc44 100644 --- a/deps/npm/docs/output/commands/npm-bin.html +++ b/deps/npm/docs/output/commands/npm-bin.html @@ -165,6 +165,8 @@

global

  • Default: false
  • Type: Boolean
  • +
  • DEPRECATED: --global, --local are deprecated. Use --location=global +instead.

Operates in "global" mode, so that packages are installed into the prefix folder instead of the current working directory. See diff --git a/deps/npm/docs/output/commands/npm-bugs.html b/deps/npm/docs/output/commands/npm-bugs.html index 3b5bed07593a65..28fdc0c643885a 100644 --- a/deps/npm/docs/output/commands/npm-bugs.html +++ b/deps/npm/docs/output/commands/npm-bugs.html @@ -142,14 +142,14 @@

npm-bugs

Table of contents

- +

Synopsis

-
npm bugs [<pkgname>]
+
npm bugs [<pkgname> [<pkgname> ...]]
 
 alias: issues
 
@@ -184,6 +184,57 @@

registry

The base URL of the npm registry.

+

workspace

+
    +
  • Default:
  • +
  • Type: String (can be set multiple times)
  • +
+

Enable running a command in the context of the configured workspaces of the +current project while filtering by running only the workspaces defined by +this configuration option.

+

Valid values for the workspace config are either:

+
    +
  • Workspace names
  • +
  • Path to a workspace directory
  • +
  • Path to a parent workspace directory (will result in selecting all +workspaces within that folder)
  • +
+

When set for the npm init command, this may be set to the folder of a +workspace which does not yet exist, to create the folder and set it up as a +brand new workspace within the project.

+

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

+ + +

workspaces

+
    +
  • Default: null
  • +
  • Type: null or Boolean
  • +
+

Set to true to run the command in the context of all configured +workspaces.

+

Explicitly setting this to false will cause commands like install to +ignore workspaces altogether. When not set explicitly:

+
    +
  • Commands that operate on the node_modules tree (install, update, etc.) +will link workspaces into the node_modules folder. - Commands that do +other things (test, exec, publish, etc.) will operate on the root project, +unless one or more workspaces are specified in the workspace config.
  • +
+

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

+ + +

include-workspace-root

+
    +
  • Default: false
  • +
  • Type: Boolean
  • +
+

Include the workspace root when workspaces are enabled for a command.

+

When false, specifying individual workspaces via the workspace config, or +all workspaces via the workspaces flag, will cause npm to operate only on +the specified workspaces, and not on the root project.

+

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

+ +

See Also

    diff --git a/deps/npm/docs/output/commands/npm-ci.html b/deps/npm/docs/output/commands/npm-ci.html index bbacda33a5174e..4f9a194ae57e54 100644 --- a/deps/npm/docs/output/commands/npm-ci.html +++ b/deps/npm/docs/output/commands/npm-ci.html @@ -137,7 +137,7 @@

    npm-ci

    -Install a project with a clean slate +Clean install a project
    @@ -161,12 +161,7 @@

    Description

    it's meant to be used in automated environments such as test platforms, continuous integration, and deployment -- or any situation where you want to make sure you're doing a clean install of your dependencies.

    -

    npm ci will be significantly faster when:

    -
      -
    • There is a package-lock.json or npm-shrinkwrap.json file.
    • -
    • The node_modules folder is missing or empty.
    • -
    -

    In short, the main differences between using npm install and npm ci are:

    +

    The main differences between using npm install and npm ci are:

    • The project must have an existing package-lock.json or npm-shrinkwrap.json.
    • @@ -179,6 +174,13 @@

      Description

    • It will never write to package.json or any of the package-locks: installs are essentially frozen.
    +

    NOTE: If you create your package-lock.json file by running npm install +with flags that can affect the shape of your dependency tree, such as +--legacy-peer-deps or --install-links, you must provide the same +flags to npm ci or you are likely to encounter errors. An easy way to do +this is to run, for example, +npm config set legacy-peer-deps=true --location=project and commit the +.npmrc file to your repo.

    Example

    Make sure you have a package-lock and an up-to-date install:

    $ cd ./my/npm/project
    diff --git a/deps/npm/docs/output/commands/npm-config.html b/deps/npm/docs/output/commands/npm-config.html
    index f8b279756dfe16..e267531fc0462f 100644
    --- a/deps/npm/docs/output/commands/npm-config.html
    +++ b/deps/npm/docs/output/commands/npm-config.html
    @@ -223,6 +223,8 @@ 

    global

    • Default: false
    • Type: Boolean
    • +
    • DEPRECATED: --global, --local are deprecated. Use --location=global +instead.

    Operates in "global" mode, so that packages are installed into the prefix folder instead of the current working directory. See @@ -251,6 +253,15 @@

    location

  • Type: "global", "user", or "project"

When passed to npm config this refers to which config file to use.

+

When set to "global" mode, packages are installed into the prefix folder +instead of the current working directory. See +folders for more on the differences in behavior.

+
    +
  • packages are installed into the {prefix}/lib/node_modules folder, instead +of the current working directory.
  • +
  • bin files are linked to {prefix}/bin
  • +
  • man pages are linked to {prefix}/share/man
  • +

long

diff --git a/deps/npm/docs/output/commands/npm-dedupe.html b/deps/npm/docs/output/commands/npm-dedupe.html index 8d7e42ad46ac93..89d62caf702327 100644 --- a/deps/npm/docs/output/commands/npm-dedupe.html +++ b/deps/npm/docs/output/commands/npm-dedupe.html @@ -142,7 +142,7 @@

npm-dedupe

Table of contents

- +

Synopsis

@@ -197,11 +197,9 @@

Description

Note that this operation transforms the dependency tree, but will never result in new modules being installed.

Using npm find-dupes will run the command in --dry-run mode.

-

Note that by default npm dedupe will not update the semver values of direct -dependencies in your project package.json, if you want to also update -values in package.json you can run: npm dedupe --save (or add the -save=true option to a configuration file -to make that the default behavior).

+

Note: npm dedupe will never update the semver values of direct +dependencies in your project package.json, if you want to update +values in package.json you can run: npm update --save instead.

Configuration

@@ -255,24 +253,9 @@

package-lock

If set to false, then ignore package-lock.json files when installing. This will also prevent writing package-lock.json if save is true.

-

When package package-locks are disabled, automatic pruning of extraneous -modules will also be disabled. To remove extraneous modules with -package-locks disabled use npm prune.

This configuration does not affect npm ci.

-

save

-
    -
  • Default: true unless when using npm update or npm dedupe where it -defaults to false
  • -
  • Type: Boolean
  • -
-

Save installed packages to a package.json file as dependencies.

-

When used with the npm rm command, removes the dependency from -package.json.

-

Will also prevent writing to package-lock.json if set to false.

- -

omit

  • Default: 'dev' if the NODE_ENV environment variable is set to @@ -394,6 +377,17 @@

    include-workspace-root

    When false, specifying individual workspaces via the workspace config, or all workspaces via the workspaces flag, will cause npm to operate only on the specified workspaces, and not on the root project.

    +

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

    + + + +
      +
    • Default: false
    • +
    • Type: Boolean
    • +
    +

    When set file: protocol dependencies that exist outside of the project root +will be packed and installed as regular dependencies instead of creating a +symlink. This option has no effect on workspaces.

    diff --git a/deps/npm/docs/output/commands/npm-diff.html b/deps/npm/docs/output/commands/npm-diff.html index c26aa27e8a0011..7ee9d76d227f8b 100644 --- a/deps/npm/docs/output/commands/npm-diff.html +++ b/deps/npm/docs/output/commands/npm-diff.html @@ -334,6 +334,8 @@

    global

    • Default: false
    • Type: Boolean
    • +
    • DEPRECATED: --global, --local are deprecated. Use --location=global +instead.

    Operates in "global" mode, so that packages are installed into the prefix folder instead of the current working directory. See @@ -407,6 +409,7 @@

    include-workspace-root

    When false, specifying individual workspaces via the workspace config, or all workspaces via the workspaces flag, will cause npm to operate only on the specified workspaces, and not on the root project.

    +

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

    diff --git a/deps/npm/docs/output/commands/npm-dist-tag.html b/deps/npm/docs/output/commands/npm-dist-tag.html index 8cadd42dcc4d26..8615aec686f79d 100644 --- a/deps/npm/docs/output/commands/npm-dist-tag.html +++ b/deps/npm/docs/output/commands/npm-dist-tag.html @@ -267,6 +267,7 @@

    include-workspace-root

    When false, specifying individual workspaces via the workspace config, or all workspaces via the workspaces flag, will cause npm to operate only on the specified workspaces, and not on the root project.

    +

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

    diff --git a/deps/npm/docs/output/commands/npm-docs.html b/deps/npm/docs/output/commands/npm-docs.html index c25f8abf9b7bfb..8155100d2259d9 100644 --- a/deps/npm/docs/output/commands/npm-docs.html +++ b/deps/npm/docs/output/commands/npm-docs.html @@ -233,6 +233,7 @@

    include-workspace-root

    When false, specifying individual workspaces via the workspace config, or all workspaces via the workspaces flag, will cause npm to operate only on the specified workspaces, and not on the root project.

    +

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

    diff --git a/deps/npm/docs/output/commands/npm-exec.html b/deps/npm/docs/output/commands/npm-exec.html index 4a5f14389c009e..7a5195ba4a2630 100644 --- a/deps/npm/docs/output/commands/npm-exec.html +++ b/deps/npm/docs/output/commands/npm-exec.html @@ -298,6 +298,7 @@

    include-workspace-root

    When false, specifying individual workspaces via the workspace config, or all workspaces via the workspaces flag, will cause npm to operate only on the specified workspaces, and not on the root project.

    +

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

    diff --git a/deps/npm/docs/output/commands/npm-find-dupes.html b/deps/npm/docs/output/commands/npm-find-dupes.html index c5685458d9629f..0e3ee0856096ab 100644 --- a/deps/npm/docs/output/commands/npm-find-dupes.html +++ b/deps/npm/docs/output/commands/npm-find-dupes.html @@ -142,7 +142,7 @@

    npm-find-dupes

    Table of contents

    - +

    Synopsis

    @@ -210,9 +210,6 @@

    package-lock

If set to false, then ignore package-lock.json files when installing. This will also prevent writing package-lock.json if save is true.

-

When package package-locks are disabled, automatic pruning of extraneous -modules will also be disabled. To remove extraneous modules with -package-locks disabled use npm prune.

This configuration does not affect npm ci.

@@ -324,6 +321,17 @@

include-workspace-root

When false, specifying individual workspaces via the workspace config, or all workspaces via the workspaces flag, will cause npm to operate only on the specified workspaces, and not on the root project.

+

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

+ + + +
    +
  • Default: false
  • +
  • Type: Boolean
  • +
+

When set file: protocol dependencies that exist outside of the project root +will be packed and installed as regular dependencies instead of creating a +symlink. This option has no effect on workspaces.

diff --git a/deps/npm/docs/output/commands/npm-init.html b/deps/npm/docs/output/commands/npm-init.html index c8dece27945345..e2e9b01a04ea5d 100644 --- a/deps/npm/docs/output/commands/npm-init.html +++ b/deps/npm/docs/output/commands/npm-init.html @@ -348,6 +348,7 @@

include-workspace-root

When false, specifying individual workspaces via the workspace config, or all workspaces via the workspaces flag, will cause npm to operate only on the specified workspaces, and not on the root project.

+

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

diff --git a/deps/npm/docs/output/commands/npm-install-test.html b/deps/npm/docs/output/commands/npm-install-test.html index 116cc24a81238d..fce049dc2c09e5 100644 --- a/deps/npm/docs/output/commands/npm-install-test.html +++ b/deps/npm/docs/output/commands/npm-install-test.html @@ -142,7 +142,7 @@

npm-install-test

Table of contents

- +

Synopsis

@@ -174,8 +174,7 @@

Configuration

save

    -
  • Default: true unless when using npm update or npm dedupe where it -defaults to false
  • +
  • Default: true unless when using npm update where it defaults to false
  • Type: Boolean

Save installed packages to a package.json file as dependencies.

@@ -197,6 +196,8 @@

global

  • Default: false
  • Type: Boolean
  • +
  • DEPRECATED: --global, --local are deprecated. Use --location=global +instead.

Operates in "global" mode, so that packages are installed into the prefix folder instead of the current working directory. See @@ -274,9 +275,6 @@

package-lock

If set to false, then ignore package-lock.json files when installing. This will also prevent writing package-lock.json if save is true.

-

When package package-locks are disabled, automatic pruning of extraneous -modules will also be disabled. To remove extraneous modules with -package-locks disabled use npm prune.

This configuration does not affect npm ci.

@@ -397,6 +395,17 @@

include-workspace-root

When false, specifying individual workspaces via the workspace config, or all workspaces via the workspaces flag, will cause npm to operate only on the specified workspaces, and not on the root project.

+

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

+ + + +
    +
  • Default: false
  • +
  • Type: Boolean
  • +
+

When set file: protocol dependencies that exist outside of the project root +will be packed and installed as regular dependencies instead of creating a +symlink. This option has no effect on workspaces.

diff --git a/deps/npm/docs/output/commands/npm-install.html b/deps/npm/docs/output/commands/npm-install.html index 755dee22402fdd..ca6ca1ee260f33 100644 --- a/deps/npm/docs/output/commands/npm-install.html +++ b/deps/npm/docs/output/commands/npm-install.html @@ -142,7 +142,7 @@

npm-install

Table of contents

- +

Synopsis

@@ -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
@@ -221,10 +221,10 @@

Description

npm will not install the package dependencies in the directory <folder>, but it will create a symlink to <folder>.

-

NOTE: If you want to install the content of a directory like a package from the registry instead of creating a link, you would need to use npm pack while in the <folder> directory, and then install the resulting tarball instead of the <folder> using npm install <tarball file>

+

NOTE: If you want to install the content of a directory like a package from the registry instead of creating a link, you would need to use the --install-links option.

Example:

-
npm install ../../other-package
+
npm install ../../other-package --install-links
 npm install ./sub-package
 
@@ -500,8 +500,7 @@

Configuration

save

    -
  • Default: true unless when using npm update or npm dedupe where it -defaults to false
  • +
  • Default: true unless when using npm update where it defaults to false
  • Type: Boolean

Save installed packages to a package.json file as dependencies.

@@ -523,6 +522,8 @@

global

  • Default: false
  • Type: Boolean
  • +
  • DEPRECATED: --global, --local are deprecated. Use --location=global +instead.

Operates in "global" mode, so that packages are installed into the prefix folder instead of the current working directory. See @@ -600,9 +601,6 @@

package-lock

If set to false, then ignore package-lock.json files when installing. This will also prevent writing package-lock.json if save is true.

-

When package package-locks are disabled, automatic pruning of extraneous -modules will also be disabled. To remove extraneous modules with -package-locks disabled use npm prune.

This configuration does not affect npm ci.

@@ -723,6 +721,17 @@

include-workspace-root

When false, specifying individual workspaces via the workspace config, or all workspaces via the workspaces flag, will cause npm to operate only on the specified workspaces, and not on the root project.

+

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

+ + + +
    +
  • Default: false
  • +
  • Type: Boolean
  • +
+

When set file: protocol dependencies that exist outside of the project root +will be packed and installed as regular dependencies instead of creating a +symlink. This option has no effect on workspaces.

diff --git a/deps/npm/docs/output/commands/npm-link.html b/deps/npm/docs/output/commands/npm-link.html index a659cb16c26de1..cb43c0478d7015 100644 --- a/deps/npm/docs/output/commands/npm-link.html +++ b/deps/npm/docs/output/commands/npm-link.html @@ -142,7 +142,7 @@

npm-link

Table of contents

- +

Synopsis

@@ -229,8 +229,7 @@

Configuration

save

    -
  • Default: true unless when using npm update or npm dedupe where it -defaults to false
  • +
  • Default: true unless when using npm update where it defaults to false
  • Type: Boolean

Save installed packages to a package.json file as dependencies.

@@ -252,6 +251,8 @@

global

  • Default: false
  • Type: Boolean
  • +
  • DEPRECATED: --global, --local are deprecated. Use --location=global +instead.

Operates in "global" mode, so that packages are installed into the prefix folder instead of the current working directory. See @@ -313,9 +314,6 @@

package-lock

If set to false, then ignore package-lock.json files when installing. This will also prevent writing package-lock.json if save is true.

-

When package package-locks are disabled, automatic pruning of extraneous -modules will also be disabled. To remove extraneous modules with -package-locks disabled use npm prune.

This configuration does not affect npm ci.

@@ -440,6 +438,17 @@

include-workspace-root

When false, specifying individual workspaces via the workspace config, or all workspaces via the workspaces flag, will cause npm to operate only on the specified workspaces, and not on the root project.

+

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

+ + + +
    +
  • Default: false
  • +
  • Type: Boolean
  • +
+

When set file: protocol dependencies that exist outside of the project root +will be packed and installed as regular dependencies instead of creating a +symlink. This option has no effect on workspaces.

diff --git a/deps/npm/docs/output/commands/npm-ls.html b/deps/npm/docs/output/commands/npm-ls.html index 19bf6080bf1a86..10caff53c3a090 100644 --- a/deps/npm/docs/output/commands/npm-ls.html +++ b/deps/npm/docs/output/commands/npm-ls.html @@ -142,7 +142,7 @@

npm-ls

Table of contents

- +

Synopsis

@@ -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.11.0 /path/to/npm
 └─┬ init-package-json@0.0.4
   └── promzard@0.1.5
 
@@ -246,6 +246,8 @@

global

  • Default: false
  • Type: Boolean
  • +
  • DEPRECATED: --global, --local are deprecated. Use --location=global +instead.

Operates in "global" mode, so that packages are installed into the prefix folder instead of the current working directory. See @@ -363,6 +365,17 @@

include-workspace-root

When false, specifying individual workspaces via the workspace config, or all workspaces via the workspaces flag, will cause npm to operate only on the specified workspaces, and not on the root project.

+

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

+ + + +
    +
  • Default: false
  • +
  • Type: Boolean
  • +
+

When set file: protocol dependencies that exist outside of the project root +will be packed and installed as regular dependencies instead of creating a +symlink. This option has no effect on workspaces.

diff --git a/deps/npm/docs/output/commands/npm-outdated.html b/deps/npm/docs/output/commands/npm-outdated.html index 0bdb9f9a66a14a..15030d60080819 100644 --- a/deps/npm/docs/output/commands/npm-outdated.html +++ b/deps/npm/docs/output/commands/npm-outdated.html @@ -268,6 +268,8 @@

global

  • Default: false
  • Type: Boolean
  • +
  • DEPRECATED: --global, --local are deprecated. Use --location=global +instead.

Operates in "global" mode, so that packages are installed into the prefix folder instead of the current working directory. See diff --git a/deps/npm/docs/output/commands/npm-owner.html b/deps/npm/docs/output/commands/npm-owner.html index b76967a18dad18..744f7821408fd5 100644 --- a/deps/npm/docs/output/commands/npm-owner.html +++ b/deps/npm/docs/output/commands/npm-owner.html @@ -142,7 +142,7 @@

npm-owner

Table of contents

- +

Synopsis

@@ -198,6 +198,45 @@

otp

password, npm will prompt on the command line for one.

+

workspace

+
    +
  • Default:
  • +
  • Type: String (can be set multiple times)
  • +
+

Enable running a command in the context of the configured workspaces of the +current project while filtering by running only the workspaces defined by +this configuration option.

+

Valid values for the workspace config are either:

+
    +
  • Workspace names
  • +
  • Path to a workspace directory
  • +
  • Path to a parent workspace directory (will result in selecting all +workspaces within that folder)
  • +
+

When set for the npm init command, this may be set to the folder of a +workspace which does not yet exist, to create the folder and set it up as a +brand new workspace within the project.

+

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

+ + +

workspaces

+
    +
  • Default: null
  • +
  • Type: null or Boolean
  • +
+

Set to true to run the command in the context of all configured +workspaces.

+

Explicitly setting this to false will cause commands like install to +ignore workspaces altogether. When not set explicitly:

+
    +
  • Commands that operate on the node_modules tree (install, update, etc.) +will link workspaces into the node_modules folder. - Commands that do +other things (test, exec, publish, etc.) will operate on the root project, +unless one or more workspaces are specified in the workspace config.
  • +
+

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

+ +

See Also

    diff --git a/deps/npm/docs/output/commands/npm-pack.html b/deps/npm/docs/output/commands/npm-pack.html index bdd4b01af46f04..86e45cb303ae36 100644 --- a/deps/npm/docs/output/commands/npm-pack.html +++ b/deps/npm/docs/output/commands/npm-pack.html @@ -240,6 +240,7 @@

    include-workspace-root

    When false, specifying individual workspaces via the workspace config, or all workspaces via the workspaces flag, will cause npm to operate only on the specified workspaces, and not on the root project.

    +

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

    diff --git a/deps/npm/docs/output/commands/npm-pkg.html b/deps/npm/docs/output/commands/npm-pkg.html index 221afc4e594b2b..95635ee6028383 100644 --- a/deps/npm/docs/output/commands/npm-pkg.html +++ b/deps/npm/docs/output/commands/npm-pkg.html @@ -192,6 +192,11 @@

    Description

    contributor in the list, you can run:

    npm pkg get contributors[0].email
     
    +

    For complex fields you can also name a property in square brackets +to specifically select a child field. This is especially helpful +with the exports object:

    +
    npm pkg get "exports[.].require"
    +
  • npm pkg set <field>=<value>

    diff --git a/deps/npm/docs/output/commands/npm-prefix.html b/deps/npm/docs/output/commands/npm-prefix.html index 2f302144269200..df6960ef97bbcd 100644 --- a/deps/npm/docs/output/commands/npm-prefix.html +++ b/deps/npm/docs/output/commands/npm-prefix.html @@ -176,6 +176,8 @@

    global

    • Default: false
    • Type: Boolean
    • +
    • DEPRECATED: --global, --local are deprecated. Use --location=global +instead.

    Operates in "global" mode, so that packages are installed into the prefix folder instead of the current working directory. See diff --git a/deps/npm/docs/output/commands/npm-prune.html b/deps/npm/docs/output/commands/npm-prune.html index 08df537cf8c443..0a248629bd8291 100644 --- a/deps/npm/docs/output/commands/npm-prune.html +++ b/deps/npm/docs/output/commands/npm-prune.html @@ -142,7 +142,7 @@

    npm-prune

    Table of contents

    - +

    Synopsis

    @@ -288,6 +288,17 @@

    include-workspace-root

    When false, specifying individual workspaces via the workspace config, or all workspaces via the workspaces flag, will cause npm to operate only on the specified workspaces, and not on the root project.

    +

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

    + + + +
      +
    • Default: false
    • +
    • Type: Boolean
    • +
    +

    When set file: protocol dependencies that exist outside of the project root +will be packed and installed as regular dependencies instead of creating a +symlink. This option has no effect on workspaces.

    diff --git a/deps/npm/docs/output/commands/npm-publish.html b/deps/npm/docs/output/commands/npm-publish.html index f46fd310d0cd13..23e5f11ea0e927 100644 --- a/deps/npm/docs/output/commands/npm-publish.html +++ b/deps/npm/docs/output/commands/npm-publish.html @@ -355,6 +355,7 @@

    include-workspace-root

    When false, specifying individual workspaces via the workspace config, or all workspaces via the workspaces flag, will cause npm to operate only on the specified workspaces, and not on the root project.

    +

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

    diff --git a/deps/npm/docs/output/commands/npm-rebuild.html b/deps/npm/docs/output/commands/npm-rebuild.html index 139d1591ed3efc..84837a3be5d394 100644 --- a/deps/npm/docs/output/commands/npm-rebuild.html +++ b/deps/npm/docs/output/commands/npm-rebuild.html @@ -142,7 +142,7 @@

    npm-rebuild

    Table of contents

    - +

    Synopsis

    @@ -173,6 +173,8 @@

    global

    • Default: false
    • Type: Boolean
    • +
    • DEPRECATED: --global, --local are deprecated. Use --location=global +instead.

    Operates in "global" mode, so that packages are installed into the prefix folder instead of the current working directory. See @@ -269,6 +271,17 @@

    include-workspace-root

    When false, specifying individual workspaces via the workspace config, or all workspaces via the workspaces flag, will cause npm to operate only on the specified workspaces, and not on the root project.

    +

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

    + + + +
      +
    • Default: false
    • +
    • Type: Boolean
    • +
    +

    When set file: protocol dependencies that exist outside of the project root +will be packed and installed as regular dependencies instead of creating a +symlink. This option has no effect on workspaces.

    diff --git a/deps/npm/docs/output/commands/npm-repo.html b/deps/npm/docs/output/commands/npm-repo.html index b5fedd5ac92ae6..24197ef0ea193c 100644 --- a/deps/npm/docs/output/commands/npm-repo.html +++ b/deps/npm/docs/output/commands/npm-repo.html @@ -142,7 +142,7 @@

    npm-repo

    Table of contents

    - +

    Synopsis

    @@ -174,6 +174,14 @@

    browser

    Set to true to use default system URL opener.

    +

    registry

    + +

    The base URL of the npm registry.

    + +

    workspace

    • Default:
    • @@ -222,6 +230,7 @@

      include-workspace-root

      When false, specifying individual workspaces via the workspace config, or all workspaces via the workspaces flag, will cause npm to operate only on the specified workspaces, and not on the root project.

      +

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

      diff --git a/deps/npm/docs/output/commands/npm-root.html b/deps/npm/docs/output/commands/npm-root.html index e0595fd8e76256..c9cc1d4b67843b 100644 --- a/deps/npm/docs/output/commands/npm-root.html +++ b/deps/npm/docs/output/commands/npm-root.html @@ -170,6 +170,8 @@

      global

      • Default: false
      • Type: Boolean
      • +
      • DEPRECATED: --global, --local are deprecated. Use --location=global +instead.

      Operates in "global" mode, so that packages are installed into the prefix folder instead of the current working directory. See diff --git a/deps/npm/docs/output/commands/npm-run-script.html b/deps/npm/docs/output/commands/npm-run-script.html index 07fc79127d0b6f..6211c2b55efcfc 100644 --- a/deps/npm/docs/output/commands/npm-run-script.html +++ b/deps/npm/docs/output/commands/npm-run-script.html @@ -290,6 +290,7 @@

      include-workspace-root

      When false, specifying individual workspaces via the workspace config, or all workspaces via the workspaces flag, will cause npm to operate only on the specified workspaces, and not on the root project.

      +

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

      if-present

      @@ -303,6 +304,7 @@

      if-present

      it's present and fail if the script fails. This is useful, for example, when running scripts that may only apply for some builds in an otherwise generic CI setup.

      +

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

      ignore-scripts

      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-set-script.html b/deps/npm/docs/output/commands/npm-set-script.html index cb66491d07c406..d9bc6b60771e9d 100644 --- a/deps/npm/docs/output/commands/npm-set-script.html +++ b/deps/npm/docs/output/commands/npm-set-script.html @@ -147,6 +147,7 @@

      Table of contents

      Synopsis

      An npm command that lets you create a task in the scripts section of the package.json.

      +

      Deprecated.

      @@ -219,6 +220,7 @@

      include-workspace-root

      When false, specifying individual workspaces via the workspace config, or all workspaces via the workspaces flag, will cause npm to operate only on the specified workspaces, and not on the root project.

      +

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

      diff --git a/deps/npm/docs/output/commands/npm-star.html b/deps/npm/docs/output/commands/npm-star.html index 42143bed974a3c..bc1f7ae76992dd 100644 --- a/deps/npm/docs/output/commands/npm-star.html +++ b/deps/npm/docs/output/commands/npm-star.html @@ -142,7 +142,7 @@

      npm-star

      Table of contents

      - +

      Synopsis

      @@ -188,6 +188,17 @@

      unicode

      false, it uses ascii characters instead of unicode glyphs.

      +

      otp

      +
        +
      • Default: null
      • +
      • Type: null or String
      • +
      +

      This is a one-time password from a two-factor authenticator. It's needed +when publishing or changing package permissions with npm access.

      +

      If not set, and a registry response fails with a challenge for a one-time +password, npm will prompt on the command line for one.

      + +

      See Also

      If set to false, then ignore package-lock.json files when installing. This will also prevent writing package-lock.json if save is true.

      -

      When package package-locks are disabled, automatic pruning of extraneous -modules will also be disabled. To remove extraneous modules with -package-locks disabled use npm prune.

      This configuration does not affect npm ci.

      @@ -476,6 +474,17 @@

      include-workspace-root

      When false, specifying individual workspaces via the workspace config, or all workspaces via the workspaces flag, will cause npm to operate only on the specified workspaces, and not on the root project.

      +

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

      + + + +
        +
      • Default: false
      • +
      • Type: Boolean
      • +
      +

      When set file: protocol dependencies that exist outside of the project root +will be packed and installed as regular dependencies instead of creating a +symlink. This option has no effect on workspaces.

      diff --git a/deps/npm/docs/output/commands/npm-version.html b/deps/npm/docs/output/commands/npm-version.html index a4e8ff6dbdc0b4..3bab12fec165a7 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

      -

      A basic-auth string to use when authenticating against the npm registry.

      +

      A basic-auth string to use when authenticating against the npm registry. +This will ONLY be used to authenticate against the npm registry. For other +registries you will need to scope it like "//other-registry.tld/:_auth"

      Warning: This should generally not be set via a command-line option. It is safer to use a registry-provided authentication bearer token stored in the ~/.npmrc file by running npm login.

      @@ -693,22 +696,6 @@

      git-tag-version

      results in no commit being made at all.

      -

      global

      -
        -
      • Default: false
      • -
      • Type: Boolean
      • -
      -

      Operates in "global" mode, so that packages are installed into the prefix -folder instead of the current working directory. See -folders for more on the differences in behavior.

      -
        -
      • packages are installed into the {prefix}/lib/node_modules folder, instead -of the current working directory.
      • -
      • bin files are linked to {prefix}/bin
      • -
      • man pages are linked to {prefix}/share/man
      • -
      - -

      global-style

      • Default: false
      • @@ -761,6 +748,7 @@

        if-present

        it's present and fail if the script fails. This is useful, for example, when running scripts that may only apply for some builds in an otherwise generic CI setup.

        +

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

        ignore-scripts

        @@ -805,6 +793,7 @@

        include-workspace-root

        When false, specifying individual workspaces via the workspace config, or all workspaces via the workspaces flag, will cause npm to operate only on the specified workspaces, and not on the root project.

        +

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

        init-author-email

        @@ -860,6 +849,16 @@

        init-version

        number, if not already set in package.json.

        + +
          +
        • Default: false
        • +
        • Type: Boolean
        • +
        +

        When set file: protocol dependencies that exist outside of the project root +will be packed and installed as regular dependencies instead of creating a +symlink. This option has no effect on workspaces.

        + +

        json

        • Default: false
        • @@ -936,6 +935,15 @@

          location

        • Type: "global", "user", or "project"

        When passed to npm config this refers to which config file to use.

        +

        When set to "global" mode, packages are installed into the prefix folder +instead of the current working directory. See +folders for more on the differences in behavior.

        +
          +
        • packages are installed into the {prefix}/lib/node_modules folder, instead +of the current working directory.
        • +
        • bin files are linked to {prefix}/bin
        • +
        • man pages are linked to {prefix}/share/man
        • +

        lockfile-version

        @@ -971,12 +979,22 @@

        loglevel

        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 +for more information.

        + +

        logs-max

        • Default: 10
        • Type: Number

        The maximum number of log files to store.

        +

        If set to 0, no log files will be written for the current run.

        long

        @@ -1065,6 +1083,17 @@

        omit

        variable will be set to 'production' for all lifecycle scripts.

        +

        omit-lockfile-registry-resolved

        +
          +
        • Default: false
        • +
        • Type: Boolean
        • +
        +

        This option causes npm to create lock files without a resolved key for +registry dependencies. Subsequent installs will need to resolve tarball +endpoints with the configured registry, likely resulting in a longer install +time.

        + +

        otp

        • Default: null
        • @@ -1099,9 +1128,6 @@

          package-lock

        If set to false, then ignore package-lock.json files when installing. This will also prevent writing package-lock.json if save is true.

        -

        When package package-locks are disabled, automatic pruning of extraneous -modules will also be disabled. To remove extraneous modules with -package-locks disabled use npm prune.

        This configuration does not affect npm ci.

        @@ -1213,8 +1239,7 @@

        registry

        save

          -
        • Default: true unless when using npm update or npm dedupe where it -defaults to false
        • +
        • Default: true unless when using npm update where it defaults to false
        • Type: Boolean

        Save installed packages to a package.json file as dependencies.

        @@ -1446,9 +1471,9 @@

        timing

      • 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 command line: npm exec -- json -g < ~/.npm/_timing.json.

      @@ -1605,6 +1630,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
      • @@ -1660,6 +1694,24 @@

        dev

        Alias for --include=dev.

        +

        global

        +
          +
        • Default: false
        • +
        • Type: Boolean
        • +
        • DEPRECATED: --global, --local are deprecated. Use --location=global +instead.
        • +
        +

        Operates in "global" mode, so that packages are installed into the prefix +folder instead of the current working directory. See +folders for more on the differences in behavior.

        +
          +
        • packages are installed into the {prefix}/lib/node_modules folder, instead +of the current working directory.
        • +
        • bin files are linked to {prefix}/bin
        • +
        • man pages are linked to {prefix}/share/man
        • +
        + +

        init.author.email

        • Default: ""
        • 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/scope.html b/deps/npm/docs/output/using-npm/scope.html index db6fc2a115f496..61ab698b5fbc95 100644 --- a/deps/npm/docs/output/using-npm/scope.html +++ b/deps/npm/docs/output/using-npm/scope.html @@ -194,9 +194,22 @@

          Publishing scoped packages

          does support scoped packages.)

          If you wish, you may associate a scope with a registry; see below.

          Publishing public scoped packages to the primary npm registry

          -

          To publish a public scoped package, you must specify --access public with -the initial publication. This will publish the package and set access -to public as if you had run npm access public after publishing.

          +

          Publishing to a scope, you have two options:

          +
            +
          • Publishing to your user scope (example: @username/module)
          • +
          • Publishing to an organization scope (example: @org/module)
          • +
          +

          If publishing a public module to an organization scope, you must +first either create an organization with the name of the scope +that you'd like to publish to or be added to an existing organization +with the appropriate permisssions. For example, if you'd like to +publish to @org, you would need to create the org organization +on npmjs.com prior to trying to publish.

          +

          Scoped packages are not public by default. You will need to specify +--access public with the initial npm publish command. This will publish +the package and set access to public as if you had run npm access public +after publishing. You do not need to do this when publishing new versions of +an existing scoped package.

          Publishing private scoped packages to the npm registry

          To publish a private scoped package to the npm registry, you must have an npm Private Modules 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/arborist-cmd.js b/deps/npm/lib/arborist-cmd.js index 6518e91e0ad9d7..5007fbd9244d24 100644 --- a/deps/npm/lib/arborist-cmd.js +++ b/deps/npm/lib/arborist-cmd.js @@ -12,6 +12,7 @@ class ArboristCmd extends BaseCommand { 'workspace', 'workspaces', 'include-workspace-root', + 'install-links', ] static ignoreImplicitWorkspace = false diff --git a/deps/npm/lib/auth/sso.js b/deps/npm/lib/auth/sso.js index 795eb8972a2236..9812a18cb99ca6 100644 --- a/deps/npm/lib/auth/sso.js +++ b/deps/npm/lib/auth/sso.js @@ -36,8 +36,6 @@ function sleep (time) { } const login = async (npm, { creds, registry, scope }) => { - log.warn('deprecated', 'SSO --auth-type is deprecated') - const opts = { ...npm.flatOptions, creds, registry, scope } const { ssoType } = opts 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..9ba3cb4003241b 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.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..cdd6db62869059 100644 --- a/deps/npm/lib/commands/birthday.js +++ b/deps/npm/lib/commands/birthday.js @@ -1,11 +1,15 @@ const BaseCommand = require('../base-command.js') +const log = require('../utils/log-shim') class Birthday extends BaseCommand { static name = 'birthday' + static description = 'Birthday, deprecated' static ignoreImplicitWorkspace = true + static isShellout = true async exec () { this.npm.config.set('yes', true) + log.warn('birthday', 'birthday is deprecated and will be removed in a future release') return this.npm.exec('exec', ['@npmcli/npm-birthday']) } } diff --git a/deps/npm/lib/commands/bugs.js b/deps/npm/lib/commands/bugs.js index f6218f033f3d3d..17cbd96649b871 100644 --- a/deps/npm/lib/commands/bugs.js +++ b/deps/npm/lib/commands/bugs.js @@ -1,33 +1,10 @@ -const pacote = require('pacote') -const log = require('../utils/log-shim') -const openUrl = require('../utils/open-url.js') -const hostedFromMani = require('../utils/hosted-git-info-from-manifest.js') -const BaseCommand = require('../base-command.js') +const PackageUrlCmd = require('../package-url-cmd.js') -class Bugs extends BaseCommand { +class Bugs extends PackageUrlCmd { static description = 'Report bugs for a package in a web browser' static name = 'bugs' - static usage = ['[]'] - static params = ['browser', 'registry'] - static ignoreImplicitWorkspace = true - async exec (args) { - if (!args || !args.length) { - args = ['.'] - } - - await Promise.all(args.map(pkg => this.getBugs(pkg))) - } - - async getBugs (pkg) { - const opts = { ...this.npm.flatOptions, fullMetadata: true } - const mani = await pacote.manifest(pkg, opts) - const url = this.getBugsUrl(mani) - log.silly('bugs', 'url', url) - await openUrl(this.npm, url, `${mani.name} bug list available at the following URL`) - } - - getBugsUrl (mani) { + getUrl (spec, mani) { if (mani.bugs) { if (typeof mani.bugs === 'string') { return mani.bugs @@ -43,7 +20,7 @@ class Bugs extends BaseCommand { } // try to get it from the repo, if possible - const info = hostedFromMani(mani) + const info = this.hostedFromMani(mani) if (info) { return info.bugs() } diff --git a/deps/npm/lib/commands/cache.js b/deps/npm/lib/commands/cache.js index b8f84abc1d9412..862f346adb4369 100644 --- a/deps/npm/lib/commands/cache.js +++ b/deps/npm/lib/commands/cache.js @@ -10,11 +10,7 @@ const jsonParse = require('json-parse-even-better-errors') const localeCompare = require('@isaacs/string-locale-compare')('en') const log = require('../utils/log-shim') -const searchCachePackage = async (path, spec, cacheKeys) => { - const parsed = npa(spec) - if (parsed.rawSpec !== '' && parsed.type === 'tag') { - throw new Error(`Cannot list cache keys for a tagged package.`) - } +const searchCachePackage = async (path, parsed, cacheKeys) => { /* eslint-disable-next-line max-len */ const searchMFH = new RegExp(`^make-fetch-happen:request-cache:.*(? { if (!packument.versions || typeof packument.versions !== 'object') { continue } + // assuming this is a packument for (const ver of Object.keys(packument.versions)) { if (semver.satisfies(ver, parsed.rawSpec)) { @@ -148,6 +145,7 @@ class Cache extends BaseCommand { } this.npm.output(`Deleted: ${key}`) await cacache.rm.entry(cachePath, key) + // XXX this could leave other entries without content! await cacache.rm.content(cachePath, entry.integrity) } } @@ -177,7 +175,7 @@ class Cache extends BaseCommand { async verify () { const cache = path.join(this.npm.cache, '_cacache') const prefix = cache.indexOf(process.env.HOME) === 0 - ? `~${cache.substr(process.env.HOME.length)}` + ? `~${cache.slice(process.env.HOME.length)}` : cache const stats = await cacache.verify(cache) this.npm.output(`Cache verified and compressed (${prefix})`) @@ -204,7 +202,11 @@ class Cache extends BaseCommand { // get results for each package spec specified const results = new Set() for (const spec of specs) { - const keySet = await searchCachePackage(cachePath, spec, cacheKeys) + const parsed = npa(spec) + if (parsed.rawSpec !== '' && parsed.type === 'tag') { + throw this.usageError('Cannot list cache keys for a tagged package.') + } + const keySet = await searchCachePackage(cachePath, parsed, cacheKeys) for (const key of keySet) { results.add(key) } diff --git a/deps/npm/lib/commands/ci.js b/deps/npm/lib/commands/ci.js index eb1e02bcdc7241..2a6125d564e912 100644 --- a/deps/npm/lib/commands/ci.js +++ b/deps/npm/lib/commands/ci.js @@ -8,19 +8,10 @@ const readdir = util.promisify(fs.readdir) const log = require('../utils/log-shim.js') const validateLockfile = require('../utils/validate-lockfile.js') -const removeNodeModules = async where => { - const rimrafOpts = { glob: false } - process.emit('time', 'npm-ci:rm') - const path = `${where}/node_modules` - // get the list of entries so we can skip the glob for performance - const entries = await readdir(path, null).catch(er => []) - await Promise.all(entries.map(f => rimraf(`${path}/${f}`, rimrafOpts))) - process.emit('timeEnd', 'npm-ci:rm') -} const ArboristWorkspaceCmd = require('../arborist-cmd.js') class CI extends ArboristWorkspaceCmd { - static description = 'Install a project with a clean slate' + static description = 'Clean install a project' static name = 'ci' static params = [ 'audit', @@ -30,10 +21,10 @@ class CI extends ArboristWorkspaceCmd { ] async exec () { - if (this.npm.config.get('global')) { - const err = new Error('`npm ci` does not work for global packages') - err.code = 'ECIGLOBAL' - throw err + if (this.npm.global) { + throw Object.assign(new Error('`npm ci` does not work for global packages'), { + code: 'ECIGLOBAL', + }) } const where = this.npm.prefix @@ -46,17 +37,14 @@ class CI extends ArboristWorkspaceCmd { } const arb = new Arborist(opts) - await Promise.all([ - arb.loadVirtual().catch(er => { - log.verbose('loadVirtual', er.stack) - const msg = - 'The `npm ci` command can only install with an existing package-lock.json or\n' + - 'npm-shrinkwrap.json with lockfileVersion >= 1. Run an install with npm@5 or\n' + - 'later to generate a package-lock.json file, then try again.' - throw new Error(msg) - }), - removeNodeModules(where), - ]) + await arb.loadVirtual().catch(er => { + log.verbose('loadVirtual', er.stack) + const msg = + 'The `npm ci` command can only install with an existing package-lock.json or\n' + + 'npm-shrinkwrap.json with lockfileVersion >= 1. Run an install with npm@5 or\n' + + 'later to generate a package-lock.json file, then try again.' + throw this.usageError(msg) + }) // retrieves inventory of packages from loaded virtual tree (lock file) const virtualInventory = new Map(arb.virtualTree.inventory) @@ -70,15 +58,24 @@ class CI extends ArboristWorkspaceCmd { // throws a validation error in case of mismatches const errors = validateLockfile(virtualInventory, arb.idealTree.inventory) if (errors.length) { - throw new Error( + throw this.usageError( '`npm ci` can only install packages when your package.json and ' + 'package-lock.json or npm-shrinkwrap.json are in sync. Please ' + 'update your lock file with `npm install` ' + 'before continuing.\n\n' + - errors.join('\n') + '\n' + errors.join('\n') ) } + // Only remove node_modules after we've successfully loaded the virtual + // tree and validated the lockfile + await this.npm.time('npm-ci:rm', async () => { + const path = `${where}/node_modules` + // get the list of entries so we can skip the glob for performance + const entries = await readdir(path, null).catch(er => []) + return Promise.all(entries.map(f => rimraf(`${path}/${f}`, { glob: false }))) + }) + await arb.reify(opts) const ignoreScripts = this.npm.config.get('ignore-scripts') diff --git a/deps/npm/lib/commands/completion.js b/deps/npm/lib/commands/completion.js index 0317753a15aaff..c24fb050dcb34d 100644 --- a/deps/npm/lib/commands/completion.js +++ b/deps/npm/lib/commands/completion.js @@ -29,19 +29,26 @@ // as an array. // +const fs = require('@npmcli/fs') +const nopt = require('nopt') + 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)) -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 fileExists = require('../utils/file-exists.js') +const { isWindowsShell } = require('../utils/is-windows.js') +const fileExists = async (file) => { + try { + const stat = await fs.stat(file) + return stat.isFile() + } catch { + return false + } +} -const { promisify } = require('util') const BaseCommand = require('../base-command.js') class Completion extends BaseCommand { @@ -98,17 +105,17 @@ class Completion extends BaseCommand { const word = words[w] const line = COMP_LINE const point = +COMP_POINT - const partialLine = line.substr(0, point) + const partialLine = line.slice(0, point) const partialWords = words.slice(0, w) // figure out where in that last word the point is. const partialWordRaw = args[w] let i = partialWordRaw.length - while (partialWordRaw.substr(0, i) !== partialLine.substr(-1 * i) && i > 0) { + while (partialWordRaw.slice(0, i) !== partialLine.slice(-1 * i) && i > 0) { i-- } - const partialWord = unescape(partialWordRaw.substr(0, i)) + const partialWord = unescape(partialWordRaw.slice(0, i)) partialWords.push(partialWord) const opts = { @@ -152,7 +159,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])) @@ -190,12 +197,10 @@ class Completion extends BaseCommand { } const dumpScript = async () => { - const fs = require('fs') - const readFile = promisify(fs.readFile) const { resolve } = require('path') const p = resolve(__dirname, '..', 'utils', 'completion.sh') - const d = (await readFile(p, 'utf8')).replace(/^#!.*?\n/, '') + const d = (await fs.readFile(p, 'utf8')).replace(/^#!.*?\n/, '') await new Promise((res, rej) => { let done = false process.stdout.on('error', er => { @@ -269,13 +274,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/config.js b/deps/npm/lib/commands/config.js index 690a69a3233e4f..96dd4abcaf4af8 100644 --- a/deps/npm/lib/commands/config.js +++ b/deps/npm/lib/commands/config.js @@ -266,6 +266,9 @@ ${defData} if (!long) { msg.push( `; node bin location = ${process.execPath}`, + `; node version = ${process.version}`, + `; npm local prefix = ${this.npm.localPrefix}`, + `; npm version = ${this.npm.version}`, `; cwd = ${process.cwd()}`, `; HOME = ${process.env.HOME}`, '; Run `npm config ls -l` to show all defaults.' @@ -273,7 +276,7 @@ ${defData} msg.push('') } - if (!this.npm.config.get('global')) { + if (!this.npm.global) { const pkgPath = resolve(this.npm.prefix, 'package.json') const pkg = await rpj(pkgPath).catch(() => ({})) diff --git a/deps/npm/lib/commands/dedupe.js b/deps/npm/lib/commands/dedupe.js index 4662ce3241b246..2cc44b2a9fb2fd 100644 --- a/deps/npm/lib/commands/dedupe.js +++ b/deps/npm/lib/commands/dedupe.js @@ -12,7 +12,6 @@ class Dedupe extends ArboristWorkspaceCmd { 'legacy-bundling', 'strict-peer-deps', 'package-lock', - 'save', 'omit', 'ignore-scripts', 'audit', @@ -23,25 +22,23 @@ class Dedupe extends ArboristWorkspaceCmd { ] async exec (args) { - if (this.npm.config.get('global')) { + if (this.npm.global) { const er = new Error('`npm dedupe` does not work in global mode.') er.code = 'EDEDUPEGLOBAL' throw er } - // In the context of `npm dedupe` the save - // config value should default to `false` - const save = this.npm.config.isDefault('save') - ? false - : this.npm.config.get('save') - const dryRun = this.npm.config.get('dry-run') const where = this.npm.prefix const opts = { ...this.npm.flatOptions, path: where, dryRun, - save, + // Saving during dedupe would only update if one of your direct + // dependencies was also duplicated somewhere in your tree. It would be + // confusing if running this were to also update your package.json. In + // order to reduce potential confusion we set this to false. + save: false, workspaces: this.workspaceNames, } const arb = new Arborist(opts) diff --git a/deps/npm/lib/commands/deprecate.js b/deps/npm/lib/commands/deprecate.js index 88eb320c32a523..0ae88f1921f566 100644 --- a/deps/npm/lib/commands/deprecate.js +++ b/deps/npm/lib/commands/deprecate.js @@ -26,7 +26,7 @@ class Deprecate extends BaseCommand { const packages = await libaccess.lsPackages(username, this.npm.flatOptions) return Object.keys(packages) .filter((name) => - packages[name] === 'write' && + packages[name] === 'read-write' && (opts.conf.argv.remain.length === 0 || name.startsWith(opts.conf.argv.remain[0]))) } diff --git a/deps/npm/lib/commands/diff.js b/deps/npm/lib/commands/diff.js index ff942cc44e9460..b8a64bd98a0394 100644 --- a/deps/npm/lib/commands/diff.js +++ b/deps/npm/lib/commands/diff.js @@ -6,7 +6,7 @@ const Arborist = require('@npmcli/arborist') const pacote = require('pacote') const pickManifest = require('npm-pick-manifest') const log = require('../utils/log-shim') -const readPackageName = require('../utils/read-package-name.js') +const readPackage = require('read-package-json-fast') const BaseCommand = require('../base-command.js') class Diff extends BaseCommand { @@ -50,7 +50,7 @@ class Diff extends BaseCommand { // node_modules is sometimes under ./lib, and in global mode we're only ever // walking through node_modules (because we will have been given a package // name already) - if (this.npm.config.get('global')) { + if (this.npm.global) { this.top = resolve(this.npm.globalDir, '..') } else { this.top = this.prefix @@ -81,7 +81,8 @@ class Diff extends BaseCommand { async packageName (path) { let name try { - name = await readPackageName(this.prefix) + const pkg = await readPackage(resolve(this.prefix, 'package.json')) + name = pkg.name } catch (e) { log.verbose('diff', 'could not read project dir package.json') } @@ -114,7 +115,8 @@ class Diff extends BaseCommand { let noPackageJson let pkgName try { - pkgName = await readPackageName(this.prefix) + const pkg = await readPackage(resolve(this.prefix, 'package.json')) + pkgName = pkg.name } catch (e) { log.verbose('diff', 'could not read project dir package.json') noPackageJson = true @@ -225,7 +227,8 @@ class Diff extends BaseCommand { if (semverA && semverB) { let pkgName try { - pkgName = await readPackageName(this.prefix) + const pkg = await readPackage(resolve(this.prefix, 'package.json')) + pkgName = pkg.name } catch (e) { log.verbose('diff', 'could not read project dir package.json') } diff --git a/deps/npm/lib/commands/dist-tag.js b/deps/npm/lib/commands/dist-tag.js index 3b82c5194cca82..a207e422cb53c1 100644 --- a/deps/npm/lib/commands/dist-tag.js +++ b/deps/npm/lib/commands/dist-tag.js @@ -1,9 +1,10 @@ const npa = require('npm-package-arg') +const path = require('path') const regFetch = require('npm-registry-fetch') const semver = require('semver') const log = require('../utils/log-shim') const otplease = require('../utils/otplease.js') -const readPackageName = require('../utils/read-package-name.js') +const readPackage = require('read-package-json-fast') const BaseCommand = require('../base-command.js') class DistTag extends BaseCommand { @@ -147,15 +148,15 @@ class DistTag extends BaseCommand { async list (spec, opts) { if (!spec) { - if (this.npm.config.get('global')) { + if (this.npm.global) { throw this.usageError() } - const pkg = await readPackageName(this.npm.prefix) - if (!pkg) { + const { name } = await readPackage(path.resolve(this.npm.prefix, 'package.json')) + if (!name) { throw this.usageError() } - return this.list(pkg, opts) + return this.list(name, opts) } spec = npa(spec) diff --git a/deps/npm/lib/commands/docs.js b/deps/npm/lib/commands/docs.js index 631615acc56b3d..5d20215b56a07f 100644 --- a/deps/npm/lib/commands/docs.js +++ b/deps/npm/lib/commands/docs.js @@ -1,54 +1,19 @@ -const pacote = require('pacote') -const openUrl = require('../utils/open-url.js') -const hostedFromMani = require('../utils/hosted-git-info-from-manifest.js') -const log = require('../utils/log-shim') -const BaseCommand = require('../base-command.js') -class Docs extends BaseCommand { +const PackageUrlCmd = require('../package-url-cmd.js') +class Docs extends PackageUrlCmd { static description = 'Open documentation for a package in a web browser' static name = 'docs' - static params = [ - 'browser', - 'registry', - 'workspace', - 'workspaces', - 'include-workspace-root', - ] - static usage = ['[ [ ...]]'] - static ignoreImplicitWorkspace = false - - async exec (args) { - if (!args || !args.length) { - args = ['.'] - } - - await Promise.all(args.map(pkg => this.getDocs(pkg))) - } - - async execWorkspaces (args, filters) { - await this.setWorkspaces(filters) - return this.exec(this.workspacePaths) - } - - async getDocs (pkg) { - const opts = { ...this.npm.flatOptions, fullMetadata: true } - const mani = await pacote.manifest(pkg, opts) - const url = this.getDocsUrl(mani) - log.silly('docs', 'url', url) - await openUrl(this.npm, url, `${mani.name} docs available at the following URL`) - } - - getDocsUrl (mani) { + getUrl (spec, mani) { if (mani.homepage) { return mani.homepage } - const info = hostedFromMani(mani) + const info = this.hostedFromMani(mani) if (info) { return info.docs() } - return 'https://www.npmjs.com/package/' + mani.name + return `https://www.npmjs.com/package/${mani.name}` } } module.exports = Docs diff --git a/deps/npm/lib/commands/doctor.js b/deps/npm/lib/commands/doctor.js index 630150c0886fed..f5bee1eb83f6cb 100644 --- a/deps/npm/lib/commands/doctor.js +++ b/deps/npm/lib/commands/doctor.js @@ -1,5 +1,4 @@ const cacache = require('cacache') -const chalk = require('chalk') const fs = require('fs') const fetch = require('make-fetch-happen') const table = require('text-table') @@ -102,28 +101,19 @@ class Doctor extends BaseCommand { messages.push(line) } - const outHead = ['Check', 'Value', 'Recommendation/Notes'].map( - !this.npm.color ? h => h : h => chalk.underline(h) - ) + const outHead = ['Check', 'Value', 'Recommendation/Notes'].map(h => this.npm.chalk.underline(h)) let allOk = true - const outBody = messages.map( - !this.npm.color - ? item => { - allOk = allOk && item[1] - item[1] = item[1] ? 'ok' : 'not ok' - item[2] = String(item[2]) - return item - } - : item => { - allOk = allOk && item[1] - if (!item[1]) { - item[0] = chalk.red(item[0]) - item[2] = chalk.magenta(String(item[2])) - } - item[1] = item[1] ? chalk.green('ok') : chalk.red('not ok') - return item - } - ) + const outBody = messages.map(item => { + if (!item[1]) { + allOk = false + item[0] = this.npm.chalk.red(item[0]) + item[1] = this.npm.chalk.red('not ok') + item[2] = this.npm.chalk.magenta(String(item[2])) + } else { + item[1] = this.npm.chalk.green('ok') + } + return item + }) const outTable = [outHead, ...outBody] const tableOpts = { stringLength: s => ansiTrim(s).length, @@ -131,10 +121,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.') @@ -149,7 +135,7 @@ class Doctor extends BaseCommand { return '' } catch (er) { if (/^E\d{3}$/.test(er.code || '')) { - throw er.code.substr(1) + ' ' + er.message + throw er.code.slice(1) + ' ' + er.message } else { throw er.message } @@ -215,7 +201,7 @@ class Doctor extends BaseCommand { const gid = process.getgid() const files = new Set([root]) for (const f of files) { - tracker.silly('checkFilesPermission', f.substr(root.length + 1)) + tracker.silly('checkFilesPermission', f.slice(root.length + 1)) const st = await lstat(f).catch(er => { // if it can't be missing, or if it can and the error wasn't that it was missing if (!missingOk || er.code !== 'ENOENT') { 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..d9a686cc9a3be7 100644 --- a/deps/npm/lib/commands/exec.js +++ b/deps/npm/lib/commands/exec.js @@ -46,11 +46,10 @@ class Exec extends BaseCommand { ] static ignoreImplicitWorkspace = false + static isShellout = true - async exec (_args, { locationMsg, path, runPath } = {}) { - if (!path) { - path = this.npm.localPrefix - } + async exec (_args, { locationMsg, runPath } = {}) { + const path = this.npm.localPrefix if (!runPath) { runPath = process.cwd() @@ -74,6 +73,9 @@ class Exec extends BaseCommand { return libexec({ ...flatOptions, + // we explicitly set packageLockOnly to false because if it's true + // when we try to install a missing package, we won't actually install it + packageLockOnly: false, args, call, localBin, @@ -94,7 +96,7 @@ class Exec extends BaseCommand { for (const path of this.workspacePaths) { const locationMsg = await getLocationMsg({ color, path }) - await this.exec(args, { locationMsg, path, runPath: path }) + await this.exec(args, { locationMsg, runPath: path }) } } } diff --git a/deps/npm/lib/commands/fund.js b/deps/npm/lib/commands/fund.js index 787a5193f01558..09ca81653b0eb3 100644 --- a/deps/npm/lib/commands/fund.js +++ b/deps/npm/lib/commands/fund.js @@ -45,7 +45,7 @@ class Fund extends ArboristWorkspaceCmd { throw err } - if (this.npm.config.get('global')) { + if (this.npm.global) { const err = new Error('`npm fund` does not support global packages') err.code = 'EFUNDGLOBAL' throw err diff --git a/deps/npm/lib/commands/help-search.js b/deps/npm/lib/commands/help-search.js index 9422b83561cc89..488189bbbc5cd8 100644 --- a/deps/npm/lib/commands/help-search.js +++ b/deps/npm/lib/commands/help-search.js @@ -1,11 +1,13 @@ const fs = require('fs') const path = require('path') -const color = require('ansicolors') +const chalk = require('chalk') const { promisify } = require('util') const glob = promisify(require('glob')) const readFile = promisify(fs.readFile) const BaseCommand = require('../base-command.js') +const globify = pattern => pattern.split('\\').join('/') + class HelpSearch extends BaseCommand { static description = 'Search npm help documentation' static name = 'help-search' @@ -19,7 +21,7 @@ class HelpSearch extends BaseCommand { } const docPath = path.resolve(__dirname, '..', '..', 'docs/content') - const files = await glob(`${docPath}/*/*.md`) + const files = await glob(`${globify(docPath)}/*/*.md`) const data = await this.readFiles(files) const results = await this.searchFiles(args, data, files) const formatted = this.formatResults(args, results) @@ -171,9 +173,9 @@ class HelpSearch extends BaseCommand { const finder = line.toLowerCase().split(arg.toLowerCase()) let p = 0 for (const f of finder) { - hilitLine.push(line.substr(p, f.length)) - const word = line.substr(p + f.length, arg.length) - const hilit = color.bgBlack(color.red(word)) + hilitLine.push(line.slice(p, p + f.length)) + const word = line.slice(p + f.length, p + f.length + arg.length) + const hilit = chalk.bgBlack.red(word) hilitLine.push(hilit) p += f.length + arg.length } diff --git a/deps/npm/lib/commands/help.js b/deps/npm/lib/commands/help.js index 40f5ad9b300926..e7d6395a1b01a6 100644 --- a/deps/npm/lib/commands/help.js +++ b/deps/npm/lib/commands/help.js @@ -5,12 +5,15 @@ const { promisify } = require('util') const glob = promisify(require('glob')) const localeCompare = require('@isaacs/string-locale-compare')('en') +const globify = pattern => pattern.split('\\').join('/') const BaseCommand = require('../base-command.js') // Strips out the number from foo.7 or foo.7. or foo.7.tgz // 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' @@ -24,7 +27,7 @@ class Help extends BaseCommand { return [] } const g = path.resolve(__dirname, '../../man/man[0-9]/*.[0-9]') - const files = await glob(g) + const files = await glob(globify(g)) return Object.keys(files.reduce(function (acc, file) { file = path.basename(file).replace(/\.[0-9]+$/, '') @@ -59,15 +62,29 @@ class Help extends BaseCommand { const manroot = path.resolve(__dirname, '..', '..', 'man') // find either section.n or npm-section.n const f = `${manroot}/${manSearch}/?(npm-)${section}.[0-9]*` - let mans = await glob(f) + let mans = await glob(globify(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/install.js b/deps/npm/lib/commands/install.js index ebba02a1bd47d0..4cda36448317fe 100644 --- a/deps/npm/lib/commands/install.js +++ b/deps/npm/lib/commands/install.js @@ -106,10 +106,9 @@ class Install extends ArboristWorkspaceCmd { // the /path/to/node_modules/.. const globalTop = resolve(this.npm.globalDir, '..') const ignoreScripts = this.npm.config.get('ignore-scripts') - const isGlobalInstall = this.npm.config.get('global') + const isGlobalInstall = this.npm.global const where = isGlobalInstall ? globalTop : this.npm.prefix const forced = this.npm.config.get('force') - const isDev = this.npm.config.get('dev') const scriptShell = this.npm.config.get('script-shell') || undefined // be very strict about engines when trying to update npm itself @@ -140,12 +139,10 @@ class Install extends ArboristWorkspaceCmd { args = ['.'] } - // TODO: Add warnings for other deprecated flags? or remove this one? - if (isDev) { - log.warn( - 'install', - 'Usage of the `--dev` option is deprecated. Use `--include=dev` instead.' - ) + // throw usage error if trying to install empty package + // name to global space, e.g: `npm i -g ""` + if (where === globalTop && !args.every(Boolean)) { + throw this.usageError() } const opts = { @@ -163,7 +160,7 @@ class Install extends ArboristWorkspaceCmd { 'preinstall', 'install', 'postinstall', - 'prepublish', // XXX should we remove this finally?? + 'prepublish', // XXX(npm9) should we remove this finally?? 'preprepare', 'prepare', 'postprepare', diff --git a/deps/npm/lib/commands/link.js b/deps/npm/lib/commands/link.js index d656791469a643..80a60d36e324e9 100644 --- a/deps/npm/lib/commands/link.js +++ b/deps/npm/lib/commands/link.js @@ -43,7 +43,7 @@ class Link extends ArboristWorkspaceCmd { } async exec (args) { - if (this.npm.config.get('global')) { + if (this.npm.global) { throw Object.assign( new Error( 'link should never be --global.\n' + diff --git a/deps/npm/lib/commands/ls.js b/deps/npm/lib/commands/ls.js index e56c90dae16eaf..cfd9cb5a5051ca 100644 --- a/deps/npm/lib/commands/ls.js +++ b/deps/npm/lib/commands/ls.js @@ -52,16 +52,12 @@ class LS extends ArboristWorkspaceCmd { const all = this.npm.config.get('all') const color = this.npm.color const depth = this.npm.config.get('depth') - const dev = this.npm.config.get('dev') - const development = this.npm.config.get('development') - const global = this.npm.config.get('global') + const global = this.npm.global const json = this.npm.config.get('json') const link = this.npm.config.get('link') const long = this.npm.config.get('long') - const only = this.npm.config.get('only') + const omit = this.npm.flatOptions.omit const parseable = this.npm.config.get('parseable') - const prod = this.npm.config.get('prod') - const production = this.npm.config.get('production') const unicode = this.npm.config.get('unicode') const packageLockOnly = this.npm.config.get('package-lock-only') const workspacesEnabled = this.npm.flatOptions.workspacesEnabled @@ -138,15 +134,10 @@ class LS extends ArboristWorkspaceCmd { ? [] : [...(node.target).edgesOut.values()] .filter(filterBySelectedWorkspaces) - .filter(filterByEdgesTypes({ - currentDepth, - dev, - development, + .filter(currentDepth === 0 ? filterByEdgesTypes({ link, - prod, - production, - only, - })) + omit, + }) : () => true) .map(mapEdgesToNodes({ seenPaths })) .concat(appendExtraneousChildren({ node, seenPaths })) .sort(sortAlphabetically) @@ -399,27 +390,13 @@ const getJsonOutputItem = (node, { global, long }) => { return augmentItemWithIncludeMetadata(node, item) } -const filterByEdgesTypes = ({ - currentDepth, - dev, - development, - link, - prod, - production, - only, -}) => { - // filter deps by type, allows for: `npm ls --dev`, `npm ls --prod`, - // `npm ls --link`, `npm ls --only=dev`, etc - const filterDev = currentDepth === 0 && - (dev || development || /^dev(elopment)?$/.test(only)) - const filterProd = currentDepth === 0 && - (prod || production || /^prod(uction)?$/.test(only)) - const filterLink = currentDepth === 0 && link - - return (edge) => - (filterDev ? edge.dev : true) && - (filterProd ? (!edge.dev && !edge.peer && !edge.peerOptional) : true) && - (filterLink ? (edge.to && edge.to.isLink) : true) +const filterByEdgesTypes = ({ link, omit = [] }) => (edge) => { + for (const omitType of omit) { + if (edge[omitType]) { + return false + } + } + return link ? edge.to && edge.to.isLink : true } const appendExtraneousChildren = ({ node, seenPaths }) => diff --git a/deps/npm/lib/commands/outdated.js b/deps/npm/lib/commands/outdated.js index 0cb5b4247a0009..081e75a2c61d36 100644 --- a/deps/npm/lib/commands/outdated.js +++ b/deps/npm/lib/commands/outdated.js @@ -2,8 +2,7 @@ const os = require('os') const path = require('path') const pacote = require('pacote') const table = require('text-table') -const color = require('chalk') -const styles = require('ansistyles') +const chalk = require('chalk') const npa = require('npm-package-arg') const pickManifest = require('npm-pick-manifest') const localeCompare = require('@isaacs/string-locale-compare')('en') @@ -28,7 +27,7 @@ class Outdated extends ArboristWorkspaceCmd { async exec (args) { const global = path.resolve(this.npm.globalDir, '..') - const where = this.npm.config.get('global') + const where = this.npm.global ? global : this.npm.prefix @@ -106,7 +105,7 @@ class Outdated extends ArboristWorkspaceCmd { const outTable = [outHead].concat(outList) if (this.npm.color) { - outTable[0] = outTable[0].map(heading => styles.underline(heading)) + outTable[0] = outTable[0].map(heading => chalk.underline(heading)) } const tableOpts = { @@ -141,7 +140,7 @@ class Outdated extends ArboristWorkspaceCmd { getEdgesOut (node) { // TODO: normalize usage of edges and avoid looping through nodes here - if (this.npm.config.get('global')) { + if (this.npm.global) { for (const child of node.children.values()) { this.trackEdge(child) } @@ -167,7 +166,7 @@ class Outdated extends ArboristWorkspaceCmd { } getWorkspacesEdges (node) { - if (this.npm.config.get('global')) { + if (this.npm.global) { return } @@ -208,7 +207,7 @@ class Outdated extends ArboristWorkspaceCmd { : edge.dev ? 'devDependencies' : 'dependencies' - for (const omitType of this.npm.config.get('omit')) { + for (const omitType of this.npm.flatOptions.omit) { if (node[omitType]) { return } @@ -282,7 +281,7 @@ class Outdated extends ArboristWorkspaceCmd { : node.name return this.npm.color && humanOutput - ? color.green(workspaceName) + ? chalk.green(workspaceName) : workspaceName } @@ -307,9 +306,9 @@ class Outdated extends ArboristWorkspaceCmd { } if (this.npm.color) { - columns[0] = color[current === wanted ? 'yellow' : 'red'](columns[0]) // current - columns[2] = color.green(columns[2]) // wanted - columns[3] = color.magenta(columns[3]) // latest + columns[0] = chalk[current === wanted ? 'yellow' : 'red'](columns[0]) // current + columns[2] = chalk.green(columns[2]) // wanted + columns[3] = chalk.magenta(columns[3]) // latest } return columns diff --git a/deps/npm/lib/commands/owner.js b/deps/npm/lib/commands/owner.js index e74efac1baf6a2..4797e9c7ec84b4 100644 --- a/deps/npm/lib/commands/owner.js +++ b/deps/npm/lib/commands/owner.js @@ -3,8 +3,18 @@ const npmFetch = require('npm-registry-fetch') const pacote = require('pacote') const log = require('../utils/log-shim') const otplease = require('../utils/otplease.js') -const readLocalPkgName = require('../utils/read-package-name.js') +const readPackageJsonFast = require('read-package-json-fast') const BaseCommand = require('../base-command.js') +const { resolve } = require('path') + +const readJson = async (pkg) => { + try { + const json = await readPackageJsonFast(pkg) + return json + } catch { + return {} + } +} class Owner extends BaseCommand { static description = 'Manage package owners' @@ -12,6 +22,8 @@ class Owner extends BaseCommand { static params = [ 'registry', 'otp', + 'workspace', + 'workspaces', ] static usage = [ @@ -38,15 +50,15 @@ class Owner extends BaseCommand { // reaches registry in order to autocomplete rm if (argv[2] === 'rm') { - if (this.npm.config.get('global')) { + if (this.npm.global) { return [] } - const pkgName = await readLocalPkgName(this.npm.prefix) - if (!pkgName) { + const { name } = await readJson(resolve(this.npm.prefix, 'package.json')) + if (!name) { return [] } - const spec = npa(pkgName) + const spec = npa(name) const data = await pacote.packument(spec, { ...this.npm.flatOptions, fullMetadata: true, @@ -59,22 +71,43 @@ class Owner extends BaseCommand { } async exec ([action, ...args]) { - switch (action) { - case 'ls': - case 'list': - return this.ls(args[0]) - case 'add': - return this.changeOwners(args[0], args[1], 'add') - case 'rm': - case 'remove': - return this.changeOwners(args[0], args[1], 'rm') - default: + if (action === 'ls' || action === 'list') { + await this.ls(args[0]) + } else if (action === 'add') { + await this.changeOwners(args[0], args[1], 'add') + } else if (action === 'rm' || action === 'remove') { + await this.changeOwners(args[0], args[1], 'rm') + } else { + throw this.usageError() + } + } + + async execWorkspaces ([action, ...args], filters) { + await this.setWorkspaces(filters) + // ls pkg or owner add/rm package + if ((action === 'ls' && args.length > 0) || args.length > 1) { + const implicitWorkspaces = this.npm.config.get('workspace', 'default') + if (implicitWorkspaces.length === 0) { + log.warn(`Ignoring specified workspace(s)`) + } + return this.exec([action, ...args]) + } + + for (const [name] of this.workspaces) { + if (action === 'ls' || action === 'list') { + await this.ls(name) + } else if (action === 'add') { + await this.changeOwners(args[0], name, 'add') + } else if (action === 'rm' || action === 'remove') { + await this.changeOwners(args[0], name, 'rm') + } else { throw this.usageError() + } } } async ls (pkg) { - pkg = await this.getPkg(pkg) + pkg = await this.getPkg(this.npm.prefix, pkg) const spec = npa(pkg) try { @@ -91,17 +124,17 @@ class Owner extends BaseCommand { } } - async getPkg (pkg) { + async getPkg (prefix, pkg) { if (!pkg) { - if (this.npm.config.get('global')) { + if (this.npm.global) { throw this.usageError() } - const pkgName = await readLocalPkgName(this.npm.prefix) - if (!pkgName) { + const { name } = await readJson(resolve(prefix, 'package.json')) + if (!name) { throw this.usageError() } - return pkgName + return name } return pkg } @@ -111,7 +144,7 @@ class Owner extends BaseCommand { throw this.usageError() } - pkg = await this.getPkg(pkg) + pkg = await this.getPkg(this.npm.prefix, pkg) log.verbose(`owner ${addOrRm}`, '%s to %s', user, pkg) const spec = npa(pkg) @@ -125,15 +158,6 @@ class Owner extends BaseCommand { throw err } - if (user && (!u || !u.name || u.error)) { - throw Object.assign( - new Error( - "Couldn't get user data for " + user + ': ' + JSON.stringify(u) - ), - { code: 'EOWNERUSER' } - ) - } - // normalize user data u = { name: u.name, email: u.email } @@ -177,32 +201,31 @@ class Owner extends BaseCommand { } const dataPath = `/${spec.escapedName}/-rev/${encodeURIComponent(data._rev)}` - const res = await otplease(this.npm.flatOptions, opts => { - return npmFetch.json(dataPath, { - ...opts, - method: 'PUT', - body: { - _id: data._id, - _rev: data._rev, - maintainers, - }, - spec, + try { + const res = await otplease(this.npm.flatOptions, opts => { + return npmFetch.json(dataPath, { + ...opts, + method: 'PUT', + body: { + _id: data._id, + _rev: data._rev, + maintainers, + }, + spec, + }) }) - }) - - if (!res.error) { if (addOrRm === 'add') { this.npm.output(`+ ${user} (${spec.name})`) } else { this.npm.output(`- ${user} (${spec.name})`) } - } else { + return res + } catch (err) { throw Object.assign( - new Error('Failed to update package: ' + JSON.stringify(res)), + new Error('Failed to update package: ' + JSON.stringify(err.message)), { code: 'EOWNERMUTATE' } ) } - return res } } diff --git a/deps/npm/lib/commands/pack.js b/deps/npm/lib/commands/pack.js index 41fef5cb45a47c..8190ceecaf94bc 100644 --- a/deps/npm/lib/commands/pack.js +++ b/deps/npm/lib/commands/pack.js @@ -44,7 +44,11 @@ class Pack extends BaseCommand { // noise generated during packing const tarballs = [] for (const { arg, manifest } of manifests) { - const tarballData = await libpack(arg, this.npm.flatOptions) + const tarballData = await libpack(arg, { + ...this.npm.flatOptions, + prefix: this.npm.localPrefix, + workspaces: this.workspacePaths, + }) const pkgContents = await getContents(manifest, tarballData) tarballs.push(pkgContents) } diff --git a/deps/npm/lib/commands/pkg.js b/deps/npm/lib/commands/pkg.js index 3a8e01f65bc921..5fac9bfb54683b 100644 --- a/deps/npm/lib/commands/pkg.js +++ b/deps/npm/lib/commands/pkg.js @@ -29,7 +29,7 @@ class Pkg extends BaseCommand { this.prefix = prefix } - if (this.npm.config.get('global')) { + if (this.npm.global) { throw Object.assign( new Error(`There's no package.json file to manage on global mode`), { code: 'EPKGGLOBAL' } diff --git a/deps/npm/lib/commands/profile.js b/deps/npm/lib/commands/profile.js index a82d31fd443a9e..fcf0eb7d53fa69 100644 --- a/deps/npm/lib/commands/profile.js +++ b/deps/npm/lib/commands/profile.js @@ -1,6 +1,6 @@ const inspect = require('util').inspect const { URL } = require('url') -const ansistyles = require('ansistyles') +const chalk = require('chalk') const log = require('../utils/log-shim.js') const npmProfile = require('npm-profile') const qrcodeTerminal = require('qrcode-terminal') @@ -163,7 +163,7 @@ class Profile extends BaseCommand { } else { const table = new Table() for (const key of Object.keys(cleaned)) { - table.push({ [ansistyles.bright(key)]: cleaned[key] }) + table.push({ [chalk.bold(key)]: cleaned[key] }) } this.npm.output(table.toString()) diff --git a/deps/npm/lib/commands/publish.js b/deps/npm/lib/commands/publish.js index 1f26370e89a567..da6437fa9c58fc 100644 --- a/deps/npm/lib/commands/publish.js +++ b/deps/npm/lib/commands/publish.js @@ -7,7 +7,6 @@ const runScript = require('@npmcli/run-script') const pacote = require('pacote') const npa = require('npm-package-arg') const npmFetch = require('npm-registry-fetch') -const chalk = require('chalk') const replaceInfo = require('../utils/replace-info.js') const otplease = require('../utils/otplease.js') @@ -69,10 +68,6 @@ class Publish extends BaseCommand { const spec = npa(args[0]) let manifest = await this.getManifest(spec, opts) - if (manifest.publishConfig) { - flatten(manifest.publishConfig, opts) - } - // only run scripts for directory type publishes if (spec.type === 'directory' && !ignoreScripts) { await runScript({ @@ -85,36 +80,42 @@ class Publish extends BaseCommand { } // we pass dryRun: true to libnpmpack so it doesn't write the file to disk - const tarballData = await pack(spec, { ...opts, dryRun: true }) + const tarballData = await pack(spec, { + ...opts, + dryRun: true, + prefix: this.npm.localPrefix, + workspaces: this.workspacePaths, + }) const pkgContents = await getContents(manifest, tarballData) // The purpose of re-reading the manifest is in case it changed, // so that we send the latest and greatest thing to the registry // note that publishConfig might have changed as well! manifest = await this.getManifest(spec, opts) - if (manifest.publishConfig) { - flatten(manifest.publishConfig, opts) - } - // note that logTar calls log.notice(), so if we ARE in silent mode, - // this will do nothing, but we still want it in the debuglog if it fails. + // JSON already has the package contents if (!json) { logTar(pkgContents, { unicode }) } - if (!dryRun) { - const resolved = npa.resolve(manifest.name, manifest.version) - const registry = npmFetch.pickRegistry(resolved, opts) - const creds = this.npm.config.getCredentialsByURI(registry) - const outputRegistry = replaceInfo(registry) - if (!creds.token && !creds.username) { - throw Object.assign( - new Error(`This command requires you to be logged in to ${outputRegistry}`), { - code: 'ENEEDAUTH', - } - ) + const resolved = npa.resolve(manifest.name, manifest.version) + const registry = npmFetch.pickRegistry(resolved, opts) + const creds = this.npm.config.getCredentialsByURI(registry) + const noCreds = !creds.token && !creds.username + const outputRegistry = replaceInfo(registry) + + if (noCreds) { + const msg = `This command requires you to be logged in to ${outputRegistry}` + if (dryRun) { + log.warn('', `${msg} (dry-run)`) + } else { + throw Object.assign(new Error(msg), { code: 'ENEEDAUTH' }) } - log.notice('', `Publishing to ${outputRegistry}`) + } + + log.notice('', `Publishing to ${outputRegistry}${dryRun ? ' (dry-run)' : ''}`) + + if (!dryRun) { await otplease(opts, opts => libpub(manifest, tarballData, opts)) } @@ -154,8 +155,6 @@ class Publish extends BaseCommand { const results = {} const json = this.npm.config.get('json') const { silent } = this.npm - const noop = a => a - const color = this.npm.color ? chalk : { green: noop, bold: noop } await this.setWorkspaces(filters) for (const [name, workspace] of this.workspaces.entries()) { @@ -167,9 +166,9 @@ class Publish extends BaseCommand { log.warn( 'publish', `Skipping workspace ${ - color.green(name) + this.npm.chalk.green(name) }, marked as ${ - color.bold('private') + this.npm.chalk.bold('private') }` ) continue @@ -192,15 +191,22 @@ class Publish extends BaseCommand { // if it's a directory, read it from the file system // otherwise, get the full metadata from whatever it is - getManifest (spec, opts) { + // XXX can't pacote read the manifest from a directory? + async getManifest (spec, opts) { + let manifest if (spec.type === 'directory') { - return readJson(`${spec.fetchSpec}/package.json`) + manifest = await readJson(`${spec.fetchSpec}/package.json`) + } else { + manifest = await pacote.manifest(spec, { + ...opts, + fullmetadata: true, + fullReadJson: true, + }) } - return pacote.manifest(spec, { - ...opts, - fullMetadata: true, - fullReadJson: true, - }) + if (manifest.publishConfig) { + flatten(manifest.publishConfig, opts) + } + return manifest } } module.exports = Publish diff --git a/deps/npm/lib/commands/rebuild.js b/deps/npm/lib/commands/rebuild.js index 0e8a1510bde2b3..3e6046d8df22b0 100644 --- a/deps/npm/lib/commands/rebuild.js +++ b/deps/npm/lib/commands/rebuild.js @@ -26,7 +26,7 @@ class Rebuild extends ArboristWorkspaceCmd { async exec (args) { const globalTop = resolve(this.npm.globalDir, '..') - const where = this.npm.config.get('global') ? globalTop : this.npm.prefix + const where = this.npm.global ? globalTop : this.npm.prefix const arb = new Arborist({ ...this.npm.flatOptions, path: where, diff --git a/deps/npm/lib/commands/repo.js b/deps/npm/lib/commands/repo.js index b8dccc209ff87a..b89b74c0bf1baa 100644 --- a/deps/npm/lib/commands/repo.js +++ b/deps/npm/lib/commands/repo.js @@ -1,40 +1,11 @@ -const pacote = require('pacote') const { URL } = require('url') -const log = require('../utils/log-shim') -const hostedFromMani = require('../utils/hosted-git-info-from-manifest.js') -const openUrl = require('../utils/open-url.js') -const BaseCommand = require('../base-command.js') -class Repo extends BaseCommand { +const PackageUrlCmd = require('../package-url-cmd.js') +class Repo extends PackageUrlCmd { static description = 'Open package repository page in the browser' static name = 'repo' - static params = ['browser', 'workspace', 'workspaces', 'include-workspace-root'] - static usage = ['[ [ ...]]'] - static ignoreImplicitWorkspace = false - - async exec (args) { - if (!args || !args.length) { - args = ['.'] - } - - await Promise.all(args.map(pkg => this.get(pkg))) - } - - async execWorkspaces (args, filters) { - await this.setWorkspaces(filters) - return this.exec(this.workspacePaths) - } - - async get (pkg) { - // XXX It is very odd that `where` is how pacote knows to look anywhere - // other than the cwd. - const opts = { - ...this.npm.flatOptions, - where: this.npm.localPrefix, - fullMetadata: true, - } - const mani = await pacote.manifest(pkg, opts) + getUrl (spec, mani) { const r = mani.repository const rurl = !r ? null : typeof r === 'string' ? r @@ -43,22 +14,20 @@ class Repo extends BaseCommand { if (!rurl) { throw Object.assign(new Error('no repository'), { - pkgid: pkg, + pkgid: spec, }) } - const info = hostedFromMani(mani) + const info = this.hostedFromMani(mani) const url = info ? info.browse(mani.repository.directory) : unknownHostedUrl(rurl) if (!url) { throw Object.assign(new Error('no repository: could not get url'), { - pkgid: pkg, + pkgid: spec, }) } - - log.silly('docs', 'url', url) - await openUrl(this.npm, url, `${mani.name} repo available at the following URL`) + return url } } module.exports = Repo 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/search.js b/deps/npm/lib/commands/search.js index a06ba4031443b4..8751e9e7d22fd0 100644 --- a/deps/npm/lib/commands/search.js +++ b/deps/npm/lib/commands/search.js @@ -3,26 +3,33 @@ const Pipeline = require('minipass-pipeline') const libSearch = require('libnpmsearch') const log = require('../utils/log-shim.js') -const formatPackageStream = require('../search/format-package-stream.js') -const packageFilter = require('../search/package-filter.js') +const formatSearchStream = require('../utils/format-search-stream.js') + +function filter (data, include, exclude) { + const words = [data.name] + .concat(data.maintainers.map(m => `=${m.username}`)) + .concat(data.keywords || []) + .map(f => f && f.trim && f.trim()) + .filter(f => f) + .join(' ') + .toLowerCase() + + if (exclude.find(e => match(words, e))) { + return false + } -function prepareIncludes (args) { - return args - .map(s => s.toLowerCase()) - .filter(s => s) + return true } -function prepareExcludes (searchexclude) { - var exclude - if (typeof searchexclude === 'string') { - exclude = searchexclude.split(/\s+/) - } else { - exclude = [] +function match (words, pattern) { + if (pattern.startsWith('/')) { + if (pattern.endsWith('/')) { + pattern = pattern.slice(0, -1) + } + pattern = new RegExp(pattern.slice(1)) + return words.match(pattern) } - - return exclude - .map(s => s.toLowerCase()) - .filter(s => s) + return words.indexOf(pattern) !== -1 } const BaseCommand = require('../base-command.js') @@ -50,8 +57,8 @@ class Search extends BaseCommand { const opts = { ...this.npm.flatOptions, ...this.npm.flatOptions.search, - include: prepareIncludes(args), - exclude: prepareExcludes(this.npm.flatOptions.search.exclude), + include: args.map(s => s.toLowerCase()).filter(s => s), + exclude: this.npm.flatOptions.search.exclude.split(/\s+/), } if (opts.include.length === 0) { @@ -63,7 +70,7 @@ class Search extends BaseCommand { class FilterStream extends Minipass { write (pkg) { - if (packageFilter(pkg, opts.include, opts.exclude)) { + if (filter(pkg, opts.include, opts.exclude)) { super.write(pkg) } } @@ -73,7 +80,7 @@ class Search extends BaseCommand { // Grab a configured output stream that will spit out packages in the // desired format. - const outputStream = formatPackageStream({ + const outputStream = formatSearchStream({ args, // --searchinclude options are not highlighted ...opts, }) diff --git a/deps/npm/lib/commands/set-script.js b/deps/npm/lib/commands/set-script.js index a6b7c3a50cdafe..a085f72a314284 100644 --- a/deps/npm/lib/commands/set-script.js +++ b/deps/npm/lib/commands/set-script.js @@ -5,7 +5,7 @@ const log = require('../utils/log-shim') const BaseCommand = require('../base-command.js') class SetScript extends BaseCommand { - static description = 'Set tasks in the scripts section of package.json' + static description = 'Set tasks in the scripts section of package.json, deprecated' static params = ['workspace', 'workspaces', 'include-workspace-root'] static name = 'set-script' static usage = ['[