0
0
mirror of https://github.com/renovatebot/renovate.git synced 2024-12-22 21:48:32 +00:00
renovatebot_renovate/lib/modules/versioning/redhat/index.ts
2024-08-19 13:15:27 +00:00

42 lines
1.3 KiB
TypeScript

import { regEx } from '../../../util/regex';
import type { GenericVersion } from '../generic';
import { GenericVersioningApi } from '../generic';
import type { VersioningApi } from '../types';
export const id = 'redhat';
export const displayName = 'Red Hat';
export const urls = [];
export const supportsRanges = false;
const pattern = regEx(
/^(?<major>\d+)(?:\.(?<minor>\d+))?(?:\.(?<patch>\d+))?(?:-(?<releaseMajor>\d+)(?:\.(?<releaseMinor>\d+))?)?$/,
);
class RedhatVersioningApi extends GenericVersioningApi {
protected _parse(version: string): GenericVersion | null {
const matches = pattern.exec(version)?.groups;
if (!matches) {
return null;
}
const { major, minor, patch, releaseMajor, releaseMinor } = matches;
const release = [
Number.parseInt(major, 10),
typeof minor === 'undefined' ? 0 : Number.parseInt(minor, 10),
typeof patch === 'undefined' ? 0 : Number.parseInt(patch, 10),
typeof releaseMajor === 'undefined'
? 0
: Number.parseInt(releaseMajor, 10),
typeof releaseMinor === 'undefined'
? 0
: Number.parseInt(releaseMinor, 10),
];
return { release, prerelease: '' };
}
}
export const api: VersioningApi = new RedhatVersioningApi();
export default api;