mirror of
https://github.com/langgenius/dify.git
synced 2026-03-21 14:28:26 +08:00
Co-authored-by: CodingOnStar <hanxujiang@dify.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
22 lines
777 B
TypeScript
22 lines
777 B
TypeScript
import { compare, greaterOrEqual, lessThan, parse } from 'std-semver'
|
|
|
|
const parseVersion = (version: string) => parse(version)
|
|
|
|
export const getLatestVersion = (versionList: string[]) => {
|
|
return [...versionList].sort((versionA, versionB) => {
|
|
return compare(parseVersion(versionB), parseVersion(versionA))
|
|
})[0]
|
|
}
|
|
|
|
export const compareVersion = (v1: string, v2: string) => {
|
|
return compare(parseVersion(v1), parseVersion(v2))
|
|
}
|
|
|
|
export const isEqualOrLaterThanVersion = (baseVersion: string, targetVersion: string) => {
|
|
return greaterOrEqual(parseVersion(baseVersion), parseVersion(targetVersion))
|
|
}
|
|
|
|
export const isEarlierThanVersion = (baseVersion: string, targetVersion: string) => {
|
|
return lessThan(parseVersion(baseVersion), parseVersion(targetVersion))
|
|
}
|