mirror of
https://github.com/langgenius/dify.git
synced 2026-05-03 00:48:04 +08:00
refactor: move to std-semver (#33682)
This commit is contained in:
@ -104,20 +104,6 @@ vi.mock('../../install-plugin/install-from-github', () => ({
|
||||
),
|
||||
}))
|
||||
|
||||
// Mock semver
|
||||
vi.mock('semver', () => ({
|
||||
lt: (v1: string, v2: string) => {
|
||||
const parseVersion = (v: string) => v.split('.').map(Number)
|
||||
const [major1, minor1, patch1] = parseVersion(v1)
|
||||
const [major2, minor2, patch2] = parseVersion(v2)
|
||||
if (major1 !== major2)
|
||||
return major1 < major2
|
||||
if (minor1 !== minor2)
|
||||
return minor1 < minor2
|
||||
return patch1 < patch2
|
||||
},
|
||||
}))
|
||||
|
||||
// ================================
|
||||
// Test Data Factories
|
||||
// ================================
|
||||
|
||||
@ -4,7 +4,6 @@ import type { Placement } from '@/app/components/base/ui/placement'
|
||||
import * as React from 'react'
|
||||
import { useCallback } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { lt } from 'semver'
|
||||
import Badge from '@/app/components/base/badge'
|
||||
import {
|
||||
Popover,
|
||||
@ -14,6 +13,7 @@ import {
|
||||
import useTimestamp from '@/hooks/use-timestamp'
|
||||
import { useVersionListOfPlugin } from '@/service/use-plugins'
|
||||
import { cn } from '@/utils/classnames'
|
||||
import { isEarlierThanVersion } from '@/utils/semver'
|
||||
|
||||
type Props = {
|
||||
disabled?: boolean
|
||||
@ -100,7 +100,7 @@ const PluginVersionPicker: FC<Props> = ({
|
||||
onClick={() => handleSelect({
|
||||
version: version.version,
|
||||
unique_identifier: version.unique_identifier,
|
||||
isDowngrade: lt(version.version, currentVersion),
|
||||
isDowngrade: isEarlierThanVersion(version.version, currentVersion),
|
||||
})}
|
||||
>
|
||||
<div className="flex grow items-center">
|
||||
|
||||
Reference in New Issue
Block a user