Browse Source

feat(nocodb): get latest non-beta version as release version

pull/4601/head
Wing-Kam Wong 2 years ago
parent
commit
ef8e21f43d
  1. 22
      packages/nocodb/src/lib/meta/api/utilApis.ts

22
packages/nocodb/src/lib/meta/api/utilApis.ts

@ -1,5 +1,6 @@
// // Project CRUD // // Project CRUD
import { Request, Response } from 'express'; import { Request, Response } from 'express';
import { compareVersions, validate } from 'compare-versions';
import { ViewTypes } from 'nocodb-sdk'; import { ViewTypes } from 'nocodb-sdk';
import Project from '../../models/Project'; import Project from '../../models/Project';
@ -65,17 +66,22 @@ export async function versionInfo(_req: Request, res: Response) {
(versionCache.lastFetched && (versionCache.lastFetched &&
versionCache.lastFetched < Date.now() - 1000 * 60 * 60) versionCache.lastFetched < Date.now() - 1000 * 60 * 60)
) { ) {
versionCache.releaseVersion = await axios const nonBetaTags = await axios
.get('https://github.com/nocodb/nocodb/releases/latest', { .get('https://api.github.com/repos/nocodb/nocodb/tags', {
timeout: 5000, timeout: 5000,
}) })
.then((response) => .then((response) => {
response.request.res.responseUrl.replace( return response.data
'https://github.com/nocodb/nocodb/releases/tag/', .map((x) => x.name)
'' .filter(
) (v) => validate(v) && !v.includes('finn') && !v.includes('beta')
) )
.sort((x, y) => compareVersions(y, x));
})
.catch(() => null); .catch(() => null);
if (nonBetaTags && nonBetaTags.length > 0) {
versionCache.releaseVersion = nonBetaTags[0];
}
versionCache.lastFetched = Date.now(); versionCache.lastFetched = Date.now();
} }

Loading…
Cancel
Save