From 6584c7d90430de35f0b3b23947406a82d2980f54 Mon Sep 17 00:00:00 2001 From: Zach Pratt Date: Fri, 2 Feb 2024 16:37:03 -0600 Subject: [PATCH] feat(vcs-details): support running form8ion against hosted githubs --- package-lock.json | 48 ++++++++++++++++++++++++++++++++++++++++++++++- package.json | 2 +- src/vcs.js | 4 ++-- src/vcs.test.js | 6 +++--- 4 files changed, 53 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index 997a8af8..0de0c6a6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ "@form8ion/project": "^18.0.0", "@form8ion/results-reporter": "^1.1.0", "@travi/cli-messages": "^1.0.4", - "hosted-git-info": "^7.0.0", + "git-url-parse": "^14.0.0", "simple-git": "^3.16.0" }, "devDependencies": { @@ -10252,6 +10252,23 @@ "node": ">=10" } }, + "node_modules/git-up": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/git-up/-/git-up-7.0.0.tgz", + "integrity": "sha512-ONdIrbBCFusq1Oy0sC71F5azx8bVkvtZtMJAsv+a6lz5YAmbNnLD6HAB4gptHZVLPR8S2/kVN6Gab7lryq5+lQ==", + "dependencies": { + "is-ssh": "^1.4.0", + "parse-url": "^8.1.0" + } + }, + "node_modules/git-url-parse": { + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/git-url-parse/-/git-url-parse-14.0.0.tgz", + "integrity": "sha512-NnLweV+2A4nCvn4U/m2AoYu0pPKlsmhK9cknG7IMwsjFY1S2jxM+mAhsDxyxfCIGfGaD+dozsyX4b6vkYc83yQ==", + "dependencies": { + "git-up": "^7.0.0" + } + }, "node_modules/github-slugger": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/github-slugger/-/github-slugger-2.0.0.tgz", @@ -11445,6 +11462,14 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-ssh": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/is-ssh/-/is-ssh-1.4.0.tgz", + "integrity": "sha512-x7+VxdxOdlV3CYpjvRLBv5Lo9OJerlYanjwFrPR9fuGPjCiNiCzFgAWpiLAohSbsnH4ZAys3SBh+hq5rJosxUQ==", + "dependencies": { + "protocols": "^2.0.1" + } + }, "node_modules/is-stream": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", @@ -17036,6 +17061,22 @@ "node": ">=0.10.0" } }, + "node_modules/parse-path": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/parse-path/-/parse-path-7.0.0.tgz", + "integrity": "sha512-Euf9GG8WT9CdqwuWJGdf3RkUcTBArppHABkO7Lm8IzRQp0e2r/kkFnmhu4TSK30Wcu5rVAZLmfPKSBBi9tWFog==", + "dependencies": { + "protocols": "^2.0.0" + } + }, + "node_modules/parse-url": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/parse-url/-/parse-url-8.1.0.tgz", + "integrity": "sha512-xDvOoLU5XRrcOZvnI6b8zA6n9O9ejNk/GExuz1yBuWUGn9KA97GI6HTs6u02wKara1CeVmZhH+0TZFdWScR89w==", + "dependencies": { + "parse-path": "^7.0.0" + } + }, "node_modules/path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", @@ -17543,6 +17584,11 @@ "pbts": "bin/pbts" } }, + "node_modules/protocols": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/protocols/-/protocols-2.0.1.tgz", + "integrity": "sha512-/XJ368cyBJ7fzLMwLKv1e4vLxOju2MNAIokcr7meSaNcVbWz/CPcW22cP04mwxOErdA5mwjA8Q6w/cdAQxVn7Q==" + }, "node_modules/publint": { "version": "0.2.7", "resolved": "https://registry.npmjs.org/publint/-/publint-0.2.7.tgz", diff --git a/package.json b/package.json index 642e3bd9..fdf0be62 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "@form8ion/project": "^18.0.0", "@form8ion/results-reporter": "^1.1.0", "@travi/cli-messages": "^1.0.4", - "hosted-git-info": "^7.0.0", + "git-url-parse": "^14.0.0", "simple-git": "^3.16.0" }, "devDependencies": { diff --git a/src/vcs.js b/src/vcs.js index 3cb56390..fde23e4e 100644 --- a/src/vcs.js +++ b/src/vcs.js @@ -1,10 +1,10 @@ import {simpleGit} from 'simple-git'; -import hostedGitInfo from 'hosted-git-info'; +import GitUrlParse from 'git-url-parse'; export async function determineExistingHostDetails({projectRoot}) { const git = simpleGit(projectRoot); const remoteOrigin = await git.remote(['get-url', 'origin']); - const {user: owner, project: name, type: host} = hostedGitInfo.fromUrl(remoteOrigin); + const {user: owner, project: name, type: host} = GitUrlParse(remoteOrigin); return {owner, name, host}; } diff --git a/src/vcs.test.js b/src/vcs.test.js index d09ff4dc..2194043d 100644 --- a/src/vcs.test.js +++ b/src/vcs.test.js @@ -1,5 +1,5 @@ import * as simpleGit from 'simple-git'; -import hostedGitInfo from 'hosted-git-info'; +import GitUrlParse from 'git-url-parse'; import {afterEach, describe, expect, it, vi} from 'vitest'; import any from '@travi/any'; @@ -8,7 +8,7 @@ import {when} from 'jest-when'; import {determineExistingHostDetails} from './vcs.js'; vi.mock('simple-git'); -vi.mock('hosted-git-info'); +vi.mock('git-url-parse'); describe('vcs', () => { afterEach(() => { @@ -24,7 +24,7 @@ describe('vcs', () => { const remote = vi.fn(); when(simpleGit.simpleGit).calledWith(projectRoot).mockReturnValue({remote}); when(remote).calledWith(['get-url', 'origin']).mockResolvedValue(remoteUrl); - when(hostedGitInfo.fromUrl).calledWith(remoteUrl).mockReturnValue({user: owner, project: name, type: host}); + when(GitUrlParse).calledWith(remoteUrl).mockReturnValue({user: owner, project: name, type: host}); expect(await determineExistingHostDetails({projectRoot})).toEqual({owner, name, host}); });