Skip to content

Commit 875bd56

Browse files
committed
1 parent dfd5d46 commit 875bd56

File tree

11 files changed

+48
-22
lines changed

11 files changed

+48
-22
lines changed

mock-registry/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"@npmcli/eslint-config": "^4.0.1",
4949
"@npmcli/template-oss": "4.11.0",
5050
"nock": "^13.2.9",
51-
"npm-package-arg": "^10.0.0",
51+
"npm-package-arg": "^10.1.0",
5252
"pacote": "^15.0.6",
5353
"tap": "^16.3.0"
5454
}

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

+26
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict'
22
module.exports = npa
33
module.exports.resolve = resolve
4+
module.exports.toPurl = toPurl
45
module.exports.Result = Result
56

67
const url = require('url')
@@ -87,6 +88,24 @@ function resolve (name, spec, where, arg) {
8788
}
8889
}
8990

91+
const defaultRegistry = 'https://registry.npmjs.org'
92+
93+
function toPurl (arg, reg = defaultRegistry) {
94+
const res = npa(arg)
95+
96+
if (res.type !== 'version') {
97+
throw invalidPurlType(res.type, res.raw)
98+
}
99+
100+
// URI-encode leading @ of scoped packages
101+
let purl = 'pkg:npm/' + res.name.replace(/^@/, '%40') + '@' + res.rawSpec
102+
if (reg !== defaultRegistry) {
103+
purl += '?repository_url=' + reg
104+
}
105+
106+
return purl
107+
}
108+
90109
function invalidPackageName (name, valid, raw) {
91110
// eslint-disable-next-line max-len
92111
const err = new Error(`Invalid package name "${name}" of package "${raw}": ${valid.errors.join('; ')}.`)
@@ -101,6 +120,13 @@ function invalidTagName (name, raw) {
101120
return err
102121
}
103122

123+
function invalidPurlType (type, raw) {
124+
// eslint-disable-next-line max-len
125+
const err = new Error(`Invalid type "${type}" of package "${raw}": Purl can only be generated for "version" types.`)
126+
err.code = 'EINVALIDPURLTYPE'
127+
return err
128+
}
129+
104130
function Result (opts) {
105131
this.type = opts.type
106132
this.registry = opts.registry

node_modules/npm-package-arg/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "npm-package-arg",
3-
"version": "10.0.0",
3+
"version": "10.1.0",
44
"description": "Parse the things that can be arguments to `npm install`",
55
"main": "./lib/npa.js",
66
"directories": {
@@ -18,7 +18,7 @@
1818
},
1919
"devDependencies": {
2020
"@npmcli/eslint-config": "^4.0.0",
21-
"@npmcli/template-oss": "4.6.1",
21+
"@npmcli/template-oss": "4.10.0",
2222
"tap": "^16.0.1"
2323
},
2424
"scripts": {
@@ -54,6 +54,6 @@
5454
},
5555
"templateOSS": {
5656
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
57-
"version": "4.6.1"
57+
"version": "4.10.0"
5858
}
5959
}

package-lock.json

+11-11
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@
129129
"nopt": "^7.0.0",
130130
"npm-audit-report": "^4.0.0",
131131
"npm-install-checks": "^6.0.0",
132-
"npm-package-arg": "^10.0.0",
132+
"npm-package-arg": "^10.1.0",
133133
"npm-pick-manifest": "^8.0.1",
134134
"npm-profile": "^7.0.1",
135135
"npm-registry-fetch": "^14.0.2",
@@ -213,7 +213,7 @@
213213
"@npmcli/eslint-config": "^4.0.1",
214214
"@npmcli/template-oss": "4.11.0",
215215
"nock": "^13.2.9",
216-
"npm-package-arg": "^10.0.0",
216+
"npm-package-arg": "^10.1.0",
217217
"pacote": "^15.0.6",
218218
"tap": "^16.3.0"
219219
},
@@ -9519,9 +9519,9 @@
95199519
}
95209520
},
95219521
"node_modules/npm-package-arg": {
9522-
"version": "10.0.0",
9523-
"resolved": "https://registry.npmjs.org/npm-package-arg/-/npm-package-arg-10.0.0.tgz",
9524-
"integrity": "sha512-7dkh8mRp7s0KwVHKIVJnFCJQ2B34gOGnzgBjDGyprycmARq/82SX/lhilQ95ZuacP/G/1gsS345iAkKmxWBQ2Q==",
9522+
"version": "10.1.0",
9523+
"resolved": "https://registry.npmjs.org/npm-package-arg/-/npm-package-arg-10.1.0.tgz",
9524+
"integrity": "sha512-uFyyCEmgBfZTtrKk/5xDfHp6+MdrqGotX/VoOyEEl3mBwiEE5FlBaePanazJSVMPT7vKepcjYBY2ztg9A3yPIA==",
95259525
"inBundle": true,
95269526
"dependencies": {
95279527
"hosted-git-info": "^6.0.0",
@@ -15006,7 +15006,7 @@
1500615006
"minimatch": "^5.1.0",
1500715007
"nopt": "^7.0.0",
1500815008
"npm-install-checks": "^6.0.0",
15009-
"npm-package-arg": "^10.0.0",
15009+
"npm-package-arg": "^10.1.0",
1501015010
"npm-pick-manifest": "^8.0.1",
1501115011
"npm-registry-fetch": "^14.0.2",
1501215012
"npmlog": "^7.0.1",
@@ -15064,7 +15064,7 @@
1506415064
"version": "7.0.0",
1506515065
"license": "ISC",
1506615066
"dependencies": {
15067-
"npm-package-arg": "^10.0.0",
15067+
"npm-package-arg": "^10.1.0",
1506815068
"npm-registry-fetch": "^14.0.2"
1506915069
},
1507015070
"devDependencies": {
@@ -15088,7 +15088,7 @@
1508815088
"binary-extensions": "^2.2.0",
1508915089
"diff": "^5.1.0",
1509015090
"minimatch": "^5.0.1",
15091-
"npm-package-arg": "^10.0.0",
15091+
"npm-package-arg": "^10.1.0",
1509215092
"pacote": "^15.0.2",
1509315093
"tar": "^6.1.0"
1509415094
},
@@ -15109,7 +15109,7 @@
1510915109
"@npmcli/run-script": "^6.0.0",
1511015110
"chalk": "^4.1.0",
1511115111
"ci-info": "^3.6.1",
15112-
"npm-package-arg": "^10.0.0",
15112+
"npm-package-arg": "^10.1.0",
1511315113
"npmlog": "^7.0.1",
1511415114
"pacote": "^15.0.2",
1511515115
"proc-log": "^3.0.0",
@@ -15189,7 +15189,7 @@
1518915189
"dependencies": {
1519015190
"@npmcli/arborist": "^6.1.4",
1519115191
"@npmcli/run-script": "^6.0.0",
15192-
"npm-package-arg": "^10.0.0",
15192+
"npm-package-arg": "^10.1.0",
1519315193
"pacote": "^15.0.2"
1519415194
},
1519515195
"devDependencies": {
@@ -15208,7 +15208,7 @@
1520815208
"license": "ISC",
1520915209
"dependencies": {
1521015210
"normalize-package-data": "^5.0.0",
15211-
"npm-package-arg": "^10.0.0",
15211+
"npm-package-arg": "^10.1.0",
1521215212
"npm-registry-fetch": "^14.0.2",
1521315213
"semver": "^7.3.7",
1521415214
"ssri": "^10.0.0"

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
"nopt": "^7.0.0",
9797
"npm-audit-report": "^4.0.0",
9898
"npm-install-checks": "^6.0.0",
99-
"npm-package-arg": "^10.0.0",
99+
"npm-package-arg": "^10.1.0",
100100
"npm-pick-manifest": "^8.0.1",
101101
"npm-profile": "^7.0.1",
102102
"npm-registry-fetch": "^14.0.2",

workspaces/arborist/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"minimatch": "^5.1.0",
2323
"nopt": "^7.0.0",
2424
"npm-install-checks": "^6.0.0",
25-
"npm-package-arg": "^10.0.0",
25+
"npm-package-arg": "^10.1.0",
2626
"npm-pick-manifest": "^8.0.1",
2727
"npm-registry-fetch": "^14.0.2",
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": "^10.0.0",
32+
"npm-package-arg": "^10.1.0",
3333
"npm-registry-fetch": "^14.0.2"
3434
},
3535
"engines": {

workspaces/libnpmdiff/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"binary-extensions": "^2.2.0",
5454
"diff": "^5.1.0",
5555
"minimatch": "^5.0.1",
56-
"npm-package-arg": "^10.0.0",
56+
"npm-package-arg": "^10.1.0",
5757
"pacote": "^15.0.2",
5858
"tar": "^6.1.0"
5959
},

workspaces/libnpmexec/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
"@npmcli/run-script": "^6.0.0",
6666
"chalk": "^4.1.0",
6767
"ci-info": "^3.6.1",
68-
"npm-package-arg": "^10.0.0",
68+
"npm-package-arg": "^10.1.0",
6969
"npmlog": "^7.0.1",
7070
"pacote": "^15.0.2",
7171
"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": "^6.1.4",
4040
"@npmcli/run-script": "^6.0.0",
41-
"npm-package-arg": "^10.0.0",
41+
"npm-package-arg": "^10.1.0",
4242
"pacote": "^15.0.2"
4343
},
4444
"engines": {

workspaces/libnpmpublish/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"homepage": "https://npmjs.com/package/libnpmpublish",
4141
"dependencies": {
4242
"normalize-package-data": "^5.0.0",
43-
"npm-package-arg": "^10.0.0",
43+
"npm-package-arg": "^10.1.0",
4444
"npm-registry-fetch": "^14.0.2",
4545
"semver": "^7.3.7",
4646
"ssri": "^10.0.0"

0 commit comments

Comments
 (0)