File tree Expand file tree Collapse file tree 6 files changed +24
-12
lines changed
tap-snapshots/test/lib/utils/config Expand file tree Collapse file tree 6 files changed +24
-12
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ const runScript = require('@npmcli/run-script')
7
7
const pacote = require ( 'pacote' )
8
8
const npa = require ( 'npm-package-arg' )
9
9
const npmFetch = require ( 'npm-registry-fetch' )
10
+ const hasCredentials = require ( '../utils/has-credentials.js' )
10
11
const replaceInfo = require ( '../utils/replace-info.js' )
11
12
12
13
const otplease = require ( '../utils/otplease.js' )
@@ -101,7 +102,7 @@ class Publish extends BaseCommand {
101
102
const resolved = npa . resolve ( manifest . name , manifest . version )
102
103
const registry = npmFetch . pickRegistry ( resolved , opts )
103
104
const creds = this . npm . config . getCredentialsByURI ( registry )
104
- const noCreds = ! creds . token && ! creds . username
105
+ const noCreds = ! hasCredentials ( creds )
105
106
const outputRegistry = replaceInfo ( registry )
106
107
107
108
if ( noCreds ) {
Original file line number Diff line number Diff line change @@ -436,8 +436,8 @@ define('cert', {
436
436
cert="-----BEGIN CERTIFICATE-----\\nXXXX\\nXXXX\\n-----END CERTIFICATE-----"
437
437
\`\`\`
438
438
439
- It is _not_ the path to a certificate file (and there is no "certfile"
440
- option) .
439
+ It is _not_ the path to a certificate file, though you can set a registry-scoped
440
+ "certfile" path like "//other-registry.tld/:certfile=/path/to/cert.pem" .
441
441
` ,
442
442
flatten,
443
443
} )
@@ -1118,7 +1118,8 @@ define('key', {
1118
1118
key="-----BEGIN PRIVATE KEY-----\\nXXXX\\nXXXX\\n-----END PRIVATE KEY-----"
1119
1119
\`\`\`
1120
1120
1121
- It is _not_ the path to a key file (and there is no "keyfile" option).
1121
+ It is _not_ the path to a key file, though you can set a registry-scoped
1122
+ "keyfile" path like "//other-registry.tld/:keyfile=/path/to/key.pem".
1122
1123
` ,
1123
1124
flatten,
1124
1125
} )
Original file line number Diff line number Diff line change 1
1
const npmFetch = require ( 'npm-registry-fetch' )
2
+ const hasCredentials = require ( './has-credentials.js' )
2
3
3
4
module . exports = async ( npm , opts ) => {
4
5
const { registry } = opts
@@ -9,8 +10,8 @@ module.exports = async (npm, opts) => {
9
10
return creds . username
10
11
}
11
12
12
- // No username, but we have a token ; fetch the username from registry
13
- if ( creds . token ) {
13
+ // No username, but we have other credentials ; fetch the username from registry
14
+ if ( hasCredentials ( creds ) ) {
14
15
const registryData = await npmFetch . json ( '/-/whoami' , { ...opts } )
15
16
return registryData . username
16
17
}
Original file line number Diff line number Diff line change
1
+ function hasCredentials ( creds ) {
2
+ return ! ! ( creds . token || creds . username || creds . certfile && creds . keyfile )
3
+ }
4
+
5
+ module . exports = hasCredentials
Original file line number Diff line number Diff line change @@ -404,8 +404,9 @@ newlines replaced by the string "\\n". For example:
404
404
cert="-----BEGIN CERTIFICATE-----\\nXXXX\\nXXXX\\n-----END CERTIFICATE-----"
405
405
\`\`\`
406
406
407
- It is _not_ the path to a certificate file (and there is no "certfile"
408
- option).
407
+ It is _not_ the path to a certificate file, though you can set a
408
+ registry-scoped "certfile" path like
409
+ "//other-registry.tld/:certfile=/path/to/cert.pem".
409
410
`
410
411
411
412
exports [ `test/lib/utils/config/definitions.js TAP > config description for ci-name 1` ] = `
@@ -1016,7 +1017,8 @@ format with newlines replaced by the string "\\n". For example:
1016
1017
key="-----BEGIN PRIVATE KEY-----\\nXXXX\\nXXXX\\n-----END PRIVATE KEY-----"
1017
1018
\`\`\`
1018
1019
1019
- It is _not_ the path to a key file (and there is no "keyfile" option).
1020
+ It is _not_ the path to a key file, though you can set a registry-scoped
1021
+ "keyfile" path like "//other-registry.tld/:keyfile=/path/to/key.pem".
1020
1022
`
1021
1023
1022
1024
exports [ `test/lib/utils/config/definitions.js TAP > config description for legacy-bundling 1` ] = `
Original file line number Diff line number Diff line change @@ -230,8 +230,9 @@ newlines replaced by the string "\\n". For example:
230
230
cert="-----BEGIN CERTIFICATE-----\\nXXXX\\nXXXX\\n-----END CERTIFICATE-----"
231
231
\`\`\`
232
232
233
- It is _not_ the path to a certificate file (and there is no "certfile"
234
- option).
233
+ It is _not_ the path to a certificate file, though you can set a
234
+ registry-scoped "certfile" path like
235
+ "//other-registry.tld/:certfile=/path/to/cert.pem".
235
236
236
237
<!-- automatically generated, do not edit manually -->
237
238
<!-- see lib/utils/config/definitions.js -->
@@ -819,7 +820,8 @@ format with newlines replaced by the string "\\n". For example:
819
820
key="-----BEGIN PRIVATE KEY-----\\nXXXX\\nXXXX\\n-----END PRIVATE KEY-----"
820
821
\`\`\`
821
822
822
- It is _not_ the path to a key file (and there is no "keyfile" option).
823
+ It is _not_ the path to a key file, though you can set a registry-scoped
824
+ "keyfile" path like "//other-registry.tld/:keyfile=/path/to/key.pem".
823
825
824
826
<!-- automatically generated, do not edit manually -->
825
827
<!-- see lib/utils/config/definitions.js -->
You can’t perform that action at this time.
0 commit comments