Skip to content
Snippets Groups Projects
Unverified Commit aff618fa authored by Rhys Arkins's avatar Rhys Arkins Committed by GitHub
Browse files

feat: dynamic platform list retrieval (#5394)

parent 0ec6617b
No related branches found
No related tags found
No related merge requests found
......@@ -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,
},
......
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(
', '
)}`
);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment