diff --git a/deps/npm/README.md b/deps/npm/README.md index 642e1a51ebc05f..7e4a5f38a7607f 100644 --- a/deps/npm/README.md +++ b/deps/npm/README.md @@ -50,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/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-ci.md b/deps/npm/docs/content/commands/npm-ci.md index 2bb542a725b5dc..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`. 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-diff.md b/deps/npm/docs/content/commands/npm-diff.md index 7dcc8af7c3b4c7..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 diff --git a/deps/npm/docs/content/commands/npm-install-test.md b/deps/npm/docs/content/commands/npm-install-test.md index 3dd860ea5c6f68..18e374869d5a60 100644 --- a/deps/npm/docs/content/commands/npm-install-test.md +++ b/deps/npm/docs/content/commands/npm-install-test.md @@ -70,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 diff --git a/deps/npm/docs/content/commands/npm-install.md b/deps/npm/docs/content/commands/npm-install.md index d6668a2c2bd0fb..318df5780e8dba 100644 --- a/deps/npm/docs/content/commands/npm-install.md +++ b/deps/npm/docs/content/commands/npm-install.md @@ -460,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 diff --git a/deps/npm/docs/content/commands/npm-link.md b/deps/npm/docs/content/commands/npm-link.md index 975c807c38b348..34c67aa3def81d 100644 --- a/deps/npm/docs/content/commands/npm-link.md +++ b/deps/npm/docs/content/commands/npm-link.md @@ -153,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 diff --git a/deps/npm/docs/content/commands/npm-ls.md b/deps/npm/docs/content/commands/npm-ls.md index ded8c0c0d26ef1..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 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-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-rebuild.md b/deps/npm/docs/content/commands/npm-rebuild.md index 52c368c8c513b9..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 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-set-script.md b/deps/npm/docs/content/commands/npm-set-script.md index 0fc267f760c81f..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. + diff --git a/deps/npm/docs/content/commands/npm-update.md b/deps/npm/docs/content/commands/npm-update.md index 421d04ca3dc583..55aad182fcafe8 100644 --- a/deps/npm/docs/content/commands/npm-update.md +++ b/deps/npm/docs/content/commands/npm-update.md @@ -188,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 diff --git a/deps/npm/docs/content/using-npm/config.md b/deps/npm/docs/content/using-npm/config.md index a33e791bb836ba..12b508582af1c3 100644 --- a/deps/npm/docs/content/using-npm/config.md +++ b/deps/npm/docs/content/using-npm/config.md @@ -687,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 @@ -1001,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` + @@ -1941,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/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

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-ci.html b/deps/npm/docs/output/commands/npm-ci.html index 713f7b0c81e4f7..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.
  • 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-diff.html b/deps/npm/docs/output/commands/npm-diff.html index 13ed989c461801..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 diff --git a/deps/npm/docs/output/commands/npm-install-test.html b/deps/npm/docs/output/commands/npm-install-test.html index 6306ceb5938558..fce049dc2c09e5 100644 --- a/deps/npm/docs/output/commands/npm-install-test.html +++ b/deps/npm/docs/output/commands/npm-install-test.html @@ -196,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 diff --git a/deps/npm/docs/output/commands/npm-install.html b/deps/npm/docs/output/commands/npm-install.html index 509702b5bd4ead..ca6ca1ee260f33 100644 --- a/deps/npm/docs/output/commands/npm-install.html +++ b/deps/npm/docs/output/commands/npm-install.html @@ -522,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 diff --git a/deps/npm/docs/output/commands/npm-link.html b/deps/npm/docs/output/commands/npm-link.html index f7d5f66a9e2bd2..cb43c0478d7015 100644 --- a/deps/npm/docs/output/commands/npm-link.html +++ b/deps/npm/docs/output/commands/npm-link.html @@ -251,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 diff --git a/deps/npm/docs/output/commands/npm-ls.html b/deps/npm/docs/output/commands/npm-ls.html index 579b54a3880811..10caff53c3a090 100644 --- a/deps/npm/docs/output/commands/npm-ls.html +++ b/deps/npm/docs/output/commands/npm-ls.html @@ -166,7 +166,7 @@

Description

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

-
npm@8.10.0 /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 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-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-rebuild.html b/deps/npm/docs/output/commands/npm-rebuild.html index f4524f1a4f0baa..84837a3be5d394 100644 --- a/deps/npm/docs/output/commands/npm-rebuild.html +++ b/deps/npm/docs/output/commands/npm-rebuild.html @@ -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 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-set-script.html b/deps/npm/docs/output/commands/npm-set-script.html index 51b29d87fa43e8..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.

diff --git a/deps/npm/docs/output/commands/npm-update.html b/deps/npm/docs/output/commands/npm-update.html index d88ea8578bacef..d0cb6d5f75501b 100644 --- a/deps/npm/docs/output/commands/npm-update.html +++ b/deps/npm/docs/output/commands/npm-update.html @@ -275,6 +275,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.html b/deps/npm/docs/output/commands/npm.html index 4a816cc1a9f398..99c109c4e25cfa 100644 --- a/deps/npm/docs/output/commands/npm.html +++ b/deps/npm/docs/output/commands/npm.html @@ -149,7 +149,7 @@

Table of contents

Version

-

8.10.0

+

8.11.0

Description

npm is the package manager for the Node JavaScript platform. It puts modules in place so that node can find them, and manages dependency diff --git a/deps/npm/docs/output/using-npm/config.html b/deps/npm/docs/output/using-npm/config.html index d00c7654e1be16..ef033b8693e4fd 100644 --- a/deps/npm/docs/output/using-npm/config.html +++ b/deps/npm/docs/output/using-npm/config.html @@ -142,7 +142,7 @@

config

Table of contents

-
+

Description

@@ -696,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
  • @@ -951,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

@@ -1701,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/lib/commands/bin.js b/deps/npm/lib/commands/bin.js index 4200d5b8ca556a..9ba3cb4003241b 100644 --- a/deps/npm/lib/commands/bin.js +++ b/deps/npm/lib/commands/bin.js @@ -15,7 +15,7 @@ class Bin extends BaseCommand { async exec (args) { const b = this.npm.bin this.npm.output(b) - if (this.npm.config.get('global') && !path.split(delimiter).includes(b)) { + 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 c7b5b31c54a62a..cdd6db62869059 100644 --- a/deps/npm/lib/commands/birthday.js +++ b/deps/npm/lib/commands/birthday.js @@ -1,13 +1,15 @@ const BaseCommand = require('../base-command.js') +const log = require('../utils/log-shim') class Birthday extends BaseCommand { static name = 'birthday' - static description = '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/cache.js b/deps/npm/lib/commands/cache.js index 634c8dbb428096..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) } } @@ -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/config.js b/deps/npm/lib/commands/config.js index 0432abac391f38..96dd4abcaf4af8 100644 --- a/deps/npm/lib/commands/config.js +++ b/deps/npm/lib/commands/config.js @@ -276,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 96d1ac2ae9a743..2cc44b2a9fb2fd 100644 --- a/deps/npm/lib/commands/dedupe.js +++ b/deps/npm/lib/commands/dedupe.js @@ -22,7 +22,7 @@ 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 diff --git a/deps/npm/lib/commands/diff.js b/deps/npm/lib/commands/diff.js index 11ee78265e62a3..b8a64bd98a0394 100644 --- a/deps/npm/lib/commands/diff.js +++ b/deps/npm/lib/commands/diff.js @@ -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 diff --git a/deps/npm/lib/commands/dist-tag.js b/deps/npm/lib/commands/dist-tag.js index 42cad80df0073f..a207e422cb53c1 100644 --- a/deps/npm/lib/commands/dist-tag.js +++ b/deps/npm/lib/commands/dist-tag.js @@ -148,7 +148,7 @@ class DistTag extends BaseCommand { async list (spec, opts) { if (!spec) { - if (this.npm.config.get('global')) { + if (this.npm.global) { throw this.usageError() } const { name } = await readPackage(path.resolve(this.npm.prefix, 'package.json')) 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/install.js b/deps/npm/lib/commands/install.js index d1f6d1481dddc5..4cda36448317fe 100644 --- a/deps/npm/lib/commands/install.js +++ b/deps/npm/lib/commands/install.js @@ -106,7 +106,7 @@ 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 scriptShell = this.npm.config.get('script-shell') || undefined 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 06268fe7e0ac0d..cfd9cb5a5051ca 100644 --- a/deps/npm/lib/commands/ls.js +++ b/deps/npm/lib/commands/ls.js @@ -52,7 +52,7 @@ class LS extends ArboristWorkspaceCmd { const all = this.npm.config.get('all') const color = this.npm.color const depth = this.npm.config.get('depth') - 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') diff --git a/deps/npm/lib/commands/outdated.js b/deps/npm/lib/commands/outdated.js index 0953c17ca10d2a..081e75a2c61d36 100644 --- a/deps/npm/lib/commands/outdated.js +++ b/deps/npm/lib/commands/outdated.js @@ -27,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 @@ -140,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) } @@ -166,7 +166,7 @@ class Outdated extends ArboristWorkspaceCmd { } getWorkspacesEdges (node) { - if (this.npm.config.get('global')) { + if (this.npm.global) { return } diff --git a/deps/npm/lib/commands/owner.js b/deps/npm/lib/commands/owner.js index 9338b22a5e8574..4797e9c7ec84b4 100644 --- a/deps/npm/lib/commands/owner.js +++ b/deps/npm/lib/commands/owner.js @@ -50,7 +50,7 @@ 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 { name } = await readJson(resolve(this.npm.prefix, 'package.json')) @@ -126,7 +126,7 @@ class Owner extends BaseCommand { async getPkg (prefix, pkg) { if (!pkg) { - if (this.npm.config.get('global')) { + if (this.npm.global) { throw this.usageError() } const { name } = await readJson(resolve(prefix, 'package.json')) 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/publish.js b/deps/npm/lib/commands/publish.js index cbf0ccf4d65810..da6437fa9c58fc 100644 --- a/deps/npm/lib/commands/publish.js +++ b/deps/npm/lib/commands/publish.js @@ -80,7 +80,12 @@ 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, 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/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 = ['[