diff --git a/node_modules/hosted-git-info/lib/git-host-info.js b/node_modules/hosted-git-info/lib/git-host-info.js index 9a9720fa3c33..cdc1e4601acf 100644 --- a/node_modules/hosted-git-info/lib/git-host-info.js +++ b/node_modules/hosted-git-info/lib/git-host-info.js @@ -6,6 +6,7 @@ const maybeEncode = (arg) => arg ? encodeURIComponent(arg) : '' const defaults = { sshtemplate: ({ domain, user, project, committish }) => `git@${domain}:${user}/${project}.git${maybeJoin('#', committish)}`, sshurltemplate: ({ domain, user, project, committish }) => `git+ssh://git@${domain}/${user}/${project}.git${maybeJoin('#', committish)}`, + edittemplate: ({ domain, user, project, committish, editpath, path }) => `https://${domain}/${user}/${project}${maybeJoin('/', editpath, '/', maybeEncode(committish || 'master'), '/', path)}`, browsetemplate: ({ domain, user, project, committish, treepath }) => `https://${domain}/${user}/${project}${maybeJoin('/', treepath, '/', maybeEncode(committish))}`, browsefiletemplate: ({ domain, user, project, committish, treepath, path, fragment, hashformat }) => `https://${domain}/${user}/${project}/${treepath}/${maybeEncode(committish || 'master')}/${path}${maybeJoin('#', hashformat(fragment || ''))}`, docstemplate: ({ domain, user, project, treepath, committish }) => `https://${domain}/${user}/${project}${maybeJoin('/', treepath, '/', maybeEncode(committish))}#readme`, @@ -24,6 +25,7 @@ gitHosts.github = Object.assign({}, defaults, { protocols: ['git:', 'http:', 'git+ssh:', 'git+https:', 'ssh:', 'https:'], domain: 'github.com', treepath: 'tree', + editpath: 'edit', filetemplate: ({ auth, user, project, committish, path }) => `https://${maybeJoin(auth, '@')}raw.githubusercontent.com/${user}/${project}/${maybeEncode(committish) || 'master'}/${path}`, gittemplate: ({ auth, domain, user, project, committish }) => `git://${maybeJoin(auth, '@')}${domain}/${user}/${project}.git${maybeJoin('#', committish)}`, tarballtemplate: ({ domain, user, project, committish }) => `https://codeload.${domain}/${user}/${project}/tar.gz/${maybeEncode(committish) || 'master'}`, @@ -53,6 +55,8 @@ gitHosts.bitbucket = Object.assign({}, defaults, { protocols: ['git+ssh:', 'git+https:', 'ssh:', 'https:'], domain: 'bitbucket.org', treepath: 'src', + editpath: '?mode=edit', + edittemplate: ({ domain, user, project, committish, treepath, path, editpath }) => `https://${domain}/${user}/${project}${maybeJoin('/', treepath, '/', maybeEncode(committish || 'master'), '/', path, editpath)}`, tarballtemplate: ({ domain, user, project, committish }) => `https://${domain}/${user}/${project}/get/${maybeEncode(committish) || 'master'}.tar.gz`, extract: (url) => { let [, user, project, aux] = url.pathname.split('/', 4) @@ -76,6 +80,7 @@ gitHosts.gitlab = Object.assign({}, defaults, { protocols: ['git+ssh:', 'git+https:', 'ssh:', 'https:'], domain: 'gitlab.com', treepath: 'tree', + editpath: '-/edit', httpstemplate: ({ auth, domain, user, project, committish }) => `git+https://${maybeJoin(auth, '@')}${domain}/${user}/${project}.git${maybeJoin('#', committish)}`, tarballtemplate: ({ domain, user, project, committish }) => `https://${domain}/${user}/${project}/repository/archive.tar.gz?ref=${maybeEncode(committish) || 'master'}`, extract: (url) => { @@ -102,8 +107,10 @@ gitHosts.gitlab = Object.assign({}, defaults, { gitHosts.gist = Object.assign({}, defaults, { protocols: ['git:', 'git+ssh:', 'git+https:', 'ssh:', 'https:'], domain: 'gist.github.com', + editpath: 'edit', sshtemplate: ({ domain, project, committish }) => `git@${domain}:${project}.git${maybeJoin('#', committish)}`, sshurltemplate: ({ domain, project, committish }) => `git+ssh://git@${domain}/${project}.git${maybeJoin('#', committish)}`, + edittemplate: ({ domain, user, project, committish, editpath }) => `https://${domain}/${user}/${project}${maybeJoin('/', maybeEncode(committish))}/${editpath}`, browsetemplate: ({ domain, project, committish }) => `https://${domain}/${project}${maybeJoin('/', maybeEncode(committish))}`, browsefiletemplate: ({ domain, project, committish, path, hashformat }) => `https://${domain}/${project}${maybeJoin('/', maybeEncode(committish))}${maybeJoin('#', hashformat(path))}`, docstemplate: ({ domain, project, committish }) => `https://${domain}/${project}${maybeJoin('/', maybeEncode(committish))}`, diff --git a/node_modules/hosted-git-info/lib/git-host.js b/node_modules/hosted-git-info/lib/git-host.js index 8a975e92e58b..bb65d4d992aa 100644 --- a/node_modules/hosted-git-info/lib/git-host.js +++ b/node_modules/hosted-git-info/lib/git-host.js @@ -95,6 +95,10 @@ class GitHost { return this._fill(this.filetemplate, { ...opts, path }) } + edit (path, opts) { + return this._fill(this.edittemplate, { ...opts, path }) + } + getDefaultRepresentation () { return this.default } diff --git a/node_modules/hosted-git-info/lib/index.js b/node_modules/hosted-git-info/lib/index.js index 8bce6b3c28d5..d5d63c66839b 100644 --- a/node_modules/hosted-git-info/lib/index.js +++ b/node_modules/hosted-git-info/lib/index.js @@ -46,8 +46,8 @@ function fromUrl (giturl, opts) { return } - const url = isGitHubShorthand(giturl) ? 'github:' + giturl : correctProtocol(giturl) - const parsed = parseGitUrl(url) + const correctedUrl = isGitHubShorthand(giturl) ? 'github:' + giturl : correctProtocol(giturl) + const parsed = parseGitUrl(correctedUrl) if (!parsed) { return parsed } @@ -229,7 +229,9 @@ const parseGitUrl = (giturl) => { let result try { result = new url.URL(giturl) - } catch (err) {} + } catch { + // this fn should never throw + } if (result) { return result @@ -238,7 +240,9 @@ const parseGitUrl = (giturl) => { const correctedUrl = correctUrl(giturl) try { result = new url.URL(correctedUrl) - } catch (err) {} + } catch { + // this fn should never throw + } return result } diff --git a/node_modules/hosted-git-info/package.json b/node_modules/hosted-git-info/package.json index 0153b0852cbf..07a5587ca76e 100644 --- a/node_modules/hosted-git-info/package.json +++ b/node_modules/hosted-git-info/package.json @@ -1,11 +1,11 @@ { "name": "hosted-git-info", - "version": "5.0.0", + "version": "5.1.0", "description": "Provides metadata and conversions from repository urls for GitHub, Bitbucket and GitLab", "main": "./lib/index.js", "repository": { "type": "git", - "url": "git+https://github.com/npm/hosted-git-info.git" + "url": "https://github.com/npm/hosted-git-info.git" }, "keywords": [ "git", @@ -27,30 +27,32 @@ "snap": "tap", "test": "tap", "test:coverage": "tap --coverage-report=html", - "lint": "eslint '**/*.js'", - "postlint": "npm-template-check", - "template-copy": "npm-template-copy --force", - "lintfix": "npm run lint -- --fix" + "lint": "eslint \"**/*.js\"", + "postlint": "template-oss-check", + "lintfix": "npm run lint -- --fix", + "template-oss-apply": "template-oss-apply --force" }, "dependencies": { "lru-cache": "^7.5.1" }, "devDependencies": { - "@npmcli/template-oss": "^2.9.2", - "tap": "^15.1.6" + "@npmcli/eslint-config": "^3.0.1", + "@npmcli/template-oss": "3.5.0", + "tap": "^16.0.1" }, "files": [ - "bin", - "lib" + "bin/", + "lib/" ], "engines": { - "node": "^12.13.0 || ^14.15.0 || >=16" + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" }, "tap": { "color": 1, "coverage": true }, "templateOSS": { - "version": "2.9.2" + "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", + "version": "3.5.0" } } diff --git a/package-lock.json b/package-lock.json index 555c08987cee..264a43bbacae 100644 --- a/package-lock.json +++ b/package-lock.json @@ -109,7 +109,7 @@ "fastest-levenshtein": "^1.0.12", "glob": "^8.0.1", "graceful-fs": "^4.2.10", - "hosted-git-info": "^5.0.0", + "hosted-git-info": "^5.1.0", "ini": "^3.0.0", "init-package-json": "^3.0.2", "is-cidr": "^4.0.2", @@ -3820,14 +3820,15 @@ } }, "node_modules/hosted-git-info": { - "version": "5.0.0", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-5.1.0.tgz", + "integrity": "sha512-Ek+QmMEqZF8XrbFdwoDjSbm7rT23pCgEMOJmz6GPk/s4yH//RQfNPArhIxbguNxROq/+5lNBwCDHMhA903Kx1Q==", "inBundle": true, - "license": "ISC", "dependencies": { "lru-cache": "^7.5.1" }, "engines": { - "node": "^12.13.0 || ^14.15.0 || >=16" + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" } }, "node_modules/html-encoding-sniffer": { diff --git a/package.json b/package.json index 03984d906706..e4a045857672 100644 --- a/package.json +++ b/package.json @@ -74,7 +74,7 @@ "fastest-levenshtein": "^1.0.12", "glob": "^8.0.1", "graceful-fs": "^4.2.10", - "hosted-git-info": "^5.0.0", + "hosted-git-info": "^5.1.0", "ini": "^3.0.0", "init-package-json": "^3.0.2", "is-cidr": "^4.0.2", diff --git a/workspaces/arborist/tap-snapshots/test/spec-from-lock.js.test.cjs b/workspaces/arborist/tap-snapshots/test/spec-from-lock.js.test.cjs index c67ddf275ccb..86a774fffb9f 100644 --- a/workspaces/arborist/tap-snapshots/test/spec-from-lock.js.test.cjs +++ b/workspaces/arborist/tap-snapshots/test/spec-from-lock.js.test.cjs @@ -101,6 +101,8 @@ Result { "default": "sshurl", "docstemplate": "function docstemplate", "domain": "github.com", + "editpath": "edit", + "edittemplate": "function edittemplate", "extract": "function extract", "filetemplate": "function filetemplate", "gittemplate": "function gittemplate",