Files
Lauri Ojansivu b39d57bf78 Publish and use the WeKan version manifest
Read the newest component versions from the fixed wekan.fi/version.txt endpoint and render its strictly validated five lines as escaped preformatted text in the Admin Version pane.

Generate the same manifest and install-page block from the release's Dockerfile pins and latest validated FerretDB tag in both local and release-all website flows. Add positive, negative, workflow and UI coverage.

Thanks to xet7 !
2026-08-30 18:04:24 +03:00

43 lines
1.3 KiB
JavaScript

export function versionParts(value) {
const match = String(value || '').trim().match(
/^v?(\d+)\.(\d+)(?:\.(\d+))?(?:[-+][0-9A-Za-z.-]+)?$/,
);
return match ? match.slice(1, 4).map(part => Number(part || 0)) : null;
}
export function compareVersions(current, newest) {
const a = versionParts(current);
const b = versionParts(newest);
if (!a || !b) return null;
for (let i = 0; i < 3; i += 1) {
if (a[i] < b[i]) return -1;
if (a[i] > b[i]) return 1;
}
return 0;
}
const VERSION_MANIFEST_LABELS = [
'WeKan',
'FerretDB',
'Meteor',
'Node',
'NPM',
];
export function parseVersionManifest(value) {
if (typeof value !== 'string' || value.length > 1024) return null;
const lines = value.replace(/\r\n/g, '\n').trim().split('\n');
if (lines.length !== VERSION_MANIFEST_LABELS.length) return null;
const versions = {};
for (let i = 0; i < VERSION_MANIFEST_LABELS.length; i += 1) {
const label = VERSION_MANIFEST_LABELS[i];
const match = lines[i].match(new RegExp(`^${label} (v?\\d+\\.\\d+(?:\\.\\d+)?(?:[-+][0-9A-Za-z.-]+)?)$`));
if (!match || !versionParts(match[1])) return null;
versions[label.toLowerCase()] = match[1].replace(/^v/, '');
}
const text = VERSION_MANIFEST_LABELS
.map(label => `${label} ${versions[label.toLowerCase()]}`)
.join('\n');
return { text, versions };
}