-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use hosted-git-info to parse registry urls
Previously this was using `new URL` which would fail on some urls that `hosted-git-info` is able to parse. But if we still get a url that can't be parsed, we now set it to be removed from the tree instead of erroring. Fixes: #5278
- Loading branch information
1 parent
ca93f3e
commit 0483d10
Showing
10 changed files
with
119 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2936,7 +2936,20 @@ t.test('installLinks', (t) => { | |
}) | ||
|
||
t.only('should preserve exact ranges, missing actual tree', async (t) => { | ||
const Arborist = require('../../lib/index.js') | ||
const Pacote = require('pacote') | ||
const Arborist = t.mock('../../lib/arborist', { | ||
pacote: { | ||
...Pacote, | ||
extract: async (...args) => { | ||
if (args[0].startsWith('gitssh')) { | ||
// we just want to test that this url is handled properly | ||
// but its not a real git url we can clone so return early | ||
return true | ||
} | ||
return Pacote.extract(...args) | ||
}, | ||
}, | ||
}) | ||
const abbrev = resolve(__dirname, | ||
'../fixtures/registry-mocks/content/abbrev/-/abbrev-1.1.1.tgz') | ||
const abbrevTGZ = fs.readFileSync(abbrev) | ||
|
@@ -2973,6 +2986,40 @@ t.only('should preserve exact ranges, missing actual tree', async (t) => { | |
}, | ||
}) | ||
|
||
const gitSshPackument = JSON.stringify({ | ||
_id: 'gitssh', | ||
_rev: 'lkjadflkjasdf', | ||
name: 'gitssh', | ||
'dist-tags': { latest: '1.1.1' }, | ||
versions: { | ||
'1.1.1': { | ||
name: 'gitssh', | ||
version: '1.1.1', | ||
dist: { | ||
// this is a url that `new URL()` cant parse | ||
// https://github.com/npm/cli/issues/5278 | ||
tarball: 'git+ssh://[email protected]:a/b/c.git#lkjadflkjasdf', | ||
}, | ||
}, | ||
}, | ||
}) | ||
|
||
const notAUrlPackument = JSON.stringify({ | ||
_id: 'notaurl', | ||
_rev: 'lkjadflkjasdf', | ||
name: 'notaurl', | ||
'dist-tags': { latest: '1.1.1' }, | ||
versions: { | ||
'1.1.1': { | ||
name: 'notaurl', | ||
version: '1.1.1', | ||
dist: { | ||
tarball: 'hey been trying to break this test', | ||
}, | ||
}, | ||
}, | ||
}) | ||
|
||
t.only('host should not be replaced replaceRegistryHost=never', async (t) => { | ||
const testdir = t.testdir({ | ||
project: { | ||
|
@@ -2981,6 +3028,8 @@ t.only('should preserve exact ranges, missing actual tree', async (t) => { | |
version: '1.0.0', | ||
dependencies: { | ||
abbrev: '1.1.1', | ||
gitssh: '1.1.1', | ||
notaurl: '1.1.1', | ||
}, | ||
}), | ||
}, | ||
|
@@ -2994,6 +3043,14 @@ t.only('should preserve exact ranges, missing actual tree', async (t) => { | |
.get('/abbrev/-/abbrev-1.1.1.tgz') | ||
.reply(200, abbrevTGZ) | ||
|
||
tnock(t, 'https://registry.github.com') | ||
.get('/gitssh') | ||
.reply(200, gitSshPackument) | ||
|
||
tnock(t, 'https://registry.github.com') | ||
.get('/notaurl') | ||
.reply(200, notAUrlPackument) | ||
|
||
const arb = new Arborist({ | ||
path: resolve(testdir, 'project'), | ||
registry: 'https://registry.github.com', | ||
|
@@ -3011,6 +3068,8 @@ t.only('should preserve exact ranges, missing actual tree', async (t) => { | |
version: '1.0.0', | ||
dependencies: { | ||
abbrev: '1.1.1', | ||
gitssh: '1.1.1', | ||
notaurl: '1.1.1', | ||
}, | ||
}), | ||
}, | ||
|
@@ -3020,10 +3079,18 @@ t.only('should preserve exact ranges, missing actual tree', async (t) => { | |
.get('/abbrev') | ||
.reply(200, abbrevPackument) | ||
|
||
tnock(t, 'https://registry.github.com') | ||
.get('/gitssh') | ||
.reply(200, gitSshPackument) | ||
|
||
tnock(t, 'https://registry.github.com') | ||
.get('/abbrev/-/abbrev-1.1.1.tgz') | ||
.reply(200, abbrevTGZ) | ||
|
||
tnock(t, 'https://registry.github.com') | ||
.get('/notaurl') | ||
.reply(200, notAUrlPackument) | ||
|
||
const arb = new Arborist({ | ||
path: resolve(testdir, 'project'), | ||
registry: 'https://registry.github.com', | ||
|
@@ -3041,6 +3108,8 @@ t.only('should preserve exact ranges, missing actual tree', async (t) => { | |
version: '1.0.0', | ||
dependencies: { | ||
abbrev: '1.1.1', | ||
gitssh: '1.1.1', | ||
notaurl: '1.1.1', | ||
}, | ||
}), | ||
}, | ||
|
@@ -3050,10 +3119,18 @@ t.only('should preserve exact ranges, missing actual tree', async (t) => { | |
.get('/abbrev') | ||
.reply(200, abbrevPackument2) | ||
|
||
tnock(t, 'https://registry.github.com') | ||
.get('/gitssh') | ||
.reply(200, gitSshPackument) | ||
|
||
tnock(t, 'https://registry.github.com') | ||
.get('/abbrev/-/abbrev-1.1.1.tgz') | ||
.reply(200, abbrevTGZ) | ||
|
||
tnock(t, 'https://registry.github.com') | ||
.get('/notaurl') | ||
.reply(200, notAUrlPackument) | ||
|
||
const arb = new Arborist({ | ||
path: resolve(testdir, 'project'), | ||
registry: 'https://registry.github.com', | ||
|