mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-10-28 23:05:01 -04:00
remove semver dependency for plugins
Signed-off-by: si458 <simonsmith5521@gmail.com>
This commit is contained in:
parent
8588fe2497
commit
960326ab40
@ -121,7 +121,7 @@ RUN case "$PREINSTALL_LIBS" in \
|
||||
true|yes|TRUE|YES) \
|
||||
cd meshcentral && \
|
||||
echo -e "----------\nPREINSTALLING LIBRARIES...\n----------"; \
|
||||
npm install ssh2@1.16.0 semver@7.7.1 nodemailer@6.10.0 image-size@2.0.1 wildleek@2.0.0 otplib@12.0.1 yubikeyotp@0.2.0;; \
|
||||
npm install ssh2@1.16.0 nodemailer@6.10.0 image-size@2.0.1 wildleek@2.0.0 otplib@12.0.1 yubikeyotp@0.2.0;; \
|
||||
false|no|FALSE|NO) \
|
||||
echo "Not pre-installing libraries.";; \
|
||||
*) \
|
||||
|
||||
@ -174,7 +174,7 @@ The following build arguments are available for customizing the build process:
|
||||
- **INCLUDE_MONGODB_TOOLS**: Include MongoDB client and related tools.
|
||||
- **INCLUDE_POSTGRESQL_TOOLS**: Include PostgreSQL client tools.
|
||||
- **INCLUDE_MARIADB_TOOLS**: Include MariaDB/MySQL client tools.
|
||||
- **PREINSTALL_LIBS**: Pre-install specific libraries like `ssh2`, `semver`, `nodemailer`, etc.
|
||||
- **PREINSTALL_LIBS**: Pre-install specific libraries like `ssh2`, `nodemailer`, etc.
|
||||
|
||||
### Build Commands with Arguments
|
||||
|
||||
|
||||
@ -4311,7 +4311,6 @@ function mainStart() {
|
||||
if (config.settings.acebase != null) { modules.push('acebase@1.29.5'); } // Add AceBase, official driver.
|
||||
if (config.settings.sqlite3 != null) { modules.push('sqlite3@5.1.7'); } // Add sqlite3, official driver.
|
||||
if (config.settings.vault != null) { modules.push('node-vault@0.10.2'); } // Add official HashiCorp's Vault module.
|
||||
if ((config.settings.plugins != null) && (config.settings.plugins != false) && ((typeof config.settings.plugins != 'object') || (config.settings.plugins.enabled != false))) { modules.push('semver@7.7.1'); } // Required for version compat testing and update checks
|
||||
if ((config.settings.plugins != null) && (config.settings.plugins.proxy != null)) { modules.push('https-proxy-agent@7.0.2'); } // Required for HTTP/HTTPS proxy support
|
||||
else if (config.settings.xmongodb != null) { modules.push('mongojs@3.1.0'); } // Add MongoJS, old driver.
|
||||
if (nodemailer || ((config.smtp != null) && (config.smtp.name != 'console')) || (config.sendmail != null)) { modules.push('nodemailer@6.9.16'); } // Add SMTP support
|
||||
|
||||
@ -286,6 +286,36 @@ module.exports.pluginHandler = function (parent) {
|
||||
return true;
|
||||
}
|
||||
|
||||
obj.versionGreater = function(a, b) {
|
||||
a = obj.versionToNumber(String(a).replace(/^v/, ''));
|
||||
b = obj.versionToNumber(String(b).replace(/^v/, ''));
|
||||
const partsA = a.split('.').map(Number);
|
||||
const partsB = b.split('.').map(Number);
|
||||
|
||||
for (let i = 0; i < Math.max(partsA.length, partsB.length); i++) {
|
||||
const numA = partsA[i] || 0;
|
||||
const numB = partsB[i] || 0;
|
||||
if (numA > numB) return true;
|
||||
if (numA < numB) return false;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
obj.versionLower = function(a, b) {
|
||||
a = obj.versionToNumber(String(a).replace(/^v/, ''));
|
||||
b = obj.versionToNumber(String(b).replace(/^v/, ''));
|
||||
const partsA = a.split('.').map(Number);
|
||||
const partsB = b.split('.').map(Number);
|
||||
|
||||
for (let i = 0; i < Math.max(partsA.length, partsB.length); i++) {
|
||||
const numA = partsA[i] || 0;
|
||||
const numB = partsB[i] || 0;
|
||||
if (numA < numB) return true;
|
||||
if (numA > numB) return false;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
obj.getPluginLatest = function () {
|
||||
return new Promise(function (resolve, reject) {
|
||||
parent.db.getPlugins(function (err, plugins) {
|
||||
@ -305,12 +335,11 @@ module.exports.pluginHandler = function (parent) {
|
||||
if (conf.configUrl == newconf.configUrl) curconf = conf;
|
||||
});
|
||||
if (curconf == null) reject("Some plugin configs could not be parsed");
|
||||
var s = require('semver');
|
||||
latestRet.push({
|
||||
'id': curconf._id,
|
||||
'installedVersion': curconf.version,
|
||||
'version': newconf.version,
|
||||
'hasUpdate': s.gt(newconf.version, curconf.version),
|
||||
'hasUpdate': obj.versionGreater(newconf.version, curconf.version),
|
||||
'meshCentralCompat': obj.versionCompare(parent.currentVer, newconf.meshCentralCompat),
|
||||
'changelogUrl': curconf.changelogUrl,
|
||||
'status': curconf.status
|
||||
@ -484,9 +513,8 @@ module.exports.pluginHandler = function (parent) {
|
||||
try {
|
||||
var vers = JSON.parse(versStr);
|
||||
var vList = [];
|
||||
var s = require('semver');
|
||||
vers.forEach((v) => {
|
||||
if (s.lt(v.name, plugin.version)) vList.push(v);
|
||||
if (obj.versionLower(v.name, plugin.version)) vList.push(v);
|
||||
});
|
||||
if (vers.length == 0) reject("No previous versions available.");
|
||||
resolve({ 'id': plugin._id, 'name': plugin.name, versionList: vList });
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user