Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Karrys <luke@lukekarrys.com>2022-11-01 19:45:37 +0300
committerGitHub <noreply@github.com>2022-11-01 19:45:37 +0300
commit26f3d0b04fec438400d337c2d4ace218225b7ecb (patch)
treec113eb5df0c5124a8e779e757701505b7860fbe3 /workspaces/arborist/test
parent292156c60bc16ba4da5942df4dd54b1c4cf9ad72 (diff)
fix: use hosted-git-info to parse registry urls (#5761)
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
Diffstat (limited to 'workspaces/arborist/test')
-rw-r--r--workspaces/arborist/test/arborist/reify.js79
1 files changed, 78 insertions, 1 deletions
diff --git a/workspaces/arborist/test/arborist/reify.js b/workspaces/arborist/test/arborist/reify.js
index 01945f713..21bbaff4b 100644
--- a/workspaces/arborist/test/arborist/reify.js
+++ b/workspaces/arborist/test/arborist/reify.js
@@ -2925,7 +2925,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)
@@ -2962,6 +2975,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://git@github.com: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: {
@@ -2970,6 +3017,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',
},
}),
},
@@ -2983,6 +3032,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',
@@ -3000,6 +3057,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',
},
}),
},
@@ -3010,9 +3069,17 @@ t.only('should preserve exact ranges, missing actual tree', async (t) => {
.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',
@@ -3030,6 +3097,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',
},
}),
},
@@ -3040,9 +3109,17 @@ t.only('should preserve exact ranges, missing actual tree', async (t) => {
.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',