2024-01-01 21:11:32 +00:00
|
|
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
2024-04-10 02:43:44 +00:00
|
|
|
// This module is browser compatible.
|
2023-06-12 03:47:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The possible release types are used as an operator for the
|
|
|
|
* increment function and as a result of the difference function.
|
|
|
|
*/
|
|
|
|
export type ReleaseType =
|
|
|
|
| "pre"
|
|
|
|
| "major"
|
|
|
|
| "premajor"
|
|
|
|
| "minor"
|
|
|
|
| "preminor"
|
|
|
|
| "patch"
|
|
|
|
| "prepatch"
|
|
|
|
| "prerelease";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* SemVer comparison operators.
|
|
|
|
*/
|
2024-05-27 10:03:20 +00:00
|
|
|
export type Operator =
|
|
|
|
| undefined
|
|
|
|
| "="
|
|
|
|
| "!="
|
|
|
|
| ">"
|
|
|
|
| ">="
|
|
|
|
| "<"
|
|
|
|
| "<=";
|
2023-06-12 03:47:03 +00:00
|
|
|
|
|
|
|
/**
|
2024-07-31 06:54:59 +00:00
|
|
|
* The shape of a valid SemVer comparator.
|
|
|
|
*
|
|
|
|
* @example Usage
|
|
|
|
* ```ts
|
|
|
|
* import type { Comparator } from "@std/semver/types";
|
|
|
|
*
|
|
|
|
* const comparator: Comparator = {
|
|
|
|
* operator: ">",
|
|
|
|
* major: 1,
|
|
|
|
* minor: 2,
|
|
|
|
* patch: 3,
|
|
|
|
* }
|
|
|
|
* ```
|
2023-06-12 03:47:03 +00:00
|
|
|
*/
|
2024-01-14 21:19:00 +00:00
|
|
|
export interface Comparator extends SemVer {
|
2024-05-27 10:03:20 +00:00
|
|
|
/** The operator */
|
2024-02-18 06:43:09 +00:00
|
|
|
operator?: Operator;
|
2023-12-18 18:10:52 +00:00
|
|
|
}
|
2023-06-12 03:47:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A SemVer object parsed into its constituent parts.
|
|
|
|
*/
|
|
|
|
export interface SemVer {
|
2024-05-27 10:03:20 +00:00
|
|
|
/** The major version */
|
2023-06-12 03:47:03 +00:00
|
|
|
major: number;
|
2024-05-27 10:03:20 +00:00
|
|
|
/** The minor version */
|
2023-06-12 03:47:03 +00:00
|
|
|
minor: number;
|
2024-05-27 10:03:20 +00:00
|
|
|
/** The patch version */
|
2023-06-12 03:47:03 +00:00
|
|
|
patch: number;
|
2024-07-11 09:21:37 +00:00
|
|
|
/**
|
|
|
|
* The prerelease version
|
|
|
|
*
|
|
|
|
* @default {[]}
|
|
|
|
*/
|
2023-12-28 10:00:18 +00:00
|
|
|
prerelease?: (string | number)[];
|
2024-07-11 09:21:37 +00:00
|
|
|
/**
|
|
|
|
* The build metadata
|
|
|
|
*
|
|
|
|
* @default {[]}
|
|
|
|
*/
|
2023-12-28 10:00:18 +00:00
|
|
|
build?: string[];
|
2023-06-12 03:47:03 +00:00
|
|
|
}
|
|
|
|
|
2024-01-14 21:19:00 +00:00
|
|
|
/**
|
|
|
|
* A type representing a semantic version range. The ranges consist of
|
|
|
|
* a nested array, which represents a set of OR comparisons while the
|
|
|
|
* inner array represents AND comparisons.
|
|
|
|
*/
|
|
|
|
export type Range = Comparator[][];
|