@e-mc/module 0.11.5 → 0.11.8
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 +50 -50
- 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.8/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.8/lib/core.d.ts
|
|
418
|
+
- https://www.unpkg.com/@e-mc/types@0.11.8/lib/logger.d.ts
|
|
419
|
+
- https://www.unpkg.com/@e-mc/types@0.11.8/lib/module.d.ts
|
|
420
|
+
- https://www.unpkg.com/@e-mc/types@0.11.8/lib/node.d.ts
|
|
421
|
+
- https://www.unpkg.com/@e-mc/types@0.11.8/lib/settings.d.ts
|
|
422
422
|
|
|
423
423
|
* https://www.npmjs.com/package/@types/node
|
|
424
424
|
|
package/index.js
CHANGED
|
@@ -647,7 +647,7 @@ function getCacheTotal() {
|
|
|
647
647
|
return CACHE_READTEXT.size + CACHE_READBUFFER.size + CACHE_READCJS.size;
|
|
648
648
|
}
|
|
649
649
|
function isMatch(key, value) {
|
|
650
|
-
return pm.isMatch(key, value, {
|
|
650
|
+
return pm.isMatch(key, value, { nocase: PLATFORM_WIN32, matchBase: value.startsWith('*') && !value.includes('/') });
|
|
651
651
|
}
|
|
652
652
|
function listDir(src, paths, depth, include, exclude, excludeDir, outFiles) {
|
|
653
653
|
const srcDir = path.join(src, ...paths);
|
|
@@ -941,6 +941,7 @@ 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 isErrorNo = (value) => value instanceof Error && (0, types_1.isString)(value.code);
|
|
944
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;
|
|
945
946
|
const hideAbort = (err) => err.name === 'AbortError' && SETTINGS.abort === false;
|
|
946
947
|
const asFile = (value) => typeof value === 'string' ? PLATFORM_WIN32 ? value.trim() : value : value instanceof URL && value.protocol === 'file:' ? (0, node_url_1.fileURLToPath)(value) : '';
|
|
@@ -983,7 +984,7 @@ class Module extends EventEmitter {
|
|
|
983
984
|
this[_g] = null;
|
|
984
985
|
}
|
|
985
986
|
static get VERSION() {
|
|
986
|
-
return "0.11.
|
|
987
|
+
return "0.11.8";
|
|
987
988
|
}
|
|
988
989
|
static get LOG_TYPE() {
|
|
989
990
|
return types_1.LOG_TYPE;
|
|
@@ -1558,22 +1559,28 @@ class Module extends EventEmitter {
|
|
|
1558
1559
|
filename = undefined;
|
|
1559
1560
|
}
|
|
1560
1561
|
if (typeof value === 'string') {
|
|
1561
|
-
let pathname = PLATFORM_WIN32 ? value.trim() : value
|
|
1562
|
+
let pathname = PLATFORM_WIN32 ? value.trim() : value;
|
|
1562
1563
|
if (normalize) {
|
|
1563
1564
|
pathname = path.normalize(pathname);
|
|
1564
|
-
convert = PLATFORM_WIN32;
|
|
1565
1565
|
}
|
|
1566
|
-
if (
|
|
1566
|
+
if (PLATFORM_WIN32) {
|
|
1567
1567
|
pathname = pathname.replace(/(?:^\\|\\+)/g, '/');
|
|
1568
1568
|
}
|
|
1569
|
-
if (pathname
|
|
1569
|
+
if (pathname) {
|
|
1570
|
+
pathname = pathname.replace(/(?<!^)\/+$/, '');
|
|
1570
1571
|
if (normalize && PLATFORM_WIN32) {
|
|
1571
1572
|
const match = /^([A-Z]):\//.exec(pathname);
|
|
1572
1573
|
if (match) {
|
|
1573
1574
|
pathname = match[1].toLowerCase() + pathname.substring(1);
|
|
1574
1575
|
}
|
|
1575
1576
|
}
|
|
1576
|
-
|
|
1577
|
+
if (!filename) {
|
|
1578
|
+
return pathname;
|
|
1579
|
+
}
|
|
1580
|
+
if (pathname !== '/') {
|
|
1581
|
+
pathname += '/';
|
|
1582
|
+
}
|
|
1583
|
+
return pathname + filename;
|
|
1577
1584
|
}
|
|
1578
1585
|
}
|
|
1579
1586
|
return filename || '';
|
|
@@ -1667,11 +1674,7 @@ class Module extends EventEmitter {
|
|
|
1667
1674
|
}
|
|
1668
1675
|
}
|
|
1669
1676
|
static isErrorCode(err, ...code) {
|
|
1670
|
-
|
|
1671
|
-
const value = err.code;
|
|
1672
|
-
return typeof value === 'string' && code.includes(value);
|
|
1673
|
-
}
|
|
1674
|
-
return false;
|
|
1677
|
+
return isErrorNo(err) && code.includes(err.code);
|
|
1675
1678
|
}
|
|
1676
1679
|
static resolveFile(value) {
|
|
1677
1680
|
if (isFileURL(value = value instanceof URL ? value.toString() : value)) {
|
|
@@ -1953,7 +1956,7 @@ class Module extends EventEmitter {
|
|
|
1953
1956
|
if (!(outDir && this.isDir(outDir))) {
|
|
1954
1957
|
return Promise.reject(errorDirectory(asFile(src) || "Unknown"));
|
|
1955
1958
|
}
|
|
1956
|
-
const pmOpts = {
|
|
1959
|
+
const pmOpts = PLATFORM_WIN32 ? { nocase: true, posixSlashes: true, windows: true } : {};
|
|
1957
1960
|
let exclude, excludeDir, recursive;
|
|
1958
1961
|
if ((0, types_1.isObject)(options)) {
|
|
1959
1962
|
if (options.matchBase) {
|
|
@@ -1972,7 +1975,7 @@ class Module extends EventEmitter {
|
|
|
1972
1975
|
for (const value of items) {
|
|
1973
1976
|
const dirEnd = value.endsWith('/') ? /^[^/][^*]+\/$/ : value.endsWith('\\') ? /^[^\\][^*]+\\$/ : null;
|
|
1974
1977
|
if (dirEnd?.test(value) && !(0, types_1.hasGlob)(value)) {
|
|
1975
|
-
(excludeDir ||= []).push(this.
|
|
1978
|
+
(excludeDir ||= []).push(this.toPosix(value, true));
|
|
1976
1979
|
}
|
|
1977
1980
|
else {
|
|
1978
1981
|
exclude.push(value);
|
|
@@ -3516,10 +3519,13 @@ class Module extends EventEmitter {
|
|
|
3516
3519
|
else if (result === false) {
|
|
3517
3520
|
return;
|
|
3518
3521
|
}
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3522
|
+
const args = [
|
|
3523
|
+
(type | 512),
|
|
3524
|
+
title,
|
|
3525
|
+
value,
|
|
3526
|
+
message,
|
|
3527
|
+
applyStyle(options, Module.LOG_STYLE_FAIL)
|
|
3528
|
+
];
|
|
3523
3529
|
applySessionId(this, options);
|
|
3524
3530
|
if (options.queue !== false && !options.passThrough && !this._logFlushed) {
|
|
3525
3531
|
if (VALUES["error.out"]) {
|
|
@@ -3648,12 +3654,12 @@ class Module extends EventEmitter {
|
|
|
3648
3654
|
options = value;
|
|
3649
3655
|
value = undefined;
|
|
3650
3656
|
}
|
|
3651
|
-
if (
|
|
3657
|
+
if (name && isErrorNo(err) && err.code.endsWith(types_1.ERR_CODE.MODULE_NOT_FOUND)) {
|
|
3652
3658
|
if (typeof options === 'number') {
|
|
3653
3659
|
options = undefined;
|
|
3654
3660
|
}
|
|
3655
3661
|
const command = VALUES["node.settings.package_manager"] || (setPnpmVer() ? 'pnpm' : setYarnVer() ? 'yarn' : 'npm');
|
|
3656
|
-
this.writeFail("
|
|
3662
|
+
this.writeFail("Package not found", err, { ...options, type: types_1.LOG_TYPE.SYSTEM, code: err.code, exec: { command, args: [command === 'npm' ? 'i' : 'add', name] } });
|
|
3657
3663
|
return true;
|
|
3658
3664
|
}
|
|
3659
3665
|
if (value) {
|
|
@@ -3662,38 +3668,32 @@ class Module extends EventEmitter {
|
|
|
3662
3668
|
return false;
|
|
3663
3669
|
}
|
|
3664
3670
|
checkFail(message, options) {
|
|
3665
|
-
|
|
3666
|
-
if (code && message
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
options.passThrough = false;
|
|
3688
|
-
message = null;
|
|
3689
|
-
}
|
|
3690
|
-
return { type, value: ["Install required?", command], message };
|
|
3691
|
-
}
|
|
3692
|
-
delete options.exec;
|
|
3693
|
-
}
|
|
3694
|
-
break;
|
|
3671
|
+
let { code, exec } = options;
|
|
3672
|
+
if (!code && isErrorNo(message)) {
|
|
3673
|
+
code = message.code;
|
|
3674
|
+
}
|
|
3675
|
+
if (exec && code?.endsWith(types_1.ERR_CODE.MODULE_NOT_FOUND)) {
|
|
3676
|
+
if (!this.aborted) {
|
|
3677
|
+
const command = exec.command + (exec.args ? ' ' + exec.args.join(' ') : '');
|
|
3678
|
+
const target = this.host || this;
|
|
3679
|
+
let session = CACHE_EXEC.get(target);
|
|
3680
|
+
if (!session) {
|
|
3681
|
+
CACHE_EXEC.set(target, session = []);
|
|
3682
|
+
}
|
|
3683
|
+
if (session.includes(command)) {
|
|
3684
|
+
return false;
|
|
3685
|
+
}
|
|
3686
|
+
session.push(command);
|
|
3687
|
+
let type = options.type || 0;
|
|
3688
|
+
type |= 4096;
|
|
3689
|
+
type &= ~1;
|
|
3690
|
+
if (options.passThrough) {
|
|
3691
|
+
options.passThrough = false;
|
|
3692
|
+
message = null;
|
|
3695
3693
|
}
|
|
3694
|
+
return { type, value: ["Install required?", command], message };
|
|
3696
3695
|
}
|
|
3696
|
+
delete options.exec;
|
|
3697
3697
|
}
|
|
3698
3698
|
}
|
|
3699
3699
|
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.8",
|
|
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.8",
|
|
24
24
|
"chalk": "4.1.2",
|
|
25
25
|
"file-type": "^18.7.0",
|
|
26
26
|
"js-yaml": "^4.1.0",
|