From c56588eaba967cd6b4ba103b8b30c0dc52b3addf Mon Sep 17 00:00:00 2001 From: RahulGautamSingh <rahultesnik@gmail.com> Date: Tue, 1 Nov 2022 20:16:09 +0530 Subject: [PATCH] refactor: convert PlatformmId to union (#18458) --- lib/config/migration.spec.ts | 3 +- lib/config/options/index.ts | 3 +- lib/config/presets/local/index.ts | 16 +++++----- lib/config/types.ts | 5 ++-- lib/constants/platform.spec.ts | 13 ++++----- lib/constants/platforms.ts | 26 +++++++---------- lib/modules/datasource/go/base.spec.ts | 11 ++++--- lib/modules/datasource/go/base.ts | 3 +- .../manager/composer/artifacts.spec.ts | 5 ++-- lib/modules/manager/composer/artifacts.ts | 29 +++++++++---------- lib/modules/manager/gomod/artifacts.spec.ts | 23 +++++++-------- lib/modules/manager/gomod/artifacts.ts | 16 +++++----- lib/modules/manager/pre-commit/extract.ts | 7 ++--- .../platform/azure/azure-got-wrapper.spec.ts | 7 ++--- .../platform/azure/azure-got-wrapper.ts | 3 +- lib/modules/platform/azure/index.ts | 3 +- .../platform/bitbucket-server/index.ts | 3 +- lib/modules/platform/bitbucket/index.ts | 3 +- lib/modules/platform/gitea/index.spec.ts | 5 ++-- lib/modules/platform/gitea/index.ts | 3 +- lib/modules/platform/gitea/utils.ts | 3 +- lib/modules/platform/github/index.ts | 7 ++--- lib/modules/platform/github/pr.ts | 3 +- lib/modules/platform/gitlab/index.ts | 3 +- lib/modules/platform/index.spec.ts | 12 +++++--- lib/util/check-token.ts | 3 +- lib/util/git/auth.spec.ts | 29 +++++++++---------- lib/util/git/auth.ts | 3 +- lib/util/host-rules.spec.ts | 27 +++++++++-------- lib/util/http/auth.spec.ts | 11 ++++--- lib/util/http/auth.ts | 3 +- lib/util/http/bitbucket-server.spec.ts | 3 +- lib/util/http/bitbucket-server.ts | 3 +- lib/util/http/bitbucket.spec.ts | 3 +- lib/util/http/bitbucket.ts | 3 +- lib/util/http/gitea.ts | 3 +- lib/util/http/github.ts | 16 ++++------ lib/util/http/gitlab.spec.ts | 7 ++--- lib/util/http/gitlab.ts | 9 +++--- lib/util/http/host-rules.spec.ts | 14 ++++----- lib/util/http/host-rules.ts | 13 ++++----- lib/workers/global/autodiscover.spec.ts | 17 +++++------ lib/workers/global/config/parse/env.spec.ts | 9 +++--- lib/workers/global/config/parse/env.ts | 3 +- lib/workers/global/index.spec.ts | 7 ++--- .../repository/dependency-dashboard.spec.ts | 3 +- lib/workers/repository/finalise/prune.spec.ts | 3 +- .../update/pr/changelog/github.spec.ts | 11 ++++--- .../update/pr/changelog/gitlab.spec.ts | 13 ++++----- .../update/pr/changelog/index.spec.ts | 9 +++--- .../update/pr/changelog/source-github.ts | 3 +- 51 files changed, 192 insertions(+), 251 deletions(-) diff --git a/lib/config/migration.spec.ts b/lib/config/migration.spec.ts index d518c7f771..8fcdcf039b 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 7661889105..ce16fd8594 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 81a4b97694..2c30b6b58e 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 3da7735283..7603028afe 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 da86c73215..b663bd5db7 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 af2d3c8ec4..dfd4d3e4b3 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 66d771ed00..7c1b6c0f7a 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 43e241e507..c7e11c8985 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 9647b4bac5..e4734a4e57 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 6ce79441de..9eab2b1cbf 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 96ffd899c0..57a780defa 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 c1c42721f7..6d2998f0aa 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 cd84dd4392..5ad6a74fac 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 d73b55a270..6b8498e378 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 408ef5d365..67c2ab51b6 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 691cebb477..1418d0403a 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 ca2246419b..9ae76d64d8 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 6d63ecf1a2..b23bf70089 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 b90c0880d9..84d6b69073 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 3b49895a7e..96d9c92ebd 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 3b0ee18cc2..1f589ee5dd 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 2d4f3d6460..9e458272ff 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 c3e9dd643e..b876953447 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 805b32f555..aa1c8af8a7 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 1f5963b03c..b55d97c46c 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 9fad02f977..f92a7b658b 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 eae5ea34be..b26d72eaed 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 cbda1ba68e..31e6e639c7 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 c3991fdacd..6513bf9e50 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 33fd3b1fd7..fe49fa57fc 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 e083970ca2..e4bb1c9291 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 68b5cefe55..56d331f72c 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 6f7fc0c2c3..449754f4ce 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 a78b78bced..ac7bb06e01 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 4f168b0f08..628ef154cb 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 9dd49c2112..394f3589e4 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 0b2401bede..b1a45bb205 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 1df2998cb1..38dbb79e45 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 b345797bf8..6a72c31cd8 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 dc910cfac8..23a201c76f 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 f52bc5d15d..e4ff0a0321 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 a9e30c327b..71299efcdc 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 a803125498..3dc48e238f 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 ca7e920191..c92ccce10d 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 2ac08c5256..73e072a1f8 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 66786f92e6..9dfd783828 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 e9330b05a8..1e00542a30 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 4751ef897f..97834fa0ec 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 c9196a53e6..92108071fb 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 4560bdf9f6..b5f6a62270 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 03fcd6c013..de4cbf935b 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 -- GitLab