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

@ -3131,7 +3131,6 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
case 'addplugin': {
if ((user.siteadmin & 0xFFFFFFFF) == 0 || parent.parent.pluginHandler == null) break; // must be full admin, plugins enabled
try {
//parent.parent.pluginHandler.addPlugin(command.url)
parent.parent.pluginHandler.getPluginConfig(command.url)
.then(parent.parent.pluginHandler.addPlugin)
.then(function(docs){

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