diff --git a/lib/platform/azure/index.ts b/lib/platform/azure/index.ts index d536ffba2b1fb2782703af3ce7ef8c9190471561..a9ed8ed84c0d246ebccc1193780aa3b72fe1e72d 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 db3c21a89d33ec5e629494fdbc5f4ca00ad06809..deee43b86ceb491a805c73ed74d64c6a4f9f8c7e 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 94683100eb6d011306a0ffb91ffcb5317a1b511c..2d5de5c4500168928b0bea44f47eceb03c193c22 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 8b84570f26a8d0424e6578836dbbe6822bf2dbf0..67101e142a1c4f3b6c65e1a4ceaabe3a7c5b169b 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 7d7cb2fe19d40887986876c43b6feeee8bbd0178..72b6ee87cc5c8bd62b9dcaac89db1024a39bdfc1 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 c3dad3147a579ca5438a8fc9066ddf9db08d08e8..2f0d3a19281c7ec7728359c9066d043da86712b4 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 ade3fe6f4adb4164a33a5c94bbd79f0298a4b16a..9fcf7bac12190ff243481ff4df1b04a670e2829d 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 fa664bac663dcd0441e5da243a2a1b77c8a379de..e8e53e59bd8ac910205b65c612926b1a83dd4246 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 497474c5cfe288c4eb8ef928d44967341d8175b3..5eb423e511c867783cd4dc7f7c834a85bc6f6d64 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>;