Skip to content

Commit ce9089f

Browse files
committedOct 2, 2023
deps: npm-package-arg@11.0.1
1 parent 39d7f04 commit ce9089f

File tree

11 files changed

+71
-73
lines changed

11 files changed

+71
-73
lines changed
 

‎mock-registry/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"@npmcli/template-oss": "4.19.0",
5151
"json-stringify-safe": "^5.0.1",
5252
"nock": "^13.3.3",
53-
"npm-package-arg": "^11.0.0",
53+
"npm-package-arg": "^11.0.1",
5454
"pacote": "^17.0.4",
5555
"tap": "^16.3.8"
5656
}

‎node_modules/npm-package-arg/lib/npa.js

+49-52
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module.exports.resolve = resolve
44
module.exports.toPurl = toPurl
55
module.exports.Result = Result
66

7-
const url = require('url')
7+
const { URL } = require('url')
88
const HostedGit = require('hosted-git-info')
99
const semver = require('semver')
1010
const path = global.FAKE_WINDOWS ? require('path').win32 : require('path')
@@ -183,10 +183,11 @@ Result.prototype.toJSON = function () {
183183
return result
184184
}
185185

186-
function setGitCommittish (res, committish) {
186+
// sets res.gitCommittish, res.gitRange, and res.gitSubdir
187+
function setGitAttrs (res, committish) {
187188
if (!committish) {
188189
res.gitCommittish = null
189-
return res
190+
return
190191
}
191192

192193
// for each :: separated item:
@@ -224,8 +225,6 @@ function setGitCommittish (res, committish) {
224225
}
225226
log.warn('npm-package-arg', `ignoring unknown key "${name}"`)
226227
}
227-
228-
return res
229228
}
230229

231230
function fromFile (res, where) {
@@ -245,10 +244,10 @@ function fromFile (res, where) {
245244
const rawWithPrefix = prefix + res.rawSpec
246245
let rawNoPrefix = rawWithPrefix.replace(/^file:/, '')
247246
try {
248-
resolvedUrl = new url.URL(rawWithPrefix, `file://${path.resolve(where)}/`)
249-
specUrl = new url.URL(rawWithPrefix)
247+
resolvedUrl = new URL(rawWithPrefix, `file://${path.resolve(where)}/`)
248+
specUrl = new URL(rawWithPrefix)
250249
} catch (originalError) {
251-
const er = new Error('Invalid file: URL, must comply with RFC 8909')
250+
const er = new Error('Invalid file: URL, must comply with RFC 8089')
252251
throw Object.assign(er, {
253252
raw: res.rawSpec,
254253
spec: res,
@@ -257,23 +256,23 @@ function fromFile (res, where) {
257256
})
258257
}
259258

260-
// XXX backwards compatibility lack of compliance with RFC 8909
259+
// XXX backwards compatibility lack of compliance with RFC 8089
261260
if (resolvedUrl.host && resolvedUrl.host !== 'localhost') {
262261
const rawSpec = res.rawSpec.replace(/^file:\/\//, 'file:///')
263-
resolvedUrl = new url.URL(rawSpec, `file://${path.resolve(where)}/`)
264-
specUrl = new url.URL(rawSpec)
262+
resolvedUrl = new URL(rawSpec, `file://${path.resolve(where)}/`)
263+
specUrl = new URL(rawSpec)
265264
rawNoPrefix = rawSpec.replace(/^file:/, '')
266265
}
267266
// turn file:/../foo into file:../foo
268267
// for 1, 2 or 3 leading slashes since we attempted
269268
// in the previous step to make it a file protocol url with a leading slash
270269
if (/^\/{1,3}\.\.?(\/|$)/.test(rawNoPrefix)) {
271270
const rawSpec = res.rawSpec.replace(/^file:\/{1,3}/, 'file:')
272-
resolvedUrl = new url.URL(rawSpec, `file://${path.resolve(where)}/`)
273-
specUrl = new url.URL(rawSpec)
271+
resolvedUrl = new URL(rawSpec, `file://${path.resolve(where)}/`)
272+
specUrl = new URL(rawSpec)
274273
rawNoPrefix = rawSpec.replace(/^file:/, '')
275274
}
276-
// XXX end RFC 8909 violation backwards compatibility section
275+
// XXX end RFC 8089 violation backwards compatibility section
277276

278277
// turn /C:/blah into just C:/blah on windows
279278
let specPath = decodeURIComponent(specUrl.pathname)
@@ -303,7 +302,8 @@ function fromHostedGit (res, hosted) {
303302
res.hosted = hosted
304303
res.saveSpec = hosted.toString({ noGitPlus: false, noCommittish: false })
305304
res.fetchSpec = hosted.getDefaultRepresentation() === 'shortcut' ? null : hosted.toString()
306-
return setGitCommittish(res, hosted.committish)
305+
setGitAttrs(res, hosted.committish)
306+
return res
307307
}
308308

309309
function unsupportedURLType (protocol, spec) {
@@ -312,62 +312,59 @@ function unsupportedURLType (protocol, spec) {
312312
return err
313313
}
314314

315-
function matchGitScp (spec) {
316-
// git ssh specifiers are overloaded to also use scp-style git
317-
// specifiers, so we have to parse those out and treat them special.
318-
// They are NOT true URIs, so we can't hand them to `url.parse`.
319-
//
320-
// This regex looks for things that look like:
321-
// git+ssh://git@my.custom.git.com:username/project.git#deadbeef
322-
//
323-
// ...and various combinations. The username in the beginning is *required*.
324-
const matched = spec.match(/^git\+ssh:\/\/([^:#]+:[^#]+(?:\.git)?)(?:#(.*))?$/i)
325-
return matched && !matched[1].match(/:[0-9]+\/?.*$/i) && {
326-
fetchSpec: matched[1],
327-
gitCommittish: matched[2] == null ? null : matched[2],
328-
}
329-
}
330-
331315
function fromURL (res) {
332-
// eslint-disable-next-line node/no-deprecated-api
333-
const urlparse = url.parse(res.rawSpec)
334-
res.saveSpec = res.rawSpec
316+
let rawSpec = res.rawSpec
317+
res.saveSpec = rawSpec
318+
if (rawSpec.startsWith('git+ssh:')) {
319+
// git ssh specifiers are overloaded to also use scp-style git
320+
// specifiers, so we have to parse those out and treat them special.
321+
// They are NOT true URIs, so we can't hand them to URL.
322+
323+
// This regex looks for things that look like:
324+
// git+ssh://git@my.custom.git.com:username/project.git#deadbeef
325+
// ...and various combinations. The username in the beginning is *required*.
326+
const matched = rawSpec.match(/^git\+ssh:\/\/([^:#]+:[^#]+(?:\.git)?)(?:#(.*))?$/i)
327+
if (matched && !matched[1].match(/:[0-9]+\/?.*$/i)) {
328+
res.type = 'git'
329+
setGitAttrs(res, matched[2])
330+
res.fetchSpec = matched[1]
331+
return res
332+
}
333+
} else if (rawSpec.startsWith('git+file://')) {
334+
// URL can't handle windows paths
335+
rawSpec = rawSpec.replace(/\\/g, '/')
336+
}
337+
const parsedUrl = new URL(rawSpec)
335338
// check the protocol, and then see if it's git or not
336-
switch (urlparse.protocol) {
339+
switch (parsedUrl.protocol) {
337340
case 'git:':
338341
case 'git+http:':
339342
case 'git+https:':
340343
case 'git+rsync:':
341344
case 'git+ftp:':
342345
case 'git+file:':
343-
case 'git+ssh:': {
346+
case 'git+ssh:':
344347
res.type = 'git'
345-
const match = urlparse.protocol === 'git+ssh:' ? matchGitScp(res.rawSpec)
346-
: null
347-
if (match) {
348-
setGitCommittish(res, match.gitCommittish)
349-
res.fetchSpec = match.fetchSpec
348+
setGitAttrs(res, parsedUrl.hash.slice(1))
349+
if (parsedUrl.protocol === 'git+file:' && /^git\+file:\/\/[a-z]:/i.test(rawSpec)) {
350+
// URL can't handle drive letters on windows file paths, the host can't contain a :
351+
res.fetchSpec = `git+file://${parsedUrl.host.toLowerCase()}:${parsedUrl.pathname}`
350352
} else {
351-
setGitCommittish(res, urlparse.hash != null ? urlparse.hash.slice(1) : '')
352-
urlparse.protocol = urlparse.protocol.replace(/^git[+]/, '')
353-
if (urlparse.protocol === 'file:' && /^git\+file:\/\/[a-z]:/i.test(res.rawSpec)) {
354-
// keep the drive letter : on windows file paths
355-
urlparse.host += ':'
356-
urlparse.hostname += ':'
357-
}
358-
delete urlparse.hash
359-
res.fetchSpec = url.format(urlparse)
353+
parsedUrl.hash = ''
354+
res.fetchSpec = parsedUrl.toString()
355+
}
356+
if (res.fetchSpec.startsWith('git+')) {
357+
res.fetchSpec = res.fetchSpec.slice(4)
360358
}
361359
break
362-
}
363360
case 'http:':
364361
case 'https:':
365362
res.type = 'remote'
366363
res.fetchSpec = res.saveSpec
367364
break
368365

369366
default:
370-
throw unsupportedURLType(urlparse.protocol, res.rawSpec)
367+
throw unsupportedURLType(parsedUrl.protocol, rawSpec)
371368
}
372369

373370
return res

‎node_modules/npm-package-arg/package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "npm-package-arg",
3-
"version": "11.0.0",
3+
"version": "11.0.1",
44
"description": "Parse the things that can be arguments to `npm install`",
55
"main": "./lib/npa.js",
66
"directories": {
@@ -61,6 +61,7 @@
6161
"16.x",
6262
"18.0.0",
6363
"18.x"
64-
]
64+
],
65+
"npmSpec": "next-9"
6566
}
6667
}

‎package-lock.json

+11-11
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
"normalize-package-data": "^6.0.0",
137137
"npm-audit-report": "^5.0.0",
138138
"npm-install-checks": "^6.2.0",
139-
"npm-package-arg": "^11.0.0",
139+
"npm-package-arg": "^11.0.1",
140140
"npm-pick-manifest": "^9.0.0",
141141
"npm-profile": "^9.0.0",
142142
"npm-registry-fetch": "^16.0.0",
@@ -238,7 +238,7 @@
238238
"@npmcli/template-oss": "4.19.0",
239239
"json-stringify-safe": "^5.0.1",
240240
"nock": "^13.3.3",
241-
"npm-package-arg": "^11.0.0",
241+
"npm-package-arg": "^11.0.1",
242242
"pacote": "^17.0.4",
243243
"tap": "^16.3.8"
244244
},
@@ -10872,9 +10872,9 @@
1087210872
}
1087310873
},
1087410874
"node_modules/npm-package-arg": {
10875-
"version": "11.0.0",
10876-
"resolved": "https://registry.npmjs.org/npm-package-arg/-/npm-package-arg-11.0.0.tgz",
10877-
"integrity": "sha512-D8sItaQ8n6VlBUFed3DLz2sCpkabRAjaiLkTamDppvh8lmmAPirzNfBuhJd/2rlmoxZ2S9mOHmIEvzV2z2jOeA==",
10875+
"version": "11.0.1",
10876+
"resolved": "https://registry.npmjs.org/npm-package-arg/-/npm-package-arg-11.0.1.tgz",
10877+
"integrity": "sha512-M7s1BD4NxdAvBKUPqqRW957Xwcl/4Zvo8Aj+ANrzvIPzGJZElrH7Z//rSaec2ORcND6FHHLnZeY8qgTpXDMFQQ==",
1087810878
"inBundle": true,
1087910879
"dependencies": {
1088010880
"hosted-git-info": "^7.0.0",
@@ -17020,7 +17020,7 @@
1702017020
"minimatch": "^9.0.0",
1702117021
"nopt": "^7.0.0",
1702217022
"npm-install-checks": "^6.2.0",
17023-
"npm-package-arg": "^11.0.0",
17023+
"npm-package-arg": "^11.0.1",
1702417024
"npm-pick-manifest": "^9.0.0",
1702517025
"npm-registry-fetch": "^16.0.0",
1702617026
"npmlog": "^7.0.1",
@@ -17080,7 +17080,7 @@
1708017080
"version": "8.0.0",
1708117081
"license": "ISC",
1708217082
"dependencies": {
17083-
"npm-package-arg": "^11.0.0",
17083+
"npm-package-arg": "^11.0.1",
1708417084
"npm-registry-fetch": "^16.0.0"
1708517085
},
1708617086
"devDependencies": {
@@ -17104,7 +17104,7 @@
1710417104
"binary-extensions": "^2.2.0",
1710517105
"diff": "^5.1.0",
1710617106
"minimatch": "^9.0.0",
17107-
"npm-package-arg": "^11.0.0",
17107+
"npm-package-arg": "^11.0.1",
1710817108
"pacote": "^17.0.4",
1710917109
"tar": "^6.1.13"
1711017110
},
@@ -17124,7 +17124,7 @@
1712417124
"@npmcli/arborist": "^7.1.0",
1712517125
"@npmcli/run-script": "^7.0.1",
1712617126
"ci-info": "^3.7.1",
17127-
"npm-package-arg": "^11.0.0",
17127+
"npm-package-arg": "^11.0.1",
1712817128
"npmlog": "^7.0.1",
1712917129
"pacote": "^17.0.4",
1713017130
"proc-log": "^3.0.0",
@@ -17203,7 +17203,7 @@
1720317203
"dependencies": {
1720417204
"@npmcli/arborist": "^7.1.0",
1720517205
"@npmcli/run-script": "^7.0.1",
17206-
"npm-package-arg": "^11.0.0",
17206+
"npm-package-arg": "^11.0.1",
1720717207
"pacote": "^17.0.4"
1720817208
},
1720917209
"devDependencies": {
@@ -17223,7 +17223,7 @@
1722317223
"dependencies": {
1722417224
"ci-info": "^3.6.1",
1722517225
"normalize-package-data": "^6.0.0",
17226-
"npm-package-arg": "^11.0.0",
17226+
"npm-package-arg": "^11.0.1",
1722717227
"npm-registry-fetch": "^16.0.0",
1722817228
"proc-log": "^3.0.0",
1722917229
"semver": "^7.3.7",

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
"normalize-package-data": "^6.0.0",
9999
"npm-audit-report": "^5.0.0",
100100
"npm-install-checks": "^6.2.0",
101-
"npm-package-arg": "^11.0.0",
101+
"npm-package-arg": "^11.0.1",
102102
"npm-pick-manifest": "^9.0.0",
103103
"npm-profile": "^9.0.0",
104104
"npm-registry-fetch": "^16.0.0",

‎workspaces/arborist/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"minimatch": "^9.0.0",
2323
"nopt": "^7.0.0",
2424
"npm-install-checks": "^6.2.0",
25-
"npm-package-arg": "^11.0.0",
25+
"npm-package-arg": "^11.0.1",
2626
"npm-pick-manifest": "^9.0.0",
2727
"npm-registry-fetch": "^16.0.0",
2828
"npmlog": "^7.0.1",

‎workspaces/libnpmaccess/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"bugs": "https://github.com/npm/libnpmaccess/issues",
3030
"homepage": "https://npmjs.com/package/libnpmaccess",
3131
"dependencies": {
32-
"npm-package-arg": "^11.0.0",
32+
"npm-package-arg": "^11.0.1",
3333
"npm-registry-fetch": "^16.0.0"
3434
},
3535
"engines": {

‎workspaces/libnpmdiff/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"binary-extensions": "^2.2.0",
5353
"diff": "^5.1.0",
5454
"minimatch": "^9.0.0",
55-
"npm-package-arg": "^11.0.0",
55+
"npm-package-arg": "^11.0.1",
5656
"pacote": "^17.0.4",
5757
"tar": "^6.1.13"
5858
},

‎workspaces/libnpmexec/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
"@npmcli/arborist": "^7.1.0",
6363
"@npmcli/run-script": "^7.0.1",
6464
"ci-info": "^3.7.1",
65-
"npm-package-arg": "^11.0.0",
65+
"npm-package-arg": "^11.0.1",
6666
"npmlog": "^7.0.1",
6767
"pacote": "^17.0.4",
6868
"proc-log": "^3.0.0",

‎workspaces/libnpmpack/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"dependencies": {
3939
"@npmcli/arborist": "^7.1.0",
4040
"@npmcli/run-script": "^7.0.1",
41-
"npm-package-arg": "^11.0.0",
41+
"npm-package-arg": "^11.0.1",
4242
"pacote": "^17.0.4"
4343
},
4444
"engines": {

‎workspaces/libnpmpublish/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"dependencies": {
4141
"ci-info": "^3.6.1",
4242
"normalize-package-data": "^6.0.0",
43-
"npm-package-arg": "^11.0.0",
43+
"npm-package-arg": "^11.0.1",
4444
"npm-registry-fetch": "^16.0.0",
4545
"proc-log": "^3.0.0",
4646
"semver": "^7.3.7",

0 commit comments

Comments
 (0)
Please sign in to comment.