Skip to content

Commit 729e893

Browse files
committed
deps: hosted-git-info@7.0.0
1 parent 7af81c7 commit 729e893

File tree

26 files changed

+763
-53
lines changed

26 files changed

+763
-53
lines changed

node_modules/.gitignore

+9-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@
3636
!/@npmcli/package-json
3737
!/@npmcli/package-json/node_modules/
3838
/@npmcli/package-json/node_modules/*
39-
!/@npmcli/package-json/node_modules/hosted-git-info
40-
!/@npmcli/package-json/node_modules/lru-cache
4139
!/@npmcli/package-json/node_modules/normalize-package-data
4240
!/@npmcli/promise-spawn
4341
!/@npmcli/query
@@ -124,6 +122,9 @@
124122
!/has-unicode
125123
!/has
126124
!/hosted-git-info
125+
!/hosted-git-info/node_modules/
126+
/hosted-git-info/node_modules/*
127+
!/hosted-git-info/node_modules/lru-cache
127128
!/http-cache-semantics
128129
!/http-proxy-agent
129130
!/https-proxy-agent
@@ -211,11 +212,17 @@
211212
!/node-gyp/node_modules/which
212213
!/nopt
213214
!/normalize-package-data
215+
!/normalize-package-data/node_modules/
216+
/normalize-package-data/node_modules/*
217+
!/normalize-package-data/node_modules/hosted-git-info
214218
!/npm-audit-report
215219
!/npm-bundled
216220
!/npm-install-checks
217221
!/npm-normalize-package-bin
218222
!/npm-package-arg
223+
!/npm-package-arg/node_modules/
224+
/npm-package-arg/node_modules/*
225+
!/npm-package-arg/node_modules/hosted-git-info
219226
!/npm-packlist
220227
!/npm-pick-manifest
221228
!/npm-profile

node_modules/hosted-git-info/lib/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
'use strict'
22

3-
const LRU = require('lru-cache')
3+
const { LRUCache } = require('lru-cache')
44
const hosts = require('./hosts.js')
55
const fromUrl = require('./from-url.js')
66
const parseUrl = require('./parse-url.js')
77

8-
const cache = new LRU({ max: 1000 })
8+
const cache = new LRUCache({ max: 1000 })
99

1010
class GitHost {
1111
constructor (type, user, auth, project, committish, defaultRepresentation, opts = {}) {

node_modules/hosted-git-info/package.json

+12-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "hosted-git-info",
3-
"version": "6.1.1",
3+
"version": "7.0.0",
44
"description": "Provides metadata and conversions from repository urls for GitHub, Bitbucket and GitLab",
55
"main": "./lib/index.js",
66
"repository": {
@@ -30,19 +30,19 @@
3030
"template-oss-apply": "template-oss-apply --force"
3131
},
3232
"dependencies": {
33-
"lru-cache": "^7.5.1"
33+
"lru-cache": "^10.0.1"
3434
},
3535
"devDependencies": {
3636
"@npmcli/eslint-config": "^4.0.0",
37-
"@npmcli/template-oss": "4.7.1",
37+
"@npmcli/template-oss": "4.18.0",
3838
"tap": "^16.0.1"
3939
},
4040
"files": [
4141
"bin/",
4242
"lib/"
4343
],
4444
"engines": {
45-
"node": "^14.17.0 || ^16.13.0 || >=18.0.0"
45+
"node": "^16.14.0 || >=18.0.0"
4646
},
4747
"tap": {
4848
"color": 1,
@@ -54,6 +54,13 @@
5454
},
5555
"templateOSS": {
5656
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
57-
"version": "4.7.1"
57+
"version": "4.18.0",
58+
"publish": "true",
59+
"ciVersions": [
60+
"16.14.0",
61+
"16.x",
62+
"18.0.0",
63+
"18.x"
64+
]
5865
}
5966
}

node_modules/@npmcli/package-json/node_modules/hosted-git-info/lib/index.js node_modules/normalize-package-data/node_modules/hosted-git-info/lib/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
'use strict'
22

3-
const { LRUCache } = require('lru-cache')
3+
const LRU = require('lru-cache')
44
const hosts = require('./hosts.js')
55
const fromUrl = require('./from-url.js')
66
const parseUrl = require('./parse-url.js')
77

8-
const cache = new LRUCache({ max: 1000 })
8+
const cache = new LRU({ max: 1000 })
99

1010
class GitHost {
1111
constructor (type, user, auth, project, committish, defaultRepresentation, opts = {}) {

node_modules/@npmcli/package-json/node_modules/hosted-git-info/package.json node_modules/normalize-package-data/node_modules/hosted-git-info/package.json

+5-12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "hosted-git-info",
3-
"version": "7.0.0",
3+
"version": "6.1.1",
44
"description": "Provides metadata and conversions from repository urls for GitHub, Bitbucket and GitLab",
55
"main": "./lib/index.js",
66
"repository": {
@@ -30,19 +30,19 @@
3030
"template-oss-apply": "template-oss-apply --force"
3131
},
3232
"dependencies": {
33-
"lru-cache": "^10.0.1"
33+
"lru-cache": "^7.5.1"
3434
},
3535
"devDependencies": {
3636
"@npmcli/eslint-config": "^4.0.0",
37-
"@npmcli/template-oss": "4.18.0",
37+
"@npmcli/template-oss": "4.7.1",
3838
"tap": "^16.0.1"
3939
},
4040
"files": [
4141
"bin/",
4242
"lib/"
4343
],
4444
"engines": {
45-
"node": "^16.14.0 || >=18.0.0"
45+
"node": "^14.17.0 || ^16.13.0 || >=18.0.0"
4646
},
4747
"tap": {
4848
"color": 1,
@@ -54,13 +54,6 @@
5454
},
5555
"templateOSS": {
5656
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
57-
"version": "4.18.0",
58-
"publish": "true",
59-
"ciVersions": [
60-
"16.14.0",
61-
"16.x",
62-
"18.0.0",
63-
"18.x"
64-
]
57+
"version": "4.7.1"
6558
}
6659
}
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)