2020-05-01 16:03:48 +00:00
|
|
|
import { Range, SemVer } from 'semver';
|
2020-02-07 18:25:27 +00:00
|
|
|
import { RangeStrategy as _RangeStrategy } from '../types';
|
2019-07-22 11:12:40 +00:00
|
|
|
|
2020-02-07 18:25:27 +00:00
|
|
|
/**
|
|
|
|
* @deprecated import from `lib/types`
|
|
|
|
*/
|
|
|
|
export type RangeStrategy = _RangeStrategy;
|
2019-07-22 11:12:40 +00:00
|
|
|
|
2020-01-16 12:43:58 +00:00
|
|
|
export interface NewValueConfig {
|
|
|
|
currentValue: string;
|
|
|
|
rangeStrategy: RangeStrategy;
|
|
|
|
fromVersion?: string;
|
|
|
|
toVersion: string;
|
|
|
|
}
|
2019-07-22 11:12:40 +00:00
|
|
|
export interface VersioningApi {
|
|
|
|
// validation
|
|
|
|
isCompatible(version: string, range?: string): string | boolean | null;
|
|
|
|
isSingleVersion(version: string): string | boolean | null;
|
|
|
|
isStable(version: string): boolean;
|
|
|
|
isValid(version: string): string | boolean | null;
|
|
|
|
isVersion(version: string): string | boolean | null;
|
|
|
|
|
|
|
|
// digestion of version
|
|
|
|
getMajor(version: string | SemVer): null | number;
|
|
|
|
getMinor(version: string | SemVer): null | number;
|
|
|
|
getPatch(version: string | SemVer): null | number;
|
|
|
|
|
|
|
|
// comparison
|
|
|
|
equals(version: string, other: string): boolean;
|
|
|
|
isGreaterThan(version: string, other: string): boolean;
|
|
|
|
isLessThanRange?(version: string, range: string): boolean;
|
|
|
|
maxSatisfyingVersion(versions: string[], range: string): string | null;
|
|
|
|
minSatisfyingVersion(versions: string[], range: string): string | null;
|
2020-01-16 12:43:58 +00:00
|
|
|
getNewValue(newValueConfig: NewValueConfig): string;
|
2019-07-22 11:12:40 +00:00
|
|
|
sortVersions(version: string, other: string): number;
|
|
|
|
|
|
|
|
matches(version: string, range: string | Range): boolean;
|
|
|
|
|
|
|
|
valueToVersion?(version: string): string;
|
|
|
|
}
|
2019-08-15 07:51:16 +00:00
|
|
|
|
|
|
|
export interface VersioningApiConstructor {
|
|
|
|
new (config?: string): VersioningApi;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function isVersioningApiConstructor(
|
|
|
|
obj: VersioningApi | VersioningApiConstructor
|
|
|
|
): obj is VersioningApiConstructor {
|
|
|
|
return typeof obj === 'function';
|
|
|
|
}
|