1
0
Fork 0
mirror of https://github.com/Ylianst/MeshCentral.git synced 2025-03-09 15:40:18 +00:00

Fake semantic versioning for MeshCentral version comparison / plugin update compatibility check

This commit is contained in:
Ryan Blenis 2019-11-06 20:00:09 -05:00
parent bf1e4cc91f
commit f90fe05fe0
2 changed files with 6 additions and 3 deletions

View file

@ -263,12 +263,16 @@ module.exports.pluginHandler = function (parent) {
});
if (curconf == null) reject('Some plugin configs could not be parsed');
var s = require('semver');
// MeshCentral doesn't adhere to semantic versioning (due to the -<alpha_char> at the end of the version)
// Convert the letter to ASCII for a "true" version number comparison
var mcCurVer = parent.currentVer.replace(/-(.)$/, (m, p1) => { return p1.charCodeAt(0); });
var piCompatVer = newconf.meshCentralCompat.replace(/-(.)$/, (m, p1) => { return p1.charCodeAt(0); });
latestRet.push({
"id": curconf._id,
"installedVersion": curconf.version,
"version": newconf.version,
"hasUpdate": s.gt(newconf.version, curconf.version),
"meshCentralCompat": s.satisfies(s.coerce(parent.currentVer), newconf.meshCentralCompat),
"meshCentralCompat": s.satisfies(mcCurVer, piCompatVer),
"changelogUrl": curconf.changelogUrl,
"status": curconf.status
});