From ef8e21f43d545af2abfbc7d597c0e32f3c1289aa Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Fri, 9 Dec 2022 12:54:15 +0800 Subject: [PATCH] feat(nocodb): get latest non-beta version as release version --- packages/nocodb/src/lib/meta/api/utilApis.ts | 22 +++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/packages/nocodb/src/lib/meta/api/utilApis.ts b/packages/nocodb/src/lib/meta/api/utilApis.ts index cdd9f0a321..16cee5adcb 100644 --- a/packages/nocodb/src/lib/meta/api/utilApis.ts +++ b/packages/nocodb/src/lib/meta/api/utilApis.ts @@ -1,5 +1,6 @@ // // Project CRUD import { Request, Response } from 'express'; +import { compareVersions, validate } from 'compare-versions'; import { ViewTypes } from 'nocodb-sdk'; import Project from '../../models/Project'; @@ -65,17 +66,22 @@ export async function versionInfo(_req: Request, res: Response) { (versionCache.lastFetched && versionCache.lastFetched < Date.now() - 1000 * 60 * 60) ) { - versionCache.releaseVersion = await axios - .get('https://github.com/nocodb/nocodb/releases/latest', { + const nonBetaTags = await axios + .get('https://api.github.com/repos/nocodb/nocodb/tags', { timeout: 5000, }) - .then((response) => - response.request.res.responseUrl.replace( - 'https://github.com/nocodb/nocodb/releases/tag/', - '' - ) - ) + .then((response) => { + return response.data + .map((x) => x.name) + .filter( + (v) => validate(v) && !v.includes('finn') && !v.includes('beta') + ) + .sort((x, y) => compareVersions(y, x)); + }) .catch(() => null); + if (nonBetaTags && nonBetaTags.length > 0) { + versionCache.releaseVersion = nonBetaTags[0]; + } versionCache.lastFetched = Date.now(); }