diff --git a/lib/modules/versioning/types.ts b/lib/modules/versioning/types.ts index 608d08e71031e71f41c0409630cec98bbdde9d17..362a6bd0d0d78e335fa0ce89784a0b4b5d319dc0 100644 --- a/lib/modules/versioning/types.ts +++ b/lib/modules/versioning/types.ts @@ -10,26 +10,90 @@ export interface NewValueConfig { } export interface VersioningApi { // validation + + /** + * Check whether the `version` is compatible with the `current` value + * constraint. + */ isCompatible(version: string, current?: string): boolean; + + /** + * Check whether the `version` constraint is not a range, i.e. it only allows a + * single specific version. + */ isSingleVersion(version: string): boolean; + + /** + * Check whether the `version` is considered to be "stable". + * + * Example: in SemVer the version must not have a pre-release marker. + */ isStable(version: string): boolean; + + /** + * Check whether the `input` is a valid version or a valid version range constraint. + */ isValid(input: string): boolean; + + /** + * Check whether the `input` is a valid version string. + */ isVersion(input: string | undefined | null): boolean; // digestion of version + getMajor(version: string | SemVer): null | number; getMinor(version: string | SemVer): null | number; getPatch(version: string | SemVer): null | number; // comparison + + /** + * Check whether `version` and `other` are logically equivalent, even if + * they're not the exact same string. + * + * For example, with Semver the build metadata should be ignored when comparing. + */ equals(version: string, other: string): boolean; + + /** + * Check whether `version` is "greater" than the `other` version. + */ isGreaterThan(version: string, other: string): boolean; + + /** + * Check whether the `version` is "less" than all the versions possible in + * the `range`. + */ isLessThanRange?(version: string, range: string): boolean; + + /** + * Select the highest version from `versions` that is within the given + * `range` constraint, or return `null` if there is no matching version. + */ getSatisfyingVersion(versions: string[], range: string): string | null; + + /** + * Select the lowest version from `versions` that is within the given + * `range` constraint, or return `null` if there is no matching version. + */ minSatisfyingVersion(versions: string[], range: string): string | null; + + /** + * Calculate a new version constraint based on the current constraint, the + * `rangeStrategy` option, and the current and new version. + */ getNewValue(newValueConfig: NewValueConfig): string | null; + + /** + * Compare two versions. Return `0` if `v1 == v2`, or `1` if `v1` is + * greater, or `-1` if `v2` is greater. + */ sortVersions(version: string, other: string): number; + /** + * Check whether the `version` satisfies the `range` constraint. + */ matches(version: string, range: string | Range): boolean; valueToVersion?(version: string): string;