Skip to content

Commit

Permalink
feat: check with min version
Browse files Browse the repository at this point in the history
  • Loading branch information
darkskygit committed Dec 19, 2024
1 parent ef0f920 commit 6de0745
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/backend/server/src/base/error/errors.gen.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable */
// AUTO GENERATED FILE
import { createUnionType, Field, ObjectType, registerEnumType } from '@nestjs/graphql';

Expand Down
11 changes: 5 additions & 6 deletions packages/backend/server/src/core/version/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ export class VersionService {

constructor(private readonly runtime: Runtime) {}

private async getRecommendedVersion() {
const minVersion = await this.runtime.fetch('version/minVersion');

private async getRecommendedVersion(minVersion: string) {
try {
const range = new semver.Range(minVersion);
const versions = range.set
Expand All @@ -27,8 +25,9 @@ export class VersionService {
}

async checkVersion(clientVersion?: any) {
const readableMinVersion = await this.getRecommendedVersion();
if (!readableMinVersion) {
const minVersion = await this.runtime.fetch('version/minVersion');
const readableMinVersion = await this.getRecommendedVersion(minVersion);
if (!minVersion || !readableMinVersion) {
// ignore invalid min version config
return true;
}
Expand All @@ -41,7 +40,7 @@ export class VersionService {
);

if (semver.valid(clientVersion)) {
if (!semver.satisfies(clientVersion, readableMinVersion)) {
if (!semver.satisfies(clientVersion, minVersion)) {
throw new UnsupportedClientVersion({
minVersion: readableMinVersion,
});
Expand Down

0 comments on commit 6de0745

Please sign in to comment.