@e-mc/module 0.6.2 → 0.6.3
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/index.js +31 -26
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -144,12 +144,14 @@ const YARN_VER = (function () {
|
|
|
144
144
|
})();
|
|
145
145
|
function applyStyle(options, style) {
|
|
146
146
|
var _h;
|
|
147
|
+
var _j;
|
|
147
148
|
for (const attr in style) {
|
|
148
|
-
(_h = options)[attr]
|
|
149
|
+
(_h = (_j = options)[attr]) !== null && _h !== void 0 ? _h : (_j[attr] = style[attr]);
|
|
149
150
|
}
|
|
150
151
|
return options;
|
|
151
152
|
}
|
|
152
153
|
function checkColorOptions(type, settings, options) {
|
|
154
|
+
var _h, _j, _k, _l;
|
|
153
155
|
if (typeof settings !== 'object') {
|
|
154
156
|
return false;
|
|
155
157
|
}
|
|
@@ -163,7 +165,7 @@ function checkColorOptions(type, settings, options) {
|
|
|
163
165
|
result = true;
|
|
164
166
|
}
|
|
165
167
|
if (typeof settings.valueBold === 'boolean') {
|
|
166
|
-
options.valueBold
|
|
168
|
+
(_h = options.valueBold) !== null && _h !== void 0 ? _h : (options.valueBold = settings.valueBold);
|
|
167
169
|
}
|
|
168
170
|
if (settings.hintColor) {
|
|
169
171
|
options.hintColor || (options.hintColor = settings.hintColor);
|
|
@@ -174,7 +176,7 @@ function checkColorOptions(type, settings, options) {
|
|
|
174
176
|
result = true;
|
|
175
177
|
}
|
|
176
178
|
if (typeof settings.hintBold === 'boolean') {
|
|
177
|
-
options.hintBold
|
|
179
|
+
(_j = options.hintBold) !== null && _j !== void 0 ? _j : (options.hintBold = settings.hintBold);
|
|
178
180
|
}
|
|
179
181
|
if (type & types_1.LOG_TYPE.FAIL) {
|
|
180
182
|
return result;
|
|
@@ -188,7 +190,7 @@ function checkColorOptions(type, settings, options) {
|
|
|
188
190
|
result = true;
|
|
189
191
|
}
|
|
190
192
|
if (typeof settings.titleBold === 'boolean') {
|
|
191
|
-
options.titleBold
|
|
193
|
+
(_k = options.titleBold) !== null && _k !== void 0 ? _k : (options.titleBold = settings.titleBold);
|
|
192
194
|
}
|
|
193
195
|
if (settings.messageColor) {
|
|
194
196
|
options.messageColor || (options.messageColor = settings.messageColor);
|
|
@@ -199,7 +201,7 @@ function checkColorOptions(type, settings, options) {
|
|
|
199
201
|
result = true;
|
|
200
202
|
}
|
|
201
203
|
if (typeof settings.messageBold === 'boolean') {
|
|
202
|
-
options.messageBold
|
|
204
|
+
(_l = options.messageBold) !== null && _l !== void 0 ? _l : (options.messageBold = settings.messageBold);
|
|
203
205
|
}
|
|
204
206
|
return result;
|
|
205
207
|
}
|
|
@@ -397,7 +399,7 @@ function checkFunction(value) {
|
|
|
397
399
|
}
|
|
398
400
|
function encryptMessage(data, cipher, algorithm) {
|
|
399
401
|
var _h;
|
|
400
|
-
if (cipher
|
|
402
|
+
if ((cipher === null || cipher === void 0 ? void 0 : cipher.key) && cipher.iv) {
|
|
401
403
|
if (!algorithm) {
|
|
402
404
|
algorithm = cipher.algorithm || 'aes-256-gcm';
|
|
403
405
|
}
|
|
@@ -458,7 +460,7 @@ function hasFileSystem(type, value, options, ignoreExists, overwrite) {
|
|
|
458
460
|
}
|
|
459
461
|
else if (options.hostPermissionOnly) {
|
|
460
462
|
const host = this.host;
|
|
461
|
-
if (host
|
|
463
|
+
if ((host === null || host === void 0 ? void 0 : host.permission) && !host[method](result)) {
|
|
462
464
|
if (options.throwsPermission) {
|
|
463
465
|
throw errorPermission(result);
|
|
464
466
|
}
|
|
@@ -557,7 +559,7 @@ class Module extends EventEmitter {
|
|
|
557
559
|
this[_f] = new AbortController();
|
|
558
560
|
this[_g] = null;
|
|
559
561
|
}
|
|
560
|
-
static get VERSION() { return "0.6.
|
|
562
|
+
static get VERSION() { return "0.6.3"; }
|
|
561
563
|
static get LOG_TYPE() { return types_1.LOG_TYPE; }
|
|
562
564
|
static get STATUS_TYPE() { return types_1.STATUS_TYPE; }
|
|
563
565
|
static get MAX_TIMEOUT() { return 2147483647; }
|
|
@@ -636,6 +638,7 @@ class Module extends EventEmitter {
|
|
|
636
638
|
return true;
|
|
637
639
|
}
|
|
638
640
|
static formatMessage(type, title, value, message, options = {}) {
|
|
641
|
+
var _h, _j, _k, _l;
|
|
639
642
|
if (options.type) {
|
|
640
643
|
type |= options.type;
|
|
641
644
|
}
|
|
@@ -675,7 +678,7 @@ class Module extends EventEmitter {
|
|
|
675
678
|
const titleIndent = options.titleIndent ? typeof options.titleIndent === 'number' ? Math.max(options.titleIndent, 0) : 0 : -1;
|
|
676
679
|
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);
|
|
677
680
|
if (Array.isArray(value)) {
|
|
678
|
-
hint = value[1]
|
|
681
|
+
hint = (_h = value[1]) !== null && _h !== void 0 ? _h : '';
|
|
679
682
|
value = value[0];
|
|
680
683
|
}
|
|
681
684
|
if (message && message instanceof Error) {
|
|
@@ -825,7 +828,7 @@ class Module extends EventEmitter {
|
|
|
825
828
|
}
|
|
826
829
|
}
|
|
827
830
|
if (bold) {
|
|
828
|
-
options.messageBold
|
|
831
|
+
(_j = options.messageBold) !== null && _j !== void 0 ? _j : (options.messageBold = true);
|
|
829
832
|
}
|
|
830
833
|
}
|
|
831
834
|
}
|
|
@@ -842,7 +845,7 @@ class Module extends EventEmitter {
|
|
|
842
845
|
}
|
|
843
846
|
if (!hintColor && !hintBgColor) {
|
|
844
847
|
({ color: hintColor, bgColor: hintBgColor } = formatHint);
|
|
845
|
-
hintBold
|
|
848
|
+
hintBold !== null && hintBold !== void 0 ? hintBold : (hintBold = formatHint.bold);
|
|
846
849
|
}
|
|
847
850
|
value = getValue() + (coloring ? chalk.blackBright('[') + formatColumn(truncateEnd(hint, hintWidth), hintColor, hintBgColor, hintBold) + chalk.blackBright(']') : `[${truncateEnd(hint, hintWidth)}]`);
|
|
848
851
|
}
|
|
@@ -858,7 +861,7 @@ class Module extends EventEmitter {
|
|
|
858
861
|
}
|
|
859
862
|
if (!valueColor && !valueBgColor) {
|
|
860
863
|
({ color: valueColor, bgColor: valueBgColor } = formatValue);
|
|
861
|
-
valueBold
|
|
864
|
+
valueBold !== null && valueBold !== void 0 ? valueBold : (valueBold = formatValue.bold);
|
|
862
865
|
}
|
|
863
866
|
try {
|
|
864
867
|
let v = value, i = id, m = message;
|
|
@@ -874,9 +877,9 @@ class Module extends EventEmitter {
|
|
|
874
877
|
const formatMessage = format.message;
|
|
875
878
|
if (!messageColor && !messageBgColor) {
|
|
876
879
|
({ color: messageColor, bgColor: messageBgColor, bold: messageBold } = formatMessage);
|
|
877
|
-
messageBold
|
|
880
|
+
messageBold !== null && messageBold !== void 0 ? messageBold : (messageBold = formatMessage.bold);
|
|
878
881
|
}
|
|
879
|
-
messageWidth
|
|
882
|
+
messageWidth !== null && messageWidth !== void 0 ? messageWidth : (messageWidth = formatMessage.width);
|
|
880
883
|
let u = unit;
|
|
881
884
|
if (u) {
|
|
882
885
|
if ((0, types_1.isObject)(SETTINGS.time_process)) {
|
|
@@ -897,13 +900,13 @@ class Module extends EventEmitter {
|
|
|
897
900
|
}
|
|
898
901
|
m = '';
|
|
899
902
|
}
|
|
900
|
-
output = (titleIndent !== -1 ? title : title ? formatColumn(title, titleColor || 'green', titleBgColor, (options.titleBold || formatTitle.bold)
|
|
903
|
+
output = (titleIndent !== -1 ? title : title ? formatColumn(title, titleColor || 'green', titleBgColor, (_k = (options.titleBold || formatTitle.bold)) !== null && _k !== void 0 ? _k : false) + chalk.blackBright(':') + ' ' : '') + formatColumn(v, valueColor, valueBgColor, valueBold) + (i ? i : ' ') + m;
|
|
901
904
|
}
|
|
902
905
|
catch {
|
|
903
906
|
}
|
|
904
907
|
}
|
|
905
908
|
if (!output) {
|
|
906
|
-
const m = truncateStart(this.asString(message), options.messageWidth
|
|
909
|
+
const m = truncateStart(this.asString(message), (_l = options.messageWidth) !== null && _l !== void 0 ? _l : format.message.width);
|
|
907
910
|
output = (titleIndent !== -1 ? title : title ? title + ': ' : '') + value + (id ? id : ' ') + (m && SETTINGS.message !== false ? (error ? '{' : '(') + getMessage(m, unit) + (error ? '}' : ')') : '');
|
|
908
911
|
}
|
|
909
912
|
if (broadcastId) {
|
|
@@ -1406,7 +1409,7 @@ class Module extends EventEmitter {
|
|
|
1406
1409
|
}
|
|
1407
1410
|
}
|
|
1408
1411
|
if (isFile) {
|
|
1409
|
-
if (ignoreFile
|
|
1412
|
+
if (ignoreFile === null || ignoreFile === void 0 ? void 0 : ignoreFile.test(name)) {
|
|
1410
1413
|
return ignore();
|
|
1411
1414
|
}
|
|
1412
1415
|
if (overwrite === false) {
|
|
@@ -1431,7 +1434,7 @@ class Module extends EventEmitter {
|
|
|
1431
1434
|
}));
|
|
1432
1435
|
}
|
|
1433
1436
|
else if (depth > 0 && (isDir || file.isDirectory())) {
|
|
1434
|
-
if (ignoreDir
|
|
1437
|
+
if (ignoreDir === null || ignoreDir === void 0 ? void 0 : ignoreDir.test(name)) {
|
|
1435
1438
|
return ignore();
|
|
1436
1439
|
}
|
|
1437
1440
|
recurse.call(this, paths.concat(name), depth - 1);
|
|
@@ -1947,6 +1950,7 @@ class Module extends EventEmitter {
|
|
|
1947
1950
|
}
|
|
1948
1951
|
static loadSettings(settings, password) {
|
|
1949
1952
|
var _h;
|
|
1953
|
+
var _j;
|
|
1950
1954
|
const current = VALUES["process.password"];
|
|
1951
1955
|
if (current) {
|
|
1952
1956
|
const proc = settings.process || {};
|
|
@@ -1962,7 +1966,7 @@ class Module extends EventEmitter {
|
|
|
1962
1966
|
}
|
|
1963
1967
|
}
|
|
1964
1968
|
else if ((0, types_1.isString)(password)) {
|
|
1965
|
-
VALUES["process.password"] = encryptMessage(password, settings.process
|
|
1969
|
+
VALUES["process.password"] = encryptMessage(password, (_h = settings.process) === null || _h === void 0 ? void 0 : _h.cipher);
|
|
1966
1970
|
}
|
|
1967
1971
|
const { temp, node, permission, memory, error, logger } = settings;
|
|
1968
1972
|
if ((0, types_1.isPlainObject)(node)) {
|
|
@@ -2008,7 +2012,7 @@ class Module extends EventEmitter {
|
|
|
2008
2012
|
VALUES["process.env.apply"] = env.apply;
|
|
2009
2013
|
}
|
|
2010
2014
|
if ((0, types_1.isString)(pwd)) {
|
|
2011
|
-
VALUES[
|
|
2015
|
+
VALUES[_j = "process.password"] || (VALUES[_j] = encryptMessage(pwd, cipher));
|
|
2012
2016
|
}
|
|
2013
2017
|
}
|
|
2014
2018
|
if (memory && (0, types_1.isPlainObject)(memory.settings)) {
|
|
@@ -2148,7 +2152,7 @@ class Module extends EventEmitter {
|
|
|
2148
2152
|
break;
|
|
2149
2153
|
}
|
|
2150
2154
|
}
|
|
2151
|
-
if (broadcast
|
|
2155
|
+
if (broadcast === null || broadcast === void 0 ? void 0 : broadcast.out) {
|
|
2152
2156
|
VALUES["broadcast.out"] = this.parseFunction(broadcast.out, { external: true, absolute: true });
|
|
2153
2157
|
}
|
|
2154
2158
|
if (stack_trace && stack_trace !== true && +stack_trace > 0) {
|
|
@@ -2244,7 +2248,7 @@ class Module extends EventEmitter {
|
|
|
2244
2248
|
}
|
|
2245
2249
|
const host = this.host;
|
|
2246
2250
|
const item = this[kSupports][name];
|
|
2247
|
-
return host && !item
|
|
2251
|
+
return host && !(item === null || item === void 0 ? void 0 : item.modified) ? host.supports(name) : (item === null || item === void 0 ? void 0 : item.value) === true;
|
|
2248
2252
|
}
|
|
2249
2253
|
getTempDir(pathname, filename, createDir) {
|
|
2250
2254
|
let increment = 0, moduleDir, uuidDir;
|
|
@@ -2268,11 +2272,11 @@ class Module extends EventEmitter {
|
|
|
2268
2272
|
let result;
|
|
2269
2273
|
if ((0, types_1.isString)(pathname)) {
|
|
2270
2274
|
leading.push(pathname);
|
|
2271
|
-
createDir
|
|
2275
|
+
createDir !== null && createDir !== void 0 ? createDir : (createDir = true);
|
|
2272
2276
|
}
|
|
2273
2277
|
if (uuidDir) {
|
|
2274
2278
|
leading.push((0, types_1.generateUUID)());
|
|
2275
|
-
createDir
|
|
2279
|
+
createDir !== null && createDir !== void 0 ? createDir : (createDir = true);
|
|
2276
2280
|
}
|
|
2277
2281
|
if ((createDir || increment > 0) && !Module.isDir(result = path.join(...leading))) {
|
|
2278
2282
|
const [output] = tryIncrementDir(result, increment);
|
|
@@ -3207,8 +3211,9 @@ class Module extends EventEmitter {
|
|
|
3207
3211
|
return !!this[kPermission];
|
|
3208
3212
|
}
|
|
3209
3213
|
isFatal(err) {
|
|
3210
|
-
|
|
3211
|
-
|
|
3214
|
+
var _h, _j;
|
|
3215
|
+
const fatal = (_j = (_h = this.host) === null || _h === void 0 ? void 0 : _h.config.error) === null || _j === void 0 ? void 0 : _j.fatal;
|
|
3216
|
+
return fatal !== null && fatal !== void 0 ? fatal : VALUES["error.fatal"];
|
|
3212
3217
|
}
|
|
3213
3218
|
get moduleName() {
|
|
3214
3219
|
return this._moduleName;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/module",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"description": "Module base class for E-mc.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"homepage": "https://github.com/anpham6/e-mc#readme",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@e-mc/types": "0.6.
|
|
23
|
+
"@e-mc/types": "0.6.3",
|
|
24
24
|
"abort-controller": "^3.0.0",
|
|
25
25
|
"chalk": "4.1.2",
|
|
26
26
|
"event-target-shim": "^5.0.1",
|