0
0
Fork 0
mirror of https://github.com/renovatebot/renovate.git synced 2025-05-12 23:51:55 +00:00
renovatebot_renovate/lib/modules/versioning/index.ts
renovate[bot] f2f8f84bd6
chore(deps): update linters to v8.22.0 (#33880)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: secustor <sebastian@poxhofer.at>
2025-02-04 22:05:57 +00:00

33 lines
956 B
TypeScript

import versionings from './api';
import { Versioning } from './schema';
import * as semverCoerced from './semver-coerced';
import type { VersioningApi, VersioningApiConstructor } from './types';
export * from './types';
export const defaultVersioning = semverCoerced;
export const getVersioningList = (): string[] => Array.from(versionings.keys());
/**
* Get versioning map. Can be used to dynamically add new versioning type
*/
export const getVersionings = (): Map<
string,
VersioningApi | VersioningApiConstructor
> => versionings;
export function get(versioning: string | null | undefined): VersioningApi {
const res = Versioning.safeParse(versioning ?? defaultVersioning.id);
if (!res.success) {
const [issue] = res.error.issues;
if (issue && issue.code === 'custom' && issue.params?.error) {
throw issue.params.error;
}
// istanbul ignore next: should never happen
throw res.error;
}
return res.data;
}