@e-mc/module 0.6.0 → 0.6.2
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 +237 -232
- package/lib-v4.d.ts +4 -4
- package/lib-v4.js +5 -5
- package/package.json +3 -3
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.6.
|
|
560
|
+
static get VERSION() { return "0.6.2"; }
|
|
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
|
}
|
|
@@ -1260,7 +1256,7 @@ class Module extends EventEmitter {
|
|
|
1260
1256
|
let result = paths[0] || '';
|
|
1261
1257
|
for (let i = 1; i < paths.length; ++i) {
|
|
1262
1258
|
const trailing = paths[i];
|
|
1263
|
-
result += (trailing
|
|
1259
|
+
result += (!trailing.startsWith('/') && !result.endsWith('/') ? '/' : '') + trailing;
|
|
1264
1260
|
}
|
|
1265
1261
|
return result;
|
|
1266
1262
|
}
|
|
@@ -1284,7 +1280,7 @@ class Module extends EventEmitter {
|
|
|
1284
1280
|
return path.join(PROCESS_CWD, value);
|
|
1285
1281
|
}
|
|
1286
1282
|
if (ch === '~' && value[1] === '/') {
|
|
1287
|
-
return VALUES["permission.home_read"
|
|
1283
|
+
return VALUES["permission.home_read"] ? path.join(OS_HOMEDIR, value.substring(2)) : '';
|
|
1288
1284
|
}
|
|
1289
1285
|
try {
|
|
1290
1286
|
if (fs.existsSync(value = path.join(PROCESS_CWD, value))) {
|
|
@@ -1308,7 +1304,7 @@ class Module extends EventEmitter {
|
|
|
1308
1304
|
fs.unlinkSync(outDir);
|
|
1309
1305
|
}
|
|
1310
1306
|
catch {
|
|
1311
|
-
this.formatMessage(32
|
|
1307
|
+
this.formatMessage(32, 'WARN', "Unable to overwrite file", value, { ...this.LOG_STYLE_WARN });
|
|
1312
1308
|
return false;
|
|
1313
1309
|
}
|
|
1314
1310
|
}
|
|
@@ -1325,7 +1321,7 @@ class Module extends EventEmitter {
|
|
|
1325
1321
|
return tryCreateDir(outDir);
|
|
1326
1322
|
}
|
|
1327
1323
|
catch (err) {
|
|
1328
|
-
this.writeFail(["Unable to create directory"
|
|
1324
|
+
this.writeFail(["Unable to create directory", value], err, 32);
|
|
1329
1325
|
}
|
|
1330
1326
|
}
|
|
1331
1327
|
return false;
|
|
@@ -1347,19 +1343,19 @@ class Module extends EventEmitter {
|
|
|
1347
1343
|
}
|
|
1348
1344
|
}
|
|
1349
1345
|
catch (err) {
|
|
1350
|
-
this.writeFail(["Unable to remove directory"
|
|
1346
|
+
this.writeFail(["Unable to remove directory", value], err, 32);
|
|
1351
1347
|
}
|
|
1352
1348
|
}
|
|
1353
1349
|
return false;
|
|
1354
1350
|
}
|
|
1355
|
-
static copyDir(src, dest, move, recursive = true) {
|
|
1351
|
+
static async copyDir(src, dest, move, recursive = true) {
|
|
1356
1352
|
const srcOut = sanitizePath(asFile(src));
|
|
1357
1353
|
if (!srcOut || !this.isDir(srcOut)) {
|
|
1358
|
-
return Promise.reject(errorDirectory(asFile(src) || "Unknown"
|
|
1354
|
+
return Promise.reject(errorDirectory(asFile(src) || "Unknown"));
|
|
1359
1355
|
}
|
|
1360
1356
|
const destOut = sanitizePath(asFile(dest));
|
|
1361
1357
|
if (!destOut || !this.createDir(destOut)) {
|
|
1362
|
-
return Promise.reject(errorDirectory(asFile(dest) || "Unknown"
|
|
1358
|
+
return Promise.reject(errorDirectory(asFile(dest) || "Unknown"));
|
|
1363
1359
|
}
|
|
1364
1360
|
let symFile, symDir, ignoreFile, ignoreDir, silent, overwrite;
|
|
1365
1361
|
if ((0, types_1.isObject)(move)) {
|
|
@@ -1430,7 +1426,7 @@ class Module extends EventEmitter {
|
|
|
1430
1426
|
.catch(err => {
|
|
1431
1427
|
failed.push(srcPath);
|
|
1432
1428
|
if (!silent) {
|
|
1433
|
-
this.writeFail([move ? "Unable to move file"
|
|
1429
|
+
this.writeFail([move ? "Unable to move file" : "Unable to copy file", path.basename(srcPath)], err, 32);
|
|
1434
1430
|
}
|
|
1435
1431
|
}));
|
|
1436
1432
|
}
|
|
@@ -1445,7 +1441,7 @@ class Module extends EventEmitter {
|
|
|
1445
1441
|
catch (err) {
|
|
1446
1442
|
failed.push(srcDir);
|
|
1447
1443
|
if (!silent) {
|
|
1448
|
-
this.writeFail(["Unable to read directory"
|
|
1444
|
+
this.writeFail(["Unable to read directory", path.basename(srcDir)], err, 32);
|
|
1449
1445
|
}
|
|
1450
1446
|
}
|
|
1451
1447
|
}
|
|
@@ -1497,7 +1493,7 @@ class Module extends EventEmitter {
|
|
|
1497
1493
|
}
|
|
1498
1494
|
catch (error) {
|
|
1499
1495
|
if (copied) {
|
|
1500
|
-
this.formatMessage(32
|
|
1496
|
+
this.formatMessage(32, 'WARN', ["Unable to delete file", path.basename(src instanceof URL ? url.fileURLToPath(src) : src)], error, { ...this.LOG_STYLE_WARN });
|
|
1501
1497
|
throws = false;
|
|
1502
1498
|
}
|
|
1503
1499
|
}
|
|
@@ -1527,7 +1523,7 @@ class Module extends EventEmitter {
|
|
|
1527
1523
|
return result;
|
|
1528
1524
|
}
|
|
1529
1525
|
catch (err) {
|
|
1530
|
-
this.writeFail(["Unable to read file"
|
|
1526
|
+
this.writeFail(["Unable to read file", path.basename(src)], err, 32);
|
|
1531
1527
|
}
|
|
1532
1528
|
}
|
|
1533
1529
|
return '';
|
|
@@ -1547,19 +1543,19 @@ class Module extends EventEmitter {
|
|
|
1547
1543
|
return result;
|
|
1548
1544
|
}
|
|
1549
1545
|
catch (err) {
|
|
1550
|
-
this.writeFail(["Unable to read file"
|
|
1546
|
+
this.writeFail(["Unable to read file", path.basename(src)], err, 32);
|
|
1551
1547
|
}
|
|
1552
1548
|
}
|
|
1553
1549
|
return null;
|
|
1554
1550
|
}
|
|
1555
|
-
static resolveMime(data) {
|
|
1551
|
+
static async resolveMime(data) {
|
|
1556
1552
|
return typeof data === 'string' ? filetype.fromFile(data) : filetype.fromBuffer(data);
|
|
1557
1553
|
}
|
|
1558
1554
|
static lookupMime(value, extension) {
|
|
1559
1555
|
return (extension ? mime.extension(value) : mime.lookup(value)) || '';
|
|
1560
1556
|
}
|
|
1561
1557
|
static initCpuUsage(instance) {
|
|
1562
|
-
if (!VALUES["node.process.cpu_usage"
|
|
1558
|
+
if (!VALUES["node.process.cpu_usage"]) {
|
|
1563
1559
|
return { user: 0, system: 0 };
|
|
1564
1560
|
}
|
|
1565
1561
|
const result = process.cpuUsage();
|
|
@@ -1570,7 +1566,7 @@ class Module extends EventEmitter {
|
|
|
1570
1566
|
return result;
|
|
1571
1567
|
}
|
|
1572
1568
|
static getCpuUsage(start, format) {
|
|
1573
|
-
if (VALUES["node.process.cpu_usage"
|
|
1569
|
+
if (VALUES["node.process.cpu_usage"]) {
|
|
1574
1570
|
let value = CACHE_CPU.get(start);
|
|
1575
1571
|
if (value === undefined) {
|
|
1576
1572
|
CACHE_CPU.set(start, getCpuTimes());
|
|
@@ -1588,7 +1584,7 @@ class Module extends EventEmitter {
|
|
|
1588
1584
|
return format ? '' : 0;
|
|
1589
1585
|
}
|
|
1590
1586
|
static getMemUsage(format) {
|
|
1591
|
-
if (!VALUES["node.process.memory_usage"
|
|
1587
|
+
if (!VALUES["node.process.memory_usage"]) {
|
|
1592
1588
|
return format ? '' : 0;
|
|
1593
1589
|
}
|
|
1594
1590
|
const usage = process.memoryUsage();
|
|
@@ -1626,24 +1622,24 @@ class Module extends EventEmitter {
|
|
|
1626
1622
|
if (!cpu_single_core) {
|
|
1627
1623
|
usage /= CPU_CORETOTAL;
|
|
1628
1624
|
}
|
|
1629
|
-
if (usage + 0.005
|
|
1625
|
+
if (usage + 0.005 >= 1) {
|
|
1630
1626
|
usage = 1;
|
|
1631
1627
|
}
|
|
1632
|
-
let bar = 20
|
|
1628
|
+
let bar = 20, red = 0.9, yellow = 0.75;
|
|
1633
1629
|
if (typeof cpu_bar === 'number') {
|
|
1634
1630
|
bar = cpu_bar;
|
|
1635
1631
|
}
|
|
1636
|
-
else if (Array.isArray(cpu_bar) && cpu_bar[0] >= 10
|
|
1632
|
+
else if (Array.isArray(cpu_bar) && cpu_bar[0] >= 10) {
|
|
1637
1633
|
let r, y;
|
|
1638
|
-
[bar, r = 0.9
|
|
1634
|
+
[bar, r = 0.9, y = 0.75] = cpu_bar;
|
|
1639
1635
|
if (r > 0 && r < 1 && y > 0 && y < 1 && y < r) {
|
|
1640
1636
|
red = r;
|
|
1641
1637
|
yellow = y;
|
|
1642
1638
|
}
|
|
1643
1639
|
}
|
|
1644
|
-
const unit = Math.max(bar, 10
|
|
1640
|
+
const unit = Math.max(bar, 10);
|
|
1645
1641
|
const length = Math.floor(usage * unit);
|
|
1646
|
-
const hint = usage === 1 ? "MAX"
|
|
1642
|
+
const hint = usage === 1 ? "MAX" : usage < 0 ? "N/A" : formatPercent(usage, 2);
|
|
1647
1643
|
result += chalk[usage >= red ? 'bgRed' : usage >= yellow ? 'bgYellow' : 'bgBlue'].white(':'.repeat(length)) + chalk.bgGrey.white(':'.repeat(unit - length)) + (hint ? chalk.bgWhite.grey(` ${hint} `) : '');
|
|
1648
1644
|
}
|
|
1649
1645
|
else if (usage) {
|
|
@@ -1838,7 +1834,7 @@ class Module extends EventEmitter {
|
|
|
1838
1834
|
return true;
|
|
1839
1835
|
}
|
|
1840
1836
|
static sanitizeCmd(value) {
|
|
1841
|
-
if (value.
|
|
1837
|
+
if (value.includes(' ')) {
|
|
1842
1838
|
return PLATFORM_WIN32 ? wrapQuote(value) : value.replace(/[ ]/g, '\\ ');
|
|
1843
1839
|
}
|
|
1844
1840
|
return value;
|
|
@@ -1869,7 +1865,7 @@ class Module extends EventEmitter {
|
|
|
1869
1865
|
}
|
|
1870
1866
|
value = quoted[2];
|
|
1871
1867
|
}
|
|
1872
|
-
if (value.
|
|
1868
|
+
if (value.includes(' ')) {
|
|
1873
1869
|
value = wrapQuote(value);
|
|
1874
1870
|
}
|
|
1875
1871
|
}
|
|
@@ -1904,7 +1900,7 @@ class Module extends EventEmitter {
|
|
|
1904
1900
|
}
|
|
1905
1901
|
return (typeof values === 'string' ? result[0] : result);
|
|
1906
1902
|
}
|
|
1907
|
-
static purgeMemory(percent = 1, limit = 0) {
|
|
1903
|
+
static async purgeMemory(percent = 1, limit = 0) {
|
|
1908
1904
|
if (typeof limit === 'boolean') {
|
|
1909
1905
|
limit = 0;
|
|
1910
1906
|
}
|
|
@@ -1942,22 +1938,22 @@ class Module extends EventEmitter {
|
|
|
1942
1938
|
static canWrite(name) {
|
|
1943
1939
|
switch (name) {
|
|
1944
1940
|
case 'temp':
|
|
1945
|
-
return VALUES["temp.write"
|
|
1941
|
+
return VALUES["temp.write"];
|
|
1946
1942
|
case 'home':
|
|
1947
|
-
return VALUES["permission.home_write"
|
|
1943
|
+
return VALUES["permission.home_write"];
|
|
1948
1944
|
default:
|
|
1949
1945
|
return false;
|
|
1950
1946
|
}
|
|
1951
1947
|
}
|
|
1952
1948
|
static loadSettings(settings, password) {
|
|
1953
1949
|
var _h;
|
|
1954
|
-
const current = VALUES["process.password"
|
|
1950
|
+
const current = VALUES["process.password"];
|
|
1955
1951
|
if (current) {
|
|
1956
1952
|
const proc = settings.process || {};
|
|
1957
1953
|
if (!password && !(password = proc.password)) {
|
|
1958
1954
|
return false;
|
|
1959
1955
|
}
|
|
1960
|
-
const algorithm = VALUES["process.cipher.algorithm"
|
|
1956
|
+
const algorithm = VALUES["process.cipher.algorithm"];
|
|
1961
1957
|
if (algorithm) {
|
|
1962
1958
|
password = encryptMessage(password, proc.cipher, algorithm);
|
|
1963
1959
|
}
|
|
@@ -1966,7 +1962,7 @@ class Module extends EventEmitter {
|
|
|
1966
1962
|
}
|
|
1967
1963
|
}
|
|
1968
1964
|
else if ((0, types_1.isString)(password)) {
|
|
1969
|
-
VALUES["process.password"
|
|
1965
|
+
VALUES["process.password"] = encryptMessage(password, settings.process?.cipher);
|
|
1970
1966
|
}
|
|
1971
1967
|
const { temp, node, permission, memory, error, logger } = settings;
|
|
1972
1968
|
if ((0, types_1.isPlainObject)(node)) {
|
|
@@ -1974,51 +1970,51 @@ class Module extends EventEmitter {
|
|
|
1974
1970
|
if ((0, types_1.isPlainObject)(proc)) {
|
|
1975
1971
|
const { cpu_usage, memory_usage, inline } = proc;
|
|
1976
1972
|
if (typeof cpu_usage === 'boolean') {
|
|
1977
|
-
VALUES["node.process.cpu_usage"
|
|
1973
|
+
VALUES["node.process.cpu_usage"] = cpu_usage;
|
|
1978
1974
|
}
|
|
1979
1975
|
if (typeof memory_usage === 'boolean') {
|
|
1980
|
-
VALUES["node.process.memory_usage"
|
|
1976
|
+
VALUES["node.process.memory_usage"] = memory_usage;
|
|
1981
1977
|
}
|
|
1982
1978
|
if (typeof inline === 'boolean') {
|
|
1983
|
-
VALUES["node.process.inline"
|
|
1979
|
+
VALUES["node.process.inline"] = inline;
|
|
1984
1980
|
}
|
|
1985
1981
|
}
|
|
1986
1982
|
if ((0, types_1.isPlainObject)(req)) {
|
|
1987
1983
|
const { ext, npm, inline } = req;
|
|
1988
1984
|
if (!ext) {
|
|
1989
|
-
VALUES["node.require.ext"
|
|
1985
|
+
VALUES["node.require.ext"] = '';
|
|
1990
1986
|
}
|
|
1991
1987
|
else if (typeof ext === 'string') {
|
|
1992
|
-
VALUES["node.require.ext"
|
|
1988
|
+
VALUES["node.require.ext"] = ext.trim().toLowerCase();
|
|
1993
1989
|
}
|
|
1994
1990
|
else if (Array.isArray(ext)) {
|
|
1995
1991
|
const items = ext.map(value => (0, types_1.isString)(value) ? value.trim().toLowerCase() : '').filter(value => value);
|
|
1996
|
-
VALUES["node.require.ext"
|
|
1992
|
+
VALUES["node.require.ext"] = items.length ? items : '';
|
|
1997
1993
|
}
|
|
1998
1994
|
else {
|
|
1999
|
-
VALUES["node.require.ext"
|
|
1995
|
+
VALUES["node.require.ext"] = 'cjs';
|
|
2000
1996
|
}
|
|
2001
1997
|
if (typeof npm === 'boolean') {
|
|
2002
|
-
VALUES["node.require.npm"
|
|
1998
|
+
VALUES["node.require.npm"] = npm;
|
|
2003
1999
|
}
|
|
2004
2000
|
if (typeof inline === 'boolean') {
|
|
2005
|
-
VALUES["node.require.inline"
|
|
2001
|
+
VALUES["node.require.inline"] = inline;
|
|
2006
2002
|
}
|
|
2007
2003
|
}
|
|
2008
2004
|
}
|
|
2009
2005
|
if ((0, types_1.isPlainObject)(settings.process)) {
|
|
2010
2006
|
const { env, cipher, password: pwd } = settings.process;
|
|
2011
2007
|
if (env && typeof env.apply === 'boolean') {
|
|
2012
|
-
VALUES["process.env.apply"
|
|
2008
|
+
VALUES["process.env.apply"] = env.apply;
|
|
2013
2009
|
}
|
|
2014
2010
|
if ((0, types_1.isString)(pwd)) {
|
|
2015
|
-
VALUES[_h = "process.password"
|
|
2011
|
+
VALUES[_h = "process.password"] || (VALUES[_h] = encryptMessage(pwd, cipher));
|
|
2016
2012
|
}
|
|
2017
2013
|
}
|
|
2018
2014
|
if (memory && (0, types_1.isPlainObject)(memory.settings)) {
|
|
2019
2015
|
const users = memory.settings.users;
|
|
2020
2016
|
if (typeof users === 'boolean' || Array.isArray(users)) {
|
|
2021
|
-
VALUES["memory.settings.users"
|
|
2017
|
+
VALUES["memory.settings.users"] = users;
|
|
2022
2018
|
}
|
|
2023
2019
|
}
|
|
2024
2020
|
if ((0, types_1.isPlainObject)(logger)) {
|
|
@@ -2029,7 +2025,7 @@ class Module extends EventEmitter {
|
|
|
2029
2025
|
if (level !== undefined) {
|
|
2030
2026
|
const value = (0, types_1.isString)(level) ? types_1.STATUS_TYPE[level.trim().toUpperCase()] : level;
|
|
2031
2027
|
if (value >= -1 && value <= types_1.STATUS_TYPE.TRACE) {
|
|
2032
|
-
VALUES["logger.level"
|
|
2028
|
+
VALUES["logger.level"] = value;
|
|
2033
2029
|
}
|
|
2034
2030
|
}
|
|
2035
2031
|
if (Array.isArray(production)) {
|
|
@@ -2153,7 +2149,7 @@ class Module extends EventEmitter {
|
|
|
2153
2149
|
}
|
|
2154
2150
|
}
|
|
2155
2151
|
if (broadcast?.out) {
|
|
2156
|
-
VALUES["broadcast.out"
|
|
2152
|
+
VALUES["broadcast.out"] = this.parseFunction(broadcast.out, { external: true, absolute: true });
|
|
2157
2153
|
}
|
|
2158
2154
|
if (stack_trace && stack_trace !== true && +stack_trace > 0) {
|
|
2159
2155
|
Error.stackTraceLimit = +stack_trace;
|
|
@@ -2161,23 +2157,32 @@ class Module extends EventEmitter {
|
|
|
2161
2157
|
}
|
|
2162
2158
|
if (error) {
|
|
2163
2159
|
if (error.out) {
|
|
2164
|
-
VALUES["error.out"
|
|
2160
|
+
VALUES["error.out"] = this.parseFunction(error.out, { external: true, absolute: true });
|
|
2165
2161
|
}
|
|
2166
2162
|
if (typeof error.fatal === 'boolean') {
|
|
2167
|
-
VALUES["error.fatal"
|
|
2163
|
+
VALUES["error.fatal"] = error.fatal;
|
|
2168
2164
|
}
|
|
2169
2165
|
}
|
|
2170
|
-
if (permission
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2166
|
+
if (permission) {
|
|
2167
|
+
const { home_read, home_write } = permission;
|
|
2168
|
+
if (typeof home_read === 'boolean') {
|
|
2169
|
+
VALUES["permission.home_read"] = home_read;
|
|
2170
|
+
}
|
|
2171
|
+
if (typeof home_write === 'boolean') {
|
|
2172
|
+
VALUES["permission.home_write"] = home_write;
|
|
2173
|
+
}
|
|
2174
|
+
if (Array.isArray(permission.process_exec)) {
|
|
2175
|
+
VALUES["permission.process_exec"] = permission.process_exec.filter(item => typeof item === 'string' || (0, types_1.isObject)(item) && typeof item.command === 'string').map(exec => {
|
|
2176
|
+
if (typeof exec === 'string') {
|
|
2177
|
+
return exec.trim();
|
|
2178
|
+
}
|
|
2179
|
+
if (typeof exec.warn === 'string') {
|
|
2180
|
+
exec.warn = [exec.warn];
|
|
2181
|
+
}
|
|
2182
|
+
exec.command = exec.command.trim();
|
|
2183
|
+
return exec;
|
|
2184
|
+
});
|
|
2185
|
+
}
|
|
2181
2186
|
}
|
|
2182
2187
|
{
|
|
2183
2188
|
let dir = settings.temp_dir, write;
|
|
@@ -2191,16 +2196,16 @@ class Module extends EventEmitter {
|
|
|
2191
2196
|
dir = dir.substring(ensureDir(PROCESS_CWD).length);
|
|
2192
2197
|
}
|
|
2193
2198
|
else {
|
|
2194
|
-
this.formatMessage(1
|
|
2199
|
+
this.formatMessage(1, 'WARN', 'Temp directory can only be relative', dir, { ...this.LOG_STYLE_WARN, newline: true });
|
|
2195
2200
|
dir = undefined;
|
|
2196
2201
|
}
|
|
2197
2202
|
}
|
|
2198
2203
|
if (!(0, types_1.isString)(dir)) {
|
|
2199
|
-
dir = VALUES["temp.dir"
|
|
2204
|
+
dir = VALUES["temp.dir"];
|
|
2200
2205
|
}
|
|
2201
2206
|
if (typeof write === 'boolean') {
|
|
2202
|
-
modified = VALUES["temp.write"
|
|
2203
|
-
VALUES["temp.write"
|
|
2207
|
+
modified = VALUES["temp.write"] !== write;
|
|
2208
|
+
VALUES["temp.write"] = write;
|
|
2204
2209
|
}
|
|
2205
2210
|
do {
|
|
2206
2211
|
const [output, index] = tryIncrementDir(path.join(PROCESS_CWD, dir), 5);
|
|
@@ -2208,19 +2213,19 @@ class Module extends EventEmitter {
|
|
|
2208
2213
|
if (index > 0) {
|
|
2209
2214
|
dir = trimDir(dir) + '_' + index;
|
|
2210
2215
|
}
|
|
2211
|
-
if (dir !== VALUES["temp.dir"
|
|
2212
|
-
VALUES["temp.dir"
|
|
2216
|
+
if (dir !== VALUES["temp.dir"]) {
|
|
2217
|
+
VALUES["temp.dir"] = dir;
|
|
2213
2218
|
modified = true;
|
|
2214
2219
|
}
|
|
2215
2220
|
(0, types_1.setTempDir)(TEMP_DIR = output);
|
|
2216
2221
|
break;
|
|
2217
2222
|
}
|
|
2218
2223
|
if (output instanceof Error) {
|
|
2219
|
-
this.writeFail(["Unable to create temp directory"
|
|
2224
|
+
this.writeFail(["Unable to create temp directory", dir], output, 32);
|
|
2220
2225
|
}
|
|
2221
|
-
} while ((dir !== "tmp"
|
|
2226
|
+
} while ((dir !== "tmp") && (dir = "tmp"));
|
|
2222
2227
|
if (modified) {
|
|
2223
|
-
this.formatMessage(1
|
|
2228
|
+
this.formatMessage(1, 'TEMP', ["Directory was modified", dir], TEMP_DIR + (VALUES["temp.write"] ? ' - writeable' : ''), { ...this.LOG_STYLE_NOTICE, newline: true });
|
|
2224
2229
|
}
|
|
2225
2230
|
settings.temp_dir = dir;
|
|
2226
2231
|
if ((0, types_1.isPlainObject)(temp)) {
|
|
@@ -2273,7 +2278,7 @@ class Module extends EventEmitter {
|
|
|
2273
2278
|
const [output] = tryIncrementDir(result, increment);
|
|
2274
2279
|
if (!(0, types_1.isString)(output)) {
|
|
2275
2280
|
if (output instanceof Error) {
|
|
2276
|
-
this.writeFail(["Unable to create temp directory"
|
|
2281
|
+
this.writeFail(["Unable to create temp directory", result], output, 32);
|
|
2277
2282
|
}
|
|
2278
2283
|
return '';
|
|
2279
2284
|
}
|
|
@@ -2307,7 +2312,7 @@ class Module extends EventEmitter {
|
|
|
2307
2312
|
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()))) {
|
|
2308
2313
|
return true;
|
|
2309
2314
|
}
|
|
2310
|
-
return VALUES["permission.home_read"
|
|
2315
|
+
return VALUES["permission.home_read"] && withinDir(uri, OS_HOMEDIR);
|
|
2311
2316
|
}
|
|
2312
2317
|
canWrite(uri, options) {
|
|
2313
2318
|
let permission = this.permission, ownPermissionOnly = false;
|
|
@@ -2328,12 +2333,12 @@ class Module extends EventEmitter {
|
|
|
2328
2333
|
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()))) {
|
|
2329
2334
|
return true;
|
|
2330
2335
|
}
|
|
2331
|
-
return VALUES["temp.write"
|
|
2336
|
+
return VALUES["temp.write"] && withinDir(uri, TEMP_DIR) || VALUES["permission.home_write"] && withinDir(uri, OS_HOMEDIR);
|
|
2332
2337
|
}
|
|
2333
2338
|
readFile(src, options = {}, callback) {
|
|
2334
2339
|
let promises, outSrc;
|
|
2335
2340
|
[options, promises, callback] = parseFileArgs(options, callback);
|
|
2336
|
-
if (outSrc = hasFileSystem.call(this, 0
|
|
2341
|
+
if (outSrc = hasFileSystem.call(this, 0, src, options)) {
|
|
2337
2342
|
const { requireExt, cache } = options;
|
|
2338
2343
|
const encoding = options.encoding && (0, types_1.getEncoding)(options.encoding);
|
|
2339
2344
|
const setCache = (data, cjs) => {
|
|
@@ -2345,7 +2350,7 @@ class Module extends EventEmitter {
|
|
|
2345
2350
|
}
|
|
2346
2351
|
};
|
|
2347
2352
|
let result;
|
|
2348
|
-
if (requireExt && VALUES["node.require.ext"
|
|
2353
|
+
if (requireExt && VALUES["node.require.ext"] && hasString(requireExt === true ? VALUES["node.require.ext"] : requireExt, getExtension(src))) {
|
|
2349
2354
|
if (cache) {
|
|
2350
2355
|
result = getCacheItem(CACHE_READCJS, outSrc);
|
|
2351
2356
|
}
|
|
@@ -2392,7 +2397,7 @@ class Module extends EventEmitter {
|
|
|
2392
2397
|
return result;
|
|
2393
2398
|
}
|
|
2394
2399
|
catch (err) {
|
|
2395
|
-
this.writeFail(["Unable to read file"
|
|
2400
|
+
this.writeFail(["Unable to read file", path.basename(src)], err, 32);
|
|
2396
2401
|
}
|
|
2397
2402
|
}
|
|
2398
2403
|
else if (promises) {
|
|
@@ -2405,7 +2410,7 @@ class Module extends EventEmitter {
|
|
|
2405
2410
|
writeFile(src, data, options = {}, callback) {
|
|
2406
2411
|
let promises, outSrc;
|
|
2407
2412
|
[options, promises, callback] = parseFileArgs(options, callback);
|
|
2408
|
-
if (outSrc = hasFileSystem.call(this, 1
|
|
2413
|
+
if (outSrc = hasFileSystem.call(this, 1, src, options, true, options.overwrite)) {
|
|
2409
2414
|
if (promises) {
|
|
2410
2415
|
return fs.promises.writeFile(outSrc, data, options.encoding).then(() => {
|
|
2411
2416
|
this.emit('file:write', outSrc, options);
|
|
@@ -2427,7 +2432,7 @@ class Module extends EventEmitter {
|
|
|
2427
2432
|
return true;
|
|
2428
2433
|
}
|
|
2429
2434
|
catch (err) {
|
|
2430
|
-
this.writeFail(["Unable to write file"
|
|
2435
|
+
this.writeFail(["Unable to write file", path.basename(src)], err, 32);
|
|
2431
2436
|
}
|
|
2432
2437
|
}
|
|
2433
2438
|
else if (promises) {
|
|
@@ -2442,7 +2447,7 @@ class Module extends EventEmitter {
|
|
|
2442
2447
|
deleteFile(src, options = {}, callback) {
|
|
2443
2448
|
let promises, outSrc;
|
|
2444
2449
|
[options, promises, callback] = parseFileArgs(options, callback);
|
|
2445
|
-
if (outSrc = hasFileSystem.call(this, 1
|
|
2450
|
+
if (outSrc = hasFileSystem.call(this, 1, src, options)) {
|
|
2446
2451
|
if (promises) {
|
|
2447
2452
|
return fs.promises.unlink(outSrc).then(() => {
|
|
2448
2453
|
this.emit('file:delete', outSrc, options);
|
|
@@ -2463,7 +2468,7 @@ class Module extends EventEmitter {
|
|
|
2463
2468
|
}
|
|
2464
2469
|
catch (err) {
|
|
2465
2470
|
if (!Module.isErrorCode(err, 'ENOENT')) {
|
|
2466
|
-
this.writeFail(["Unable to delete file"
|
|
2471
|
+
this.writeFail(["Unable to delete file", path.basename(src)], err, 32);
|
|
2467
2472
|
return false;
|
|
2468
2473
|
}
|
|
2469
2474
|
}
|
|
@@ -2482,7 +2487,7 @@ class Module extends EventEmitter {
|
|
|
2482
2487
|
copyFile(src, dest, options = {}, callback) {
|
|
2483
2488
|
let promises, outSrc, outDest;
|
|
2484
2489
|
[options, promises, callback] = parseFileArgs(options, callback);
|
|
2485
|
-
if ((outSrc = hasFileSystem.call(this, 0
|
|
2490
|
+
if ((outSrc = hasFileSystem.call(this, 0, src, options)) && (outDest = hasFileSystem.call(this, 1, dest, options, true, options.overwrite))) {
|
|
2486
2491
|
const destDir = path.dirname(outDest);
|
|
2487
2492
|
if (!Module.isDir(destDir) && (options.createDir === false || !Module.createDir(destDir))) {
|
|
2488
2493
|
if (promises) {
|
|
@@ -2519,7 +2524,7 @@ class Module extends EventEmitter {
|
|
|
2519
2524
|
return true;
|
|
2520
2525
|
}
|
|
2521
2526
|
catch (err) {
|
|
2522
|
-
this.writeFail(["Unable to copy file"
|
|
2527
|
+
this.writeFail(["Unable to copy file", dest], err, 32);
|
|
2523
2528
|
}
|
|
2524
2529
|
}
|
|
2525
2530
|
}
|
|
@@ -2535,7 +2540,7 @@ class Module extends EventEmitter {
|
|
|
2535
2540
|
moveFile(src, dest, options = {}, callback) {
|
|
2536
2541
|
let promises, outSrc, outDest;
|
|
2537
2542
|
[options, promises, callback] = parseFileArgs(options, callback);
|
|
2538
|
-
if ((outSrc = hasFileSystem.call(this, 1
|
|
2543
|
+
if ((outSrc = hasFileSystem.call(this, 1, src, options)) && (outDest = hasFileSystem.call(this, 1, dest, options, true, options.overwrite))) {
|
|
2539
2544
|
const destDir = path.dirname(outDest);
|
|
2540
2545
|
if (!Module.isDir(destDir) && (options.createDir === false || !Module.createDir(destDir))) {
|
|
2541
2546
|
if (promises) {
|
|
@@ -2602,7 +2607,7 @@ class Module extends EventEmitter {
|
|
|
2602
2607
|
this.emit('file:move', outDest, options);
|
|
2603
2608
|
return true;
|
|
2604
2609
|
}
|
|
2605
|
-
this.writeFail(["Unable to move file"
|
|
2610
|
+
this.writeFail(["Unable to move file", dest], err, 32);
|
|
2606
2611
|
}
|
|
2607
2612
|
}
|
|
2608
2613
|
}
|
|
@@ -2623,7 +2628,7 @@ class Module extends EventEmitter {
|
|
|
2623
2628
|
createDir(src, options = {}, callback) {
|
|
2624
2629
|
let promises, outSrc;
|
|
2625
2630
|
[options, promises, callback] = parseFileArgs(options, callback);
|
|
2626
|
-
if (outSrc = hasFileSystem.call(this, 1
|
|
2631
|
+
if (outSrc = hasFileSystem.call(this, 1, src, options, true)) {
|
|
2627
2632
|
if (Module.isDir(outSrc)) {
|
|
2628
2633
|
if (promises) {
|
|
2629
2634
|
return Promise.resolve(true);
|
|
@@ -2670,7 +2675,7 @@ class Module extends EventEmitter {
|
|
|
2670
2675
|
}
|
|
2671
2676
|
}
|
|
2672
2677
|
catch (err) {
|
|
2673
|
-
this.writeFail(["Unable to create directory"
|
|
2678
|
+
this.writeFail(["Unable to create directory", src], err, 32);
|
|
2674
2679
|
}
|
|
2675
2680
|
}
|
|
2676
2681
|
else if (promises) {
|
|
@@ -2685,11 +2690,11 @@ class Module extends EventEmitter {
|
|
|
2685
2690
|
removeDir(src, options = {}, callback) {
|
|
2686
2691
|
let promises, outSrc;
|
|
2687
2692
|
[options, promises, callback] = parseFileArgs(options, callback);
|
|
2688
|
-
if (outSrc = hasFileSystem.call(this, 1
|
|
2693
|
+
if (outSrc = hasFileSystem.call(this, 1, src, options, true)) {
|
|
2689
2694
|
try {
|
|
2690
2695
|
if (Module.isDir(outSrc)) {
|
|
2691
2696
|
const { emptyDir = false, recursive = true } = options;
|
|
2692
|
-
const errorResponse = (failed) => new Error("Unsupported access"
|
|
2697
|
+
const errorResponse = (failed) => new Error("Unsupported access" + ':' + (failed.length > 1 ? failed.map(value => `\n- ${value}`) : ' ' + failed[0]));
|
|
2693
2698
|
if (promises || isFunction(callback)) {
|
|
2694
2699
|
const result = new Promise((resolve, reject) => {
|
|
2695
2700
|
const failed = tryRemoveDir(outSrc, emptyDir, !!recursive);
|
|
@@ -2740,7 +2745,7 @@ class Module extends EventEmitter {
|
|
|
2740
2745
|
}
|
|
2741
2746
|
}
|
|
2742
2747
|
catch (err) {
|
|
2743
|
-
this.writeFail(["Unable to remove directory"
|
|
2748
|
+
this.writeFail(["Unable to remove directory", src], err, 32);
|
|
2744
2749
|
}
|
|
2745
2750
|
}
|
|
2746
2751
|
else if (promises) {
|
|
@@ -2752,8 +2757,8 @@ class Module extends EventEmitter {
|
|
|
2752
2757
|
}
|
|
2753
2758
|
return false;
|
|
2754
2759
|
}
|
|
2755
|
-
allSettled(tasks, rejected, options) {
|
|
2756
|
-
rejected || (rejected = "Unknown"
|
|
2760
|
+
async allSettled(tasks, rejected, options) {
|
|
2761
|
+
rejected || (rejected = "Unknown");
|
|
2757
2762
|
return Promise.allSettled(tasks).then(result => {
|
|
2758
2763
|
const items = [];
|
|
2759
2764
|
for (const item of result) {
|
|
@@ -2782,16 +2787,16 @@ class Module extends EventEmitter {
|
|
|
2782
2787
|
}
|
|
2783
2788
|
options = {};
|
|
2784
2789
|
}
|
|
2785
|
-
this.formatFail(type || types_1.LOG_TYPE.SYSTEM, "FAIL!"
|
|
2790
|
+
this.formatFail(type || types_1.LOG_TYPE.SYSTEM, "FAIL!", value, message, options);
|
|
2786
2791
|
}
|
|
2787
2792
|
writeTimeProcess(title, value, startTime, options = {}) {
|
|
2788
2793
|
const { type = 0, statusType = 0 } = options;
|
|
2789
|
-
const http = type & 1024
|
|
2794
|
+
const http = type & 1024;
|
|
2790
2795
|
const meter = SETTINGS.meter;
|
|
2791
2796
|
const failed = isFailed(options);
|
|
2792
2797
|
const increment = options.meterIncrement || (http ? meter.http
|
|
2793
|
-
: type & 2048
|
|
2794
|
-
: type & 8
|
|
2798
|
+
: type & 2048 ? meter.image
|
|
2799
|
+
: type & 8 ? meter.compress
|
|
2795
2800
|
: meter.process) || 250;
|
|
2796
2801
|
const duration = getTimeOffset(startTime);
|
|
2797
2802
|
let meterTime = duration, delayTime = options.delayTime;
|
|
@@ -2810,10 +2815,10 @@ class Module extends EventEmitter {
|
|
|
2810
2815
|
}
|
|
2811
2816
|
}
|
|
2812
2817
|
if (failed && !http) {
|
|
2813
|
-
value = "Failed"
|
|
2818
|
+
value = "Failed" + ' -> ' + value;
|
|
2814
2819
|
}
|
|
2815
2820
|
const args = [
|
|
2816
|
-
(256
|
|
2821
|
+
(256 | type),
|
|
2817
2822
|
title,
|
|
2818
2823
|
[value, formatTimeHint(duration)],
|
|
2819
2824
|
(failed ? 'X' : '>').repeat(Math.min(Math.ceil(meterTime / increment), SETTINGS.format.meter.width)),
|
|
@@ -2848,10 +2853,10 @@ class Module extends EventEmitter {
|
|
|
2848
2853
|
message = value;
|
|
2849
2854
|
value = '';
|
|
2850
2855
|
}
|
|
2851
|
-
value || (value = isFailed(options) ? "Failed"
|
|
2856
|
+
value || (value = isFailed(options) ? "Failed" : "Success");
|
|
2852
2857
|
const duration = getTimeOffset(startTime);
|
|
2853
2858
|
const args = [
|
|
2854
|
-
(128
|
|
2859
|
+
(128 | type),
|
|
2855
2860
|
title,
|
|
2856
2861
|
[value, formatTimeHint(duration)],
|
|
2857
2862
|
message,
|
|
@@ -2888,10 +2893,10 @@ class Module extends EventEmitter {
|
|
|
2888
2893
|
if (options.passThrough) {
|
|
2889
2894
|
message = null;
|
|
2890
2895
|
}
|
|
2891
|
-
const args = [(type | 512
|
|
2896
|
+
const args = [(type | 512), title, value, message, applyStyle(options, Module.LOG_STYLE_FAIL)];
|
|
2892
2897
|
applyLogId.call(this, options);
|
|
2893
2898
|
if (options.queue !== false && !options.passThrough && !this._logFlushed) {
|
|
2894
|
-
if (VALUES["error.out"
|
|
2899
|
+
if (VALUES["error.out"]) {
|
|
2895
2900
|
options.timeStamp = Date.now();
|
|
2896
2901
|
}
|
|
2897
2902
|
this._logQueued.push(args);
|
|
@@ -2902,9 +2907,9 @@ class Module extends EventEmitter {
|
|
|
2902
2907
|
const host = this.host;
|
|
2903
2908
|
const target = host || this;
|
|
2904
2909
|
let fatal;
|
|
2905
|
-
if (options.exec && (type & 4096
|
|
2910
|
+
if (options.exec && (type & 4096) && target.willAbort("(exec)")) {
|
|
2906
2911
|
const exec = { ...options.exec };
|
|
2907
|
-
let output = VALUES["permission.process_exec"
|
|
2912
|
+
let output = VALUES["permission.process_exec"].find(item => exec.command === ((0, types_1.isObject)(item) ? item.command : item));
|
|
2908
2913
|
if (output) {
|
|
2909
2914
|
if ((0, types_1.isPlainObject)(output)) {
|
|
2910
2915
|
output = { ...output };
|
|
@@ -2925,14 +2930,14 @@ class Module extends EventEmitter {
|
|
|
2925
2930
|
}
|
|
2926
2931
|
}
|
|
2927
2932
|
else {
|
|
2928
|
-
this.formatMessage(4096
|
|
2933
|
+
this.formatMessage(4096, "WARN!", "Exec command not permitted", exec.command, { ...Module.LOG_STYLE_WARN });
|
|
2929
2934
|
}
|
|
2930
2935
|
}
|
|
2931
2936
|
if (options.passThrough) {
|
|
2932
2937
|
return;
|
|
2933
2938
|
}
|
|
2934
2939
|
if (options.abortable !== false && (options.fatal !== false || this.isFatal(message))) {
|
|
2935
|
-
if (target.willAbort("(unknown)"
|
|
2940
|
+
if (target.willAbort("(unknown)")) {
|
|
2936
2941
|
if (host) {
|
|
2937
2942
|
host.abort();
|
|
2938
2943
|
}
|
|
@@ -2948,18 +2953,18 @@ class Module extends EventEmitter {
|
|
|
2948
2953
|
this.abort();
|
|
2949
2954
|
fatal = true;
|
|
2950
2955
|
}
|
|
2951
|
-
else if ((type & 8192
|
|
2952
|
-
(type & 1
|
|
2953
|
-
(type & 2
|
|
2954
|
-
(type & 8
|
|
2955
|
-
(type & 16
|
|
2956
|
-
(type & 32
|
|
2957
|
-
(type & 64
|
|
2958
|
-
(type & 1024
|
|
2959
|
-
(type & 2048
|
|
2960
|
-
(type & 4096
|
|
2961
|
-
(type & 16384
|
|
2962
|
-
(type & 65536
|
|
2956
|
+
else if ((type & 8192 && (!host || host.willAbort("(permission)"))) ||
|
|
2957
|
+
(type & 1) && target.willAbort("(system)") ||
|
|
2958
|
+
(type & 2) && target.willAbort("(node)") ||
|
|
2959
|
+
(type & 8) && target.willAbort("(compress)") ||
|
|
2960
|
+
(type & 16) && target.willAbort("(watch)") ||
|
|
2961
|
+
(type & 32) && target.willAbort("(file)") ||
|
|
2962
|
+
(type & 64) && target.willAbort("(cloud)") ||
|
|
2963
|
+
(type & 1024) && target.willAbort("(http)") ||
|
|
2964
|
+
(type & 2048) && target.willAbort("(image)") ||
|
|
2965
|
+
(type & 4096) && target.willAbort("(exec)") ||
|
|
2966
|
+
(type & 16384) && target.willAbort("(timeout)") ||
|
|
2967
|
+
(type & 65536) && target.willAbort("(db)")) {
|
|
2963
2968
|
if (host) {
|
|
2964
2969
|
if (host.abortable) {
|
|
2965
2970
|
host.abort();
|
|
@@ -2999,7 +3004,7 @@ class Module extends EventEmitter {
|
|
|
2999
3004
|
this.addLog(statusType, message || (Array.isArray(value) ? value[0] : value));
|
|
3000
3005
|
}
|
|
3001
3006
|
if (options.queue && !this._logFlushed) {
|
|
3002
|
-
if (VALUES["error.out"
|
|
3007
|
+
if (VALUES["error.out"] && (type & 512)) {
|
|
3003
3008
|
options.timeStamp = Date.now();
|
|
3004
3009
|
}
|
|
3005
3010
|
this._logQueued.push(args);
|
|
@@ -3021,7 +3026,7 @@ class Module extends EventEmitter {
|
|
|
3021
3026
|
if (typeof options === 'number') {
|
|
3022
3027
|
options = undefined;
|
|
3023
3028
|
}
|
|
3024
|
-
this.writeFail("Unknown"
|
|
3029
|
+
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] } });
|
|
3025
3030
|
return true;
|
|
3026
3031
|
}
|
|
3027
3032
|
if (value) {
|
|
@@ -3049,13 +3054,13 @@ class Module extends EventEmitter {
|
|
|
3049
3054
|
}
|
|
3050
3055
|
session.push(command);
|
|
3051
3056
|
let type = options.type || 0;
|
|
3052
|
-
type |= 4096
|
|
3053
|
-
type &= ~1
|
|
3057
|
+
type |= 4096;
|
|
3058
|
+
type &= ~1;
|
|
3054
3059
|
if (options.passThrough) {
|
|
3055
3060
|
options.passThrough = false;
|
|
3056
3061
|
message = null;
|
|
3057
3062
|
}
|
|
3058
|
-
return { type, value: ["Install required?"
|
|
3063
|
+
return { type, value: ["Install required?", command], message };
|
|
3059
3064
|
}
|
|
3060
3065
|
delete options.exec;
|
|
3061
3066
|
}
|
|
@@ -3143,7 +3148,7 @@ class Module extends EventEmitter {
|
|
|
3143
3148
|
message = '';
|
|
3144
3149
|
}
|
|
3145
3150
|
}
|
|
3146
|
-
this.status.push({ value: message.trim() || "Unknown"
|
|
3151
|
+
this.status.push({ value: message.trim() || "Unknown", name, duration, timeStamp, type, sessionId: this.sessionId, from: from || this.moduleName, source });
|
|
3147
3152
|
}
|
|
3148
3153
|
getLog(...type) {
|
|
3149
3154
|
return this.status.filter(item => type.includes(item.type));
|
|
@@ -3203,7 +3208,7 @@ class Module extends EventEmitter {
|
|
|
3203
3208
|
}
|
|
3204
3209
|
isFatal(err) {
|
|
3205
3210
|
const fatal = this.host?.config.error?.fatal;
|
|
3206
|
-
return fatal ?? VALUES["error.fatal"
|
|
3211
|
+
return fatal ?? VALUES["error.fatal"];
|
|
3207
3212
|
}
|
|
3208
3213
|
get moduleName() {
|
|
3209
3214
|
return this._moduleName;
|