From e45267c17c8d71eab35648d5045c218afbdd6f62 Mon Sep 17 00:00:00 2001 From: alex <48489896+devnaumov@users.noreply.github.com> Date: Mon, 15 Apr 2024 13:54:53 +0200 Subject: [PATCH] CB-4358 omit patch version (#2548) Co-authored-by: kseniaguzeeva <112612526+kseniaguzeeva@users.noreply.github.com> --- webapp/packages/core-version-update/package.json | 4 +--- .../core-version-update/src/VersionUpdateService.ts | 8 +++++--- webapp/packages/core-version/package.json | 4 +++- webapp/packages/core-version/src/VersionService.ts | 13 +++++++++++++ .../package.json | 3 +-- .../src/VersionUpdate.tsx | 5 ++--- webapp/yarn.lock | 2 +- 7 files changed, 26 insertions(+), 13 deletions(-) diff --git a/webapp/packages/core-version-update/package.json b/webapp/packages/core-version-update/package.json index 3924796697..424e097f61 100644 --- a/webapp/packages/core-version-update/package.json +++ b/webapp/packages/core-version-update/package.json @@ -20,12 +20,10 @@ "@cloudbeaver/core-di": "~0.1.0", "@cloudbeaver/core-localization": "~0.1.0", "@cloudbeaver/core-version": "~0.1.0", - "mobx": "^6.12.0", - "semver": "^7.6.0" + "mobx": "^6.12.0" }, "peerDependencies": {}, "devDependencies": { - "@types/semver": "~7.5.8", "typescript": "^5.3.3" } } diff --git a/webapp/packages/core-version-update/src/VersionUpdateService.ts b/webapp/packages/core-version-update/src/VersionUpdateService.ts index bcf25cc13f..29ecbae77d 100644 --- a/webapp/packages/core-version-update/src/VersionUpdateService.ts +++ b/webapp/packages/core-version-update/src/VersionUpdateService.ts @@ -6,7 +6,6 @@ * you may not use this file except in compliance with the License. */ import { computed, makeObservable } from 'mobx'; -import { compare } from 'semver'; import { injectable } from '@cloudbeaver/core-di'; import { IVersion, VersionResource, VersionService } from '@cloudbeaver/core-version'; @@ -29,10 +28,13 @@ export class VersionUpdateService { return false; } - return compare(this.versionResource.latest.number, this.versionService.current) === 1; + return this.versionService.compareVersions(this.versionResource.latest.number, this.versionService.current) === 1; } - constructor(private readonly versionService: VersionService, private readonly versionResource: VersionResource) { + constructor( + private readonly versionService: VersionService, + private readonly versionResource: VersionResource, + ) { this.versionInstructionGetter = null; makeObservable(this, { diff --git a/webapp/packages/core-version/package.json b/webapp/packages/core-version/package.json index 7cc601e49a..b2b5296a2b 100644 --- a/webapp/packages/core-version/package.json +++ b/webapp/packages/core-version/package.json @@ -23,11 +23,13 @@ "@cloudbeaver/core-root": "~0.1.0", "@cloudbeaver/core-utils": "~0.1.0", "mobx": "^6.12.0", - "react": "^18.2.0" + "react": "^18.2.0", + "semver": "^7.6.0" }, "peerDependencies": {}, "devDependencies": { "@types/react": "^18.2.63", + "@types/semver": "^7.5.8", "typescript": "^5.3.3" } } diff --git a/webapp/packages/core-version/src/VersionService.ts b/webapp/packages/core-version/src/VersionService.ts index 5cdda2ccca..3b73d69640 100644 --- a/webapp/packages/core-version/src/VersionService.ts +++ b/webapp/packages/core-version/src/VersionService.ts @@ -6,6 +6,7 @@ * you may not use this file except in compliance with the License. */ import { computed, makeObservable } from 'mobx'; +import { compare, gte, parse } from 'semver'; import { injectable } from '@cloudbeaver/core-di'; import { ServerConfigResource } from '@cloudbeaver/core-root'; @@ -44,4 +45,16 @@ export class VersionService { backendVersion, }; } + + greaterOrEqual(v1: string, v2: string) { + return gte(v1, v2); + } + + parseVersion(version: string) { + return parse(version); + } + + compareVersions(v1: string, v2: string): number { + return compare(v1, v2); + } } diff --git a/webapp/packages/plugin-version-update-administration/package.json b/webapp/packages/plugin-version-update-administration/package.json index c9f3b41d16..a3e883f623 100644 --- a/webapp/packages/plugin-version-update-administration/package.json +++ b/webapp/packages/plugin-version-update-administration/package.json @@ -28,8 +28,7 @@ "@cloudbeaver/core-version-update": "~0.1.0", "mobx-react-lite": "^4.0.5", "react": "^18.2.0", - "react-markdown": "^9.0.1", - "semver": "^7.6.0" + "react-markdown": "^9.0.1" }, "peerDependencies": {}, "devDependencies": { diff --git a/webapp/packages/plugin-version-update-administration/src/VersionUpdate.tsx b/webapp/packages/plugin-version-update-administration/src/VersionUpdate.tsx index 92bc319fcc..f28a564099 100644 --- a/webapp/packages/plugin-version-update-administration/src/VersionUpdate.tsx +++ b/webapp/packages/plugin-version-update-administration/src/VersionUpdate.tsx @@ -6,10 +6,9 @@ * you may not use this file except in compliance with the License. */ import { observer } from 'mobx-react-lite'; -import { gte } from 'semver'; import type { AdministrationItemContentComponent } from '@cloudbeaver/core-administration'; -import { ColoredContainer, s, useResource, useS, useStyles } from '@cloudbeaver/core-blocks'; +import { ColoredContainer, s, useResource, useS } from '@cloudbeaver/core-blocks'; import { useService } from '@cloudbeaver/core-di'; import { CachedMapAllKey } from '@cloudbeaver/core-resource'; import { VersionResource, VersionService } from '@cloudbeaver/core-version'; @@ -28,7 +27,7 @@ export const VersionUpdate: AdministrationItemContentComponent = observer(functi }); const GeneralInstructions = versionUpdateService.generalInstructionsGetter?.(); - const versions = versionResource.resource.values.filter(v => gte(v.number, versionService.current)); + const versions = versionResource.resource.values.filter(v => versionService.greaterOrEqual(v.number, versionService.current)); return ( diff --git a/webapp/yarn.lock b/webapp/yarn.lock index b528c3876e..051f2f523f 100644 --- a/webapp/yarn.lock +++ b/webapp/yarn.lock @@ -4941,7 +4941,7 @@ resolved "https://registry.yarnpkg.com/@types/scheduler/-/scheduler-0.16.8.tgz#ce5ace04cfeabe7ef87c0091e50752e36707deff" integrity sha512-WZLiwShhwLRmeV6zH+GkbOFT6Z6VklCItrDioxUnv+u4Ll+8vKeFySoFyK/0ctcRpOmwAicELfmys1sDc/Rw+A== -"@types/semver@^7.3.12", "@types/semver@^7.5.0", "@types/semver@~7.5.8": +"@types/semver@^7.3.12", "@types/semver@^7.5.0", "@types/semver@^7.5.8": version "7.5.8" resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.5.8.tgz#8268a8c57a3e4abd25c165ecd36237db7948a55e" integrity sha512-I8EUhyrgfLrcTkzV3TSsGyl1tSuPrEDzr0yd5m90UgNxQkyDXULk3b6MlQqTCpZpNtWe1K0hzclnZkTcLBe2UQ==