@e-mc/module 0.8.18 → 0.8.19
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 +5 -5
- package/index.d.ts +4 -4
- package/index.js +21 -8
- package/lib-v4.d.ts +4 -4
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
## Interface
|
|
11
11
|
|
|
12
|
-
- https://www.unpkg.com/@e-mc/types@0.8.
|
|
12
|
+
- https://www.unpkg.com/@e-mc/types@0.8.19/lib/index.d.ts
|
|
13
13
|
|
|
14
14
|
```typescript
|
|
15
15
|
import type { LogStatus } from "./squared";
|
|
@@ -231,10 +231,10 @@ interface ModuleConstructor {
|
|
|
231
231
|
|
|
232
232
|
## References
|
|
233
233
|
|
|
234
|
-
- https://www.unpkg.com/@e-mc/types@0.8.
|
|
235
|
-
- https://www.unpkg.com/@e-mc/types@0.8.
|
|
236
|
-
- https://www.unpkg.com/@e-mc/types@0.8.
|
|
237
|
-
- https://www.unpkg.com/@e-mc/types@0.8.
|
|
234
|
+
- https://www.unpkg.com/@e-mc/types@0.8.19/lib/core.d.ts
|
|
235
|
+
- https://www.unpkg.com/@e-mc/types@0.8.19/lib/logger.d.ts
|
|
236
|
+
- https://www.unpkg.com/@e-mc/types@0.8.19/lib/module.d.ts
|
|
237
|
+
- https://www.unpkg.com/@e-mc/types@0.8.19/lib/node.d.ts
|
|
238
238
|
|
|
239
239
|
## LICENSE
|
|
240
240
|
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ModuleConstructor } from '
|
|
2
|
-
|
|
3
|
-
declare const Module: ModuleConstructor;
|
|
4
|
-
|
|
1
|
+
import type { ModuleConstructor } from '@e-mc/types/lib';
|
|
2
|
+
|
|
3
|
+
declare const Module: ModuleConstructor;
|
|
4
|
+
|
|
5
5
|
export = Module;
|
package/index.js
CHANGED
|
@@ -106,6 +106,7 @@ const VALUES = {
|
|
|
106
106
|
["node.process.cpu_usage"]: true,
|
|
107
107
|
["node.process.memory_usage"]: true,
|
|
108
108
|
["node.process.inline"]: true,
|
|
109
|
+
["node.settings.package_manager"]: '',
|
|
109
110
|
["temp.dir"]: "tmp",
|
|
110
111
|
["temp.write"]: false,
|
|
111
112
|
["process.password"]: '',
|
|
@@ -176,7 +177,7 @@ function setPnpmVer() {
|
|
|
176
177
|
value = value.substring(0, index);
|
|
177
178
|
}
|
|
178
179
|
index = value.lastIndexOf(value.indexOf('@', 2) !== -1 ? '@' : '/');
|
|
179
|
-
const name = value.substring(
|
|
180
|
+
const name = value.substring(0, index).replace(/^\//, '');
|
|
180
181
|
const version = value.substring(index + 1);
|
|
181
182
|
if (!items.find(item => item[0] === name && item[1] === version)) {
|
|
182
183
|
items.push([name, version]);
|
|
@@ -714,7 +715,7 @@ class Module extends EventEmitter {
|
|
|
714
715
|
this[_f] = new AbortController();
|
|
715
716
|
this[_g] = null;
|
|
716
717
|
}
|
|
717
|
-
static get VERSION() { return "0.8.
|
|
718
|
+
static get VERSION() { return "0.8.19"; }
|
|
718
719
|
static get LOG_TYPE() { return types_1.LOG_TYPE; }
|
|
719
720
|
static get STATUS_TYPE() { return types_1.STATUS_TYPE; }
|
|
720
721
|
static get MAX_TIMEOUT() { return 2147483647; }
|
|
@@ -756,6 +757,7 @@ class Module extends EventEmitter {
|
|
|
756
757
|
case "error.fatal":
|
|
757
758
|
return VALUES[key];
|
|
758
759
|
case "node.require.ext":
|
|
760
|
+
case "node.settings.package_manager":
|
|
759
761
|
case "process.password":
|
|
760
762
|
case "process.cipher.algorithm":
|
|
761
763
|
return VALUES[key] !== '';
|
|
@@ -2090,8 +2092,8 @@ class Module extends EventEmitter {
|
|
|
2090
2092
|
}
|
|
2091
2093
|
static sanitizeArgs(values, doubleQuote) {
|
|
2092
2094
|
const result = typeof values === 'string' ? [values] : values;
|
|
2093
|
-
const pattern = /[
|
|
2094
|
-
const sanitize = (value) => value.replace(pattern, capture => (capture === '$' || capture === '`' ? '\\' : '') + '\\' + capture);
|
|
2095
|
+
const pattern = /[^\w+-.,/:@]/g;
|
|
2096
|
+
const sanitize = (value) => value.replace(pattern, capture => capture === '\n' ? "'\n'" : (capture === '$' || capture === '`' ? '\\' : '') + '\\' + capture);
|
|
2095
2097
|
for (let i = 0; i < result.length; ++i) {
|
|
2096
2098
|
let value = result[i].trim(), leading = '';
|
|
2097
2099
|
if (value !== '--') {
|
|
@@ -2204,8 +2206,8 @@ class Module extends EventEmitter {
|
|
|
2204
2206
|
}
|
|
2205
2207
|
}
|
|
2206
2208
|
static loadSettings(settings, password) {
|
|
2207
|
-
var _h;
|
|
2208
|
-
var
|
|
2209
|
+
var _h, _j;
|
|
2210
|
+
var _k;
|
|
2209
2211
|
const current = VALUES["process.password"];
|
|
2210
2212
|
if (current) {
|
|
2211
2213
|
const proc = settings.process || {};
|
|
@@ -2260,6 +2262,17 @@ class Module extends EventEmitter {
|
|
|
2260
2262
|
VALUES["node.require.inline"] = inline;
|
|
2261
2263
|
}
|
|
2262
2264
|
}
|
|
2265
|
+
const manager = (_j = node.settings) === null || _j === void 0 ? void 0 : _j.package_manager;
|
|
2266
|
+
switch (manager) {
|
|
2267
|
+
case 'npm':
|
|
2268
|
+
case 'yarn':
|
|
2269
|
+
case 'pnpm':
|
|
2270
|
+
VALUES["node.settings.package_manager"] = manager;
|
|
2271
|
+
break;
|
|
2272
|
+
default:
|
|
2273
|
+
VALUES["node.settings.package_manager"] = '';
|
|
2274
|
+
break;
|
|
2275
|
+
}
|
|
2263
2276
|
}
|
|
2264
2277
|
if ((0, types_1.isPlainObject)(settings.process)) {
|
|
2265
2278
|
const { env, cipher, password: pwd } = settings.process;
|
|
@@ -2267,7 +2280,7 @@ class Module extends EventEmitter {
|
|
|
2267
2280
|
VALUES["process.env.apply"] = env.apply;
|
|
2268
2281
|
}
|
|
2269
2282
|
if ((0, types_1.isString)(pwd)) {
|
|
2270
|
-
VALUES[
|
|
2283
|
+
VALUES[_k = "process.password"] || (VALUES[_k] = encryptMessage(pwd, cipher));
|
|
2271
2284
|
}
|
|
2272
2285
|
}
|
|
2273
2286
|
if ((0, types_1.isPlainObject)(memory === null || memory === void 0 ? void 0 : memory.settings)) {
|
|
@@ -3347,7 +3360,7 @@ class Module extends EventEmitter {
|
|
|
3347
3360
|
if (typeof options === 'number') {
|
|
3348
3361
|
options = undefined;
|
|
3349
3362
|
}
|
|
3350
|
-
this.writeFail("Unknown", err, { ...options, type: types_1.LOG_TYPE.SYSTEM, code: types_1.ERR_CODE.MODULE_NOT_FOUND, exec: { command: 'npm', args: ['
|
|
3363
|
+
this.writeFail("Unknown", err, { ...options, type: types_1.LOG_TYPE.SYSTEM, code: types_1.ERR_CODE.MODULE_NOT_FOUND, exec: { command: VALUES["node.settings.package_manager"] || (setPnpmVer() ? 'pnpm' : setYarnVer() ? 'yarn' : 'npm'), args: ['install', name] } });
|
|
3351
3364
|
return true;
|
|
3352
3365
|
}
|
|
3353
3366
|
if (value) {
|
package/lib-v4.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { IModuleLibV4 } from '
|
|
2
|
-
|
|
3
|
-
declare const LibV4: IModuleLibV4;
|
|
4
|
-
|
|
1
|
+
import type { IModuleLibV4 } from '@e-mc/types/lib/compat-v4';
|
|
2
|
+
|
|
3
|
+
declare const LibV4: IModuleLibV4;
|
|
4
|
+
|
|
5
5
|
export = LibV4;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/module",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.19",
|
|
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.8.
|
|
23
|
+
"@e-mc/types": "0.8.19",
|
|
24
24
|
"abort-controller": "^3.0.0",
|
|
25
25
|
"chalk": "4.1.2",
|
|
26
26
|
"event-target-shim": "^5.0.1",
|