@e-mc/module 0.11.4 → 0.11.7
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/README.md +6 -6
- package/index.js +38 -45
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
## Interface
|
|
11
11
|
|
|
12
|
-
* [View Source](https://www.unpkg.com/@e-mc/types@0.11.
|
|
12
|
+
* [View Source](https://www.unpkg.com/@e-mc/types@0.11.7/lib/index.d.ts)
|
|
13
13
|
|
|
14
14
|
```typescript
|
|
15
15
|
import type { LogStatus } from "./squared";
|
|
@@ -414,11 +414,11 @@ interface LoggerModule {
|
|
|
414
414
|
|
|
415
415
|
## References
|
|
416
416
|
|
|
417
|
-
- https://www.unpkg.com/@e-mc/types@0.11.
|
|
418
|
-
- https://www.unpkg.com/@e-mc/types@0.11.
|
|
419
|
-
- https://www.unpkg.com/@e-mc/types@0.11.
|
|
420
|
-
- https://www.unpkg.com/@e-mc/types@0.11.
|
|
421
|
-
- https://www.unpkg.com/@e-mc/types@0.11.
|
|
417
|
+
- https://www.unpkg.com/@e-mc/types@0.11.7/lib/core.d.ts
|
|
418
|
+
- https://www.unpkg.com/@e-mc/types@0.11.7/lib/logger.d.ts
|
|
419
|
+
- https://www.unpkg.com/@e-mc/types@0.11.7/lib/module.d.ts
|
|
420
|
+
- https://www.unpkg.com/@e-mc/types@0.11.7/lib/node.d.ts
|
|
421
|
+
- https://www.unpkg.com/@e-mc/types@0.11.7/lib/settings.d.ts
|
|
422
422
|
|
|
423
423
|
* https://www.npmjs.com/package/@types/node
|
|
424
424
|
|
package/index.js
CHANGED
|
@@ -941,8 +941,8 @@ function isPathUNC(value) {
|
|
|
941
941
|
value = value.toString();
|
|
942
942
|
return (VALUES["node.posix.strict"] && value.includes('/') ? /^\/\/[\w.-]+\/[\w-]+\$?\/[^\n]*?[^/]$/ : /^(?:\\\\|\/\/)[\w.-]+[\\/][\w-]+\$?[\\/][^\n]*?[^\\/]$/).test(value);
|
|
943
943
|
}
|
|
944
|
-
const
|
|
945
|
-
const formatLogMessage = (type, message, unit, ident) =>
|
|
944
|
+
const isErrorNo = (value) => value instanceof Error && (0, types_1.isString)(value.code);
|
|
945
|
+
const formatLogMessage = (type, message, unit, ident) => !ident && (type & 256) ? (unit + LOG_DIVIDER + message).trimEnd() : unit ? (type & 256) && ident ? unit + LOG_DIVIDER + message : (message + (ident ? '' : ' ') + unit).trimStart() : message;
|
|
946
946
|
const hideAbort = (err) => err.name === 'AbortError' && SETTINGS.abort === false;
|
|
947
947
|
const asFile = (value) => typeof value === 'string' ? PLATFORM_WIN32 ? value.trim() : value : value instanceof URL && value.protocol === 'file:' ? (0, node_url_1.fileURLToPath)(value) : '';
|
|
948
948
|
const wrapQuote = (value) => '"' + value.replaceAll('"', '\\"') + '"';
|
|
@@ -984,7 +984,7 @@ class Module extends EventEmitter {
|
|
|
984
984
|
this[_g] = null;
|
|
985
985
|
}
|
|
986
986
|
static get VERSION() {
|
|
987
|
-
return "0.11.
|
|
987
|
+
return "0.11.7";
|
|
988
988
|
}
|
|
989
989
|
static get LOG_TYPE() {
|
|
990
990
|
return types_1.LOG_TYPE;
|
|
@@ -1275,7 +1275,7 @@ class Module extends EventEmitter {
|
|
|
1275
1275
|
const logOptions = { maxLength: messageWidth ?? formatMessage.width, outLength: 0, messageTextWrap };
|
|
1276
1276
|
m = formatLogColumn(m, messageColor, messageBgColor, messageBold, messageUnitIndent ? format.meter.bgAltColor : undefined, logOptions);
|
|
1277
1277
|
if (u && messageTextWrap && messageTextWrap !== 'none' && LOG_MIN_WIDTH + logOptions.outLength + (0, node_util_1.stripVTControlCharacters)(unit).length + (messageUnitIndent ? 0 : 1) > PROCESS_STDOUT.columns) {
|
|
1278
|
-
if (
|
|
1278
|
+
if ((type & 256) && !messageUnitIndent) {
|
|
1279
1279
|
m = '';
|
|
1280
1280
|
if (LOG_MIN_WIDTH + (0, node_util_1.stripVTControlCharacters)(u).length > PROCESS_STDOUT.columns) {
|
|
1281
1281
|
u = '';
|
|
@@ -1668,11 +1668,7 @@ class Module extends EventEmitter {
|
|
|
1668
1668
|
}
|
|
1669
1669
|
}
|
|
1670
1670
|
static isErrorCode(err, ...code) {
|
|
1671
|
-
|
|
1672
|
-
const value = err.code;
|
|
1673
|
-
return typeof value === 'string' && code.includes(value);
|
|
1674
|
-
}
|
|
1675
|
-
return false;
|
|
1671
|
+
return isErrorNo(err) && code.includes(err.code);
|
|
1676
1672
|
}
|
|
1677
1673
|
static resolveFile(value) {
|
|
1678
1674
|
if (isFileURL(value = value instanceof URL ? value.toString() : value)) {
|
|
@@ -3517,10 +3513,13 @@ class Module extends EventEmitter {
|
|
|
3517
3513
|
else if (result === false) {
|
|
3518
3514
|
return;
|
|
3519
3515
|
}
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3516
|
+
const args = [
|
|
3517
|
+
(type | 512),
|
|
3518
|
+
title,
|
|
3519
|
+
value,
|
|
3520
|
+
message,
|
|
3521
|
+
applyStyle(options, Module.LOG_STYLE_FAIL)
|
|
3522
|
+
];
|
|
3524
3523
|
applySessionId(this, options);
|
|
3525
3524
|
if (options.queue !== false && !options.passThrough && !this._logFlushed) {
|
|
3526
3525
|
if (VALUES["error.out"]) {
|
|
@@ -3649,12 +3648,12 @@ class Module extends EventEmitter {
|
|
|
3649
3648
|
options = value;
|
|
3650
3649
|
value = undefined;
|
|
3651
3650
|
}
|
|
3652
|
-
if (
|
|
3651
|
+
if (name && isErrorNo(err) && err.code.endsWith(types_1.ERR_CODE.MODULE_NOT_FOUND)) {
|
|
3653
3652
|
if (typeof options === 'number') {
|
|
3654
3653
|
options = undefined;
|
|
3655
3654
|
}
|
|
3656
3655
|
const command = VALUES["node.settings.package_manager"] || (setPnpmVer() ? 'pnpm' : setYarnVer() ? 'yarn' : 'npm');
|
|
3657
|
-
this.writeFail("
|
|
3656
|
+
this.writeFail("Package not found", err, { ...options, type: types_1.LOG_TYPE.SYSTEM, code: err.code, exec: { command, args: [command === 'npm' ? 'i' : 'add', name] } });
|
|
3658
3657
|
return true;
|
|
3659
3658
|
}
|
|
3660
3659
|
if (value) {
|
|
@@ -3663,38 +3662,32 @@ class Module extends EventEmitter {
|
|
|
3663
3662
|
return false;
|
|
3664
3663
|
}
|
|
3665
3664
|
checkFail(message, options) {
|
|
3666
|
-
|
|
3667
|
-
if (code && message
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
options.passThrough = false;
|
|
3689
|
-
message = null;
|
|
3690
|
-
}
|
|
3691
|
-
return { type, value: ["Install required?", command], message };
|
|
3692
|
-
}
|
|
3693
|
-
delete options.exec;
|
|
3694
|
-
}
|
|
3695
|
-
break;
|
|
3665
|
+
let { code, exec } = options;
|
|
3666
|
+
if (!code && isErrorNo(message)) {
|
|
3667
|
+
code = message.code;
|
|
3668
|
+
}
|
|
3669
|
+
if (exec && code?.endsWith(types_1.ERR_CODE.MODULE_NOT_FOUND)) {
|
|
3670
|
+
if (!this.aborted) {
|
|
3671
|
+
const command = exec.command + (exec.args ? ' ' + exec.args.join(' ') : '');
|
|
3672
|
+
const target = this.host || this;
|
|
3673
|
+
let session = CACHE_EXEC.get(target);
|
|
3674
|
+
if (!session) {
|
|
3675
|
+
CACHE_EXEC.set(target, session = []);
|
|
3676
|
+
}
|
|
3677
|
+
if (session.includes(command)) {
|
|
3678
|
+
return false;
|
|
3679
|
+
}
|
|
3680
|
+
session.push(command);
|
|
3681
|
+
let type = options.type || 0;
|
|
3682
|
+
type |= 4096;
|
|
3683
|
+
type &= ~1;
|
|
3684
|
+
if (options.passThrough) {
|
|
3685
|
+
options.passThrough = false;
|
|
3686
|
+
message = null;
|
|
3696
3687
|
}
|
|
3688
|
+
return { type, value: ["Install required?", command], message };
|
|
3697
3689
|
}
|
|
3690
|
+
delete options.exec;
|
|
3698
3691
|
}
|
|
3699
3692
|
}
|
|
3700
3693
|
writeLog(type, value, timeStamp, duration) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/module",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.7",
|
|
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": "BSD-3-Clause",
|
|
21
21
|
"homepage": "https://github.com/anpham6/e-mc#readme",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@e-mc/types": "0.11.
|
|
23
|
+
"@e-mc/types": "0.11.7",
|
|
24
24
|
"chalk": "4.1.2",
|
|
25
25
|
"file-type": "^18.7.0",
|
|
26
26
|
"js-yaml": "^4.1.0",
|