@e-mc/module 0.6.13 → 0.6.15
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 +1 -1
- package/index.js +16 -43
- package/package.json +2 -2
package/LICENSE
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copyright
|
|
1
|
+
Copyright 2023 An Pham
|
|
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
|
|
package/index.js
CHANGED
|
@@ -102,7 +102,6 @@ const VALUES = {
|
|
|
102
102
|
["node.process.cpu_usage"]: true,
|
|
103
103
|
["node.process.memory_usage"]: true,
|
|
104
104
|
["node.process.inline"]: true,
|
|
105
|
-
["node.settings.package_manager"]: '',
|
|
106
105
|
["temp.dir"]: "tmp",
|
|
107
106
|
["temp.write"]: false,
|
|
108
107
|
["process.password"]: '',
|
|
@@ -118,6 +117,8 @@ const VALUES = {
|
|
|
118
117
|
["logger.level"]: -1
|
|
119
118
|
};
|
|
120
119
|
const REGEXP_TORRENT = /^(?:magnet:\?xt=|(?:https?|s?ftp):\/\/[^/][^\n]*?\.(?:torrent|metalink|meta4)(?:\?[^\n]*)?$)/i;
|
|
120
|
+
const REGEXP_CLIESCAPE = /[^\w+-.,/:@]/g;
|
|
121
|
+
const REGEXP_CLIOPTION = /^(-[^\s=]+|--[^-\s=][^\s=]*)(=)?\s*(.*)$/s;
|
|
121
122
|
const RESERVED_SHELL = [
|
|
122
123
|
'if',
|
|
123
124
|
'then',
|
|
@@ -587,7 +588,7 @@ class Module extends EventEmitter {
|
|
|
587
588
|
this[_f] = new AbortController();
|
|
588
589
|
this[_g] = null;
|
|
589
590
|
}
|
|
590
|
-
static get VERSION() { return "0.6.
|
|
591
|
+
static get VERSION() { return "0.6.15"; }
|
|
591
592
|
static get LOG_TYPE() { return types_1.LOG_TYPE; }
|
|
592
593
|
static get STATUS_TYPE() { return types_1.STATUS_TYPE; }
|
|
593
594
|
static get MAX_TIMEOUT() { return 2147483647; }
|
|
@@ -627,7 +628,6 @@ class Module extends EventEmitter {
|
|
|
627
628
|
case "error.fatal":
|
|
628
629
|
return VALUES[key];
|
|
629
630
|
case "node.require.ext":
|
|
630
|
-
case "node.settings.package_manager":
|
|
631
631
|
case "process.password":
|
|
632
632
|
case "process.cipher.algorithm":
|
|
633
633
|
return VALUES[key] !== '';
|
|
@@ -1871,12 +1871,10 @@ class Module extends EventEmitter {
|
|
|
1871
1871
|
}
|
|
1872
1872
|
static sanitizeArgs(values, doubleQuote) {
|
|
1873
1873
|
const result = typeof values === 'string' ? [values] : values;
|
|
1874
|
-
const pattern = /[^\w+-.,/:@]/g;
|
|
1875
|
-
const sanitize = (value) => value.replace(pattern, capture => capture === '\n' ? "'\n'" : (capture === '$' || capture === '`' ? '\\' : '') + '\\' + capture);
|
|
1876
1874
|
for (let i = 0; i < result.length; ++i) {
|
|
1877
1875
|
let value = result[i].trim(), leading = '';
|
|
1878
1876
|
if (value !== '--') {
|
|
1879
|
-
const opt =
|
|
1877
|
+
const opt = REGEXP_CLIOPTION.exec(value);
|
|
1880
1878
|
if (opt) {
|
|
1881
1879
|
if (!opt[2] && !opt[3]) {
|
|
1882
1880
|
result[i] = opt[1];
|
|
@@ -1886,7 +1884,7 @@ class Module extends EventEmitter {
|
|
|
1886
1884
|
value = opt[3];
|
|
1887
1885
|
}
|
|
1888
1886
|
if (value) {
|
|
1889
|
-
const quoted = /^(["'])(.*)\1
|
|
1887
|
+
const quoted = /^(["'])(.*)\1$/s.exec(value);
|
|
1890
1888
|
if (PLATFORM_WIN32) {
|
|
1891
1889
|
if (quoted) {
|
|
1892
1890
|
if (quoted[1] === '"') {
|
|
@@ -1899,33 +1897,19 @@ class Module extends EventEmitter {
|
|
|
1899
1897
|
value = wrapQuote(value);
|
|
1900
1898
|
}
|
|
1901
1899
|
}
|
|
1902
|
-
else {
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
if (quoted[1] === "'") {
|
|
1906
|
-
result[i] = leading + value;
|
|
1907
|
-
continue;
|
|
1908
|
-
}
|
|
1909
|
-
value = quoted[2];
|
|
1910
|
-
type = true;
|
|
1911
|
-
}
|
|
1912
|
-
if (pattern.test(value)) {
|
|
1913
|
-
if (type) {
|
|
1914
|
-
value = '"' + sanitize(value) + '"';
|
|
1915
|
-
}
|
|
1916
|
-
else {
|
|
1917
|
-
value = "'" + value.replace(/'/g, "'\\''") + "'";
|
|
1918
|
-
}
|
|
1900
|
+
else if (!quoted) {
|
|
1901
|
+
if (REGEXP_CLIESCAPE.test(value)) {
|
|
1902
|
+
value = doubleQuote ? `"${value.replace(/(?<!\\)"/g, '\\"')}"` : `'${value.replace(/'/g, "'\\''")}'`;
|
|
1919
1903
|
}
|
|
1920
1904
|
else if (RESERVED_SHELL.includes(value)) {
|
|
1921
|
-
value =
|
|
1905
|
+
value = `'${value}'`;
|
|
1922
1906
|
}
|
|
1923
1907
|
}
|
|
1924
1908
|
}
|
|
1925
1909
|
else if (opt) {
|
|
1926
1910
|
leading = leading.trim();
|
|
1927
1911
|
if (!PLATFORM_WIN32 && leading.length > 2 && leading[1] !== '-') {
|
|
1928
|
-
leading
|
|
1912
|
+
leading.replace(REGEXP_CLIESCAPE, capture => '\\' + capture);
|
|
1929
1913
|
}
|
|
1930
1914
|
}
|
|
1931
1915
|
}
|
|
@@ -1979,8 +1963,8 @@ class Module extends EventEmitter {
|
|
|
1979
1963
|
}
|
|
1980
1964
|
}
|
|
1981
1965
|
static loadSettings(settings, password) {
|
|
1982
|
-
var _h
|
|
1983
|
-
var
|
|
1966
|
+
var _h;
|
|
1967
|
+
var _j;
|
|
1984
1968
|
const current = VALUES["process.password"];
|
|
1985
1969
|
if (current) {
|
|
1986
1970
|
const proc = settings.process || {};
|
|
@@ -2035,17 +2019,6 @@ class Module extends EventEmitter {
|
|
|
2035
2019
|
VALUES["node.require.inline"] = inline;
|
|
2036
2020
|
}
|
|
2037
2021
|
}
|
|
2038
|
-
const manager = (_j = node.settings) === null || _j === void 0 ? void 0 : _j.package_manager;
|
|
2039
|
-
switch (manager) {
|
|
2040
|
-
case 'npm':
|
|
2041
|
-
case 'yarn':
|
|
2042
|
-
case 'pnpm':
|
|
2043
|
-
VALUES["node.settings.package_manager"] = manager;
|
|
2044
|
-
break;
|
|
2045
|
-
default:
|
|
2046
|
-
VALUES["node.settings.package_manager"] = '';
|
|
2047
|
-
break;
|
|
2048
|
-
}
|
|
2049
2022
|
}
|
|
2050
2023
|
if ((0, types_1.isPlainObject)(settings.process)) {
|
|
2051
2024
|
const { env, cipher, password: pwd } = settings.process;
|
|
@@ -2053,7 +2026,7 @@ class Module extends EventEmitter {
|
|
|
2053
2026
|
VALUES["process.env.apply"] = env.apply;
|
|
2054
2027
|
}
|
|
2055
2028
|
if ((0, types_1.isString)(pwd)) {
|
|
2056
|
-
VALUES[
|
|
2029
|
+
VALUES[_j = "process.password"] || (VALUES[_j] = encryptMessage(pwd, cipher));
|
|
2057
2030
|
}
|
|
2058
2031
|
}
|
|
2059
2032
|
if (memory && (0, types_1.isPlainObject)(memory.settings)) {
|
|
@@ -3068,7 +3041,7 @@ class Module extends EventEmitter {
|
|
|
3068
3041
|
if (typeof options === 'number') {
|
|
3069
3042
|
options = undefined;
|
|
3070
3043
|
}
|
|
3071
|
-
this.writeFail("Unknown", err, { ...options, type: types_1.LOG_TYPE.SYSTEM, code: types_1.ERR_CODE.MODULE_NOT_FOUND, exec: { command:
|
|
3044
|
+
this.writeFail("Unknown", err, { ...options, type: types_1.LOG_TYPE.SYSTEM, code: types_1.ERR_CODE.MODULE_NOT_FOUND, exec: { command: 'npm', args: ['i', name] } });
|
|
3072
3045
|
return true;
|
|
3073
3046
|
}
|
|
3074
3047
|
if (value) {
|
|
@@ -3361,8 +3334,8 @@ Module.LOG_STYLE_WARN = Object.freeze({ titleBgColor: 'bgBlack', titleColor: 'ye
|
|
|
3361
3334
|
Module.LOG_STYLE_NOTICE = Object.freeze({ titleBgColor: 'bgGrey', titleColor: 'white' });
|
|
3362
3335
|
Module.LOG_STYLE_REVERSE = Object.freeze({ titleBgColor: 'bgWhite', titleColor: 'black', messageBgColor: 'bgGrey' });
|
|
3363
3336
|
if (!Module.supported(15, 4)) {
|
|
3364
|
-
({ AbortController:
|
|
3365
|
-
({ EventTarget:
|
|
3337
|
+
({ AbortController: globalThis.AbortController } = require('abort-controller'));
|
|
3338
|
+
({ EventTarget: globalThis.EventTarget } = require('event-target-shim'));
|
|
3366
3339
|
}
|
|
3367
3340
|
EventEmitter.defaultMaxListeners = Infinity;
|
|
3368
3341
|
Object.freeze(types_1.LOG_TYPE);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/module",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.15",
|
|
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.6.
|
|
23
|
+
"@e-mc/types": "0.6.15",
|
|
24
24
|
"abort-controller": "^3.0.0",
|
|
25
25
|
"chalk": "4.1.2",
|
|
26
26
|
"event-target-shim": "^5.0.1",
|