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. 20
      packages/nocodb/src/lib/meta/api/utilApis.ts

20
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();
}

Loading…
Cancel
Save