@e-mc/module 0.9.10 → 0.9.11
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 +9 -6
- package/index.d.ts +4 -4
- package/index.js +18 -5
- 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
|
-
* [View Source](https://www.unpkg.com/@e-mc/types@0.9.
|
|
12
|
+
* [View Source](https://www.unpkg.com/@e-mc/types@0.9.11/lib/index.d.ts)
|
|
13
13
|
|
|
14
14
|
```typescript
|
|
15
15
|
import type { LogStatus } from "./squared";
|
|
@@ -256,6 +256,9 @@ interface NodeModule {
|
|
|
256
256
|
npm?: boolean;
|
|
257
257
|
inline?: boolean;
|
|
258
258
|
};
|
|
259
|
+
settings?: {
|
|
260
|
+
package_manager?: "npm" | "yarn" | "pnpm";
|
|
261
|
+
};
|
|
259
262
|
}
|
|
260
263
|
|
|
261
264
|
interface ProcessModule {
|
|
@@ -389,11 +392,11 @@ type ForegroundColor = typeof IForegroundColor | `#${string}`;
|
|
|
389
392
|
|
|
390
393
|
## References
|
|
391
394
|
|
|
392
|
-
- https://www.unpkg.com/@e-mc/types@0.9.
|
|
393
|
-
- https://www.unpkg.com/@e-mc/types@0.9.
|
|
394
|
-
- https://www.unpkg.com/@e-mc/types@0.9.
|
|
395
|
-
- https://www.unpkg.com/@e-mc/types@0.9.
|
|
396
|
-
- https://www.unpkg.com/@e-mc/types@0.9.
|
|
395
|
+
- https://www.unpkg.com/@e-mc/types@0.9.11/lib/core.d.ts
|
|
396
|
+
- https://www.unpkg.com/@e-mc/types@0.9.11/lib/logger.d.ts
|
|
397
|
+
- https://www.unpkg.com/@e-mc/types@0.9.11/lib/module.d.ts
|
|
398
|
+
- https://www.unpkg.com/@e-mc/types@0.9.11/lib/node.d.ts
|
|
399
|
+
- https://www.unpkg.com/@e-mc/types@0.9.11/lib/settings.d.ts
|
|
397
400
|
|
|
398
401
|
* https://www.npmjs.com/package/@types/node
|
|
399
402
|
|
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]);
|
|
@@ -720,7 +721,7 @@ class Module extends EventEmitter {
|
|
|
720
721
|
this[_f] = new AbortController();
|
|
721
722
|
this[_g] = null;
|
|
722
723
|
}
|
|
723
|
-
static get VERSION() { return "0.9.
|
|
724
|
+
static get VERSION() { return "0.9.11"; }
|
|
724
725
|
static get LOG_TYPE() { return types_1.LOG_TYPE; }
|
|
725
726
|
static get STATUS_TYPE() { return types_1.STATUS_TYPE; }
|
|
726
727
|
static get MAX_TIMEOUT() { return 2147483647; }
|
|
@@ -763,6 +764,7 @@ class Module extends EventEmitter {
|
|
|
763
764
|
case "error.fatal":
|
|
764
765
|
return VALUES[key];
|
|
765
766
|
case "node.require.ext":
|
|
767
|
+
case "node.settings.package_manager":
|
|
766
768
|
case "process.password":
|
|
767
769
|
case "process.cipher.algorithm":
|
|
768
770
|
return VALUES[key] !== '';
|
|
@@ -2107,8 +2109,8 @@ class Module extends EventEmitter {
|
|
|
2107
2109
|
}
|
|
2108
2110
|
static sanitizeArgs(values, doubleQuote) {
|
|
2109
2111
|
const result = typeof values === 'string' ? [values] : values;
|
|
2110
|
-
const pattern = /[
|
|
2111
|
-
const sanitize = (value) => value.replace(pattern, capture => (capture === '$' || capture === '`' ? '\\' : '') + '\\' + capture);
|
|
2112
|
+
const pattern = /[^\w+-.,/:@]/g;
|
|
2113
|
+
const sanitize = (value) => value.replace(pattern, capture => capture === '\n' ? "'\n'" : (capture === '$' || capture === '`' ? '\\' : '') + '\\' + capture);
|
|
2112
2114
|
for (let i = 0; i < result.length; ++i) {
|
|
2113
2115
|
let value = result[i].trim(), leading = '';
|
|
2114
2116
|
if (value !== '--') {
|
|
@@ -2277,6 +2279,17 @@ class Module extends EventEmitter {
|
|
|
2277
2279
|
VALUES["node.require.inline"] = inline;
|
|
2278
2280
|
}
|
|
2279
2281
|
}
|
|
2282
|
+
const manager = node.settings?.package_manager;
|
|
2283
|
+
switch (manager) {
|
|
2284
|
+
case 'npm':
|
|
2285
|
+
case 'yarn':
|
|
2286
|
+
case 'pnpm':
|
|
2287
|
+
VALUES["node.settings.package_manager"] = manager;
|
|
2288
|
+
break;
|
|
2289
|
+
default:
|
|
2290
|
+
VALUES["node.settings.package_manager"] = '';
|
|
2291
|
+
break;
|
|
2292
|
+
}
|
|
2280
2293
|
}
|
|
2281
2294
|
if ((0, types_1.isPlainObject)(settings.process)) {
|
|
2282
2295
|
const { env, cipher, password: pwd } = settings.process;
|
|
@@ -3369,7 +3382,7 @@ class Module extends EventEmitter {
|
|
|
3369
3382
|
if (typeof options === 'number') {
|
|
3370
3383
|
options = undefined;
|
|
3371
3384
|
}
|
|
3372
|
-
this.writeFail("Unknown", err, { ...options, type: types_1.LOG_TYPE.SYSTEM, code: types_1.ERR_CODE.MODULE_NOT_FOUND, exec: { command: 'npm', args: ['
|
|
3385
|
+
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] } });
|
|
3373
3386
|
return true;
|
|
3374
3387
|
}
|
|
3375
3388
|
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.9.
|
|
3
|
+
"version": "0.9.11",
|
|
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.9.
|
|
23
|
+
"@e-mc/types": "0.9.11",
|
|
24
24
|
"chalk": "4.1.2",
|
|
25
25
|
"file-type": "16.5.4",
|
|
26
26
|
"js-yaml": "^4.1.0",
|