mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-11 22:46:27 +00:00
feat: dynamic versionScheme import (#5393)
This commit is contained in:
parent
987e0a2bfd
commit
0ec6617b6d
2 changed files with 21 additions and 30 deletions
|
@ -7,18 +7,16 @@ import {
|
|||
VERSION_SCHEME_HEX,
|
||||
VERSION_SCHEME_HASHICORP,
|
||||
VERSION_SCHEME_IVY,
|
||||
VERSION_SCHEME_LOOSE,
|
||||
VERSION_SCHEME_MAVEN,
|
||||
VERSION_SCHEME_NODE,
|
||||
VERSION_SCHEME_NPM,
|
||||
VERSION_SCHEME_NUGET,
|
||||
VERSION_SCHEME_PEP440,
|
||||
VERSION_SCHEME_POETRY,
|
||||
VERSION_SCHEME_REGEX,
|
||||
VERSION_SCHEME_RUBY,
|
||||
VERSION_SCHEME_SEMVER,
|
||||
VERSION_SCHEME_SWIFT,
|
||||
} from '../constants/version-schemes';
|
||||
import { getVersionSchemeList } from '../versioning';
|
||||
import {
|
||||
PLATFORM_TYPE_AZURE,
|
||||
PLATFORM_TYPE_BITBUCKET,
|
||||
|
@ -659,26 +657,7 @@ const options: RenovateOptions[] = [
|
|||
name: 'versionScheme',
|
||||
description: 'Version scheme to use for filtering and comparisons',
|
||||
type: 'string',
|
||||
allowedValues: [
|
||||
VERSION_SCHEME_CARGO,
|
||||
VERSION_SCHEME_COMPOSER,
|
||||
VERSION_SCHEME_DOCKER,
|
||||
VERSION_SCHEME_GIT,
|
||||
VERSION_SCHEME_HASHICORP,
|
||||
VERSION_SCHEME_HEX,
|
||||
VERSION_SCHEME_IVY,
|
||||
VERSION_SCHEME_LOOSE,
|
||||
VERSION_SCHEME_MAVEN,
|
||||
VERSION_SCHEME_NODE,
|
||||
VERSION_SCHEME_NPM,
|
||||
VERSION_SCHEME_NUGET,
|
||||
VERSION_SCHEME_PEP440,
|
||||
VERSION_SCHEME_POETRY,
|
||||
VERSION_SCHEME_REGEX,
|
||||
VERSION_SCHEME_RUBY,
|
||||
VERSION_SCHEME_SEMVER,
|
||||
VERSION_SCHEME_SWIFT,
|
||||
],
|
||||
allowedValues: getVersionSchemeList(),
|
||||
default: VERSION_SCHEME_SEMVER,
|
||||
cli: false,
|
||||
env: false,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import fs from 'fs';
|
||||
import { logger } from '../logger';
|
||||
import { getOptions } from '../config/definitions';
|
||||
import {
|
||||
VersioningApi,
|
||||
VersioningApiConstructor,
|
||||
|
@ -8,14 +8,26 @@ import {
|
|||
|
||||
export * from './common';
|
||||
|
||||
const supportedSchemes = getOptions().find(
|
||||
option => option.name === 'versionScheme'
|
||||
).allowedValues;
|
||||
|
||||
const schemes: Record<string, VersioningApi | VersioningApiConstructor> = {};
|
||||
|
||||
for (const scheme of supportedSchemes) {
|
||||
schemes[scheme] = require('./' + scheme).api; // eslint-disable-line
|
||||
const versionSchemeList: string[] = [];
|
||||
|
||||
export const getVersionSchemeList = (): string[] => versionSchemeList;
|
||||
|
||||
const versionSchemes = fs
|
||||
.readdirSync(__dirname, { withFileTypes: true })
|
||||
.filter(dirent => dirent.isDirectory())
|
||||
.map(dirent => dirent.name)
|
||||
.sort();
|
||||
|
||||
for (const scheme of versionSchemes) {
|
||||
try {
|
||||
schemes[scheme] = require('./' + scheme).api; // eslint-disable-line
|
||||
versionSchemeList.push(scheme);
|
||||
} catch (err) /* istanbul ignore next */ {
|
||||
logger.fatal({ err }, `Can not load version scheme "${scheme}".`);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
export function get(versionScheme: string): VersioningApi {
|
||||
|
|
Loading…
Reference in a new issue