From b11e5cb7617b5b32706a525a40aa91f58919ba85 Mon Sep 17 00:00:00 2001 From: Rhys Arkins <rhys@arkins.net> Date: Fri, 24 Jul 2020 17:57:45 +0200 Subject: [PATCH] chore: rename platform types --- lib/platform/azure/index.ts | 12 ++++++------ lib/platform/bitbucket-server/index.ts | 12 ++++++------ lib/platform/bitbucket/index.ts | 12 ++++++------ lib/platform/common.ts | 8 ++++---- lib/platform/gitea/index.spec.ts | 4 ++-- lib/platform/gitea/index.ts | 8 ++++---- lib/platform/github/index.ts | 12 ++++++------ lib/platform/gitlab/index.ts | 12 ++++++------ lib/workers/repository/init/apis.ts | 4 ++-- 9 files changed, 42 insertions(+), 42 deletions(-) diff --git a/lib/platform/azure/index.ts b/lib/platform/azure/index.ts index d536ffba2b..a9ed8ed84c 100644 --- a/lib/platform/azure/index.ts +++ b/lib/platform/azure/index.ts @@ -26,10 +26,10 @@ import { EnsureIssueResult, FindPRConfig, Issue, - PlatformConfig, + PlatformResult, Pr, - RepoConfig, RepoParams, + RepoResult, VulnerabilityAlert, } from '../common'; import { smartTruncate } from '../utils/pr-body'; @@ -65,7 +65,7 @@ export function initPlatform({ token, username, password, -}: RenovateConfig): Promise<PlatformConfig> { +}: RenovateConfig): Promise<PlatformResult> { if (!endpoint) { throw new Error('Init: You must configure an Azure DevOps endpoint'); } @@ -80,7 +80,7 @@ export function initPlatform({ }; defaults.endpoint = res.endpoint; azureApi.setEndpoint(res.endpoint); - const platformConfig: PlatformConfig = { + const platformConfig: PlatformResult = { endpoint: defaults.endpoint, }; return Promise.resolve(platformConfig); @@ -98,7 +98,7 @@ export async function initRepo({ localDir, azureWorkItemId, optimizeForDisabled, -}: RepoParams): Promise<RepoConfig> { +}: RepoParams): Promise<RepoResult> { logger.debug(`initRepo("${repository}")`); config = { repository, azureWorkItemId } as any; const azureApiGit = await azureApi.gitApi(); @@ -157,7 +157,7 @@ export async function initRepo({ gitAuthorName: global.gitAuthor?.name, gitAuthorEmail: global.gitAuthor?.email, }); - const repoConfig: RepoConfig = { + const repoConfig: RepoResult = { defaultBranch, isFork: false, }; diff --git a/lib/platform/bitbucket-server/index.ts b/lib/platform/bitbucket-server/index.ts index db3c21a89d..deee43b86c 100644 --- a/lib/platform/bitbucket-server/index.ts +++ b/lib/platform/bitbucket-server/index.ts @@ -29,10 +29,10 @@ import { EnsureIssueResult, FindPRConfig, Issue, - PlatformConfig, + PlatformResult, Pr, - RepoConfig, RepoParams, + RepoResult, VulnerabilityAlert, } from '../common'; import { smartTruncate } from '../utils/pr-body'; @@ -68,7 +68,7 @@ export function initPlatform({ endpoint, username, password, -}: RenovateConfig): Promise<PlatformConfig> { +}: RenovateConfig): Promise<PlatformResult> { if (!endpoint) { throw new Error('Init: You must configure a Bitbucket Server endpoint'); } @@ -80,7 +80,7 @@ export function initPlatform({ // TODO: Add a connection check that endpoint/username/password combination are valid defaults.endpoint = ensureTrailingSlash(endpoint); setBaseUrl(defaults.endpoint); - const platformConfig: PlatformConfig = { + const platformConfig: PlatformResult = { endpoint: defaults.endpoint, }; return Promise.resolve(platformConfig); @@ -111,7 +111,7 @@ export async function initRepo({ localDir, optimizeForDisabled, bbUseDefaultReviewers, -}: RepoParams): Promise<RepoConfig> { +}: RepoParams): Promise<RepoResult> { logger.debug( `initRepo("${JSON.stringify({ repository, localDir }, null, 2)}")` ); @@ -202,7 +202,7 @@ export async function initRepo({ ) ).body.displayId; config.mergeMethod = 'merge'; - const repoConfig: RepoConfig = { + const repoConfig: RepoResult = { defaultBranch, isFork: !!info.parent, }; diff --git a/lib/platform/bitbucket/index.ts b/lib/platform/bitbucket/index.ts index 94683100eb..2d5de5c450 100644 --- a/lib/platform/bitbucket/index.ts +++ b/lib/platform/bitbucket/index.ts @@ -23,10 +23,10 @@ import { EnsureIssueResult, FindPRConfig, Issue, - PlatformConfig, + PlatformResult, Pr, - RepoConfig, RepoParams, + RepoResult, VulnerabilityAlert, } from '../common'; import { smartTruncate } from '../utils/pr-body'; @@ -46,7 +46,7 @@ export function initPlatform({ endpoint, username, password, -}: RenovateConfig): Promise<PlatformConfig> { +}: RenovateConfig): Promise<PlatformResult> { if (!(username && password)) { throw new Error( 'Init: You must configure a Bitbucket username and password' @@ -60,7 +60,7 @@ export function initPlatform({ } setBaseUrl(endpoint_); // TODO: Add a connection check that endpoint/username/password combination are valid - const platformConfig: PlatformConfig = { + const platformConfig: PlatformResult = { endpoint: endpoint || BITBUCKET_PROD_ENDPOINT, }; return Promise.resolve(platformConfig); @@ -86,7 +86,7 @@ export async function initRepo({ localDir, optimizeForDisabled, bbUseDefaultReviewers, -}: RepoParams): Promise<RepoConfig> { +}: RepoParams): Promise<RepoResult> { logger.debug(`initRepo("${repository}")`); const opts = hostRules.find({ hostType: PLATFORM_TYPE_BITBUCKET, @@ -159,7 +159,7 @@ export async function initRepo({ gitAuthorName: global.gitAuthor?.name, gitAuthorEmail: global.gitAuthor?.email, }); - const repoConfig: RepoConfig = { + const repoConfig: RepoResult = { defaultBranch: info.mainbranch, isFork: info.isFork, }; diff --git a/lib/platform/common.ts b/lib/platform/common.ts index 8b84570f26..67101e142a 100644 --- a/lib/platform/common.ts +++ b/lib/platform/common.ts @@ -6,13 +6,13 @@ import { export type VulnerabilityAlert = _VulnerabilityAlert; -export interface PlatformConfig { +export interface PlatformResult { endpoint: string; renovateUsername?: any; gitAuthor?: any; } -export interface RepoConfig { +export interface RepoResult { defaultBranch: string; isFork: boolean; } @@ -122,7 +122,7 @@ export interface Platform { findIssue(title: string): Promise<Issue | null>; getIssueList(): Promise<Issue[]>; getVulnerabilityAlerts(): Promise<VulnerabilityAlert[]>; - initRepo(config: RepoParams): Promise<RepoConfig>; + initRepo(config: RepoParams): Promise<RepoResult>; getPrList(): Promise<Pr[]>; ensureIssueClosing(title: string): Promise<void>; ensureIssue( @@ -158,5 +158,5 @@ export interface Platform { requiredStatusChecks?: string[] | null ): Promise<BranchStatus>; getBranchPr(branchName: string): Promise<Pr | null>; - initPlatform(config: RenovateConfig): Promise<PlatformConfig>; + initPlatform(config: RenovateConfig): Promise<PlatformResult>; } diff --git a/lib/platform/gitea/index.spec.ts b/lib/platform/gitea/index.spec.ts index 7d7cb2fe19..72b6ee87cc 100644 --- a/lib/platform/gitea/index.spec.ts +++ b/lib/platform/gitea/index.spec.ts @@ -1,4 +1,4 @@ -import { BranchStatusConfig, Platform, RepoConfig, RepoParams } from '..'; +import { BranchStatusConfig, Platform, RepoParams, RepoResult } from '..'; import { partial } from '../../../test/util'; import { REPOSITORY_ACCESS_FORBIDDEN, @@ -168,7 +168,7 @@ describe('platform/gitea', () => { function initFakeRepo( repo?: Partial<ght.Repo>, config?: Partial<RepoParams> - ): Promise<RepoConfig> { + ): Promise<RepoResult> { helper.getRepo.mockResolvedValueOnce({ ...mockRepo, ...repo }); return gitea.initRepo({ diff --git a/lib/platform/gitea/index.ts b/lib/platform/gitea/index.ts index c3dad3147a..2f0d3a1928 100644 --- a/lib/platform/gitea/index.ts +++ b/lib/platform/gitea/index.ts @@ -29,10 +29,10 @@ import { FindPRConfig, Issue, Platform, - PlatformConfig, + PlatformResult, Pr, - RepoConfig, RepoParams, + RepoResult, VulnerabilityAlert, } from '../common'; import { smartTruncate } from '../utils/pr-body'; @@ -186,7 +186,7 @@ const platform: Platform = { async initPlatform({ endpoint, token, - }: GiteaRenovateConfig): Promise<PlatformConfig> { + }: GiteaRenovateConfig): Promise<PlatformResult> { if (!token) { throw new Error('Init: You must configure a Gitea personal access token'); } @@ -221,7 +221,7 @@ const platform: Platform = { repository, localDir, optimizeForDisabled, - }: RepoParams): Promise<RepoConfig> { + }: RepoParams): Promise<RepoResult> { let renovateConfig: RenovateConfig; let repo: helper.Repo; diff --git a/lib/platform/github/index.ts b/lib/platform/github/index.ts index ade3fe6f4a..9fcf7bac12 100644 --- a/lib/platform/github/index.ts +++ b/lib/platform/github/index.ts @@ -38,10 +38,10 @@ import { EnsureIssueResult, FindPRConfig, Issue, - PlatformConfig, + PlatformResult, Pr, - RepoConfig, RepoParams, + RepoResult, VulnerabilityAlert, } from '../common'; import { smartTruncate } from '../utils/pr-body'; @@ -76,7 +76,7 @@ export async function initPlatform({ }: { endpoint: string; token: string; -}): Promise<PlatformConfig> { +}): Promise<PlatformResult> { if (!token) { throw new Error('Init: You must configure a GitHub personal access token'); } @@ -126,7 +126,7 @@ export async function initPlatform({ gitAuthor = undefined; } logger.debug('Authenticated as GitHub user: ' + renovateUsername); - const platformConfig: PlatformConfig = { + const platformConfig: PlatformResult = { endpoint: defaults.endpoint, gitAuthor, renovateUsername, @@ -172,7 +172,7 @@ export async function initRepo({ includeForks, renovateUsername, optimizeForDisabled, -}: RepoParams): Promise<RepoConfig> { +}: RepoParams): Promise<RepoResult> { logger.debug(`initRepo("${repository}")`); // config is used by the platform api itself, not necessary for the app layer to know config = { localDir, repository } as any; @@ -422,7 +422,7 @@ export async function initRepo({ gitAuthorName: global.gitAuthor?.name, gitAuthorEmail: global.gitAuthor?.email, }); - const repoConfig: RepoConfig = { + const repoConfig: RepoResult = { defaultBranch: config.defaultBranch, isFork: repo.isFork === true, }; diff --git a/lib/platform/gitlab/index.ts b/lib/platform/gitlab/index.ts index fa664bac66..e8e53e59bd 100644 --- a/lib/platform/gitlab/index.ts +++ b/lib/platform/gitlab/index.ts @@ -32,10 +32,10 @@ import { EnsureIssueConfig, FindPRConfig, Issue, - PlatformConfig, + PlatformResult, Pr, - RepoConfig, RepoParams, + RepoResult, VulnerabilityAlert, } from '../common'; import { smartTruncate } from '../utils/pr-body'; @@ -79,7 +79,7 @@ export async function initPlatform({ }: { token: string; endpoint: string; -}): Promise<PlatformConfig> { +}): Promise<PlatformResult> { if (!token) { throw new Error('Init: You must configure a GitLab personal access token'); } @@ -106,7 +106,7 @@ export async function initPlatform({ ); throw new Error('Init: Authentication failure'); } - const platformConfig: PlatformConfig = { + const platformConfig: PlatformResult = { endpoint: defaults.endpoint, gitAuthor, }; @@ -140,7 +140,7 @@ export async function initRepo({ repository, localDir, optimizeForDisabled, -}: RepoParams): Promise<RepoConfig> { +}: RepoParams): Promise<RepoResult> { config = {} as any; config.repository = urlEscape(repository); config.localDir = localDir; @@ -252,7 +252,7 @@ export async function initRepo({ logger.debug({ err }, 'Unknown GitLab initRepo error'); throw err; } - const repoConfig: RepoConfig = { + const repoConfig: RepoResult = { defaultBranch, isFork: !!res.body.forked_from_project, }; diff --git a/lib/workers/repository/init/apis.ts b/lib/workers/repository/init/apis.ts index 497474c5cf..5eb423e511 100644 --- a/lib/workers/repository/init/apis.ts +++ b/lib/workers/repository/init/apis.ts @@ -1,9 +1,9 @@ import { RenovateConfig } from '../../../config'; import * as npmApi from '../../../datasource/npm'; -import { RepoConfig, RepoParams, platform } from '../../../platform'; +import { RepoParams, RepoResult, platform } from '../../../platform'; // TODO: fix types -export type WorkerPlatformConfig = RepoConfig & +export type WorkerPlatformConfig = RepoResult & RenovateConfig & Record<string, any>; -- GitLab