@e-mc/module 0.7.14 → 0.7.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/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import type { ModuleConstructor } from '../types/lib';
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
@@ -102,6 +102,7 @@ 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"]: '',
105
106
  ["temp.dir"]: "tmp",
106
107
  ["temp.write"]: false,
107
108
  ["process.password"]: '',
@@ -586,7 +587,7 @@ class Module extends EventEmitter {
586
587
  this[_f] = new AbortController();
587
588
  this[_g] = null;
588
589
  }
589
- static get VERSION() { return "0.7.14"; }
590
+ static get VERSION() { return "0.7.15"; }
590
591
  static get LOG_TYPE() { return types_1.LOG_TYPE; }
591
592
  static get STATUS_TYPE() { return types_1.STATUS_TYPE; }
592
593
  static get MAX_TIMEOUT() { return 2147483647; }
@@ -626,6 +627,7 @@ class Module extends EventEmitter {
626
627
  case "error.fatal":
627
628
  return VALUES[key];
628
629
  case "node.require.ext":
630
+ case "node.settings.package_manager":
629
631
  case "process.password":
630
632
  case "process.cipher.algorithm":
631
633
  return VALUES[key] !== '';
@@ -1900,8 +1902,8 @@ class Module extends EventEmitter {
1900
1902
  }
1901
1903
  static sanitizeArgs(values, doubleQuote) {
1902
1904
  const result = typeof values === 'string' ? [values] : values;
1903
- const pattern = /[^0-9a-z%+-./:=@_]/gi;
1904
- const sanitize = (value) => value.replace(pattern, capture => (capture === '$' || capture === '`' ? '\\' : '') + '\\' + capture);
1905
+ const pattern = /[^\w+-.,/:@]/g;
1906
+ const sanitize = (value) => value.replace(pattern, capture => capture === '\n' ? "'\n'" : (capture === '$' || capture === '`' ? '\\' : '') + '\\' + capture);
1905
1907
  for (let i = 0; i < result.length; ++i) {
1906
1908
  let value = result[i].trim(), leading = '';
1907
1909
  if (value !== '--') {
@@ -2008,8 +2010,8 @@ class Module extends EventEmitter {
2008
2010
  }
2009
2011
  }
2010
2012
  static loadSettings(settings, password) {
2011
- var _h;
2012
- var _j;
2013
+ var _h, _j;
2014
+ var _k;
2013
2015
  const current = VALUES["process.password"];
2014
2016
  if (current) {
2015
2017
  const proc = settings.process || {};
@@ -2064,6 +2066,17 @@ class Module extends EventEmitter {
2064
2066
  VALUES["node.require.inline"] = inline;
2065
2067
  }
2066
2068
  }
2069
+ const manager = (_j = node.settings) === null || _j === void 0 ? void 0 : _j.package_manager;
2070
+ switch (manager) {
2071
+ case 'npm':
2072
+ case 'yarn':
2073
+ case 'pnpm':
2074
+ VALUES["node.settings.package_manager"] = manager;
2075
+ break;
2076
+ default:
2077
+ VALUES["node.settings.package_manager"] = '';
2078
+ break;
2079
+ }
2067
2080
  }
2068
2081
  if ((0, types_1.isPlainObject)(settings.process)) {
2069
2082
  const { env, cipher, password: pwd } = settings.process;
@@ -2071,7 +2084,7 @@ class Module extends EventEmitter {
2071
2084
  VALUES["process.env.apply"] = env.apply;
2072
2085
  }
2073
2086
  if ((0, types_1.isString)(pwd)) {
2074
- VALUES[_j = "process.password"] || (VALUES[_j] = encryptMessage(pwd, cipher));
2087
+ VALUES[_k = "process.password"] || (VALUES[_k] = encryptMessage(pwd, cipher));
2075
2088
  }
2076
2089
  }
2077
2090
  if (memory && (0, types_1.isPlainObject)(memory.settings)) {
@@ -3087,7 +3100,7 @@ class Module extends EventEmitter {
3087
3100
  if (typeof options === 'number') {
3088
3101
  options = undefined;
3089
3102
  }
3090
- 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] } });
3103
+ 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"] || 'npm', args: ['install', name] } });
3091
3104
  return true;
3092
3105
  }
3093
3106
  if (value) {
package/lib-v4.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import type { IModuleLibV4 } from '../types/lib/compat-v4';
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.7.14",
3
+ "version": "0.7.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.7.14",
23
+ "@e-mc/types": "0.7.15",
24
24
  "abort-controller": "^3.0.0",
25
25
  "chalk": "4.1.2",
26
26
  "event-target-shim": "^5.0.1",