Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion tap-snapshots/test/lib/docs.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -1794,10 +1794,14 @@ Rebuild bundled dependencies after installation.
#### \`registry\`

* Default: "https://registry.npmjs.org/"
* Type: URL
* Type: URL or "default"

The base URL of the npm registry.

Can be set to \`"default"\` to use the default npm registry
(\`https://registry.npmjs.org/\`), which is useful when you have a custom
registry configured globally but want to temporarily use the default one.



#### \`replace-registry-host\`
Expand Down
14 changes: 12 additions & 2 deletions workspaces/config/lib/definitions/definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2048,11 +2048,21 @@ const definitions = {
}),
registry: new Definition('registry', {
default: 'https://registry.npmjs.org/',
type: url,
type: [url, 'default'],
description: `
The base URL of the npm registry.

Can be set to \`"default"\` to use the default npm registry
(\`https://registry.npmjs.org/\`), which is useful when you have
a custom registry configured globally but want to temporarily
use the default one.
`,
flatten,
flatten (key, obj, flatOptions) {
const val = obj[key]
flatOptions.registry = /^default$/i.test(val)
? 'https://registry.npmjs.org/'
: val
},
}),
'replace-registry-host': new Definition('replace-registry-host', {
default: 'npmjs',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@ Object {
],
"registry": Array [
"full url with \\"http://\\"",
"default",
],
"replace-registry-host": Array [
"npmjs",
Expand Down
22 changes: 22 additions & 0 deletions workspaces/config/test/definitions/definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,28 @@ t.test('scope', t => {
t.end()
})

t.test('registry - "default" maps to default registry URL', t => {
const defs = mockDefs()

const flat1 = {}
defs.registry.flatten('registry', { registry: 'default' }, flat1)
t.equal(flat1.registry, 'https://registry.npmjs.org/', 'lowercase default')

const flat2 = {}
defs.registry.flatten('registry', { registry: 'DEFAULT' }, flat2)
t.equal(flat2.registry, 'https://registry.npmjs.org/', 'uppercase DEFAULT')

const flat3 = {}
defs.registry.flatten('registry', { registry: 'Default' }, flat3)
t.equal(flat3.registry, 'https://registry.npmjs.org/', 'mixed case Default')

const flat4 = {}
defs.registry.flatten('registry', { registry: 'https://custom.registry.com/' }, flat4)
t.equal(flat4.registry, 'https://custom.registry.com/', 'custom URL passes through')

t.end()
})

t.test('strictSSL', t => {
const obj = { 'strict-ssl': false }
const flat = {}
Expand Down