Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps: upgrade npm to 7.9.0 #38156

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions deps/npm/CHANGELOG.md
@@ -1,4 +1,23 @@
## v7.9.0 (2021-04-08)

### FEATURES

* [`1f3e88eba`](https://github.com/npm/cli/commit/1f3e88ebaf4901d8f9f07b43404d824fef7e5ff5)
[#3032](https://github.com/npm/cli/issues/3032)
feat(dist-tag): add workspace support
([@nlf](https://github.com/nlf))
* [`6e31df4e7`](https://github.com/npm/cli/commit/6e31df4e7957337962fd3d93e495931e3592bb9e)
[#3033](https://github.com/npm/cli/issues/3033)
feat(pack): add workspace support
([@wraithgar](https://github.com/wraithgar))

### DEPENDENCIES

* [`ba4f7fea8`](https://github.com/npm/cli/commit/ba4f7fea8fca8e3509469a218f094fe69095888b)
`licensee@8.2.0`

## v7.8.0 (2021-04-01)

### FEATURES


Expand Down
12 changes: 12 additions & 0 deletions deps/npm/docs/content/commands/npm-dist-tag.md
Expand Up @@ -88,6 +88,18 @@ semver as `>=1.4.0 <1.5.0`. See <https://github.com/npm/npm/issues/6082>.
The simplest way to avoid semver problems with tags is to use tags that do
not begin with a number or the letter `v`.

### Configuration

#### workspaces

Only supported by `ls`. Enables listing dist-tags of all workspace
contexts defined in the current `package.json`.

#### workspace

Only supported by `ls`. Enables listing dist-tags of workspace contexts
limiting results to only those specified by this config item.

### See Also

* [npm publish](/commands/npm-publish)
Expand Down
23 changes: 19 additions & 4 deletions deps/npm/docs/content/commands/npm-pack.md
Expand Up @@ -10,6 +10,25 @@ description: Create a tarball from a package
npm pack [[<@scope>/]<pkg>...] [--dry-run]
```

### Configuration

#### dry-run

Do everything that pack usually does without actually packing anything.
That is, report on what would have gone into the tarball, but nothing
else.

#### workspaces

Enables workspaces context while creating tarballs. Tarballs for each
workspaces will be generated.

#### workspace

Enables workspaces context and limits results to only those specified by
this config item. Tarballs will only be generated for the packages
named in the workspaces given here.

### Description

For anything that's installable (that is, a package folder, tarball,
Expand All @@ -23,10 +42,6 @@ overwritten the second time.

If no arguments are supplied, then npm packs the current package folder.

The `--dry-run` argument will do everything that pack usually does without
actually packing anything. That is, it reports on what would have gone
into the tarball, but nothing else.

### See Also

* [npm-packlist package](http://npm.im/npm-packlist)
Expand Down
9 changes: 8 additions & 1 deletion deps/npm/docs/output/commands/npm-dist-tag.html
Expand Up @@ -141,7 +141,7 @@ <h1 id="npm-dist-tag">npm-dist-tag</h1>

<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="#purpose">Purpose</a></li><li><a href="#caveats">Caveats</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="#purpose">Purpose</a></li><li><a href="#caveats">Caveats</a></li><li><a href="#configuration">Configuration</a></li><ul><li><a href="#workspaces">workspaces</a></li><li><a href="#workspace">workspace</a></li></ul><li><a href="#see-also">See Also</a></li></ul></div>
</section>

<div id="_content"><h3 id="synopsis">Synopsis</h3>
Expand Down Expand Up @@ -208,6 +208,13 @@ <h3 id="caveats">Caveats</h3>
semver as <code>&gt;=1.4.0 &lt;1.5.0</code>. See <a href="https://github.com/npm/npm/issues/6082">https://github.com/npm/npm/issues/6082</a>.</p>
<p>The simplest way to avoid semver problems with tags is to use tags that do
not begin with a number or the letter <code>v</code>.</p>
<h3 id="configuration">Configuration</h3>
<h4 id="workspaces">workspaces</h4>
<p>Only supported by <code>ls</code>. Enables listing dist-tags of all workspace
contexts defined in the current <code>package.json</code>.</p>
<h4 id="workspace">workspace</h4>
<p>Only supported by <code>ls</code>. Enables listing dist-tags of workspace contexts
limiting results to only those specified by this config item.</p>
<h3 id="see-also">See Also</h3>
<ul>
<li><a href="../commands/npm-publish.html">npm publish</a></li>
Expand Down
2 changes: 1 addition & 1 deletion deps/npm/docs/output/commands/npm-ls.html
Expand Up @@ -159,7 +159,7 @@ <h3 id="description">Description</h3>
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@7.8.0 /path/to/npm
<pre lang="bash"><code>npm@7.9.0 /path/to/npm
└─┬ init-package-json@0.0.4
└── promzard@0.1.5
</code></pre>
Expand Down
17 changes: 13 additions & 4 deletions deps/npm/docs/output/commands/npm-pack.html
Expand Up @@ -141,12 +141,24 @@ <h1 id="npm-pack">npm-pack</h1>

<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="#see-also">See Also</a></li></ul></div>
<div id="_table_of_contents"><ul><li><a href="#synopsis">Synopsis</a></li><li><a href="#configuration">Configuration</a></li><ul><li><a href="#dry-run">dry-run</a></li><li><a href="#workspaces">workspaces</a></li><li><a href="#workspace">workspace</a></li></ul><li><a href="#description">Description</a></li><li><a href="#see-also">See Also</a></li></ul></div>
</section>

<div id="_content"><h3 id="synopsis">Synopsis</h3>
<pre lang="bash"><code>npm pack [[&lt;@scope&gt;/]&lt;pkg&gt;...] [--dry-run]
</code></pre>
<h3 id="configuration">Configuration</h3>
<h4 id="dry-run">dry-run</h4>
<p>Do everything that pack usually does without actually packing anything.
That is, report on what would have gone into the tarball, but nothing
else.</p>
<h4 id="workspaces">workspaces</h4>
<p>Enables workspaces context while creating tarballs. Tarballs for each
workspaces will be generated.</p>
<h4 id="workspace">workspace</h4>
<p>Enables workspaces context and limits results to only those specified by
this config item. Tarballs will only be generated for the packages
named in the workspaces given here.</p>
<h3 id="description">Description</h3>
<p>For anything that’s installable (that is, a package folder, tarball,
tarball url, git url, name@tag, name@version, name, or scoped name), this
Expand All @@ -156,9 +168,6 @@ <h3 id="description">Description</h3>
<p>If the same package is specified multiple times, then the file will be
overwritten the second time.</p>
<p>If no arguments are supplied, then npm packs the current package folder.</p>
<p>The <code>--dry-run</code> argument will do everything that pack usually does without
actually packing anything. That is, it reports on what would have gone
into the tarball, but nothing else.</p>
<h3 id="see-also">See Also</h3>
<ul>
<li><a href="http://npm.im/npm-packlist">npm-packlist package</a></li>
Expand Down
2 changes: 1 addition & 1 deletion deps/npm/docs/output/commands/npm.html
Expand Up @@ -148,7 +148,7 @@ <h2 id="table-of-contents">Table of contents</h2>
<pre lang="bash"><code>npm &lt;command&gt; [args]
</code></pre>
<h3 id="version">Version</h3>
<p>7.8.0</p>
<p>7.9.0</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
Expand Down
56 changes: 52 additions & 4 deletions deps/npm/lib/dist-tag.js
Expand Up @@ -5,13 +5,19 @@ const semver = require('semver')

const otplease = require('./utils/otplease.js')
const readLocalPkgName = require('./utils/read-local-package.js')
const getWorkspaces = require('./workspaces/get-workspaces.js')
const BaseCommand = require('./base-command.js')

class DistTag extends BaseCommand {
static get description () {
return 'Modify package distribution tags'
}

/* istanbul ignore next - see test/lib/load-all-commands.js */
static get params () {
return ['workspace', 'workspaces']
}

/* istanbul ignore next - see test/lib/load-all-commands.js */
static get name () {
return 'dist-tag'
Expand Down Expand Up @@ -43,15 +49,14 @@ class DistTag extends BaseCommand {

async distTag ([cmdName, pkg, tag]) {
const opts = this.npm.flatOptions
const has = (items) => new Set(items).has(cmdName)

if (has(['add', 'a', 'set', 's']))
if (['add', 'a', 'set', 's'].includes(cmdName))
return this.add(pkg, tag, opts)

if (has(['rm', 'r', 'del', 'd', 'remove']))
if (['rm', 'r', 'del', 'd', 'remove'].includes(cmdName))
return this.remove(pkg, tag, opts)

if (has(['ls', 'l', 'sl', 'list']))
if (['ls', 'l', 'sl', 'list'].includes(cmdName))
return this.list(pkg, opts)

if (!pkg) {
Expand All @@ -62,6 +67,33 @@ class DistTag extends BaseCommand {
throw this.usage
}

execWorkspaces (args, filters, cb) {
this.distTagWorkspaces(args, filters).then(() => cb()).catch(cb)
}

async distTagWorkspaces ([cmdName, pkg, tag], filters) {
// cmdName is some form of list
// pkg is one of:
// - unset
// - .
// - .@version
if (['ls', 'l', 'sl', 'list'].includes(cmdName) && (!pkg || pkg === '.' || /^\.@/.test(pkg)))
return this.listWorkspaces(filters)

// pkg is unset
// cmdName is one of:
// - unset
// - .
// - .@version
if (!pkg && (!cmdName || cmdName === '.' || /^\.@/.test(cmdName)))
return this.listWorkspaces(filters)

// anything else is just a regular dist-tag command
// so we fallback to the non-workspaces implementation
log.warn('Ignoring workspaces for specified package')
return this.distTag([cmdName, pkg, tag])
}

async add (spec, tag, opts) {
spec = npa(spec || '')
const version = spec.rawSpec
Expand Down Expand Up @@ -145,6 +177,22 @@ class DistTag extends BaseCommand {
}
}

async listWorkspaces (filters) {
const workspaces =
await getWorkspaces(filters, { path: this.npm.localPrefix })

for (const [name] of workspaces) {
try {
this.npm.output(`${name}:`)
await this.list(npa(name), this.npm.flatOptions)
} catch (err) {
// set the exitCode directly, but ignore the error
// since it will have already been logged by this.list()
process.exitCode = 1
}
}
}

async fetchTags (spec, opts) {
const data = await regFetch.json(
`/-/package/${spec.escapedName}/dist-tags`,
Expand Down
23 changes: 22 additions & 1 deletion deps/npm/lib/pack.js
Expand Up @@ -3,6 +3,7 @@ const log = require('npmlog')
const pacote = require('pacote')
const libpack = require('libnpmpack')
const npa = require('npm-package-arg')
const getWorkspaces = require('./workspaces/get-workspaces.js')

const { getContents, logTar } = require('./utils/tar.js')

Expand All @@ -23,7 +24,7 @@ class Pack extends BaseCommand {

/* istanbul ignore next - see test/lib/load-all-commands.js */
static get params () {
return ['dry-run']
return ['dry-run', 'workspace', 'workspaces']
}

/* istanbul ignore next - see test/lib/load-all-commands.js */
Expand All @@ -35,6 +36,10 @@ class Pack extends BaseCommand {
this.pack(args).then(() => cb()).catch(cb)
}

execWorkspaces (args, filters, cb) {
this.packWorkspaces(args, filters).then(() => cb()).catch(cb)
}

async pack (args) {
if (args.length === 0)
args = ['.']
Expand Down Expand Up @@ -62,5 +67,21 @@ class Pack extends BaseCommand {
this.npm.output(tar.filename.replace(/^@/, '').replace(/\//, '-'))
}
}

async packWorkspaces (args, filters) {
// If they either ask for nothing, or explicitly include '.' in the args,
// we effectively translate that into each workspace requested

const useWorkspaces = args.length === 0 || args.includes('.')

if (!useWorkspaces) {
this.npm.log.warn('Ignoring workspaces for specified package(s)')
return this.pack(args)
}

const workspaces =
await getWorkspaces(filters, { path: this.npm.localPrefix })
return this.pack([...workspaces.values(), ...args.filter(a => a !== '.')])
}
}
module.exports = Pack
2 changes: 1 addition & 1 deletion deps/npm/lib/view.js
Expand Up @@ -151,7 +151,7 @@ class View extends BaseCommand {

const local = /^\.@/.test(pkg) || pkg === '.'
if (!local) {
this.npm.log.warn('Ignoring workspaces for remote package')
this.npm.log.warn('Ignoring workspaces for specified package(s)')
return this.view([pkg, ...args])
}
let wholePackument = false
Expand Down
9 changes: 9 additions & 0 deletions deps/npm/man/man1/npm-dist-tag.1
Expand Up @@ -90,6 +90,15 @@ semver as \fB>=1\.4\.0 <1\.5\.0\fP\|\. See https://github\.com/npm/npm/issues/6
.P
The simplest way to avoid semver problems with tags is to use tags that do
not begin with a number or the letter \fBv\fP\|\.
.SS Configuration
.SS workspaces
.P
Only supported by \fBls\fP\|\. Enables listing dist\-tags of all workspace
contexts defined in the current \fBpackage\.json\fP\|\.
.SS workspace
.P
Only supported by \fBls\fP\|\. Enables listing dist\-tags of workspace contexts
limiting results to only those specified by this config item\.
.SS See Also
.RS 0
.IP \(bu 2
Expand Down
2 changes: 1 addition & 1 deletion deps/npm/man/man1/npm-ls.1
Expand Up @@ -26,7 +26,7 @@ example, running \fBnpm ls promzard\fP in npm's source tree will show:
.P
.RS 2
.nf
npm@7\.8\.0 /path/to/npm
npm@7\.9\.0 /path/to/npm
└─┬ init\-package\-json@0\.0\.4
└── promzard@0\.1\.5
.fi
Expand Down
19 changes: 15 additions & 4 deletions deps/npm/man/man1/npm-pack.1
Expand Up @@ -8,6 +8,21 @@
npm pack [[<@scope>/]<pkg>\.\.\.] [\-\-dry\-run]
.fi
.RE
.SS Configuration
.SS dry\-run
.P
Do everything that pack usually does without actually packing anything\.
That is, report on what would have gone into the tarball, but nothing
else\.
.SS workspaces
.P
Enables workspaces context while creating tarballs\. Tarballs for each
workspaces will be generated\.
.SS workspace
.P
Enables workspaces context and limits results to only those specified by
this config item\. Tarballs will only be generated for the packages
named in the workspaces given here\.
.SS Description
.P
For anything that's installable (that is, a package folder, tarball,
Expand All @@ -20,10 +35,6 @@ If the same package is specified multiple times, then the file will be
overwritten the second time\.
.P
If no arguments are supplied, then npm packs the current package folder\.
.P
The \fB\-\-dry\-run\fP argument will do everything that pack usually does without
actually packing anything\. That is, it reports on what would have gone
into the tarball, but nothing else\.
.SS See Also
.RS 0
.IP \(bu 2
Expand Down
2 changes: 1 addition & 1 deletion deps/npm/man/man1/npm.1
Expand Up @@ -10,7 +10,7 @@ npm <command> [args]
.RE
.SS Version
.P
7\.8\.0
7\.9\.0
.SS Description
.P
npm is the package manager for the Node JavaScript platform\. It puts
Expand Down
2 changes: 1 addition & 1 deletion deps/npm/package.json
@@ -1,5 +1,5 @@
{
"version": "7.8.0",
"version": "7.9.0",
"name": "npm",
"description": "a package manager for JavaScript",
"keywords": [
Expand Down