meshCentralCompat version comparison changes and updated docs for clarity
Ryan Blenis committed
Mar 11, 2020 at 21:22 UTC
2a49dcac2d3359777cd73af6edeccf3a3021f30e
2 files changed
+5
-5
pluginHandler.js
+4
-4
@@ -276,12 +276,12 @@ module.exports.pluginHandler = function (parent) {
276
277
// MeshCentral doesn't adhere to semantic versioning (due to the -<alpha_char> at the end of the version)
278
// Convert 1.2.3-a to 1.2.3-3 where the letter is converted to a number.
279
- function versionToNumber(ver) { var x = ver.split('-'); if (x.length != 2) return ver; x[1] = x[1].toLowerCase().charCodeAt(0) - 96; return x.join('.'); }
279
+ obj.versionToNumber = function(ver) { var x = ver.split('-'); if (x.length != 2) return ver; x[1] = x[1].toLowerCase().charCodeAt(0) - 96; return x.join('.'); }
280
281
// Check if the current version of MeshCentral is at least the minimal required.
282
- function checkMeshCentralVersion(current, minimal) {
282
+ obj.versionCompare = function(current, minimal) {
283
if (minimal.startsWith('>=')) { minimal = minimal.substring(2); }
284
- var c = versionToNumber(current).split('.'), m = versionToNumber(minimal).split('.');
284
+ var c = obj.versionToNumber(current).split('.'), m = obj.versionToNumber(minimal).split('.');
285
if (c.length != m.length) return false;
286
for (var i = 0; i < c.length; i++) { var cx = parseInt(c[i]), cm = parseInt(m[i]); if (cx > cm) { return true; } if (cx < cm) { return false; } }
287
return true;
@@ -312,7 +312,7 @@ module.exports.pluginHandler = function (parent) {
312
'installedVersion': curconf.version,
313
'version': newconf.version,
314
'hasUpdate': s.gt(newconf.version, curconf.version),
315
- 'meshCentralCompat': checkMeshCentralVersion(parent.currentVer, newconf.meshCentralCompat),
315
+ 'meshCentralCompat': obj.versionCompare(parent.currentVer, newconf.meshCentralCompat),
316
'changelogUrl': curconf.changelogUrl,
317
'status': curconf.status
318
});
plugin_development.md
+1
-1
@@ -49,7 +49,7 @@ A valid JSON object within a file named `config.json` in the root folder of your
49
| repository.type | Yes | string | valid values are `git` and in the future, `npm` will also be supported in the future
50
| repository.url | Yes | string | the URL to the project's repository
51
| versionHistoryUrl | No | string | the URL to the project's versions/tags
52
-| meshCentralCompat | Yes | string | the semantic version string of required compatibility with the MeshCentral server
52
+| meshCentralCompat | Yes | string | the minimum version string of required compatibility with the MeshCentral server, can be formatted as "0.1.2-c" or ">=0.1.2-c". Currently only supports minimum version, not full semantic checking.
53
54
## Plugin Hooks
55
These are separated into the following categories depending on the type of functionality the plugin should offer.