From ce39fac73ffb8055946b258a1c72f54c891df672 Mon Sep 17 00:00:00 2001 From: bzp2010 Date: Mon, 16 Sep 2024 00:47:18 +0800 Subject: [PATCH] fix --- libs/backend-api7/e2e/support/global-setup.ts | 16 +++++++++++++--- libs/backend-api7/e2e/support/utils.ts | 5 +++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/libs/backend-api7/e2e/support/global-setup.ts b/libs/backend-api7/e2e/support/global-setup.ts index dd7b45f..5ad55ac 100644 --- a/libs/backend-api7/e2e/support/global-setup.ts +++ b/libs/backend-api7/e2e/support/global-setup.ts @@ -2,7 +2,7 @@ import axios from 'axios'; import { spawn } from 'node:child_process'; import { randomUUID } from 'node:crypto'; import { Agent } from 'node:https'; -import { gte, lt } from 'semver'; +import * as semver from 'semver'; const httpClient = axios.create({ baseURL: 'https://localhost:7443', @@ -68,7 +68,12 @@ const initUser = async (username = 'admin', password = 'admin') => { }); // If the version is lower than 3.2.15, the license should be activated first. - if (lt('3.2.15', process.env.BACKEND_API7_VERSION ?? '0.0.0')) + if ( + semver.lt( + '3.2.15', + semver.coerce(process.env.BACKEND_API7_VERSION) ?? '0.0.0', + ) + ) await activateAPI7(); console.log('Modify password'); @@ -88,7 +93,12 @@ const initUser = async (username = 'admin', password = 'admin') => { // If the version is greater than or equal to 3.2.15, the license should // be activated after changing the password. - if (gte('3.2.15', process.env.BACKEND_API7_VERSION ?? '0.0.0')) + if ( + semver.gte( + '3.2.15', + semver.coerce(process.env.BACKEND_API7_VERSION) ?? '0.0.0', + ) + ) await activateAPI7(); }; diff --git a/libs/backend-api7/e2e/support/utils.ts b/libs/backend-api7/e2e/support/utils.ts index 50e0d80..2dd5483 100644 --- a/libs/backend-api7/e2e/support/utils.ts +++ b/libs/backend-api7/e2e/support/utils.ts @@ -1,5 +1,6 @@ import * as ADCSDK from '@api7/adc-sdk'; import { Listr, SilentRenderer } from 'listr2'; +import * as semver from 'semver'; import { BackendAPI7 } from '../../src'; @@ -101,7 +102,7 @@ export const conditionalDescribe = (cond: cond) => export const conditionalIt = (cond: cond) => (cond ? it : it.skip); export const semverCondition = ( - op: (v1: string, v2: string) => boolean, + op: (v1: string, v2: string | semver.SemVer) => boolean, target: string, - base = process.env.BACKEND_API7_VERSION ?? '0.0.0', + base = semver.coerce(process.env.BACKEND_API7_VERSION) ?? '0.0.0', ) => op(target, base);