Fake semantic versioning for MeshCentral version comparison / plugin update compatibility check
Ryan Blenis committed
Nov 6, 2019 at 20:00 UTC
f90fe05fe0699a4a73c8df19b49411916a1b8707
2 files changed
+6
-3
meshuser.js
+1
-2
@@ -3130,8 +3130,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
3130
}
3131
case 'addplugin': {
3132
if ((user.siteadmin & 0xFFFFFFFF) == 0 || parent.parent.pluginHandler == null) break; // must be full admin, plugins enabled
3133
- try {
3134
- //parent.parent.pluginHandler.addPlugin(command.url)
3133
+ try {
3134
parent.parent.pluginHandler.getPluginConfig(command.url)
3135
.then(parent.parent.pluginHandler.addPlugin)
3136
.then(function(docs){
pluginHandler.js
+5
-1
@@ -263,12 +263,16 @@ module.exports.pluginHandler = function (parent) {
263
});
264
if (curconf == null) reject('Some plugin configs could not be parsed');
265
var s = require('semver');
266
+ // MeshCentral doesn't adhere to semantic versioning (due to the -<alpha_char> at the end of the version)
267
+ // Convert the letter to ASCII for a "true" version number comparison
268
+ var mcCurVer = parent.currentVer.replace(/-(.)$/, (m, p1) => { return p1.charCodeAt(0); });
269
+ var piCompatVer = newconf.meshCentralCompat.replace(/-(.)$/, (m, p1) => { return p1.charCodeAt(0); });
270
latestRet.push({
271
"id": curconf._id,
272
"installedVersion": curconf.version,
273
"version": newconf.version,
274
"hasUpdate": s.gt(newconf.version, curconf.version),
271
- "meshCentralCompat": s.satisfies(s.coerce(parent.currentVer), newconf.meshCentralCompat),
275
+ "meshCentralCompat": s.satisfies(mcCurVer, piCompatVer),
276
"changelogUrl": curconf.changelogUrl,
277
"status": curconf.status
278
});