Skip to content

Commit c748668

Browse files
ruyadornoTrott
authored andcommitted
deps: upgrade npm to 7.9.0
PR-URL: #38156 Reviewed-By: Myles Borins <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent 7e516aa commit c748668

21 files changed

+575
-59
lines changed

deps/npm/CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,23 @@
1+
## v7.9.0 (2021-04-08)
2+
3+
### FEATURES
4+
5+
* [`1f3e88eba`](https://github.com/npm/cli/commit/1f3e88ebaf4901d8f9f07b43404d824fef7e5ff5)
6+
[#3032](https://github.com/npm/cli/issues/3032)
7+
feat(dist-tag): add workspace support
8+
([@nlf](https://github.com/nlf))
9+
* [`6e31df4e7`](https://github.com/npm/cli/commit/6e31df4e7957337962fd3d93e495931e3592bb9e)
10+
[#3033](https://github.com/npm/cli/issues/3033)
11+
feat(pack): add workspace support
12+
([@wraithgar](https://github.com/wraithgar))
13+
14+
### DEPENDENCIES
15+
16+
* [`ba4f7fea8`](https://github.com/npm/cli/commit/ba4f7fea8fca8e3509469a218f094fe69095888b)
17+
18+
119
## v7.8.0 (2021-04-01)
20+
221
### FEATURES
322

423

deps/npm/docs/content/commands/npm-dist-tag.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,18 @@ semver as `>=1.4.0 <1.5.0`. See <https://github.com/npm/npm/issues/6082>.
8888
The simplest way to avoid semver problems with tags is to use tags that do
8989
not begin with a number or the letter `v`.
9090

91+
### Configuration
92+
93+
#### workspaces
94+
95+
Only supported by `ls`. Enables listing dist-tags of all workspace
96+
contexts defined in the current `package.json`.
97+
98+
#### workspace
99+
100+
Only supported by `ls`. Enables listing dist-tags of workspace contexts
101+
limiting results to only those specified by this config item.
102+
91103
### See Also
92104

93105
* [npm publish](/commands/npm-publish)

deps/npm/docs/content/commands/npm-pack.md

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,25 @@ description: Create a tarball from a package
1010
npm pack [[<@scope>/]<pkg>...] [--dry-run]
1111
```
1212

13+
### Configuration
14+
15+
#### dry-run
16+
17+
Do everything that pack usually does without actually packing anything.
18+
That is, report on what would have gone into the tarball, but nothing
19+
else.
20+
21+
#### workspaces
22+
23+
Enables workspaces context while creating tarballs. Tarballs for each
24+
workspaces will be generated.
25+
26+
#### workspace
27+
28+
Enables workspaces context and limits results to only those specified by
29+
this config item. Tarballs will only be generated for the packages
30+
named in the workspaces given here.
31+
1332
### Description
1433

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

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

26-
The `--dry-run` argument will do everything that pack usually does without
27-
actually packing anything. That is, it reports on what would have gone
28-
into the tarball, but nothing else.
29-
3045
### See Also
3146

3247
* [npm-packlist package](http://npm.im/npm-packlist)

deps/npm/docs/output/commands/npm-dist-tag.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ <h1 id="npm-dist-tag">npm-dist-tag</h1>
141141

142142
<section id="table_of_contents">
143143
<h2 id="table-of-contents">Table of contents</h2>
144-
<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>
144+
<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>
145145
</section>
146146

147147
<div id="_content"><h3 id="synopsis">Synopsis</h3>
@@ -208,6 +208,13 @@ <h3 id="caveats">Caveats</h3>
208208
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>
209209
<p>The simplest way to avoid semver problems with tags is to use tags that do
210210
not begin with a number or the letter <code>v</code>.</p>
211+
<h3 id="configuration">Configuration</h3>
212+
<h4 id="workspaces">workspaces</h4>
213+
<p>Only supported by <code>ls</code>. Enables listing dist-tags of all workspace
214+
contexts defined in the current <code>package.json</code>.</p>
215+
<h4 id="workspace">workspace</h4>
216+
<p>Only supported by <code>ls</code>. Enables listing dist-tags of workspace contexts
217+
limiting results to only those specified by this config item.</p>
211218
<h3 id="see-also">See Also</h3>
212219
<ul>
213220
<li><a href="../commands/npm-publish.html">npm publish</a></li>

deps/npm/docs/output/commands/npm-ls.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ <h3 id="description">Description</h3>
159159
the results to only the paths to the packages named. Note that nested
160160
packages will <em>also</em> show the paths to the specified packages. For
161161
example, running <code>npm ls promzard</code> in npm’s source tree will show:</p>
162-
<pre lang="bash"><code>npm@7.8.0 /path/to/npm
162+
<pre lang="bash"><code>npm@7.9.0 /path/to/npm
163163
164164
165165
</code></pre>

deps/npm/docs/output/commands/npm-pack.html

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,24 @@ <h1 id="npm-pack">npm-pack</h1>
141141

142142
<section id="table_of_contents">
143143
<h2 id="table-of-contents">Table of contents</h2>
144-
<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>
144+
<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>
145145
</section>
146146

147147
<div id="_content"><h3 id="synopsis">Synopsis</h3>
148148
<pre lang="bash"><code>npm pack [[&lt;@scope&gt;/]&lt;pkg&gt;...] [--dry-run]
149149
</code></pre>
150+
<h3 id="configuration">Configuration</h3>
151+
<h4 id="dry-run">dry-run</h4>
152+
<p>Do everything that pack usually does without actually packing anything.
153+
That is, report on what would have gone into the tarball, but nothing
154+
else.</p>
155+
<h4 id="workspaces">workspaces</h4>
156+
<p>Enables workspaces context while creating tarballs. Tarballs for each
157+
workspaces will be generated.</p>
158+
<h4 id="workspace">workspace</h4>
159+
<p>Enables workspaces context and limits results to only those specified by
160+
this config item. Tarballs will only be generated for the packages
161+
named in the workspaces given here.</p>
150162
<h3 id="description">Description</h3>
151163
<p>For anything that’s installable (that is, a package folder, tarball,
152164
tarball url, git url, name@tag, name@version, name, or scoped name), this
@@ -156,9 +168,6 @@ <h3 id="description">Description</h3>
156168
<p>If the same package is specified multiple times, then the file will be
157169
overwritten the second time.</p>
158170
<p>If no arguments are supplied, then npm packs the current package folder.</p>
159-
<p>The <code>--dry-run</code> argument will do everything that pack usually does without
160-
actually packing anything. That is, it reports on what would have gone
161-
into the tarball, but nothing else.</p>
162171
<h3 id="see-also">See Also</h3>
163172
<ul>
164173
<li><a href="http://npm.im/npm-packlist">npm-packlist package</a></li>

deps/npm/docs/output/commands/npm.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ <h2 id="table-of-contents">Table of contents</h2>
148148
<pre lang="bash"><code>npm &lt;command&gt; [args]
149149
</code></pre>
150150
<h3 id="version">Version</h3>
151-
<p>7.8.0</p>
151+
<p>7.9.0</p>
152152
<h3 id="description">Description</h3>
153153
<p>npm is the package manager for the Node JavaScript platform. It puts
154154
modules in place so that node can find them, and manages dependency

deps/npm/lib/dist-tag.js

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,19 @@ const semver = require('semver')
55

66
const otplease = require('./utils/otplease.js')
77
const readLocalPkgName = require('./utils/read-local-package.js')
8+
const getWorkspaces = require('./workspaces/get-workspaces.js')
89
const BaseCommand = require('./base-command.js')
910

1011
class DistTag extends BaseCommand {
1112
static get description () {
1213
return 'Modify package distribution tags'
1314
}
1415

16+
/* istanbul ignore next - see test/lib/load-all-commands.js */
17+
static get params () {
18+
return ['workspace', 'workspaces']
19+
}
20+
1521
/* istanbul ignore next - see test/lib/load-all-commands.js */
1622
static get name () {
1723
return 'dist-tag'
@@ -43,15 +49,14 @@ class DistTag extends BaseCommand {
4349

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

48-
if (has(['add', 'a', 'set', 's']))
53+
if (['add', 'a', 'set', 's'].includes(cmdName))
4954
return this.add(pkg, tag, opts)
5055

51-
if (has(['rm', 'r', 'del', 'd', 'remove']))
56+
if (['rm', 'r', 'del', 'd', 'remove'].includes(cmdName))
5257
return this.remove(pkg, tag, opts)
5358

54-
if (has(['ls', 'l', 'sl', 'list']))
59+
if (['ls', 'l', 'sl', 'list'].includes(cmdName))
5560
return this.list(pkg, opts)
5661

5762
if (!pkg) {
@@ -62,6 +67,33 @@ class DistTag extends BaseCommand {
6267
throw this.usage
6368
}
6469

70+
execWorkspaces (args, filters, cb) {
71+
this.distTagWorkspaces(args, filters).then(() => cb()).catch(cb)
72+
}
73+
74+
async distTagWorkspaces ([cmdName, pkg, tag], filters) {
75+
// cmdName is some form of list
76+
// pkg is one of:
77+
// - unset
78+
// - .
79+
// - .@version
80+
if (['ls', 'l', 'sl', 'list'].includes(cmdName) && (!pkg || pkg === '.' || /^\.@/.test(pkg)))
81+
return this.listWorkspaces(filters)
82+
83+
// pkg is unset
84+
// cmdName is one of:
85+
// - unset
86+
// - .
87+
// - .@version
88+
if (!pkg && (!cmdName || cmdName === '.' || /^\.@/.test(cmdName)))
89+
return this.listWorkspaces(filters)
90+
91+
// anything else is just a regular dist-tag command
92+
// so we fallback to the non-workspaces implementation
93+
log.warn('Ignoring workspaces for specified package')
94+
return this.distTag([cmdName, pkg, tag])
95+
}
96+
6597
async add (spec, tag, opts) {
6698
spec = npa(spec || '')
6799
const version = spec.rawSpec
@@ -145,6 +177,22 @@ class DistTag extends BaseCommand {
145177
}
146178
}
147179

180+
async listWorkspaces (filters) {
181+
const workspaces =
182+
await getWorkspaces(filters, { path: this.npm.localPrefix })
183+
184+
for (const [name] of workspaces) {
185+
try {
186+
this.npm.output(`${name}:`)
187+
await this.list(npa(name), this.npm.flatOptions)
188+
} catch (err) {
189+
// set the exitCode directly, but ignore the error
190+
// since it will have already been logged by this.list()
191+
process.exitCode = 1
192+
}
193+
}
194+
}
195+
148196
async fetchTags (spec, opts) {
149197
const data = await regFetch.json(
150198
`/-/package/${spec.escapedName}/dist-tags`,

deps/npm/lib/pack.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const log = require('npmlog')
33
const pacote = require('pacote')
44
const libpack = require('libnpmpack')
55
const npa = require('npm-package-arg')
6+
const getWorkspaces = require('./workspaces/get-workspaces.js')
67

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

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

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

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

39+
execWorkspaces (args, filters, cb) {
40+
this.packWorkspaces(args, filters).then(() => cb()).catch(cb)
41+
}
42+
3843
async pack (args) {
3944
if (args.length === 0)
4045
args = ['.']
@@ -62,5 +67,21 @@ class Pack extends BaseCommand {
6267
this.npm.output(tar.filename.replace(/^@/, '').replace(/\//, '-'))
6368
}
6469
}
70+
71+
async packWorkspaces (args, filters) {
72+
// If they either ask for nothing, or explicitly include '.' in the args,
73+
// we effectively translate that into each workspace requested
74+
75+
const useWorkspaces = args.length === 0 || args.includes('.')
76+
77+
if (!useWorkspaces) {
78+
this.npm.log.warn('Ignoring workspaces for specified package(s)')
79+
return this.pack(args)
80+
}
81+
82+
const workspaces =
83+
await getWorkspaces(filters, { path: this.npm.localPrefix })
84+
return this.pack([...workspaces.values(), ...args.filter(a => a !== '.')])
85+
}
6586
}
6687
module.exports = Pack

deps/npm/lib/view.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ class View extends BaseCommand {
151151

152152
const local = /^\.@/.test(pkg) || pkg === '.'
153153
if (!local) {
154-
this.npm.log.warn('Ignoring workspaces for remote package')
154+
this.npm.log.warn('Ignoring workspaces for specified package(s)')
155155
return this.view([pkg, ...args])
156156
}
157157
let wholePackument = false

0 commit comments

Comments
 (0)