@e-mc/module 0.5.3 → 0.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +7 -11
- package/README.md +5 -3
- package/index.d.ts +4 -4
- package/index.js +238 -233
- package/lib-v4.d.ts +4 -4
- package/lib-v4.js +5 -5
- package/package.json +4 -4
package/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/* eslint no-global-assign: "off" */
|
|
3
2
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
4
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
4
|
const path = require("path");
|
|
@@ -12,7 +11,7 @@ const mime = require("mime-types");
|
|
|
12
11
|
const chalk = require("chalk");
|
|
13
12
|
const stripansi = require("strip-ansi");
|
|
14
13
|
const EventEmitter = require("events");
|
|
15
|
-
const types_1 = require("
|
|
14
|
+
const types_1 = require("@e-mc/types");
|
|
16
15
|
const kSessionId = Symbol('sessionId');
|
|
17
16
|
const kBroadcastId = Symbol('broadcastId');
|
|
18
17
|
const kTempDir = Symbol('tempDir');
|
|
@@ -97,30 +96,30 @@ const SETTINGS = {
|
|
|
97
96
|
stdout: true
|
|
98
97
|
};
|
|
99
98
|
const VALUES = {
|
|
100
|
-
["node.require.ext"
|
|
101
|
-
["node.require.npm"
|
|
102
|
-
["node.require.inline"
|
|
103
|
-
["node.process.cpu_usage"
|
|
104
|
-
["node.process.memory_usage"
|
|
105
|
-
["node.process.inline"
|
|
106
|
-
["temp.dir"
|
|
107
|
-
["temp.write"
|
|
108
|
-
["process.password"
|
|
109
|
-
["process.cipher.algorithm"
|
|
110
|
-
["process.env.apply"
|
|
111
|
-
["permission.process_exec"
|
|
112
|
-
["permission.home_read"
|
|
113
|
-
["permission.home_write"
|
|
114
|
-
["memory.settings.users"
|
|
115
|
-
["error.out"
|
|
116
|
-
["error.fatal"
|
|
117
|
-
["broadcast.out"
|
|
118
|
-
["logger.level"
|
|
99
|
+
["node.require.ext"]: 'cjs',
|
|
100
|
+
["node.require.npm"]: true,
|
|
101
|
+
["node.require.inline"]: true,
|
|
102
|
+
["node.process.cpu_usage"]: true,
|
|
103
|
+
["node.process.memory_usage"]: true,
|
|
104
|
+
["node.process.inline"]: true,
|
|
105
|
+
["temp.dir"]: "tmp",
|
|
106
|
+
["temp.write"]: false,
|
|
107
|
+
["process.password"]: '',
|
|
108
|
+
["process.cipher.algorithm"]: '',
|
|
109
|
+
["process.env.apply"]: false,
|
|
110
|
+
["permission.process_exec"]: [],
|
|
111
|
+
["permission.home_read"]: false,
|
|
112
|
+
["permission.home_write"]: false,
|
|
113
|
+
["memory.settings.users"]: false,
|
|
114
|
+
["error.out"]: null,
|
|
115
|
+
["error.fatal"]: false,
|
|
116
|
+
["broadcast.out"]: null,
|
|
117
|
+
["logger.level"]: -1
|
|
119
118
|
};
|
|
120
119
|
const REGEXP_TORRENT = /^(?:magnet:\?xt=|(?:https?|s?ftp):\/\/[^/][^\n]*?\.(?:torrent|metalink|meta4)(?:\?[^\n]*)?$)/i;
|
|
121
120
|
let LOG_NEWLINE = true;
|
|
122
121
|
let LOG_EMPTYLINE = false;
|
|
123
|
-
let TEMP_DIR = path.join(PROCESS_CWD, "tmp"
|
|
122
|
+
let TEMP_DIR = path.join(PROCESS_CWD, "tmp");
|
|
124
123
|
const PNPM_VER = (function () {
|
|
125
124
|
try {
|
|
126
125
|
const pathname = path.resolve('./node_modules/.modules.yaml');
|
|
@@ -307,9 +306,9 @@ function errorObject(message) {
|
|
|
307
306
|
case 'string':
|
|
308
307
|
return new Error(message);
|
|
309
308
|
case 'number':
|
|
310
|
-
return (0, types_1.errorMessage)("Error code"
|
|
309
|
+
return (0, types_1.errorMessage)("Error code", message.toString());
|
|
311
310
|
default:
|
|
312
|
-
return message instanceof Error ? message : new Error(Module.asString(message) || "Unknown"
|
|
311
|
+
return message instanceof Error ? message : new Error(Module.asString(message) || "Unknown");
|
|
313
312
|
}
|
|
314
313
|
}
|
|
315
314
|
function isFailed(options) {
|
|
@@ -322,7 +321,7 @@ function isFailed(options) {
|
|
|
322
321
|
return false;
|
|
323
322
|
}
|
|
324
323
|
function getErrorMessage(err) {
|
|
325
|
-
return SETTINGS.stack_trace && err.stack || err.message || err.toString() || "Unknown"
|
|
324
|
+
return SETTINGS.stack_trace && err.stack || err.message || err.toString() || "Unknown";
|
|
326
325
|
}
|
|
327
326
|
function writeLine(value) {
|
|
328
327
|
PROCESS_STDOUT.write((!LOG_NEWLINE ? '\n' : '') + value + '\n');
|
|
@@ -330,7 +329,7 @@ function writeLine(value) {
|
|
|
330
329
|
LOG_EMPTYLINE = false;
|
|
331
330
|
}
|
|
332
331
|
function errorPermission(value) {
|
|
333
|
-
return (0, types_1.errorValue)("Unsupported access"
|
|
332
|
+
return (0, types_1.errorValue)("Unsupported access", value);
|
|
334
333
|
}
|
|
335
334
|
function parseFileArgs(options = {}, callback) {
|
|
336
335
|
let promises;
|
|
@@ -391,7 +390,7 @@ function addCacheItem(map, key, data) {
|
|
|
391
390
|
}
|
|
392
391
|
function checkFunction(value) {
|
|
393
392
|
if (typeof value === 'function') {
|
|
394
|
-
Object.defineProperty(value, "__cjs__"
|
|
393
|
+
Object.defineProperty(value, "__cjs__", { value: true });
|
|
395
394
|
return value;
|
|
396
395
|
}
|
|
397
396
|
return null;
|
|
@@ -404,7 +403,7 @@ function encryptMessage(data, cipher, algorithm) {
|
|
|
404
403
|
}
|
|
405
404
|
const result = (0, types_1.encryptUTF8)(algorithm, cipher.key, cipher.iv, data);
|
|
406
405
|
if (result) {
|
|
407
|
-
VALUES[_h = "process.cipher.algorithm"
|
|
406
|
+
VALUES[_h = "process.cipher.algorithm"] || (VALUES[_h] = algorithm);
|
|
408
407
|
return result;
|
|
409
408
|
}
|
|
410
409
|
}
|
|
@@ -429,7 +428,7 @@ function hasFileSystem(type, value, options, ignoreExists, overwrite) {
|
|
|
429
428
|
}
|
|
430
429
|
else if (!(result = Module.fromLocalPath(value))) {
|
|
431
430
|
if (options.throwsDoesNotExist) {
|
|
432
|
-
throw (0, types_1.errorValue)("File not found"
|
|
431
|
+
throw (0, types_1.errorValue)("File not found", value);
|
|
433
432
|
}
|
|
434
433
|
return '';
|
|
435
434
|
}
|
|
@@ -441,14 +440,14 @@ function hasFileSystem(type, value, options, ignoreExists, overwrite) {
|
|
|
441
440
|
}
|
|
442
441
|
if (!ignoreExists && !Module.isPath(result)) {
|
|
443
442
|
if (options.throwsDoesNotExist) {
|
|
444
|
-
throw (0, types_1.errorValue)("File not found"
|
|
443
|
+
throw (0, types_1.errorValue)("File not found", value);
|
|
445
444
|
}
|
|
446
445
|
return '';
|
|
447
446
|
}
|
|
448
447
|
if (options.ignorePermission) {
|
|
449
448
|
return result;
|
|
450
449
|
}
|
|
451
|
-
const method = type === 1
|
|
450
|
+
const method = type === 1 ? 'canWrite' : 'canRead';
|
|
452
451
|
if (options.ownPermissionOnly) {
|
|
453
452
|
if (this.hasOwnPermission() && !this[method](result)) {
|
|
454
453
|
if (options.throwsPermission) {
|
|
@@ -529,13 +528,13 @@ const asFile = (value) => value instanceof URL ? value.protocol === 'file:' ? ur
|
|
|
529
528
|
const wrapQuote = (value) => '"' + value.replace(/"/g, '\\"') + '"';
|
|
530
529
|
const isFunction = (value) => typeof value === 'function';
|
|
531
530
|
const isFileURL = (value) => /^file:\/\//i.test(value);
|
|
532
|
-
const errorDirectory = (value) => (0, types_1.errorValue)("Path is not a directory"
|
|
531
|
+
const errorDirectory = (value) => (0, types_1.errorValue)("Path is not a directory", value);
|
|
533
532
|
const sanitizePath = (value) => (0, types_1.isString)(value) ? path.resolve(value.trim()) : '';
|
|
534
|
-
const ensureDir = (value) => value
|
|
535
|
-
const trimDir = (value) => value
|
|
533
|
+
const ensureDir = (value) => !value.endsWith(path.sep) ? value + path.sep : value;
|
|
534
|
+
const trimDir = (value) => value.endsWith(path.sep) ? value.substring(0, value.length - 1) : value;
|
|
536
535
|
const getExtension = (value) => path.extname(value).toLowerCase().substring(1);
|
|
537
536
|
const hasString = (item, value) => (0, types_1.isString)(value) && (item === value || Array.isArray(item) && item.includes(value));
|
|
538
|
-
const getCpuTimes = () => os.cpus().reduce((a, b) => a + b.times.user + b.times.sys, 0) * 1000
|
|
537
|
+
const getCpuTimes = () => os.cpus().reduce((a, b) => a + b.times.user + b.times.sys, 0) * 1000;
|
|
539
538
|
class Module extends EventEmitter {
|
|
540
539
|
constructor() {
|
|
541
540
|
super(...arguments);
|
|
@@ -547,18 +546,18 @@ class Module extends EventEmitter {
|
|
|
547
546
|
this._threadable = false;
|
|
548
547
|
this._logEnabled = true;
|
|
549
548
|
this._logFlushed = false;
|
|
550
|
-
this._logLevel = VALUES["logger.level"
|
|
549
|
+
this._logLevel = VALUES["logger.level"];
|
|
551
550
|
this._hostEvents = ['abort'];
|
|
552
551
|
this._logQueued = [];
|
|
553
552
|
this[_a] = '';
|
|
554
|
-
this[_b] = VALUES["temp.dir"
|
|
553
|
+
this[_b] = VALUES["temp.dir"];
|
|
555
554
|
this[_c] = '';
|
|
556
555
|
this[_d] = null;
|
|
557
556
|
this[_e] = { stripAnsi: { value: true, modified: false } };
|
|
558
557
|
this[_f] = new AbortController();
|
|
559
558
|
this[_g] = null;
|
|
560
559
|
}
|
|
561
|
-
static get VERSION() { return "0.5.
|
|
560
|
+
static get VERSION() { return "0.5.4"; }
|
|
562
561
|
static get LOG_TYPE() { return types_1.LOG_TYPE; }
|
|
563
562
|
static get STATUS_TYPE() { return types_1.STATUS_TYPE; }
|
|
564
563
|
static get MAX_TIMEOUT() { return 2147483647; }
|
|
@@ -580,33 +579,33 @@ class Module extends EventEmitter {
|
|
|
580
579
|
}
|
|
581
580
|
static enabled(key, username) {
|
|
582
581
|
switch (key) {
|
|
583
|
-
case "memory.settings.users"
|
|
582
|
+
case "memory.settings.users": {
|
|
584
583
|
const users = VALUES[key];
|
|
585
584
|
return users === false || !!username && (users === true || users.includes(username));
|
|
586
585
|
}
|
|
587
|
-
case "temp.dir"
|
|
588
|
-
return VALUES[key] !== "tmp"
|
|
589
|
-
case "node.require.npm"
|
|
590
|
-
case "node.require.inline"
|
|
591
|
-
case "node.process.cpu_usage"
|
|
592
|
-
case "node.process.memory_usage"
|
|
593
|
-
case "node.process.inline"
|
|
594
|
-
case "temp.write"
|
|
595
|
-
case "permission.home_read"
|
|
596
|
-
case "permission.home_write"
|
|
597
|
-
case "process.env.apply"
|
|
598
|
-
case "error.fatal"
|
|
586
|
+
case "temp.dir":
|
|
587
|
+
return VALUES[key] !== "tmp";
|
|
588
|
+
case "node.require.npm":
|
|
589
|
+
case "node.require.inline":
|
|
590
|
+
case "node.process.cpu_usage":
|
|
591
|
+
case "node.process.memory_usage":
|
|
592
|
+
case "node.process.inline":
|
|
593
|
+
case "temp.write":
|
|
594
|
+
case "permission.home_read":
|
|
595
|
+
case "permission.home_write":
|
|
596
|
+
case "process.env.apply":
|
|
597
|
+
case "error.fatal":
|
|
599
598
|
return VALUES[key];
|
|
600
|
-
case "node.require.ext"
|
|
601
|
-
case "process.password"
|
|
602
|
-
case "process.cipher.algorithm"
|
|
599
|
+
case "node.require.ext":
|
|
600
|
+
case "process.password":
|
|
601
|
+
case "process.cipher.algorithm":
|
|
603
602
|
return VALUES[key] !== '';
|
|
604
|
-
case "permission.process_exec"
|
|
603
|
+
case "permission.process_exec":
|
|
605
604
|
return VALUES[key].length > 0;
|
|
606
|
-
case "error.out"
|
|
607
|
-
case "broadcast.out"
|
|
605
|
+
case "error.out":
|
|
606
|
+
case "broadcast.out":
|
|
608
607
|
return VALUES[key] !== null;
|
|
609
|
-
case "logger.level"
|
|
608
|
+
case "logger.level":
|
|
610
609
|
return VALUES[key] >= 0;
|
|
611
610
|
default:
|
|
612
611
|
return false;
|
|
@@ -618,20 +617,20 @@ class Module extends EventEmitter {
|
|
|
618
617
|
return false;
|
|
619
618
|
}
|
|
620
619
|
}
|
|
621
|
-
else if ((value & 1
|
|
622
|
-
(value & 2
|
|
623
|
-
(value & 4
|
|
624
|
-
(value & 8
|
|
625
|
-
(value & 16
|
|
626
|
-
(value & 32
|
|
627
|
-
(value & 64
|
|
628
|
-
(value & 128
|
|
629
|
-
(value & 256
|
|
630
|
-
(value & 1024
|
|
631
|
-
(value & 2048
|
|
632
|
-
(value & 4096
|
|
633
|
-
(value & 32768
|
|
634
|
-
(value & 65536
|
|
620
|
+
else if ((value & 1) && SETTINGS.system === false ||
|
|
621
|
+
(value & 2) && SETTINGS.node === false ||
|
|
622
|
+
(value & 4) && SETTINGS.process === false ||
|
|
623
|
+
(value & 8) && SETTINGS.compress === false ||
|
|
624
|
+
(value & 16) && SETTINGS.watch === false ||
|
|
625
|
+
(value & 32) && SETTINGS.file === false ||
|
|
626
|
+
(value & 64) && SETTINGS.cloud === false ||
|
|
627
|
+
(value & 128) && SETTINGS.time_elapsed === false ||
|
|
628
|
+
(value & 256) && SETTINGS.time_process === false ||
|
|
629
|
+
(value & 1024) && SETTINGS.http === false ||
|
|
630
|
+
(value & 2048) && SETTINGS.image === false ||
|
|
631
|
+
(value & 4096) && SETTINGS.exec === false ||
|
|
632
|
+
(value & 32768) && SETTINGS.stdout === false ||
|
|
633
|
+
(value & 65536) && SETTINGS.db === false) {
|
|
635
634
|
return false;
|
|
636
635
|
}
|
|
637
636
|
return true;
|
|
@@ -640,19 +639,18 @@ class Module extends EventEmitter {
|
|
|
640
639
|
if (options.type) {
|
|
641
640
|
type |= options.type;
|
|
642
641
|
}
|
|
643
|
-
const BROADCAST_OUT = VALUES["broadcast.out"
|
|
642
|
+
const BROADCAST_OUT = VALUES["broadcast.out"];
|
|
644
643
|
const sessionId = options.sessionId;
|
|
645
644
|
let broadcastId = options.broadcastId;
|
|
646
|
-
if ((type & 512
|
|
645
|
+
if ((type & 512) === 512 && VALUES["error.out"]) {
|
|
647
646
|
try {
|
|
648
|
-
const ERROR_OUT = VALUES["error.out"
|
|
649
|
-
const errorOptions = { type: type & ~512
|
|
650
|
-
|
|
651
|
-
if (ERROR_OUT["__cjs__" /* INTERNAL.CJS */]) {
|
|
647
|
+
const ERROR_OUT = VALUES["error.out"];
|
|
648
|
+
const errorOptions = { type: type & ~512, value, timeStamp: getTimeStamp(options, true), sessionId };
|
|
649
|
+
if (ERROR_OUT["__cjs__"]) {
|
|
652
650
|
ERROR_OUT(errorObject(message), errorOptions);
|
|
653
651
|
}
|
|
654
652
|
else {
|
|
655
|
-
ERROR_OUT.apply(VALUES["node.process.inline"
|
|
653
|
+
ERROR_OUT.apply(VALUES["node.process.inline"] ? process : null, VALUES["node.require.inline"] ? [errorObject(message), errorOptions, require] : [errorObject(message), errorOptions]);
|
|
656
654
|
}
|
|
657
655
|
}
|
|
658
656
|
catch {
|
|
@@ -663,7 +661,7 @@ class Module extends EventEmitter {
|
|
|
663
661
|
}
|
|
664
662
|
let messageUnitIndent = options.messageUnitIndent, coloring;
|
|
665
663
|
if (!broadcastId) {
|
|
666
|
-
(0, types_1.setLogCurrent)({ type, title, value, message });
|
|
664
|
+
(0, types_1.setLogCurrent)({ type, title, value, message, sessionId });
|
|
667
665
|
coloring = !(options.useColor === false || SETTINGS.color === false);
|
|
668
666
|
}
|
|
669
667
|
else if ((0, types_1.isPlainObject)(broadcastId)) {
|
|
@@ -675,7 +673,7 @@ class Module extends EventEmitter {
|
|
|
675
673
|
const formatValue = format.value;
|
|
676
674
|
const id = sessionId && SETTINGS.session_id ? ' ' + sessionId.padStart(SETTINGS.session_id, '0') + ' ' : '';
|
|
677
675
|
const titleIndent = options.titleIndent ? typeof options.titleIndent === 'number' ? Math.max(options.titleIndent, 0) : 0 : -1;
|
|
678
|
-
let output, error, hint, valueWidth = Math.max(formatValue.width - (id ? SETTINGS.session_id + 1 : 0), 1), titleJustify = options.titleJustify || ((type & 512
|
|
676
|
+
let output, error, hint, valueWidth = Math.max(formatValue.width - (id ? SETTINGS.session_id + 1 : 0), 1), titleJustify = options.titleJustify || ((type & 512) || options.failed ? 'center' : formatTitle.justify);
|
|
679
677
|
if (Array.isArray(value)) {
|
|
680
678
|
hint = value[1] ?? '';
|
|
681
679
|
value = value[0];
|
|
@@ -724,7 +722,7 @@ class Module extends EventEmitter {
|
|
|
724
722
|
indent = match[1];
|
|
725
723
|
if (bgAltColor) {
|
|
726
724
|
try {
|
|
727
|
-
indent = (bgAltColor
|
|
725
|
+
indent = (bgAltColor.startsWith('#') ? chalk.bgHex(bgAltColor) : chalk[bgAltColor])(indent);
|
|
728
726
|
}
|
|
729
727
|
catch {
|
|
730
728
|
}
|
|
@@ -747,10 +745,10 @@ class Module extends EventEmitter {
|
|
|
747
745
|
try {
|
|
748
746
|
let current = bold ? chalk.bold : chalk;
|
|
749
747
|
if (typeof color === 'string' && color.length > 1) {
|
|
750
|
-
current = color
|
|
748
|
+
current = color.startsWith('#') ? current.hex(color) : current[color];
|
|
751
749
|
}
|
|
752
750
|
if (typeof bgColor === 'string' && bgColor.length > 1) {
|
|
753
|
-
current = bgColor
|
|
751
|
+
current = bgColor.startsWith('#') ? current.bgHex(bgColor) : current[bgColor];
|
|
754
752
|
}
|
|
755
753
|
return indent + current(content);
|
|
756
754
|
}
|
|
@@ -759,52 +757,52 @@ class Module extends EventEmitter {
|
|
|
759
757
|
}
|
|
760
758
|
return indent + (bold ? chalk.bold(content) : content);
|
|
761
759
|
};
|
|
762
|
-
if (type === 0
|
|
760
|
+
if (type === 0) {
|
|
763
761
|
checkColorOptions(type, SETTINGS.unknown, options);
|
|
764
762
|
}
|
|
765
763
|
else {
|
|
766
|
-
if (type & 4096
|
|
764
|
+
if (type & 4096) {
|
|
767
765
|
checkColorOptions(type, SETTINGS.exec, options);
|
|
768
766
|
}
|
|
769
|
-
else if (type & 32
|
|
767
|
+
else if (type & 32) {
|
|
770
768
|
checkColorOptions(type, SETTINGS.file, options);
|
|
771
769
|
}
|
|
772
|
-
else if (type & 2
|
|
770
|
+
else if (type & 2) {
|
|
773
771
|
if (!checkColorOptions(type, SETTINGS.node, options)) {
|
|
774
772
|
applyStyle(options, this.LOG_STYLE_REVERSE);
|
|
775
773
|
options.hintColor || (options.hintColor = 'yellow');
|
|
776
774
|
}
|
|
777
775
|
titleJustify = 'center';
|
|
778
776
|
}
|
|
779
|
-
else if (type & 1
|
|
777
|
+
else if (type & 1) {
|
|
780
778
|
checkColorOptions(type, SETTINGS.system, options);
|
|
781
779
|
if (options.titleBgColor) {
|
|
782
780
|
titleJustify = 'center';
|
|
783
781
|
}
|
|
784
782
|
}
|
|
785
|
-
if (type & 1024
|
|
783
|
+
if (type & 1024) {
|
|
786
784
|
checkColorOptions(type, SETTINGS.http, options);
|
|
787
785
|
}
|
|
788
|
-
else if (type & 64
|
|
786
|
+
else if (type & 64) {
|
|
789
787
|
checkColorOptions(type, SETTINGS.cloud, options);
|
|
790
788
|
}
|
|
791
|
-
else if (type & 65536
|
|
789
|
+
else if (type & 65536) {
|
|
792
790
|
checkColorOptions(type, SETTINGS.db, options);
|
|
793
791
|
}
|
|
794
|
-
else if (type & 16
|
|
792
|
+
else if (type & 16) {
|
|
795
793
|
checkColorOptions(type, SETTINGS.watch, options);
|
|
796
794
|
titleJustify = 'center';
|
|
797
795
|
}
|
|
798
|
-
else if (type & 2048
|
|
796
|
+
else if (type & 2048) {
|
|
799
797
|
checkColorOptions(type, SETTINGS.image, options);
|
|
800
798
|
}
|
|
801
|
-
else if (type & 8
|
|
799
|
+
else if (type & 8) {
|
|
802
800
|
checkColorOptions(type, SETTINGS.compress, options);
|
|
803
801
|
}
|
|
804
|
-
else if ((type & 4
|
|
802
|
+
else if ((type & 4) && !options.titleColor && !checkColorOptions(type, SETTINGS.process, options)) {
|
|
805
803
|
options.titleColor = 'magenta';
|
|
806
804
|
}
|
|
807
|
-
if (type & 128
|
|
805
|
+
if (type & 128) {
|
|
808
806
|
if (!checkColorOptions(type, SETTINGS.time_elapsed, options)) {
|
|
809
807
|
options.hintColor || (options.hintColor = 'yellow');
|
|
810
808
|
}
|
|
@@ -812,7 +810,7 @@ class Module extends EventEmitter {
|
|
|
812
810
|
titleJustify = 'center';
|
|
813
811
|
}
|
|
814
812
|
}
|
|
815
|
-
else if (type & 256
|
|
813
|
+
else if (type & 256) {
|
|
816
814
|
if (options.failed) {
|
|
817
815
|
options.messageBgColor || (options.messageBgColor = 'bgGrey');
|
|
818
816
|
}
|
|
@@ -851,8 +849,8 @@ class Module extends EventEmitter {
|
|
|
851
849
|
else if (title) {
|
|
852
850
|
value = getValue();
|
|
853
851
|
}
|
|
854
|
-
const unit = options.messageUnit ? type & 256
|
|
855
|
-
const getMessage = (m, u) => type & 256
|
|
852
|
+
const unit = options.messageUnit ? type & 256 ? options.messageUnit.padStart(options.messageUnitMinWidth || 0) : options.messageUnit : '';
|
|
853
|
+
const getMessage = (m, u) => type & 256 && messageUnitIndent === undefined ? (u + m).trimEnd() : u ? (m + (messageUnitIndent === undefined ? ' ' : '') + u).trimStart() : m;
|
|
856
854
|
if (coloring) {
|
|
857
855
|
let { titleColor, titleBgColor, valueColor, valueBgColor, valueBold, messageWidth, messageColor, messageBgColor, messageBold } = options;
|
|
858
856
|
if (!titleColor && !titleBgColor) {
|
|
@@ -912,12 +910,11 @@ class Module extends EventEmitter {
|
|
|
912
910
|
if (BROADCAST_OUT) {
|
|
913
911
|
try {
|
|
914
912
|
options = { ...options, broadcastId, timeStamp: getTimeStamp(options, false) };
|
|
915
|
-
|
|
916
|
-
if (BROADCAST_OUT["__cjs__" /* INTERNAL.CJS */]) {
|
|
913
|
+
if (BROADCAST_OUT["__cjs__"]) {
|
|
917
914
|
BROADCAST_OUT(output, options);
|
|
918
915
|
}
|
|
919
916
|
else {
|
|
920
|
-
BROADCAST_OUT.apply(VALUES["node.process.inline"
|
|
917
|
+
BROADCAST_OUT.apply(VALUES["node.process.inline"] ? process : null, VALUES["node.require.inline"] ? [output, options, require] : [output, options]);
|
|
921
918
|
}
|
|
922
919
|
}
|
|
923
920
|
catch {
|
|
@@ -936,7 +933,7 @@ class Module extends EventEmitter {
|
|
|
936
933
|
LOG_EMPTYLINE = true;
|
|
937
934
|
}
|
|
938
935
|
}
|
|
939
|
-
if (type & 512
|
|
936
|
+
if (type & 512) {
|
|
940
937
|
process.stderr.write((!LOG_NEWLINE ? '\n' : '') + output + '\n');
|
|
941
938
|
}
|
|
942
939
|
else if (typeof options.progressBar === 'boolean' && typeof PROCESS_STDOUT.clearLine === 'function') {
|
|
@@ -969,7 +966,7 @@ class Module extends EventEmitter {
|
|
|
969
966
|
}
|
|
970
967
|
options = {};
|
|
971
968
|
}
|
|
972
|
-
this.formatMessage(((type || 1
|
|
969
|
+
this.formatMessage(((type || 1) | 512), "FAIL!", value, message, applyStyle(options, this.LOG_STYLE_FAIL));
|
|
973
970
|
}
|
|
974
971
|
static parseFunction(value, absolute, sync = true) {
|
|
975
972
|
let context, requireExt, external;
|
|
@@ -977,7 +974,7 @@ class Module extends EventEmitter {
|
|
|
977
974
|
({ context, requireExt, external, absolute, sync = true } = absolute);
|
|
978
975
|
}
|
|
979
976
|
if (requireExt === undefined || requireExt === true) {
|
|
980
|
-
requireExt = VALUES["node.require.ext"
|
|
977
|
+
requireExt = VALUES["node.require.ext"];
|
|
981
978
|
}
|
|
982
979
|
let result = (0, types_1.asFunction)(value, sync);
|
|
983
980
|
if (!result && (0, types_1.isString)(value)) {
|
|
@@ -986,7 +983,7 @@ class Module extends EventEmitter {
|
|
|
986
983
|
location = location.substring(4);
|
|
987
984
|
}
|
|
988
985
|
else if (pathname = absolute && path.isAbsolute(location) ? location : this.fromLocalPath(location)) {
|
|
989
|
-
if (requireExt && VALUES["node.require.ext"
|
|
986
|
+
if (requireExt && VALUES["node.require.ext"] && hasString(requireExt, getExtension(pathname))) {
|
|
990
987
|
try {
|
|
991
988
|
result = checkFunction(require(pathname));
|
|
992
989
|
}
|
|
@@ -998,13 +995,12 @@ class Module extends EventEmitter {
|
|
|
998
995
|
result = (0, types_1.asFunction)(fs.readFileSync(pathname, 'utf-8'), sync);
|
|
999
996
|
}
|
|
1000
997
|
catch (err) {
|
|
1001
|
-
this.writeFail(["Unable to read file"
|
|
998
|
+
this.writeFail(["Unable to read file", value], err, 32);
|
|
1002
999
|
}
|
|
1003
1000
|
}
|
|
1004
1001
|
}
|
|
1005
|
-
if (external && !pathname && VALUES["node.require.npm"
|
|
1002
|
+
if (external && !pathname && VALUES["node.require.npm"] && /^(?:@[a-z\d-*~][a-z\d-*._~]*\/)?[a-z\d-~][a-z\d-._~]*(?:\/.*)?$/.test(location)) {
|
|
1006
1003
|
try {
|
|
1007
|
-
// @ts-ignore
|
|
1008
1004
|
result = checkFunction(require(types_1.IMPORT_MAP[location] || location));
|
|
1009
1005
|
}
|
|
1010
1006
|
catch {
|
|
@@ -1063,7 +1059,7 @@ class Module extends EventEmitter {
|
|
|
1063
1059
|
break;
|
|
1064
1060
|
}
|
|
1065
1061
|
if (cacheKey === 'throws') {
|
|
1066
|
-
throw new Error("Not able to cache"
|
|
1062
|
+
throw new Error("Not able to cache");
|
|
1067
1063
|
}
|
|
1068
1064
|
return cacheKey ? (0, types_1.generateUUID)() : '';
|
|
1069
1065
|
}
|
|
@@ -1258,7 +1254,7 @@ class Module extends EventEmitter {
|
|
|
1258
1254
|
let result = paths[0] || '';
|
|
1259
1255
|
for (let i = 1; i < paths.length; ++i) {
|
|
1260
1256
|
const trailing = paths[i];
|
|
1261
|
-
result += (trailing
|
|
1257
|
+
result += (!trailing.startsWith('/') && !result.endsWith('/') ? '/' : '') + trailing;
|
|
1262
1258
|
}
|
|
1263
1259
|
return result;
|
|
1264
1260
|
}
|
|
@@ -1282,7 +1278,7 @@ class Module extends EventEmitter {
|
|
|
1282
1278
|
return path.join(PROCESS_CWD, value);
|
|
1283
1279
|
}
|
|
1284
1280
|
if (ch === '~' && value[1] === '/') {
|
|
1285
|
-
return VALUES["permission.home_read"
|
|
1281
|
+
return VALUES["permission.home_read"] ? path.join(OS_HOMEDIR, value.substring(2)) : '';
|
|
1286
1282
|
}
|
|
1287
1283
|
try {
|
|
1288
1284
|
if (fs.existsSync(value = path.join(PROCESS_CWD, value))) {
|
|
@@ -1306,7 +1302,7 @@ class Module extends EventEmitter {
|
|
|
1306
1302
|
fs.unlinkSync(outDir);
|
|
1307
1303
|
}
|
|
1308
1304
|
catch {
|
|
1309
|
-
this.formatMessage(32
|
|
1305
|
+
this.formatMessage(32, 'WARN', "Unable to overwrite file", value, { ...this.LOG_STYLE_WARN });
|
|
1310
1306
|
return false;
|
|
1311
1307
|
}
|
|
1312
1308
|
}
|
|
@@ -1323,7 +1319,7 @@ class Module extends EventEmitter {
|
|
|
1323
1319
|
return tryCreateDir(outDir);
|
|
1324
1320
|
}
|
|
1325
1321
|
catch (err) {
|
|
1326
|
-
this.writeFail(["Unable to create directory"
|
|
1322
|
+
this.writeFail(["Unable to create directory", value], err, 32);
|
|
1327
1323
|
}
|
|
1328
1324
|
}
|
|
1329
1325
|
return false;
|
|
@@ -1345,19 +1341,19 @@ class Module extends EventEmitter {
|
|
|
1345
1341
|
}
|
|
1346
1342
|
}
|
|
1347
1343
|
catch (err) {
|
|
1348
|
-
this.writeFail(["Unable to remove directory"
|
|
1344
|
+
this.writeFail(["Unable to remove directory", value], err, 32);
|
|
1349
1345
|
}
|
|
1350
1346
|
}
|
|
1351
1347
|
return false;
|
|
1352
1348
|
}
|
|
1353
|
-
static copyDir(src, dest, move, recursive = true) {
|
|
1349
|
+
static async copyDir(src, dest, move, recursive = true) {
|
|
1354
1350
|
const srcOut = sanitizePath(asFile(src));
|
|
1355
1351
|
if (!srcOut || !this.isDir(srcOut)) {
|
|
1356
|
-
return Promise.reject(errorDirectory(asFile(src) || "Unknown"
|
|
1352
|
+
return Promise.reject(errorDirectory(asFile(src) || "Unknown"));
|
|
1357
1353
|
}
|
|
1358
1354
|
const destOut = sanitizePath(asFile(dest));
|
|
1359
1355
|
if (!destOut || !this.createDir(destOut)) {
|
|
1360
|
-
return Promise.reject(errorDirectory(asFile(dest) || "Unknown"
|
|
1356
|
+
return Promise.reject(errorDirectory(asFile(dest) || "Unknown"));
|
|
1361
1357
|
}
|
|
1362
1358
|
let symFile, symDir, ignoreFile, ignoreDir, silent, overwrite;
|
|
1363
1359
|
if ((0, types_1.isObject)(move)) {
|
|
@@ -1428,7 +1424,7 @@ class Module extends EventEmitter {
|
|
|
1428
1424
|
.catch(err => {
|
|
1429
1425
|
failed.push(srcPath);
|
|
1430
1426
|
if (!silent) {
|
|
1431
|
-
this.writeFail([move ? "Unable to move file"
|
|
1427
|
+
this.writeFail([move ? "Unable to move file" : "Unable to copy file", path.basename(srcPath)], err, 32);
|
|
1432
1428
|
}
|
|
1433
1429
|
}));
|
|
1434
1430
|
}
|
|
@@ -1443,7 +1439,7 @@ class Module extends EventEmitter {
|
|
|
1443
1439
|
catch (err) {
|
|
1444
1440
|
failed.push(srcDir);
|
|
1445
1441
|
if (!silent) {
|
|
1446
|
-
this.writeFail(["Unable to read directory"
|
|
1442
|
+
this.writeFail(["Unable to read directory", path.basename(srcDir)], err, 32);
|
|
1447
1443
|
}
|
|
1448
1444
|
}
|
|
1449
1445
|
}
|
|
@@ -1495,7 +1491,7 @@ class Module extends EventEmitter {
|
|
|
1495
1491
|
}
|
|
1496
1492
|
catch (error) {
|
|
1497
1493
|
if (copied) {
|
|
1498
|
-
this.formatMessage(32
|
|
1494
|
+
this.formatMessage(32, 'WARN', ["Unable to delete file", path.basename(src instanceof URL ? url.fileURLToPath(src) : src)], error, { ...this.LOG_STYLE_WARN });
|
|
1499
1495
|
throws = false;
|
|
1500
1496
|
}
|
|
1501
1497
|
}
|
|
@@ -1525,7 +1521,7 @@ class Module extends EventEmitter {
|
|
|
1525
1521
|
return result;
|
|
1526
1522
|
}
|
|
1527
1523
|
catch (err) {
|
|
1528
|
-
this.writeFail(["Unable to read file"
|
|
1524
|
+
this.writeFail(["Unable to read file", path.basename(src)], err, 32);
|
|
1529
1525
|
}
|
|
1530
1526
|
}
|
|
1531
1527
|
return '';
|
|
@@ -1545,19 +1541,19 @@ class Module extends EventEmitter {
|
|
|
1545
1541
|
return result;
|
|
1546
1542
|
}
|
|
1547
1543
|
catch (err) {
|
|
1548
|
-
this.writeFail(["Unable to read file"
|
|
1544
|
+
this.writeFail(["Unable to read file", path.basename(src)], err, 32);
|
|
1549
1545
|
}
|
|
1550
1546
|
}
|
|
1551
1547
|
return null;
|
|
1552
1548
|
}
|
|
1553
|
-
static resolveMime(data) {
|
|
1549
|
+
static async resolveMime(data) {
|
|
1554
1550
|
return typeof data === 'string' ? filetype.fromFile(data) : filetype.fromBuffer(data);
|
|
1555
1551
|
}
|
|
1556
1552
|
static lookupMime(value, extension) {
|
|
1557
1553
|
return (extension ? mime.extension(value) : mime.lookup(value)) || '';
|
|
1558
1554
|
}
|
|
1559
1555
|
static initCpuUsage(instance) {
|
|
1560
|
-
if (!VALUES["node.process.cpu_usage"
|
|
1556
|
+
if (!VALUES["node.process.cpu_usage"]) {
|
|
1561
1557
|
return { user: 0, system: 0 };
|
|
1562
1558
|
}
|
|
1563
1559
|
const result = process.cpuUsage();
|
|
@@ -1568,7 +1564,7 @@ class Module extends EventEmitter {
|
|
|
1568
1564
|
return result;
|
|
1569
1565
|
}
|
|
1570
1566
|
static getCpuUsage(start, format) {
|
|
1571
|
-
if (VALUES["node.process.cpu_usage"
|
|
1567
|
+
if (VALUES["node.process.cpu_usage"]) {
|
|
1572
1568
|
let value = CACHE_CPU.get(start);
|
|
1573
1569
|
if (value === undefined) {
|
|
1574
1570
|
CACHE_CPU.set(start, getCpuTimes());
|
|
@@ -1586,7 +1582,7 @@ class Module extends EventEmitter {
|
|
|
1586
1582
|
return format ? '' : 0;
|
|
1587
1583
|
}
|
|
1588
1584
|
static getMemUsage(format) {
|
|
1589
|
-
if (!VALUES["node.process.memory_usage"
|
|
1585
|
+
if (!VALUES["node.process.memory_usage"]) {
|
|
1590
1586
|
return format ? '' : 0;
|
|
1591
1587
|
}
|
|
1592
1588
|
const usage = process.memoryUsage();
|
|
@@ -1624,24 +1620,24 @@ class Module extends EventEmitter {
|
|
|
1624
1620
|
if (!cpu_single_core) {
|
|
1625
1621
|
usage /= CPU_CORETOTAL;
|
|
1626
1622
|
}
|
|
1627
|
-
if (usage + 0.005
|
|
1623
|
+
if (usage + 0.005 >= 1) {
|
|
1628
1624
|
usage = 1;
|
|
1629
1625
|
}
|
|
1630
|
-
let bar = 20
|
|
1626
|
+
let bar = 20, red = 0.9, yellow = 0.75;
|
|
1631
1627
|
if (typeof cpu_bar === 'number') {
|
|
1632
1628
|
bar = cpu_bar;
|
|
1633
1629
|
}
|
|
1634
|
-
else if (Array.isArray(cpu_bar) && cpu_bar[0] >= 10
|
|
1630
|
+
else if (Array.isArray(cpu_bar) && cpu_bar[0] >= 10) {
|
|
1635
1631
|
let r, y;
|
|
1636
|
-
[bar, r = 0.9
|
|
1632
|
+
[bar, r = 0.9, y = 0.75] = cpu_bar;
|
|
1637
1633
|
if (r > 0 && r < 1 && y > 0 && y < 1 && y < r) {
|
|
1638
1634
|
red = r;
|
|
1639
1635
|
yellow = y;
|
|
1640
1636
|
}
|
|
1641
1637
|
}
|
|
1642
|
-
const unit = Math.max(bar, 10
|
|
1638
|
+
const unit = Math.max(bar, 10);
|
|
1643
1639
|
const length = Math.floor(usage * unit);
|
|
1644
|
-
const hint = usage === 1 ? "MAX"
|
|
1640
|
+
const hint = usage === 1 ? "MAX" : usage < 0 ? "N/A" : formatPercent(usage, 2);
|
|
1645
1641
|
result += chalk[usage >= red ? 'bgRed' : usage >= yellow ? 'bgYellow' : 'bgBlue'].white(':'.repeat(length)) + chalk.bgGrey.white(':'.repeat(unit - length)) + (hint ? chalk.bgWhite.grey(` ${hint} `) : '');
|
|
1646
1642
|
}
|
|
1647
1643
|
else if (usage) {
|
|
@@ -1836,7 +1832,7 @@ class Module extends EventEmitter {
|
|
|
1836
1832
|
return true;
|
|
1837
1833
|
}
|
|
1838
1834
|
static sanitizeCmd(value) {
|
|
1839
|
-
if (value.
|
|
1835
|
+
if (value.includes(' ')) {
|
|
1840
1836
|
return PLATFORM_WIN32 ? wrapQuote(value) : value.replace(/[ ]/g, '\\ ');
|
|
1841
1837
|
}
|
|
1842
1838
|
return value;
|
|
@@ -1867,7 +1863,7 @@ class Module extends EventEmitter {
|
|
|
1867
1863
|
}
|
|
1868
1864
|
value = quoted[2];
|
|
1869
1865
|
}
|
|
1870
|
-
if (value.
|
|
1866
|
+
if (value.includes(' ')) {
|
|
1871
1867
|
value = wrapQuote(value);
|
|
1872
1868
|
}
|
|
1873
1869
|
}
|
|
@@ -1902,7 +1898,7 @@ class Module extends EventEmitter {
|
|
|
1902
1898
|
}
|
|
1903
1899
|
return (typeof values === 'string' ? result[0] : result);
|
|
1904
1900
|
}
|
|
1905
|
-
static purgeMemory(percent = 1, limit = 0) {
|
|
1901
|
+
static async purgeMemory(percent = 1, limit = 0) {
|
|
1906
1902
|
if (typeof limit === 'boolean') {
|
|
1907
1903
|
limit = 0;
|
|
1908
1904
|
}
|
|
@@ -1940,22 +1936,22 @@ class Module extends EventEmitter {
|
|
|
1940
1936
|
static canWrite(name) {
|
|
1941
1937
|
switch (name) {
|
|
1942
1938
|
case 'temp':
|
|
1943
|
-
return VALUES["temp.write"
|
|
1939
|
+
return VALUES["temp.write"];
|
|
1944
1940
|
case 'home':
|
|
1945
|
-
return VALUES["permission.home_write"
|
|
1941
|
+
return VALUES["permission.home_write"];
|
|
1946
1942
|
default:
|
|
1947
1943
|
return false;
|
|
1948
1944
|
}
|
|
1949
1945
|
}
|
|
1950
1946
|
static loadSettings(settings, password) {
|
|
1951
1947
|
var _h;
|
|
1952
|
-
const current = VALUES["process.password"
|
|
1948
|
+
const current = VALUES["process.password"];
|
|
1953
1949
|
if (current) {
|
|
1954
1950
|
const proc = settings.process || {};
|
|
1955
1951
|
if (!password && !(password = proc.password)) {
|
|
1956
1952
|
return false;
|
|
1957
1953
|
}
|
|
1958
|
-
const algorithm = VALUES["process.cipher.algorithm"
|
|
1954
|
+
const algorithm = VALUES["process.cipher.algorithm"];
|
|
1959
1955
|
if (algorithm) {
|
|
1960
1956
|
password = encryptMessage(password, proc.cipher, algorithm);
|
|
1961
1957
|
}
|
|
@@ -1964,7 +1960,7 @@ class Module extends EventEmitter {
|
|
|
1964
1960
|
}
|
|
1965
1961
|
}
|
|
1966
1962
|
else if ((0, types_1.isString)(password)) {
|
|
1967
|
-
VALUES["process.password"
|
|
1963
|
+
VALUES["process.password"] = encryptMessage(password, settings.process?.cipher);
|
|
1968
1964
|
}
|
|
1969
1965
|
const { temp, node, permission, memory, error, logger } = settings;
|
|
1970
1966
|
if ((0, types_1.isPlainObject)(node)) {
|
|
@@ -1972,51 +1968,51 @@ class Module extends EventEmitter {
|
|
|
1972
1968
|
if ((0, types_1.isPlainObject)(proc)) {
|
|
1973
1969
|
const { cpu_usage, memory_usage, inline } = proc;
|
|
1974
1970
|
if (typeof cpu_usage === 'boolean') {
|
|
1975
|
-
VALUES["node.process.cpu_usage"
|
|
1971
|
+
VALUES["node.process.cpu_usage"] = cpu_usage;
|
|
1976
1972
|
}
|
|
1977
1973
|
if (typeof memory_usage === 'boolean') {
|
|
1978
|
-
VALUES["node.process.memory_usage"
|
|
1974
|
+
VALUES["node.process.memory_usage"] = memory_usage;
|
|
1979
1975
|
}
|
|
1980
1976
|
if (typeof inline === 'boolean') {
|
|
1981
|
-
VALUES["node.process.inline"
|
|
1977
|
+
VALUES["node.process.inline"] = inline;
|
|
1982
1978
|
}
|
|
1983
1979
|
}
|
|
1984
1980
|
if ((0, types_1.isPlainObject)(req)) {
|
|
1985
1981
|
const { ext, npm, inline } = req;
|
|
1986
1982
|
if (!ext) {
|
|
1987
|
-
VALUES["node.require.ext"
|
|
1983
|
+
VALUES["node.require.ext"] = '';
|
|
1988
1984
|
}
|
|
1989
1985
|
else if (typeof ext === 'string') {
|
|
1990
|
-
VALUES["node.require.ext"
|
|
1986
|
+
VALUES["node.require.ext"] = ext.trim().toLowerCase();
|
|
1991
1987
|
}
|
|
1992
1988
|
else if (Array.isArray(ext)) {
|
|
1993
1989
|
const items = ext.map(value => (0, types_1.isString)(value) ? value.trim().toLowerCase() : '').filter(value => value);
|
|
1994
|
-
VALUES["node.require.ext"
|
|
1990
|
+
VALUES["node.require.ext"] = items.length ? items : '';
|
|
1995
1991
|
}
|
|
1996
1992
|
else {
|
|
1997
|
-
VALUES["node.require.ext"
|
|
1993
|
+
VALUES["node.require.ext"] = 'cjs';
|
|
1998
1994
|
}
|
|
1999
1995
|
if (typeof npm === 'boolean') {
|
|
2000
|
-
VALUES["node.require.npm"
|
|
1996
|
+
VALUES["node.require.npm"] = npm;
|
|
2001
1997
|
}
|
|
2002
1998
|
if (typeof inline === 'boolean') {
|
|
2003
|
-
VALUES["node.require.inline"
|
|
1999
|
+
VALUES["node.require.inline"] = inline;
|
|
2004
2000
|
}
|
|
2005
2001
|
}
|
|
2006
2002
|
}
|
|
2007
2003
|
if ((0, types_1.isPlainObject)(settings.process)) {
|
|
2008
2004
|
const { env, cipher, password: pwd } = settings.process;
|
|
2009
2005
|
if (env && typeof env.apply === 'boolean') {
|
|
2010
|
-
VALUES["process.env.apply"
|
|
2006
|
+
VALUES["process.env.apply"] = env.apply;
|
|
2011
2007
|
}
|
|
2012
2008
|
if ((0, types_1.isString)(pwd)) {
|
|
2013
|
-
VALUES[_h = "process.password"
|
|
2009
|
+
VALUES[_h = "process.password"] || (VALUES[_h] = encryptMessage(pwd, cipher));
|
|
2014
2010
|
}
|
|
2015
2011
|
}
|
|
2016
2012
|
if (memory && (0, types_1.isPlainObject)(memory.settings)) {
|
|
2017
2013
|
const users = memory.settings.users;
|
|
2018
2014
|
if (typeof users === 'boolean' || Array.isArray(users)) {
|
|
2019
|
-
VALUES["memory.settings.users"
|
|
2015
|
+
VALUES["memory.settings.users"] = users;
|
|
2020
2016
|
}
|
|
2021
2017
|
}
|
|
2022
2018
|
if ((0, types_1.isPlainObject)(logger)) {
|
|
@@ -2027,7 +2023,7 @@ class Module extends EventEmitter {
|
|
|
2027
2023
|
if (level !== undefined) {
|
|
2028
2024
|
const value = (0, types_1.isString)(level) ? types_1.STATUS_TYPE[level.trim().toUpperCase()] : level;
|
|
2029
2025
|
if (value >= -1 && value <= types_1.STATUS_TYPE.TRACE) {
|
|
2030
|
-
VALUES["logger.level"
|
|
2026
|
+
VALUES["logger.level"] = value;
|
|
2031
2027
|
}
|
|
2032
2028
|
}
|
|
2033
2029
|
if (Array.isArray(production)) {
|
|
@@ -2151,7 +2147,7 @@ class Module extends EventEmitter {
|
|
|
2151
2147
|
}
|
|
2152
2148
|
}
|
|
2153
2149
|
if (broadcast?.out) {
|
|
2154
|
-
VALUES["broadcast.out"
|
|
2150
|
+
VALUES["broadcast.out"] = this.parseFunction(broadcast.out, { external: true, absolute: true });
|
|
2155
2151
|
}
|
|
2156
2152
|
if (stack_trace && stack_trace !== true && +stack_trace > 0) {
|
|
2157
2153
|
Error.stackTraceLimit = +stack_trace;
|
|
@@ -2159,23 +2155,32 @@ class Module extends EventEmitter {
|
|
|
2159
2155
|
}
|
|
2160
2156
|
if (error) {
|
|
2161
2157
|
if (error.out) {
|
|
2162
|
-
VALUES["error.out"
|
|
2158
|
+
VALUES["error.out"] = this.parseFunction(error.out, { external: true, absolute: true });
|
|
2163
2159
|
}
|
|
2164
2160
|
if (typeof error.fatal === 'boolean') {
|
|
2165
|
-
VALUES["error.fatal"
|
|
2161
|
+
VALUES["error.fatal"] = error.fatal;
|
|
2166
2162
|
}
|
|
2167
2163
|
}
|
|
2168
|
-
if (permission
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2164
|
+
if (permission) {
|
|
2165
|
+
const { home_read, home_write } = permission;
|
|
2166
|
+
if (typeof home_read === 'boolean') {
|
|
2167
|
+
VALUES["permission.home_read"] = home_read;
|
|
2168
|
+
}
|
|
2169
|
+
if (typeof home_write === 'boolean') {
|
|
2170
|
+
VALUES["permission.home_write"] = home_write;
|
|
2171
|
+
}
|
|
2172
|
+
if (Array.isArray(permission.process_exec)) {
|
|
2173
|
+
VALUES["permission.process_exec"] = permission.process_exec.filter(item => typeof item === 'string' || (0, types_1.isObject)(item) && typeof item.command === 'string').map(exec => {
|
|
2174
|
+
if (typeof exec === 'string') {
|
|
2175
|
+
return exec.trim();
|
|
2176
|
+
}
|
|
2177
|
+
if (typeof exec.warn === 'string') {
|
|
2178
|
+
exec.warn = [exec.warn];
|
|
2179
|
+
}
|
|
2180
|
+
exec.command = exec.command.trim();
|
|
2181
|
+
return exec;
|
|
2182
|
+
});
|
|
2183
|
+
}
|
|
2179
2184
|
}
|
|
2180
2185
|
{
|
|
2181
2186
|
let dir = settings.temp_dir, write;
|
|
@@ -2189,16 +2194,16 @@ class Module extends EventEmitter {
|
|
|
2189
2194
|
dir = dir.substring(ensureDir(PROCESS_CWD).length);
|
|
2190
2195
|
}
|
|
2191
2196
|
else {
|
|
2192
|
-
this.formatMessage(1
|
|
2197
|
+
this.formatMessage(1, 'WARN', 'Temp directory can only be relative', dir, { ...this.LOG_STYLE_WARN, newline: true });
|
|
2193
2198
|
dir = undefined;
|
|
2194
2199
|
}
|
|
2195
2200
|
}
|
|
2196
2201
|
if (!(0, types_1.isString)(dir)) {
|
|
2197
|
-
dir = VALUES["temp.dir"
|
|
2202
|
+
dir = VALUES["temp.dir"];
|
|
2198
2203
|
}
|
|
2199
2204
|
if (typeof write === 'boolean') {
|
|
2200
|
-
modified = VALUES["temp.write"
|
|
2201
|
-
VALUES["temp.write"
|
|
2205
|
+
modified = VALUES["temp.write"] !== write;
|
|
2206
|
+
VALUES["temp.write"] = write;
|
|
2202
2207
|
}
|
|
2203
2208
|
do {
|
|
2204
2209
|
const [output, index] = tryIncrementDir(path.join(PROCESS_CWD, dir), 5);
|
|
@@ -2206,19 +2211,19 @@ class Module extends EventEmitter {
|
|
|
2206
2211
|
if (index > 0) {
|
|
2207
2212
|
dir = trimDir(dir) + '_' + index;
|
|
2208
2213
|
}
|
|
2209
|
-
if (dir !== VALUES["temp.dir"
|
|
2210
|
-
VALUES["temp.dir"
|
|
2214
|
+
if (dir !== VALUES["temp.dir"]) {
|
|
2215
|
+
VALUES["temp.dir"] = dir;
|
|
2211
2216
|
modified = true;
|
|
2212
2217
|
}
|
|
2213
2218
|
(0, types_1.setTempDir)(TEMP_DIR = output);
|
|
2214
2219
|
break;
|
|
2215
2220
|
}
|
|
2216
2221
|
if (output instanceof Error) {
|
|
2217
|
-
this.writeFail(["Unable to create temp directory"
|
|
2222
|
+
this.writeFail(["Unable to create temp directory", dir], output, 32);
|
|
2218
2223
|
}
|
|
2219
|
-
} while ((dir !== "tmp"
|
|
2224
|
+
} while ((dir !== "tmp") && (dir = "tmp"));
|
|
2220
2225
|
if (modified) {
|
|
2221
|
-
this.formatMessage(1
|
|
2226
|
+
this.formatMessage(1, 'TEMP', ["Directory was modified", dir], TEMP_DIR + (VALUES["temp.write"] ? ' - writeable' : ''), { ...this.LOG_STYLE_NOTICE, newline: true });
|
|
2222
2227
|
}
|
|
2223
2228
|
settings.temp_dir = dir;
|
|
2224
2229
|
if ((0, types_1.isPlainObject)(temp)) {
|
|
@@ -2271,7 +2276,7 @@ class Module extends EventEmitter {
|
|
|
2271
2276
|
const [output] = tryIncrementDir(result, increment);
|
|
2272
2277
|
if (!(0, types_1.isString)(output)) {
|
|
2273
2278
|
if (output instanceof Error) {
|
|
2274
|
-
this.writeFail(["Unable to create temp directory"
|
|
2279
|
+
this.writeFail(["Unable to create temp directory", result], output, 32);
|
|
2275
2280
|
}
|
|
2276
2281
|
return '';
|
|
2277
2282
|
}
|
|
@@ -2305,7 +2310,7 @@ class Module extends EventEmitter {
|
|
|
2305
2310
|
if (permission && (Module.isFile(uri, 'unc') ? permission.hasUNCRead(path.normalize(uri)) || ownPermissionOnly && !permission.getUNCRead() : path.isAbsolute(uri = path.resolve(uri)) && (permission.hasDiskRead(uri) || ownPermissionOnly && !permission.getDiskRead()))) {
|
|
2306
2311
|
return true;
|
|
2307
2312
|
}
|
|
2308
|
-
return VALUES["permission.home_read"
|
|
2313
|
+
return VALUES["permission.home_read"] && withinDir(uri, OS_HOMEDIR);
|
|
2309
2314
|
}
|
|
2310
2315
|
canWrite(uri, options) {
|
|
2311
2316
|
let permission = this.permission, ownPermissionOnly = false;
|
|
@@ -2326,12 +2331,12 @@ class Module extends EventEmitter {
|
|
|
2326
2331
|
if (permission && (Module.isFile(uri, 'unc') ? permission.hasUNCWrite(path.normalize(uri)) || ownPermissionOnly && !permission.getUNCWrite() : path.isAbsolute(uri = path.resolve(uri)) && (permission.hasDiskWrite(uri) || ownPermissionOnly && !permission.getDiskWrite()))) {
|
|
2327
2332
|
return true;
|
|
2328
2333
|
}
|
|
2329
|
-
return VALUES["temp.write"
|
|
2334
|
+
return VALUES["temp.write"] && withinDir(uri, TEMP_DIR) || VALUES["permission.home_write"] && withinDir(uri, OS_HOMEDIR);
|
|
2330
2335
|
}
|
|
2331
2336
|
readFile(src, options = {}, callback) {
|
|
2332
2337
|
let promises, outSrc;
|
|
2333
2338
|
[options, promises, callback] = parseFileArgs(options, callback);
|
|
2334
|
-
if (outSrc = hasFileSystem.call(this, 0
|
|
2339
|
+
if (outSrc = hasFileSystem.call(this, 0, src, options)) {
|
|
2335
2340
|
const { requireExt, cache } = options;
|
|
2336
2341
|
const encoding = options.encoding && (0, types_1.getEncoding)(options.encoding);
|
|
2337
2342
|
const setCache = (data, cjs) => {
|
|
@@ -2343,7 +2348,7 @@ class Module extends EventEmitter {
|
|
|
2343
2348
|
}
|
|
2344
2349
|
};
|
|
2345
2350
|
let result;
|
|
2346
|
-
if (requireExt && VALUES["node.require.ext"
|
|
2351
|
+
if (requireExt && VALUES["node.require.ext"] && hasString(requireExt === true ? VALUES["node.require.ext"] : requireExt, getExtension(src))) {
|
|
2347
2352
|
if (cache) {
|
|
2348
2353
|
result = getCacheItem(CACHE_READCJS, outSrc);
|
|
2349
2354
|
}
|
|
@@ -2371,7 +2376,7 @@ class Module extends EventEmitter {
|
|
|
2371
2376
|
}
|
|
2372
2377
|
if (isFunction(callback)) {
|
|
2373
2378
|
if (result) {
|
|
2374
|
-
callback(null, result);
|
|
2379
|
+
(callback)(null, result);
|
|
2375
2380
|
}
|
|
2376
2381
|
else {
|
|
2377
2382
|
fs.readFile(outSrc, encoding, (err, data) => {
|
|
@@ -2390,7 +2395,7 @@ class Module extends EventEmitter {
|
|
|
2390
2395
|
return result;
|
|
2391
2396
|
}
|
|
2392
2397
|
catch (err) {
|
|
2393
|
-
this.writeFail(["Unable to read file"
|
|
2398
|
+
this.writeFail(["Unable to read file", path.basename(src)], err, 32);
|
|
2394
2399
|
}
|
|
2395
2400
|
}
|
|
2396
2401
|
else if (promises) {
|
|
@@ -2403,7 +2408,7 @@ class Module extends EventEmitter {
|
|
|
2403
2408
|
writeFile(src, data, options = {}, callback) {
|
|
2404
2409
|
let promises, outSrc;
|
|
2405
2410
|
[options, promises, callback] = parseFileArgs(options, callback);
|
|
2406
|
-
if (outSrc = hasFileSystem.call(this, 1
|
|
2411
|
+
if (outSrc = hasFileSystem.call(this, 1, src, options, true, options.overwrite)) {
|
|
2407
2412
|
if (promises) {
|
|
2408
2413
|
return fs.promises.writeFile(outSrc, data, options.encoding).then(() => {
|
|
2409
2414
|
this.emit('file:write', outSrc, options);
|
|
@@ -2425,7 +2430,7 @@ class Module extends EventEmitter {
|
|
|
2425
2430
|
return true;
|
|
2426
2431
|
}
|
|
2427
2432
|
catch (err) {
|
|
2428
|
-
this.writeFail(["Unable to write file"
|
|
2433
|
+
this.writeFail(["Unable to write file", path.basename(src)], err, 32);
|
|
2429
2434
|
}
|
|
2430
2435
|
}
|
|
2431
2436
|
else if (promises) {
|
|
@@ -2440,7 +2445,7 @@ class Module extends EventEmitter {
|
|
|
2440
2445
|
deleteFile(src, options = {}, callback) {
|
|
2441
2446
|
let promises, outSrc;
|
|
2442
2447
|
[options, promises, callback] = parseFileArgs(options, callback);
|
|
2443
|
-
if (outSrc = hasFileSystem.call(this, 1
|
|
2448
|
+
if (outSrc = hasFileSystem.call(this, 1, src, options)) {
|
|
2444
2449
|
if (promises) {
|
|
2445
2450
|
return fs.promises.unlink(outSrc).then(() => {
|
|
2446
2451
|
this.emit('file:delete', outSrc, options);
|
|
@@ -2461,7 +2466,7 @@ class Module extends EventEmitter {
|
|
|
2461
2466
|
}
|
|
2462
2467
|
catch (err) {
|
|
2463
2468
|
if (!Module.isErrorCode(err, 'ENOENT')) {
|
|
2464
|
-
this.writeFail(["Unable to delete file"
|
|
2469
|
+
this.writeFail(["Unable to delete file", path.basename(src)], err, 32);
|
|
2465
2470
|
return false;
|
|
2466
2471
|
}
|
|
2467
2472
|
}
|
|
@@ -2480,7 +2485,7 @@ class Module extends EventEmitter {
|
|
|
2480
2485
|
copyFile(src, dest, options = {}, callback) {
|
|
2481
2486
|
let promises, outSrc, outDest;
|
|
2482
2487
|
[options, promises, callback] = parseFileArgs(options, callback);
|
|
2483
|
-
if ((outSrc = hasFileSystem.call(this, 0
|
|
2488
|
+
if ((outSrc = hasFileSystem.call(this, 0, src, options)) && (outDest = hasFileSystem.call(this, 1, dest, options, true, options.overwrite))) {
|
|
2484
2489
|
const destDir = path.dirname(outDest);
|
|
2485
2490
|
if (!Module.isDir(destDir) && (options.createDir === false || !Module.createDir(destDir))) {
|
|
2486
2491
|
if (promises) {
|
|
@@ -2517,7 +2522,7 @@ class Module extends EventEmitter {
|
|
|
2517
2522
|
return true;
|
|
2518
2523
|
}
|
|
2519
2524
|
catch (err) {
|
|
2520
|
-
this.writeFail(["Unable to copy file"
|
|
2525
|
+
this.writeFail(["Unable to copy file", dest], err, 32);
|
|
2521
2526
|
}
|
|
2522
2527
|
}
|
|
2523
2528
|
}
|
|
@@ -2533,7 +2538,7 @@ class Module extends EventEmitter {
|
|
|
2533
2538
|
moveFile(src, dest, options = {}, callback) {
|
|
2534
2539
|
let promises, outSrc, outDest;
|
|
2535
2540
|
[options, promises, callback] = parseFileArgs(options, callback);
|
|
2536
|
-
if ((outSrc = hasFileSystem.call(this, 1
|
|
2541
|
+
if ((outSrc = hasFileSystem.call(this, 1, src, options)) && (outDest = hasFileSystem.call(this, 1, dest, options, true, options.overwrite))) {
|
|
2537
2542
|
const destDir = path.dirname(outDest);
|
|
2538
2543
|
if (!Module.isDir(destDir) && (options.createDir === false || !Module.createDir(destDir))) {
|
|
2539
2544
|
if (promises) {
|
|
@@ -2600,7 +2605,7 @@ class Module extends EventEmitter {
|
|
|
2600
2605
|
this.emit('file:move', outDest, options);
|
|
2601
2606
|
return true;
|
|
2602
2607
|
}
|
|
2603
|
-
this.writeFail(["Unable to move file"
|
|
2608
|
+
this.writeFail(["Unable to move file", dest], err, 32);
|
|
2604
2609
|
}
|
|
2605
2610
|
}
|
|
2606
2611
|
}
|
|
@@ -2621,7 +2626,7 @@ class Module extends EventEmitter {
|
|
|
2621
2626
|
createDir(src, options = {}, callback) {
|
|
2622
2627
|
let promises, outSrc;
|
|
2623
2628
|
[options, promises, callback] = parseFileArgs(options, callback);
|
|
2624
|
-
if (outSrc = hasFileSystem.call(this, 1
|
|
2629
|
+
if (outSrc = hasFileSystem.call(this, 1, src, options, true)) {
|
|
2625
2630
|
if (Module.isDir(outSrc)) {
|
|
2626
2631
|
if (promises) {
|
|
2627
2632
|
return Promise.resolve(true);
|
|
@@ -2668,7 +2673,7 @@ class Module extends EventEmitter {
|
|
|
2668
2673
|
}
|
|
2669
2674
|
}
|
|
2670
2675
|
catch (err) {
|
|
2671
|
-
this.writeFail(["Unable to create directory"
|
|
2676
|
+
this.writeFail(["Unable to create directory", src], err, 32);
|
|
2672
2677
|
}
|
|
2673
2678
|
}
|
|
2674
2679
|
else if (promises) {
|
|
@@ -2683,11 +2688,11 @@ class Module extends EventEmitter {
|
|
|
2683
2688
|
removeDir(src, options = {}, callback) {
|
|
2684
2689
|
let promises, outSrc;
|
|
2685
2690
|
[options, promises, callback] = parseFileArgs(options, callback);
|
|
2686
|
-
if (outSrc = hasFileSystem.call(this, 1
|
|
2691
|
+
if (outSrc = hasFileSystem.call(this, 1, src, options, true)) {
|
|
2687
2692
|
try {
|
|
2688
2693
|
if (Module.isDir(outSrc)) {
|
|
2689
2694
|
const { emptyDir = false, recursive = true } = options;
|
|
2690
|
-
const errorResponse = (failed) => new Error("Unsupported access"
|
|
2695
|
+
const errorResponse = (failed) => new Error("Unsupported access" + ':' + (failed.length > 1 ? failed.map(value => `\n- ${value}`) : ' ' + failed[0]));
|
|
2691
2696
|
if (promises || isFunction(callback)) {
|
|
2692
2697
|
const result = new Promise((resolve, reject) => {
|
|
2693
2698
|
const failed = tryRemoveDir(outSrc, emptyDir, !!recursive);
|
|
@@ -2738,7 +2743,7 @@ class Module extends EventEmitter {
|
|
|
2738
2743
|
}
|
|
2739
2744
|
}
|
|
2740
2745
|
catch (err) {
|
|
2741
|
-
this.writeFail(["Unable to remove directory"
|
|
2746
|
+
this.writeFail(["Unable to remove directory", src], err, 32);
|
|
2742
2747
|
}
|
|
2743
2748
|
}
|
|
2744
2749
|
else if (promises) {
|
|
@@ -2750,8 +2755,8 @@ class Module extends EventEmitter {
|
|
|
2750
2755
|
}
|
|
2751
2756
|
return false;
|
|
2752
2757
|
}
|
|
2753
|
-
allSettled(tasks, rejected, options) {
|
|
2754
|
-
rejected || (rejected = "Unknown"
|
|
2758
|
+
async allSettled(tasks, rejected, options) {
|
|
2759
|
+
rejected || (rejected = "Unknown");
|
|
2755
2760
|
return Promise.allSettled(tasks).then(result => {
|
|
2756
2761
|
const items = [];
|
|
2757
2762
|
for (const item of result) {
|
|
@@ -2780,16 +2785,16 @@ class Module extends EventEmitter {
|
|
|
2780
2785
|
}
|
|
2781
2786
|
options = {};
|
|
2782
2787
|
}
|
|
2783
|
-
this.formatFail(type || types_1.LOG_TYPE.SYSTEM, "FAIL!"
|
|
2788
|
+
this.formatFail(type || types_1.LOG_TYPE.SYSTEM, "FAIL!", value, message, options);
|
|
2784
2789
|
}
|
|
2785
2790
|
writeTimeProcess(title, value, startTime, options = {}) {
|
|
2786
2791
|
const { type = 0, statusType = 0 } = options;
|
|
2787
|
-
const http = type & 1024
|
|
2792
|
+
const http = type & 1024;
|
|
2788
2793
|
const meter = SETTINGS.meter;
|
|
2789
2794
|
const failed = isFailed(options);
|
|
2790
2795
|
const increment = options.meterIncrement || (http ? meter.http
|
|
2791
|
-
: type & 2048
|
|
2792
|
-
: type & 8
|
|
2796
|
+
: type & 2048 ? meter.image
|
|
2797
|
+
: type & 8 ? meter.compress
|
|
2793
2798
|
: meter.process) || 250;
|
|
2794
2799
|
const duration = getTimeOffset(startTime);
|
|
2795
2800
|
let meterTime = duration, delayTime = options.delayTime;
|
|
@@ -2808,10 +2813,10 @@ class Module extends EventEmitter {
|
|
|
2808
2813
|
}
|
|
2809
2814
|
}
|
|
2810
2815
|
if (failed && !http) {
|
|
2811
|
-
value = "Failed"
|
|
2816
|
+
value = "Failed" + ' -> ' + value;
|
|
2812
2817
|
}
|
|
2813
2818
|
const args = [
|
|
2814
|
-
(256
|
|
2819
|
+
(256 | type),
|
|
2815
2820
|
title,
|
|
2816
2821
|
[value, formatTimeHint(duration)],
|
|
2817
2822
|
(failed ? 'X' : '>').repeat(Math.min(Math.ceil(meterTime / increment), SETTINGS.format.meter.width)),
|
|
@@ -2846,10 +2851,10 @@ class Module extends EventEmitter {
|
|
|
2846
2851
|
message = value;
|
|
2847
2852
|
value = '';
|
|
2848
2853
|
}
|
|
2849
|
-
value || (value = isFailed(options) ? "Failed"
|
|
2854
|
+
value || (value = isFailed(options) ? "Failed" : "Success");
|
|
2850
2855
|
const duration = getTimeOffset(startTime);
|
|
2851
2856
|
const args = [
|
|
2852
|
-
(128
|
|
2857
|
+
(128 | type),
|
|
2853
2858
|
title,
|
|
2854
2859
|
[value, formatTimeHint(duration)],
|
|
2855
2860
|
message,
|
|
@@ -2886,10 +2891,10 @@ class Module extends EventEmitter {
|
|
|
2886
2891
|
if (options.passThrough) {
|
|
2887
2892
|
message = null;
|
|
2888
2893
|
}
|
|
2889
|
-
const args = [(type | 512
|
|
2894
|
+
const args = [(type | 512), title, value, message, applyStyle(options, Module.LOG_STYLE_FAIL)];
|
|
2890
2895
|
applyLogId.call(this, options);
|
|
2891
2896
|
if (options.queue !== false && !options.passThrough && !this._logFlushed) {
|
|
2892
|
-
if (VALUES["error.out"
|
|
2897
|
+
if (VALUES["error.out"]) {
|
|
2893
2898
|
options.timeStamp = Date.now();
|
|
2894
2899
|
}
|
|
2895
2900
|
this._logQueued.push(args);
|
|
@@ -2900,9 +2905,9 @@ class Module extends EventEmitter {
|
|
|
2900
2905
|
const host = this.host;
|
|
2901
2906
|
const target = host || this;
|
|
2902
2907
|
let fatal;
|
|
2903
|
-
if (options.exec && (type & 4096
|
|
2908
|
+
if (options.exec && (type & 4096) && target.willAbort("(exec)")) {
|
|
2904
2909
|
const exec = { ...options.exec };
|
|
2905
|
-
let output = VALUES["permission.process_exec"
|
|
2910
|
+
let output = VALUES["permission.process_exec"].find(item => exec.command === ((0, types_1.isObject)(item) ? item.command : item));
|
|
2906
2911
|
if (output) {
|
|
2907
2912
|
if ((0, types_1.isPlainObject)(output)) {
|
|
2908
2913
|
output = { ...output };
|
|
@@ -2923,14 +2928,14 @@ class Module extends EventEmitter {
|
|
|
2923
2928
|
}
|
|
2924
2929
|
}
|
|
2925
2930
|
else {
|
|
2926
|
-
this.formatMessage(4096
|
|
2931
|
+
this.formatMessage(4096, "WARN!", "Exec command not permitted", exec.command, { ...Module.LOG_STYLE_WARN });
|
|
2927
2932
|
}
|
|
2928
2933
|
}
|
|
2929
2934
|
if (options.passThrough) {
|
|
2930
2935
|
return;
|
|
2931
2936
|
}
|
|
2932
2937
|
if (options.abortable !== false && (options.fatal !== false || this.isFatal(message))) {
|
|
2933
|
-
if (target.willAbort("(unknown)"
|
|
2938
|
+
if (target.willAbort("(unknown)")) {
|
|
2934
2939
|
if (host) {
|
|
2935
2940
|
host.abort();
|
|
2936
2941
|
}
|
|
@@ -2946,18 +2951,18 @@ class Module extends EventEmitter {
|
|
|
2946
2951
|
this.abort();
|
|
2947
2952
|
fatal = true;
|
|
2948
2953
|
}
|
|
2949
|
-
else if ((type & 8192
|
|
2950
|
-
(type & 1
|
|
2951
|
-
(type & 2
|
|
2952
|
-
(type & 8
|
|
2953
|
-
(type & 16
|
|
2954
|
-
(type & 32
|
|
2955
|
-
(type & 64
|
|
2956
|
-
(type & 1024
|
|
2957
|
-
(type & 2048
|
|
2958
|
-
(type & 4096
|
|
2959
|
-
(type & 16384
|
|
2960
|
-
(type & 65536
|
|
2954
|
+
else if ((type & 8192 && (!host || host.willAbort("(permission)"))) ||
|
|
2955
|
+
(type & 1) && target.willAbort("(system)") ||
|
|
2956
|
+
(type & 2) && target.willAbort("(node)") ||
|
|
2957
|
+
(type & 8) && target.willAbort("(compress)") ||
|
|
2958
|
+
(type & 16) && target.willAbort("(watch)") ||
|
|
2959
|
+
(type & 32) && target.willAbort("(file)") ||
|
|
2960
|
+
(type & 64) && target.willAbort("(cloud)") ||
|
|
2961
|
+
(type & 1024) && target.willAbort("(http)") ||
|
|
2962
|
+
(type & 2048) && target.willAbort("(image)") ||
|
|
2963
|
+
(type & 4096) && target.willAbort("(exec)") ||
|
|
2964
|
+
(type & 16384) && target.willAbort("(timeout)") ||
|
|
2965
|
+
(type & 65536) && target.willAbort("(db)")) {
|
|
2961
2966
|
if (host) {
|
|
2962
2967
|
if (host.abortable) {
|
|
2963
2968
|
host.abort();
|
|
@@ -2997,7 +3002,7 @@ class Module extends EventEmitter {
|
|
|
2997
3002
|
this.addLog(statusType, message || (Array.isArray(value) ? value[0] : value));
|
|
2998
3003
|
}
|
|
2999
3004
|
if (options.queue && !this._logFlushed) {
|
|
3000
|
-
if (VALUES["error.out"
|
|
3005
|
+
if (VALUES["error.out"] && (type & 512)) {
|
|
3001
3006
|
options.timeStamp = Date.now();
|
|
3002
3007
|
}
|
|
3003
3008
|
this._logQueued.push(args);
|
|
@@ -3019,7 +3024,7 @@ class Module extends EventEmitter {
|
|
|
3019
3024
|
if (typeof options === 'number') {
|
|
3020
3025
|
options = undefined;
|
|
3021
3026
|
}
|
|
3022
|
-
this.writeFail("Unknown"
|
|
3027
|
+
this.writeFail("Unknown", err, { ...options, type: types_1.LOG_TYPE.SYSTEM, code: types_1.ERR_CODE.MODULE_NOT_FOUND, exec: { command: 'npm', args: ['i', name] } });
|
|
3023
3028
|
return true;
|
|
3024
3029
|
}
|
|
3025
3030
|
if (value) {
|
|
@@ -3047,13 +3052,13 @@ class Module extends EventEmitter {
|
|
|
3047
3052
|
}
|
|
3048
3053
|
session.push(command);
|
|
3049
3054
|
let type = options.type || 0;
|
|
3050
|
-
type |= 4096
|
|
3051
|
-
type &= ~1
|
|
3055
|
+
type |= 4096;
|
|
3056
|
+
type &= ~1;
|
|
3052
3057
|
if (options.passThrough) {
|
|
3053
3058
|
options.passThrough = false;
|
|
3054
3059
|
message = null;
|
|
3055
3060
|
}
|
|
3056
|
-
return { type, value: ["Install required?"
|
|
3061
|
+
return { type, value: ["Install required?", command], message };
|
|
3057
3062
|
}
|
|
3058
3063
|
delete options.exec;
|
|
3059
3064
|
}
|
|
@@ -3141,7 +3146,7 @@ class Module extends EventEmitter {
|
|
|
3141
3146
|
message = '';
|
|
3142
3147
|
}
|
|
3143
3148
|
}
|
|
3144
|
-
this.status.push({ value: message.trim() || "Unknown"
|
|
3149
|
+
this.status.push({ value: message.trim() || "Unknown", name, duration, timeStamp, type, sessionId: this.sessionId, from: from || this.moduleName, source });
|
|
3145
3150
|
}
|
|
3146
3151
|
getLog(...type) {
|
|
3147
3152
|
return this.status.filter(item => type.includes(item.type));
|
|
@@ -3200,7 +3205,7 @@ class Module extends EventEmitter {
|
|
|
3200
3205
|
}
|
|
3201
3206
|
isFatal(err) {
|
|
3202
3207
|
const fatal = this.host?.config.error?.fatal;
|
|
3203
|
-
return fatal ?? VALUES["error.fatal"
|
|
3208
|
+
return fatal ?? VALUES["error.fatal"];
|
|
3204
3209
|
}
|
|
3205
3210
|
get moduleName() {
|
|
3206
3211
|
return this._moduleName;
|