diff --git a/lib/config/migration.spec.ts b/lib/config/migration.spec.ts index d518c7f7718ad3404ac65d7183c6595d4795583f..8fcdcf039be4cd5f5c91499b62a854d42ce71088 100644 --- a/lib/config/migration.spec.ts +++ b/lib/config/migration.spec.ts @@ -1,4 +1,3 @@ -import { PlatformId } from '../constants'; import { GlobalConfig } from './global'; import * as configMigration from './migration'; import type { @@ -16,7 +15,7 @@ describe('config/migration', () => { const config: TestRenovateConfig = { endpoints: [{}] as never, enabled: true, - platform: PlatformId.Github, + platform: 'github', hostRules: [ { platform: 'docker', diff --git a/lib/config/options/index.ts b/lib/config/options/index.ts index 76618891050a3a08b1c49df6dbcef32853ac40d8..ce16fd8594e298bb34724b9eaf562b4cf9523ace 100644 --- a/lib/config/options/index.ts +++ b/lib/config/options/index.ts @@ -1,4 +1,3 @@ -import { PlatformId } from '../../constants'; import { getManagers } from '../../modules/manager'; import { getPlatformList } from '../../modules/platform'; import { getVersioningList } from '../../modules/versioning'; @@ -635,7 +634,7 @@ const options: RenovateOptions[] = [ description: 'Platform type of repository.', type: 'string', allowedValues: getPlatformList(), - default: PlatformId.Github, + default: 'github', globalOnly: true, }, { diff --git a/lib/config/presets/local/index.ts b/lib/config/presets/local/index.ts index 81a4b97694235738da776b55de467f3cb349a552..2c30b6b58ea5ebf408afa10317f1f127f8e77095 100644 --- a/lib/config/presets/local/index.ts +++ b/lib/config/presets/local/index.ts @@ -1,4 +1,4 @@ -import { PlatformId } from '../../../constants'; +import type { PlatformId } from '../../../constants'; import { GlobalConfig } from '../../global'; import * as azure from '../azure'; import * as bitbucket from '../bitbucket'; @@ -7,16 +7,14 @@ import * as gitea from '../gitea'; import * as github from '../github'; import * as gitlab from '../gitlab'; import type { Preset, PresetConfig } from '../types'; -import * as local from './common'; const resolvers = { - [PlatformId.Azure]: azure, - [PlatformId.Bitbucket]: bitbucket, - [PlatformId.BitbucketServer]: bitbucketServer, - [PlatformId.CodeCommit]: local, - [PlatformId.Gitea]: gitea, - [PlatformId.Github]: github, - [PlatformId.Gitlab]: gitlab, + azure, + bitbucket, + 'bitbucket-server': bitbucketServer, + gitea, + github, + gitlab, } as const; export function getPreset({ diff --git a/lib/config/types.ts b/lib/config/types.ts index 3da773528317d9f87fb72e9426430fa0725b9991..7603028afe57188c664879f659e35423838a8af6 100644 --- a/lib/config/types.ts +++ b/lib/config/types.ts @@ -1,5 +1,6 @@ import type { LogLevel } from 'bunyan'; import type { Range } from 'semver'; +import type { PlatformId } from '../constants'; import type { HostRule } from '../types'; import type { GitNoVerifyOption } from '../util/git/types'; @@ -100,7 +101,7 @@ export interface GlobalOnlyConfig { privateKeyPathOld?: string; redisUrl?: string; repositories?: RenovateRepository[]; - platform?: string; + platform?: PlatformId; endpoint?: string; } @@ -128,7 +129,7 @@ export interface RepoGlobalConfig { localDir?: string; cacheDir?: string; containerbaseDir?: string; - platform?: string; + platform?: PlatformId; endpoint?: string; } diff --git a/lib/constants/platform.spec.ts b/lib/constants/platform.spec.ts index da86c73215cdacb8fc79917f72af6fb2c7b37116..b663bd5db70cc5d7fddf7eb1b878d50213ed2382 100644 --- a/lib/constants/platform.spec.ts +++ b/lib/constants/platform.spec.ts @@ -12,7 +12,6 @@ import { BITBUCKET_API_USING_HOST_TYPES, GITHUB_API_USING_HOST_TYPES, GITLAB_API_USING_HOST_TYPES, - PlatformId, } from './platforms'; describe('constants/platform', () => { @@ -29,11 +28,11 @@ describe('constants/platform', () => { expect( GITLAB_API_USING_HOST_TYPES.includes(GITLAB_CHANGELOG_ID) ).toBeTrue(); - expect(GITLAB_API_USING_HOST_TYPES.includes(PlatformId.Gitlab)).toBeTrue(); + expect(GITLAB_API_USING_HOST_TYPES.includes('gitlab')).toBeTrue(); }); it('should be not part of the GITLAB_API_USING_HOST_TYPES ', () => { - expect(GITLAB_API_USING_HOST_TYPES.includes(PlatformId.Github)).toBeFalse(); + expect(GITLAB_API_USING_HOST_TYPES.includes('github')).toBeFalse(); }); it('should be part of the GITHUB_API_USING_HOST_TYPES ', () => { @@ -50,19 +49,17 @@ describe('constants/platform', () => { expect( GITHUB_API_USING_HOST_TYPES.includes(GITHUB_CHANGELOG_ID) ).toBeTrue(); - expect(GITHUB_API_USING_HOST_TYPES.includes(PlatformId.Github)).toBeTrue(); + expect(GITHUB_API_USING_HOST_TYPES.includes('github')).toBeTrue(); }); it('should be not part of the GITHUB_API_USING_HOST_TYPES ', () => { - expect(GITHUB_API_USING_HOST_TYPES.includes(PlatformId.Gitlab)).toBeFalse(); + expect(GITHUB_API_USING_HOST_TYPES.includes('gitlab')).toBeFalse(); }); it('should be part of the BITBUCKET_API_USING_HOST_TYPES ', () => { expect( BITBUCKET_API_USING_HOST_TYPES.includes(BitBucketTagsDatasource.id) ).toBeTrue(); - expect( - BITBUCKET_API_USING_HOST_TYPES.includes(PlatformId.Bitbucket) - ).toBeTrue(); + expect(BITBUCKET_API_USING_HOST_TYPES.includes('bitbucket')).toBeTrue(); }); }); diff --git a/lib/constants/platforms.ts b/lib/constants/platforms.ts index af2d3c8ec41de427eeea91373601b45d8122ba64..dfd4d3e4b39c7dd415a2db08e15bbb564bef4c9d 100644 --- a/lib/constants/platforms.ts +++ b/lib/constants/platforms.ts @@ -1,16 +1,13 @@ -// eslint-disable-next-line typescript-enum/no-enum, typescript-enum/no-const-enum -export const enum PlatformId { - Azure = 'azure', - Bitbucket = 'bitbucket', - BitbucketServer = 'bitbucket-server', - CodeCommit = 'codecommit', - Gitea = 'gitea', - Github = 'github', - Gitlab = 'gitlab', -} +export type PlatformId = + | 'azure' + | 'bitbucket' + | 'bitbucket-server' + | 'gitea' + | 'github' + | 'gitlab'; export const GITHUB_API_USING_HOST_TYPES = [ - PlatformId.Github, + 'github', 'github-releases', 'github-tags', 'pod', @@ -19,14 +16,11 @@ export const GITHUB_API_USING_HOST_TYPES = [ ]; export const GITLAB_API_USING_HOST_TYPES = [ - PlatformId.Gitlab, + 'gitlab', 'gitlab-releases', 'gitlab-tags', 'gitlab-packages', 'gitlab-changelog', ]; -export const BITBUCKET_API_USING_HOST_TYPES = [ - PlatformId.Bitbucket, - 'bitbucket-tags', -]; +export const BITBUCKET_API_USING_HOST_TYPES = ['bitbucket', 'bitbucket-tags']; diff --git a/lib/modules/datasource/go/base.spec.ts b/lib/modules/datasource/go/base.spec.ts index 66d771ed00b6d62eb2832d47492171c3795e07a5..7c1b6c0f7aed0ae3a4507439166bcbdde2c9f170 100644 --- a/lib/modules/datasource/go/base.spec.ts +++ b/lib/modules/datasource/go/base.spec.ts @@ -1,7 +1,6 @@ import { Fixtures } from '../../../../test/fixtures'; import * as httpMock from '../../../../test/http-mock'; import { mocked } from '../../../../test/util'; -import { PlatformId } from '../../../constants'; import * as _hostRules from '../../../util/host-rules'; import { GitTagsDatasource } from '../git-tags'; import { GithubTagsDatasource } from '../github-tags'; @@ -205,7 +204,7 @@ describe('modules/datasource/go/base', () => { }); it('supports GitLab EE deps', async () => { - hostRules.hostType.mockReturnValue(PlatformId.Gitlab); + hostRules.hostType.mockReturnValue('gitlab'); httpMock .scope('https://my.custom.domain') .get('/golang/myrepo?go-get=1') @@ -223,7 +222,7 @@ describe('modules/datasource/go/base', () => { }); it('supports GitLab EE deps in subgroup', async () => { - hostRules.hostType.mockReturnValue(PlatformId.Gitlab); + hostRules.hostType.mockReturnValue('gitlab'); httpMock .scope('https://my.custom.domain') .get('/golang/subgroup/myrepo?go-get=1') @@ -241,7 +240,7 @@ describe('modules/datasource/go/base', () => { }); it('supports GitLab EE deps in subgroup with version', async () => { - hostRules.hostType.mockReturnValue(PlatformId.Gitlab); + hostRules.hostType.mockReturnValue('gitlab'); httpMock .scope('https://my.custom.domain') .get('/golang/subgroup/myrepo/v2?go-get=1') @@ -259,7 +258,7 @@ describe('modules/datasource/go/base', () => { }); it('supports GitLab EE deps in private subgroup with vcs indicator', async () => { - hostRules.hostType.mockReturnValue(PlatformId.Gitlab); + hostRules.hostType.mockReturnValue('gitlab'); httpMock .scope('https://my.custom.domain') .get('/golang/subgroup/myrepo.git/v2?go-get=1') @@ -277,7 +276,7 @@ describe('modules/datasource/go/base', () => { }); it('supports GitLab EE monorepo deps in subgroup', async () => { - hostRules.hostType.mockReturnValue(PlatformId.Gitlab); + hostRules.hostType.mockReturnValue('gitlab'); httpMock .scope('https://my.custom.domain') .get('/golang/subgroup/myrepo/monorepo?go-get=1') diff --git a/lib/modules/datasource/go/base.ts b/lib/modules/datasource/go/base.ts index 43e241e5075232985c7bd88f04898eeadd3361c4..c7e11c898598ac84b70b5bbdc0a92db0ea218f5c 100644 --- a/lib/modules/datasource/go/base.ts +++ b/lib/modules/datasource/go/base.ts @@ -1,7 +1,6 @@ // TODO: types (#7154) /* eslint-disable @typescript-eslint/restrict-template-expressions */ import URL from 'url'; -import { PlatformId } from '../../../constants'; import { logger } from '../../../logger'; import { detectPlatform } from '../../../util/common'; import * as hostRules from '../../../util/host-rules'; @@ -139,7 +138,7 @@ export class BaseGoDatasource { }; } - if (hostRules.hostType({ url: goSourceUrl }) === PlatformId.Gitlab) { + if (hostRules.hostType({ url: goSourceUrl }) === 'gitlab') { // get server base url from import url const parsedUrl = URL.parse(goSourceUrl); diff --git a/lib/modules/manager/composer/artifacts.spec.ts b/lib/modules/manager/composer/artifacts.spec.ts index 9647b4bac516f604df906a3aa280fefd1870de31..e4734a4e5767e84fe0bd143346257f79cc54ccde 100644 --- a/lib/modules/manager/composer/artifacts.spec.ts +++ b/lib/modules/manager/composer/artifacts.spec.ts @@ -3,7 +3,6 @@ import { envMock, mockExecAll } from '../../../../test/exec-util'; import { env, fs, git, mocked, partial } from '../../../../test/util'; import { GlobalConfig } from '../../../config/global'; import type { RepoGlobalConfig } from '../../../config/types'; -import { PlatformId } from '../../../constants'; import * as docker from '../../../util/exec/docker'; import type { StatusResult } from '../../../util/git/types'; import * as hostRules from '../../../util/host-rules'; @@ -111,12 +110,12 @@ describe('modules/manager/composer/artifacts', () => { it('uses hostRules to set COMPOSER_AUTH', async () => { hostRules.add({ - hostType: PlatformId.Github, + hostType: 'github', matchHost: 'api.github.com', token: 'github-token', }); hostRules.add({ - hostType: PlatformId.Gitlab, + hostType: 'gitlab', matchHost: 'gitlab.com', token: 'gitlab-token', }); diff --git a/lib/modules/manager/composer/artifacts.ts b/lib/modules/manager/composer/artifacts.ts index 6ce79441de6c32bb2723466a2cd19afee39c5c93..9eab2b1cbff392feadda76258c660b9abf55b4fb 100644 --- a/lib/modules/manager/composer/artifacts.ts +++ b/lib/modules/manager/composer/artifacts.ts @@ -1,6 +1,5 @@ import is from '@sindresorhus/is'; import { quote } from 'shlex'; -import { PlatformId } from '../../../constants'; import { SYSTEM_INSUFFICIENT_DISK_SPACE, TEMPORARY_ERROR, @@ -33,7 +32,7 @@ function getAuthJson(): string | null { const authJson: AuthJson = {}; const githubCredentials = hostRules.find({ - hostType: PlatformId.Github, + hostType: 'github', url: 'https://api.github.com/', }); if (githubCredentials?.token) { @@ -42,20 +41,18 @@ function getAuthJson(): string | null { }; } - hostRules - .findAll({ hostType: PlatformId.Gitlab }) - ?.forEach((gitlabHostRule) => { - if (gitlabHostRule?.token) { - const host = gitlabHostRule.resolvedHost ?? 'gitlab.com'; - authJson['gitlab-token'] = authJson['gitlab-token'] ?? {}; - authJson['gitlab-token'][host] = gitlabHostRule.token; - // https://getcomposer.org/doc/articles/authentication-for-private-packages.md#gitlab-token - authJson['gitlab-domains'] = [ - host, - ...(authJson['gitlab-domains'] ?? []), - ]; - } - }); + hostRules.findAll({ hostType: 'gitlab' })?.forEach((gitlabHostRule) => { + if (gitlabHostRule?.token) { + const host = gitlabHostRule.resolvedHost ?? 'gitlab.com'; + authJson['gitlab-token'] = authJson['gitlab-token'] ?? {}; + authJson['gitlab-token'][host] = gitlabHostRule.token; + // https://getcomposer.org/doc/articles/authentication-for-private-packages.md#gitlab-token + authJson['gitlab-domains'] = [ + host, + ...(authJson['gitlab-domains'] ?? []), + ]; + } + }); hostRules .findAll({ hostType: PackagistDatasource.id }) diff --git a/lib/modules/manager/gomod/artifacts.spec.ts b/lib/modules/manager/gomod/artifacts.spec.ts index 96ffd899c031ab3f6f67b9328bb9f120e1856c90..57a780defaa4e8cfaddfa1219f3c85cbac711271 100644 --- a/lib/modules/manager/gomod/artifacts.spec.ts +++ b/lib/modules/manager/gomod/artifacts.spec.ts @@ -3,7 +3,6 @@ import { envMock, mockExecAll } from '../../../../test/exec-util'; import { env, fs, git, mocked } from '../../../../test/util'; import { GlobalConfig } from '../../../config/global'; import type { RepoGlobalConfig } from '../../../config/types'; -import { PlatformId } from '../../../constants/platforms'; import * as docker from '../../../util/exec/docker'; import type { StatusResult } from '../../../util/git/types'; import * as _hostRules from '../../../util/host-rules'; @@ -399,7 +398,7 @@ describe('modules/manager/gomod/artifacts', () => { hostRules.getAll.mockReturnValueOnce([ { token: 'some-token', - hostType: PlatformId.Github, + hostType: 'github', matchHost: 'api.github.com', }, { token: 'some-other-token', matchHost: 'https://gitea.com' }, @@ -499,13 +498,13 @@ describe('modules/manager/gomod/artifacts', () => { hostRules.getAll.mockReturnValueOnce([ { token: 'some-token', - hostType: PlatformId.Github, + hostType: 'github', matchHost: 'api.github.com', }, { token: 'some-enterprise-token', matchHost: 'github.enterprise.com', - hostType: PlatformId.Github, + hostType: 'github', }, ]); fs.readLocalFile.mockResolvedValueOnce('Current go.sum'); @@ -568,7 +567,7 @@ describe('modules/manager/gomod/artifacts', () => { { token: 'some-enterprise-token', matchHost: 'gitlab.enterprise.com', - hostType: PlatformId.Gitlab, + hostType: 'gitlab', }, ]); fs.readLocalFile.mockResolvedValueOnce('Current go.sum'); @@ -623,12 +622,12 @@ describe('modules/manager/gomod/artifacts', () => { { token: 'some-enterprise-token-repo1', matchHost: 'https://gitlab.enterprise.com/repo1', - hostType: PlatformId.Gitlab, + hostType: 'gitlab', }, { token: 'some-enterprise-token-repo2', matchHost: 'https://gitlab.enterprise.com/repo2', - hostType: PlatformId.Gitlab, + hostType: 'gitlab', }, ]); fs.readLocalFile.mockResolvedValueOnce('Current go.sum'); @@ -692,12 +691,12 @@ describe('modules/manager/gomod/artifacts', () => { { token: 'some-token', matchHost: 'ssh://github.enterprise.com', - hostType: PlatformId.Github, + hostType: 'github', }, { token: 'some-gitlab-token', matchHost: 'gitlab.enterprise.com', - hostType: PlatformId.Gitlab, + hostType: 'gitlab', }, ]); fs.readLocalFile.mockResolvedValueOnce('Current go.sum'); @@ -755,17 +754,17 @@ describe('modules/manager/gomod/artifacts', () => { { token: 'some-token', matchHost: 'api.github.com', - hostType: PlatformId.Github, + hostType: 'github', }, { token: 'some-enterprise-token', matchHost: 'github.enterprise.com', - hostType: PlatformId.Github, + hostType: 'github', }, { token: 'some-gitlab-token', matchHost: 'gitlab.enterprise.com', - hostType: PlatformId.Gitlab, + hostType: 'gitlab', }, ]); fs.readLocalFile.mockResolvedValueOnce('Current go.sum'); diff --git a/lib/modules/manager/gomod/artifacts.ts b/lib/modules/manager/gomod/artifacts.ts index c1c42721f7e9f60045eeac8a77dcce2f7829deff..6d2998f0aa493b46f945aa1696c6f949c88142d6 100644 --- a/lib/modules/manager/gomod/artifacts.ts +++ b/lib/modules/manager/gomod/artifacts.ts @@ -1,7 +1,6 @@ import is from '@sindresorhus/is'; import upath from 'upath'; import { GlobalConfig } from '../../../config/global'; -import { PlatformId } from '../../../constants'; import { TEMPORARY_ERROR } from '../../../constants/error-messages'; import { logger } from '../../../logger'; import type { HostRule } from '../../../types'; @@ -37,7 +36,7 @@ function getGitEnvironmentVariables(): NodeJS.ProcessEnv { // hard-coded logic to use authentication for github.com based on the githubToken for api.github.com const githubToken = find({ - hostType: PlatformId.Github, + hostType: 'github', url: 'https://api.github.com/', }); @@ -56,13 +55,12 @@ function getGitEnvironmentVariables(): NodeJS.ProcessEnv { const goGitAllowedHostType = new Set<string>([ // All known git platforms - PlatformId.Azure, - PlatformId.Bitbucket, - PlatformId.BitbucketServer, - PlatformId.CodeCommit, - PlatformId.Gitea, - PlatformId.Github, - PlatformId.Gitlab, + 'azure', + 'bitbucket', + 'bitbucket-server', + 'gitea', + 'github', + 'gitlab', ]); // for each hostRule without hostType we add additional authentication variables to the environmentVariables diff --git a/lib/modules/manager/pre-commit/extract.ts b/lib/modules/manager/pre-commit/extract.ts index cd84dd4392080fafd5f4ff367ed5ca0838114a62..5ad6a74fac24fdc7675771b76d79fe71bcd2a2eb 100644 --- a/lib/modules/manager/pre-commit/extract.ts +++ b/lib/modules/manager/pre-commit/extract.ts @@ -1,6 +1,5 @@ import is from '@sindresorhus/is'; import { load } from 'js-yaml'; -import { PlatformId } from '../../../constants'; import { logger } from '../../../logger'; import type { SkipReason } from '../../../types'; import { find } from '../../../util/host-rules'; @@ -51,9 +50,9 @@ function determineDatasource( return { skipReason: 'unknown-registry', registryUrls: [hostname] }; } for (const [hostType, sourceId] of [ - [PlatformId.Gitea, GitlabTagsDatasource.id], - [PlatformId.Github, GithubTagsDatasource.id], - [PlatformId.Gitlab, GitlabTagsDatasource.id], + ['gitea', GitlabTagsDatasource.id], + ['github', GithubTagsDatasource.id], + ['gitlab', GitlabTagsDatasource.id], ]) { if (!isEmptyObject(find({ hostType, url: hostUrl }))) { logger.debug( diff --git a/lib/modules/platform/azure/azure-got-wrapper.spec.ts b/lib/modules/platform/azure/azure-got-wrapper.spec.ts index d73b55a2704d7b0d18a8d4f5689bf4261265aedc..6b8498e378b1a1e87f3c49eddfffdef549bd0df5 100644 --- a/lib/modules/platform/azure/azure-got-wrapper.spec.ts +++ b/lib/modules/platform/azure/azure-got-wrapper.spec.ts @@ -1,4 +1,3 @@ -import { PlatformId } from '../../../constants'; import type * as _hostRules from '../../../util/host-rules'; describe('modules/platform/azure/azure-got-wrapper', () => { @@ -21,7 +20,7 @@ describe('modules/platform/azure/azure-got-wrapper', () => { it('should set personal access token and endpoint', () => { hostRules.add({ - hostType: PlatformId.Azure, + hostType: 'azure', token: '123test', matchHost: 'https://dev.azure.com/renovate1', }); @@ -42,7 +41,7 @@ describe('modules/platform/azure/azure-got-wrapper', () => { it('should set bearer token and endpoint', () => { hostRules.add({ - hostType: PlatformId.Azure, + hostType: 'azure', token: 'testtoken', matchHost: 'https://dev.azure.com/renovate2', }); @@ -63,7 +62,7 @@ describe('modules/platform/azure/azure-got-wrapper', () => { it('should set password and endpoint', () => { hostRules.add({ - hostType: PlatformId.Azure, + hostType: 'azure', username: 'user', password: 'pass', matchHost: 'https://dev.azure.com/renovate3', diff --git a/lib/modules/platform/azure/azure-got-wrapper.ts b/lib/modules/platform/azure/azure-got-wrapper.ts index 408ef5d36504fab93fd828472b6e94a102cb4af5..67c2ab51b6b21d2f6a25ec86410bbd246dd61118 100644 --- a/lib/modules/platform/azure/azure-got-wrapper.ts +++ b/lib/modules/platform/azure/azure-got-wrapper.ts @@ -4,11 +4,10 @@ import type { ICoreApi } from 'azure-devops-node-api/CoreApi'; import type { IGitApi } from 'azure-devops-node-api/GitApi'; import type { IPolicyApi } from 'azure-devops-node-api/PolicyApi'; import type { IRequestHandler } from 'azure-devops-node-api/interfaces/common/VsoBaseInterfaces'; -import { PlatformId } from '../../../constants'; import type { HostRule } from '../../../types'; import * as hostRules from '../../../util/host-rules'; -const hostType = PlatformId.Azure; +const hostType = 'azure'; let endpoint: string; function getAuthenticationHandler(config: HostRule): IRequestHandler { diff --git a/lib/modules/platform/azure/index.ts b/lib/modules/platform/azure/index.ts index 691cebb477066ff7ab563e0f47ce9cb017e8b3f0..1418d0403aa1fc4acc5060efc118337c32b8864a 100644 --- a/lib/modules/platform/azure/index.ts +++ b/lib/modules/platform/azure/index.ts @@ -10,7 +10,6 @@ import { } from 'azure-devops-node-api/interfaces/GitInterfaces.js'; import delay from 'delay'; import JSON5 from 'json5'; -import { PlatformId } from '../../../constants'; import { REPOSITORY_ARCHIVED, REPOSITORY_EMPTY, @@ -81,7 +80,7 @@ const defaults: { endpoint?: string; hostType: string; } = { - hostType: PlatformId.Azure, + hostType: 'azure', }; export function initPlatform({ diff --git a/lib/modules/platform/bitbucket-server/index.ts b/lib/modules/platform/bitbucket-server/index.ts index ca2246419b599c73e1eb217b52d55d38d11daba5..9ae76d64d8cd43290c5ba340b2428a927427750a 100644 --- a/lib/modules/platform/bitbucket-server/index.ts +++ b/lib/modules/platform/bitbucket-server/index.ts @@ -2,7 +2,6 @@ import is from '@sindresorhus/is'; import delay from 'delay'; import JSON5 from 'json5'; import type { PartialDeep } from 'type-fest'; -import { PlatformId } from '../../../constants'; import { REPOSITORY_CHANGED, REPOSITORY_EMPTY, @@ -69,7 +68,7 @@ const defaults: { endpoint?: string; hostType: string; } = { - hostType: PlatformId.BitbucketServer, + hostType: 'bitbucket-server', }; /* istanbul ignore next */ diff --git a/lib/modules/platform/bitbucket/index.ts b/lib/modules/platform/bitbucket/index.ts index 6d63ecf1a2775a108559f2813176308a878566d0..b23bf7008963d8b5aabacc87d44dede95a883bfc 100644 --- a/lib/modules/platform/bitbucket/index.ts +++ b/lib/modules/platform/bitbucket/index.ts @@ -1,7 +1,6 @@ import URL from 'url'; import is from '@sindresorhus/is'; import JSON5 from 'json5'; -import { PlatformId } from '../../../constants'; import { REPOSITORY_NOT_FOUND } from '../../../constants/error-messages'; import { logger } from '../../../logger'; import { BranchStatus, PrState, VulnerabilityAlert } from '../../../types'; @@ -158,7 +157,7 @@ export async function initRepo({ }: RepoParams): Promise<RepoResult> { logger.debug(`initRepo("${repository}")`); const opts = hostRules.find({ - hostType: PlatformId.Bitbucket, + hostType: 'bitbucket', url: defaults.endpoint, }); config = { diff --git a/lib/modules/platform/gitea/index.spec.ts b/lib/modules/platform/gitea/index.spec.ts index b90c0880d968c603e0dcabaec7a0466553e95c73..84d6b6907304f5370ee5c705bf08d7428af234eb 100644 --- a/lib/modules/platform/gitea/index.spec.ts +++ b/lib/modules/platform/gitea/index.spec.ts @@ -6,7 +6,6 @@ import type { RepoResult, } from '..'; import { mocked, partial } from '../../../../test/util'; -import { PlatformId } from '../../../constants'; import { CONFIG_GIT_URL_UNAVAILABLE, REPOSITORY_ACCESS_FORBIDDEN, @@ -495,7 +494,7 @@ describe('modules/platform/gitea/index', () => { const token = 'abc'; hostRules.add({ - hostType: PlatformId.Gitea, + hostType: 'gitea', matchHost: 'https://gitea.com/', token, }); @@ -523,7 +522,7 @@ describe('modules/platform/gitea/index', () => { const token = 'abc'; hostRules.add({ - hostType: PlatformId.Gitea, + hostType: 'gitea', matchHost: 'https://gitea.com/', token, }); diff --git a/lib/modules/platform/gitea/index.ts b/lib/modules/platform/gitea/index.ts index 3b49895a7ec9aba1b2a7a202b41faa18ae4aed3c..96d9c92ebd1e57c9ee4bc7d1ad83f89462c9ad3f 100644 --- a/lib/modules/platform/gitea/index.ts +++ b/lib/modules/platform/gitea/index.ts @@ -1,7 +1,6 @@ import is from '@sindresorhus/is'; import JSON5 from 'json5'; import semver from 'semver'; -import { PlatformId } from '../../../constants'; import { REPOSITORY_ACCESS_FORBIDDEN, REPOSITORY_ARCHIVED, @@ -69,7 +68,7 @@ interface GiteaRepoConfig { const DRAFT_PREFIX = 'WIP: '; const defaults = { - hostType: PlatformId.Gitea, + hostType: 'gitea', endpoint: 'https://gitea.com/', version: '0.0.0', }; diff --git a/lib/modules/platform/gitea/utils.ts b/lib/modules/platform/gitea/utils.ts index 3b0ee18cc28b1192b6b04699871fdaf2a9d3aaa0..1f589ee5dd1c9cd94787dea726c492eeb22c1203 100644 --- a/lib/modules/platform/gitea/utils.ts +++ b/lib/modules/platform/gitea/utils.ts @@ -1,5 +1,4 @@ import type { MergeStrategy } from '../../../config/types'; -import { PlatformId } from '../../../constants'; import { CONFIG_GIT_URL_UNAVAILABLE } from '../../../constants/error-messages'; import { logger } from '../../../logger'; import * as hostRules from '../../../util/host-rules'; @@ -31,7 +30,7 @@ export function getRepoUrl( // Find options for current host and determine Git endpoint const opts = hostRules.find({ - hostType: PlatformId.Gitea, + hostType: 'gitea', url: endpoint, }); diff --git a/lib/modules/platform/github/index.ts b/lib/modules/platform/github/index.ts index 2d4f3d6460d6487c772f99ac5d76f1cae28b9fca..9e458272ffc3ef186b5fd15bdb9622fecd8e47cd 100644 --- a/lib/modules/platform/github/index.ts +++ b/lib/modules/platform/github/index.ts @@ -7,7 +7,6 @@ import JSON5 from 'json5'; import { DateTime } from 'luxon'; import semver from 'semver'; import { GlobalConfig } from '../../../config/global'; -import { PlatformId } from '../../../constants'; import { PLATFORM_INTEGRATION_UNAUTHORIZED, REPOSITORY_ACCESS_FORBIDDEN, @@ -90,7 +89,7 @@ export const GitHubMaxPrBodyLen = 60000; export function resetConfigs(): void { config = {} as never; platformConfig = { - hostType: PlatformId.Github, + hostType: 'github', endpoint: 'https://api.github.com/', }; } @@ -266,7 +265,7 @@ export async function initRepo({ githubHttp.setBaseUrl(endpoint); } const opts = hostRules.find({ - hostType: PlatformId.Github, + hostType: 'github', url: platformConfig.endpoint, }); config.renovateUsername = renovateUsername; @@ -1248,7 +1247,7 @@ async function getComments(issueNo: number): Promise<Comment[]> { } catch (err) /* istanbul ignore next */ { if (err.statusCode === 404) { logger.debug('404 response when retrieving comments'); - throw new ExternalHostError(err, PlatformId.Github); + throw new ExternalHostError(err, 'github'); } throw err; } diff --git a/lib/modules/platform/github/pr.ts b/lib/modules/platform/github/pr.ts index c3e9dd643e2cca80380bdc5fbec364c4e1f402a2..b876953447419d98e32201f7182818c82538e204 100644 --- a/lib/modules/platform/github/pr.ts +++ b/lib/modules/platform/github/pr.ts @@ -1,5 +1,4 @@ import is from '@sindresorhus/is'; -import { PlatformId } from '../../../constants'; import { logger } from '../../../logger'; import { ExternalHostError } from '../../../types/errors/external-host-error'; import { getCache } from '../../../util/cache/repository'; @@ -111,7 +110,7 @@ export async function getPrCache( ); } catch (err) /* istanbul ignore next */ { logger.debug({ err }, 'getPrList err'); - throw new ExternalHostError(err, PlatformId.Github); + throw new ExternalHostError(err, 'github'); } return prApiCache.getItems(); diff --git a/lib/modules/platform/gitlab/index.ts b/lib/modules/platform/gitlab/index.ts index 805b32f55531c9e861f0beef435a888b8c83c673..aa1c8af8a712d3774ff200cce9650977ce3ebf12 100644 --- a/lib/modules/platform/gitlab/index.ts +++ b/lib/modules/platform/gitlab/index.ts @@ -3,7 +3,6 @@ import is from '@sindresorhus/is'; import delay from 'delay'; import JSON5 from 'json5'; import semver from 'semver'; -import { PlatformId } from '../../../constants'; import { CONFIG_GIT_URL_UNAVAILABLE, PLATFORM_AUTHENTICATION_ERROR, @@ -75,7 +74,7 @@ let config: { } = {} as any; const defaults = { - hostType: PlatformId.Gitlab, + hostType: 'gitlab', endpoint: 'https://gitlab.com/api/v4/', version: '0.0.0', }; diff --git a/lib/modules/platform/index.spec.ts b/lib/modules/platform/index.spec.ts index 1f5963b03c5cb1ce3d724c0e5bfdf2e05e59bcff..b55d97c46cb7be03206c3724dbe9295ad2662d66 100644 --- a/lib/modules/platform/index.spec.ts +++ b/lib/modules/platform/index.spec.ts @@ -1,5 +1,5 @@ import * as httpMock from '../../../test/http-mock'; -import { PlatformId } from '../../constants'; +import type { PlatformId } from '../../constants'; import { PLATFORM_NOT_FOUND } from '../../constants/error-messages'; import { loadModules } from '../../util/modules'; import type { Platform } from './types'; @@ -42,7 +42,11 @@ describe('modules/platform/index', () => { }); it('throws if wrong platform', async () => { - const config = { platform: 'wrong', username: 'abc', password: '123' }; + const config = { + platform: 'wrong' as PlatformId, + username: 'abc', + password: '123', + }; await expect(platform.initPlatform(config)).rejects.toThrow(); }); @@ -53,7 +57,7 @@ describe('modules/platform/index', () => { .basicAuth({ user: 'abc', pass: '123' }) .reply(200, { uuid: 123 }); const config = { - platform: PlatformId.Bitbucket, + platform: 'bitbucket' as PlatformId, gitAuthor: 'user@domain.com', username: 'abc', password: '123', @@ -69,7 +73,7 @@ describe('modules/platform/index', () => { username: 'abc', }, ], - platform: PlatformId.Bitbucket, + platform: 'bitbucket', }); }); }); diff --git a/lib/util/check-token.ts b/lib/util/check-token.ts index 9fad02f977f2f294262bef782107dd573f87b695..f92a7b658b70f8efda6d8b9c7d0e338503415e36 100644 --- a/lib/util/check-token.ts +++ b/lib/util/check-token.ts @@ -1,5 +1,4 @@ import { GlobalConfig } from '../config/global'; -import { PlatformId } from '../constants'; import { logger } from '../logger'; import { GithubReleasesDatasource } from '../modules/datasource/github-releases'; import { GithubTagsDatasource } from '../modules/datasource/github-tags'; @@ -11,7 +10,7 @@ export function checkGithubToken( packageFiles: Record<string, PackageFile[]> | undefined ): void { const { token } = hostRules.find({ - hostType: PlatformId.Github, + hostType: 'github', url: 'https://api.github.com', }); diff --git a/lib/util/git/auth.spec.ts b/lib/util/git/auth.spec.ts index eae5ea34be991475e227c61ab2f427e0493ddce5..b26d72eaedbd52e3732ad9c51c156bc63a3e9178 100644 --- a/lib/util/git/auth.spec.ts +++ b/lib/util/git/auth.spec.ts @@ -1,4 +1,3 @@ -import { PlatformId } from '../../constants'; import { getGitAuthenticatedEnvironmentVariables } from './auth'; describe('util/git/auth', () => { @@ -11,7 +10,7 @@ describe('util/git/auth', () => { expect( getGitAuthenticatedEnvironmentVariables('https://github.com/', { token: 'token1234', - hostType: PlatformId.Github, + hostType: 'github', matchHost: 'github.com', }) ).toStrictEqual({ @@ -29,7 +28,7 @@ describe('util/git/auth', () => { expect( getGitAuthenticatedEnvironmentVariables('foobar://github.com/', { token: 'token1234', - hostType: PlatformId.Github, + hostType: 'github', matchHost: 'github.com', }) ).toStrictEqual({ @@ -47,7 +46,7 @@ describe('util/git/auth', () => { expect( getGitAuthenticatedEnvironmentVariables('https://github.com/', { token: 'x-access-token:token1234', - hostType: PlatformId.Github, + hostType: 'github', matchHost: 'github.com', }) ).toStrictEqual({ @@ -70,7 +69,7 @@ describe('util/git/auth', () => { 'https://github.com/', { token: 'token1234', - hostType: PlatformId.Github, + hostType: 'github', matchHost: 'github.com', }, { GIT_CONFIG_COUNT: '1' } @@ -93,7 +92,7 @@ describe('util/git/auth', () => { 'https://github.com/', { token: 'token1234', - hostType: PlatformId.Github, + hostType: 'github', matchHost: 'github.com', }, { GIT_CONFIG_COUNT: '1' } @@ -114,7 +113,7 @@ describe('util/git/auth', () => { expect( getGitAuthenticatedEnvironmentVariables('https://github.com/', { token: 'token1234', - hostType: PlatformId.Github, + hostType: 'github', matchHost: 'github.com', }) ).toStrictEqual({ @@ -134,7 +133,7 @@ describe('util/git/auth', () => { 'https://github.com/', { token: 'token1234', - hostType: PlatformId.Github, + hostType: 'github', matchHost: 'github.com', }, { RANDOM_VARIABLE: 'random' } @@ -156,7 +155,7 @@ describe('util/git/auth', () => { expect( getGitAuthenticatedEnvironmentVariables('https://github.com/', { token: 'token1234', - hostType: PlatformId.Github, + hostType: 'github', matchHost: 'github.com', }) ).toStrictEqual({ @@ -174,7 +173,7 @@ describe('util/git/auth', () => { expect( getGitAuthenticatedEnvironmentVariables('https://gitlab.com/', { token: 'token1234', - hostType: PlatformId.Gitlab, + hostType: 'gitlab', matchHost: 'github.com', }) ).toStrictEqual({ @@ -218,7 +217,7 @@ describe('util/git/auth', () => { { username: 'testing', password: '1234', - hostType: PlatformId.Gitlab, + hostType: 'gitlab', matchHost: 'github.com', }, { env: 'value' } @@ -232,7 +231,7 @@ describe('util/git/auth', () => { expect( getGitAuthenticatedEnvironmentVariables('http://github.com/', { token: 'token1234', - hostType: PlatformId.Github, + hostType: 'github', matchHost: 'github.com', }) ).toStrictEqual({ @@ -250,7 +249,7 @@ describe('util/git/auth', () => { expect( getGitAuthenticatedEnvironmentVariables('https://github.com/org', { token: 'token1234', - hostType: PlatformId.Github, + hostType: 'github', matchHost: 'github.com', }) ).toStrictEqual({ @@ -268,7 +267,7 @@ describe('util/git/auth', () => { expect( getGitAuthenticatedEnvironmentVariables('https://github.com/org/repo', { token: 'token1234', - hostType: PlatformId.Github, + hostType: 'github', matchHost: 'github.com', }) ).toStrictEqual({ @@ -290,7 +289,7 @@ describe('util/git/auth', () => { 'https://github.com:89/org/repo.git', { token: 'token1234', - hostType: PlatformId.Github, + hostType: 'github', matchHost: 'github.com', } ) diff --git a/lib/util/git/auth.ts b/lib/util/git/auth.ts index cbda1ba68e15b947d2cea3fddc01b2e3923808a9..31e6e639c7ee7baacfe5511f612ebe808d98f92b 100644 --- a/lib/util/git/auth.ts +++ b/lib/util/git/auth.ts @@ -1,4 +1,3 @@ -import { PlatformId } from '../../constants'; import { logger } from '../../logger'; import type { HostRule } from '../../types'; import { detectPlatform } from '../common'; @@ -75,7 +74,7 @@ function getAuthenticationRulesWithToken( if (!type) { type = detectPlatform(url); } - if (type === PlatformId.Gitlab) { + if (type === 'gitlab') { token = `gitlab-ci-token:${authToken}`; } return getAuthenticationRules(url, token); diff --git a/lib/util/host-rules.spec.ts b/lib/util/host-rules.spec.ts index c3991fdacda190e8f44cfd652f240f31a15a3214..6513bf9e50ac4ce67c94d3052a0201f1b1d6e382 100644 --- a/lib/util/host-rules.spec.ts +++ b/lib/util/host-rules.spec.ts @@ -1,4 +1,3 @@ -import { PlatformId } from '../constants'; import { NugetDatasource } from '../modules/datasource/nuget'; import type { HostRule } from '../types'; import { @@ -20,7 +19,7 @@ describe('util/host-rules', () => { it('throws if both domainName and hostName', () => { expect(() => add({ - hostType: PlatformId.Azure, + hostType: 'azure', domainName: 'github.com', hostName: 'api.github.com', } as HostRule) @@ -30,7 +29,7 @@ describe('util/host-rules', () => { it('throws if both domainName and baseUrl', () => { expect(() => add({ - hostType: PlatformId.Azure, + hostType: 'azure', domainName: 'github.com', matchHost: 'https://api.github.com', } as HostRule) @@ -40,7 +39,7 @@ describe('util/host-rules', () => { it('throws if both hostName and baseUrl', () => { expect(() => add({ - hostType: PlatformId.Azure, + hostType: 'azure', hostName: 'api.github.com', matchHost: 'https://api.github.com', } as HostRule) @@ -129,25 +128,25 @@ describe('util/host-rules', () => { it('matches on specific path', () => { // Initialized platform holst rule add({ - hostType: PlatformId.Github, + hostType: 'github', matchHost: 'https://api.github.com', token: 'abc', }); // specific host rule for using other token in different org add({ - hostType: PlatformId.Github, + hostType: 'github', matchHost: 'https://api.github.com/repos/org-b/', token: 'def', }); // Initialized generic host rule for github platform add({ - hostType: PlatformId.Github, + hostType: 'github', matchHost: 'https://api.github.com', token: 'abc', }); expect( find({ - hostType: PlatformId.Github, + hostType: 'github', url: 'https://api.github.com/repos/org-b/someRepo/tags?per_page=100', }).token ).toBe('def'); @@ -160,7 +159,7 @@ describe('util/host-rules', () => { }); expect( find({ - hostType: PlatformId.Github, + hostType: 'github', url: 'https://api.github.com/repos/org-b/someRepo/tags?per_page=100', }).token ).toBe('abc'); @@ -174,7 +173,7 @@ describe('util/host-rules', () => { it('matches if hostType is configured and host rule is filtered with datasource', () => { add({ - hostType: PlatformId.Github, + hostType: 'github', matchHost: 'https://api.github.com', token: 'abc', }); @@ -364,11 +363,11 @@ describe('util/host-rules', () => { describe('hostType()', () => { it('return hostType', () => { add({ - hostType: PlatformId.Github, + hostType: 'github', token: 'aaaaaa', }); add({ - hostType: PlatformId.Github, + hostType: 'github', matchHost: 'github.example.com', token: 'abc', }); @@ -386,11 +385,11 @@ describe('util/host-rules', () => { it('returns null', () => { add({ - hostType: PlatformId.Github, + hostType: 'github', token: 'aaaaaa', }); add({ - hostType: PlatformId.Github, + hostType: 'github', matchHost: 'github.example.com', token: 'abc', }); diff --git a/lib/util/http/auth.spec.ts b/lib/util/http/auth.spec.ts index 33fd3b1fd7d5c96be86de98533289cf394922727..fe49fa57fc2ade419eaee2b7dd62c3abb5fc7b35 100644 --- a/lib/util/http/auth.spec.ts +++ b/lib/util/http/auth.spec.ts @@ -1,6 +1,5 @@ import type { NormalizedOptions } from 'got'; import { partial } from '../../../test/util'; -import { PlatformId } from '../../constants'; import { applyAuthorization, removeAuthorization } from './auth'; import type { GotOptions } from './types'; @@ -29,7 +28,7 @@ describe('util/http/auth', () => { it('gitea password', () => { const opts: GotOptions = { headers: {}, - hostType: PlatformId.Gitea, + hostType: 'gitea', password: 'XXXX', }; @@ -50,7 +49,7 @@ describe('util/http/auth', () => { const opts: GotOptions = { headers: {}, token: 'XXXX', - hostType: PlatformId.Gitea, + hostType: 'gitea', }; applyAuthorization(opts); @@ -70,7 +69,7 @@ describe('util/http/auth', () => { const opts: GotOptions = { headers: {}, token: 'XXX', - hostType: PlatformId.Github, + hostType: 'github', }; applyAuthorization(opts); @@ -108,7 +107,7 @@ describe('util/http/auth', () => { headers: {}, // Personal Access Token is exactly 20 characters long token: '0123456789012345test', - hostType: PlatformId.Gitlab, + hostType: 'gitlab', }; applyAuthorization(opts); @@ -129,7 +128,7 @@ describe('util/http/auth', () => { headers: {}, token: 'a40bdd925a0c0b9c4cdd19d101c0df3b2bcd063ab7ad6706f03bcffcec01test', - hostType: PlatformId.Gitlab, + hostType: 'gitlab', }; applyAuthorization(opts); diff --git a/lib/util/http/auth.ts b/lib/util/http/auth.ts index e083970ca2646c8333ffd348b6b74c49ecefe23d..e4bb1c92919e31746bf3dce974d29a54aa389dcd 100644 --- a/lib/util/http/auth.ts +++ b/lib/util/http/auth.ts @@ -3,7 +3,6 @@ import type { Options } from 'got'; import { GITHUB_API_USING_HOST_TYPES, GITLAB_API_USING_HOST_TYPES, - PlatformId, } from '../../constants'; import type { GotOptions } from './types'; @@ -16,7 +15,7 @@ export function applyAuthorization(inOptions: GotOptions): GotOptions { options.headers ??= {}; if (options.token) { - if (options.hostType === PlatformId.Gitea) { + if (options.hostType === 'gitea') { options.headers.authorization = `token ${options.token}`; } else if ( options.hostType && diff --git a/lib/util/http/bitbucket-server.spec.ts b/lib/util/http/bitbucket-server.spec.ts index 68b5cefe55ae73e6b5f51f0abfd4d2831b2cf36f..56d331f72ce1bbc65ae18a889a33784569ba0660 100644 --- a/lib/util/http/bitbucket-server.spec.ts +++ b/lib/util/http/bitbucket-server.spec.ts @@ -1,5 +1,4 @@ import * as httpMock from '../../../test/http-mock'; -import { PlatformId } from '../../constants'; import * as hostRules from '../host-rules'; import { BitbucketServerHttp, setBaseUrl } from './bitbucket-server'; @@ -17,7 +16,7 @@ describe('util/http/bitbucket-server', () => { // clean up hostRules hostRules.clear(); hostRules.add({ - hostType: PlatformId.BitbucketServer, + hostType: 'bitbucket-server', matchHost: baseUrl, token: 'token', }); diff --git a/lib/util/http/bitbucket-server.ts b/lib/util/http/bitbucket-server.ts index 6f7fc0c2c338195f07646291f2768a0b9101335f..449754f4cecea7ec803b125e74a8dca0a342ecde 100644 --- a/lib/util/http/bitbucket-server.ts +++ b/lib/util/http/bitbucket-server.ts @@ -1,4 +1,3 @@ -import { PlatformId } from '../../constants'; import { resolveBaseUrl } from '../url'; import type { HttpOptions, HttpResponse, InternalHttpOptions } from './types'; import { Http } from '.'; @@ -10,7 +9,7 @@ export const setBaseUrl = (url: string): void => { export class BitbucketServerHttp extends Http { constructor(options?: HttpOptions) { - super(PlatformId.BitbucketServer, options); + super('bitbucket-server', options); } protected override request<T>( diff --git a/lib/util/http/bitbucket.spec.ts b/lib/util/http/bitbucket.spec.ts index a78b78bced8185ce274148d8ac547eb1e0672c3e..ac7bb06e010322a3268dc18ed5fc807f2dc5443e 100644 --- a/lib/util/http/bitbucket.spec.ts +++ b/lib/util/http/bitbucket.spec.ts @@ -1,5 +1,4 @@ import * as httpMock from '../../../test/http-mock'; -import { PlatformId } from '../../constants'; import * as hostRules from '../host-rules'; import { BitbucketHttp, setBaseUrl } from './bitbucket'; @@ -17,7 +16,7 @@ describe('util/http/bitbucket', () => { // clean up hostRules hostRules.clear(); hostRules.add({ - hostType: PlatformId.Bitbucket, + hostType: 'bitbucket', matchHost: baseUrl, token: 'token', }); diff --git a/lib/util/http/bitbucket.ts b/lib/util/http/bitbucket.ts index 4f168b0f08124231fb4e7cb6793c3666eabcd08a..628ef154cba1fed7270f17e9c4a4f5f0b62774a1 100644 --- a/lib/util/http/bitbucket.ts +++ b/lib/util/http/bitbucket.ts @@ -1,4 +1,3 @@ -import { PlatformId } from '../../constants'; import type { HttpOptions, HttpResponse, InternalHttpOptions } from './types'; import { Http } from '.'; @@ -9,7 +8,7 @@ export const setBaseUrl = (url: string): void => { }; export class BitbucketHttp extends Http { - constructor(type: string = PlatformId.Bitbucket, options?: HttpOptions) { + constructor(type = 'bitbucket', options?: HttpOptions) { super(type, options); } diff --git a/lib/util/http/gitea.ts b/lib/util/http/gitea.ts index 9dd49c211275e58aa9e6bfd846ca7866931e686d..394f3589e4b0c4962d4227f393b3362b547bf9f9 100644 --- a/lib/util/http/gitea.ts +++ b/lib/util/http/gitea.ts @@ -1,5 +1,4 @@ import is from '@sindresorhus/is'; -import { PlatformId } from '../../constants'; import { resolveBaseUrl } from '../url'; import type { HttpOptions, HttpResponse, InternalHttpOptions } from './types'; import { Http } from '.'; @@ -32,7 +31,7 @@ function resolveUrl(path: string, base: string): URL { export class GiteaHttp extends Http<GiteaHttpOptions> { constructor(options?: HttpOptions) { - super(PlatformId.Gitea, options); + super('gitea', options); } protected override async request<T>( diff --git a/lib/util/http/github.ts b/lib/util/http/github.ts index 0b2401bedee9b8a41090a8785f3372a3137d140a..b1a45bb2056d5c48ff1426845a63b836024f299d 100644 --- a/lib/util/http/github.ts +++ b/lib/util/http/github.ts @@ -1,6 +1,5 @@ import is from '@sindresorhus/is'; import { DateTime } from 'luxon'; -import { PlatformId } from '../../constants'; import { PLATFORM_BAD_CREDENTIALS, PLATFORM_INTEGRATION_UNAUTHORIZED, @@ -74,15 +73,15 @@ function handleGotError( err.code === 'ECONNRESET' ) { logger.debug({ err }, 'GitHub failure: RequestError'); - return new ExternalHostError(err, PlatformId.Github); + return new ExternalHostError(err, 'github'); } if (err.name === 'ParseError') { logger.debug({ err }, ''); - return new ExternalHostError(err, PlatformId.Github); + return new ExternalHostError(err, 'github'); } if (err.statusCode && err.statusCode >= 500 && err.statusCode < 600) { logger.debug({ err }, 'GitHub failure: 5xx'); - return new ExternalHostError(err, PlatformId.Github); + return new ExternalHostError(err, 'github'); } if ( err.statusCode === 403 && @@ -126,7 +125,7 @@ function handleGotError( 'GitHub failure: Bad credentials' ); if (rateLimit === '60') { - return new ExternalHostError(err, PlatformId.Github); + return new ExternalHostError(err, 'github'); } return new Error(PLATFORM_BAD_CREDENTIALS); } @@ -146,7 +145,7 @@ function handleGotError( return err; } logger.debug({ err }, '422 Error thrown from GitHub'); - return new ExternalHostError(err, PlatformId.Github); + return new ExternalHostError(err, 'github'); } if ( err.statusCode === 410 && @@ -261,10 +260,7 @@ function setGraphqlPageSize(fieldName: string, newPageSize: number): void { } export class GithubHttp extends Http<GithubHttpOptions> { - constructor( - hostType: string = PlatformId.Github, - options?: GithubHttpOptions - ) { + constructor(hostType = 'github', options?: GithubHttpOptions) { super(hostType, options); } diff --git a/lib/util/http/gitlab.spec.ts b/lib/util/http/gitlab.spec.ts index 1df2998cb1a05c71237e4cbf86dca4b02fa9fe82..38dbb79e45c3980ce9232f93a68488397ad8b057 100644 --- a/lib/util/http/gitlab.spec.ts +++ b/lib/util/http/gitlab.spec.ts @@ -1,12 +1,11 @@ import * as httpMock from '../../../test/http-mock'; -import { PlatformId } from '../../constants'; import { EXTERNAL_HOST_ERROR } from '../../constants/error-messages'; import { GitlabReleasesDatasource } from '../../modules/datasource/gitlab-releases'; import * as hostRules from '../host-rules'; import { GitlabHttp, setBaseUrl } from './gitlab'; hostRules.add({ - hostType: PlatformId.Gitlab, + hostType: 'gitlab', token: '123test', }); @@ -22,7 +21,7 @@ describe('util/http/gitlab', () => { delete process.env.GITLAB_IGNORE_REPO_URL; hostRules.add({ - hostType: PlatformId.Gitlab, + hostType: 'gitlab', token: 'abc123', }); }); @@ -72,7 +71,7 @@ describe('util/http/gitlab', () => { it('supports different datasources', async () => { const gitlabApiDatasource = new GitlabHttp(GitlabReleasesDatasource.id); - hostRules.add({ hostType: PlatformId.Gitlab, token: 'abc' }); + hostRules.add({ hostType: 'gitlab', token: 'abc' }); hostRules.add({ hostType: GitlabReleasesDatasource.id, token: 'def', diff --git a/lib/util/http/gitlab.ts b/lib/util/http/gitlab.ts index b345797bf82e74e3b926c9949df872710e7c0bf3..6a72c31cd8f7b623c7ec806123bbc65d9e1b8268 100644 --- a/lib/util/http/gitlab.ts +++ b/lib/util/http/gitlab.ts @@ -1,5 +1,4 @@ import is from '@sindresorhus/is'; -import { PlatformId } from '../../constants'; import { logger } from '../../logger'; import { ExternalHostError } from '../../types/errors/external-host-error'; import { parseLinkHeader, parseUrl } from '../url'; @@ -16,7 +15,7 @@ export interface GitlabHttpOptions extends HttpOptions { } export class GitlabHttp extends Http<GitlabHttpOptions> { - constructor(type: string = PlatformId.Gitlab, options?: GitlabHttpOptions) { + constructor(type = 'gitlab', options?: GitlabHttpOptions) { super(type, options); } @@ -67,7 +66,7 @@ export class GitlabHttp extends Http<GitlabHttpOptions> { err.statusCode === 429 || (err.statusCode >= 500 && err.statusCode < 600) ) { - throw new ExternalHostError(err, PlatformId.Gitlab); + throw new ExternalHostError(err, 'gitlab'); } const platformFailureCodes = [ 'EAI_AGAIN', @@ -76,10 +75,10 @@ export class GitlabHttp extends Http<GitlabHttpOptions> { 'UNABLE_TO_VERIFY_LEAF_SIGNATURE', ]; if (platformFailureCodes.includes(err.code)) { - throw new ExternalHostError(err, PlatformId.Gitlab); + throw new ExternalHostError(err, 'gitlab'); } if (err.name === 'ParseError') { - throw new ExternalHostError(err, PlatformId.Gitlab); + throw new ExternalHostError(err, 'gitlab'); } throw err; } diff --git a/lib/util/http/host-rules.spec.ts b/lib/util/http/host-rules.spec.ts index dc910cfac88ecb59a69343b40e38f3cfb0da8859..23a201c76fa61abb6015f114d86bff21df853511 100644 --- a/lib/util/http/host-rules.spec.ts +++ b/lib/util/http/host-rules.spec.ts @@ -1,4 +1,3 @@ -import { PlatformId } from '../../constants'; import { bootstrap } from '../../proxy'; import * as hostRules from '../host-rules'; import { dnsLookup } from './dns'; @@ -10,7 +9,7 @@ jest.mock('global-agent'); describe('util/http/host-rules', () => { const options = { - hostType: PlatformId.Github, + hostType: 'github', }; beforeEach(() => { @@ -22,11 +21,11 @@ describe('util/http/host-rules', () => { // clean up hostRules hostRules.clear(); hostRules.add({ - hostType: PlatformId.Github, + hostType: 'github', token: 'token', }); hostRules.add({ - hostType: PlatformId.Gitea, + hostType: 'gitea', password: 'password', }); @@ -38,12 +37,12 @@ describe('util/http/host-rules', () => { }); hostRules.add({ - hostType: PlatformId.Gitlab, + hostType: 'gitlab', token: 'abc', }); hostRules.add({ - hostType: PlatformId.Bitbucket, + hostType: 'bitbucket', token: 'cdef', }); }); @@ -65,8 +64,7 @@ describe('util/http/host-rules', () => { }); it('adds auth', () => { - expect(applyHostRules(url, { hostType: PlatformId.Gitea })) - .toMatchInlineSnapshot(` + expect(applyHostRules(url, { hostType: 'gitea' })).toMatchInlineSnapshot(` { "hostType": "gitea", "password": "password", diff --git a/lib/util/http/host-rules.ts b/lib/util/http/host-rules.ts index f52bc5d15de20336644303c386f54d9c64d4cfdb..e4ff0a0321a180e58cda5480a84140c12e02a349 100644 --- a/lib/util/http/host-rules.ts +++ b/lib/util/http/host-rules.ts @@ -3,7 +3,6 @@ import { BITBUCKET_API_USING_HOST_TYPES, GITHUB_API_USING_HOST_TYPES, GITLAB_API_USING_HOST_TYPES, - PlatformId, } from '../../constants'; import { logger } from '../../logger'; import { hasProxy } from '../../proxy'; @@ -26,11 +25,11 @@ export function findMatchingRules(options: GotOptions, url: string): HostRule { if ( hostType && GITHUB_API_USING_HOST_TYPES.includes(hostType) && - hostType !== PlatformId.Github + hostType !== 'github' ) { res = { ...hostRules.find({ - hostType: PlatformId.Github, + hostType: 'github', url, }), ...res, @@ -41,11 +40,11 @@ export function findMatchingRules(options: GotOptions, url: string): HostRule { if ( hostType && GITLAB_API_USING_HOST_TYPES.includes(hostType) && - hostType !== PlatformId.Gitlab + hostType !== 'gitlab' ) { res = { ...hostRules.find({ - hostType: PlatformId.Gitlab, + hostType: 'gitlab', url, }), ...res, @@ -56,11 +55,11 @@ export function findMatchingRules(options: GotOptions, url: string): HostRule { if ( hostType && BITBUCKET_API_USING_HOST_TYPES.includes(hostType) && - hostType !== PlatformId.Bitbucket + hostType !== 'bitbucket' ) { res = { ...hostRules.find({ - hostType: PlatformId.Bitbucket, + hostType: 'bitbucket', url, }), ...res, diff --git a/lib/workers/global/autodiscover.spec.ts b/lib/workers/global/autodiscover.spec.ts index a9e30c327b91ab39d30f347bd7ab35b14a9e74ad..71299efcdc83802cfe63cc2dd4ff1fdbd16797a8 100644 --- a/lib/workers/global/autodiscover.spec.ts +++ b/lib/workers/global/autodiscover.spec.ts @@ -1,5 +1,4 @@ import type { RenovateConfig } from '../../config/types'; -import { PlatformId } from '../../constants'; import * as platform from '../../modules/platform'; import * as _ghApi from '../../modules/platform/github'; import * as _hostRules from '../../util/host-rules'; @@ -19,7 +18,7 @@ describe('workers/global/autodiscover', () => { jest.resetAllMocks(); config = {}; await platform.initPlatform({ - platform: PlatformId.Github, + platform: 'github', token: '123test', endpoint: 'endpoint', }); @@ -31,7 +30,7 @@ describe('workers/global/autodiscover', () => { it('autodiscovers github but empty', async () => { config.autodiscover = true; - config.platform = PlatformId.Github; + config.platform = 'github'; hostRules.find = jest.fn(() => ({ token: 'abc', })); @@ -42,7 +41,7 @@ describe('workers/global/autodiscover', () => { it('autodiscovers github repos', async () => { config.autodiscover = true; - config.platform = PlatformId.Github; + config.platform = 'github'; hostRules.find = jest.fn(() => ({ token: 'abc', })); @@ -54,7 +53,7 @@ describe('workers/global/autodiscover', () => { it('filters autodiscovered github repos', async () => { config.autodiscover = true; config.autodiscoverFilter = ['project/re*']; - config.platform = PlatformId.Github; + config.platform = 'github'; hostRules.find = jest.fn(() => ({ token: 'abc', })); @@ -82,7 +81,7 @@ describe('workers/global/autodiscover', () => { it('filters autodiscovered github repos with regex', async () => { config.autodiscover = true; config.autodiscoverFilter = ['/project/re*./']; - config.platform = PlatformId.Github; + config.platform = 'github'; hostRules.find = jest.fn(() => ({ token: 'abc', })); @@ -96,7 +95,7 @@ describe('workers/global/autodiscover', () => { it('filters autodiscovered github repos with regex negation', async () => { config.autodiscover = true; config.autodiscoverFilter = ['!/project/re*./']; - config.platform = PlatformId.Github; + config.platform = 'github'; hostRules.find = jest.fn(() => ({ token: 'abc', })); @@ -110,7 +109,7 @@ describe('workers/global/autodiscover', () => { it('filters autodiscovered github repos with minimatch negation', async () => { config.autodiscover = true; config.autodiscoverFilter = '!project/re*'; - config.platform = PlatformId.Github; + config.platform = 'github'; hostRules.find = jest.fn(() => ({ token: 'abc', })); @@ -124,7 +123,7 @@ describe('workers/global/autodiscover', () => { it('fail if regex pattern is not valid', async () => { config.autodiscover = true; config.autodiscoverFilter = ['/project/re**./']; - config.platform = PlatformId.Github; + config.platform = 'github'; hostRules.find = jest.fn(() => ({ token: 'abc', })); diff --git a/lib/workers/global/config/parse/env.spec.ts b/lib/workers/global/config/parse/env.spec.ts index a803125498f71b2a3a8ab5d2d9173b0e31be7ddf..3dc48e238f08ff687fbbf28d5ce6d1707d098525 100644 --- a/lib/workers/global/config/parse/env.spec.ts +++ b/lib/workers/global/config/parse/env.spec.ts @@ -1,5 +1,4 @@ import type { RequiredConfig } from '../../../../config/types'; -import { PlatformId } from '../../../../constants'; import { logger } from '../../../../logger'; import * as env from './env'; import type { ParseConfigOptions } from './types'; @@ -162,7 +161,7 @@ describe('workers/global/config/parse/env', () => { it('supports GitLab token', () => { const envParam: NodeJS.ProcessEnv = { - RENOVATE_PLATFORM: PlatformId.Gitlab, + RENOVATE_PLATFORM: 'gitlab', RENOVATE_TOKEN: 'a gitlab.com token', }; expect(env.getConfig(envParam)).toMatchSnapshot({ @@ -173,7 +172,7 @@ describe('workers/global/config/parse/env', () => { it('supports GitLab custom endpoint', () => { const envParam: NodeJS.ProcessEnv = { - RENOVATE_PLATFORM: PlatformId.Gitlab, + RENOVATE_PLATFORM: 'gitlab', RENOVATE_TOKEN: 'a gitlab token', RENOVATE_ENDPOINT: 'a gitlab endpoint', }; @@ -199,7 +198,7 @@ describe('workers/global/config/parse/env', () => { it('supports Bitbucket token', () => { const envParam: NodeJS.ProcessEnv = { - RENOVATE_PLATFORM: PlatformId.Bitbucket, + RENOVATE_PLATFORM: 'bitbucket', RENOVATE_ENDPOINT: 'a bitbucket endpoint', RENOVATE_USERNAME: 'some-username', RENOVATE_PASSWORD: 'app-password', @@ -214,7 +213,7 @@ describe('workers/global/config/parse/env', () => { it('supports Bitbucket username/password', () => { const envParam: NodeJS.ProcessEnv = { - RENOVATE_PLATFORM: PlatformId.Bitbucket, + RENOVATE_PLATFORM: 'bitbucket', RENOVATE_ENDPOINT: 'a bitbucket endpoint', RENOVATE_USERNAME: 'some-username', RENOVATE_PASSWORD: 'app-password', diff --git a/lib/workers/global/config/parse/env.ts b/lib/workers/global/config/parse/env.ts index ca7e9201917d35f0089d3d870b50d4ed47257ab8..c92ccce10d3ea35204057c7047f16414d6b884b6 100644 --- a/lib/workers/global/config/parse/env.ts +++ b/lib/workers/global/config/parse/env.ts @@ -2,7 +2,6 @@ import is from '@sindresorhus/is'; import JSON5 from 'json5'; import { getOptions } from '../../../../config/options'; import type { AllConfig } from '../../../../config/types'; -import { PlatformId } from '../../../../constants'; import { logger } from '../../../../logger'; import { coersions } from './coersions'; import type { ParseConfigOptions } from './types'; @@ -136,7 +135,7 @@ export function getConfig(inputEnv: NodeJS.ProcessEnv): AllConfig { if (env.GITHUB_COM_TOKEN) { logger.debug(`Converting GITHUB_COM_TOKEN into a global host rule`); config.hostRules.push({ - hostType: PlatformId.Github, + hostType: 'github', matchHost: 'github.com', token: env.GITHUB_COM_TOKEN, }); diff --git a/lib/workers/global/index.spec.ts b/lib/workers/global/index.spec.ts index 2ac08c5256539f408bbd5f201e0aa015c397a8c1..73e072a1f834849f5aad928f726f2a70de95ca5a 100644 --- a/lib/workers/global/index.spec.ts +++ b/lib/workers/global/index.spec.ts @@ -3,7 +3,6 @@ import { ERROR, WARN } from 'bunyan'; import * as _fs from 'fs-extra'; import { logger, mocked } from '../../../test/util'; import * as _presets from '../../config/presets'; -import { PlatformId } from '../../constants'; import { CONFIG_PRESETS_INVALID } from '../../constants/error-messages'; import { DockerDatasource } from '../../modules/datasource/docker'; import * as _platform from '../../modules/platform'; @@ -152,7 +151,7 @@ describe('workers/global/index', () => { it('github', async () => { configParser.parseConfigs.mockResolvedValueOnce({ repositories: ['a'], - platform: PlatformId.Github, + platform: 'github', endpoint: 'https://github.com/', }); await globalWorker.start(); @@ -163,7 +162,7 @@ describe('workers/global/index', () => { it('gitlab', async () => { configParser.parseConfigs.mockResolvedValueOnce({ repositories: [{ repository: 'a' }], - platform: PlatformId.Gitlab, + platform: 'gitlab', endpoint: 'https://my.gitlab.com/', }); await globalWorker.start(); @@ -176,7 +175,7 @@ describe('workers/global/index', () => { it('successfully write file', async () => { configParser.parseConfigs.mockResolvedValueOnce({ repositories: ['myOrg/myRepo'], - platform: PlatformId.Github, + platform: 'github', endpoint: 'https://github.com/', writeDiscoveredRepos: '/tmp/renovate-output.json', }); diff --git a/lib/workers/repository/dependency-dashboard.spec.ts b/lib/workers/repository/dependency-dashboard.spec.ts index 66786f92e6e2e3c1d8ce580541028297022f403f..9dfd783828603a6bd69cfa2421bf99a185103495 100644 --- a/lib/workers/repository/dependency-dashboard.spec.ts +++ b/lib/workers/repository/dependency-dashboard.spec.ts @@ -9,7 +9,6 @@ import { platform, } from '../../../test/util'; import { GlobalConfig } from '../../config/global'; -import { PlatformId } from '../../constants'; import type { PackageDependency, PackageFile, @@ -35,7 +34,7 @@ beforeEach(() => { jest.clearAllMocks(); massageMdSpy.mockImplementation(massageMarkdown); config = getConfig(); - config.platform = PlatformId.Github; + config.platform = 'github'; config.errors = []; config.warnings = []; }); diff --git a/lib/workers/repository/finalise/prune.spec.ts b/lib/workers/repository/finalise/prune.spec.ts index e9330b05a8332cba568cb8821e294af196984407..1e00542a3062d72b16e67300721391340842efa9 100644 --- a/lib/workers/repository/finalise/prune.spec.ts +++ b/lib/workers/repository/finalise/prune.spec.ts @@ -5,7 +5,6 @@ import { platform, } from '../../../../test/util'; import { GlobalConfig } from '../../../config/global'; -import { PlatformId } from '../../../constants'; import * as cleanup from './prune'; jest.mock('../../../util/git'); @@ -15,7 +14,7 @@ let config: RenovateConfig; beforeEach(() => { jest.resetAllMocks(); config = getConfig(); - config.platform = PlatformId.Github; + config.platform = 'github'; config.errors = []; config.warnings = []; }); diff --git a/lib/workers/repository/update/pr/changelog/github.spec.ts b/lib/workers/repository/update/pr/changelog/github.spec.ts index 4751ef897f1b1296b85d87f1f730f6f1005f7b4b..97834fa0ec0c9bae3e823dfd1e4670eb28304dc8 100644 --- a/lib/workers/repository/update/pr/changelog/github.spec.ts +++ b/lib/workers/repository/update/pr/changelog/github.spec.ts @@ -1,6 +1,5 @@ import * as httpMock from '../../../../../../test/http-mock'; import { GlobalConfig } from '../../../../../config/global'; -import { PlatformId } from '../../../../../constants'; import * as semverVersioning from '../../../../../modules/versioning/semver'; import * as hostRules from '../../../../../util/host-rules'; import type { BranchUpgradeConfig } from '../../../../types'; @@ -42,7 +41,7 @@ describe('workers/repository/update/pr/changelog/github', () => { beforeEach(() => { hostRules.clear(); hostRules.add({ - hostType: PlatformId.Github, + hostType: 'github', matchHost: 'https://api.github.com/', token: 'abc', }); @@ -235,7 +234,7 @@ describe('workers/repository/update/pr/changelog/github', () => { it('supports github enterprise and github.com changelog', async () => { hostRules.add({ - hostType: PlatformId.Github, + hostType: 'github', token: 'super_secret', matchHost: 'https://github-enterprise.example.com/', }); @@ -273,7 +272,7 @@ describe('workers/repository/update/pr/changelog/github', () => { customChangelogUrl: replacementSourceUrl, }; hostRules.add({ - hostType: PlatformId.Github, + hostType: 'github', token: 'super_secret', matchHost: 'https://github-enterprise.example.com/', }); @@ -294,7 +293,7 @@ describe('workers/repository/update/pr/changelog/github', () => { it('supports github enterprise and github enterprise changelog', async () => { hostRules.add({ - hostType: PlatformId.Github, + hostType: 'github', matchHost: 'https://github-enterprise.example.com/', token: 'abc', }); @@ -336,7 +335,7 @@ describe('workers/repository/update/pr/changelog/github', () => { customChangelogUrl: replacementSourceUrl, }; hostRules.add({ - hostType: PlatformId.Github, + hostType: 'github', matchHost: 'https://github-enterprise.example.com/', token: 'abc', }); diff --git a/lib/workers/repository/update/pr/changelog/gitlab.spec.ts b/lib/workers/repository/update/pr/changelog/gitlab.spec.ts index c9196a53e65697dbad799ea0b74d3e8c84b41b0f..92108071fb819f5ba8cac4bd7b236b8e039d6f8a 100644 --- a/lib/workers/repository/update/pr/changelog/gitlab.spec.ts +++ b/lib/workers/repository/update/pr/changelog/gitlab.spec.ts @@ -1,5 +1,4 @@ import * as httpMock from '../../../../../../test/http-mock'; -import { PlatformId } from '../../../../../constants'; import * as semverVersioning from '../../../../../modules/versioning/semver'; import * as hostRules from '../../../../../util/host-rules'; import type { BranchUpgradeConfig } from '../../../../types'; @@ -41,7 +40,7 @@ describe('workers/repository/update/pr/changelog/gitlab', () => { beforeEach(() => { hostRules.clear(); hostRules.add({ - hostType: PlatformId.Gitlab, + hostType: 'gitlab', matchHost, token: 'abc', }); @@ -250,7 +249,7 @@ describe('workers/repository/update/pr/changelog/gitlab', () => { it('supports gitlab enterprise and gitlab enterprise changelog', async () => { hostRules.add({ - hostType: PlatformId.Gitlab, + hostType: 'gitlab', matchHost: 'https://gitlab-enterprise.example.com/', token: 'abc', }); @@ -284,7 +283,7 @@ describe('workers/repository/update/pr/changelog/gitlab', () => { it('supports self-hosted gitlab changelog', async () => { httpMock.scope('https://git.test.com').persist().get(/.*/).reply(200, []); hostRules.add({ - hostType: PlatformId.Gitlab, + hostType: 'gitlab', matchHost: 'https://git.test.com/', token: 'abc', }); @@ -292,7 +291,7 @@ describe('workers/repository/update/pr/changelog/gitlab', () => { expect( await getChangeLogJSON({ ...upgrade, - platform: PlatformId.Gitlab, + platform: 'gitlab', sourceUrl: 'https://git.test.com/meno/dropzone/', endpoint: 'https://git.test.com/api/v4/', }) @@ -323,13 +322,13 @@ describe('workers/repository/update/pr/changelog/gitlab', () => { 'https://git.test.com/replacement/sourceurl/'; const config = { ...upgrade, - platform: PlatformId.Gitlab, + platform: 'gitlab', endpoint: 'https://git.test.com/api/v4/', sourceUrl, customChangelogUrl: replacementSourceUrl, }; hostRules.add({ - hostType: PlatformId.Gitlab, + hostType: 'gitlab', matchHost: 'https://git.test.com/', token: 'abc', }); diff --git a/lib/workers/repository/update/pr/changelog/index.spec.ts b/lib/workers/repository/update/pr/changelog/index.spec.ts index 4560bdf9f6b0f1d92a0f51b5a1338fafcc89d571..b5f6a622702e4b7f74c1ef5afe8e37a8799414d2 100644 --- a/lib/workers/repository/update/pr/changelog/index.spec.ts +++ b/lib/workers/repository/update/pr/changelog/index.spec.ts @@ -1,7 +1,6 @@ import * as httpMock from '../../../../../../test/http-mock'; import { partial } from '../../../../../../test/util'; import { GlobalConfig } from '../../../../../config/global'; -import { PlatformId } from '../../../../../constants'; import * as semverVersioning from '../../../../../modules/versioning/semver'; import * as hostRules from '../../../../../util/host-rules'; import type { BranchConfig } from '../../../../types'; @@ -38,7 +37,7 @@ describe('workers/repository/update/pr/changelog/index', () => { jest.resetAllMocks(); hostRules.clear(); hostRules.add({ - hostType: PlatformId.Github, + hostType: 'github', matchHost: 'https://api.github.com/', token: 'abc', }); @@ -258,7 +257,7 @@ describe('workers/repository/update/pr/changelog/index', () => { it('supports github enterprise and github.com changelog', async () => { httpMock.scope(githubApiHost).persist().get(/.*/).reply(200, []); hostRules.add({ - hostType: PlatformId.Github, + hostType: 'github', token: 'super_secret', matchHost: 'https://github-enterprise.example.com/', }); @@ -294,7 +293,7 @@ describe('workers/repository/update/pr/changelog/index', () => { .get(/.*/) .reply(200, []); hostRules.add({ - hostType: PlatformId.Github, + hostType: 'github', matchHost: 'https://github-enterprise.example.com/', token: 'abc', }); @@ -332,7 +331,7 @@ describe('workers/repository/update/pr/changelog/index', () => { .get(/.*/) .reply(200, []); hostRules.add({ - hostType: PlatformId.Github, + hostType: 'github', matchHost: 'https://github-enterprise.example.com/', token: 'abc', }); diff --git a/lib/workers/repository/update/pr/changelog/source-github.ts b/lib/workers/repository/update/pr/changelog/source-github.ts index 03fcd6c013f7f60164a1d3da175d42f45112282b..de4cbf935b89d8dae23cc9d3a0d6a41e8cd2f213 100644 --- a/lib/workers/repository/update/pr/changelog/source-github.ts +++ b/lib/workers/repository/update/pr/changelog/source-github.ts @@ -1,7 +1,6 @@ // TODO #7154 import URL from 'url'; import { GlobalConfig } from '../../../../../config/global'; -import { PlatformId } from '../../../../../constants'; import { logger } from '../../../../../logger'; import type { Release } from '../../../../../modules/datasource/types'; import * as allVersioning from '../../../../../modules/versioning'; @@ -53,7 +52,7 @@ export async function getChangeLogJSON( ? 'https://api.github.com/' : sourceUrl; const { token } = hostRules.find({ - hostType: PlatformId.Github, + hostType: 'github', url, }); // istanbul ignore if