mirror of
https://github.com/langgenius/dify.git
synced 2026-04-05 19:02:41 +08:00
test(workflow): add unit tests for workflow components (#33741)
Co-authored-by: CodingOnStar <hanxujiang@dify.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -1,19 +1,21 @@
|
||||
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(parse(versionB), parse(versionA))
|
||||
return compare(parseVersion(versionB), parseVersion(versionA))
|
||||
})[0]
|
||||
}
|
||||
|
||||
export const compareVersion = (v1: string, v2: string) => {
|
||||
return compare(parse(v1), parse(v2))
|
||||
return compare(parseVersion(v1), parseVersion(v2))
|
||||
}
|
||||
|
||||
export const isEqualOrLaterThanVersion = (baseVersion: string, targetVersion: string) => {
|
||||
return greaterOrEqual(parse(baseVersion), parse(targetVersion))
|
||||
return greaterOrEqual(parseVersion(baseVersion), parseVersion(targetVersion))
|
||||
}
|
||||
|
||||
export const isEarlierThanVersion = (baseVersion: string, targetVersion: string) => {
|
||||
return lessThan(parse(baseVersion), parse(targetVersion))
|
||||
return lessThan(parseVersion(baseVersion), parseVersion(targetVersion))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user