@e-mc/module 0.7.2 → 0.7.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 +4 -8
- package/README.md +1 -1
- package/index.js +31 -26
- package/package.json +2 -2
package/LICENSE
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
Copyright 2023
|
|
1
|
+
Copyright 2023 Sukina
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
10
|
-
|
|
11
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
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.7.
|
|
562
|
+
static get VERSION() { return "0.7.4"; }
|
|
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) {
|
|
@@ -1437,7 +1440,7 @@ class Module extends EventEmitter {
|
|
|
1437
1440
|
}
|
|
1438
1441
|
}
|
|
1439
1442
|
if (isFile) {
|
|
1440
|
-
if (ignoreFile
|
|
1443
|
+
if (ignoreFile === null || ignoreFile === void 0 ? void 0 : ignoreFile.test(name)) {
|
|
1441
1444
|
return ignore();
|
|
1442
1445
|
}
|
|
1443
1446
|
if (overwrite === false) {
|
|
@@ -1462,7 +1465,7 @@ class Module extends EventEmitter {
|
|
|
1462
1465
|
}));
|
|
1463
1466
|
}
|
|
1464
1467
|
else if (depth > 0 && (isDir || file.isDirectory())) {
|
|
1465
|
-
if (ignoreDir
|
|
1468
|
+
if (ignoreDir === null || ignoreDir === void 0 ? void 0 : ignoreDir.test(name)) {
|
|
1466
1469
|
return ignore();
|
|
1467
1470
|
}
|
|
1468
1471
|
recurse.call(this, paths.concat(name), depth - 1);
|
|
@@ -1978,6 +1981,7 @@ class Module extends EventEmitter {
|
|
|
1978
1981
|
}
|
|
1979
1982
|
static loadSettings(settings, password) {
|
|
1980
1983
|
var _h;
|
|
1984
|
+
var _j;
|
|
1981
1985
|
const current = VALUES["process.password"];
|
|
1982
1986
|
if (current) {
|
|
1983
1987
|
const proc = settings.process || {};
|
|
@@ -1993,7 +1997,7 @@ class Module extends EventEmitter {
|
|
|
1993
1997
|
}
|
|
1994
1998
|
}
|
|
1995
1999
|
else if ((0, types_1.isString)(password)) {
|
|
1996
|
-
VALUES["process.password"] = encryptMessage(password, settings.process
|
|
2000
|
+
VALUES["process.password"] = encryptMessage(password, (_h = settings.process) === null || _h === void 0 ? void 0 : _h.cipher);
|
|
1997
2001
|
}
|
|
1998
2002
|
const { temp, node, permission, memory, error, logger } = settings;
|
|
1999
2003
|
if ((0, types_1.isPlainObject)(node)) {
|
|
@@ -2039,7 +2043,7 @@ class Module extends EventEmitter {
|
|
|
2039
2043
|
VALUES["process.env.apply"] = env.apply;
|
|
2040
2044
|
}
|
|
2041
2045
|
if ((0, types_1.isString)(pwd)) {
|
|
2042
|
-
VALUES[
|
|
2046
|
+
VALUES[_j = "process.password"] || (VALUES[_j] = encryptMessage(pwd, cipher));
|
|
2043
2047
|
}
|
|
2044
2048
|
}
|
|
2045
2049
|
if (memory && (0, types_1.isPlainObject)(memory.settings)) {
|
|
@@ -2179,7 +2183,7 @@ class Module extends EventEmitter {
|
|
|
2179
2183
|
break;
|
|
2180
2184
|
}
|
|
2181
2185
|
}
|
|
2182
|
-
if (broadcast
|
|
2186
|
+
if (broadcast === null || broadcast === void 0 ? void 0 : broadcast.out) {
|
|
2183
2187
|
VALUES["broadcast.out"] = this.parseFunction(broadcast.out, { external: true, absolute: true });
|
|
2184
2188
|
}
|
|
2185
2189
|
if (stack_trace && stack_trace !== true && +stack_trace > 0) {
|
|
@@ -2275,7 +2279,7 @@ class Module extends EventEmitter {
|
|
|
2275
2279
|
}
|
|
2276
2280
|
const host = this.host;
|
|
2277
2281
|
const item = this[kSupports][name];
|
|
2278
|
-
return host && !item
|
|
2282
|
+
return host && !(item === null || item === void 0 ? void 0 : item.modified) ? host.supports(name) : (item === null || item === void 0 ? void 0 : item.value) === true;
|
|
2279
2283
|
}
|
|
2280
2284
|
getTempDir(pathname, filename, createDir) {
|
|
2281
2285
|
let increment = 0, moduleDir, uuidDir;
|
|
@@ -2299,11 +2303,11 @@ class Module extends EventEmitter {
|
|
|
2299
2303
|
let result;
|
|
2300
2304
|
if ((0, types_1.isString)(pathname)) {
|
|
2301
2305
|
leading.push(pathname);
|
|
2302
|
-
createDir
|
|
2306
|
+
createDir !== null && createDir !== void 0 ? createDir : (createDir = true);
|
|
2303
2307
|
}
|
|
2304
2308
|
if (uuidDir) {
|
|
2305
2309
|
leading.push((0, types_1.generateUUID)());
|
|
2306
|
-
createDir
|
|
2310
|
+
createDir !== null && createDir !== void 0 ? createDir : (createDir = true);
|
|
2307
2311
|
}
|
|
2308
2312
|
if ((createDir || increment > 0) && !Module.isDir(result = path.join(...leading))) {
|
|
2309
2313
|
const [output] = tryIncrementDir(result, increment);
|
|
@@ -3238,8 +3242,9 @@ class Module extends EventEmitter {
|
|
|
3238
3242
|
return !!this[kPermission];
|
|
3239
3243
|
}
|
|
3240
3244
|
isFatal(err) {
|
|
3241
|
-
|
|
3242
|
-
|
|
3245
|
+
var _h, _j;
|
|
3246
|
+
const fatal = (_j = (_h = this.host) === null || _h === void 0 ? void 0 : _h.config.error) === null || _j === void 0 ? void 0 : _j.fatal;
|
|
3247
|
+
return fatal !== null && fatal !== void 0 ? fatal : VALUES["error.fatal"];
|
|
3243
3248
|
}
|
|
3244
3249
|
get moduleName() {
|
|
3245
3250
|
return this._moduleName;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/module",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.4",
|
|
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.7.
|
|
23
|
+
"@e-mc/types": "0.7.4",
|
|
24
24
|
"abort-controller": "^3.0.0",
|
|
25
25
|
"chalk": "4.1.2",
|
|
26
26
|
"event-target-shim": "^5.0.1",
|