Skip to content

Commit 75dbce9

Browse files
npm-cli-bottargos
authored andcommitted
deps: upgrade npm to 9.2.0
PR-URL: #45780 Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
1 parent 2e4d37e commit 75dbce9

166 files changed

Lines changed: 9178 additions & 695 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎deps/npm/docs/content/commands/npm-doctor.md‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ description: Check your npm environment
77
### Synopsis
88

99
```bash
10-
npm doctor
10+
npm doctor [ping] [registry] [versions] [environment] [permissions] [cache]
1111
```
1212

1313
Note: This command is unaware of workspaces.
@@ -33,8 +33,10 @@ Also, in addition to this, there are also very many issue reports due to
3333
using old versions of npm. Since npm is constantly improving, running
3434
`npm@latest` is better than an old version.
3535

36-
`npm doctor` verifies the following items in your environment, and if there
37-
are any recommended changes, it will display them.
36+
`npm doctor` verifies the following items in your environment, and if
37+
there are any recommended changes, it will display them. By default npm
38+
runs all of these checks. You can limit what checks are ran by
39+
specifying them as extra arguments.
3840

3941
#### `npm ping`
4042

‎deps/npm/docs/content/commands/npm-ls.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ packages will *also* show the paths to the specified packages. For
2727
example, running `npm ls promzard` in npm's source tree will show:
2828

2929
```bash
30-
npm@9.1.3 /path/to/npm
30+
npm@9.2.0 /path/to/npm
3131
└─┬ init-package-json@0.0.4
3232
└── promzard@0.1.5
3333
```

‎deps/npm/docs/content/commands/npm.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ npm
1212

1313
### Version
1414

15-
9.1.3
15+
9.2.0
1616

1717
### Description
1818

‎deps/npm/docs/output/commands/npm-doctor.html‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ <h2 id="table-of-contents">Table of contents</h2>
146146
</section>
147147

148148
<divid="_content"><h3id="synopsis">Synopsis</h3>
149-
<pre><codeclass="language-bash">npm doctor
149+
<pre><codeclass="language-bash">npm doctor [ping] [registry] [versions] [environment] [permissions] [cache]
150150
</code></pre>
151151
<p>Note: This command is unaware of workspaces.</p>
152152
<h3id="description">Description</h3>
@@ -167,8 +167,10 @@ <h3 id="description">Description</h3>
167167
<p>Also, in addition to this, there are also very many issue reports due to
168168
using old versions of npm. Since npm is constantly improving, running
169169
<code>npm@latest</code> is better than an old version.</p>
170-
<p><code>npm doctor</code> verifies the following items in your environment, and if there
171-
are any recommended changes, it will display them.</p>
170+
<p><code>npm doctor</code> verifies the following items in your environment, and if
171+
there are any recommended changes, it will display them. By default npm
172+
runs all of these checks. You can limit what checks are ran by
173+
specifying them as extra arguments.</p>
172174
<h4id="npm-ping"><code>npm ping</code></h4>
173175
<p>By default, npm installs from the primary npm registry,
174176
<code>registry.npmjs.org</code>. <code>npm doctor</code> hits a special ping endpoint within the

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ <h3 id="description">Description</h3>
160160
the results to only the paths to the packages named. Note that nested
161161
packages will <em>also</em> show the paths to the specified packages. For
162162
example, running <code>npm ls promzard</code> in npm's source tree will show:</p>
163-
<pre><codeclass="language-bash">npm@9.1.3 /path/to/npm
163+
<pre><codeclass="language-bash">npm@9.2.0 /path/to/npm
164164
└─┬ init-package-json@0.0.4
165165
└── promzard@0.1.5
166166
</code></pre>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ <h2 id="table-of-contents">Table of contents</h2>
149149
<pre><codeclass="language-bash">npm
150150
</code></pre>
151151
<h3id="version">Version</h3>
152-
<p>9.1.3</p>
152+
<p>9.2.0</p>
153153
<h3id="description">Description</h3>
154154
<p>npm is the package manager for the Node JavaScript platform. It puts
155155
modules in place so that node can find them, and manages dependency

‎deps/npm/lib/commands/completion.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const BaseCommand = require('../base-command.js')
5454
classCompletionextendsBaseCommand{
5555
staticdescription='Tab Completion for npm'
5656
staticname='completion'
57-
staticignoreImplicitWorkspace=false
57+
staticignoreImplicitWorkspace=true
5858

5959
// completion for the completion command
6060
asynccompletion(opts){

‎deps/npm/lib/commands/doctor.js‎

Lines changed: 162 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
constcacache=require('cacache')
22
constfs=require('fs')
33
constfetch=require('make-fetch-happen')
4-
consttable=require('text-table')
4+
constTable=require('cli-table3')
55
constwhich=require('which')
66
constpacote=require('pacote')
77
const{ resolve }=require('path')
88
constsemver=require('semver')
99
const{ promisify }=require('util')
1010
constlog=require('../utils/log-shim.js')
11-
constansiTrim=require('../utils/ansi-trim.js')
1211
constping=require('../utils/ping.js')
1312
const{
1413
registry: {default: defaultRegistry},
@@ -17,6 +16,7 @@ const lstat = promisify(fs.lstat)
1716
constreaddir=promisify(fs.readdir)
1817
constaccess=promisify(fs.access)
1918
const{R_OK,W_OK,X_OK}=fs.constants
19+
2020
constmaskLabel=mask=>{
2121
constlabel=[]
2222
if(mask&R_OK){
@@ -34,76 +34,105 @@ const maskLabel = mask => {
3434
returnlabel.join(', ')
3535
}
3636

37+
constsubcommands=[
38+
{
39+
groups: ['ping','registry'],
40+
title: 'npm ping',
41+
cmd: 'checkPing',
42+
},{
43+
groups: ['versions'],
44+
title: 'npm -v',
45+
cmd: 'getLatestNpmVersion',
46+
},{
47+
groups: ['versions'],
48+
title: 'node -v',
49+
cmd: 'getLatestNodejsVersion',
50+
},{
51+
groups: ['registry'],
52+
title: 'npm config get registry',
53+
cmd: 'checkNpmRegistry',
54+
},{
55+
groups: ['environment'],
56+
title: 'git executable in PATH',
57+
cmd: 'getGitPath',
58+
},{
59+
groups: ['environment'],
60+
title: 'global bin folder in PATH',
61+
cmd: 'getBinPath',
62+
},{
63+
groups: ['permissions','cache'],
64+
title: 'Perms check on cached files',
65+
cmd: 'checkCachePermission',
66+
windows: false,
67+
},{
68+
groups: ['permissions'],
69+
title: 'Perms check on local node_modules',
70+
cmd: 'checkLocalModulesPermission',
71+
windows: false,
72+
},{
73+
groups: ['permissions'],
74+
title: 'Perms check on global node_modules',
75+
cmd: 'checkGlobalModulesPermission',
76+
windows: false,
77+
},{
78+
groups: ['permissions'],
79+
title: 'Perms check on local bin folder',
80+
cmd: 'checkLocalBinPermission',
81+
windows: false,
82+
},{
83+
groups: ['permissions'],
84+
title: 'Perms check on global bin folder',
85+
cmd: 'checkGlobalBinPermission',
86+
windows: false,
87+
},{
88+
groups: ['cache'],
89+
title: 'Verify cache contents',
90+
cmd: 'verifyCachedFiles',
91+
windows: false,
92+
},
93+
// TODO:
94+
// group === 'dependencies'?
95+
// - ensure arborist.loadActual() runs without errors and no invalid edges
96+
// - ensure package-lock.json matches loadActual()
97+
// - verify loadActual without hidden lock file matches hidden lockfile
98+
// group === '???'
99+
// - verify all local packages have bins linked
100+
// What is the fix for these?
101+
]
37102
constBaseCommand=require('../base-command.js')
38103
classDoctorextendsBaseCommand{
39104
staticdescription='Check your npm environment'
40105
staticname='doctor'
41106
staticparams=['registry']
42107
staticignoreImplicitWorkspace=false
108+
staticusage=[`[${subcommands.flatMap(s=>s.groups)
109+
.filter((value,index,self)=>self.indexOf(value)===index)
110+
.join('] [')}]`]
111+
112+
staticsubcommands=subcommands
113+
114+
// minimum width of check column, enough for the word `Check`
115+
#checkWidth =5
43116

44117
asyncexec(args){
45118
log.info('Running checkup')
119+
letallOk=true
46120

47-
// each message is [title, ok, message]
48-
constmessages=[]
49-
50-
constactions=[
51-
['npm ping','checkPing',[]],
52-
['npm -v','getLatestNpmVersion',[]],
53-
['node -v','getLatestNodejsVersion',[]],
54-
['npm config get registry','checkNpmRegistry',[]],
55-
['which git','getGitPath',[]],
56-
...(process.platform==='win32'
57-
? []
58-
: [
59-
[
60-
'Perms check on cached files',
61-
'checkFilesPermission',
62-
[this.npm.cache,true,R_OK],
63-
],[
64-
'Perms check on local node_modules',
65-
'checkFilesPermission',
66-
[this.npm.localDir,true,R_OK|W_OK,true],
67-
],[
68-
'Perms check on global node_modules',
69-
'checkFilesPermission',
70-
[this.npm.globalDir,false,R_OK],
71-
],[
72-
'Perms check on local bin folder',
73-
'checkFilesPermission',
74-
[this.npm.localBin,false,R_OK|W_OK|X_OK,true],
75-
],[
76-
'Perms check on global bin folder',
77-
'checkFilesPermission',
78-
[this.npm.globalBin,false,X_OK],
79-
],
80-
]),
81-
[
82-
'Verify cache contents',
83-
'verifyCachedFiles',
84-
[this.npm.flatOptions.cache],
85-
],
86-
// TODO:
87-
// - ensure arborist.loadActual() runs without errors and no invalid edges
88-
// - ensure package-lock.json matches loadActual()
89-
// - verify loadActual without hidden lock file matches hidden lockfile
90-
// - verify all local packages have bins linked
91-
]
121+
constactions=this.actions(args)
122+
this.#checkWidth =actions.reduce((length,item)=>
123+
Math.max(item.title.length,length),this.#checkWidth)
92124

125+
if(!this.npm.silent){
126+
this.output(['Check','Value','Recommendation/Notes'].map(h=>this.npm.chalk.underline(h)))
127+
}
93128
// Do the actual work
94-
for(const[msg,fn,args]ofactions){
95-
constline=[msg]
129+
for(const{ title, cmd }ofactions){
130+
constitem=[title]
96131
try{
97-
line.push(true,awaitthis[fn](...args))
98-
}catch(er){
99-
line.push(false,er)
132+
item.push(true,awaitthis[cmd]())
133+
}catch(err){
134+
item.push(false,err)
100135
}
101-
messages.push(line)
102-
}
103-
104-
constoutHead=['Check','Value','Recommendation/Notes'].map(h=>this.npm.chalk.underline(h))
105-
letallOk=true
106-
constoutBody=messages.map(item=>{
107136
if(!item[1]){
108137
allOk=false
109138
item[0]=this.npm.chalk.red(item[0])
@@ -112,18 +141,18 @@ class Doctor extends BaseCommand {
112141
}else{
113142
item[1]=this.npm.chalk.green('ok')
114143
}
115-
returnitem
116-
})
117-
constoutTable=[outHead, ...outBody]
118-
consttableOpts={
119-
stringLength: s=>ansiTrim(s).length,
144+
if(!this.npm.silent){
145+
this.output(item)
146+
}
120147
}
121148

122-
if(!this.npm.silent){
123-
this.npm.output(table(outTable,tableOpts))
124-
}
125149
if(!allOk){
126-
thrownewError('Some problems found. See above for recommendations.')
150+
if(this.npm.silent){
151+
/* eslint-disable-next-line max-len */
152+
thrownewError('Some problems found. Check logs or disable silent mode for recommendations.')
153+
}else{
154+
thrownewError('Some problems found. See above for recommendations.')
155+
}
127156
}
128157
}
129158

@@ -191,6 +220,35 @@ class Doctor extends BaseCommand {
191220
}
192221
}
193222

223+
asyncgetBinPath(dir){
224+
consttracker=log.newItem('getBinPath',1)
225+
tracker.info('getBinPath','Finding npm global bin in your PATH')
226+
if(!process.env.PATH.includes(this.npm.globalBin)){
227+
thrownewError(`Add ${this.npm.globalBin} to your $PATH`)
228+
}
229+
returnthis.npm.globalBin
230+
}
231+
232+
asynccheckCachePermission(){
233+
returnthis.checkFilesPermission(this.npm.cache,true,R_OK)
234+
}
235+
236+
asynccheckLocalModulesPermission(){
237+
returnthis.checkFilesPermission(this.npm.localDir,true,R_OK|W_OK,true)
238+
}
239+
240+
asynccheckGlobalModulesPermission(){
241+
returnthis.checkFilesPermission(this.npm.globalDir,false,R_OK)
242+
}
243+
244+
asynccheckLocalBinPermission(){
245+
returnthis.checkFilesPermission(this.npm.localBin,false,R_OK|W_OK|X_OK,true)
246+
}
247+
248+
asynccheckGlobalBinPermission(){
249+
returnthis.checkFilesPermission(this.npm.globalBin,false,X_OK)
250+
}
251+
194252
asynccheckFilesPermission(root,shouldOwn,mask,missingOk){
195253
letok=true
196254

@@ -264,7 +322,7 @@ class Doctor extends BaseCommand {
264322
try{
265323
returnawaitwhich('git').catch(er=>{
266324
tracker.warn(er)
267-
throw"Install git and ensure it's in your PATH."
325+
thrownewError("Install git and ensure it's in your PATH.")
268326
})
269327
}finally{
270328
tracker.finish()
@@ -312,6 +370,42 @@ class Doctor extends BaseCommand {
312370
return`using default registry (${defaultRegistry})`
313371
}
314372
}
373+
374+
output(row){
375+
constt=newTable({
376+
chars: {top: '',
377+
'top-mid': '',
378+
'top-left': '',
379+
'top-right': '',
380+
bottom: '',
381+
'bottom-mid': '',
382+
'bottom-left': '',
383+
'bottom-right': '',
384+
left: '',
385+
'left-mid': '',
386+
mid: '',
387+
'mid-mid': '',
388+
right: '',
389+
'right-mid': '',
390+
middle: ' '},
391+
style: {'padding-left': 0,'padding-right': 0},
392+
colWidths: [this.#checkWidth,6],
393+
})
394+
t.push(row)
395+
this.npm.output(t.toString())
396+
}
397+
398+
actions(params){
399+
returnthis.constructor.subcommands.filter(subcmd=>{
400+
if(process.platform==='win32'&&subcmd.windows===false){
401+
returnfalse
402+
}
403+
if(params.length){
404+
returnparams.some(param=>subcmd.groups.includes(param))
405+
}
406+
returntrue
407+
})
408+
}
315409
}
316410

317411
module.exports=Doctor

‎deps/npm/man/man1/npm-access.1‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.TH "NPM-ACCESS" "1" "November 2022" "" ""
1+
.TH "NPM-ACCESS" "1" "December 2022" "" ""
22
.SH "NAME"
33
\fBnpm-access\fR - Set access level on published packages
44
.SS "Synopsis"

0 commit comments

Comments
 (0)