Add runtime version reporting and display
This commit is contained in:
27
src/shared/versions.js
Normal file
27
src/shared/versions.js
Normal file
@@ -0,0 +1,27 @@
|
||||
export const HARBOR_VERSIONS = Object.freeze({
|
||||
macClient: '0.1.0',
|
||||
gatewayClient: '0.1.0',
|
||||
gatewayBackend: '0.1.0',
|
||||
});
|
||||
|
||||
export function parseVersion(value) {
|
||||
const match = /^(\d+)\.(\d+)\.(\d+)$/.exec(String(value || ''));
|
||||
return match ? {
|
||||
major: Number(match[1]),
|
||||
minor: Number(match[2]),
|
||||
hotfix: Number(match[3]),
|
||||
} : null;
|
||||
}
|
||||
|
||||
export function versionCompatibility(versions) {
|
||||
const mac = parseVersion(versions?.macClient);
|
||||
const client = parseVersion(versions?.gatewayClient);
|
||||
const backend = parseVersion(versions?.gatewayBackend);
|
||||
const major = Boolean(mac && client && backend
|
||||
&& mac.major === client.major
|
||||
&& client.major === backend.major);
|
||||
const gateway = Boolean(client && backend
|
||||
&& client.major === backend.major
|
||||
&& client.minor === backend.minor);
|
||||
return { compatible: major && gateway, major, gateway };
|
||||
}
|
||||
Reference in New Issue
Block a user