remove minify-js use html-minifier instead #6357
Signed-off-by: si458 <simonsmith5521@gmail.com>
si458 committed
Sep 10, 2024 at 20:01 UTC
2b5337329a7eaaa27c7605755fe428ea0c6ceff6
3 files changed
+8
-6
docker/Dockerfile
+1
-1
@@ -18,7 +18,7 @@ RUN if ! [ -z "$DISABLE_TRANSLATE" ] && [ "$DISABLE_TRANSLATE" != "yes" ] && [ "
18
fi
19
20
# install translate/minify modules if need too
21
-RUN if [ -z "$DISABLE_MINIFY" ] || [ -z "$DISABLE_TRANSLATE" ]; then cd meshcentral && npm install html-minifier jsdom minify-js; fi
21
+RUN if [ -z "$DISABLE_MINIFY" ] || [ -z "$DISABLE_TRANSLATE" ]; then cd meshcentral && npm install html-minifier jsdom; fi
22
23
# first extractall if need too
24
RUN if [ -z "$DISABLE_MINIFY" ] || [ -z "$DISABLE_TRANSLATE" ]; then cd meshcentral/translate && node translate.js extractall; fi
meshcentral.js
+1
-1
@@ -4143,7 +4143,7 @@ function mainStart() {
4143
else if (config.settings.xmongodb != null) { modules.push('mongojs@3.1.0'); } // Add MongoJS, old driver.
4144
if (nodemailer || ((config.smtp != null) && (config.smtp.name != 'console')) || (config.sendmail != null)) { modules.push('nodemailer@6.9.8'); } // Add SMTP support
4145
if (sendgrid || (config.sendgrid != null)) { modules.push('@sendgrid/mail'); } // Add SendGrid support
4146
- if ((args.translate || args.dev) && (Number(process.version.match(/^v(\d+\.\d+)/)[1]) >= 16)) { modules.push('jsdom@22.1.0'); modules.push('esprima@4.0.1'); modules.push('minify-js@0.0.4'); modules.push('html-minifier@4.0.0'); } // Translation support
4146
+ if ((args.translate || args.dev) && (Number(process.version.match(/^v(\d+\.\d+)/)[1]) >= 16)) { modules.push('jsdom@22.1.0'); modules.push('esprima@4.0.1'); modules.push('html-minifier@4.0.0'); } // Translation support
4147
if (typeof config.settings.crowdsec == 'object') { modules.push('@crowdsec/express-bouncer@0.1.0'); } // Add CrowdSec bounser module (https://www.npmjs.com/package/@crowdsec/express-bouncer)
4148
4149
if (typeof config.settings.autobackup == 'object') {
translate/translate.js
+6
-4
@@ -140,7 +140,7 @@ if (directRun && (NodeJSVer >= 12)) {
140
// Get things setup
141
jsdom = require('jsdom');
142
esprima = require('esprima'); // https://www.npmjs.com/package/esprima
143
- if (minifyLib == 1) { minify = require('minify-js'); }
143
+ if (minifyLib == 1) { log("minify-js is no longer used, please switch to \"html-minifier\""); process.exit(); return; }
144
if (minifyLib == 2) { minify = require('html-minifier').minify; } // https://www.npmjs.com/package/html-minifier
145
146
switch (op) {
@@ -157,8 +157,8 @@ if (directRun && (NodeJSVer >= 12)) {
157
if (directRun) { setup(); }
158
159
function setup() {
160
- var libs = ['jsdom@22.1.0', 'esprima@4.0.1', 'minify-js@0.0.4'];
161
- if (minifyLib == 1) { libs.push('minify-js@0.0.4'); }
160
+ var libs = ['jsdom@22.1.0', 'esprima@4.0.1'];
161
+ if (minifyLib == 1) { log("minify-js is no longer used, please switch to \"html-minifier\""); process.exit(); return; }
162
if (minifyLib == 2) { libs.push('html-minifier@4.0.0'); }
163
InstallModules(libs, start);
164
}
@@ -169,7 +169,7 @@ function startEx(argv) {
169
// Load dependencies
170
jsdom = require('jsdom');
171
esprima = require('esprima'); // https://www.npmjs.com/package/esprima
172
- if (minifyLib == 1) { minify = require('minify-js'); }
172
+ if (minifyLib == 1) { log("minify-js is no longer used, please switch to \"html-minifier\""); process.exit(); return; }
173
if (minifyLib == 2) { minify = require('html-minifier').minify; } // https://www.npmjs.com/package/html-minifier
174
175
var command = null;
@@ -490,6 +490,8 @@ function startEx(argv) {
490
outnamemin = (outname.substring(0, outname.length - 5) + '-min.html');
491
} else if (outname.endsWith('.htm')) {
492
outnamemin = (outname.substring(0, outname.length - 4) + '-min.htm');
493
+ } else if (outname.endsWith('.js')) {
494
+ outnamemin = (outname.substring(0, outname.length - 3) + '-min.js');
495
} else {
496
outnamemin = (outname, outname + '.min');
497
}