deps: upgrade npm to 8.5.5

PR-URL: https://github.com/nodejs/node/pull/42382
Reviewed-By: Ruy Adorno <ruyadorno@github.com>
Reviewed-By: Mestery <mestery@protonmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
npm team 2022-03-17 20:22:31 +00:00 committed by Rich Trott
parent fff95aeea9
commit 76d85a82ea
191 changed files with 4398 additions and 4071 deletions

View File

@ -246,6 +246,7 @@ mistakes, unnecessary performance degradation, and malicious input.
* Allow conflicting peerDependencies to be installed in the root project.
* Implicitly set `--yes` during `npm init`.
* Allow clobbering existing values in `npm pkg`
* Allow unpublishing of entire packages (not just a single version).
If you don't have a clear idea of what you want to do, it is strongly
recommended that you do not use this option!
@ -306,6 +307,36 @@ variable will be set to `'production'` for all lifecycle scripts.
<!-- automatically generated, do not edit manually -->
<!-- see lib/utils/config/definitions.js -->
#### `foreground-scripts`
* Default: false
* Type: Boolean
Run all build scripts (ie, `preinstall`, `install`, and `postinstall`)
scripts for installed packages in the foreground process, sharing standard
input, output, and error with the main npm process.
Note that this will generally make installs run slower, and be much noisier,
but can be useful for debugging.
<!-- automatically generated, do not edit manually -->
<!-- see lib/utils/config/definitions.js -->
#### `ignore-scripts`
* Default: false
* Type: Boolean
If true, npm does not run scripts specified in package.json files.
Note that commands explicitly intended to run a particular script, such as
`npm start`, `npm stop`, `npm restart`, `npm test`, and `npm run-script`
will still run their intended script if `ignore-scripts` is set, but they
will *not* run any pre- or post-scripts.
<!-- automatically generated, do not edit manually -->
<!-- see lib/utils/config/definitions.js -->
#### `workspace`
* Default:

View File

@ -94,6 +94,21 @@ submitted.
<!-- automatically generated, do not edit manually -->
<!-- see lib/utils/config/definitions.js -->
#### `foreground-scripts`
* Default: false
* Type: Boolean
Run all build scripts (ie, `preinstall`, `install`, and `postinstall`)
scripts for installed packages in the foreground process, sharing standard
input, output, and error with the main npm process.
Note that this will generally make installs run slower, and be much noisier,
but can be useful for debugging.
<!-- automatically generated, do not edit manually -->
<!-- see lib/utils/config/definitions.js -->
#### `ignore-scripts`
* Default: false

View File

@ -199,6 +199,7 @@ mistakes, unnecessary performance degradation, and malicious input.
* Allow conflicting peerDependencies to be installed in the root project.
* Implicitly set `--yes` during `npm init`.
* Allow clobbering existing values in `npm pkg`
* Allow unpublishing of entire packages (not just a single version).
If you don't have a clear idea of what you want to do, it is strongly
recommended that you do not use this option!

View File

@ -43,6 +43,21 @@ submitted.
<!-- automatically generated, do not edit manually -->
<!-- see lib/utils/config/definitions.js -->
#### `foreground-scripts`
* Default: false
* Type: Boolean
Run all build scripts (ie, `preinstall`, `install`, and `postinstall`)
scripts for installed packages in the foreground process, sharing standard
input, output, and error with the main npm process.
Note that this will generally make installs run slower, and be much noisier,
but can be useful for debugging.
<!-- automatically generated, do not edit manually -->
<!-- see lib/utils/config/definitions.js -->
#### `ignore-scripts`
* Default: false

View File

@ -112,6 +112,27 @@ will be preferred.
<!-- automatically generated, do not edit manually -->
<!-- see lib/utils/config/definitions.js -->
#### `omit`
* Default: 'dev' if the `NODE_ENV` environment variable is set to
'production', otherwise empty.
* Type: "dev", "optional", or "peer" (can be set multiple times)
Dependency types to omit from the installation tree on disk.
Note that these dependencies _are_ still resolved and added to the
`package-lock.json` or `npm-shrinkwrap.json` file. They are just not
physically installed on disk.
If a package type appears in both the `--include` and `--omit` lists, then
it will be included.
If the resulting omit list includes `'dev'`, then the `NODE_ENV` environment
variable will be set to `'production'` for all lifecycle scripts.
<!-- automatically generated, do not edit manually -->
<!-- see lib/utils/config/definitions.js -->
#### `strict-peer-deps`
* Default: false
@ -151,23 +172,17 @@ This configuration does not affect `npm ci`.
<!-- automatically generated, do not edit manually -->
<!-- see lib/utils/config/definitions.js -->
#### `omit`
#### `foreground-scripts`
* Default: 'dev' if the `NODE_ENV` environment variable is set to
'production', otherwise empty.
* Type: "dev", "optional", or "peer" (can be set multiple times)
* Default: false
* Type: Boolean
Dependency types to omit from the installation tree on disk.
Run all build scripts (ie, `preinstall`, `install`, and `postinstall`)
scripts for installed packages in the foreground process, sharing standard
input, output, and error with the main npm process.
Note that these dependencies _are_ still resolved and added to the
`package-lock.json` or `npm-shrinkwrap.json` file. They are just not
physically installed on disk.
If a package type appears in both the `--include` and `--omit` lists, then
it will be included.
If the resulting omit list includes `'dev'`, then the `NODE_ENV` environment
variable will be set to `'production'` for all lifecycle scripts.
Note that this will generally make installs run slower, and be much noisier,
but can be useful for debugging.
<!-- automatically generated, do not edit manually -->
<!-- see lib/utils/config/definitions.js -->

View File

@ -22,7 +22,7 @@ npm install <tarball url>
npm install <git:// url>
npm install <github username>/<github project>
aliases: i, in, ins, inst, insta, instal, isnt, isnta, isntal, add
aliases: i, in, ins, inst, insta, instal, isnt, isnta, isntal, isntall, add
```
<!-- automatically generated, do not edit manually -->
@ -502,6 +502,27 @@ will be preferred.
<!-- automatically generated, do not edit manually -->
<!-- see lib/utils/config/definitions.js -->
#### `omit`
* Default: 'dev' if the `NODE_ENV` environment variable is set to
'production', otherwise empty.
* Type: "dev", "optional", or "peer" (can be set multiple times)
Dependency types to omit from the installation tree on disk.
Note that these dependencies _are_ still resolved and added to the
`package-lock.json` or `npm-shrinkwrap.json` file. They are just not
physically installed on disk.
If a package type appears in both the `--include` and `--omit` lists, then
it will be included.
If the resulting omit list includes `'dev'`, then the `NODE_ENV` environment
variable will be set to `'production'` for all lifecycle scripts.
<!-- automatically generated, do not edit manually -->
<!-- see lib/utils/config/definitions.js -->
#### `strict-peer-deps`
* Default: false
@ -541,23 +562,17 @@ This configuration does not affect `npm ci`.
<!-- automatically generated, do not edit manually -->
<!-- see lib/utils/config/definitions.js -->
#### `omit`
#### `foreground-scripts`
* Default: 'dev' if the `NODE_ENV` environment variable is set to
'production', otherwise empty.
* Type: "dev", "optional", or "peer" (can be set multiple times)
* Default: false
* Type: Boolean
Dependency types to omit from the installation tree on disk.
Run all build scripts (ie, `preinstall`, `install`, and `postinstall`)
scripts for installed packages in the foreground process, sharing standard
input, output, and error with the main npm process.
Note that these dependencies _are_ still resolved and added to the
`package-lock.json` or `npm-shrinkwrap.json` file. They are just not
physically installed on disk.
If a package type appears in both the `--include` and `--omit` lists, then
it will be included.
If the resulting omit list includes `'dev'`, then the `NODE_ENV` environment
variable will be set to `'production'` for all lifecycle scripts.
Note that this will generally make installs run slower, and be much noisier,
but can be useful for debugging.
<!-- automatically generated, do not edit manually -->
<!-- see lib/utils/config/definitions.js -->

View File

@ -14,6 +14,8 @@ description: Manages your package.json
npm pkg set <key>=<value> [<key>=<value> ...]
npm pkg get [<key> [<key> ...]]
npm pkg delete <key> [<key> ...]
npm pkg set [<array>[<index>].<key>=<value> ...]
npm pkg set [<array>[].<key>=<value> ...]
```
<!-- automatically generated, do not edit manually -->
@ -197,6 +199,7 @@ mistakes, unnecessary performance degradation, and malicious input.
* Allow conflicting peerDependencies to be installed in the root project.
* Implicitly set `--yes` during `npm init`.
* Allow clobbering existing values in `npm pkg`
* Allow unpublishing of entire packages (not just a single version).
If you don't have a clear idea of what you want to do, it is strongly
recommended that you do not use this option!

View File

@ -99,6 +99,36 @@ Not supported by all npm commands.
<!-- automatically generated, do not edit manually -->
<!-- see lib/utils/config/definitions.js -->
#### `foreground-scripts`
* Default: false
* Type: Boolean
Run all build scripts (ie, `preinstall`, `install`, and `postinstall`)
scripts for installed packages in the foreground process, sharing standard
input, output, and error with the main npm process.
Note that this will generally make installs run slower, and be much noisier,
but can be useful for debugging.
<!-- automatically generated, do not edit manually -->
<!-- see lib/utils/config/definitions.js -->
#### `ignore-scripts`
* Default: false
* Type: Boolean
If true, npm does not run scripts specified in package.json files.
Note that commands explicitly intended to run a particular script, such as
`npm start`, `npm stop`, `npm restart`, `npm test`, and `npm run-script`
will still run their intended script if `ignore-scripts` is set, but they
will *not* run any pre- or post-scripts.
<!-- automatically generated, do not edit manually -->
<!-- see lib/utils/config/definitions.js -->
#### `workspace`
* Default:

View File

@ -70,6 +70,21 @@ systems.
<!-- automatically generated, do not edit manually -->
<!-- see lib/utils/config/definitions.js -->
#### `foreground-scripts`
* Default: false
* Type: Boolean
Run all build scripts (ie, `preinstall`, `install`, and `postinstall`)
scripts for installed packages in the foreground process, sharing standard
input, output, and error with the main npm process.
Note that this will generally make installs run slower, and be much noisier,
but can be useful for debugging.
<!-- automatically generated, do not edit manually -->
<!-- see lib/utils/config/definitions.js -->
#### `ignore-scripts`
* Default: false

View File

@ -6,22 +6,23 @@ description: Remove a package from the registry
### Synopsis
<!-- AUTOGENERATED USAGE DESCRIPTIONS START -->
<!-- automatically generated, do not edit manually -->
<!-- see lib/commands/unpublish.js -->
```bash
npm unpublish [<@scope>/]<pkg>[@<version>]
```
<!-- automatically generated, do not edit manually -->
<!-- see lib/commands/unpublish.js -->
<!-- AUTOGENERATED USAGE DESCRIPTIONS END -->
To learn more about how the npm registry treats unpublish, see our <a
href="https://docs.npmjs.com/policies/unpublish" target="_blank"
rel="noopener noreferrer"> unpublish policies</a>
#### Unpublishing a single version of a package
```bash
npm unpublish [<@scope>/]<pkg>@<version>
```
#### Unpublishing an entire package
```bash
npm unpublish [<@scope>/]<pkg> --force
```
### Warning
Consider using the [`deprecate`](/commands/npm-deprecate) command instead,
@ -87,6 +88,7 @@ mistakes, unnecessary performance degradation, and malicious input.
* Allow conflicting peerDependencies to be installed in the root project.
* Implicitly set `--yes` during `npm init`.
* Allow clobbering existing values in `npm pkg`
* Allow unpublishing of entire packages (not just a single version).
If you don't have a clear idea of what you want to do, it is strongly
recommended that you do not use this option!

View File

@ -169,6 +169,22 @@ be _downgraded_.
<!-- AUTOGENERATED CONFIG DESCRIPTIONS START -->
<!-- automatically generated, do not edit manually -->
<!-- see lib/utils/config/definitions.js -->
#### `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`.
<!-- automatically generated, do not edit manually -->
<!-- see lib/utils/config/definitions.js -->
#### `global`
* Default: false
@ -214,6 +230,27 @@ will be preferred.
<!-- automatically generated, do not edit manually -->
<!-- see lib/utils/config/definitions.js -->
#### `omit`
* Default: 'dev' if the `NODE_ENV` environment variable is set to
'production', otherwise empty.
* Type: "dev", "optional", or "peer" (can be set multiple times)
Dependency types to omit from the installation tree on disk.
Note that these dependencies _are_ still resolved and added to the
`package-lock.json` or `npm-shrinkwrap.json` file. They are just not
physically installed on disk.
If a package type appears in both the `--include` and `--omit` lists, then
it will be included.
If the resulting omit list includes `'dev'`, then the `NODE_ENV` environment
variable will be set to `'production'` for all lifecycle scripts.
<!-- automatically generated, do not edit manually -->
<!-- see lib/utils/config/definitions.js -->
#### `strict-peer-deps`
* Default: false
@ -253,39 +290,17 @@ This configuration does not affect `npm ci`.
<!-- automatically generated, do not edit manually -->
<!-- see lib/utils/config/definitions.js -->
#### `save`
#### `foreground-scripts`
* Default: `true` unless when using `npm update` or `npm dedupe` where it
defaults to `false`
* Default: false
* Type: Boolean
Save installed packages to a `package.json` file as dependencies.
Run all build scripts (ie, `preinstall`, `install`, and `postinstall`)
scripts for installed packages in the foreground process, sharing standard
input, output, and error with the main npm process.
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`.
<!-- automatically generated, do not edit manually -->
<!-- see lib/utils/config/definitions.js -->
#### `omit`
* Default: 'dev' if the `NODE_ENV` environment variable is set to
'production', otherwise empty.
* Type: "dev", "optional", or "peer" (can be set multiple times)
Dependency types to omit from the installation tree on disk.
Note that these dependencies _are_ still resolved and added to the
`package-lock.json` or `npm-shrinkwrap.json` file. They are just not
physically installed on disk.
If a package type appears in both the `--include` and `--omit` lists, then
it will be included.
If the resulting omit list includes `'dev'`, then the `NODE_ENV` environment
variable will be set to `'production'` for all lifecycle scripts.
Note that this will generally make installs run slower, and be much noisier,
but can be useful for debugging.
<!-- automatically generated, do not edit manually -->
<!-- see lib/utils/config/definitions.js -->

View File

@ -52,7 +52,8 @@ Run git commit hooks when using the `npm version` command.
* Default: true
* Type: Boolean
Tag the commit when using the `npm version` command.
Tag the commit when using the `npm version` command. Setting this to false
results in no commit being made at all.
<!-- automatically generated, do not edit manually -->
<!-- see lib/utils/config/definitions.js -->

View File

@ -323,7 +323,7 @@ This should be a module relative to the root of your package folder.
For most modules, it makes the most sense to have a main script and often
not much else.
If `main` is not set it defaults to `index.js` in the packages root folder.
If `main` is not set it defaults to `index.js` in the package's root folder.
### browser
@ -690,6 +690,10 @@ This feature is helpful for local offline development and creating tests
that require npm installing where you don't want to hit an external server,
but should not be used when publishing packages to the public registry.
*note*: Packages linked by local path will not have their own
dependencies installed when `npm install` is ran in this case. You must
run `npm install` from inside the local path itself.
### devDependencies
If someone is planning on downloading and using your module in their

View File

@ -616,6 +616,7 @@ mistakes, unnecessary performance degradation, and malicious input.
* Allow conflicting peerDependencies to be installed in the root project.
* Implicitly set `--yes` during `npm init`.
* Allow clobbering existing values in `npm pkg`
* Allow unpublishing of entire packages (not just a single version).
If you don't have a clear idea of what you want to do, it is strongly
recommended that you do not use this option!
@ -677,7 +678,8 @@ but is not in the `PATH`, then set this to the full path to the git binary.
* Default: true
* Type: Boolean
Tag the commit when using the `npm version` command.
Tag the commit when using the `npm version` command. Setting this to false
results in no commit being made at all.
<!-- automatically generated, do not edit manually -->
<!-- see lib/utils/config/definitions.js -->

View File

@ -142,7 +142,7 @@ npm command-line interface
<section id="table_of_contents">
<h2 id="table-of-contents">Table of contents</h2>
<div id="_table_of_contents"><ul><li><a href="#synopsis">Synopsis</a></li><li><a href="#description">Description</a></li><li><a href="#audit-endpoints">Audit Endpoints</a></li><ul><li><a href="#bulk-advisory-endpoint">Bulk Advisory Endpoint</a></li><li><a href="#quick-audit-endpoint">Quick Audit Endpoint</a></li><li><a href="#scrubbing">Scrubbing</a></li><li><a href="#calculating-meta-vulnerabilities-and-remediations">Calculating Meta-Vulnerabilities and Remediations</a></li></ul><li><a href="#exit-code">Exit Code</a></li><li><a href="#examples">Examples</a></li><li><a href="#configuration">Configuration</a></li><ul><li><a href="#audit-level"><code>audit-level</code></a></li><li><a href="#dry-run"><code>dry-run</code></a></li><li><a href="#force"><code>force</code></a></li><li><a href="#json"><code>json</code></a></li><li><a href="#package-lock-only"><code>package-lock-only</code></a></li><li><a href="#omit"><code>omit</code></a></li><li><a href="#workspace"><code>workspace</code></a></li><li><a href="#workspaces"><code>workspaces</code></a></li><li><a href="#include-workspace-root"><code>include-workspace-root</code></a></li></ul><li><a href="#see-also">See Also</a></li></ul></div>
<div id="_table_of_contents"><ul><li><a href="#synopsis">Synopsis</a></li><li><a href="#description">Description</a></li><li><a href="#audit-endpoints">Audit Endpoints</a></li><ul><li><a href="#bulk-advisory-endpoint">Bulk Advisory Endpoint</a></li><li><a href="#quick-audit-endpoint">Quick Audit Endpoint</a></li><li><a href="#scrubbing">Scrubbing</a></li><li><a href="#calculating-meta-vulnerabilities-and-remediations">Calculating Meta-Vulnerabilities and Remediations</a></li></ul><li><a href="#exit-code">Exit Code</a></li><li><a href="#examples">Examples</a></li><li><a href="#configuration">Configuration</a></li><ul><li><a href="#audit-level"><code>audit-level</code></a></li><li><a href="#dry-run"><code>dry-run</code></a></li><li><a href="#force"><code>force</code></a></li><li><a href="#json"><code>json</code></a></li><li><a href="#package-lock-only"><code>package-lock-only</code></a></li><li><a href="#omit"><code>omit</code></a></li><li><a href="#foreground-scripts"><code>foreground-scripts</code></a></li><li><a href="#ignore-scripts"><code>ignore-scripts</code></a></li><li><a href="#workspace"><code>workspace</code></a></li><li><a href="#workspaces"><code>workspaces</code></a></li><li><a href="#include-workspace-root"><code>include-workspace-root</code></a></li></ul><li><a href="#see-also">See Also</a></li></ul></div>
</section>
<div id="_content"><h3 id="synopsis">Synopsis</h3>
@ -319,6 +319,7 @@ range (including SemVer-major changes).</li>
<li>Allow conflicting peerDependencies to be installed in the root project.</li>
<li>Implicitly set <code>--yes</code> during <code>npm init</code>.</li>
<li>Allow clobbering existing values in <code>npm pkg</code></li>
<li>Allow unpublishing of entire packages (not just a single version).</li>
</ul>
<p>If you don't have a clear idea of what you want to do, it is strongly
recommended that you do not use this option!</p>
@ -366,6 +367,30 @@ it will be included.</p>
variable will be set to <code>'production'</code> for all lifecycle scripts.</p>
<!-- raw HTML omitted -->
<!-- raw HTML omitted -->
<h4 id="foreground-scripts"><code>foreground-scripts</code></h4>
<ul>
<li>Default: false</li>
<li>Type: Boolean</li>
</ul>
<p>Run all build scripts (ie, <code>preinstall</code>, <code>install</code>, and <code>postinstall</code>)
scripts for installed packages in the foreground process, sharing standard
input, output, and error with the main npm process.</p>
<p>Note that this will generally make installs run slower, and be much noisier,
but can be useful for debugging.</p>
<!-- raw HTML omitted -->
<!-- raw HTML omitted -->
<h4 id="ignore-scripts"><code>ignore-scripts</code></h4>
<ul>
<li>Default: false</li>
<li>Type: Boolean</li>
</ul>
<p>If true, npm does not run scripts specified in package.json files.</p>
<p>Note that commands explicitly intended to run a particular script, such as
<code>npm start</code>, <code>npm stop</code>, <code>npm restart</code>, <code>npm test</code>, and <code>npm run-script</code>
will still run their intended script if <code>ignore-scripts</code> is set, but they
will <em>not</em> run any pre- or post-scripts.</p>
<!-- raw HTML omitted -->
<!-- raw HTML omitted -->
<h4 id="workspace"><code>workspace</code></h4>
<ul>
<li>Default:</li>

View File

@ -142,7 +142,7 @@ npm command-line interface
<section id="table_of_contents">
<h2 id="table-of-contents">Table of contents</h2>
<div id="_table_of_contents"><ul><li><a href="#synopsis">Synopsis</a></li><li><a href="#description">Description</a></li><li><a href="#example">Example</a></li><li><a href="#configuration">Configuration</a></li><ul><li><a href="#audit"><code>audit</code></a></li><li><a href="#ignore-scripts"><code>ignore-scripts</code></a></li><li><a href="#script-shell"><code>script-shell</code></a></li></ul><li><a href="#see-also">See Also</a></li></ul></div>
<div id="_table_of_contents"><ul><li><a href="#synopsis">Synopsis</a></li><li><a href="#description">Description</a></li><li><a href="#example">Example</a></li><li><a href="#configuration">Configuration</a></li><ul><li><a href="#audit"><code>audit</code></a></li><li><a href="#foreground-scripts"><code>foreground-scripts</code></a></li><li><a href="#ignore-scripts"><code>ignore-scripts</code></a></li><li><a href="#script-shell"><code>script-shell</code></a></li></ul><li><a href="#see-also">See Also</a></li></ul></div>
</section>
<div id="_content"><h3 id="synopsis">Synopsis</h3>
@ -214,6 +214,18 @@ documentation for <a href="../commands/npm-audit.html"><code>npm audit</code></a
submitted.</p>
<!-- raw HTML omitted -->
<!-- raw HTML omitted -->
<h4 id="foreground-scripts"><code>foreground-scripts</code></h4>
<ul>
<li>Default: false</li>
<li>Type: Boolean</li>
</ul>
<p>Run all build scripts (ie, <code>preinstall</code>, <code>install</code>, and <code>postinstall</code>)
scripts for installed packages in the foreground process, sharing standard
input, output, and error with the main npm process.</p>
<p>Note that this will generally make installs run slower, and be much noisier,
but can be useful for debugging.</p>
<!-- raw HTML omitted -->
<!-- raw HTML omitted -->
<h4 id="ignore-scripts"><code>ignore-scripts</code></h4>
<ul>
<li>Default: false</li>

View File

@ -294,6 +294,7 @@ range (including SemVer-major changes).</li>
<li>Allow conflicting peerDependencies to be installed in the root project.</li>
<li>Implicitly set <code>--yes</code> during <code>npm init</code>.</li>
<li>Allow clobbering existing values in <code>npm pkg</code></li>
<li>Allow unpublishing of entire packages (not just a single version).</li>
</ul>
<p>If you don't have a clear idea of what you want to do, it is strongly
recommended that you do not use this option!</p>

View File

@ -142,7 +142,7 @@ npm command-line interface
<section id="table_of_contents">
<h2 id="table-of-contents">Table of contents</h2>
<div id="_table_of_contents"><ul><li><a href="#synopsis">Synopsis</a></li><li><a href="#description">Description</a></li><li><a href="#configuration">Configuration</a></li><ul><li><a href="#audit"><code>audit</code></a></li><li><a href="#ignore-scripts"><code>ignore-scripts</code></a></li><li><a href="#script-shell"><code>script-shell</code></a></li></ul><li><a href="#see-also">See Also</a></li></ul></div>
<div id="_table_of_contents"><ul><li><a href="#synopsis">Synopsis</a></li><li><a href="#description">Description</a></li><li><a href="#configuration">Configuration</a></li><ul><li><a href="#audit"><code>audit</code></a></li><li><a href="#foreground-scripts"><code>foreground-scripts</code></a></li><li><a href="#ignore-scripts"><code>ignore-scripts</code></a></li><li><a href="#script-shell"><code>script-shell</code></a></li></ul><li><a href="#see-also">See Also</a></li></ul></div>
</section>
<div id="_content"><h3 id="synopsis">Synopsis</h3>
@ -173,6 +173,18 @@ documentation for <a href="../commands/npm-audit.html"><code>npm audit</code></a
submitted.</p>
<!-- raw HTML omitted -->
<!-- raw HTML omitted -->
<h4 id="foreground-scripts"><code>foreground-scripts</code></h4>
<ul>
<li>Default: false</li>
<li>Type: Boolean</li>
</ul>
<p>Run all build scripts (ie, <code>preinstall</code>, <code>install</code>, and <code>postinstall</code>)
scripts for installed packages in the foreground process, sharing standard
input, output, and error with the main npm process.</p>
<p>Note that this will generally make installs run slower, and be much noisier,
but can be useful for debugging.</p>
<!-- raw HTML omitted -->
<!-- raw HTML omitted -->
<h4 id="ignore-scripts"><code>ignore-scripts</code></h4>
<ul>
<li>Default: false</li>

View File

@ -142,7 +142,7 @@ npm command-line interface
<section id="table_of_contents">
<h2 id="table-of-contents">Table of contents</h2>
<div id="_table_of_contents"><ul><li><a href="#synopsis">Synopsis</a></li><li><a href="#description">Description</a></li><li><a href="#configuration">Configuration</a></li><ul><li><a href="#save"><code>save</code></a></li><li><a href="#save-exact"><code>save-exact</code></a></li><li><a href="#global"><code>global</code></a></li><li><a href="#global-style"><code>global-style</code></a></li><li><a href="#legacy-bundling"><code>legacy-bundling</code></a></li><li><a href="#strict-peer-deps"><code>strict-peer-deps</code></a></li><li><a href="#package-lock"><code>package-lock</code></a></li><li><a href="#omit"><code>omit</code></a></li><li><a href="#ignore-scripts"><code>ignore-scripts</code></a></li><li><a href="#audit"><code>audit</code></a></li><li><a href="#bin-links"><code>bin-links</code></a></li><li><a href="#fund"><code>fund</code></a></li><li><a href="#dry-run"><code>dry-run</code></a></li><li><a href="#workspace"><code>workspace</code></a></li><li><a href="#workspaces"><code>workspaces</code></a></li><li><a href="#include-workspace-root"><code>include-workspace-root</code></a></li></ul><li><a href="#see-also">See Also</a></li></ul></div>
<div id="_table_of_contents"><ul><li><a href="#synopsis">Synopsis</a></li><li><a href="#description">Description</a></li><li><a href="#configuration">Configuration</a></li><ul><li><a href="#save"><code>save</code></a></li><li><a href="#save-exact"><code>save-exact</code></a></li><li><a href="#global"><code>global</code></a></li><li><a href="#global-style"><code>global-style</code></a></li><li><a href="#legacy-bundling"><code>legacy-bundling</code></a></li><li><a href="#omit"><code>omit</code></a></li><li><a href="#strict-peer-deps"><code>strict-peer-deps</code></a></li><li><a href="#package-lock"><code>package-lock</code></a></li><li><a href="#foreground-scripts"><code>foreground-scripts</code></a></li><li><a href="#ignore-scripts"><code>ignore-scripts</code></a></li><li><a href="#audit"><code>audit</code></a></li><li><a href="#bin-links"><code>bin-links</code></a></li><li><a href="#fund"><code>fund</code></a></li><li><a href="#dry-run"><code>dry-run</code></a></li><li><a href="#workspace"><code>workspace</code></a></li><li><a href="#workspaces"><code>workspaces</code></a></li><li><a href="#include-workspace-root"><code>include-workspace-root</code></a></li></ul><li><a href="#see-also">See Also</a></li></ul></div>
</section>
<div id="_content"><h3 id="synopsis">Synopsis</h3>
@ -233,6 +233,22 @@ eliminates all automatic deduping. If used with <code>global-style</code> this o
will be preferred.</p>
<!-- raw HTML omitted -->
<!-- raw HTML omitted -->
<h4 id="omit"><code>omit</code></h4>
<ul>
<li>Default: 'dev' if the <code>NODE_ENV</code> environment variable is set to
'production', otherwise empty.</li>
<li>Type: "dev", "optional", or "peer" (can be set multiple times)</li>
</ul>
<p>Dependency types to omit from the installation tree on disk.</p>
<p>Note that these dependencies <em>are</em> still resolved and added to the
<code>package-lock.json</code> or <code>npm-shrinkwrap.json</code> file. They are just not
physically installed on disk.</p>
<p>If a package type appears in both the <code>--include</code> and <code>--omit</code> lists, then
it will be included.</p>
<p>If the resulting omit list includes <code>'dev'</code>, then the <code>NODE_ENV</code> environment
variable will be set to <code>'production'</code> for all lifecycle scripts.</p>
<!-- raw HTML omitted -->
<!-- raw HTML omitted -->
<h4 id="strict-peer-deps"><code>strict-peer-deps</code></h4>
<ul>
<li>Default: false</li>
@ -264,20 +280,16 @@ package-locks disabled use <code>npm prune</code>.</p>
<p>This configuration does not affect <code>npm ci</code>.</p>
<!-- raw HTML omitted -->
<!-- raw HTML omitted -->
<h4 id="omit"><code>omit</code></h4>
<h4 id="foreground-scripts"><code>foreground-scripts</code></h4>
<ul>
<li>Default: 'dev' if the <code>NODE_ENV</code> environment variable is set to
'production', otherwise empty.</li>
<li>Type: "dev", "optional", or "peer" (can be set multiple times)</li>
<li>Default: false</li>
<li>Type: Boolean</li>
</ul>
<p>Dependency types to omit from the installation tree on disk.</p>
<p>Note that these dependencies <em>are</em> still resolved and added to the
<code>package-lock.json</code> or <code>npm-shrinkwrap.json</code> file. They are just not
physically installed on disk.</p>
<p>If a package type appears in both the <code>--include</code> and <code>--omit</code> lists, then
it will be included.</p>
<p>If the resulting omit list includes <code>'dev'</code>, then the <code>NODE_ENV</code> environment
variable will be set to <code>'production'</code> for all lifecycle scripts.</p>
<p>Run all build scripts (ie, <code>preinstall</code>, <code>install</code>, and <code>postinstall</code>)
scripts for installed packages in the foreground process, sharing standard
input, output, and error with the main npm process.</p>
<p>Note that this will generally make installs run slower, and be much noisier,
but can be useful for debugging.</p>
<!-- raw HTML omitted -->
<!-- raw HTML omitted -->
<h4 id="ignore-scripts"><code>ignore-scripts</code></h4>

View File

@ -142,7 +142,7 @@ npm command-line interface
<section id="table_of_contents">
<h2 id="table-of-contents">Table of contents</h2>
<div id="_table_of_contents"><ul><li><a href="#synopsis">Synopsis</a></li><li><a href="#description">Description</a></li><li><a href="#configuration">Configuration</a></li><ul><li><a href="#save"><code>save</code></a></li><li><a href="#save-exact"><code>save-exact</code></a></li><li><a href="#global"><code>global</code></a></li><li><a href="#global-style"><code>global-style</code></a></li><li><a href="#legacy-bundling"><code>legacy-bundling</code></a></li><li><a href="#strict-peer-deps"><code>strict-peer-deps</code></a></li><li><a href="#package-lock"><code>package-lock</code></a></li><li><a href="#omit"><code>omit</code></a></li><li><a href="#ignore-scripts"><code>ignore-scripts</code></a></li><li><a href="#audit"><code>audit</code></a></li><li><a href="#bin-links"><code>bin-links</code></a></li><li><a href="#fund"><code>fund</code></a></li><li><a href="#dry-run"><code>dry-run</code></a></li><li><a href="#workspace"><code>workspace</code></a></li><li><a href="#workspaces"><code>workspaces</code></a></li><li><a href="#include-workspace-root"><code>include-workspace-root</code></a></li></ul><li><a href="#algorithm">Algorithm</a></li><li><a href="#see-also">See Also</a></li></ul></div>
<div id="_table_of_contents"><ul><li><a href="#synopsis">Synopsis</a></li><li><a href="#description">Description</a></li><li><a href="#configuration">Configuration</a></li><ul><li><a href="#save"><code>save</code></a></li><li><a href="#save-exact"><code>save-exact</code></a></li><li><a href="#global"><code>global</code></a></li><li><a href="#global-style"><code>global-style</code></a></li><li><a href="#legacy-bundling"><code>legacy-bundling</code></a></li><li><a href="#omit"><code>omit</code></a></li><li><a href="#strict-peer-deps"><code>strict-peer-deps</code></a></li><li><a href="#package-lock"><code>package-lock</code></a></li><li><a href="#foreground-scripts"><code>foreground-scripts</code></a></li><li><a href="#ignore-scripts"><code>ignore-scripts</code></a></li><li><a href="#audit"><code>audit</code></a></li><li><a href="#bin-links"><code>bin-links</code></a></li><li><a href="#fund"><code>fund</code></a></li><li><a href="#dry-run"><code>dry-run</code></a></li><li><a href="#workspace"><code>workspace</code></a></li><li><a href="#workspaces"><code>workspaces</code></a></li><li><a href="#include-workspace-root"><code>include-workspace-root</code></a></li></ul><li><a href="#algorithm">Algorithm</a></li><li><a href="#see-also">See Also</a></li></ul></div>
</section>
<div id="_content"><h3 id="synopsis">Synopsis</h3>
@ -160,7 +160,7 @@ npm install &lt;tarball url&gt;
npm install &lt;git:// url&gt;
npm install &lt;github username&gt;/&lt;github project&gt;
aliases: i, in, ins, inst, insta, instal, isnt, isnta, isntal, add
aliases: i, in, ins, inst, insta, instal, isnt, isnta, isntal, isntall, add
</code></pre>
<!-- raw HTML omitted -->
<!-- raw HTML omitted -->
@ -559,6 +559,22 @@ eliminates all automatic deduping. If used with <code>global-style</code> this o
will be preferred.</p>
<!-- raw HTML omitted -->
<!-- raw HTML omitted -->
<h4 id="omit"><code>omit</code></h4>
<ul>
<li>Default: 'dev' if the <code>NODE_ENV</code> environment variable is set to
'production', otherwise empty.</li>
<li>Type: "dev", "optional", or "peer" (can be set multiple times)</li>
</ul>
<p>Dependency types to omit from the installation tree on disk.</p>
<p>Note that these dependencies <em>are</em> still resolved and added to the
<code>package-lock.json</code> or <code>npm-shrinkwrap.json</code> file. They are just not
physically installed on disk.</p>
<p>If a package type appears in both the <code>--include</code> and <code>--omit</code> lists, then
it will be included.</p>
<p>If the resulting omit list includes <code>'dev'</code>, then the <code>NODE_ENV</code> environment
variable will be set to <code>'production'</code> for all lifecycle scripts.</p>
<!-- raw HTML omitted -->
<!-- raw HTML omitted -->
<h4 id="strict-peer-deps"><code>strict-peer-deps</code></h4>
<ul>
<li>Default: false</li>
@ -590,20 +606,16 @@ package-locks disabled use <code>npm prune</code>.</p>
<p>This configuration does not affect <code>npm ci</code>.</p>
<!-- raw HTML omitted -->
<!-- raw HTML omitted -->
<h4 id="omit"><code>omit</code></h4>
<h4 id="foreground-scripts"><code>foreground-scripts</code></h4>
<ul>
<li>Default: 'dev' if the <code>NODE_ENV</code> environment variable is set to
'production', otherwise empty.</li>
<li>Type: "dev", "optional", or "peer" (can be set multiple times)</li>
<li>Default: false</li>
<li>Type: Boolean</li>
</ul>
<p>Dependency types to omit from the installation tree on disk.</p>
<p>Note that these dependencies <em>are</em> still resolved and added to the
<code>package-lock.json</code> or <code>npm-shrinkwrap.json</code> file. They are just not
physically installed on disk.</p>
<p>If a package type appears in both the <code>--include</code> and <code>--omit</code> lists, then
it will be included.</p>
<p>If the resulting omit list includes <code>'dev'</code>, then the <code>NODE_ENV</code> environment
variable will be set to <code>'production'</code> for all lifecycle scripts.</p>
<p>Run all build scripts (ie, <code>preinstall</code>, <code>install</code>, and <code>postinstall</code>)
scripts for installed packages in the foreground process, sharing standard
input, output, and error with the main npm process.</p>
<p>Note that this will generally make installs run slower, and be much noisier,
but can be useful for debugging.</p>
<!-- raw HTML omitted -->
<!-- raw HTML omitted -->
<h4 id="ignore-scripts"><code>ignore-scripts</code></h4>

View File

@ -166,7 +166,7 @@ tree at all, use <a href="../commands/npm-explain.html"><code>npm explain</code>
the results to only the paths to the packages named. Note that nested
packages will <em>also</em> show the paths to the specified packages. For
example, running <code>npm ls promzard</code> in npm's source tree will show:</p>
<pre lang="bash"><code>npm@8.5.3 /path/to/npm
<pre lang="bash"><code>npm@8.5.5 /path/to/npm
└─┬ init-package-json@0.0.4
└── promzard@0.1.5
</code></pre>

View File

@ -152,6 +152,8 @@ npm command-line interface
<pre lang="bash"><code>npm pkg set &lt;key&gt;=&lt;value&gt; [&lt;key&gt;=&lt;value&gt; ...]
npm pkg get [&lt;key&gt; [&lt;key&gt; ...]]
npm pkg delete &lt;key&gt; [&lt;key&gt; ...]
npm pkg set [&lt;array&gt;[&lt;index&gt;].&lt;key&gt;=&lt;value&gt; ...]
npm pkg set [&lt;array&gt;[].&lt;key&gt;=&lt;value&gt; ...]
</code></pre>
<!-- raw HTML omitted -->
<!-- raw HTML omitted -->
@ -284,6 +286,7 @@ range (including SemVer-major changes).</li>
<li>Allow conflicting peerDependencies to be installed in the root project.</li>
<li>Implicitly set <code>--yes</code> during <code>npm init</code>.</li>
<li>Allow clobbering existing values in <code>npm pkg</code></li>
<li>Allow unpublishing of entire packages (not just a single version).</li>
</ul>
<p>If you don't have a clear idea of what you want to do, it is strongly
recommended that you do not use this option!</p>

View File

@ -142,7 +142,7 @@ npm command-line interface
<section id="table_of_contents">
<h2 id="table-of-contents">Table of contents</h2>
<div id="_table_of_contents"><ul><li><a href="#synopsis">Synopsis</a></li><li><a href="#description">Description</a></li><li><a href="#configuration">Configuration</a></li><ul><li><a href="#omit"><code>omit</code></a></li><li><a href="#dry-run"><code>dry-run</code></a></li><li><a href="#json"><code>json</code></a></li><li><a href="#workspace"><code>workspace</code></a></li><li><a href="#workspaces"><code>workspaces</code></a></li><li><a href="#include-workspace-root"><code>include-workspace-root</code></a></li></ul><li><a href="#see-also">See Also</a></li></ul></div>
<div id="_table_of_contents"><ul><li><a href="#synopsis">Synopsis</a></li><li><a href="#description">Description</a></li><li><a href="#configuration">Configuration</a></li><ul><li><a href="#omit"><code>omit</code></a></li><li><a href="#dry-run"><code>dry-run</code></a></li><li><a href="#json"><code>json</code></a></li><li><a href="#foreground-scripts"><code>foreground-scripts</code></a></li><li><a href="#ignore-scripts"><code>ignore-scripts</code></a></li><li><a href="#workspace"><code>workspace</code></a></li><li><a href="#workspaces"><code>workspaces</code></a></li><li><a href="#include-workspace-root"><code>include-workspace-root</code></a></li></ul><li><a href="#see-also">See Also</a></li></ul></div>
</section>
<div id="_content"><h3 id="synopsis">Synopsis</h3>
@ -216,6 +216,30 @@ saving them to your <code>package.json</code>.</li>
<p>Not supported by all npm commands.</p>
<!-- raw HTML omitted -->
<!-- raw HTML omitted -->
<h4 id="foreground-scripts"><code>foreground-scripts</code></h4>
<ul>
<li>Default: false</li>
<li>Type: Boolean</li>
</ul>
<p>Run all build scripts (ie, <code>preinstall</code>, <code>install</code>, and <code>postinstall</code>)
scripts for installed packages in the foreground process, sharing standard
input, output, and error with the main npm process.</p>
<p>Note that this will generally make installs run slower, and be much noisier,
but can be useful for debugging.</p>
<!-- raw HTML omitted -->
<!-- raw HTML omitted -->
<h4 id="ignore-scripts"><code>ignore-scripts</code></h4>
<ul>
<li>Default: false</li>
<li>Type: Boolean</li>
</ul>
<p>If true, npm does not run scripts specified in package.json files.</p>
<p>Note that commands explicitly intended to run a particular script, such as
<code>npm start</code>, <code>npm stop</code>, <code>npm restart</code>, <code>npm test</code>, and <code>npm run-script</code>
will still run their intended script if <code>ignore-scripts</code> is set, but they
will <em>not</em> run any pre- or post-scripts.</p>
<!-- raw HTML omitted -->
<!-- raw HTML omitted -->
<h4 id="workspace"><code>workspace</code></h4>
<ul>
<li>Default:</li>

View File

@ -142,7 +142,7 @@ npm command-line interface
<section id="table_of_contents">
<h2 id="table-of-contents">Table of contents</h2>
<div id="_table_of_contents"><ul><li><a href="#synopsis">Synopsis</a></li><li><a href="#description">Description</a></li><li><a href="#configuration">Configuration</a></li><ul><li><a href="#global"><code>global</code></a></li><li><a href="#bin-links"><code>bin-links</code></a></li><li><a href="#ignore-scripts"><code>ignore-scripts</code></a></li><li><a href="#workspace"><code>workspace</code></a></li><li><a href="#workspaces"><code>workspaces</code></a></li><li><a href="#include-workspace-root"><code>include-workspace-root</code></a></li></ul><li><a href="#see-also">See Also</a></li></ul></div>
<div id="_table_of_contents"><ul><li><a href="#synopsis">Synopsis</a></li><li><a href="#description">Description</a></li><li><a href="#configuration">Configuration</a></li><ul><li><a href="#global"><code>global</code></a></li><li><a href="#bin-links"><code>bin-links</code></a></li><li><a href="#foreground-scripts"><code>foreground-scripts</code></a></li><li><a href="#ignore-scripts"><code>ignore-scripts</code></a></li><li><a href="#workspace"><code>workspace</code></a></li><li><a href="#workspaces"><code>workspaces</code></a></li><li><a href="#include-workspace-root"><code>include-workspace-root</code></a></li></ul><li><a href="#see-also">See Also</a></li></ul></div>
</section>
<div id="_content"><h3 id="synopsis">Synopsis</h3>
@ -197,6 +197,18 @@ fact that some file systems don't support symlinks, even on ostensibly Unix
systems.</p>
<!-- raw HTML omitted -->
<!-- raw HTML omitted -->
<h4 id="foreground-scripts"><code>foreground-scripts</code></h4>
<ul>
<li>Default: false</li>
<li>Type: Boolean</li>
</ul>
<p>Run all build scripts (ie, <code>preinstall</code>, <code>install</code>, and <code>postinstall</code>)
scripts for installed packages in the foreground process, sharing standard
input, output, and error with the main npm process.</p>
<p>Note that this will generally make installs run slower, and be much noisier,
but can be useful for debugging.</p>
<!-- raw HTML omitted -->
<!-- raw HTML omitted -->
<h4 id="ignore-scripts"><code>ignore-scripts</code></h4>
<ul>
<li>Default: false</li>

View File

@ -142,17 +142,19 @@ npm command-line interface
<section id="table_of_contents">
<h2 id="table-of-contents">Table of contents</h2>
<div id="_table_of_contents"><ul><li><a href="#synopsis">Synopsis</a></li><ul><li><a href="#unpublishing-a-single-version-of-a-package">Unpublishing a single version of a package</a></li><li><a href="#unpublishing-an-entire-package">Unpublishing an entire package</a></li></ul><li><a href="#warning">Warning</a></li><li><a href="#description">Description</a></li><li><a href="#configuration">Configuration</a></li><ul><li><a href="#dry-run"><code>dry-run</code></a></li><li><a href="#force"><code>force</code></a></li><li><a href="#workspace"><code>workspace</code></a></li><li><a href="#workspaces"><code>workspaces</code></a></li></ul><li><a href="#see-also">See Also</a></li></ul></div>
<div id="_table_of_contents"><ul><li><a href="#synopsis">Synopsis</a></li><li><a href="#warning">Warning</a></li><li><a href="#description">Description</a></li><li><a href="#configuration">Configuration</a></li><ul><li><a href="#dry-run"><code>dry-run</code></a></li><li><a href="#force"><code>force</code></a></li><li><a href="#workspace"><code>workspace</code></a></li><li><a href="#workspaces"><code>workspaces</code></a></li></ul><li><a href="#see-also">See Also</a></li></ul></div>
</section>
<div id="_content"><h3 id="synopsis">Synopsis</h3>
<!-- raw HTML omitted -->
<!-- raw HTML omitted -->
<!-- raw HTML omitted -->
<pre lang="bash"><code>npm unpublish [&lt;@scope&gt;/]&lt;pkg&gt;[@&lt;version&gt;]
</code></pre>
<!-- raw HTML omitted -->
<!-- raw HTML omitted -->
<!-- raw HTML omitted -->
<p>To learn more about how the npm registry treats unpublish, see our <!-- raw HTML omitted --> unpublish policies<!-- raw HTML omitted --></p>
<h4 id="unpublishing-a-single-version-of-a-package">Unpublishing a single version of a package</h4>
<pre lang="bash"><code>npm unpublish [&lt;@scope&gt;/]&lt;pkg&gt;@&lt;version&gt;
</code></pre>
<h4 id="unpublishing-an-entire-package">Unpublishing an entire package</h4>
<pre lang="bash"><code>npm unpublish [&lt;@scope&gt;/]&lt;pkg&gt; --force
</code></pre>
<h3 id="warning">Warning</h3>
<p>Consider using the <a href="../commands/npm-deprecate.html"><code>deprecate</code></a> command instead,
if your intent is to encourage users to upgrade, or if you no longer
@ -207,6 +209,7 @@ range (including SemVer-major changes).</li>
<li>Allow conflicting peerDependencies to be installed in the root project.</li>
<li>Implicitly set <code>--yes</code> during <code>npm init</code>.</li>
<li>Allow clobbering existing values in <code>npm pkg</code></li>
<li>Allow unpublishing of entire packages (not just a single version).</li>
</ul>
<p>If you don't have a clear idea of what you want to do, it is strongly
recommended that you do not use this option!</p>

View File

@ -142,7 +142,7 @@ npm command-line interface
<section id="table_of_contents">
<h2 id="table-of-contents">Table of contents</h2>
<div id="_table_of_contents"><ul><li><a href="#synopsis">Synopsis</a></li><li><a href="#description">Description</a></li><li><a href="#example">Example</a></li><ul><li><a href="#caret-dependencies">Caret Dependencies</a></li><li><a href="#tilde-dependencies">Tilde Dependencies</a></li><li><a href="#caret-dependencies-below-100">Caret Dependencies below 1.0.0</a></li><li><a href="#subdependencies">Subdependencies</a></li><li><a href="#updating-globally-installed-packages">Updating Globally-Installed Packages</a></li></ul><li><a href="#configuration">Configuration</a></li><ul><li><a href="#global"><code>global</code></a></li><li><a href="#global-style"><code>global-style</code></a></li><li><a href="#legacy-bundling"><code>legacy-bundling</code></a></li><li><a href="#strict-peer-deps"><code>strict-peer-deps</code></a></li><li><a href="#package-lock"><code>package-lock</code></a></li><li><a href="#save"><code>save</code></a></li><li><a href="#omit"><code>omit</code></a></li><li><a href="#ignore-scripts"><code>ignore-scripts</code></a></li><li><a href="#audit"><code>audit</code></a></li><li><a href="#bin-links"><code>bin-links</code></a></li><li><a href="#fund"><code>fund</code></a></li><li><a href="#dry-run"><code>dry-run</code></a></li><li><a href="#workspace"><code>workspace</code></a></li><li><a href="#workspaces"><code>workspaces</code></a></li><li><a href="#include-workspace-root"><code>include-workspace-root</code></a></li></ul><li><a href="#see-also">See Also</a></li></ul></div>
<div id="_table_of_contents"><ul><li><a href="#synopsis">Synopsis</a></li><li><a href="#description">Description</a></li><li><a href="#example">Example</a></li><ul><li><a href="#caret-dependencies">Caret Dependencies</a></li><li><a href="#tilde-dependencies">Tilde Dependencies</a></li><li><a href="#caret-dependencies-below-100">Caret Dependencies below 1.0.0</a></li><li><a href="#subdependencies">Subdependencies</a></li><li><a href="#updating-globally-installed-packages">Updating Globally-Installed Packages</a></li></ul><li><a href="#configuration">Configuration</a></li><ul><li><a href="#save"><code>save</code></a></li><li><a href="#global"><code>global</code></a></li><li><a href="#global-style"><code>global-style</code></a></li><li><a href="#legacy-bundling"><code>legacy-bundling</code></a></li><li><a href="#omit"><code>omit</code></a></li><li><a href="#strict-peer-deps"><code>strict-peer-deps</code></a></li><li><a href="#package-lock"><code>package-lock</code></a></li><li><a href="#foreground-scripts"><code>foreground-scripts</code></a></li><li><a href="#ignore-scripts"><code>ignore-scripts</code></a></li><li><a href="#audit"><code>audit</code></a></li><li><a href="#bin-links"><code>bin-links</code></a></li><li><a href="#fund"><code>fund</code></a></li><li><a href="#dry-run"><code>dry-run</code></a></li><li><a href="#workspace"><code>workspace</code></a></li><li><a href="#workspaces"><code>workspaces</code></a></li><li><a href="#include-workspace-root"><code>include-workspace-root</code></a></li></ul><li><a href="#see-also">See Also</a></li></ul></div>
</section>
<div id="_content"><h3 id="synopsis">Synopsis</h3>
@ -260,6 +260,18 @@ be <em>downgraded</em>.</p>
<!-- raw HTML omitted -->
<!-- raw HTML omitted -->
<!-- raw HTML omitted -->
<h4 id="save"><code>save</code></h4>
<ul>
<li>Default: <code>true</code> unless when using <code>npm update</code> or <code>npm dedupe</code> where it
defaults to <code>false</code></li>
<li>Type: Boolean</li>
</ul>
<p>Save installed packages to a <code>package.json</code> file as dependencies.</p>
<p>When used with the <code>npm rm</code> command, removes the dependency from
<code>package.json</code>.</p>
<p>Will also prevent writing to <code>package-lock.json</code> if set to <code>false</code>.</p>
<!-- raw HTML omitted -->
<!-- raw HTML omitted -->
<h4 id="global"><code>global</code></h4>
<ul>
<li>Default: false</li>
@ -300,6 +312,22 @@ eliminates all automatic deduping. If used with <code>global-style</code> this o
will be preferred.</p>
<!-- raw HTML omitted -->
<!-- raw HTML omitted -->
<h4 id="omit"><code>omit</code></h4>
<ul>
<li>Default: 'dev' if the <code>NODE_ENV</code> environment variable is set to
'production', otherwise empty.</li>
<li>Type: "dev", "optional", or "peer" (can be set multiple times)</li>
</ul>
<p>Dependency types to omit from the installation tree on disk.</p>
<p>Note that these dependencies <em>are</em> still resolved and added to the
<code>package-lock.json</code> or <code>npm-shrinkwrap.json</code> file. They are just not
physically installed on disk.</p>
<p>If a package type appears in both the <code>--include</code> and <code>--omit</code> lists, then
it will be included.</p>
<p>If the resulting omit list includes <code>'dev'</code>, then the <code>NODE_ENV</code> environment
variable will be set to <code>'production'</code> for all lifecycle scripts.</p>
<!-- raw HTML omitted -->
<!-- raw HTML omitted -->
<h4 id="strict-peer-deps"><code>strict-peer-deps</code></h4>
<ul>
<li>Default: false</li>
@ -331,32 +359,16 @@ package-locks disabled use <code>npm prune</code>.</p>
<p>This configuration does not affect <code>npm ci</code>.</p>
<!-- raw HTML omitted -->
<!-- raw HTML omitted -->
<h4 id="save"><code>save</code></h4>
<h4 id="foreground-scripts"><code>foreground-scripts</code></h4>
<ul>
<li>Default: <code>true</code> unless when using <code>npm update</code> or <code>npm dedupe</code> where it
defaults to <code>false</code></li>
<li>Default: false</li>
<li>Type: Boolean</li>
</ul>
<p>Save installed packages to a <code>package.json</code> file as dependencies.</p>
<p>When used with the <code>npm rm</code> command, removes the dependency from
<code>package.json</code>.</p>
<p>Will also prevent writing to <code>package-lock.json</code> if set to <code>false</code>.</p>
<!-- raw HTML omitted -->
<!-- raw HTML omitted -->
<h4 id="omit"><code>omit</code></h4>
<ul>
<li>Default: 'dev' if the <code>NODE_ENV</code> environment variable is set to
'production', otherwise empty.</li>
<li>Type: "dev", "optional", or "peer" (can be set multiple times)</li>
</ul>
<p>Dependency types to omit from the installation tree on disk.</p>
<p>Note that these dependencies <em>are</em> still resolved and added to the
<code>package-lock.json</code> or <code>npm-shrinkwrap.json</code> file. They are just not
physically installed on disk.</p>
<p>If a package type appears in both the <code>--include</code> and <code>--omit</code> lists, then
it will be included.</p>
<p>If the resulting omit list includes <code>'dev'</code>, then the <code>NODE_ENV</code> environment
variable will be set to <code>'production'</code> for all lifecycle scripts.</p>
<p>Run all build scripts (ie, <code>preinstall</code>, <code>install</code>, and <code>postinstall</code>)
scripts for installed packages in the foreground process, sharing standard
input, output, and error with the main npm process.</p>
<p>Note that this will generally make installs run slower, and be much noisier,
but can be useful for debugging.</p>
<!-- raw HTML omitted -->
<!-- raw HTML omitted -->
<h4 id="ignore-scripts"><code>ignore-scripts</code></h4>

View File

@ -182,7 +182,8 @@ to the same value as the current version.</p>
<li>Default: true</li>
<li>Type: Boolean</li>
</ul>
<p>Tag the commit when using the <code>npm version</code> command.</p>
<p>Tag the commit when using the <code>npm version</code> command. Setting this to false
results in no commit being made at all.</p>
<!-- raw HTML omitted -->
<!-- raw HTML omitted -->
<h4 id="json"><code>json</code></h4>

View File

@ -149,7 +149,7 @@ npm command-line interface
<!-- raw HTML omitted -->
<!-- raw HTML omitted -->
<h3 id="version">Version</h3>
<p>8.5.3</p>
<p>8.5.5</p>
<h3 id="description">Description</h3>
<p>npm is the package manager for the Node JavaScript platform. It puts
modules in place so that node can find them, and manages dependency

View File

@ -391,7 +391,7 @@ be returned.</p>
<p>This should be a module relative to the root of your package folder.</p>
<p>For most modules, it makes the most sense to have a main script and often
not much else.</p>
<p>If <code>main</code> is not set it defaults to <code>index.js</code> in the packages root folder.</p>
<p>If <code>main</code> is not set it defaults to <code>index.js</code> in the package's root folder.</p>
<h3 id="browser">browser</h3>
<p>If your module is meant to be used client-side the browser field should be
used instead of the main field. This is helpful to hint users that it might
@ -663,6 +663,9 @@ contains a package. Local paths can be saved using <code>npm install -S</code> o
<p>This feature is helpful for local offline development and creating tests
that require npm installing where you don't want to hit an external server,
but should not be used when publishing packages to the public registry.</p>
<p><em>note</em>: Packages linked by local path will not have their own
dependencies installed when <code>npm install</code> is ran in this case. You must
run <code>npm install</code> from inside the local path itself.</p>
<h3 id="devdependencies">devDependencies</h3>
<p>If someone is planning on downloading and using your module in their
program, then they probably don't want or need to download and build the

View File

@ -639,6 +639,7 @@ range (including SemVer-major changes).</li>
<li>Allow conflicting peerDependencies to be installed in the root project.</li>
<li>Implicitly set <code>--yes</code> during <code>npm init</code>.</li>
<li>Allow clobbering existing values in <code>npm pkg</code></li>
<li>Allow unpublishing of entire packages (not just a single version).</li>
</ul>
<p>If you don't have a clear idea of what you want to do, it is strongly
recommended that you do not use this option!</p>
@ -688,7 +689,8 @@ but is not in the <code>PATH</code>, then set this to the full path to the git b
<li>Default: true</li>
<li>Type: Boolean</li>
</ul>
<p>Tag the commit when using the <code>npm version</code> command.</p>
<p>Tag the commit when using the <code>npm version</code> command. Setting this to false
results in no commit being made at all.</p>
<!-- raw HTML omitted -->
<!-- raw HTML omitted -->
<h4 id="global"><code>global</code></h4>

View File

@ -14,6 +14,8 @@ class Audit extends ArboristWorkspaceCmd {
'json',
'package-lock-only',
'omit',
'foreground-scripts',
'ignore-scripts',
...super.params,
]

View File

@ -24,6 +24,7 @@ class CI extends ArboristWorkspaceCmd {
static name = 'ci'
static params = [
'audit',
'foreground-scripts',
'ignore-scripts',
'script-shell',
]

View File

@ -10,7 +10,6 @@ const semver = require('semver')
const { promisify } = require('util')
const log = require('../utils/log-shim.js')
const ansiTrim = require('../utils/ansi-trim.js')
const isWindows = require('../utils/is-windows.js')
const ping = require('../utils/ping.js')
const {
registry: { default: defaultRegistry },
@ -55,32 +54,36 @@ class Doctor extends BaseCommand {
['node -v', 'getLatestNodejsVersion', []],
['npm config get registry', 'checkNpmRegistry', []],
['which git', 'getGitPath', []],
...(isWindows
...(process.platform === 'win32'
? []
: [
['Perms check on cached files', 'checkFilesPermission', [this.npm.cache, true, R_OK]],
[
'Perms check on cached files',
'checkFilesPermission',
[this.npm.cache, true, R_OK],
], [
'Perms check on local node_modules',
'checkFilesPermission',
[this.npm.localDir, true],
],
[
[this.npm.localDir, true, R_OK | W_OK, true],
], [
'Perms check on global node_modules',
'checkFilesPermission',
[this.npm.globalDir, false],
],
[
[this.npm.globalDir, false, R_OK],
], [
'Perms check on local bin folder',
'checkFilesPermission',
[this.npm.localBin, false, R_OK | W_OK | X_OK],
],
[
[this.npm.localBin, false, R_OK | W_OK | X_OK, true],
], [
'Perms check on global bin folder',
'checkFilesPermission',
[this.npm.globalBin, false, X_OK],
],
]),
['Verify cache contents', 'verifyCachedFiles', [this.npm.flatOptions.cache]],
[
'Verify cache contents',
'verifyCachedFiles',
[this.npm.flatOptions.cache],
],
// TODO:
// - ensure arborist.loadActual() runs without errors and no invalid edges
// - ensure package-lock.json matches loadActual()
@ -129,6 +132,7 @@ class Doctor extends BaseCommand {
if (!this.npm.silent) {
this.npm.output(table(outTable, tableOpts))
if (!allOk) {
// TODO is this really needed?
console.error('')
}
}
@ -141,7 +145,7 @@ class Doctor extends BaseCommand {
const tracker = log.newItem('checkPing', 1)
tracker.info('checkPing', 'Pinging registry')
try {
await ping(this.npm.flatOptions)
await ping({ ...this.npm.flatOptions, retry: false })
return ''
} catch (er) {
if (/^E\d{3}$/.test(er.code || '')) {
@ -201,11 +205,7 @@ class Doctor extends BaseCommand {
}
}
async checkFilesPermission (root, shouldOwn, mask = null) {
if (mask === null) {
mask = shouldOwn ? R_OK | W_OK : R_OK
}
async checkFilesPermission (root, shouldOwn, mask, missingOk) {
let ok = true
const tracker = log.newItem(root, 1)
@ -217,8 +217,11 @@ class Doctor extends BaseCommand {
for (const f of files) {
tracker.silly('checkFilesPermission', f.substr(root.length + 1))
const st = await lstat(f).catch(er => {
ok = false
tracker.warn('checkFilesPermission', 'error getting info for ' + f)
// if it can't be missing, or if it can and the error wasn't that it was missing
if (!missingOk || er.code !== 'ENOENT') {
ok = false
tracker.warn('checkFilesPermission', 'error getting info for ' + f)
}
})
tracker.completeWork(1)

View File

@ -14,15 +14,18 @@ const ArboristWorkspaceCmd = require('../arborist-cmd.js')
class Install extends ArboristWorkspaceCmd {
static description = 'Install a package'
static name = 'install'
// These are in the order they will show up in when running "-h"
static params = [
'save',
'save-exact',
'global',
'global-style',
'legacy-bundling',
'omit',
'strict-peer-deps',
'package-lock',
'omit',
'foreground-scripts',
'ignore-scripts',
'audit',
'bin-links',

View File

@ -59,60 +59,39 @@ class Owner extends BaseCommand {
}
async exec ([action, ...args]) {
const opts = {
...this.npm.flatOptions,
}
switch (action) {
case 'ls':
case 'list':
return this.ls(args[0], opts)
return this.ls(args[0])
case 'add':
return this.add(args[0], args[1], opts)
return this.changeOwners(args[0], args[1], 'add')
case 'rm':
case 'remove':
return this.rm(args[0], args[1], opts)
return this.changeOwners(args[0], args[1], 'rm')
default:
throw this.usageError()
}
}
async ls (pkg, opts) {
if (!pkg) {
if (this.npm.config.get('global')) {
throw this.usageError()
}
const pkgName = await readLocalPkgName(this.npm.prefix)
if (!pkgName) {
throw this.usageError()
}
pkg = pkgName
}
async ls (pkg) {
pkg = await this.getPkg(pkg)
const spec = npa(pkg)
try {
const packumentOpts = { ...opts, fullMetadata: true }
const packumentOpts = { ...this.npm.flatOptions, fullMetadata: true, preferOnline: true }
const { maintainers } = await pacote.packument(spec, packumentOpts)
if (!maintainers || !maintainers.length) {
this.npm.output('no admin found')
} else {
this.npm.output(maintainers.map(o => `${o.name} <${o.email}>`).join('\n'))
this.npm.output(maintainers.map(m => `${m.name} <${m.email}>`).join('\n'))
}
return maintainers
} catch (err) {
log.error('owner ls', "Couldn't get owner data", pkg)
throw err
}
}
async add (user, pkg, opts) {
if (!user) {
throw this.usageError()
}
async getPkg (pkg) {
if (!pkg) {
if (this.npm.config.get('global')) {
throw this.usageError()
@ -122,44 +101,25 @@ class Owner extends BaseCommand {
throw this.usageError()
}
pkg = pkgName
return pkgName
}
log.verbose('owner add', '%s to %s', user, pkg)
const spec = npa(pkg)
return this.putOwners(spec, user, opts,
(newOwner, owners) => this.validateAddOwner(newOwner, owners))
return pkg
}
async rm (user, pkg, opts) {
async changeOwners (user, pkg, addOrRm) {
if (!user) {
throw this.usageError()
}
if (!pkg) {
if (this.npm.config.get('global')) {
throw this.usageError()
}
const pkgName = await readLocalPkgName(this.npm.prefix)
if (!pkgName) {
throw this.usageError()
}
pkg = pkgName
}
log.verbose('owner rm', '%s from %s', user, pkg)
pkg = await this.getPkg(pkg)
log.verbose(`owner ${addOrRm}`, '%s to %s', user, pkg)
const spec = npa(pkg)
return this.putOwners(spec, user, opts,
(rmOwner, owners) => this.validateRmOwner(rmOwner, owners))
}
async putOwners (spec, user, opts, validation) {
const uri = `/-/user/org.couchdb.user:${encodeURIComponent(user)}`
let u = ''
let u
try {
u = await npmFetch.json(uri, opts)
u = await npmFetch.json(uri, this.npm.flatOptions)
} catch (err) {
log.error('owner mutate', `Error getting user data for ${user}`)
throw err
@ -177,36 +137,64 @@ class Owner extends BaseCommand {
// normalize user data
u = { name: u.name, email: u.email }
const data = await pacote.packument(spec, { ...opts, fullMetadata: true })
const data = await pacote.packument(spec, {
...this.npm.flatOptions,
fullMetadata: true,
preferOnline: true,
})
// save the number of maintainers before validation for comparison
const before = data.maintainers ? data.maintainers.length : 0
const owners = data.maintainers || []
let maintainers
if (addOrRm === 'add') {
const existing = owners.find(o => o.name === u.name)
if (existing) {
log.info(
'owner add',
`Already a package owner: ${existing.name} <${existing.email}>`
)
return
}
maintainers = [
...owners,
u,
]
} else {
maintainers = owners.filter(o => o.name !== u.name)
const m = validation(u, data.maintainers)
if (!m) {
return
} // invalid owners
if (maintainers.length === owners.length) {
log.info('owner rm', 'Not a package owner: ' + u.name)
return false
}
const body = {
_id: data._id,
_rev: data._rev,
maintainers: m,
if (!maintainers.length) {
throw Object.assign(
new Error(
'Cannot remove all owners of a package. Add someone else first.'
),
{ code: 'EOWNERRM' }
)
}
}
const dataPath = `/${spec.escapedName}/-rev/${encodeURIComponent(data._rev)}`
const res = await otplease(opts, opts => {
const res = await otplease(this.npm.flatOptions, opts => {
return npmFetch.json(dataPath, {
...opts,
method: 'PUT',
body,
body: {
_id: data._id,
_rev: data._rev,
maintainers,
},
spec,
})
})
if (!res.error) {
if (m.length < before) {
this.npm.output(`- ${user} (${spec.name})`)
} else {
if (addOrRm === 'add') {
this.npm.output(`+ ${user} (${spec.name})`)
} else {
this.npm.output(`- ${user} (${spec.name})`)
}
} else {
throw Object.assign(
@ -216,47 +204,6 @@ class Owner extends BaseCommand {
}
return res
}
validateAddOwner (newOwner, owners) {
owners = owners || []
for (const o of owners) {
if (o.name === newOwner.name) {
log.info(
'owner add',
'Already a package owner: ' + o.name + ' <' + o.email + '>'
)
return false
}
}
return [
...owners,
newOwner,
]
}
validateRmOwner (rmOwner, owners) {
let found = false
const m = owners.filter(function (o) {
var match = (o.name === rmOwner.name)
found = found || match
return !match
})
if (!found) {
log.info('owner rm', 'Not a package owner: ' + rmOwner.name)
return false
}
if (!m.length) {
throw Object.assign(
new Error(
'Cannot remove all owners of a package. Add someone else first.'
),
{ code: 'EOWNERRM' }
)
}
return m
}
}
module.exports = Owner

View File

@ -6,7 +6,15 @@ const ArboristWorkspaceCmd = require('../arborist-cmd.js')
class Prune extends ArboristWorkspaceCmd {
static description = 'Remove extraneous packages'
static name = 'prune'
static params = ['omit', 'dry-run', 'json', ...super.params]
static params = [
'omit',
'dry-run',
'json',
'foreground-scripts',
'ignore-scripts',
...super.params,
]
static usage = ['[[<@scope>/]<pkg>...]']
async exec () {

View File

@ -11,6 +11,7 @@ class Rebuild extends ArboristWorkspaceCmd {
static params = [
'global',
'bin-links',
'foreground-scripts',
'ignore-scripts',
...super.params,
]

View File

@ -10,14 +10,16 @@ const ArboristWorkspaceCmd = require('../arborist-cmd.js')
class Update extends ArboristWorkspaceCmd {
static description = 'Update packages'
static name = 'update'
static params = [
'save',
'global',
'global-style',
'legacy-bundling',
'omit',
'strict-peer-deps',
'package-lock',
'save',
'omit',
'foreground-scripts',
'ignore-scripts',
'audit',
'bin-links',

View File

@ -103,6 +103,7 @@ class View extends BaseCommand {
// put the version back if it existed
pkg = `${manifest.name}${pkg.slice(1)}`
}
let wholePackument = false
if (!args.length) {
args = ['']
@ -196,7 +197,7 @@ class View extends BaseCommand {
// get the data about this package
let version = this.npm.config.get('tag')
// rawSpec is the git url if this is from git
if (spec.type !== 'git' && spec.rawSpec) {
if (spec.type !== 'git' && spec.type !== 'directory' && spec.rawSpec) {
version = spec.rawSpec
}
@ -205,10 +206,9 @@ class View extends BaseCommand {
if (pckmnt['dist-tags'] && pckmnt['dist-tags'][version]) {
version = pckmnt['dist-tags'][version]
}
if (pckmnt.time && pckmnt.time.unpublished) {
const u = pckmnt.time.unpublished
const er = new Error('Unpublished by ' + u.name + ' on ' + u.time)
const er = new Error(`Unpublished on ${u.time}`)
er.statusCode = 404
er.code = 'E404'
er.pkgid = pckmnt._id

View File

@ -37,6 +37,7 @@ const affordances = {
isnt: 'install',
isnta: 'install',
isntal: 'install',
isntall: 'install',
'install-clean': 'ci',
'isntall-clean': 'ci',
hlep: 'help',

View File

@ -740,6 +740,7 @@ define('force', {
* Allow conflicting peerDependencies to be installed in the root project.
* Implicitly set \`--yes\` during \`npm init\`.
* Allow clobbering existing values in \`npm pkg\`
* Allow unpublishing of entire packages (not just a single version).
If you don't have a clear idea of what you want to do, it is strongly
recommended that you do not use this option!
@ -798,7 +799,8 @@ define('git-tag-version', {
default: true,
type: Boolean,
description: `
Tag the commit when using the \`npm version\` command.
Tag the commit when using the \`npm version\` command. Setting this to
false results in no commit being made at all.
`,
flatten,
})

View File

@ -199,12 +199,7 @@ module.exports = (er, npm) => {
const valResult = nameValidator(pkg)
if (valResult.validForNewPackages) {
detail.push([
'404',
'You should bug the author to publish it (or use the name yourself!)',
])
} else {
if (!valResult.validForNewPackages) {
detail.push(['404', 'This package name is not valid, because', ''])
const errorsArray = [...(valResult.errors || []), ...(valResult.warnings || [])]

View File

@ -1,20 +1,17 @@
const prompt = 'This operation requires a one-time password.\nEnter OTP:'
const readUserInfo = require('./read-user-info.js')
const isOtpError = err =>
err.code === 'EOTP' || (err.code === 'E401' && /one-time pass/.test(err.body))
module.exports = otplease
function otplease (opts, fn) {
opts = { prompt, ...opts }
return Promise.resolve().then(() => fn(opts)).catch(err => {
if (!isOtpError(err)) {
async function otplease (opts, fn) {
try {
await fn(opts)
} catch (err) {
if (err.code !== 'EOTP' && (err.code !== 'E401' || !/one-time pass/.test(err.body))) {
throw err
} else if (!process.stdin.isTTY || !process.stdout.isTTY) {
throw err
} else {
return readUserInfo.otp(opts.prompt)
.then(otp => fn({ ...opts, otp }))
const otp = await readUserInfo.otp('This operation requires a one-time password.\nEnter OTP:')
return fn({ ...opts, otp })
}
})
}
}

View File

@ -260,6 +260,8 @@ Allow conflicting peerDependencies to be installed in the root project\.
Implicitly set \fB\-\-yes\fP during \fBnpm init\fP\|\.
.IP \(bu 2
Allow clobbering existing values in \fBnpm pkg\fP
.IP \(bu 2
Allow unpublishing of entire packages (not just a single version)\.
.RE
.P
@ -321,6 +323,36 @@ it will be included\.
.P
If the resulting omit list includes \fB\|'dev'\fP, then the \fBNODE_ENV\fP environment
variable will be set to \fB\|'production'\fP for all lifecycle scripts\.
.SS \fBforeground\-scripts\fP
.RS 0
.IP \(bu 2
Default: false
.IP \(bu 2
Type: Boolean
.RE
.P
Run all build scripts (ie, \fBpreinstall\fP, \fBinstall\fP, and \fBpostinstall\fP)
scripts for installed packages in the foreground process, sharing standard
input, output, and error with the main npm process\.
.P
Note that this will generally make installs run slower, and be much noisier,
but can be useful for debugging\.
.SS \fBignore\-scripts\fP
.RS 0
.IP \(bu 2
Default: false
.IP \(bu 2
Type: Boolean
.RE
.P
If true, npm does not run scripts specified in package\.json files\.
.P
Note that commands explicitly intended to run a particular script, such as
\fBnpm start\fP, \fBnpm stop\fP, \fBnpm restart\fP, \fBnpm test\fP, and \fBnpm run\-script\fP
will still run their intended script if \fBignore\-scripts\fP is set, but they
will \fInot\fR run any pre\- or post\-scripts\.
.SS \fBworkspace\fP
.RS 0
.IP \(bu 2

View File

@ -94,6 +94,21 @@ When "true" submit audit reports alongside the current npm command to the
default registry and all registries configured for scopes\. See the
documentation for npm help \fBaudit\fP for details on what is
submitted\.
.SS \fBforeground\-scripts\fP
.RS 0
.IP \(bu 2
Default: false
.IP \(bu 2
Type: Boolean
.RE
.P
Run all build scripts (ie, \fBpreinstall\fP, \fBinstall\fP, and \fBpostinstall\fP)
scripts for installed packages in the foreground process, sharing standard
input, output, and error with the main npm process\.
.P
Note that this will generally make installs run slower, and be much noisier,
but can be useful for debugging\.
.SS \fBignore\-scripts\fP
.RS 0
.IP \(bu 2

View File

@ -225,6 +225,8 @@ Allow conflicting peerDependencies to be installed in the root project\.
Implicitly set \fB\-\-yes\fP during \fBnpm init\fP\|\.
.IP \(bu 2
Allow clobbering existing values in \fBnpm pkg\fP
.IP \(bu 2
Allow unpublishing of entire packages (not just a single version)\.
.RE
.P

View File

@ -27,6 +27,21 @@ When "true" submit audit reports alongside the current npm command to the
default registry and all registries configured for scopes\. See the
documentation for npm help \fBaudit\fP for details on what is
submitted\.
.SS \fBforeground\-scripts\fP
.RS 0
.IP \(bu 2
Default: false
.IP \(bu 2
Type: Boolean
.RE
.P
Run all build scripts (ie, \fBpreinstall\fP, \fBinstall\fP, and \fBpostinstall\fP)
scripts for installed packages in the foreground process, sharing standard
input, output, and error with the main npm process\.
.P
Note that this will generally make installs run slower, and be much noisier,
but can be useful for debugging\.
.SS \fBignore\-scripts\fP
.RS 0
.IP \(bu 2

View File

@ -101,6 +101,27 @@ Causes npm to install the package such that versions of npm prior to 1\.4,
such as the one included with node 0\.8, can install the package\. This
eliminates all automatic deduping\. If used with \fBglobal\-style\fP this option
will be preferred\.
.SS \fBomit\fP
.RS 0
.IP \(bu 2
Default: 'dev' if the \fBNODE_ENV\fP environment variable is set to
\|'production', otherwise empty\.
.IP \(bu 2
Type: "dev", "optional", or "peer" (can be set multiple times)
.RE
.P
Dependency types to omit from the installation tree on disk\.
.P
Note that these dependencies \fIare\fR still resolved and added to the
\fBpackage\-lock\.json\fP or \fBnpm\-shrinkwrap\.json\fP file\. They are just not
physically installed on disk\.
.P
If a package type appears in both the \fB\-\-include\fP and \fB\-\-omit\fP lists, then
it will be included\.
.P
If the resulting omit list includes \fB\|'dev'\fP, then the \fBNODE_ENV\fP environment
variable will be set to \fB\|'production'\fP for all lifecycle scripts\.
.SS \fBstrict\-peer\-deps\fP
.RS 0
.IP \(bu 2
@ -140,27 +161,21 @@ modules will also be disabled\. To remove extraneous modules with
package\-locks disabled use \fBnpm prune\fP\|\.
.P
This configuration does not affect \fBnpm ci\fP\|\.
.SS \fBomit\fP
.SS \fBforeground\-scripts\fP
.RS 0
.IP \(bu 2
Default: 'dev' if the \fBNODE_ENV\fP environment variable is set to
\|'production', otherwise empty\.
Default: false
.IP \(bu 2
Type: "dev", "optional", or "peer" (can be set multiple times)
Type: Boolean
.RE
.P
Dependency types to omit from the installation tree on disk\.
Run all build scripts (ie, \fBpreinstall\fP, \fBinstall\fP, and \fBpostinstall\fP)
scripts for installed packages in the foreground process, sharing standard
input, output, and error with the main npm process\.
.P
Note that these dependencies \fIare\fR still resolved and added to the
\fBpackage\-lock\.json\fP or \fBnpm\-shrinkwrap\.json\fP file\. They are just not
physically installed on disk\.
.P
If a package type appears in both the \fB\-\-include\fP and \fB\-\-omit\fP lists, then
it will be included\.
.P
If the resulting omit list includes \fB\|'dev'\fP, then the \fBNODE_ENV\fP environment
variable will be set to \fB\|'production'\fP for all lifecycle scripts\.
Note that this will generally make installs run slower, and be much noisier,
but can be useful for debugging\.
.SS \fBignore\-scripts\fP
.RS 0
.IP \(bu 2

View File

@ -16,7 +16,7 @@ npm install <tarball url>
npm install <git:// url>
npm install <github username>/<github project>
aliases: i, in, ins, inst, insta, instal, isnt, isnta, isntal, add
aliases: i, in, ins, inst, insta, instal, isnt, isnta, isntal, isntall, add
.fi
.RE
.SS Description
@ -512,6 +512,27 @@ Causes npm to install the package such that versions of npm prior to 1\.4,
such as the one included with node 0\.8, can install the package\. This
eliminates all automatic deduping\. If used with \fBglobal\-style\fP this option
will be preferred\.
.SS \fBomit\fP
.RS 0
.IP \(bu 2
Default: 'dev' if the \fBNODE_ENV\fP environment variable is set to
\|'production', otherwise empty\.
.IP \(bu 2
Type: "dev", "optional", or "peer" (can be set multiple times)
.RE
.P
Dependency types to omit from the installation tree on disk\.
.P
Note that these dependencies \fIare\fR still resolved and added to the
\fBpackage\-lock\.json\fP or \fBnpm\-shrinkwrap\.json\fP file\. They are just not
physically installed on disk\.
.P
If a package type appears in both the \fB\-\-include\fP and \fB\-\-omit\fP lists, then
it will be included\.
.P
If the resulting omit list includes \fB\|'dev'\fP, then the \fBNODE_ENV\fP environment
variable will be set to \fB\|'production'\fP for all lifecycle scripts\.
.SS \fBstrict\-peer\-deps\fP
.RS 0
.IP \(bu 2
@ -551,27 +572,21 @@ modules will also be disabled\. To remove extraneous modules with
package\-locks disabled use \fBnpm prune\fP\|\.
.P
This configuration does not affect \fBnpm ci\fP\|\.
.SS \fBomit\fP
.SS \fBforeground\-scripts\fP
.RS 0
.IP \(bu 2
Default: 'dev' if the \fBNODE_ENV\fP environment variable is set to
\|'production', otherwise empty\.
Default: false
.IP \(bu 2
Type: "dev", "optional", or "peer" (can be set multiple times)
Type: Boolean
.RE
.P
Dependency types to omit from the installation tree on disk\.
Run all build scripts (ie, \fBpreinstall\fP, \fBinstall\fP, and \fBpostinstall\fP)
scripts for installed packages in the foreground process, sharing standard
input, output, and error with the main npm process\.
.P
Note that these dependencies \fIare\fR still resolved and added to the
\fBpackage\-lock\.json\fP or \fBnpm\-shrinkwrap\.json\fP file\. They are just not
physically installed on disk\.
.P
If a package type appears in both the \fB\-\-include\fP and \fB\-\-omit\fP lists, then
it will be included\.
.P
If the resulting omit list includes \fB\|'dev'\fP, then the \fBNODE_ENV\fP environment
variable will be set to \fB\|'production'\fP for all lifecycle scripts\.
Note that this will generally make installs run slower, and be much noisier,
but can be useful for debugging\.
.SS \fBignore\-scripts\fP
.RS 0
.IP \(bu 2

View File

@ -26,7 +26,7 @@ example, running \fBnpm ls promzard\fP in npm's source tree will show:
.P
.RS 2
.nf
npm@8\.5\.3 /path/to/npm
npm@8\.5\.5 /path/to/npm
└─┬ init\-package\-json@0\.0\.4
└── promzard@0\.1\.5
.fi

View File

@ -8,6 +8,8 @@
npm pkg set <key>=<value> [<key>=<value> \.\.\.]
npm pkg get [<key> [<key> \.\.\.]]
npm pkg delete <key> [<key> \.\.\.]
npm pkg set [<array>[<index>]\.<key>=<value> \.\.\.]
npm pkg set [<array>[]\.<key>=<value> \.\.\.]
.fi
.RE
.SS Description
@ -209,6 +211,8 @@ Allow conflicting peerDependencies to be installed in the root project\.
Implicitly set \fB\-\-yes\fP during \fBnpm init\fP\|\.
.IP \(bu 2
Allow clobbering existing values in \fBnpm pkg\fP
.IP \(bu 2
Allow unpublishing of entire packages (not just a single version)\.
.RE
.P

View File

@ -86,6 +86,36 @@ saving them to your \fBpackage\.json\fP\|\.
.RE
.P
Not supported by all npm commands\.
.SS \fBforeground\-scripts\fP
.RS 0
.IP \(bu 2
Default: false
.IP \(bu 2
Type: Boolean
.RE
.P
Run all build scripts (ie, \fBpreinstall\fP, \fBinstall\fP, and \fBpostinstall\fP)
scripts for installed packages in the foreground process, sharing standard
input, output, and error with the main npm process\.
.P
Note that this will generally make installs run slower, and be much noisier,
but can be useful for debugging\.
.SS \fBignore\-scripts\fP
.RS 0
.IP \(bu 2
Default: false
.IP \(bu 2
Type: Boolean
.RE
.P
If true, npm does not run scripts specified in package\.json files\.
.P
Note that commands explicitly intended to run a particular script, such as
\fBnpm start\fP, \fBnpm stop\fP, \fBnpm restart\fP, \fBnpm test\fP, and \fBnpm run\-script\fP
will still run their intended script if \fBignore\-scripts\fP is set, but they
will \fInot\fR run any pre\- or post\-scripts\.
.SS \fBworkspace\fP
.RS 0
.IP \(bu 2

View File

@ -59,6 +59,21 @@ executables\.
Set to false to have it not do this\. This can be used to work around the
fact that some file systems don't support symlinks, even on ostensibly Unix
systems\.
.SS \fBforeground\-scripts\fP
.RS 0
.IP \(bu 2
Default: false
.IP \(bu 2
Type: Boolean
.RE
.P
Run all build scripts (ie, \fBpreinstall\fP, \fBinstall\fP, and \fBpostinstall\fP)
scripts for installed packages in the foreground process, sharing standard
input, output, and error with the main npm process\.
.P
Note that this will generally make installs run slower, and be much noisier,
but can be useful for debugging\.
.SS \fBignore\-scripts\fP
.RS 0
.IP \(bu 2

View File

@ -3,23 +3,15 @@
\fBnpm-unpublish\fR \- Remove a package from the registry
.SS Synopsis
.P
.RS 2
.nf
npm unpublish [<@scope>/]<pkg>[@<version>]
.fi
.RE
.P
To learn more about how the npm registry treats unpublish, see our <a
href="https://docs\.npmjs\.com/policies/unpublish" target="_blank"
rel="noopener noreferrer"> unpublish policies</a>
.SS Unpublishing a single version of a package
.P
.RS 2
.nf
npm unpublish [<@scope>/]<pkg>@<version>
.fi
.RE
.SS Unpublishing an entire package
.P
.RS 2
.nf
npm unpublish [<@scope>/]<pkg> \-\-force
.fi
.RE
.SS Warning
.P
Consider using the npm help \fBdeprecate\fP command instead,
@ -93,6 +85,8 @@ Allow conflicting peerDependencies to be installed in the root project\.
Implicitly set \fB\-\-yes\fP during \fBnpm init\fP\|\.
.IP \(bu 2
Allow clobbering existing values in \fBnpm pkg\fP
.IP \(bu 2
Allow unpublishing of entire packages (not just a single version)\.
.RE
.P

View File

@ -159,6 +159,22 @@ need to run \fBnpm install \-g [<pkg>\.\.\.]\fP
NOTE: If a package has been upgraded to a version newer than \fBlatest\fP, it will
be \fIdowngraded\fR\|\.
.SS Configuration
.SS \fBsave\fP
.RS 0
.IP \(bu 2
Default: \fBtrue\fP unless when using \fBnpm update\fP or \fBnpm dedupe\fP where it
defaults to \fBfalse\fP
.IP \(bu 2
Type: Boolean
.RE
.P
Save installed packages to a \fBpackage\.json\fP file as dependencies\.
.P
When used with the \fBnpm rm\fP command, removes the dependency from
\fBpackage\.json\fP\|\.
.P
Will also prevent writing to \fBpackage\-lock\.json\fP if set to \fBfalse\fP\|\.
.SS \fBglobal\fP
.RS 0
.IP \(bu 2
@ -209,6 +225,27 @@ Causes npm to install the package such that versions of npm prior to 1\.4,
such as the one included with node 0\.8, can install the package\. This
eliminates all automatic deduping\. If used with \fBglobal\-style\fP this option
will be preferred\.
.SS \fBomit\fP
.RS 0
.IP \(bu 2
Default: 'dev' if the \fBNODE_ENV\fP environment variable is set to
\|'production', otherwise empty\.
.IP \(bu 2
Type: "dev", "optional", or "peer" (can be set multiple times)
.RE
.P
Dependency types to omit from the installation tree on disk\.
.P
Note that these dependencies \fIare\fR still resolved and added to the
\fBpackage\-lock\.json\fP or \fBnpm\-shrinkwrap\.json\fP file\. They are just not
physically installed on disk\.
.P
If a package type appears in both the \fB\-\-include\fP and \fB\-\-omit\fP lists, then
it will be included\.
.P
If the resulting omit list includes \fB\|'dev'\fP, then the \fBNODE_ENV\fP environment
variable will be set to \fB\|'production'\fP for all lifecycle scripts\.
.SS \fBstrict\-peer\-deps\fP
.RS 0
.IP \(bu 2
@ -248,43 +285,21 @@ modules will also be disabled\. To remove extraneous modules with
package\-locks disabled use \fBnpm prune\fP\|\.
.P
This configuration does not affect \fBnpm ci\fP\|\.
.SS \fBsave\fP
.SS \fBforeground\-scripts\fP
.RS 0
.IP \(bu 2
Default: \fBtrue\fP unless when using \fBnpm update\fP or \fBnpm dedupe\fP where it
defaults to \fBfalse\fP
Default: false
.IP \(bu 2
Type: Boolean
.RE
.P
Save installed packages to a \fBpackage\.json\fP file as dependencies\.
Run all build scripts (ie, \fBpreinstall\fP, \fBinstall\fP, and \fBpostinstall\fP)
scripts for installed packages in the foreground process, sharing standard
input, output, and error with the main npm process\.
.P
When used with the \fBnpm rm\fP command, removes the dependency from
\fBpackage\.json\fP\|\.
.P
Will also prevent writing to \fBpackage\-lock\.json\fP if set to \fBfalse\fP\|\.
.SS \fBomit\fP
.RS 0
.IP \(bu 2
Default: 'dev' if the \fBNODE_ENV\fP environment variable is set to
\|'production', otherwise empty\.
.IP \(bu 2
Type: "dev", "optional", or "peer" (can be set multiple times)
.RE
.P
Dependency types to omit from the installation tree on disk\.
.P
Note that these dependencies \fIare\fR still resolved and added to the
\fBpackage\-lock\.json\fP or \fBnpm\-shrinkwrap\.json\fP file\. They are just not
physically installed on disk\.
.P
If a package type appears in both the \fB\-\-include\fP and \fB\-\-omit\fP lists, then
it will be included\.
.P
If the resulting omit list includes \fB\|'dev'\fP, then the \fBNODE_ENV\fP environment
variable will be set to \fB\|'production'\fP for all lifecycle scripts\.
Note that this will generally make installs run slower, and be much noisier,
but can be useful for debugging\.
.SS \fBignore\-scripts\fP
.RS 0
.IP \(bu 2

View File

@ -41,7 +41,8 @@ Type: Boolean
.RE
.P
Tag the commit when using the \fBnpm version\fP command\.
Tag the commit when using the \fBnpm version\fP command\. Setting this to false
results in no commit being made at all\.
.SS \fBjson\fP
.RS 0
.IP \(bu 2

View File

@ -4,7 +4,7 @@
.SS Synopsis
.SS Version
.P
8\.5\.3
8\.5\.5
.SS Description
.P
npm is the package manager for the Node JavaScript platform\. It puts

View File

@ -370,7 +370,7 @@ This should be a module relative to the root of your package folder\.
For most modules, it makes the most sense to have a main script and often
not much else\.
.P
If \fBmain\fP is not set it defaults to \fBindex\.js\fP in the packages root folder\.
If \fBmain\fP is not set it defaults to \fBindex\.js\fP in the package's root folder\.
.SS browser
.P
If your module is meant to be used client\-side the browser field should be
@ -772,6 +772,10 @@ in which case they will be normalized to a relative path and added to your
This feature is helpful for local offline development and creating tests
that require npm installing where you don't want to hit an external server,
but should not be used when publishing packages to the public registry\.
.P
\fInote\fR: Packages linked by local path will not have their own
dependencies installed when \fBnpm install\fP is ran in this case\. You must
run \fBnpm install\fP from inside the local path itself\.
.SS devDependencies
.P
If someone is planning on downloading and using your module in their

View File

@ -668,6 +668,8 @@ Allow conflicting peerDependencies to be installed in the root project\.
Implicitly set \fB\-\-yes\fP during \fBnpm init\fP\|\.
.IP \(bu 2
Allow clobbering existing values in \fBnpm pkg\fP
.IP \(bu 2
Allow unpublishing of entire packages (not just a single version)\.
.RE
.P
@ -731,7 +733,8 @@ Type: Boolean
.RE
.P
Tag the commit when using the \fBnpm version\fP command\.
Tag the commit when using the \fBnpm version\fP command\. Setting this to false
results in no commit being made at all\.
.SS \fBglobal\fP
.RS 0
.IP \(bu 2

View File

@ -435,7 +435,7 @@ module.exports = cls => class ActualLoader extends cls {
if (d.dummy) {
// it's a placeholder, so likely would not have loaded this dep,
// unless another dep in the tree also needs it.
const depPath = `${p}/node_modules/${name}`
const depPath = normalize(`${p}/node_modules/${name}`)
const cached = this[_cache].get(depPath)
if (!cached || cached.dummy) {
depPromises.push(this[_loadFSNode]({

View File

@ -136,15 +136,19 @@ module.exports = cls => class Builder extends cls {
process.emit('time', `build:${type}`)
await this[_buildQueues](nodes)
if (!this[_ignoreScripts]) {
await this[_runScripts]('preinstall')
}
if (this[_binLinks] && type !== 'links') {
await this[_linkAllBins]()
}
// links should also run prepare scripts and only link bins after that
if (type === 'links') {
// links should run prepare scripts and only link bins after that
if (type !== 'links') {
if (!this[_ignoreScripts]) {
await this[_runScripts]('preinstall')
}
if (this[_binLinks]) {
await this[_linkAllBins]()
}
if (!this[_ignoreScripts]) {
await this[_runScripts]('install')
await this[_runScripts]('postinstall')
}
} else {
await this[_runScripts]('prepare')
if (this[_binLinks]) {
@ -152,11 +156,6 @@ module.exports = cls => class Builder extends cls {
}
}
if (!this[_ignoreScripts]) {
await this[_runScripts]('install')
await this[_runScripts]('postinstall')
}
process.emit('timeEnd', `build:${type}`)
}

View File

@ -1225,14 +1225,23 @@ module.exports = cls => class Reifier extends cls {
newSpec = h.shortcut(opt)
}
} else if (isLocalDep) {
// save the relative path in package.json
// Normally saveSpec is updated with the proper relative
// path already, but it's possible to specify a full absolute
// path initially, in which case we can end up with the wrong
// thing, so just get the ultimate fetchSpec and relativize it.
const p = req.fetchSpec.replace(/^file:/, '')
const rel = relpath(addTree.realpath, p)
newSpec = `file:${rel}`
// when finding workspace nodes, make sure that
// we save them using their version instead of
// using their relative path
if (edge.type === 'workspace') {
const { version } = edge.to.target
const prefixRange = version ? this[_savePrefix] + version : '*'
newSpec = prefixRange
} else {
// save the relative path in package.json
// Normally saveSpec is updated with the proper relative
// path already, but it's possible to specify a full absolute
// path initially, in which case we can end up with the wrong
// thing, so just get the ultimate fetchSpec and relativize it.
const p = req.fetchSpec.replace(/^file:/, '')
const rel = relpath(addTree.realpath, p)
newSpec = `file:${rel}`
}
} else {
newSpec = req.saveSpec
}

View File

@ -1,19 +1,19 @@
{
"name": "@npmcli/arborist",
"version": "5.0.0",
"version": "5.0.3",
"description": "Manage node_modules trees",
"dependencies": {
"@isaacs/string-locale-compare": "^1.1.0",
"@npmcli/installed-package-contents": "^1.0.7",
"@npmcli/map-workspaces": "^2.0.0",
"@npmcli/metavuln-calculator": "^3.0.0",
"@npmcli/metavuln-calculator": "^3.0.1",
"@npmcli/move-file": "^1.1.0",
"@npmcli/name-from-folder": "^1.0.1",
"@npmcli/node-gyp": "^1.0.3",
"@npmcli/package-json": "^1.0.1",
"@npmcli/run-script": "^3.0.0",
"bin-links": "^3.0.0",
"cacache": "^15.0.3",
"cacache": "^16.0.0",
"common-ancestor-path": "^1.0.1",
"json-parse-even-better-errors": "^2.3.1",
"json-stringify-nice": "^1.1.4",
@ -25,7 +25,7 @@
"npm-pick-manifest": "^7.0.0",
"npm-registry-fetch": "^13.0.0",
"npmlog": "^6.0.1",
"pacote": "^13.0.2",
"pacote": "^13.0.5",
"parse-conflict-json": "^2.0.1",
"proc-log": "^2.0.0",
"promise-all-reject-late": "^1.0.0",

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,587 +0,0 @@
const perf = typeof performance === 'object' && performance &&
typeof performance.now === 'function' ? performance : Date
const warned = new Set()
const deprecatedOption = (opt, instead) => {
const code = `LRU_CACHE_OPTION_${opt}`
if (shouldWarn(code)) {
warn(code, `${opt} option`, `options.${instead}`, LRUCache)
}
}
const deprecatedMethod = (method, instead) => {
const code = `LRU_CACHE_METHOD_${method}`
if (shouldWarn(code)) {
const { prototype } = LRUCache
const { get } = Object.getOwnPropertyDescriptor(prototype, method)
warn(code, `${method} method`, `cache.${instead}()`, get)
}
}
const deprecatedProperty = (field, instead) => {
const code = `LRU_CACHE_PROPERTY_${field}`
if (shouldWarn(code)) {
const { prototype } = LRUCache
const { get } = Object.getOwnPropertyDescriptor(prototype, field)
warn(code, `${field} property`, `cache.${instead}`, get)
}
}
const shouldWarn = (code) => !(process.noDeprecation || warned.has(code))
const warn = (code, what, instead, fn) => {
warned.add(code)
process.emitWarning(`The ${what} is deprecated. Please use ${instead} instead.`, 'DeprecationWarning', code, fn)
}
const isPosInt = n => n && n === Math.floor(n) && n > 0 && isFinite(n)
/* istanbul ignore next - This is a little bit ridiculous, tbh.
* The maximum array length is 2^32-1 or thereabouts on most JS impls.
* And well before that point, you're caching the entire world, I mean,
* that's ~32GB of just integers for the next/prev links, plus whatever
* else to hold that many keys and values. Just filling the memory with
* zeroes at init time is brutal when you get that big.
* But why not be complete?
* Maybe in the future, these limits will have expanded. */
const getUintArray = max => !isPosInt(max) ? null
: max <= Math.pow(2, 8) ? Uint8Array
: max <= Math.pow(2, 16) ? Uint16Array
: max <= Math.pow(2, 32) ? Uint32Array
: max <= Number.MAX_SAFE_INTEGER ? ZeroArray
: null
class ZeroArray extends Array {
constructor (size) {
super(size)
this.fill(0)
}
}
class Stack {
constructor (max) {
const UintArray = getUintArray(max)
this.heap = new UintArray(max)
this.length = 0
}
push (n) {
this.heap[this.length++] = n
}
pop () {
return this.heap[--this.length]
}
}
class LRUCache {
constructor (options = {}) {
const {
max,
ttl,
ttlResolution = 1,
ttlAutopurge,
updateAgeOnGet,
allowStale,
dispose,
disposeAfter,
noDisposeOnSet,
noUpdateTTL,
maxSize,
sizeCalculation,
} = options
// deprecated options, don't trigger a warning for getting them if
// the thing being passed in is another LRUCache we're copying.
const {
length,
maxAge,
stale,
} = options instanceof LRUCache ? {} : options
if (!isPosInt(max)) {
throw new TypeError('max option must be an integer')
}
const UintArray = getUintArray(max)
if (!UintArray) {
throw new Error('invalid max value: ' + max)
}
this.max = max
this.maxSize = maxSize || 0
this.sizeCalculation = sizeCalculation || length
if (this.sizeCalculation) {
if (!this.maxSize) {
throw new TypeError('cannot set sizeCalculation without setting maxSize')
}
if (typeof this.sizeCalculation !== 'function') {
throw new TypeError('sizeCalculating set to non-function')
}
}
this.keyMap = new Map()
this.keyList = new Array(max).fill(null)
this.valList = new Array(max).fill(null)
this.next = new UintArray(max)
this.prev = new UintArray(max)
this.head = 0
this.tail = 0
this.free = new Stack(max)
this.initialFill = 1
this.size = 0
if (typeof dispose === 'function') {
this.dispose = dispose
}
if (typeof disposeAfter === 'function') {
this.disposeAfter = disposeAfter
this.disposed = []
} else {
this.disposeAfter = null
this.disposed = null
}
this.noDisposeOnSet = !!noDisposeOnSet
this.noUpdateTTL = !!noUpdateTTL
if (this.maxSize) {
if (!isPosInt(this.maxSize)) {
throw new TypeError('maxSize must be a positive integer if specified')
}
this.initializeSizeTracking()
}
this.allowStale = !!allowStale || !!stale
this.updateAgeOnGet = !!updateAgeOnGet
this.ttlResolution = isPosInt(ttlResolution) || ttlResolution === 0
? ttlResolution : 1
this.ttlAutopurge = !!ttlAutopurge
this.ttl = ttl || maxAge || 0
if (this.ttl) {
if (!isPosInt(this.ttl)) {
throw new TypeError('ttl must be a positive integer if specified')
}
this.initializeTTLTracking()
}
if (stale) {
deprecatedOption('stale', 'allowStale')
}
if (maxAge) {
deprecatedOption('maxAge', 'ttl')
}
if (length) {
deprecatedOption('length', 'sizeCalculation')
}
}
initializeTTLTracking () {
this.ttls = new ZeroArray(this.max)
this.starts = new ZeroArray(this.max)
this.setItemTTL = (index, ttl) => {
this.starts[index] = ttl !== 0 ? perf.now() : 0
this.ttls[index] = ttl
if (ttl !== 0 && this.ttlAutopurge) {
const t = setTimeout(() => {
if (this.isStale(index)) {
this.delete(this.keyList[index])
}
}, ttl + 1)
/* istanbul ignore else - unref() not supported on all platforms */
if (t.unref) {
t.unref()
}
}
}
this.updateItemAge = (index) => {
this.starts[index] = this.ttls[index] !== 0 ? perf.now() : 0
}
// debounce calls to perf.now() to 1s so we're not hitting
// that costly call repeatedly.
let cachedNow = 0
const getNow = () => {
const n = perf.now()
if (this.ttlResolution > 0) {
cachedNow = n
const t = setTimeout(() => cachedNow = 0, this.ttlResolution)
/* istanbul ignore else - not available on all platforms */
if (t.unref) {
t.unref()
}
}
return n
}
this.isStale = (index) => {
return this.ttls[index] !== 0 && this.starts[index] !== 0 &&
((cachedNow || getNow()) - this.starts[index] > this.ttls[index])
}
}
updateItemAge (index) {}
setItemTTL (index, ttl) {}
isStale (index) { return false }
initializeSizeTracking () {
this.calculatedSize = 0
this.sizes = new ZeroArray(this.max)
this.removeItemSize = index => this.calculatedSize -= this.sizes[index]
this.addItemSize = (index, v, k, size, sizeCalculation) => {
const s = size || (sizeCalculation ? sizeCalculation(v, k) : 0)
this.sizes[index] = isPosInt(s) ? s : 0
const maxSize = this.maxSize - this.sizes[index]
while (this.calculatedSize > maxSize) {
this.evict()
}
this.calculatedSize += this.sizes[index]
}
this.delete = k => {
if (this.size !== 0) {
const index = this.keyMap.get(k)
if (index !== undefined) {
this.calculatedSize -= this.sizes[index]
}
}
return LRUCache.prototype.delete.call(this, k)
}
}
removeItemSize (index) {}
addItemSize (index, v, k, size, sizeCalculation) {}
*indexes () {
if (this.size) {
for (let i = this.tail; true; i = this.prev[i]) {
if (!this.isStale(i)) {
yield i
}
if (i === this.head) {
break
}
}
}
}
*rindexes () {
if (this.size) {
for (let i = this.head; true; i = this.next[i]) {
if (!this.isStale(i)) {
yield i
}
if (i === this.tail) {
break
}
}
}
}
*entries () {
for (const i of this.indexes()) {
yield [this.keyList[i], this.valList[i]]
}
}
*keys () {
for (const i of this.indexes()) {
yield this.keyList[i]
}
}
*values () {
for (const i of this.indexes()) {
yield this.valList[i]
}
}
[Symbol.iterator] () {
return this.entries()
}
find (fn, getOptions = {}) {
for (const i of this.indexes()) {
if (fn(this.valList[i], this.keyList[i], this)) {
return this.get(this.keyList[i], getOptions)
}
}
}
forEach (fn, thisp = this) {
for (const i of this.indexes()) {
fn.call(thisp, this.valList[i], this.keyList[i], this)
}
}
rforEach (fn, thisp = this) {
for (const i of this.rindexes()) {
fn.call(thisp, this.valList[i], this.keyList[i], this)
}
}
get prune () {
deprecatedMethod('prune', 'purgeStale')
return this.purgeStale
}
purgeStale () {
let deleted = false
if (this.size) {
for (let i = this.head; true; i = this.next[i]) {
const b = i === this.tail
if (this.isStale(i)) {
this.delete(this.keyList[i])
deleted = true
}
if (b) {
break
}
}
}
return deleted
}
dump () {
const arr = []
for (const i of this.indexes()) {
const key = this.keyList[i]
const value = this.valList[i]
const entry = { value }
if (this.ttls) {
entry.ttl = this.ttls[i]
}
if (this.sizes) {
entry.size = this.sizes[i]
}
arr.unshift([key, entry])
}
return arr
}
load (arr) {
this.clear()
for (const [key, entry] of arr) {
this.set(key, entry.value, entry)
}
}
dispose (v, k, reason) {}
set (k, v, {
ttl = this.ttl,
noDisposeOnSet = this.noDisposeOnSet,
size = 0,
sizeCalculation = this.sizeCalculation,
noUpdateTTL = this.noUpdateTTL,
} = {}) {
let index = this.size === 0 ? undefined : this.keyMap.get(k)
if (index === undefined) {
// addition
index = this.newIndex()
this.keyList[index] = k
this.valList[index] = v
this.keyMap.set(k, index)
this.next[this.tail] = index
this.prev[index] = this.tail
this.tail = index
this.size ++
this.addItemSize(index, v, k, size, sizeCalculation)
noUpdateTTL = false
} else {
// update
const oldVal = this.valList[index]
if (v !== oldVal) {
if (!noDisposeOnSet) {
this.dispose(oldVal, k, 'set')
if (this.disposeAfter) {
this.disposed.push([oldVal, k, 'set'])
}
}
this.removeItemSize(index)
this.valList[index] = v
this.addItemSize(index, v, k, size, sizeCalculation)
}
this.moveToTail(index)
}
if (ttl !== 0 && this.ttl === 0 && !this.ttls) {
this.initializeTTLTracking()
}
if (!noUpdateTTL) {
this.setItemTTL(index, ttl)
}
if (this.disposeAfter) {
while (this.disposed.length) {
this.disposeAfter(...this.disposed.shift())
}
}
return this
}
newIndex () {
if (this.size === 0) {
return this.tail
}
if (this.size === this.max) {
return this.evict()
}
if (this.free.length !== 0) {
return this.free.pop()
}
// initial fill, just keep writing down the list
return this.initialFill++
}
pop () {
if (this.size) {
const val = this.valList[this.head]
this.evict()
return val
}
}
evict () {
const head = this.head
const k = this.keyList[head]
const v = this.valList[head]
this.dispose(v, k, 'evict')
if (this.disposeAfter) {
this.disposed.push([v, k, 'evict'])
}
this.removeItemSize(head)
this.head = this.next[head]
this.keyMap.delete(k)
this.size --
return head
}
has (k) {
return this.keyMap.has(k) && !this.isStale(this.keyMap.get(k))
}
// like get(), but without any LRU updating or TTL expiration
peek (k, { allowStale = this.allowStale } = {}) {
const index = this.keyMap.get(k)
if (index !== undefined && (allowStale || !this.isStale(index))) {
return this.valList[index]
}
}
get (k, {
allowStale = this.allowStale,
updateAgeOnGet = this.updateAgeOnGet,
} = {}) {
const index = this.keyMap.get(k)
if (index !== undefined) {
if (this.isStale(index)) {
const value = allowStale ? this.valList[index] : undefined
this.delete(k)
return value
} else {
this.moveToTail(index)
if (updateAgeOnGet) {
this.updateItemAge(index)
}
return this.valList[index]
}
}
}
connect (p, n) {
this.prev[n] = p
this.next[p] = n
}
moveToTail (index) {
// if tail already, nothing to do
// if head, move head to next[index]
// else
// move next[prev[index]] to next[index] (head has no prev)
// move prev[next[index]] to prev[index]
// prev[index] = tail
// next[tail] = index
// tail = index
if (index !== this.tail) {
if (index === this.head) {
this.head = this.next[index]
} else {
this.connect(this.prev[index], this.next[index])
}
this.connect(this.tail, index)
this.tail = index
}
}
get del () {
deprecatedMethod('del', 'delete')
return this.delete
}
delete (k) {
let deleted = false
if (this.size !== 0) {
const index = this.keyMap.get(k)
if (index !== undefined) {
deleted = true
if (this.size === 1) {
this.clear()
} else {
this.removeItemSize(index)
this.dispose(this.valList[index], k, 'delete')
if (this.disposeAfter) {
this.disposed.push([this.valList[index], k, 'delete'])
}
this.keyMap.delete(k)
this.keyList[index] = null
this.valList[index] = null
if (index === this.tail) {
this.tail = this.prev[index]
} else if (index === this.head) {
this.head = this.next[index]
} else {
this.next[this.prev[index]] = this.next[index]
this.prev[this.next[index]] = this.prev[index]
}
this.size --
this.free.push(index)
}
}
}
if (this.disposed) {
while (this.disposed.length) {
this.disposeAfter(...this.disposed.shift())
}
}
return deleted
}
clear () {
if (this.dispose !== LRUCache.prototype.dispose) {
for (const index of this.rindexes()) {
this.dispose(this.valList[index], this.keyList[index], 'delete')
}
}
if (this.disposeAfter) {
for (const index of this.rindexes()) {
this.disposed.push([this.valList[index], this.keyList[index], 'delete'])
}
}
this.keyMap.clear()
this.valList.fill(null)
this.keyList.fill(null)
if (this.ttls) {
this.ttls.fill(0)
this.starts.fill(0)
}
if (this.sizes) {
this.sizes.fill(0)
}
this.head = 0
this.tail = 0
this.initialFill = 1
this.free.length = 0
this.calculatedSize = 0
this.size = 0
if (this.disposed) {
while (this.disposed.length) {
this.disposeAfter(...this.disposed.shift())
}
}
}
get reset () {
deprecatedMethod('reset', 'clear')
return this.clear
}
get length () {
deprecatedProperty('length', 'size')
return this.size
}
}
module.exports = LRUCache

View File

@ -1,52 +0,0 @@
{
"name": "lru-cache",
"description": "A cache object that deletes the least-recently-used items.",
"version": "7.4.0",
"author": "Isaac Z. Schlueter <i@izs.me>",
"keywords": [
"mru",
"lru",
"cache"
],
"scripts": {
"prepare": "webpack-cli -o bundle ./index.js --node-env production",
"build": "npm run prepare",
"presize": "npm run prepare",
"test": "tap",
"snap": "tap",
"size": "size-limit",
"preversion": "npm test",
"postversion": "npm publish",
"prepublishOnly": "git push origin --follow-tags"
},
"main": "index.js",
"browser": "./bundle/main.js",
"exports": {
".": "./index.js",
"./browser": "./bundle/main.js"
},
"repository": "git://github.com/isaacs/node-lru-cache.git",
"devDependencies": {
"@size-limit/preset-small-lib": "^7.0.8",
"benchmark": "^2.1.4",
"size-limit": "^7.0.8",
"tap": "^15.1.6",
"webpack-cli": "^4.9.2"
},
"license": "ISC",
"files": [
"index.js",
"bundle"
],
"engines": {
"node": ">=12"
},
"tap": {
"coverage-map": "map.js"
},
"size-limit": [
{
"path": "./bundle/main.js"
}
]
}

View File

@ -117,28 +117,52 @@ async function mapWorkspaces (opts = {}) {
const name = getPackageName(pkg, packagePathname)
let seenPackagePathnames = seen.get(name)
if (!seenPackagePathnames) {
seenPackagePathnames = new Set()
seen.set(name, seenPackagePathnames)
}
if (item.negate) {
results.delete(packagePathname, name)
seenPackagePathnames.delete(packagePathname)
} else {
if (seen.has(name) && seen.get(name) !== packagePathname) {
throw getError({
Type: Error,
message: [
'must not have multiple workspaces with the same name',
`package '${name}' has conflicts in the following paths:`,
' ' + seen.get(name),
' ' + packagePathname,
].join('\n'),
code: 'EDUPLICATEWORKSPACE',
})
}
seen.set(name, packagePathname)
results.set(packagePathname, name)
seenPackagePathnames.add(packagePathname)
}
}
}
return reverseResultMap(results)
const errorMessageArray = ['must not have multiple workspaces with the same name']
for (const [packageName, seenPackagePathnames] of seen) {
if (seenPackagePathnames.size === 0) {
continue
}
if (seenPackagePathnames.size > 1) {
addDuplicateErrorMessages(errorMessageArray, packageName, seenPackagePathnames)
} else {
results.set(packageName, seenPackagePathnames.values().next().value)
}
}
if (errorMessageArray.length > 1) {
throw getError({
Type: Error,
message: errorMessageArray.join('\n'),
code: 'EDUPLICATEWORKSPACE',
})
}
return results
}
function addDuplicateErrorMessages (messageArray, packageName, packagePathnames) {
messageArray.push(
`package '${packageName}' has conflicts in the following paths:`
)
for (const packagePathname of packagePathnames) {
messageArray.push(
' ' + packagePathname
)
}
}
mapWorkspaces.virtual = function (opts = {}) {

View File

@ -1,6 +1,6 @@
{
"name": "@npmcli/map-workspaces",
"version": "2.0.1",
"version": "2.0.2",
"main": "lib/index.js",
"files": [
"bin",
@ -37,23 +37,18 @@
"tap": {
"check-coverage": true
},
"standard": {
"ignore": [
"/tap-snapshots/"
]
},
"devDependencies": {
"@npmcli/template-oss": "^2.7.1",
"eslint": "^8.9.0",
"@npmcli/template-oss": "^2.9.2",
"eslint": "^8.10.0",
"tap": "^15.1.6"
},
"dependencies": {
"@npmcli/name-from-folder": "^1.0.1",
"glob": "^7.2.0",
"minimatch": "^5.0.0",
"minimatch": "^5.0.1",
"read-package-json-fast": "^2.0.3"
},
"templateOSS": {
"version": "2.7.1"
"version": "2.9.2"
}
}

View File

@ -1,6 +1,6 @@
{
"name": "@npmcli/metavuln-calculator",
"version": "3.0.0",
"version": "3.0.1",
"main": "lib/index.js",
"files": [
"bin",
@ -29,20 +29,20 @@
"coverage-map": "map.js"
},
"devDependencies": {
"@npmcli/template-oss": "^2.7.1",
"@npmcli/template-oss": "^2.9.2",
"require-inject": "^1.4.4",
"tap": "^15.1.6"
},
"dependencies": {
"cacache": "^15.3.0",
"cacache": "^16.0.0",
"json-parse-even-better-errors": "^2.3.1",
"pacote": "^13.0.1",
"pacote": "^13.0.3",
"semver": "^7.3.5"
},
"engines": {
"node": "^12.13.0 || ^14.15.0 || >=16"
},
"templateOSS": {
"version": "2.7.1"
"version": "2.9.2"
}
}

View File

@ -20,15 +20,18 @@ function read (cache, integrity, opts = {}) {
// get size
return lstat(cpath).then(stat => ({ stat, cpath, sri }))
}).then(({ stat, cpath, sri }) => {
if (typeof size === 'number' && stat.size !== size)
if (typeof size === 'number' && stat.size !== size) {
throw sizeError(size, stat.size)
}
if (stat.size > MAX_SINGLE_READ_SIZE)
if (stat.size > MAX_SINGLE_READ_SIZE) {
return readPipeline(cpath, stat.size, sri, new Pipeline()).concat()
}
return readFile(cpath, null).then((data) => {
if (!ssri.checkData(data, sri))
if (!ssri.checkData(data, sri)) {
throw integrityError(sri, cpath)
}
return data
})
@ -55,11 +58,13 @@ function readSync (cache, integrity, opts = {}) {
const { size } = opts
return withContentSriSync(cache, integrity, (cpath, sri) => {
const data = fs.readFileSync(cpath)
if (typeof size === 'number' && size !== data.length)
if (typeof size === 'number' && size !== data.length) {
throw sizeError(size, data.length)
}
if (ssri.checkData(data, sri))
if (ssri.checkData(data, sri)) {
return data
}
throw integrityError(sri, cpath)
})
@ -75,8 +80,9 @@ function readStream (cache, integrity, opts = {}) {
// just lstat to ensure it exists
return lstat(cpath).then((stat) => ({ stat, cpath, sri }))
}).then(({ stat, cpath, sri }) => {
if (typeof size === 'number' && size !== stat.size)
if (typeof size === 'number' && size !== stat.size) {
return stream.emit('error', sizeError(size, stat.size))
}
readPipeline(cpath, stat.size, sri, stream)
}, er => stream.emit('error', er))
@ -106,21 +112,24 @@ function copySync (cache, integrity, dest) {
module.exports.hasContent = hasContent
function hasContent (cache, integrity) {
if (!integrity)
if (!integrity) {
return Promise.resolve(false)
}
return withContentSri(cache, integrity, (cpath, sri) => {
return lstat(cpath).then((stat) => ({ size: stat.size, sri, stat }))
}).catch((err) => {
if (err.code === 'ENOENT')
if (err.code === 'ENOENT') {
return false
}
if (err.code === 'EPERM') {
/* istanbul ignore else */
if (process.platform !== 'win32')
if (process.platform !== 'win32') {
throw err
else
} else {
return false
}
}
})
}
@ -128,23 +137,26 @@ function hasContent (cache, integrity) {
module.exports.hasContent.sync = hasContentSync
function hasContentSync (cache, integrity) {
if (!integrity)
if (!integrity) {
return false
}
return withContentSriSync(cache, integrity, (cpath, sri) => {
try {
const stat = fs.lstatSync(cpath)
return { size: stat.size, sri, stat }
} catch (err) {
if (err.code === 'ENOENT')
if (err.code === 'ENOENT') {
return false
}
if (err.code === 'EPERM') {
/* istanbul ignore else */
if (process.platform !== 'win32')
if (process.platform !== 'win32') {
throw err
else
} else {
return false
}
}
}
})
@ -180,13 +192,15 @@ function withContentSri (cache, integrity, fn) {
.then((results) => {
// Return the first non error if it is found
const result = results.find((r) => !(r instanceof Error))
if (result)
if (result) {
return result
}
// Throw the No matching content found error
const enoentError = results.find((r) => r.code === 'ENOENT')
if (enoentError)
if (enoentError) {
throw enoentError
}
// Throw generic error
throw results.find((r) => r instanceof Error)
@ -228,6 +242,7 @@ function withContentSriSync (cache, integrity, fn) {
}
function sizeError (expected, found) {
/* eslint-disable-next-line max-len */
const err = new Error(`Bad data size: expected inserted data to be ${expected} bytes, but got ${found} instead`)
err.expected = expected
err.found = found

View File

@ -11,9 +11,10 @@ module.exports = rm
function rm (cache, integrity) {
return hasContent(cache, integrity).then((content) => {
// ~pretty~ sure we can't end up with a content lacking sri, but be safe
if (content && content.sri)
if (content && content.sri) {
return rimraf(contentPath(cache, content.sri)).then(() => true)
else
} else {
return false
}
})
}

View File

@ -22,15 +22,18 @@ module.exports = write
function write (cache, data, opts = {}) {
const { algorithms, size, integrity } = opts
if (algorithms && algorithms.length > 1)
if (algorithms && algorithms.length > 1) {
throw new Error('opts.algorithms only supports a single algorithm for now')
}
if (typeof size === 'number' && data.length !== size)
if (typeof size === 'number' && data.length !== size) {
return Promise.reject(sizeError(size, data.length))
}
const sri = ssri.fromData(data, algorithms ? { algorithms } : {})
if (integrity && !ssri.checkData(data, integrity, opts))
if (integrity && !ssri.checkData(data, integrity, opts)) {
return Promise.reject(checksumError(integrity, sri))
}
return disposer(makeTmp(cache, opts), makeTmpDisposer,
(tmp) => {
@ -149,8 +152,9 @@ function makeTmp (cache, opts) {
}
function makeTmpDisposer (tmp) {
if (tmp.moved)
if (tmp.moved) {
return Promise.resolve()
}
return rimraf(tmp.target)
}
@ -171,6 +175,7 @@ function moveToDestination (tmp, cache, sri, opts) {
}
function sizeError (expected, found) {
/* eslint-disable-next-line max-len */
const err = new Error(`Bad data size: expected inserted data to be ${expected} bytes, but got ${found} instead`)
err.expected = expected
err.found = found

View File

@ -49,8 +49,9 @@ async function compact (cache, key, matchFn, opts = {}) {
// if the integrity is null and no validateEntry is provided, we break
// as we consider the null integrity to be a deletion of everything
// that came before it.
if (entry.integrity === null && !opts.validateEntry)
if (entry.integrity === null && !opts.validateEntry) {
break
}
// if this entry is valid, and it is either the first entry or
// the newEntries array doesn't already include an entry that
@ -58,8 +59,9 @@ async function compact (cache, key, matchFn, opts = {}) {
// it to the beginning of our list
if ((!opts.validateEntry || opts.validateEntry(entry) === true) &&
(newEntries.length === 0 ||
!newEntries.find((oldEntry) => matchFn(oldEntry, entry))))
!newEntries.find((oldEntry) => matchFn(oldEntry, entry)))) {
newEntries.unshift(entry)
}
}
const newIndex = '\n' + newEntries.map((entry) => {
@ -78,8 +80,9 @@ async function compact (cache, key, matchFn, opts = {}) {
}
const teardown = async (tmp) => {
if (!tmp.moved)
if (!tmp.moved) {
return rimraf(tmp.target)
}
}
const write = async (tmp) => {
@ -92,8 +95,9 @@ async function compact (cache, key, matchFn, opts = {}) {
try {
await fixOwner.chownr(cache, bucket)
} catch (err) {
if (err.code !== 'ENOENT')
if (err.code !== 'ENOENT') {
throw err
}
}
}
@ -136,8 +140,9 @@ function insert (cache, key, integrity, opts = {}) {
})
.then(() => fixOwner.chownr(cache, bucket))
.catch((err) => {
if (err.code === 'ENOENT')
if (err.code === 'ENOENT') {
return undefined
}
throw err
// There's a class of race conditions that happen when things get deleted
@ -169,8 +174,9 @@ function insertSync (cache, key, integrity, opts = {}) {
try {
fixOwner.chownr.sync(cache, bucket)
} catch (err) {
if (err.code !== 'ENOENT')
if (err.code !== 'ENOENT') {
throw err
}
}
return formatEntry(cache, entry)
}
@ -182,17 +188,19 @@ function find (cache, key) {
return bucketEntries(bucket)
.then((entries) => {
return entries.reduce((latest, next) => {
if (next && next.key === key)
if (next && next.key === key) {
return formatEntry(cache, next)
else
} else {
return latest
}
}, null)
})
.catch((err) => {
if (err.code === 'ENOENT')
if (err.code === 'ENOENT') {
return null
else
} else {
throw err
}
})
}
@ -202,24 +210,27 @@ function findSync (cache, key) {
const bucket = bucketPath(cache, key)
try {
return bucketEntriesSync(bucket).reduce((latest, next) => {
if (next && next.key === key)
if (next && next.key === key) {
return formatEntry(cache, next)
else
} else {
return latest
}
}, null)
} catch (err) {
if (err.code === 'ENOENT')
if (err.code === 'ENOENT') {
return null
else
} else {
throw err
}
}
}
module.exports.delete = del
function del (cache, key, opts = {}) {
if (!opts.removeFully)
if (!opts.removeFully) {
return insert(cache, key, null, opts)
}
const bucket = bucketPath(cache, key)
return rimraf(bucket)
@ -228,8 +239,9 @@ function del (cache, key, opts = {}) {
module.exports.delete.sync = delSync
function delSync (cache, key, opts = {}) {
if (!opts.removeFully)
if (!opts.removeFully) {
return insertSync(cache, key, null, opts)
}
const bucket = bucketPath(cache, key)
return rimraf.sync(bucket)
@ -263,12 +275,14 @@ function lsStream (cache) {
// reduced is a map of key => entry
for (const entry of reduced.values()) {
const formatted = formatEntry(cache, entry)
if (formatted)
if (formatted) {
stream.write(formatted)
}
}
}).catch(err => {
if (err.code === 'ENOENT')
if (err.code === 'ENOENT') {
return undefined
}
throw err
})
})
@ -312,8 +326,9 @@ function bucketEntriesSync (bucket, filter) {
function _bucketEntries (data, filter) {
const entries = []
data.split('\n').forEach((entry) => {
if (!entry)
if (!entry) {
return
}
const pieces = entry.split('\t')
if (!pieces[1] || hashEntry(pieces[1]) !== pieces[0]) {
@ -328,8 +343,9 @@ function _bucketEntries (data, filter) {
// Entry is corrupted!
return
}
if (obj)
if (obj) {
entries.push(obj)
}
})
return entries
}
@ -371,8 +387,9 @@ function hash (str, digest) {
function formatEntry (cache, entry, keepAll) {
// Treat null digests as deletions. They'll shadow any previous entries.
if (!entry.integrity && !keepAll)
if (!entry.integrity && !keepAll) {
return null
}
return {
key: entry.key,
@ -386,8 +403,9 @@ function formatEntry (cache, entry, keepAll) {
function readdirOrEmpty (dir) {
return readdir(dir).catch((err) => {
if (err.code === 'ENOENT' || err.code === 'ENOTDIR')
if (err.code === 'ENOENT' || err.code === 'ENOTDIR') {
return []
}
throw err
})

View File

@ -6,9 +6,9 @@ const Pipeline = require('minipass-pipeline')
const fs = require('fs')
const util = require('util')
const index = require('./lib/entry-index')
const memo = require('./lib/memoization')
const read = require('./lib/content/read')
const index = require('./entry-index')
const memo = require('./memoization')
const read = require('./content/read')
const writeFile = util.promisify(fs.writeFile)
@ -25,12 +25,14 @@ function getData (cache, key, opts = {}) {
}
return index.find(cache, key, opts).then((entry) => {
if (!entry)
if (!entry) {
throw new index.NotFoundError(cache, key)
}
return read(cache, entry.integrity, { integrity, size }).then((data) => {
if (memoize)
if (memoize) {
memo.put(cache, entry, data, opts)
}
return {
data,
@ -46,12 +48,14 @@ module.exports = getData
function getDataByDigest (cache, key, opts = {}) {
const { integrity, memoize, size } = opts
const memoized = memo.get.byDigest(cache, key, opts)
if (memoized && memoize !== false)
if (memoized && memoize !== false) {
return Promise.resolve(memoized)
}
return read(cache, key, { integrity, size }).then((res) => {
if (memoize)
if (memoize) {
memo.put.byDigest(cache, key, res, opts)
}
return res
})
}
@ -70,8 +74,9 @@ function getDataSync (cache, key, opts = {}) {
}
}
const entry = index.find.sync(cache, key, opts)
if (!entry)
if (!entry) {
throw new index.NotFoundError(cache, key)
}
const data = read.sync(cache, entry.integrity, {
integrity: integrity,
size: size,
@ -82,8 +87,9 @@ function getDataSync (cache, key, opts = {}) {
size: entry.size,
integrity: entry.integrity,
}
if (memoize)
if (memoize) {
memo.put(cache, entry, res.data, opts)
}
return res
}
@ -94,15 +100,17 @@ function getDataByDigestSync (cache, digest, opts = {}) {
const { integrity, memoize, size } = opts
const memoized = memo.get.byDigest(cache, digest, opts)
if (memoized && memoize !== false)
if (memoized && memoize !== false) {
return memoized
}
const res = read.sync(cache, digest, {
integrity: integrity,
size: size,
})
if (memoize)
if (memoize) {
memo.put.byDigest(cache, digest, res, opts)
}
return res
}
@ -122,15 +130,17 @@ const getMemoizedStream = (memoized) => {
function getStream (cache, key, opts = {}) {
const { memoize, size } = opts
const memoized = memo.get(cache, key, opts)
if (memoized && memoize !== false)
if (memoized && memoize !== false) {
return getMemoizedStream(memoized)
}
const stream = new Pipeline()
index
.find(cache, key)
.then((entry) => {
if (!entry)
if (!entry) {
throw new index.NotFoundError(cache, key)
}
stream.emit('metadata', entry.metadata)
stream.emit('integrity', entry.integrity)
@ -170,8 +180,9 @@ function getStreamDigest (cache, integrity, opts = {}) {
return stream
} else {
const stream = read.readStream(cache, integrity, opts)
if (!memoize)
if (!memoize) {
return stream
}
const memoStream = new Collect.PassThrough()
memoStream.on('collect', data => memo.put.byDigest(
@ -189,18 +200,20 @@ module.exports.stream.byDigest = getStreamDigest
function info (cache, key, opts = {}) {
const { memoize } = opts
const memoized = memo.get(cache, key, opts)
if (memoized && memoize !== false)
if (memoized && memoize !== false) {
return Promise.resolve(memoized.entry)
else
} else {
return index.find(cache, key)
}
}
module.exports.info = info
function copy (cache, key, dest, opts = {}) {
if (read.copy) {
return index.find(cache, key, opts).then((entry) => {
if (!entry)
if (!entry) {
throw new index.NotFoundError(cache, key)
}
return read.copy(cache, entry.integrity, dest, opts)
.then(() => {
return {
@ -225,8 +238,9 @@ function copy (cache, key, dest, opts = {}) {
module.exports.copy = copy
function copyByDigest (cache, key, dest, opts = {}) {
if (read.copy)
if (read.copy) {
return read.copy(cache, key, dest, opts).then(() => key)
}
return getDataByDigest(cache, key, opts).then((res) => {
return writeFile(dest, res).then(() => key)

View File

@ -1,20 +1,19 @@
'use strict'
const ls = require('./ls.js')
const get = require('./get.js')
const put = require('./put.js')
const rm = require('./rm.js')
const verify = require('./verify.js')
const { clearMemoized } = require('./lib/memoization.js')
const tmp = require('./lib/util/tmp.js')
const index = require('./lib/entry-index.js')
const { clearMemoized } = require('./memoization.js')
const tmp = require('./util/tmp.js')
const index = require('./entry-index.js')
module.exports.index = {}
module.exports.index.compact = index.compact
module.exports.index.insert = index.insert
module.exports.ls = ls
module.exports.ls.stream = ls.stream
module.exports.ls = index.ls
module.exports.ls.stream = index.lsStream
module.exports.get = get
module.exports.get.byDigest = get.byDigest

View File

@ -2,13 +2,11 @@
const LRU = require('lru-cache')
const MAX_SIZE = 50 * 1024 * 1024 // 50MB
const MAX_AGE = 3 * 60 * 1000
const MEMOIZED = new LRU({
max: MAX_SIZE,
maxAge: MAX_AGE,
length: (entry, key) => key.startsWith('key:') ? entry.data.length : entry.length,
max: 500,
maxSize: 50 * 1024 * 1024, // 50MB
ttl: 3 * 60 * 1000, // 3 minutes
sizeCalculation: (entry, key) => key.startsWith('key:') ? entry.data.length : entry.length,
})
module.exports.clearMemoized = clearMemoized
@ -18,7 +16,7 @@ function clearMemoized () {
MEMOIZED.forEach((v, k) => {
old[k] = v
})
MEMOIZED.reset()
MEMOIZED.clear()
return old
}
@ -62,12 +60,13 @@ class ObjProxy {
}
function pickMem (opts) {
if (!opts || !opts.memoize)
if (!opts || !opts.memoize) {
return MEMOIZED
else if (opts.memoize.get && opts.memoize.set)
} else if (opts.memoize.get && opts.memoize.set) {
return opts.memoize
else if (typeof opts.memoize === 'object')
} else if (typeof opts.memoize === 'object') {
return new ObjProxy(opts.memoize)
else
} else {
return MEMOIZED
}
}

View File

@ -1,8 +1,8 @@
'use strict'
const index = require('./lib/entry-index')
const memo = require('./lib/memoization')
const write = require('./lib/content/write')
const index = require('./entry-index')
const memo = require('./memoization')
const write = require('./content/write')
const Flush = require('minipass-flush')
const { PassThrough } = require('minipass-collect')
const Pipeline = require('minipass-pipeline')
@ -21,8 +21,9 @@ function putData (cache, key, data, opts = {}) {
return index
.insert(cache, key, res.integrity, { ...opts, size: res.size })
.then((entry) => {
if (memoize)
if (memoize) {
memo.put(cache, entry, data, opts)
}
return res.integrity
})
@ -67,14 +68,17 @@ function putStream (cache, key, opts = {}) {
return index
.insert(cache, key, integrity, { ...opts, size })
.then((entry) => {
if (memoize && memoData)
if (memoize && memoData) {
memo.put(cache, entry, memoData, opts)
}
if (integrity)
if (integrity) {
pipeline.emit('integrity', integrity)
}
if (size)
if (size) {
pipeline.emit('size', size)
}
})
},
}))

View File

@ -2,11 +2,11 @@
const util = require('util')
const index = require('./lib/entry-index')
const memo = require('./lib/memoization')
const index = require('./entry-index')
const memo = require('./memoization')
const path = require('path')
const rimraf = util.promisify(require('rimraf'))
const rmContent = require('./lib/content/rm')
const rmContent = require('./content/rm')
module.exports = entry
module.exports.entry = entry

View File

@ -8,8 +8,9 @@ function disposer (creatorFn, disposerFn, fn) {
.then(
// disposer resolved, do something with original fn's promise
() => {
if (shouldThrow)
if (shouldThrow) {
throw result
}
return result
},

View File

@ -49,8 +49,9 @@ function fixOwner (cache, filepath) {
const { uid, gid } = owner
// No need to override if it's already what we used.
if (self.uid === uid && self.gid === gid)
if (self.uid === uid && self.gid === gid) {
return
}
return inflight('fixOwner: fixing ownership on ' + filepath, () =>
chownr(
@ -58,8 +59,9 @@ function fixOwner (cache, filepath) {
typeof uid === 'number' ? uid : self.uid,
typeof gid === 'number' ? gid : self.gid
).catch((err) => {
if (err.code === 'ENOENT')
if (err.code === 'ENOENT') {
return null
}
throw err
})
@ -93,8 +95,9 @@ function fixOwnerSync (cache, filepath) {
)
} catch (err) {
// only catch ENOENT, any other error is a problem.
if (err.code === 'ENOENT')
if (err.code === 'ENOENT') {
return null
}
throw err
}
@ -110,12 +113,14 @@ function mkdirfix (cache, p, cb) {
return Promise.resolve(inferOwner(cache)).then(() => {
return mkdirp(p)
.then((made) => {
if (made)
if (made) {
return fixOwner(cache, made).then(() => made)
}
})
.catch((err) => {
if (err.code === 'EEXIST')
if (err.code === 'EEXIST') {
return fixOwner(cache, p).then(() => null)
}
throw err
})
@ -136,7 +141,8 @@ function mkdirfixSync (cache, p) {
if (err.code === 'EEXIST') {
fixOwnerSync(cache, p)
return null
} else
} else {
throw err
}
}
}

View File

@ -38,10 +38,12 @@ function moveFile (src, dest) {
} else if (err.code === 'EEXIST' || err.code === 'EBUSY') {
// file already exists, so whatever
return resolve()
} else
} else {
return reject(err)
} else
}
} else {
return resolve()
}
})
})
.then(() => {

View File

@ -54,8 +54,9 @@ function verify (cache, opts) {
stats[k] = s[k]
})
const end = new Date()
if (!stats.runTime)
if (!stats.runTime) {
stats.runTime = {}
}
stats.runTime[label] = end - start
return Promise.resolve(stats)
@ -108,8 +109,9 @@ function garbageCollect (cache, opts) {
const indexStream = index.lsStream(cache)
const liveContent = new Set()
indexStream.on('data', (entry) => {
if (opts.filter && !opts.filter(entry))
if (opts.filter && !opts.filter(entry)) {
return
}
liveContent.add(entry.integrity.toString())
})
@ -176,8 +178,9 @@ function verifyContent (filepath, sri) {
return ssri
.checkStream(new fsm.ReadStream(filepath), sri)
.catch((err) => {
if (err.code !== 'EINTEGRITY')
if (err.code !== 'EINTEGRITY') {
throw err
}
return rimraf(filepath).then(() => {
contentInfo.valid = false
@ -186,8 +189,9 @@ function verifyContent (filepath, sri) {
.then(() => contentInfo)
})
.catch((err) => {
if (err.code === 'ENOENT')
if (err.code === 'ENOENT') {
return { size: 0, valid: false }
}
throw err
})
@ -209,9 +213,9 @@ function rebuildIndex (cache, opts) {
const entry = entries[k]
const excluded = opts.filter && !opts.filter(entry)
excluded && stats.rejectedEntries++
if (buckets[hashed] && !excluded)
if (buckets[hashed] && !excluded) {
buckets[hashed].push(entry)
else if (buckets[hashed] && excluded) {
} else if (buckets[hashed] && excluded) {
// skip
} else if (excluded) {
buckets[hashed] = []

View File

@ -1,6 +0,0 @@
'use strict'
const index = require('./lib/entry-index')
module.exports = index.ls
module.exports.stream = index.lsStream

View File

@ -1,14 +1,14 @@
{
"name": "cacache",
"version": "15.3.0",
"version": "16.0.2",
"cache-version": {
"content": "2",
"index": "5"
},
"description": "Fast, fault-tolerant, cross-platform, disk-based, data-agnostic, content-addressable cache.",
"main": "index.js",
"main": "lib/index.js",
"files": [
"*.js",
"bin",
"lib"
],
"scripts": {
@ -20,10 +20,13 @@
"snap": "tap",
"coverage": "tap",
"test-docker": "docker run -it --rm --name pacotest -v \"$PWD\":/tmp -w /tmp node:latest npm test",
"lint": "npm run npmclilint -- \"*.*js\" \"lib/**/*.*js\" \"test/**/*.*js\"",
"lint": "eslint '**/*.js'",
"npmclilint": "npmcli-lint",
"lintfix": "npm run lint -- --fix",
"postsnap": "npm run lintfix --"
"postsnap": "npm run lintfix --",
"postlint": "npm-template-check",
"template-copy": "npm-template-copy --force",
"posttest": "npm run lint"
},
"repository": "https://github.com/npm/cacache",
"keywords": [
@ -44,28 +47,28 @@
"license": "ISC",
"dependencies": {
"@npmcli/fs": "^1.0.0",
"@npmcli/move-file": "^1.0.1",
"@npmcli/move-file": "^1.1.2",
"chownr": "^2.0.0",
"fs-minipass": "^2.0.0",
"glob": "^7.1.4",
"fs-minipass": "^2.1.0",
"glob": "^7.2.0",
"infer-owner": "^1.0.4",
"lru-cache": "^6.0.0",
"minipass": "^3.1.1",
"lru-cache": "^7.5.1",
"minipass": "^3.1.6",
"minipass-collect": "^1.0.2",
"minipass-flush": "^1.0.5",
"minipass-pipeline": "^1.2.2",
"mkdirp": "^1.0.3",
"minipass-pipeline": "^1.2.4",
"mkdirp": "^1.0.4",
"p-map": "^4.0.0",
"promise-inflight": "^1.0.1",
"rimraf": "^3.0.2",
"ssri": "^8.0.1",
"tar": "^6.0.2",
"tar": "^6.1.11",
"unique-filename": "^1.1.1"
},
"devDependencies": {
"@npmcli/lint": "^1.0.1",
"@npmcli/template-oss": "^2.9.2",
"benchmark": "^2.1.4",
"chalk": "^4.0.0",
"chalk": "^4.1.2",
"require-inject": "^1.4.4",
"tacks": "^1.3.0",
"tap": "^15.0.9"
@ -75,6 +78,11 @@
"test-regex": "test/[^/]*.js"
},
"engines": {
"node": ">= 10"
}
"node": "^12.13.0 || ^14.15.0 || >=16"
},
"templateOSS": {
"windowsCI": false,
"version": "2.9.2"
},
"author": "GitHub Inc."
}

View File

@ -1,3 +0,0 @@
'use strict'
module.exports = require('./lib/verify')

View File

@ -1,37 +0,0 @@
declare namespace ansiRegex {
interface Options {
/**
Match only the first ANSI escape.
@default false
*/
onlyFirst: boolean;
}
}
/**
Regular expression for matching ANSI escape codes.
@example
```
import ansiRegex = require('ansi-regex');
ansiRegex().test('\u001B[4mcake\u001B[0m');
//=> true
ansiRegex().test('cake');
//=> false
'\u001B[4mcake\u001B[0m'.match(ansiRegex());
//=> ['\u001B[4m', '\u001B[0m']
'\u001B[4mcake\u001B[0m'.match(ansiRegex({onlyFirst: true}));
//=> ['\u001B[4m']
'\u001B]8;;https://github.com\u0007click\u001B]8;;\u0007'.match(ansiRegex());
//=> ['\u001B]8;;https://github.com\u0007', '\u001B]8;;\u0007']
```
*/
declare function ansiRegex(options?: ansiRegex.Options): RegExp;
export = ansiRegex;

View File

@ -1,10 +0,0 @@
'use strict';
module.exports = ({onlyFirst = false} = {}) => {
const pattern = [
'[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)',
'(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'
].join('|');
return new RegExp(pattern, onlyFirst ? undefined : 'g');
};

View File

@ -1,9 +0,0 @@
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -1,55 +0,0 @@
{
"name": "ansi-regex",
"version": "5.0.1",
"description": "Regular expression for matching ANSI escape codes",
"license": "MIT",
"repository": "chalk/ansi-regex",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=8"
},
"scripts": {
"test": "xo && ava && tsd",
"view-supported": "node fixtures/view-codes.js"
},
"files": [
"index.js",
"index.d.ts"
],
"keywords": [
"ansi",
"styles",
"color",
"colour",
"colors",
"terminal",
"console",
"cli",
"string",
"tty",
"escape",
"formatting",
"rgb",
"256",
"shell",
"xterm",
"command-line",
"text",
"regex",
"regexp",
"re",
"match",
"test",
"find",
"pattern"
],
"devDependencies": {
"ava": "^2.4.0",
"tsd": "^0.9.0",
"xo": "^0.25.3"
}
}

View File

@ -1,17 +0,0 @@
/**
Strip [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) from a string.
@example
```
import stripAnsi = require('strip-ansi');
stripAnsi('\u001B[4mUnicorn\u001B[0m');
//=> 'Unicorn'
stripAnsi('\u001B]8;;https://github.com\u0007Click\u001B]8;;\u0007');
//=> 'Click'
```
*/
declare function stripAnsi(string: string): string;
export = stripAnsi;

View File

@ -1,4 +0,0 @@
'use strict';
const ansiRegex = require('ansi-regex');
module.exports = string => typeof string === 'string' ? string.replace(ansiRegex(), '') : string;

View File

@ -1,9 +0,0 @@
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -1,54 +0,0 @@
{
"name": "strip-ansi",
"version": "6.0.1",
"description": "Strip ANSI escape codes from a string",
"license": "MIT",
"repository": "chalk/strip-ansi",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=8"
},
"scripts": {
"test": "xo && ava && tsd"
},
"files": [
"index.js",
"index.d.ts"
],
"keywords": [
"strip",
"trim",
"remove",
"ansi",
"styles",
"color",
"colour",
"colors",
"terminal",
"console",
"string",
"tty",
"escape",
"formatting",
"rgb",
"256",
"shell",
"xterm",
"log",
"logging",
"command-line",
"text"
],
"dependencies": {
"ansi-regex": "^5.0.1"
},
"devDependencies": {
"ava": "^2.4.0",
"tsd": "^0.10.0",
"xo": "^0.25.3"
}
}

View File

@ -1,45 +0,0 @@
var Gauge = require('./')
var gaugeDefault = require('./themes.js')
var onExit = require('signal-exit')
var activeGauge
onExit(function () {
activeGauge.disable()
})
var themes = gaugeDefault.getThemeNames()
nextBar()
function nextBar () {
var themeName = themes.shift()
console.log('Demoing output for ' + themeName)
var gt = new Gauge(process.stderr, {
updateInterval: 50,
theme: themeName,
cleanupOnExit: false,
})
activeGauge = gt
var progress = 0
var cnt = 0
var pulse = setInterval(function () {
gt.pulse('this is a thing that happened ' + (++cnt))
}, 110)
var prog = setInterval(function () {
progress += 0.04
gt.show(themeName + ':' + Math.round(progress * 1000), progress)
if (progress >= 1) {
clearInterval(prog)
clearInterval(pulse)
gt.disable()
if (themes.length) {
nextBar()
}
}
}, 100)
gt.show()
}

Some files were not shown because too many files have changed in this diff Show More