From 18ad752d8d11557f9fe71d8dad70381fda45bc04 Mon Sep 17 00:00:00 2001 From: Allison Kemmerle Date: Wed, 4 Dec 2024 10:35:31 -0500 Subject: [PATCH 1/4] Change types for fetching github content --- lib/github.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/github.ts b/lib/github.ts index 4108bad..05a50da 100644 --- a/lib/github.ts +++ b/lib/github.ts @@ -26,7 +26,8 @@ export async function fetchFileFromRepository( repoPath: RepoPath, filePath: string, ref: string -): Promise { + // eslint-disable-next-line @typescript-eslint/no-explicit-any +): Promise { try { logger.debug( i18n(`${i18nKey}.fetchFileFromRepository.fetching`, { @@ -145,6 +146,7 @@ export async function fetchGitHubRepoContentFromDownloadUrl( } else { fileContents = resp.data; } + // @ts-expect-error TODO: Discuss with team how to address error fs.outputFileSync(dest, fileContents); } From 9fc731177b38668bd23def0e783b9dda93dd2c50 Mon Sep 17 00:00:00 2001 From: Allison Kemmerle Date: Wed, 4 Dec 2024 10:47:42 -0500 Subject: [PATCH 2/4] Remove comment --- lib/github.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/github.ts b/lib/github.ts index 05a50da..7b53f4f 100644 --- a/lib/github.ts +++ b/lib/github.ts @@ -146,7 +146,6 @@ export async function fetchGitHubRepoContentFromDownloadUrl( } else { fileContents = resp.data; } - // @ts-expect-error TODO: Discuss with team how to address error fs.outputFileSync(dest, fileContents); } From bb7a33e04315a970a6f8db40e93f8bcf2072aa85 Mon Sep 17 00:00:00 2001 From: Allison Kemmerle Date: Wed, 4 Dec 2024 13:54:50 -0500 Subject: [PATCH 3/4] Address feedback p1 --- api/github.ts | 6 +++--- lib/github.ts | 7 +++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/api/github.ts b/api/github.ts index 46ee440..a17a4c9 100644 --- a/api/github.ts +++ b/api/github.ts @@ -56,12 +56,12 @@ export function fetchRepoAsZip(zipUrl: string): HubSpotPromise { } // Returns the raw file contents via the raw.githubusercontent endpoint -export function fetchRepoFile( +export function fetchRepoFile( repoPath: RepoPath, filePath: string, ref: string -): HubSpotPromise { - return axios.get( +): HubSpotPromise { + return axios.get( `${GITHUB_RAW_CONTENT_API_PATH}/${repoPath}/${ref}/${filePath}`, { headers: { diff --git a/lib/github.ts b/lib/github.ts index 7b53f4f..d779cb1 100644 --- a/lib/github.ts +++ b/lib/github.ts @@ -22,12 +22,11 @@ import { isHubSpotHttpError, isSystemError } from '../errors'; const i18nKey = 'lib.github'; -export async function fetchFileFromRepository( +export async function fetchFileFromRepository( repoPath: RepoPath, filePath: string, ref: string - // eslint-disable-next-line @typescript-eslint/no-explicit-any -): Promise { +): Promise { try { logger.debug( i18n(`${i18nKey}.fetchFileFromRepository.fetching`, { @@ -36,7 +35,7 @@ export async function fetchFileFromRepository( ); const { data } = await fetchRepoFile(repoPath, filePath, ref); - return data; + return data as T; } catch (err) { throw new Error( i18n(`${i18nKey}.fetchFileFromRepository.errors.fetchFail`), From 02f193dc44b491147749b68f1314acdbefb13108 Mon Sep 17 00:00:00 2001 From: Allison Kemmerle Date: Thu, 5 Dec 2024 12:35:14 -0500 Subject: [PATCH 4/4] Address feedback & add property to type --- lib/github.ts | 4 ++-- types/developerTestAccounts.ts | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/github.ts b/lib/github.ts index d779cb1..a12133a 100644 --- a/lib/github.ts +++ b/lib/github.ts @@ -34,8 +34,8 @@ export async function fetchFileFromRepository( }) ); - const { data } = await fetchRepoFile(repoPath, filePath, ref); - return data as T; + const { data } = await fetchRepoFile(repoPath, filePath, ref); + return data; } catch (err) { throw new Error( i18n(`${i18nKey}.fetchFileFromRepository.errors.fetchFail`), diff --git a/types/developerTestAccounts.ts b/types/developerTestAccounts.ts index 60179d4..d1deef4 100644 --- a/types/developerTestAccounts.ts +++ b/types/developerTestAccounts.ts @@ -5,6 +5,7 @@ export type DeveloperTestAccount = { createdAt: string; updatedAt: string; status: string; + id: number; }; export type FetchDeveloperTestAccountsResponse = {