Skip to content

Commit 6deae9e

Browse files
committed
deps: update hosted-git-info@8.0.0
1 parent 034c729 commit 6deae9e

File tree

29 files changed

+2135
-39
lines changed

29 files changed

+2135
-39
lines changed

node_modules/.gitignore

+8-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
!/@npmcli/package-json/node_modules/@npmcli/
4949
/@npmcli/package-json/node_modules/@npmcli/*
5050
!/@npmcli/package-json/node_modules/@npmcli/git
51-
!/@npmcli/package-json/node_modules/hosted-git-info
5251
!/@npmcli/package-json/node_modules/ini
5352
!/@npmcli/package-json/node_modules/isexe
5453
!/@npmcli/package-json/node_modules/json-parse-even-better-errors
@@ -158,6 +157,7 @@
158157
!/init-package-json/node_modules/@npmcli/
159158
/init-package-json/node_modules/@npmcli/*
160159
!/init-package-json/node_modules/@npmcli/package-json
160+
!/init-package-json/node_modules/hosted-git-info
161161
!/ip-address
162162
!/ip-regex
163163
!/is-cidr
@@ -211,11 +211,17 @@
211211
/nopt/node_modules/*
212212
!/nopt/node_modules/abbrev
213213
!/normalize-package-data
214+
!/normalize-package-data/node_modules/
215+
/normalize-package-data/node_modules/*
216+
!/normalize-package-data/node_modules/hosted-git-info
214217
!/npm-audit-report
215218
!/npm-bundled
216219
!/npm-install-checks
217220
!/npm-normalize-package-bin
218221
!/npm-package-arg
222+
!/npm-package-arg/node_modules/
223+
/npm-package-arg/node_modules/*
224+
!/npm-package-arg/node_modules/hosted-git-info
219225
!/npm-packlist
220226
!/npm-pick-manifest
221227
!/npm-profile
@@ -238,6 +244,7 @@
238244
!/pacote/node_modules/@npmcli/promise-spawn
239245
!/pacote/node_modules/@npmcli/run-script
240246
!/pacote/node_modules/cacache
247+
!/pacote/node_modules/hosted-git-info
241248
!/pacote/node_modules/unique-filename
242249
!/pacote/node_modules/unique-slug
243250
!/parse-conflict-json

node_modules/hosted-git-info/package.json

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "hosted-git-info",
3-
"version": "7.0.2",
3+
"version": "8.0.0",
44
"description": "Provides metadata and conversions from repository urls for GitHub, Bitbucket and GitLab",
55
"main": "./lib/index.js",
66
"repository": {
@@ -24,25 +24,26 @@
2424
"snap": "tap",
2525
"test": "tap",
2626
"test:coverage": "tap --coverage-report=html",
27-
"lint": "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\"",
27+
"lint": "npm run eslint",
2828
"postlint": "template-oss-check",
29-
"lintfix": "npm run lint -- --fix",
30-
"template-oss-apply": "template-oss-apply --force"
29+
"lintfix": "npm run eslint -- --fix",
30+
"template-oss-apply": "template-oss-apply --force",
31+
"eslint": "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\""
3132
},
3233
"dependencies": {
3334
"lru-cache": "^10.0.1"
3435
},
3536
"devDependencies": {
36-
"@npmcli/eslint-config": "^4.0.0",
37-
"@npmcli/template-oss": "4.22.0",
37+
"@npmcli/eslint-config": "^5.0.0",
38+
"@npmcli/template-oss": "4.23.3",
3839
"tap": "^16.0.1"
3940
},
4041
"files": [
4142
"bin/",
4243
"lib/"
4344
],
4445
"engines": {
45-
"node": "^16.14.0 || >=18.0.0"
46+
"node": "^18.17.0 || >=20.5.0"
4647
},
4748
"tap": {
4849
"color": 1,
@@ -54,7 +55,7 @@
5455
},
5556
"templateOSS": {
5657
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
57-
"version": "4.22.0",
58+
"version": "4.23.3",
5859
"publish": "true"
5960
}
6061
}

node_modules/@npmcli/package-json/node_modules/hosted-git-info/package.json node_modules/init-package-json/node_modules/hosted-git-info/package.json

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "hosted-git-info",
3-
"version": "8.0.0",
3+
"version": "7.0.2",
44
"description": "Provides metadata and conversions from repository urls for GitHub, Bitbucket and GitLab",
55
"main": "./lib/index.js",
66
"repository": {
@@ -24,26 +24,25 @@
2424
"snap": "tap",
2525
"test": "tap",
2626
"test:coverage": "tap --coverage-report=html",
27-
"lint": "npm run eslint",
27+
"lint": "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\"",
2828
"postlint": "template-oss-check",
29-
"lintfix": "npm run eslint -- --fix",
30-
"template-oss-apply": "template-oss-apply --force",
31-
"eslint": "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\""
29+
"lintfix": "npm run lint -- --fix",
30+
"template-oss-apply": "template-oss-apply --force"
3231
},
3332
"dependencies": {
3433
"lru-cache": "^10.0.1"
3534
},
3635
"devDependencies": {
37-
"@npmcli/eslint-config": "^5.0.0",
38-
"@npmcli/template-oss": "4.23.3",
36+
"@npmcli/eslint-config": "^4.0.0",
37+
"@npmcli/template-oss": "4.22.0",
3938
"tap": "^16.0.1"
4039
},
4140
"files": [
4241
"bin/",
4342
"lib/"
4443
],
4544
"engines": {
46-
"node": "^18.17.0 || >=20.5.0"
45+
"node": "^16.14.0 || >=18.0.0"
4746
},
4847
"tap": {
4948
"color": 1,
@@ -55,7 +54,7 @@
5554
},
5655
"templateOSS": {
5756
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
58-
"version": "4.23.3",
57+
"version": "4.22.0",
5958
"publish": "true"
6059
}
6160
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Copyright (c) 2015, Rebecca Turner
2+
3+
Permission to use, copy, modify, and/or distribute this software for any
4+
purpose with or without fee is hereby granted, provided that the above
5+
copyright notice and this permission notice appear in all copies.
6+
7+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
8+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
9+
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
11+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
12+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13+
PERFORMANCE OF THIS SOFTWARE.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
'use strict'
2+
3+
const parseUrl = require('./parse-url')
4+
5+
// look for github shorthand inputs, such as npm/cli
6+
const isGitHubShorthand = (arg) => {
7+
// it cannot contain whitespace before the first #
8+
// it cannot start with a / because that's probably an absolute file path
9+
// but it must include a slash since repos are username/repository
10+
// it cannot start with a . because that's probably a relative file path
11+
// it cannot start with an @ because that's a scoped package if it passes the other tests
12+
// it cannot contain a : before a # because that tells us that there's a protocol
13+
// a second / may not exist before a #
14+
const firstHash = arg.indexOf('#')
15+
const firstSlash = arg.indexOf('/')
16+
const secondSlash = arg.indexOf('/', firstSlash + 1)
17+
const firstColon = arg.indexOf(':')
18+
const firstSpace = /\s/.exec(arg)
19+
const firstAt = arg.indexOf('@')
20+
21+
const spaceOnlyAfterHash = !firstSpace || (firstHash > -1 && firstSpace.index > firstHash)
22+
const atOnlyAfterHash = firstAt === -1 || (firstHash > -1 && firstAt > firstHash)
23+
const colonOnlyAfterHash = firstColon === -1 || (firstHash > -1 && firstColon > firstHash)
24+
const secondSlashOnlyAfterHash = secondSlash === -1 || (firstHash > -1 && secondSlash > firstHash)
25+
const hasSlash = firstSlash > 0
26+
// if a # is found, what we really want to know is that the character
27+
// immediately before # is not a /
28+
const doesNotEndWithSlash = firstHash > -1 ? arg[firstHash - 1] !== '/' : !arg.endsWith('/')
29+
const doesNotStartWithDot = !arg.startsWith('.')
30+
31+
return spaceOnlyAfterHash && hasSlash && doesNotEndWithSlash &&
32+
doesNotStartWithDot && atOnlyAfterHash && colonOnlyAfterHash &&
33+
secondSlashOnlyAfterHash
34+
}
35+
36+
module.exports = (giturl, opts, { gitHosts, protocols }) => {
37+
if (!giturl) {
38+
return
39+
}
40+
41+
const correctedUrl = isGitHubShorthand(giturl) ? `github:${giturl}` : giturl
42+
const parsed = parseUrl(correctedUrl, protocols)
43+
if (!parsed) {
44+
return
45+
}
46+
47+
const gitHostShortcut = gitHosts.byShortcut[parsed.protocol]
48+
const gitHostDomain = gitHosts.byDomain[parsed.hostname.startsWith('www.')
49+
? parsed.hostname.slice(4)
50+
: parsed.hostname]
51+
const gitHostName = gitHostShortcut || gitHostDomain
52+
if (!gitHostName) {
53+
return
54+
}
55+
56+
const gitHostInfo = gitHosts[gitHostShortcut || gitHostDomain]
57+
let auth = null
58+
if (protocols[parsed.protocol]?.auth && (parsed.username || parsed.password)) {
59+
auth = `${parsed.username}${parsed.password ? ':' + parsed.password : ''}`
60+
}
61+
62+
let committish = null
63+
let user = null
64+
let project = null
65+
let defaultRepresentation = null
66+
67+
try {
68+
if (gitHostShortcut) {
69+
let pathname = parsed.pathname.startsWith('/') ? parsed.pathname.slice(1) : parsed.pathname
70+
const firstAt = pathname.indexOf('@')
71+
// we ignore auth for shortcuts, so just trim it out
72+
if (firstAt > -1) {
73+
pathname = pathname.slice(firstAt + 1)
74+
}
75+
76+
const lastSlash = pathname.lastIndexOf('/')
77+
if (lastSlash > -1) {
78+
user = decodeURIComponent(pathname.slice(0, lastSlash))
79+
// we want nulls only, never empty strings
80+
if (!user) {
81+
user = null
82+
}
83+
project = decodeURIComponent(pathname.slice(lastSlash + 1))
84+
} else {
85+
project = decodeURIComponent(pathname)
86+
}
87+
88+
if (project.endsWith('.git')) {
89+
project = project.slice(0, -4)
90+
}
91+
92+
if (parsed.hash) {
93+
committish = decodeURIComponent(parsed.hash.slice(1))
94+
}
95+
96+
defaultRepresentation = 'shortcut'
97+
} else {
98+
if (!gitHostInfo.protocols.includes(parsed.protocol)) {
99+
return
100+
}
101+
102+
const segments = gitHostInfo.extract(parsed)
103+
if (!segments) {
104+
return
105+
}
106+
107+
user = segments.user && decodeURIComponent(segments.user)
108+
project = decodeURIComponent(segments.project)
109+
committish = decodeURIComponent(segments.committish)
110+
defaultRepresentation = protocols[parsed.protocol]?.name || parsed.protocol.slice(0, -1)
111+
}
112+
} catch (err) {
113+
/* istanbul ignore else */
114+
if (err instanceof URIError) {
115+
return
116+
} else {
117+
throw err
118+
}
119+
}
120+
121+
return [gitHostName, user, auth, project, committish, defaultRepresentation, opts]
122+
}

0 commit comments

Comments
 (0)