mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-15 17:16:25 +00:00
53 lines
1.2 KiB
TypeScript
53 lines
1.2 KiB
TypeScript
import semver from 'semver';
|
|
import stable from 'semver-stable';
|
|
import { NewValueConfig, VersioningApi } from '../common';
|
|
|
|
export const id = 'semver';
|
|
export const displayName = 'Semantic';
|
|
export const urls = ['https://semver.org/'];
|
|
export const supportsRanges = false;
|
|
|
|
const { is: isStable } = stable;
|
|
|
|
const {
|
|
compare: sortVersions,
|
|
maxSatisfying: maxSatisfyingVersion,
|
|
minSatisfying: minSatisfyingVersion,
|
|
major: getMajor,
|
|
minor: getMinor,
|
|
patch: getPatch,
|
|
satisfies: matches,
|
|
valid,
|
|
ltr: isLessThanRange,
|
|
gt: isGreaterThan,
|
|
eq: equals,
|
|
} = semver;
|
|
|
|
// If this is left as an alias, inputs like "17.04.0" throw errors
|
|
export const isVersion = (input: string): string => valid(input);
|
|
|
|
export { isVersion as isValid, maxSatisfyingVersion };
|
|
|
|
function getNewValue({ toVersion }: NewValueConfig): string {
|
|
return toVersion;
|
|
}
|
|
|
|
export const api: VersioningApi = {
|
|
equals,
|
|
getMajor,
|
|
getMinor,
|
|
getPatch,
|
|
isCompatible: isVersion,
|
|
isGreaterThan,
|
|
isLessThanRange,
|
|
isSingleVersion: isVersion,
|
|
isStable,
|
|
isValid: isVersion,
|
|
isVersion,
|
|
matches,
|
|
maxSatisfyingVersion,
|
|
minSatisfyingVersion,
|
|
getNewValue,
|
|
sortVersions,
|
|
};
|
|
export default api;
|