diff --git a/lib/config/definitions.ts b/lib/config/definitions.ts index 313f3eaab30047f06ddbe6311dbe2402cf85005a..55c368b5bfddf11c0a3a050968a4d980ec938a8c 100644 --- a/lib/config/definitions.ts +++ b/lib/config/definitions.ts @@ -17,13 +17,8 @@ import { VERSION_SCHEME_SWIFT, } from '../constants/version-schemes'; import { getVersionSchemeList } from '../versioning'; -import { - PLATFORM_TYPE_AZURE, - PLATFORM_TYPE_BITBUCKET, - PLATFORM_TYPE_BITBUCKET_SERVER, - PLATFORM_TYPE_GITHUB, - PLATFORM_TYPE_GITLAB, -} from '../constants/platforms'; +import { PLATFORM_TYPE_GITHUB } from '../constants/platforms'; +import { platformList } from '../platform'; export interface RenovateOptionBase { admin?: boolean; @@ -463,13 +458,7 @@ const options: RenovateOptions[] = [ name: 'platform', description: 'Platform type of repository', type: 'string', - allowedValues: [ - PLATFORM_TYPE_AZURE, - PLATFORM_TYPE_BITBUCKET, - PLATFORM_TYPE_BITBUCKET_SERVER, - PLATFORM_TYPE_GITHUB, - PLATFORM_TYPE_GITLAB, - ], + allowedValues: platformList, default: PLATFORM_TYPE_GITHUB, admin: true, }, diff --git a/lib/platform/index.ts b/lib/platform/index.ts index c9d0715eace26174b7bcf6d252d9fe38dd3117b2..f13da5e1baeae235d5c23d6efff9478e55716a65 100644 --- a/lib/platform/index.ts +++ b/lib/platform/index.ts @@ -1,17 +1,20 @@ +import fs from 'fs'; import URL from 'url'; import addrs from 'email-addresses'; import * as hostRules from '../util/host-rules'; import { logger } from '../logger'; import { Platform } from './common'; import { RenovateConfig } from '../config/common'; -import { getOptions } from '../config/definitions'; import { PLATFORM_NOT_FOUND } from '../constants/error-messages'; export * from './common'; -const supportedPlatforms = getOptions().find( - option => option.name === 'platform' -).allowedValues; +export const platformList = fs + .readdirSync(__dirname, { withFileTypes: true }) + .filter(dirent => dirent.isDirectory()) + .map(dirent => dirent.name) + .filter(name => name !== 'git' && name !== 'utils') // TODO: should be cleaner + .sort(); let _platform: Platform; @@ -28,9 +31,9 @@ const handler: ProxyHandler<Platform> = { export const platform = new Proxy<Platform>({} as any, handler); export async function setPlatformApi(name: string): Promise<void> { - if (!supportedPlatforms.includes(name)) + if (!platformList.includes(name)) throw new Error( - `Init: Platform "${name}" not found. Must be one of: ${supportedPlatforms.join( + `Init: Platform "${name}" not found. Must be one of: ${platformList.join( ', ' )}` );