tnp-core 18.0.47 → 18.0.50

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.
Files changed (101) hide show
  1. package/README.md +1 -1
  2. package/assets/shared/shared_folder_info.txt +1 -1
  3. package/browser/esm2022/lib/core-imports.mjs +66 -5
  4. package/browser/esm2022/lib/core-models.mjs +51 -48
  5. package/browser/esm2022/lib/helpers-messages.mjs +9 -4
  6. package/browser/esm2022/lib/helpers.mjs +152 -369
  7. package/browser/esm2022/lib/utils.mjs +521 -8
  8. package/browser/fesm2022/tnp-core.mjs +1469 -1105
  9. package/browser/fesm2022/tnp-core.mjs.map +1 -1
  10. package/browser/lib/core-imports.d.ts +41 -1
  11. package/browser/lib/core-models.d.ts +51 -83
  12. package/browser/lib/helpers-messages.d.ts +6 -3
  13. package/browser/lib/helpers.d.ts +22 -0
  14. package/browser/lib/utils.d.ts +48 -0
  15. package/cli.backend.d.ts +1 -0
  16. package/cli.backend.js +15 -2
  17. package/cli.backend.js.map +1 -1
  18. package/client/esm2022/lib/core-imports.mjs +66 -5
  19. package/client/esm2022/lib/core-models.mjs +51 -48
  20. package/client/esm2022/lib/helpers-messages.mjs +9 -4
  21. package/client/esm2022/lib/helpers.mjs +152 -369
  22. package/client/esm2022/lib/utils.mjs +521 -8
  23. package/client/fesm2022/tnp-core.mjs +1469 -1105
  24. package/client/fesm2022/tnp-core.mjs.map +1 -1
  25. package/client/lib/core-imports.d.ts +41 -1
  26. package/client/lib/core-models.d.ts +51 -83
  27. package/client/lib/helpers-messages.d.ts +6 -3
  28. package/client/lib/helpers.d.ts +22 -0
  29. package/client/lib/utils.d.ts +48 -0
  30. package/index.js +15 -2
  31. package/index.js.map +1 -1
  32. package/lib/build-info._auto-generated_.js.map +1 -1
  33. package/lib/command-exists.js +20 -20
  34. package/lib/command-exists.js.map +1 -1
  35. package/lib/core-cli.js +49 -66
  36. package/lib/core-cli.js.map +1 -1
  37. package/lib/core-config.js.map +1 -1
  38. package/lib/core-imports.d.ts +41 -20
  39. package/lib/core-imports.js +202 -78
  40. package/lib/core-imports.js.map +1 -1
  41. package/lib/core-models.d.ts +51 -83
  42. package/lib/core-models.js +52 -47
  43. package/lib/core-models.js.map +1 -1
  44. package/lib/framework-name.js +2 -2
  45. package/lib/framework-name.js.map +1 -1
  46. package/lib/helpers-isomorphic.js +33 -52
  47. package/lib/helpers-isomorphic.js.map +1 -1
  48. package/lib/helpers-messages.d.ts +6 -3
  49. package/lib/helpers-messages.js +79 -102
  50. package/lib/helpers-messages.js.map +1 -1
  51. package/lib/helpers.d.ts +21 -3
  52. package/lib/helpers.js +718 -967
  53. package/lib/helpers.js.map +1 -1
  54. package/lib/index._auto-generated_.js.map +1 -1
  55. package/lib/index.js +23 -10
  56. package/lib/index.js.map +1 -1
  57. package/lib/node-chalk-mock.js +2 -2
  58. package/lib/node-chalk-mock.js.map +1 -1
  59. package/lib/node-path-mock.js +2 -2
  60. package/lib/node-path-mock.js.map +1 -1
  61. package/lib/progress-data.js +21 -23
  62. package/lib/progress-data.js.map +1 -1
  63. package/lib/public-api.js +19 -6
  64. package/lib/public-api.js.map +1 -1
  65. package/lib/required-global-npm-packages.js.map +1 -1
  66. package/lib/required.d.ts +44 -0
  67. package/lib/safe-types/glob.d.ts +102 -0
  68. package/lib/safe-types/minimatch/assert-valid-pattern.d.ts +1 -0
  69. package/lib/safe-types/minimatch/ast.d.ts +17 -0
  70. package/lib/safe-types/minimatch/brace-expressions.d.ts +7 -0
  71. package/lib/safe-types/minimatch/escape.d.ts +11 -0
  72. package/lib/safe-types/minimatch/index.d copy.d.ts +93 -0
  73. package/lib/safe-types/minimatch/index.d.ts +93 -0
  74. package/lib/safe-types/minimatch/unescapd.d.ts +16 -0
  75. package/lib/safe-types/minimatch/unescape.d.ts +16 -0
  76. package/lib/safe-types/minimatch.d.ts +0 -0
  77. package/lib/safe-types/rimraf.d.ts +28 -0
  78. package/lib/utils.d.ts +48 -1
  79. package/lib/utils.js +1252 -1146
  80. package/lib/utils.js.map +1 -1
  81. package/migrations/index.js +15 -2
  82. package/migrations/index.js.map +1 -1
  83. package/migrations/migrations_index._auto-generated_.js.map +1 -1
  84. package/package.json +26 -89
  85. package/src.d.ts +1 -1
  86. package/taon.jsonc +48 -58
  87. package/tmp-environment.json +8 -403
  88. package/websql/esm2022/lib/core-imports.mjs +66 -5
  89. package/websql/esm2022/lib/core-models.mjs +51 -48
  90. package/websql/esm2022/lib/helpers-messages.mjs +9 -4
  91. package/websql/esm2022/lib/helpers.mjs +152 -369
  92. package/websql/esm2022/lib/utils.mjs +521 -8
  93. package/websql/fesm2022/tnp-core.mjs +1466 -1102
  94. package/websql/fesm2022/tnp-core.mjs.map +1 -1
  95. package/websql/lib/core-imports.d.ts +41 -1
  96. package/websql/lib/core-models.d.ts +51 -83
  97. package/websql/lib/helpers-messages.d.ts +6 -3
  98. package/websql/lib/helpers.d.ts +22 -0
  99. package/websql/lib/utils.d.ts +48 -0
  100. package/browser/package.json +0 -25
  101. package/websql/package.json +0 -25
package/lib/helpers.js CHANGED
@@ -1,181 +1,155 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.HelpersCore = void 0;
4
- var tslib_1 = require("tslib");
5
4
  //#region import
6
5
  //#region @backend
7
- var core_imports_1 = require("./core-imports");
8
- var json5Write = require("json10-writer");
9
- var buffer_1 = require("buffer");
10
- var electron_1 = require("electron");
6
+ const core_imports_1 = require("./core-imports");
7
+ const json5Write = require("json10-writer");
8
+ const buffer_1 = require("buffer");
9
+ const electron_1 = require("electron");
11
10
  //#endregion
12
11
  /* */
13
12
  /* */
14
- var core_imports_2 = require("./core-imports");
15
- var utils_1 = require("./utils");
16
- var index_1 = require("./index");
17
- var helpers_messages_1 = require("./helpers-messages");
18
- var core_models_1 = require("./core-models");
19
- var encoding = 'utf8';
13
+ const core_imports_2 = require("./core-imports");
14
+ const utils_1 = require("./utils");
15
+ const index_1 = require("./index");
16
+ const helpers_messages_1 = require("./helpers-messages");
17
+ const core_models_1 = require("./core-models");
18
+ const encoding = 'utf8';
20
19
  //#region @backend
21
- var forceTrace = !global.hideLog;
20
+ const forceTrace = !global.hideLog;
22
21
  //#endregion
23
- var WEBSQL_PROC_MOCK_PROCESSES_PID = {};
24
- var WEBSQL_PROC_MOCK_PROCESSES_PPID = {};
22
+ const WEBSQL_PROC_MOCK_PROCESSES_PID = {};
23
+ const WEBSQL_PROC_MOCK_PROCESSES_PPID = {};
25
24
  //#endregion
26
25
  // TODO UNCOMMENT
27
26
  // const globalProcessStdout = {};
28
27
  // const globalProcessStder = {};
29
28
  // const maxProcessHistoryLinesChekc = 20;
30
- var HelpersCore = /** @class */ (function (_super) {
31
- tslib_1.__extends(HelpersCore, _super);
29
+ class HelpersCore extends helpers_messages_1.HelpersMessages {
30
+ //#region singleton
31
+ static _instanceCore;
32
+ static get InstanceCore() {
33
+ if (!HelpersCore._instanceCore) {
34
+ HelpersCore._instanceCore = new HelpersCore();
35
+ }
36
+ return HelpersCore._instanceCore;
37
+ }
38
+ //#endregion
39
+ //#region fields / getters
40
+ //#region @backend
41
+ processes = [];
42
+ //#endregion
43
+ bigMaxBuffer = 2024 * 500;
44
+ //#region @backend
45
+ /**
46
+ * @deprecated use UtilsOs
47
+ */
48
+ get isRunningIn() {
49
+ return {
50
+ /**
51
+ * @deprecated use UtilsOs.isRunningInMochaTest()
52
+ */
53
+ mochaTest() {
54
+ return index_1.UtilsOs.isRunningInMochaTest();
55
+ },
56
+ /**
57
+ * @deprecated use UtilsOs.isRunningInCliMode()
58
+ */
59
+ cliMode() {
60
+ return index_1.UtilsOs.isRunningInCliMode();
61
+ },
62
+ };
63
+ }
32
64
  //#endregion
33
65
  //#endregion
34
66
  //#region constructor
35
- function HelpersCore() {
36
- var _this = _super.call(this) || this;
37
- //#endregion
38
- //#region fields / getters
39
- //#region @backend
40
- _this.processes = [];
41
- //#endregion
42
- _this.bigMaxBuffer = 2024 * 500;
43
- return _this;
67
+ constructor() {
68
+ super();
44
69
  // //#region @backend
45
70
  // process.on('SIGINT', this.cleanExit); // catch ctrl-c
46
71
  // process.on('SIGTERM', this.cleanExit); // catch kill
47
72
  // //#endregion
48
73
  }
49
- Object.defineProperty(HelpersCore, "InstanceCore", {
50
- get: function () {
51
- if (!HelpersCore._instanceCore) {
52
- HelpersCore._instanceCore = new HelpersCore();
53
- }
54
- return HelpersCore._instanceCore;
55
- },
56
- enumerable: false,
57
- configurable: true
58
- });
59
- Object.defineProperty(HelpersCore.prototype, "isRunningIn", {
60
- //#region @backend
61
- /**
62
- * @deprecated use UtilsOs
63
- */
64
- get: function () {
65
- return {
66
- /**
67
- * @deprecated use UtilsOs.isRunningInMochaTest()
68
- */
69
- mochaTest: function () {
70
- return index_1.UtilsOs.isRunningInMochaTest();
71
- },
72
- /**
73
- * @deprecated use UtilsOs.isRunningInCliMode()
74
- */
75
- cliMode: function () {
76
- return index_1.UtilsOs.isRunningInCliMode();
77
- },
78
- };
79
- },
80
- enumerable: false,
81
- configurable: true
82
- });
83
- Object.defineProperty(HelpersCore.prototype, "isWsl", {
84
- //#endregion
85
- //#region methods / is wsl
86
- /**
87
- * @deprecated use UtilsOs.isRunningInsideWsl()
88
- */
89
- get: function () {
90
- return index_1.UtilsOs.isRunningInWsl();
91
- },
92
- enumerable: false,
93
- configurable: true
94
- });
74
+ //#endregion
75
+ //#region methods / is wsl
76
+ /**
77
+ * @deprecated use UtilsOs.isRunningInsideWsl()
78
+ */
79
+ get isWsl() {
80
+ return index_1.UtilsOs.isRunningInWsl();
81
+ }
95
82
  //#endregion
96
83
  //#region methods / is running in docker
97
84
  /**
98
85
  * @deprecated use UtilsOs.isRunningInDocker
99
86
  */
100
- HelpersCore.prototype.isRunningInDocker = function () {
87
+ isRunningInDocker() {
101
88
  return index_1.UtilsOs.isRunningInDocker();
102
- };
89
+ }
103
90
  //#endregion
104
91
  //#region methods / is running in docker
105
92
  /**
106
93
  * @deprecated use UtilsOs.isRunningInLinuxGraphicEnvironment
107
94
  */
108
- HelpersCore.prototype.isRunningInLinuxGraphicsCapableEnvironment = function () {
95
+ isRunningInLinuxGraphicsCapableEnvironment() {
109
96
  return index_1.UtilsOs.isRunningInLinuxGraphicsCapableEnvironment();
110
- };
97
+ }
111
98
  //#endregion
112
99
  //#region clear console
113
100
  /**
114
101
  * @deprecated use UtilsTerminal.clearConsole
115
102
  */
116
- HelpersCore.prototype.clearConsole = function () {
103
+ clearConsole() {
117
104
  return utils_1.UtilsTerminal.clearConsole();
118
- };
119
- Object.defineProperty(HelpersCore.prototype, "ipcRenderer", {
105
+ }
106
+ //#endregion
107
+ //#region methods / electron ipc renderer
108
+ /**
109
+ * get electron browser ipc renderer
110
+ */
111
+ get ipcRenderer() {
112
+ //#region @backend
113
+ return;
120
114
  //#endregion
121
- //#region methods / electron ipc renderer
122
- /**
123
- * get electron browser ipc renderer
124
- */
125
- get: function () {
126
- //#region @backend
127
- return;
128
- //#endregion
129
- /* */
130
- /* */
131
- /* */
132
- /* */
133
- /* */
134
- /* */
135
- },
136
- enumerable: false,
137
- configurable: true
138
- });
139
- Object.defineProperty(HelpersCore.prototype, "webFrame", {
115
+ /* */
116
+ /* */
117
+ /* */
118
+ /* */
119
+ /* */
120
+ /* */
121
+ }
122
+ //#endregion
123
+ //#region methods / electron webframe
124
+ /**
125
+ * get electron web frame
126
+ */
127
+ get webFrame() {
128
+ //#region @backend
129
+ return;
140
130
  //#endregion
141
- //#region methods / electron webframe
142
- /**
143
- * get electron web frame
144
- */
145
- get: function () {
146
- //#region @backend
131
+ /* */
132
+ /* */
133
+ /* */
134
+ /* */
135
+ /* */
136
+ }
137
+ //#endregion
138
+ //#region methods / electron ipc renderer
139
+ /**
140
+ * get electron backend ipc main proces
141
+ */
142
+ get ipcMain() {
143
+ //#region @backendFunc
144
+ if (!this.isElectron) {
147
145
  return;
148
- //#endregion
149
- /* */
150
- /* */
151
- /* */
152
- /* */
153
- /* */
154
- },
155
- enumerable: false,
156
- configurable: true
157
- });
158
- Object.defineProperty(HelpersCore.prototype, "ipcMain", {
146
+ }
147
+ return electron_1.ipcMain;
159
148
  //#endregion
160
- //#region methods / electron ipc renderer
161
- /**
162
- * get electron backend ipc main proces
163
- */
164
- get: function () {
165
- //#region @backendFunc
166
- if (!this.isElectron) {
167
- return;
168
- }
169
- return electron_1.ipcMain;
170
- //#endregion
171
- },
172
- enumerable: false,
173
- configurable: true
174
- });
149
+ }
175
150
  //#endregion
176
151
  //#region methods / get electron window
177
- HelpersCore.prototype.getElectronWindow = function (_a) {
178
- var _b = _a === void 0 ? {} : _a, _c = _b.allowRunningInsecureContent, allowRunningInsecureContent = _c === void 0 ? true : _c;
152
+ getElectronWindow({ allowRunningInsecureContent = true, } = {}) {
179
153
  //#region @backendFunc
180
154
  // const size = screen.getPrimaryDisplay().workAreaSize;
181
155
  // // Create the browser window.
@@ -192,25 +166,24 @@ var HelpersCore = /** @class */ (function (_super) {
192
166
  // });
193
167
  // return win
194
168
  //#endregion
195
- };
169
+ }
196
170
  //#endregion
197
171
  //#region methods / media from type
198
- HelpersCore.prototype.mediaTypeFromSrc = function (src) {
199
- var ext = core_imports_2.path.extname(src);
200
- var media = core_models_1.CoreModels.mimeTypes[ext];
201
- return core_imports_2._.first(media === null || media === void 0 ? void 0 : media.split('/'));
202
- };
172
+ mediaTypeFromSrc(src) {
173
+ const ext = core_imports_2.path.extname(src);
174
+ const media = core_models_1.CoreModels.mimeTypes[ext];
175
+ return core_imports_2._.first(media?.split('/'));
176
+ }
203
177
  //#endregion
204
178
  //#region methods / sleep
205
- HelpersCore.prototype.sleep = function (seconds) {
206
- if (seconds === void 0) { seconds = 1; }
179
+ sleep(seconds = 1) {
207
180
  //#region @backendFunc
208
- return index_1.Helpers.run("sleep ".concat(seconds)).sync();
181
+ return index_1.Helpers.run(`sleep ${seconds}`).sync();
209
182
  //#endregion
210
- };
183
+ }
211
184
  //#endregion
212
185
  //#region methods / remove if exists
213
- HelpersCore.prototype.removeIfExists = function (absoluteFileOrFolderPath) {
186
+ removeIfExists(absoluteFileOrFolderPath) {
214
187
  //#region @backendFunc
215
188
  if (Array.isArray(absoluteFileOrFolderPath)) {
216
189
  absoluteFileOrFolderPath = (0, core_imports_2.crossPlatformPath)(absoluteFileOrFolderPath);
@@ -232,18 +205,18 @@ var HelpersCore = /** @class */ (function (_super) {
232
205
  }
233
206
  }
234
207
  //#endregion
235
- };
208
+ }
236
209
  //#endregion
237
210
  //#region methods / relative
238
211
  /**
239
212
  * path.relative that return cross platform path
240
213
  */
241
- HelpersCore.prototype.relative = function (cwd, to) {
214
+ relative(cwd, to) {
242
215
  return (0, core_imports_2.crossPlatformPath)(core_imports_2.path.relative(cwd, to));
243
- };
216
+ }
244
217
  //#endregion
245
218
  //#region methods / remove file if exists
246
- HelpersCore.prototype.removeFileIfExists = function (absoluteFilePath) {
219
+ removeFileIfExists(absoluteFilePath) {
247
220
  //#region @backendFunc
248
221
  if (Array.isArray(absoluteFilePath)) {
249
222
  absoluteFilePath = (0, core_imports_2.crossPlatformPath)(absoluteFilePath);
@@ -257,15 +230,15 @@ var HelpersCore = /** @class */ (function (_super) {
257
230
  core_imports_1.fse.unlinkSync(absoluteFilePath);
258
231
  }
259
232
  //#endregion
260
- };
233
+ }
261
234
  //#endregion
262
235
  //#region methods / remove folder if exists
263
- HelpersCore.prototype.removeFolderIfExists = function (absoluteFolderPath) {
236
+ removeFolderIfExists(absoluteFolderPath) {
264
237
  //#region @backendFunc
265
238
  if (Array.isArray(absoluteFolderPath)) {
266
239
  absoluteFolderPath = (0, core_imports_2.crossPlatformPath)(absoluteFolderPath);
267
240
  }
268
- index_1.Helpers.log("[helpers] Remove folder: ".concat(absoluteFolderPath));
241
+ index_1.Helpers.log(`[helpers] Remove folder: ${absoluteFolderPath}`);
269
242
  if (process.platform === 'win32') {
270
243
  // rimraf.sync(absoluteFolderPath);
271
244
  this.tryRemoveDir(absoluteFolderPath, false, true);
@@ -275,17 +248,17 @@ var HelpersCore = /** @class */ (function (_super) {
275
248
  core_imports_1.fse.removeSync(absoluteFolderPath);
276
249
  }
277
250
  //#endregion
278
- };
251
+ }
279
252
  //#endregion
280
253
  //#region methods / remove empty line from string
281
254
  /**
282
255
  * leave max 1 empty line
283
256
  */
284
- HelpersCore.prototype.removeEmptyLineFromString = function (str) {
285
- var lines = (str || '').split('\n');
286
- var previousWasEmpty = false;
257
+ removeEmptyLineFromString(str) {
258
+ const lines = (str || '').split('\n');
259
+ let previousWasEmpty = false;
287
260
  return lines
288
- .filter(function (line) {
261
+ .filter(line => {
289
262
  if (line.trim() === '') {
290
263
  if (previousWasEmpty) {
291
264
  // Skip this line because the previous line was also empty
@@ -304,116 +277,116 @@ var HelpersCore = /** @class */ (function (_super) {
304
277
  }
305
278
  })
306
279
  .join('\n');
307
- };
280
+ }
308
281
  //#endregion
309
282
  //#region methods / try remove empty dir
310
283
  /**
311
284
  * @deprecated
312
285
  */
313
- HelpersCore.prototype.tryRemoveDir = function (dirpath, contentOnly, omitWarningNotExisted) {
314
- if (contentOnly === void 0) { contentOnly = false; }
315
- if (omitWarningNotExisted === void 0) { omitWarningNotExisted = false; }
286
+ tryRemoveDir(dirpath, contentOnly = false, omitWarningNotExisted = false) {
316
287
  //#region @backendFunc
317
288
  if (!core_imports_1.fse.existsSync(dirpath)) {
318
289
  if (!omitWarningNotExisted) {
319
- index_1.Helpers.warn("[taon-helper][tryRemoveDir] Folder ".concat(core_imports_2.path.basename(dirpath), " doesn't exist."));
290
+ index_1.Helpers.warn(`[taon-helper][tryRemoveDir] Folder ${core_imports_2.path.basename(dirpath)} doesn't exist.`);
320
291
  }
321
292
  return;
322
293
  }
323
- index_1.Helpers.log("[taon-helpers][tryRemoveDir]: ".concat(dirpath));
294
+ index_1.Helpers.log(`[taon-helpers][tryRemoveDir]: ${dirpath}`);
324
295
  try {
325
296
  if (contentOnly) {
326
- core_imports_1.rimraf.sync("".concat(dirpath, "/*"));
297
+ core_imports_1.rimraf.sync(`${dirpath}/*`);
327
298
  }
328
299
  else {
329
300
  core_imports_1.rimraf.sync(dirpath);
330
301
  }
331
- index_1.Helpers.log("Remove done: ".concat(dirpath));
302
+ index_1.Helpers.log(`Remove done: ${dirpath}`);
332
303
  return;
333
304
  }
334
305
  catch (e) {
335
- index_1.Helpers.warn("\n\n Trying to remove directory: ".concat(dirpath, "\n\n\n (USER ACTION REQUIRED!!!)\n Please check if you did't open\n ").concat(dirpath, "\n in windows explorer\n\n or try to unlock file with app Unlocker or File Locksmith (from power tools)\n\n "));
306
+ index_1.Helpers.warn(`
307
+
308
+ Trying to remove directory: ${dirpath}
309
+
310
+
311
+ (USER ACTION REQUIRED!!!)
312
+ Please check if you did't open
313
+ ${dirpath}
314
+ in windows explorer
315
+
316
+ or try to unlock file with app Unlocker or File Locksmith (from power tools)
317
+
318
+ `);
336
319
  index_1.Helpers.sleep(1);
337
320
  index_1.Helpers.tryRemoveDir(dirpath, contentOnly);
338
321
  }
339
322
  //#endregion
340
- };
323
+ }
341
324
  //#endregion
342
325
  //#region methods / remove file or folder
343
- HelpersCore.prototype.remove = function (fileOrFolderPathOrPatter, exactFolder) {
344
- if (exactFolder === void 0) { exactFolder = false; }
326
+ remove(fileOrFolderPathOrPatter, exactFolder = false) {
345
327
  //#region @backendFunc
346
328
  if (Array.isArray(fileOrFolderPathOrPatter)) {
347
329
  fileOrFolderPathOrPatter = (0, core_imports_2.crossPlatformPath)(fileOrFolderPathOrPatter);
348
330
  }
349
- index_1.Helpers.log("[taon-core][remove]: ".concat(fileOrFolderPathOrPatter), 1);
331
+ index_1.Helpers.log(`[taon-core][remove]: ${fileOrFolderPathOrPatter}`, 1);
350
332
  if (exactFolder) {
351
333
  core_imports_1.rimraf.sync(fileOrFolderPathOrPatter, { glob: false, disableGlob: true });
352
334
  return;
353
335
  }
354
336
  core_imports_1.rimraf.sync(fileOrFolderPathOrPatter);
355
337
  //#endregion
356
- };
338
+ }
357
339
  //#endregion
358
340
  //#region methods / clean exit process
359
341
  //#region @backend
360
- HelpersCore.prototype.cleanExit = function () {
361
- index_1.Helpers.processes.forEach(function (p) {
342
+ cleanExit() {
343
+ index_1.Helpers.processes.forEach(p => {
362
344
  p.kill('SIGINT');
363
345
  p.kill('SIGTERM');
364
- index_1.Helpers.log("Killing child process on ".concat(p.pid));
346
+ index_1.Helpers.log(`Killing child process on ${p.pid}`);
365
347
  });
366
- index_1.Helpers.log("Killing parent on ".concat(process.pid));
348
+ index_1.Helpers.log(`Killing parent on ${process.pid}`);
367
349
  process.exit();
368
- };
369
- Object.defineProperty(HelpersCore.prototype, "isRunningInGitBash", {
370
- //#endregion
350
+ }
351
+ //#endregion
352
+ //#endregion
353
+ //#region methods / is running in git bash
354
+ get isRunningInGitBash() {
355
+ //#region @backendFunc
356
+ // console.log('TERM', process.env.TERM);
357
+ // console.log('MSYSTEM', process.env.MSYSTEM);
358
+ return ((process.env?.TERM?.search('cygwin') !== -1 ||
359
+ process.env?.TERM?.search('xterm') !== -1) &&
360
+ !!process.env?.MSYSTEM);
371
361
  //#endregion
372
- //#region methods / is running in git bash
373
- get: function () {
374
- var _a, _b, _c, _d, _e;
375
- //#region @backendFunc
376
- // console.log('TERM', process.env.TERM);
377
- // console.log('MSYSTEM', process.env.MSYSTEM);
378
- return ((((_b = (_a = process.env) === null || _a === void 0 ? void 0 : _a.TERM) === null || _b === void 0 ? void 0 : _b.search('cygwin')) !== -1 ||
379
- ((_d = (_c = process.env) === null || _c === void 0 ? void 0 : _c.TERM) === null || _d === void 0 ? void 0 : _d.search('xterm')) !== -1) &&
380
- !!((_e = process.env) === null || _e === void 0 ? void 0 : _e.MSYSTEM));
381
- //#endregion
382
- },
383
- enumerable: false,
384
- configurable: true
385
- });
386
- Object.defineProperty(HelpersCore.prototype, "isSupportedTaonTerminal", {
362
+ }
363
+ //#endregion
364
+ //#region methods / check if projects is running in supported terminal
365
+ /**
366
+ * Check if the current shell is supported by Taon framework.
367
+ */
368
+ get isSupportedTaonTerminal() {
369
+ //#region @backendFunc
370
+ return process.platform === 'win32' ? this.isRunningInGitBash : true;
387
371
  //#endregion
388
- //#region methods / check if projects is running in supported terminal
389
- /**
390
- * Check if the current shell is supported by Taon framework.
391
- */
392
- get: function () {
393
- //#region @backendFunc
394
- return process.platform === 'win32' ? this.isRunningInGitBash : true;
395
- //#endregion
396
- },
397
- enumerable: false,
398
- configurable: true
399
- });
372
+ }
400
373
  //#endregion
401
374
  //#region methods / check if function is class
402
375
  /**
403
376
  * check if function is class
404
377
  */
405
- HelpersCore.prototype.isClass = function (funcOrClass) {
406
- var isClass = false;
378
+ isClass(funcOrClass) {
379
+ let isClass = false;
407
380
  if (typeof funcOrClass === 'function') {
408
381
  // Check if it has a prototype property
409
382
  // console.log('Object.getOwnPropertyNames(funcOrClass.prototype)', Object.getOwnPropertyNames(funcOrClass.prototype).filter(f => f !== 'constructor'))
410
383
  isClass =
411
384
  !!funcOrClass.prototype &&
412
- Object.getOwnPropertyNames(funcOrClass.prototype).filter(function (f) { return f !== 'constructor'; }).length > 0;
385
+ Object.getOwnPropertyNames(funcOrClass.prototype).filter(f => f !== 'constructor').length > 0;
413
386
  }
414
387
  // console.log('is class: ' + isClass, funcOrClass)
415
388
  return isClass;
416
- };
389
+ }
417
390
  //#endregion
418
391
  //#region methods / is blob
419
392
  /**
@@ -422,10 +395,10 @@ var HelpersCore = /** @class */ (function (_super) {
422
395
  * @param maybeBlob
423
396
  * @returns
424
397
  */
425
- HelpersCore.prototype.isBlob = function (maybeBlob) {
398
+ isBlob(maybeBlob) {
426
399
  // TODO is this needed hmmmm
427
400
  return maybeBlob instanceof buffer_1.Blob; // || toString.call(maybeBlob) === '[object Blob]';
428
- };
401
+ }
429
402
  //#endregion
430
403
  //#region methods / is buffer
431
404
  /**
@@ -435,28 +408,28 @@ var HelpersCore = /** @class */ (function (_super) {
435
408
  * @returns
436
409
  */
437
410
  //#region @backend
438
- HelpersCore.prototype.isBuffer = function (maybeNodejsBuffer) {
411
+ isBuffer(maybeNodejsBuffer) {
439
412
  return Buffer.isBuffer(maybeNodejsBuffer);
440
- };
413
+ }
441
414
  //#endregion
442
415
  //#endregion
443
416
  //#region methods / remove slash at the end of string
444
- HelpersCore.prototype.removeSlashAtEnd = function (s) {
445
- s = (s === null || s === void 0 ? void 0 : s.endsWith("/")) ? s.slice(0, s.length - 1) : s;
417
+ removeSlashAtEnd(s) {
418
+ s = s?.endsWith(`/`) ? s.slice(0, s.length - 1) : s;
446
419
  return s;
447
- };
420
+ }
448
421
  //#endregion
449
422
  //#region methods / remove slash at the begin of string
450
- HelpersCore.prototype.removeSlashAtBegin = function (s) {
451
- s = (s === null || s === void 0 ? void 0 : s.startsWith("/")) ? s.slice(1) : s;
423
+ removeSlashAtBegin(s) {
424
+ s = s?.startsWith(`/`) ? s.slice(1) : s;
452
425
  return s;
453
- };
426
+ }
454
427
  //#endregion
455
428
  //#region methods / stringify object pretty format
456
429
  /**
457
430
  * stringify to pretty json string
458
431
  */
459
- HelpersCore.prototype.stringify = function (inputObject) {
432
+ stringify(inputObject) {
460
433
  // if (_.isString(inputObject)) {
461
434
  // return inputObject;
462
435
  // }
@@ -465,36 +438,38 @@ var HelpersCore = /** @class */ (function (_super) {
465
438
  // Helpers.error(`[tnp-helpers] trying to stringify not a object`, false, true);
466
439
  // }
467
440
  return JSON.stringify(inputObject, null, 2);
468
- };
441
+ }
469
442
  //#endregion
470
443
  //#region methods / run sync or async
471
- HelpersCore.prototype.runSyncOrAsync = function (fnOrOptions) {
472
- return tslib_1.__awaiter(this, void 0, void 0, function () {
473
- var promisOrValue, functionFn, context, arrayOfParams;
474
- return tslib_1.__generator(this, function (_a) {
475
- if (core_imports_2._.isUndefined(fnOrOptions)) {
476
- return [2 /*return*/, void 0];
477
- }
478
- functionFn = fnOrOptions.functionFn, context = fnOrOptions.context, arrayOfParams = fnOrOptions.arrayOfParams;
479
- promisOrValue = functionFn.apply(context, arrayOfParams);
480
- // } else {
481
- // // @ts-ignore
482
- // promisOrValue = _.isArray(fnOrOptions) ? fnOrOptions[1][fnOrOptions[0]](...firstArg) : fnOrOptions(...firstArg);
483
- // }
484
- // let wasPromise = false;
485
- if (promisOrValue instanceof Promise) {
486
- // wasPromise = true;
487
- promisOrValue = Promise.resolve(promisOrValue);
488
- }
489
- // console.log('was promis ', wasPromise)
490
- return [2 /*return*/, promisOrValue];
491
- });
492
- });
493
- };
444
+ async runSyncOrAsync(fnOrOptions) {
445
+ if (core_imports_2._.isUndefined(fnOrOptions)) {
446
+ return void 0;
447
+ }
448
+ let promisOrValue;
449
+ // const optionsMode = _.isObject(fnOrOptions)
450
+ // && !_.isArray(fnOrOptions)
451
+ // && !_.isFunction(fnOrOptions)
452
+ // && !_.isNil(fnOrOptions)
453
+ // ;
454
+ // if (optionsMode) {
455
+ const { functionFn, context, arrayOfParams } = fnOrOptions;
456
+ promisOrValue = functionFn.apply(context, arrayOfParams);
457
+ // } else {
458
+ // // @ts-ignore
459
+ // promisOrValue = _.isArray(fnOrOptions) ? fnOrOptions[1][fnOrOptions[0]](...firstArg) : fnOrOptions(...firstArg);
460
+ // }
461
+ // let wasPromise = false;
462
+ if (promisOrValue instanceof Promise) {
463
+ // wasPromise = true;
464
+ promisOrValue = Promise.resolve(promisOrValue);
465
+ }
466
+ // console.log('was promis ', wasPromise)
467
+ return promisOrValue;
468
+ }
494
469
  //#endregion
495
470
  //#region methods / create symlink
496
471
  //#region @backend
497
- HelpersCore.prototype.createSymLink = function (existedFileOrFolder, destinationPath, options) {
472
+ createSymLink(existedFileOrFolder, destinationPath, options) {
498
473
  //#region fix parameters
499
474
  existedFileOrFolder = (0, core_imports_2.crossPlatformPath)(existedFileOrFolder);
500
475
  destinationPath = (0, core_imports_2.crossPlatformPath)(destinationPath);
@@ -502,7 +477,8 @@ var HelpersCore = /** @class */ (function (_super) {
502
477
  // from: ${existedFileOrFolder},
503
478
  // to: ${destinationPath},
504
479
  // `)
505
- index_1.Helpers.log("[tnp-code][create link] exited -> dest\n ".concat(existedFileOrFolder, " ").concat(destinationPath), 1);
480
+ index_1.Helpers.log(`[tnp-code][create link] exited -> dest
481
+ ${existedFileOrFolder} ${destinationPath}`, 1);
506
482
  options = options ? options : {};
507
483
  if (core_imports_2._.isUndefined(options.continueWhenExistedFolderDoesntExists)) {
508
484
  options.continueWhenExistedFolderDoesntExists = false;
@@ -519,17 +495,34 @@ var HelpersCore = /** @class */ (function (_super) {
519
495
  if (core_imports_2._.isUndefined(options.allowNotAbsolutePathes)) {
520
496
  options.allowNotAbsolutePathes = false;
521
497
  }
498
+ if (options.dontRenameWhenSlashAtEnd) {
499
+ destinationPath = index_1.Helpers.removeSlashAtEnd(destinationPath);
500
+ }
501
+ if (options.tryRemoveDesPath) {
502
+ try {
503
+ core_imports_1.fse.unlinkSync(destinationPath);
504
+ }
505
+ catch (error) {
506
+ try {
507
+ core_imports_1.fse.removeSync(destinationPath);
508
+ }
509
+ catch (error) { }
510
+ }
511
+ }
522
512
  //#endregion
523
- var continueWhenExistedFolderDoesntExists = options.continueWhenExistedFolderDoesntExists, windowsHardLink = options.windowsHardLink, speedUpProcess = options.speedUpProcess;
513
+ const { continueWhenExistedFolderDoesntExists, windowsHardLink, speedUpProcess, } = options;
524
514
  // console.log('Create link!')
525
- var targetExisted = existedFileOrFolder;
526
- var linkDest = destinationPath;
515
+ let targetExisted = existedFileOrFolder;
516
+ let linkDest = destinationPath;
527
517
  if (!core_imports_1.fse.existsSync(existedFileOrFolder)) {
528
518
  if (continueWhenExistedFolderDoesntExists) {
529
519
  // just continue and create link to not existed folder
530
520
  }
531
521
  else {
532
- index_1.Helpers.error("[helpers.createLink] target path doesn't exist: ".concat(existedFileOrFolder, "\n use option \"continueWhenExistedFolderDoesntExists\" to fix this if you know that\n file will be eventually in place\n "));
522
+ index_1.Helpers.error(`[helpers.createLink] target path doesn't exist: ${existedFileOrFolder}
523
+ use option "continueWhenExistedFolderDoesntExists" to fix this if you know that
524
+ file will be eventually in place
525
+ `);
533
526
  }
534
527
  }
535
528
  /**
@@ -551,16 +544,22 @@ var HelpersCore = /** @class */ (function (_super) {
551
544
  }
552
545
  else {
553
546
  if (!core_imports_2.path.isAbsolute(linkDest)) {
554
- index_1.Helpers.error("[createsymlink] path is not absolute:\n targetExisted: ".concat(targetExisted, "\n linkDest: ").concat(linkDest, "\n "));
547
+ index_1.Helpers.error(`[createsymlink] path is not absolute:
548
+ targetExisted: ${targetExisted}
549
+ linkDest: ${linkDest}
550
+ `);
555
551
  }
556
552
  if (!core_imports_2.path.isAbsolute(targetExisted)) {
557
- index_1.Helpers.error("[createsymlink] path is not absolute:\n targetExisted: ".concat(targetExisted, "\n linkDest: ").concat(linkDest, "\n "));
553
+ index_1.Helpers.error(`[createsymlink] path is not absolute:
554
+ targetExisted: ${targetExisted}
555
+ linkDest: ${linkDest}
556
+ `);
558
557
  }
559
558
  }
560
559
  if (linkDest.endsWith('/')) {
561
560
  linkDest = (0, core_imports_2.crossPlatformPath)(core_imports_2.path.join(linkDest, core_imports_2.path.basename(targetExisted)));
562
561
  }
563
- var parentFolderLinkDest = core_imports_2.path.dirname(linkDest);
562
+ const parentFolderLinkDest = core_imports_2.path.dirname(linkDest);
564
563
  if (index_1.Helpers.isSymlinkFileExitedOrUnexisted(parentFolderLinkDest)) {
565
564
  core_imports_1.fse.unlinkSync(parentFolderLinkDest);
566
565
  }
@@ -581,13 +580,16 @@ var HelpersCore = /** @class */ (function (_super) {
581
580
  targetExisted = (0, core_imports_2.crossPlatformPath)(core_imports_1.fse.realpathSync(targetExisted));
582
581
  }
583
582
  catch (error) {
584
- index_1.Helpers.warn("[tnp-helpers] Error while resolving target for windows link\n target: \"".concat(targetExisted, "\"\n link: \"").concat(linkDest, "\"\n "), true);
583
+ index_1.Helpers.warn(`[tnp-helpers] Error while resolving target for windows link
584
+ target: "${targetExisted}"
585
+ link: "${linkDest}"
586
+ `, true);
585
587
  }
586
588
  // TODO QUICK_FIX on windows you can't create link to link
587
589
  }
588
590
  // targetExisted = path.win32.normalize(targetExisted).replace(/\\$/, '');
589
591
  // linkDest = path.win32.normalize(linkDest).replace(/\\$/, '');
590
- var targetIsFile = index_1.Helpers.isFile(targetExisted);
592
+ const targetIsFile = index_1.Helpers.isFile(targetExisted);
591
593
  // const destIsLink = Helpers.isExistedSymlink(linkDest) || Helpers.isUnexistedLink(linkDest)
592
594
  // console.log({
593
595
  // targetExisted,
@@ -603,8 +605,8 @@ var HelpersCore = /** @class */ (function (_super) {
603
605
  }
604
606
  else {
605
607
  if (targetIsFile) {
606
- var winLinkCommand = "mklink ".concat(windowsHardLink ? '/D' : targetIsFile ? '/H' : '/j', " \"").concat(linkDest, "\" \"").concat(targetExisted, "\"");
607
- var showSymlinkOutputOnWindows = forceTrace;
608
+ const winLinkCommand = `mklink ${windowsHardLink ? '/D' : targetIsFile ? '/H' : '/j'} "${linkDest}" "${targetExisted}"`;
609
+ const showSymlinkOutputOnWindows = forceTrace;
608
610
  index_1.Helpers.run(winLinkCommand, {
609
611
  biggerBuffer: false,
610
612
  output: showSymlinkOutputOnWindows,
@@ -643,33 +645,33 @@ var HelpersCore = /** @class */ (function (_super) {
643
645
  else {
644
646
  core_imports_1.fse.symlinkSync(targetExisted, linkDest);
645
647
  }
646
- };
648
+ }
647
649
  //#endregion
648
650
  //#endregion
649
651
  //#region methods / mkdirp
650
652
  //#region @backend
651
- HelpersCore.prototype.createFolder = function (folderPath) {
653
+ createFolder(folderPath) {
652
654
  return index_1.Helpers.mkdirp(folderPath);
653
- };
654
- HelpersCore.prototype.mkdirp = function (folderPath) {
655
+ }
656
+ mkdirp(folderPath) {
655
657
  if (core_imports_2._.isArray(folderPath)) {
656
658
  folderPath = (0, core_imports_2.crossPlatformPath)(folderPath);
657
659
  }
658
660
  if (!core_imports_2.path.isAbsolute(folderPath)) {
659
- index_1.Helpers.warn("[taon-core][mkdirp] Path is not absolute, abort ".concat(folderPath), true);
661
+ index_1.Helpers.warn(`[taon-core][mkdirp] Path is not absolute, abort ${folderPath}`, true);
660
662
  return;
661
663
  }
662
664
  if (core_imports_2._.isString(folderPath) &&
663
665
  folderPath.startsWith('/tmp ') &&
664
666
  core_imports_1.os.platform() === 'darwin') {
665
- index_1.Helpers.warn("[taon-core][mkdirp] On mac osx /tmp is changed to /private/tmp", false);
666
- folderPath = folderPath.replace("/tmp/", '/private/tmp/');
667
+ index_1.Helpers.warn(`[taon-core][mkdirp] On mac osx /tmp is changed to /private/tmp`, false);
668
+ folderPath = folderPath.replace(`/tmp/`, '/private/tmp/');
667
669
  }
668
670
  if (index_1.Helpers.isUnexistedLink(folderPath)) {
669
671
  index_1.Helpers.remove(folderPath);
670
672
  }
671
673
  if (core_imports_1.fse.existsSync(folderPath)) {
672
- index_1.Helpers.log("[taon-core][mkdirp] folder path already exists: ".concat(folderPath));
674
+ index_1.Helpers.log(`[taon-core][mkdirp] folder path already exists: ${folderPath}`);
673
675
  }
674
676
  else {
675
677
  // if (Helpers.isSymlinkFileExitedOrUnexisted(path.dirname(folderPath))) {
@@ -678,10 +680,10 @@ var HelpersCore = /** @class */ (function (_super) {
678
680
  // Helpers.removeFileIfExists(path.dirname(folderPath));
679
681
  // } catch (error) {}
680
682
  // }
681
- index_1.Helpers.log("[taon-core][mkdirp] ".concat(folderPath), 1);
683
+ index_1.Helpers.log(`[taon-core][mkdirp] ${folderPath}`, 1);
682
684
  core_imports_1.fse.mkdirpSync(folderPath);
683
685
  }
684
- };
686
+ }
685
687
  //#endregion
686
688
  //#endregion
687
689
  //#region methods / is symlink that matches url
@@ -689,13 +691,12 @@ var HelpersCore = /** @class */ (function (_super) {
689
691
  * symlink may have existed or unexisted destiantion url
690
692
  * @param destUrl M
691
693
  */
692
- HelpersCore.prototype.isSymlinkThatMatchesUrl = function (possibleSymlink, destUrl, absoluteFileMatch) {
693
- if (absoluteFileMatch === void 0) { absoluteFileMatch = false; }
694
+ isSymlinkThatMatchesUrl(possibleSymlink, destUrl, absoluteFileMatch = false) {
694
695
  //#region @backendFunc
695
696
  destUrl = (0, core_imports_2.crossPlatformPath)(destUrl);
696
697
  if (index_1.Helpers.exists(possibleSymlink)) {
697
698
  if (index_1.Helpers.isExistedSymlink(possibleSymlink)) {
698
- var fileLink = core_imports_1.fse.readlinkSync(possibleSymlink);
699
+ let fileLink = core_imports_1.fse.readlinkSync(possibleSymlink);
699
700
  if (absoluteFileMatch) {
700
701
  fileLink = core_imports_1.fse.realpathSync(fileLink);
701
702
  }
@@ -707,11 +708,11 @@ var HelpersCore = /** @class */ (function (_super) {
707
708
  }
708
709
  }
709
710
  try {
710
- var linkToUnexitedLink = core_imports_1.fse
711
+ const linkToUnexitedLink = core_imports_1.fse
711
712
  .lstatSync(possibleSymlink)
712
713
  .isSymbolicLink();
713
714
  if (linkToUnexitedLink) {
714
- var fileLink = core_imports_1.fse.readlinkSync(possibleSymlink);
715
+ let fileLink = core_imports_1.fse.readlinkSync(possibleSymlink);
715
716
  if (absoluteFileMatch) {
716
717
  fileLink = core_imports_1.fse.realpathSync(fileLink);
717
718
  }
@@ -724,29 +725,29 @@ var HelpersCore = /** @class */ (function (_super) {
724
725
  return false;
725
726
  }
726
727
  //#endregion
727
- };
728
+ }
728
729
  //#endregion
729
730
  //#region methods / is symlink file existed or unexisted
730
- HelpersCore.prototype.isSymlinkFileExitedOrUnexisted = function (filePath) {
731
+ isSymlinkFileExitedOrUnexisted(filePath) {
731
732
  //#region @backendFunc
732
733
  if (core_imports_2._.isArray(filePath)) {
733
- filePath = (0, core_imports_2.crossPlatformPath)(core_imports_2.path.join.apply(core_imports_2.path, tslib_1.__spreadArray([], tslib_1.__read(filePath), false)));
734
+ filePath = (0, core_imports_2.crossPlatformPath)(core_imports_2.path.join(...filePath));
734
735
  }
735
736
  try {
736
- var linkToUnexitedLink = core_imports_1.fse.lstatSync(filePath).isSymbolicLink();
737
+ const linkToUnexitedLink = core_imports_1.fse.lstatSync(filePath).isSymbolicLink();
737
738
  return linkToUnexitedLink;
738
739
  }
739
740
  catch (error) {
740
741
  return false;
741
742
  }
742
743
  //#endregion
743
- };
744
+ }
744
745
  //#endregion
745
746
  //#region methods / is unexisted link
746
747
  /**
747
748
  * If symbolnk link that target file does not exits
748
749
  */
749
- HelpersCore.prototype.isUnexistedLink = function (filePath) {
750
+ isUnexistedLink(filePath) {
750
751
  //#region @backendFunc
751
752
  if (core_imports_2._.isArray(filePath)) {
752
753
  filePath = (0, core_imports_2.crossPlatformPath)(filePath);
@@ -756,7 +757,7 @@ var HelpersCore = /** @class */ (function (_super) {
756
757
  filePath = core_imports_2.path.win32.normalize(filePath);
757
758
  }
758
759
  try {
759
- var linkToUnexitedLink = core_imports_1.fse
760
+ const linkToUnexitedLink = core_imports_1.fse
760
761
  .lstatSync(filePath)
761
762
  .isSymbolicLink();
762
763
  return (linkToUnexitedLink &&
@@ -766,13 +767,13 @@ var HelpersCore = /** @class */ (function (_super) {
766
767
  return false;
767
768
  }
768
769
  //#endregion
769
- };
770
+ }
770
771
  //#endregion
771
772
  //#region methods / is exited symlink
772
773
  /**
773
774
  * @param existedLink check if source of link exists
774
775
  */
775
- HelpersCore.prototype.isExistedSymlink = function (filePath) {
776
+ isExistedSymlink(filePath) {
776
777
  //#region @backendFunc
777
778
  if (core_imports_2._.isArray(filePath)) {
778
779
  filePath = (0, core_imports_2.crossPlatformPath)(filePath);
@@ -782,7 +783,7 @@ var HelpersCore = /** @class */ (function (_super) {
782
783
  filePath = core_imports_2.path.win32.normalize(filePath);
783
784
  }
784
785
  try {
785
- var linkToUnexitedLink = core_imports_1.fse
786
+ const linkToUnexitedLink = core_imports_1.fse
786
787
  .lstatSync(filePath)
787
788
  .isSymbolicLink();
788
789
  return (linkToUnexitedLink &&
@@ -792,12 +793,12 @@ var HelpersCore = /** @class */ (function (_super) {
792
793
  return false;
793
794
  }
794
795
  //#endregion
795
- };
796
+ }
796
797
  //#endregion
797
798
  //#region methods / path contain link
798
799
  //#region @backend
799
- HelpersCore.prototype.pathContainLink = function (p) {
800
- var previous;
800
+ pathContainLink(p) {
801
+ let previous;
801
802
  while (true) {
802
803
  p = (0, core_imports_2.crossPlatformPath)(core_imports_2.path.dirname(p));
803
804
  // @ts-ignore
@@ -812,180 +813,163 @@ var HelpersCore = /** @class */ (function (_super) {
812
813
  }
813
814
  previous = p;
814
815
  }
815
- };
816
+ }
816
817
  //#endregion
817
818
  //#endregion
818
819
  //#region methods / exists
819
- HelpersCore.prototype.exists = function (folderOrFilePath) {
820
+ exists(folderOrFilePath) {
820
821
  //#region @backendFunc
821
822
  if (core_imports_2._.isArray(folderOrFilePath)) {
822
823
  folderOrFilePath = (0, core_imports_2.crossPlatformPath)(folderOrFilePath);
823
824
  }
824
825
  if (!folderOrFilePath) {
825
- index_1.Helpers.warn("[taon-core][exists] Path is not a string, abort.. \"".concat(folderOrFilePath, "\""), true);
826
+ index_1.Helpers.warn(`[taon-core][exists] Path is not a string, abort.. "${folderOrFilePath}"`, true);
826
827
  return false;
827
828
  }
828
829
  if (!core_imports_2.path.isAbsolute(folderOrFilePath)) {
829
- index_1.Helpers.warn("[taon-core]\n File path is not absolute:\n ".concat(folderOrFilePath, "\n\n "), true);
830
+ index_1.Helpers.warn(`[taon-core]
831
+ File path is not absolute:
832
+ ${folderOrFilePath}
833
+
834
+ `, true);
830
835
  return false;
831
836
  }
832
837
  return core_imports_1.fse.existsSync(folderOrFilePath);
833
838
  //#endregion
834
- };
839
+ }
835
840
  //#endregion
836
841
  //#region methods / fix command
837
842
  /**
838
843
  * this is HACK for running procesess inside processes
839
844
  */
840
- HelpersCore.prototype._fixCommand = function (command) {
845
+ _fixCommand(command) {
841
846
  if ((command.startsWith('tnp ') || command.startsWith('taon ')) && // TODO every cli projects here that uses run and need to kill process easly!
842
847
  command.search('-spinner=false') === -1 &&
843
848
  command.search('-spinner=off') === -1) {
844
- command = "".concat(command, " -spinner=false");
849
+ command = `${command} -spinner=false`;
845
850
  }
846
851
  if (global.skipCoreCheck &&
847
852
  (command.startsWith('tnp ') || command.startsWith('taon '))) {
848
- command = "".concat(command, " --skipCoreCheck");
853
+ command = `${command} --skipCoreCheck`;
849
854
  }
850
855
  return command;
851
- };
856
+ }
852
857
  //#endregion
853
858
  //#region methods / command
854
- HelpersCore.prototype.command = function (command) {
859
+ command(command) {
855
860
  // console.log({ command })
856
861
  command = index_1.Helpers._fixCommand(command);
857
862
  return {
858
863
  //#region @backend
859
- getherOutput: function (options) {
864
+ getherOutput(options) {
860
865
  if (!options) {
861
866
  options = {};
862
867
  }
863
- return new Promise(function (resolve) {
868
+ return new Promise(resolve => {
864
869
  // @ts-ignore
865
- var ommitStder = options.ommitStder, cwd = options.cwd, biggerBuffer = options.biggerBuffer, gatherColors = options.gatherColors;
870
+ let { ommitStder, cwd, biggerBuffer, gatherColors } = options;
866
871
  if (!cwd) {
867
872
  cwd = process.cwd();
868
873
  }
869
- var maxBuffer = biggerBuffer ? index_1.Helpers.bigMaxBuffer : void 0;
870
- var env = gatherColors ? tslib_1.__assign(tslib_1.__assign({}, process.env), { FORCE_COLOR: '1' }) : {};
871
- var proc = core_imports_1.child_process.exec(command, {
872
- cwd: cwd, // @ts-ignore
873
- maxBuffer: maxBuffer,
874
+ const maxBuffer = biggerBuffer ? index_1.Helpers.bigMaxBuffer : void 0;
875
+ const env = gatherColors ? { ...process.env, FORCE_COLOR: '1' } : {};
876
+ const proc = core_imports_1.child_process.exec(command, {
877
+ cwd, // @ts-ignore
878
+ maxBuffer,
874
879
  env: env,
875
880
  });
876
- var gatheredData = '';
877
- proc.on('exit', function (code) {
881
+ let gatheredData = '';
882
+ proc.on('exit', code => {
878
883
  resolve(gatheredData);
879
884
  });
880
885
  // @ts-ignore
881
- proc.stdout.on('data', function (data) {
882
- gatheredData = "".concat(gatheredData).concat((data === null || data === void 0 ? void 0 : data.toString()) || '');
886
+ proc.stdout.on('data', data => {
887
+ gatheredData = `${gatheredData}${data?.toString() || ''}`;
883
888
  });
884
889
  // @ts-ignore
885
- proc.stdout.on('error', function (data) {
886
- gatheredData = "".concat(gatheredData).concat((data === null || data === void 0 ? void 0 : data.toString()) || '');
890
+ proc.stdout.on('error', data => {
891
+ gatheredData = `${gatheredData}${data?.toString() || ''}`;
887
892
  });
888
893
  if (!ommitStder) {
889
894
  // @ts-ignore
890
- proc.stderr.on('data', function (data) {
891
- gatheredData = "".concat(gatheredData).concat((data === null || data === void 0 ? void 0 : data.toString()) || '');
895
+ proc.stderr.on('data', data => {
896
+ gatheredData = `${gatheredData}${data?.toString() || ''}`;
892
897
  });
893
898
  // @ts-ignore
894
- proc.stderr.on('error', function (data) {
895
- gatheredData = "".concat(gatheredData).concat((data === null || data === void 0 ? void 0 : data.toString()) || '');
899
+ proc.stderr.on('error', data => {
900
+ gatheredData = `${gatheredData}${data?.toString() || ''}`;
896
901
  });
897
902
  }
898
903
  });
899
904
  },
900
905
  //#endregion
901
906
  };
902
- };
907
+ }
903
908
  //#endregion
904
909
  //#region methods / wait
905
- HelpersCore.prototype.wait = function (second) {
906
- return new Promise(function (resolve, reject) {
907
- setTimeout(function () {
908
- resolve(void 0);
909
- }, second * 1000);
910
- });
911
- };
912
- HelpersCore.prototype.timeout = function (seconds) {
913
- return tslib_1.__awaiter(this, void 0, void 0, function () {
914
- return tslib_1.__generator(this, function (_a) {
915
- switch (_a.label) {
916
- case 0: return [4 /*yield*/, index_1.Helpers.wait(seconds)];
917
- case 1: return [2 /*return*/, _a.sent()];
918
- }
919
- });
920
- });
921
- };
910
+ /**
911
+ * @deprecated use UtilsTerminal.wait
912
+ */
913
+ async wait(second) {
914
+ await utils_1.UtilsTerminal.wait(second);
915
+ }
916
+ async timeout(seconds) {
917
+ return await index_1.Helpers.wait(seconds);
918
+ }
922
919
  //#endregion
923
920
  //#region methods / command output as string async
924
921
  //#region @backend
925
- HelpersCore.prototype.commnadOutputAsStringAsync = function (command_1) {
926
- return tslib_1.__awaiter(this, arguments, void 0, function (command, cwd, options) {
927
- var opt, output, splited, e_1;
928
- if (cwd === void 0) { cwd = (0, core_imports_2.crossPlatformPath)(process.cwd()); }
929
- return tslib_1.__generator(this, function (_a) {
930
- switch (_a.label) {
931
- case 0:
932
- command = index_1.Helpers._fixCommand(command);
933
- opt = (options || {});
934
- output = '';
935
- _a.label = 1;
936
- case 1:
937
- _a.trys.push([1, 3, , 4]);
938
- return [4 /*yield*/, index_1.Helpers.command(command).getherOutput({
939
- cwd: cwd, // @ts-ignore
940
- biggerBuffer: opt.biggerBuffer, // @ts-ignore
941
- ommitStder: !opt.showStder, // @ts-ignore
942
- gatherColors: opt.gatherColors,
943
- })];
944
- case 2:
945
- output = _a.sent();
946
- // console.log({
947
- // output
948
- // })
949
- // @ts-ignore
950
- if (!opt.showOnlyLastLine) {
951
- return [2 /*return*/, output.replace(/[^\x00-\xFF]/g, '')];
952
- }
953
- splited = (output || '').split('\n');
954
- output = (splited.pop() || '').replace(/[^\x00-\xFF]/g, '');
955
- return [3 /*break*/, 4];
956
- case 3:
957
- e_1 = _a.sent();
958
- // @ts-ignore
959
- if (opt.showErrorWarning) {
960
- index_1.Helpers.warn("[taon-helepr] Not able to get output from command:\n \"".concat(command, "\"\n "));
961
- }
962
- return [3 /*break*/, 4];
963
- case 4: return [2 /*return*/, output];
964
- }
922
+ async commnadOutputAsStringAsync(command, cwd = (0, core_imports_2.crossPlatformPath)(process.cwd()), options) {
923
+ command = index_1.Helpers._fixCommand(command);
924
+ const opt = (options || {});
925
+ let output = '';
926
+ try {
927
+ output = await index_1.Helpers.command(command).getherOutput({
928
+ cwd, // @ts-ignore
929
+ biggerBuffer: opt.biggerBuffer, // @ts-ignore
930
+ ommitStder: !opt.showStder, // @ts-ignore
931
+ gatherColors: opt.gatherColors,
965
932
  });
966
- });
967
- };
933
+ // console.log({
934
+ // output
935
+ // })
936
+ // @ts-ignore
937
+ if (!opt.showOnlyLastLine) {
938
+ return output.replace(/[^\x00-\xFF]/g, '');
939
+ }
940
+ const splited = (output || '').split('\n');
941
+ output = (splited.pop() || '').replace(/[^\x00-\xFF]/g, '');
942
+ }
943
+ catch (e) {
944
+ // @ts-ignore
945
+ if (opt.showErrorWarning) {
946
+ index_1.Helpers.warn(`[taon-helepr] Not able to get output from command:
947
+ "${command}"
948
+ `);
949
+ }
950
+ }
951
+ return output;
952
+ }
968
953
  //#endregion
969
954
  //#endregion
970
955
  //#region methods / command output as string
971
956
  //#region @backend
972
- HelpersCore.prototype.commnadOutputAsString = function (command, cwd, options) {
973
- var _a;
974
- if (cwd === void 0) { cwd = (0, core_imports_2.crossPlatformPath)(process.cwd()); }
957
+ commnadOutputAsString(command, cwd = (0, core_imports_2.crossPlatformPath)(process.cwd()), options) {
975
958
  command = index_1.Helpers._fixCommand(command);
976
- var opt = (options || {});
977
- var output = '';
959
+ const opt = (options || {});
960
+ let output = '';
978
961
  try {
979
962
  // @ts-ignore
980
- var env = opt.gatherColors ? tslib_1.__assign(tslib_1.__assign({}, process.env), { FORCE_COLOR: '1' }) : {};
963
+ const env = opt.gatherColors ? { ...process.env, FORCE_COLOR: '1' } : {};
981
964
  // output = Helpers.run(command, { output: false, cwd, biggerBuffer }).sync().toString().trim()
982
- output = (((_a = core_imports_1.child_process
965
+ output = (core_imports_1.child_process
983
966
  .execSync(command, {
984
- cwd: cwd, // @ts-ignore
967
+ cwd, // @ts-ignore
985
968
  stdio: ['ignore', 'pipe', opt.showStder ? 'pipe' : 'ignore'], // @ts-ignore
986
969
  maxBuffer: opt.biggerBuffer ? index_1.Helpers.bigMaxBuffer : void 0,
987
970
  env: env,
988
- })) === null || _a === void 0 ? void 0 : _a.toString()) || '').trim();
971
+ })
972
+ ?.toString() || '').trim();
989
973
  // console.log({
990
974
  // output
991
975
  // })
@@ -993,86 +977,78 @@ var HelpersCore = /** @class */ (function (_super) {
993
977
  if (!opt.showOnlyLastLine) {
994
978
  return output.replace(/[^\x00-\xFF]/g, '');
995
979
  }
996
- var splited = (output || '').split('\n');
980
+ const splited = (output || '').split('\n');
997
981
  output = (splited.pop() || '').replace(/[^\x00-\xFF]/g, '');
998
982
  }
999
983
  catch (e) {
1000
984
  // @ts-ignore
1001
985
  if (opt.showErrorWarning) {
1002
- index_1.Helpers.warn("[taon-helpers] Not able to get output from command:\n \"".concat(command, "\"\n cwd: ").concat(cwd, "\n "));
986
+ index_1.Helpers.warn(`[taon-helpers] Not able to get output from command:
987
+ "${command}"
988
+ cwd: ${cwd}
989
+ `);
1003
990
  }
1004
991
  }
1005
992
  return output;
1006
- };
993
+ }
1007
994
  //#endregion
1008
995
  //#endregion
1009
996
  //#region methods / kill process by port
1010
- HelpersCore.prototype.killProcessByPort = function (portOrPortsToKill, options) {
1011
- return tslib_1.__awaiter(this, void 0, void 0, function () {
1012
- var showOutoput, index, port, org, e_2;
1013
- return tslib_1.__generator(this, function (_a) {
1014
- switch (_a.label) {
1015
- case 0:
1016
- showOutoput = !options || !options.silent;
1017
- if (!core_imports_2._.isArray(portOrPortsToKill)) {
1018
- portOrPortsToKill = [portOrPortsToKill];
1019
- }
1020
- index = 0;
1021
- _a.label = 1;
1022
- case 1:
1023
- if (!(index < portOrPortsToKill.length)) return [3 /*break*/, 6];
1024
- port = portOrPortsToKill[index];
1025
- index_1.Helpers.info("[taon-helpers] Killing process on port: ".concat(port));
1026
- org = port;
1027
- port = Number(port);
1028
- if (!core_imports_2._.isNumber(port)) {
1029
- showOutoput &&
1030
- index_1.Helpers.warn("[taon-helpers] Can't kill on port: \"".concat(org, "\""));
1031
- return [2 /*return*/];
1032
- }
1033
- _a.label = 2;
1034
- case 2:
1035
- _a.trys.push([2, 4, , 5]);
1036
- return [4 /*yield*/, (0, core_imports_1.fkill)(":".concat(port), { force: true })];
1037
- case 3:
1038
- _a.sent();
1039
- // run(`fkill -f :${port} &> /dev/null`, { output: false }).sync()
1040
- showOutoput &&
1041
- index_1.Helpers.info("[taon-helpers] Processs killed successfully on port: ".concat(port));
1042
- return [3 /*break*/, 5];
1043
- case 4:
1044
- e_2 = _a.sent();
1045
- showOutoput &&
1046
- index_1.Helpers.warn("[taon-helpers] No process to kill on port: ".concat(port, "... "), false);
1047
- return [3 /*break*/, 5];
1048
- case 5:
1049
- index++;
1050
- return [3 /*break*/, 1];
1051
- case 6: return [2 /*return*/];
1052
- }
1053
- });
1054
- });
1055
- };
997
+ async killProcessByPort(portOrPortsToKill, options) {
998
+ //#region @backendFunc
999
+ const showOutoput = !options || !options.silent;
1000
+ if (!core_imports_2._.isArray(portOrPortsToKill)) {
1001
+ portOrPortsToKill = [portOrPortsToKill];
1002
+ }
1003
+ for (let index = 0; index < portOrPortsToKill.length; index++) {
1004
+ let port = portOrPortsToKill[index];
1005
+ index_1.Helpers.info(`[taon-helpers] Killing process on port: ${port}`);
1006
+ const org = port;
1007
+ port = Number(port);
1008
+ if (!core_imports_2._.isNumber(port)) {
1009
+ showOutoput &&
1010
+ index_1.Helpers.warn(`[taon-helpers] Can't kill on port: "${org}"`);
1011
+ return;
1012
+ }
1013
+ try {
1014
+ await (0, core_imports_1.fkill)(`:${port}`, { force: true });
1015
+ // run(`fkill -f :${port} &> /dev/null`, { output: false }).sync()
1016
+ showOutoput &&
1017
+ index_1.Helpers.info(`[taon-helpers] Processs killed successfully on port: ${port}`);
1018
+ }
1019
+ catch (e) {
1020
+ showOutoput &&
1021
+ index_1.Helpers.warn(`[taon-helpers] No process to kill on port: ${port}... `, false);
1022
+ }
1023
+ // console.log(`Killing process on port ${port} in progress`);
1024
+ // try {
1025
+ // if (os.platform() === 'linux') {
1026
+ // run(`lsof -i:${port}`, { output: false }).sync()
1027
+ // } else if (os.platform() === 'darwin') {
1028
+ // run(`lsof -P | grep ':${port}' | awk '{print $2}' | xargs kill -9 `, { output: false }).sync()
1029
+ // }
1030
+ // info(`Process killed on port: ${port}`)
1031
+ // } catch (e) {
1032
+ // error(`Problem with killing process on port ${port}:
1033
+ // ${e}
1034
+ // `, true)
1035
+ // }
1036
+ }
1037
+ //#endregion
1038
+ }
1056
1039
  //#endregion
1057
1040
  //#region methods / kill on port
1058
- HelpersCore.prototype.killOnPort = function (portOrPortsToKill, options) {
1059
- return tslib_1.__awaiter(this, void 0, void 0, function () {
1060
- return tslib_1.__generator(this, function (_a) {
1061
- switch (_a.label) {
1062
- case 0: return [4 /*yield*/, index_1.Helpers.killProcessByPort(portOrPortsToKill, options)];
1063
- case 1: return [2 /*return*/, _a.sent()];
1064
- }
1065
- });
1066
- });
1067
- };
1041
+ async killOnPort(portOrPortsToKill, options) {
1042
+ return await index_1.Helpers.killProcessByPort(portOrPortsToKill, options);
1043
+ }
1068
1044
  //#endregion
1069
1045
  //#region methods / kill process
1070
- HelpersCore.prototype.killProcess = function (byPid) {
1046
+ killProcess(byPid) {
1071
1047
  //#region @backend
1072
1048
  // Helpers.run(`kill -9 ${byPid}`).sync()
1073
1049
  //#endregion
1074
1050
  //#region @backend
1075
- index_1.Helpers.run("fkill --force ".concat(byPid)).sync();
1051
+ index_1.Helpers.run(`fkill --force ${byPid}`).sync();
1076
1052
  // return;
1077
1053
  //#endregion
1078
1054
  /* */
@@ -1097,10 +1073,10 @@ var HelpersCore = /** @class */ (function (_super) {
1097
1073
  /* */
1098
1074
  /* */
1099
1075
  /* */
1100
- };
1076
+ }
1101
1077
  //#endregion
1102
1078
  //#region methods / run
1103
- HelpersCore.prototype.run = function (command, options) {
1079
+ run(command, options) {
1104
1080
  command = index_1.Helpers._fixCommand(command);
1105
1081
  // console.log({ command })
1106
1082
  //#region @backend
@@ -1113,26 +1089,31 @@ var HelpersCore = /** @class */ (function (_super) {
1113
1089
  if (options.cwd === void 0)
1114
1090
  options.cwd = (0, core_imports_2.crossPlatformPath)(process.cwd());
1115
1091
  if (!core_imports_2._.isString(command)) {
1116
- index_1.Helpers.error("[taon-helpers] command is not a string");
1092
+ index_1.Helpers.error(`[taon-helpers] command is not a string`);
1117
1093
  }
1118
1094
  //#endregion
1119
1095
  return {
1120
1096
  /**
1121
1097
  * start command as synchronous nodej proces
1122
1098
  */
1123
- sync: function () {
1099
+ sync() {
1124
1100
  // TODO buffer
1125
1101
  //#region @backendFunc
1126
1102
  // @ts-ignore
1127
1103
  if (core_imports_2._.isArray(options.extractFromLine)) {
1128
- index_1.Helpers.error("[tnp-helper] extractFromLine only for:\n - asyncAsPromise\n - async\n - unitlOutputContains\n\n ", false, true);
1104
+ index_1.Helpers.error(`[tnp-helper] extractFromLine only for:
1105
+ - asyncAsPromise
1106
+ - async
1107
+ - unitlOutputContains
1108
+
1109
+ `, false, true);
1129
1110
  }
1130
1111
  // @ts-ignore
1131
1112
  if (core_imports_2._.isNumber(options.tryAgainWhenFailAfter) &&
1132
1113
  options.tryAgainWhenFailAfter > 0) {
1133
1114
  // TODO try again when fail
1134
1115
  // try {
1135
- var proc = index_1.Helpers.runSyncIn(command, options);
1116
+ const proc = index_1.Helpers.runSyncIn(command, options);
1136
1117
  return proc;
1137
1118
  // } catch (error) {
1138
1119
  // TODO: WAIT FUNCTION HERE
@@ -1146,7 +1127,7 @@ var HelpersCore = /** @class */ (function (_super) {
1146
1127
  * start command as asynchronous nodej proces
1147
1128
  * @param detach (default: false) - if true process will be detached
1148
1129
  */
1149
- async: function (detach) {
1130
+ async(detach = false) {
1150
1131
  //#region websqlFunc
1151
1132
  //#region mock of process
1152
1133
  /* */
@@ -1247,7 +1228,6 @@ var HelpersCore = /** @class */ (function (_super) {
1247
1228
  /* */
1248
1229
  /* */
1249
1230
  /* */
1250
- if (detach === void 0) { detach = false; }
1251
1231
  //#endregion
1252
1232
  //#region @backendFunc
1253
1233
  // @ts-ignore
@@ -1259,18 +1239,18 @@ var HelpersCore = /** @class */ (function (_super) {
1259
1239
  /**
1260
1240
  * start command as asynchronous nodej proces inside promise
1261
1241
  */
1262
- asyncAsPromise: function () {
1242
+ asyncAsPromise() {
1263
1243
  //#region @backendFunc
1264
- var isResolved = false;
1265
- return new Promise(function (resolve, reject) {
1266
- var proc = index_1.Helpers.runAsyncIn(command, options);
1267
- proc.on('exit', function () {
1244
+ let isResolved = false;
1245
+ return new Promise((resolve, reject) => {
1246
+ const proc = index_1.Helpers.runAsyncIn(command, options);
1247
+ proc.on('exit', () => {
1268
1248
  if (!isResolved) {
1269
1249
  isResolved = true;
1270
1250
  resolve(void 0);
1271
1251
  }
1272
1252
  });
1273
- proc.on('error', function () {
1253
+ proc.on('error', () => {
1274
1254
  if (!isResolved) {
1275
1255
  isResolved = true;
1276
1256
  reject();
@@ -1279,12 +1259,12 @@ var HelpersCore = /** @class */ (function (_super) {
1279
1259
  });
1280
1260
  //#endregion
1281
1261
  },
1282
- unitlOutput: function (optionsOutput) {
1262
+ unitlOutput(optionsOutput) {
1283
1263
  //#region @backendFunc
1284
1264
  optionsOutput = optionsOutput || {};
1285
- var stdoutMsg = optionsOutput.stdoutMsg, stderMsg = optionsOutput.stderMsg, timeout = optionsOutput.timeout, stdoutOutputContainsCallback = optionsOutput.stdoutOutputContainsCallback;
1286
- var isResolved = false;
1287
- return new Promise(function (resolve, reject) {
1265
+ let { stdoutMsg, stderMsg, timeout, stdoutOutputContainsCallback } = optionsOutput;
1266
+ let isResolved = false;
1267
+ return new Promise((resolve, reject) => {
1288
1268
  if (core_imports_2._.isString(stdoutMsg)) {
1289
1269
  stdoutMsg = [stdoutMsg];
1290
1270
  }
@@ -1292,23 +1272,23 @@ var HelpersCore = /** @class */ (function (_super) {
1292
1272
  stderMsg = [stderMsg];
1293
1273
  }
1294
1274
  if (!core_imports_2._.isArray(stdoutMsg)) {
1295
- reject("[unitlOutputContains] Message not a array");
1275
+ reject(`[unitlOutputContains] Message not a array`);
1296
1276
  }
1297
- var proc = index_1.Helpers.runAsyncIn(command, options);
1298
- proc.on('exit', function () {
1299
- console.info("EXIT OF PROCESS");
1277
+ const proc = index_1.Helpers.runAsyncIn(command, options);
1278
+ proc.on('exit', () => {
1279
+ console.info(`EXIT OF PROCESS`);
1300
1280
  });
1301
1281
  //#region stderr
1302
1282
  // @ts-ignore
1303
- proc.stderr.on('data', function (message) {
1304
- var data = message.toString().trim();
1283
+ proc.stderr.on('data', message => {
1284
+ const data = message.toString().trim();
1305
1285
  if (!isResolved && core_imports_2._.isArray(stderMsg)) {
1306
- for (var index = 0; index < stderMsg.length; index++) {
1307
- var rejectm = stderMsg[index];
1286
+ for (let index = 0; index < stderMsg.length; index++) {
1287
+ const rejectm = stderMsg[index];
1308
1288
  if (data.search(rejectm) !== -1) {
1309
- console.info("[unitlOutputContains] Rejected move to next step...");
1289
+ console.info(`[unitlOutputContains] Rejected move to next step...`);
1310
1290
  isResolved = true;
1311
- setTimeout(function () {
1291
+ setTimeout(() => {
1312
1292
  reject();
1313
1293
  proc.kill('SIGINT');
1314
1294
  }, timeout);
@@ -1320,13 +1300,13 @@ var HelpersCore = /** @class */ (function (_super) {
1320
1300
  //#endregion
1321
1301
  //#region stdout
1322
1302
  // @ts-ignore
1323
- proc.stdout.on('data', function (message) {
1324
- var data = message.toString().trim();
1303
+ proc.stdout.on('data', message => {
1304
+ const data = message.toString().trim();
1325
1305
  if (isResolved) {
1326
- for (var index = 0; index < stdoutMsg.length; index++) {
1327
- var m = stdoutMsg[index];
1306
+ for (let index = 0; index < stdoutMsg.length; index++) {
1307
+ const m = stdoutMsg[index];
1328
1308
  if (data.search(m) !== -1) {
1329
- console.info("[unitlOutputContains][is resolved] Move to next step...");
1309
+ console.info(`[unitlOutputContains][is resolved] Move to next step...`);
1330
1310
  stdoutOutputContainsCallback &&
1331
1311
  stdoutOutputContainsCallback();
1332
1312
  break;
@@ -1334,14 +1314,14 @@ var HelpersCore = /** @class */ (function (_super) {
1334
1314
  }
1335
1315
  }
1336
1316
  else {
1337
- for (var index = 0; index < stdoutMsg.length; index++) {
1338
- var m = stdoutMsg[index];
1317
+ for (let index = 0; index < stdoutMsg.length; index++) {
1318
+ const m = stdoutMsg[index];
1339
1319
  if (data.search(m) !== -1) {
1340
- console.info("[unitlOutputContains] Move to next step...");
1320
+ console.info(`[unitlOutputContains] Move to next step...`);
1341
1321
  stdoutOutputContainsCallback &&
1342
1322
  stdoutOutputContainsCallback();
1343
1323
  isResolved = true;
1344
- setTimeout(function () {
1324
+ setTimeout(() => {
1345
1325
  resolve(void 0);
1346
1326
  }, timeout);
1347
1327
  break;
@@ -1349,12 +1329,12 @@ var HelpersCore = /** @class */ (function (_super) {
1349
1329
  }
1350
1330
  }
1351
1331
  if (!isResolved && core_imports_2._.isArray(stderMsg)) {
1352
- for (var index = 0; index < stderMsg.length; index++) {
1353
- var rejectm = stderMsg[index];
1332
+ for (let index = 0; index < stderMsg.length; index++) {
1333
+ const rejectm = stderMsg[index];
1354
1334
  if (data.search(rejectm) !== -1) {
1355
- console.info("[unitlOutputContains] Rejected move to next step...");
1335
+ console.info(`[unitlOutputContains] Rejected move to next step...`);
1356
1336
  isResolved = true;
1357
- setTimeout(function () {
1337
+ setTimeout(() => {
1358
1338
  reject();
1359
1339
  proc.kill('SIGINT');
1360
1340
  }, timeout);
@@ -1372,11 +1352,10 @@ var HelpersCore = /** @class */ (function (_super) {
1372
1352
  * start command as asynchronous nodej proces inside promise
1373
1353
  * and wait until output contains some string
1374
1354
  */
1375
- unitlOutputContains: function (stdoutMsg, stderMsg, timeout, stdoutOutputContainsCallback) {
1376
- if (timeout === void 0) { timeout = 0; }
1355
+ unitlOutputContains(stdoutMsg, stderMsg, timeout = 0, stdoutOutputContainsCallback) {
1377
1356
  //#region @backendFunc
1378
- var isResolved = false;
1379
- return new Promise(function (resolve, reject) {
1357
+ let isResolved = false;
1358
+ return new Promise((resolve, reject) => {
1380
1359
  if (core_imports_2._.isString(stdoutMsg)) {
1381
1360
  stdoutMsg = [stdoutMsg];
1382
1361
  }
@@ -1384,19 +1363,19 @@ var HelpersCore = /** @class */ (function (_super) {
1384
1363
  stderMsg = [stderMsg];
1385
1364
  }
1386
1365
  if (!core_imports_2._.isArray(stdoutMsg)) {
1387
- reject("[unitlOutputContains] Message not a array");
1366
+ reject(`[unitlOutputContains] Message not a array`);
1388
1367
  }
1389
- var proc = index_1.Helpers.runAsyncIn(command, options);
1368
+ const proc = index_1.Helpers.runAsyncIn(command, options);
1390
1369
  // @ts-ignore
1391
- proc.stderr.on('data', function (message) {
1392
- var data = message.toString().trim();
1370
+ proc.stderr.on('data', message => {
1371
+ const data = message.toString().trim();
1393
1372
  if (!isResolved && core_imports_2._.isArray(stderMsg)) {
1394
- for (var index = 0; index < stderMsg.length; index++) {
1395
- var rejectm = stderMsg[index];
1373
+ for (let index = 0; index < stderMsg.length; index++) {
1374
+ const rejectm = stderMsg[index];
1396
1375
  if (data.search(rejectm) !== -1) {
1397
- index_1.Helpers.info("[unitlOutputContains] Rejected move to next step...");
1376
+ index_1.Helpers.info(`[unitlOutputContains] Rejected move to next step...`);
1398
1377
  isResolved = true;
1399
- setTimeout(function () {
1378
+ setTimeout(() => {
1400
1379
  reject();
1401
1380
  proc.kill('SIGINT');
1402
1381
  }, timeout);
@@ -1406,11 +1385,11 @@ var HelpersCore = /** @class */ (function (_super) {
1406
1385
  }
1407
1386
  });
1408
1387
  // @ts-ignore
1409
- proc.stdout.on('data', function (message) {
1410
- var data = message.toString().trim();
1388
+ proc.stdout.on('data', message => {
1389
+ const data = message.toString().trim();
1411
1390
  if (isResolved) {
1412
- for (var index = 0; index < stdoutMsg.length; index++) {
1413
- var m = stdoutMsg[index];
1391
+ for (let index = 0; index < stdoutMsg.length; index++) {
1392
+ const m = stdoutMsg[index];
1414
1393
  if (data.search(m) !== -1) {
1415
1394
  stdoutOutputContainsCallback &&
1416
1395
  stdoutOutputContainsCallback();
@@ -1419,14 +1398,14 @@ var HelpersCore = /** @class */ (function (_super) {
1419
1398
  }
1420
1399
  }
1421
1400
  else {
1422
- for (var index = 0; index < stdoutMsg.length; index++) {
1423
- var m = stdoutMsg[index];
1401
+ for (let index = 0; index < stdoutMsg.length; index++) {
1402
+ const m = stdoutMsg[index];
1424
1403
  if (data.search(m) !== -1) {
1425
- index_1.Helpers.info("[unitlOutputContains] Move to next step...");
1404
+ index_1.Helpers.info(`[unitlOutputContains] Move to next step...`);
1426
1405
  stdoutOutputContainsCallback &&
1427
1406
  stdoutOutputContainsCallback();
1428
1407
  isResolved = true;
1429
- setTimeout(function () {
1408
+ setTimeout(() => {
1430
1409
  resolve(void 0);
1431
1410
  }, timeout);
1432
1411
  break;
@@ -1434,12 +1413,12 @@ var HelpersCore = /** @class */ (function (_super) {
1434
1413
  }
1435
1414
  }
1436
1415
  if (!isResolved && core_imports_2._.isArray(stderMsg)) {
1437
- for (var index = 0; index < stderMsg.length; index++) {
1438
- var rejectm = stderMsg[index];
1416
+ for (let index = 0; index < stderMsg.length; index++) {
1417
+ const rejectm = stderMsg[index];
1439
1418
  if (data.search(rejectm) !== -1) {
1440
- index_1.Helpers.info("[unitlOutputContains] Rejected move to next step...");
1419
+ index_1.Helpers.info(`[unitlOutputContains] Rejected move to next step...`);
1441
1420
  isResolved = true;
1442
- setTimeout(function () {
1421
+ setTimeout(() => {
1443
1422
  reject();
1444
1423
  proc.kill('SIGINT');
1445
1424
  }, timeout);
@@ -1452,41 +1431,36 @@ var HelpersCore = /** @class */ (function (_super) {
1452
1431
  //#endregion
1453
1432
  },
1454
1433
  };
1455
- };
1434
+ }
1456
1435
  //#endregion
1457
1436
  //#region methods / question yest no
1458
1437
  /**
1459
1438
  * @deprecated use UtilsTerminal.confirm
1460
1439
  */
1461
- HelpersCore.prototype.questionYesNo = function (message_1, callbackTrue_1, callbackFalse_1) {
1462
- return tslib_1.__awaiter(this, arguments, void 0, function (message, callbackTrue, callbackFalse, defaultValue) {
1463
- if (defaultValue === void 0) { defaultValue = true; }
1464
- return tslib_1.__generator(this, function (_a) {
1465
- switch (_a.label) {
1466
- case 0: return [4 /*yield*/, utils_1.UtilsTerminal.confirm({
1467
- message: message,
1468
- callbackTrue: callbackTrue,
1469
- callbackFalse: callbackFalse,
1470
- defaultValue: defaultValue,
1471
- })];
1472
- case 1:
1473
- //#region @backendFunc
1474
- return [2 /*return*/, _a.sent()];
1475
- }
1476
- });
1440
+ async questionYesNo(message, callbackTrue, callbackFalse, defaultValue = true) {
1441
+ //#region @backendFunc
1442
+ return await utils_1.UtilsTerminal.confirm({
1443
+ message,
1444
+ callbackTrue,
1445
+ callbackFalse,
1446
+ defaultValue,
1477
1447
  });
1478
- };
1448
+ //#endregion
1449
+ }
1479
1450
  //#endregion
1480
1451
  //#region methods / get stdio
1481
1452
  //#region @backend
1482
- HelpersCore.prototype.getStdio = function (options) {
1483
- var
1453
+ getStdio(options) {
1454
+ const {
1484
1455
  // @ts-ignore
1485
- output = options.output, silence = options.silence, stdio = options.stdio;
1456
+ output, silence, stdio,
1457
+ // pipeToParentProcerss = false,
1458
+ // inheritFromParentProcerss = false
1459
+ } = options;
1486
1460
  if (typeof stdio !== 'undefined') {
1487
1461
  return stdio;
1488
1462
  }
1489
- var resstdio = output
1463
+ let resstdio = output
1490
1464
  ? [0, 1, 2]
1491
1465
  : core_imports_2._.isBoolean(silence) && silence
1492
1466
  ? 'ignore'
@@ -1498,37 +1472,37 @@ var HelpersCore = /** @class */ (function (_super) {
1498
1472
  // stdio = ['inherit', 'inherit', 'inherit'] as any;
1499
1473
  // }
1500
1474
  return resstdio;
1501
- };
1475
+ }
1502
1476
  //#endregion
1503
1477
  //#endregion
1504
1478
  //#region methods / run sync in
1505
1479
  //#region @backend
1506
- HelpersCore.prototype.runSyncIn = function (command, options) {
1480
+ runSyncIn(command, options) {
1507
1481
  // @ts-ignore
1508
- var cwd = options.cwd, biggerBuffer = options.biggerBuffer;
1509
- var maxBuffer = biggerBuffer ? index_1.Helpers.bigMaxBuffer : undefined;
1510
- var stdio = index_1.Helpers.getStdio(options);
1482
+ const { cwd, biggerBuffer } = options;
1483
+ const maxBuffer = biggerBuffer ? index_1.Helpers.bigMaxBuffer : undefined;
1484
+ let stdio = index_1.Helpers.getStdio(options);
1511
1485
  index_1.Helpers.checkProcess(cwd, command);
1512
- return core_imports_1.child_process.execSync(command, { stdio: stdio, cwd: cwd, maxBuffer: maxBuffer });
1513
- };
1486
+ return core_imports_1.child_process.execSync(command, { stdio, cwd, maxBuffer });
1487
+ }
1514
1488
  //#endregion
1515
1489
  //#endregion
1516
1490
  //#region methods / run async in
1517
1491
  //#region @backend
1518
- HelpersCore.prototype.runAsyncIn = function (command, options) {
1492
+ runAsyncIn(command, options) {
1519
1493
  // @ts-ignore
1520
- var output = options.output, cwd = options.cwd, biggerBuffer = options.biggerBuffer, outputLineReplace = options.outputLineReplace, extractFromLine = options.extractFromLine, detach = options.detach;
1521
- var maxBuffer = biggerBuffer ? index_1.Helpers.bigMaxBuffer : undefined;
1522
- var stdio = index_1.Helpers.getStdio(options);
1494
+ const { output, cwd, biggerBuffer, outputLineReplace, extractFromLine, detach, } = options;
1495
+ const maxBuffer = biggerBuffer ? index_1.Helpers.bigMaxBuffer : undefined;
1496
+ let stdio = index_1.Helpers.getStdio(options);
1523
1497
  index_1.Helpers.checkProcess(cwd, command);
1524
- var proc;
1498
+ let proc;
1525
1499
  if (detach) {
1526
1500
  //#region detached
1527
- var cmd = core_imports_2._.first(command.split(' '));
1528
- var argsForCmd = command.split(' ').slice(1);
1529
- index_1.Helpers.log("cmd: \"".concat(cmd, "\", args: \"").concat(argsForCmd.join(' '), "\""));
1501
+ const cmd = core_imports_2._.first(command.split(' '));
1502
+ const argsForCmd = command.split(' ').slice(1);
1503
+ index_1.Helpers.log(`cmd: "${cmd}", args: "${argsForCmd.join(' ')}"`);
1530
1504
  if (process.platform === 'win32') {
1531
- proc = (0, core_imports_1.spawn)(cmd, argsForCmd, { cwd: cwd, detached: true });
1505
+ proc = (0, core_imports_1.spawn)(cmd, argsForCmd, { cwd, detached: true });
1532
1506
  // proc = child_process.spawn(cmd, argsForCmd, {
1533
1507
  // cwd,
1534
1508
  // detached: true,
@@ -1542,16 +1516,20 @@ var HelpersCore = /** @class */ (function (_super) {
1542
1516
  }
1543
1517
  else {
1544
1518
  // @ts-ignore
1545
- proc = core_imports_1.child_process.spawn(cmd, argsForCmd, { cwd: cwd, detached: true });
1519
+ proc = core_imports_1.child_process.spawn(cmd, argsForCmd, { cwd, detached: true });
1546
1520
  }
1547
- index_1.Helpers.log("\n\n DETACHED PROCESS IS WORKING ON PID: ".concat(proc.pid, "\n\n "));
1521
+ index_1.Helpers.log(`
1522
+
1523
+ DETACHED PROCESS IS WORKING ON PID: ${proc.pid}
1524
+
1525
+ `);
1548
1526
  // proc = child.exec(`${command} &`, { cwd, maxBuffer, });
1549
1527
  //#endregion
1550
1528
  }
1551
1529
  else {
1552
1530
  // Helpers.log(`Command to execture: ${command}`)
1553
- var env = tslib_1.__assign(tslib_1.__assign({}, process.env), { FORCE_COLOR: '1' });
1554
- proc = core_imports_1.child_process.exec(command, { cwd: cwd, maxBuffer: maxBuffer, env: env });
1531
+ const env = { ...process.env, FORCE_COLOR: '1' };
1532
+ proc = core_imports_1.child_process.exec(command, { cwd, maxBuffer, env });
1555
1533
  // if (global.globalSystemToolMode) {
1556
1534
  // proc.on('exit', (code) => {
1557
1535
  // Helpers.log('EXITING BIG PROCESS');
@@ -1565,14 +1543,13 @@ var HelpersCore = /** @class */ (function (_super) {
1565
1543
  }
1566
1544
  return index_1.Helpers.logProc(proc, detach ? true : output, detach ? void 0 : stdio, outputLineReplace, // @ts-ignore
1567
1545
  options.prefix, extractFromLine);
1568
- };
1546
+ }
1569
1547
  //#endregion
1570
1548
  //#endregion
1571
1549
  //#region methods / log process
1572
1550
  //#region @backend
1573
1551
  //#region log process
1574
- HelpersCore.prototype.logProc = function (proc, output, stdio, outputLineReplace, prefix, extractFromLine) {
1575
- if (output === void 0) { output = true; }
1552
+ logProc(proc, output = true, stdio, outputLineReplace, prefix, extractFromLine) {
1576
1553
  index_1.Helpers.processes.push(proc);
1577
1554
  if (stdio) {
1578
1555
  // @ts-ignore
@@ -1583,28 +1560,28 @@ var HelpersCore = /** @class */ (function (_super) {
1583
1560
  }
1584
1561
  if (output) {
1585
1562
  // @ts-ignore
1586
- proc.stdout.on('data', function (data) {
1563
+ proc.stdout.on('data', data => {
1587
1564
  // if (data?.toString().search('was unexpected at this time') !== -1) {
1588
1565
  // console.log('!!!COMMAND',command)
1589
1566
  // }
1590
1567
  process.stdout.write(index_1.Helpers.modifyLineByLine(data, outputLineReplace, prefix, extractFromLine));
1591
1568
  });
1592
1569
  // @ts-ignore
1593
- proc.stdout.on('error', function (data) {
1570
+ proc.stdout.on('error', data => {
1594
1571
  // if (data?.toString().search('was unexpected at this time') !== -1) {
1595
1572
  // console.log('!!!COMMAND',command)
1596
1573
  // }
1597
1574
  console.log(index_1.Helpers.modifyLineByLine(data, outputLineReplace, prefix, extractFromLine));
1598
1575
  });
1599
1576
  // @ts-ignore
1600
- proc.stderr.on('data', function (data) {
1577
+ proc.stderr.on('data', data => {
1601
1578
  // if (data?.toString().search('was unexpected at this time') !== -1) {
1602
1579
  // console.log('!!!COMMAND',command)
1603
1580
  // }
1604
1581
  process.stderr.write(index_1.Helpers.modifyLineByLine(data, outputLineReplace, prefix, extractFromLine));
1605
1582
  });
1606
1583
  // @ts-ignore
1607
- proc.stderr.on('error', function (data) {
1584
+ proc.stderr.on('error', data => {
1608
1585
  // if (data?.toString().search('was unexpected at this time') !== -1) {
1609
1586
  // console.log('!!!COMMAND',command)
1610
1587
  // }
@@ -1612,207 +1589,14 @@ var HelpersCore = /** @class */ (function (_super) {
1612
1589
  });
1613
1590
  }
1614
1591
  return proc;
1615
- };
1616
- //#endregion
1617
- HelpersCore.prototype.execute = function (command, cwd, options) {
1618
- return tslib_1.__awaiter(this, void 0, void 0, function () {
1619
- var _a, hideOutput, resolvePromiseMsg, outputLineReplace, prefix, extractFromLine, exitOnErrorCallback, askToTryAgainOnError, resolvePromiseMsgCallback, similarProcessKey, _b, stderResolvePromiseMsgCallback, stdoutResolvePromiseMsgCallback, childProcess, isResolved, handlProc, error_1;
1620
- var _this = this;
1621
- return tslib_1.__generator(this, function (_c) {
1622
- switch (_c.label) {
1623
- case 0:
1624
- _a = options || {}, hideOutput = _a.hideOutput, resolvePromiseMsg = _a.resolvePromiseMsg, outputLineReplace = _a.outputLineReplace, prefix = _a.prefix, extractFromLine = _a.extractFromLine, exitOnErrorCallback = _a.exitOnErrorCallback, askToTryAgainOnError = _a.askToTryAgainOnError, resolvePromiseMsgCallback = _a.resolvePromiseMsgCallback, similarProcessKey = _a.similarProcessKey;
1625
- command = index_1.Helpers._fixCommand(command);
1626
- _b = resolvePromiseMsgCallback || {}, stderResolvePromiseMsgCallback = _b.stderr, stdoutResolvePromiseMsgCallback = _b.stdout;
1627
- // let {
1628
- // stderMsgForPromiseResolve,
1629
- // stdoutMsgForPromiseResolve
1630
- // } = resolvePromiseMsg || {};
1631
- // processes.push(proc);
1632
- if (!resolvePromiseMsg) {
1633
- resolvePromiseMsg = {};
1634
- }
1635
- if (!hideOutput) {
1636
- hideOutput = {};
1637
- }
1638
- isResolved = false;
1639
- if (core_imports_2._.isString(resolvePromiseMsg.stdout)) {
1640
- resolvePromiseMsg.stdout = [resolvePromiseMsg.stdout];
1641
- }
1642
- if (core_imports_2._.isString(resolvePromiseMsg.stderr)) {
1643
- resolvePromiseMsg.stderr = [resolvePromiseMsg.stderr];
1644
- }
1645
- handlProc = function (proc) {
1646
- return new Promise(function (resolve, reject) {
1647
- // console.log(
1648
- // `[execute] Process started...`,
1649
- // (resolvePromiseMsg.stdout as string[]).map(c => `"${c}"`).join(','),
1650
- // );
1651
- //#region handle stdout data
1652
- proc.stdout.on('data', function (rawData) {
1653
- var data = (rawData === null || rawData === void 0 ? void 0 : rawData.toString()) || '';
1654
- data = index_1.Helpers.modifyLineByLine(data, // @ts-ignore
1655
- outputLineReplace, prefix, extractFromLine);
1656
- if (!hideOutput.stdout) {
1657
- process.stdout.write(data);
1658
- }
1659
- if (core_imports_2._.isArray(resolvePromiseMsg.stdout)) {
1660
- for (var index = 0; index < resolvePromiseMsg.stdout.length; index++) {
1661
- // console.log(`DATA STDOUT: ${chalk.gray(data)}`);
1662
- var resolveCompilationMessage = resolvePromiseMsg.stdout[index];
1663
- if (data.search(resolveCompilationMessage) !== -1) {
1664
- // Helpers.info(`[unitlOutputContains] AAA...`);
1665
- stdoutResolvePromiseMsgCallback &&
1666
- stdoutResolvePromiseMsgCallback();
1667
- if (!isResolved) {
1668
- isResolved = true;
1669
- resolve(void 0);
1670
- }
1671
- break;
1672
- }
1673
- }
1674
- }
1675
- // TODO NOT NEEDED
1676
- if (core_imports_2._.isArray(resolvePromiseMsg.stderr)) {
1677
- for (var index = 0; index < resolvePromiseMsg.stderr.length; index++) {
1678
- var rejectm = resolvePromiseMsg.stderr[index];
1679
- if (data.search(rejectm) !== -1) {
1680
- // Helpers.info(`[unitlOutputContains] Rejected move to next step...`);
1681
- stdoutResolvePromiseMsgCallback &&
1682
- stdoutResolvePromiseMsgCallback();
1683
- if (!isResolved) {
1684
- isResolved = true;
1685
- reject();
1686
- proc.kill('SIGINT');
1687
- }
1688
- break;
1689
- }
1690
- }
1691
- }
1692
- });
1693
- //#endregion
1694
- //#region handle exit process
1695
- proc.on('exit', function (code) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
1696
- var error_2;
1697
- return tslib_1.__generator(this, function (_a) {
1698
- switch (_a.label) {
1699
- case 0:
1700
- if (!hideOutput.acceptAllExitCodeAsSuccess) return [3 /*break*/, 1];
1701
- resolve(void 0);
1702
- return [3 /*break*/, 9];
1703
- case 1:
1704
- if (!(code !== 0)) return [3 /*break*/, 8];
1705
- if (!core_imports_2._.isFunction(exitOnErrorCallback)) return [3 /*break*/, 6];
1706
- _a.label = 2;
1707
- case 2:
1708
- _a.trys.push([2, 4, , 5]);
1709
- return [4 /*yield*/, this.runSyncOrAsync({
1710
- functionFn: exitOnErrorCallback,
1711
- arrayOfParams: [code],
1712
- })];
1713
- case 3:
1714
- _a.sent();
1715
- reject("Command failed with code=".concat(code));
1716
- return [3 /*break*/, 5];
1717
- case 4:
1718
- error_2 = _a.sent();
1719
- reject(error_2);
1720
- return [3 /*break*/, 5];
1721
- case 5: return [3 /*break*/, 7];
1722
- case 6:
1723
- reject("Command failed with code=".concat(code));
1724
- _a.label = 7;
1725
- case 7: return [3 /*break*/, 9];
1726
- case 8:
1727
- resolve(void 0);
1728
- _a.label = 9;
1729
- case 9: return [2 /*return*/];
1730
- }
1731
- });
1732
- }); });
1733
- //#endregion
1734
- //#region handle stdout error
1735
- proc.stdout.on('error', function (rawData) {
1736
- var data = (rawData === null || rawData === void 0 ? void 0 : rawData.toString()) || '';
1737
- data = index_1.Helpers.modifyLineByLine(data, // @ts-ignore
1738
- outputLineReplace, prefix, extractFromLine);
1739
- if (!hideOutput.stdout) {
1740
- process.stdout.write(JSON.stringify(data));
1741
- }
1742
- // console.log(data);
1743
- });
1744
- //#endregion
1745
- //#region handle stder data
1746
- proc.stderr.on('data', function (rawData) {
1747
- var data = (rawData === null || rawData === void 0 ? void 0 : rawData.toString()) || '';
1748
- data = index_1.Helpers.modifyLineByLine(data, // @ts-ignore
1749
- outputLineReplace, prefix, extractFromLine);
1750
- if (!hideOutput.stderr) {
1751
- process.stderr.write(data);
1752
- }
1753
- if (core_imports_2._.isArray(resolvePromiseMsg.stderr)) {
1754
- // @ts-ignore
1755
- for (var index = 0; index < resolvePromiseMsg.stderr.length; index++) {
1756
- // @ts-ignore
1757
- var rejectm = resolvePromiseMsg.stderr[index];
1758
- if (data.search(rejectm) !== -1) {
1759
- // Helpers.info(`[unitlOutputContains] Rejected move to next step...`);
1760
- stderResolvePromiseMsgCallback &&
1761
- stderResolvePromiseMsgCallback();
1762
- if (!isResolved) {
1763
- isResolved = true;
1764
- reject();
1765
- proc.kill('SIGINT');
1766
- }
1767
- break;
1768
- }
1769
- }
1770
- }
1771
- });
1772
- //#endregion
1773
- //#region handle stder error
1774
- proc.stderr.on('error', function (rawData) {
1775
- var data = (rawData === null || rawData === void 0 ? void 0 : rawData.toString()) || '';
1776
- data = index_1.Helpers.modifyLineByLine(data, // @ts-ignore
1777
- outputLineReplace, prefix, extractFromLine);
1778
- // @ts-ignore
1779
- if (!hideOutput.stderr) {
1780
- process.stderr.write(JSON.stringify(data));
1781
- }
1782
- // console.log(data);
1783
- });
1784
- //#endregion
1785
- });
1786
- };
1787
- _c.label = 1;
1788
- case 1:
1789
- if (!true) return [3 /*break*/, 9];
1790
- childProcess = core_imports_1.child_process.exec(command, { cwd: cwd });
1791
- _c.label = 2;
1792
- case 2:
1793
- _c.trys.push([2, 4, , 8]);
1794
- return [4 /*yield*/, handlProc(childProcess)];
1795
- case 3:
1796
- _c.sent();
1797
- return [3 /*break*/, 9];
1798
- case 4:
1799
- error_1 = _c.sent();
1800
- index_1.Helpers.error("Command failed:\n\n".concat(command, "\n\nin location: ").concat(cwd, "\n\n "), true, true);
1801
- if (!askToTryAgainOnError) return [3 /*break*/, 6];
1802
- return [4 /*yield*/, index_1.Helpers.questionYesNo("Try again this command ?")];
1803
- case 5:
1804
- if (!(_c.sent())) {
1805
- throw error_1;
1806
- }
1807
- return [3 /*break*/, 7];
1808
- case 6: throw error_1;
1809
- case 7: return [3 /*break*/, 8];
1810
- case 8: return [3 /*break*/, 1];
1811
- case 9: return [2 /*return*/];
1812
- }
1813
- });
1814
- });
1815
- };
1592
+ }
1593
+ //#endregion
1594
+ /**
1595
+ * @deprecated use UtilsProcess.startAsync
1596
+ */
1597
+ async execute(command, cwd, options) {
1598
+ return utils_1.UtilsProcess.startAsync(command, cwd, options);
1599
+ }
1816
1600
  //#endregion
1817
1601
  //#endregion
1818
1602
  //#region methods / check process
@@ -1820,67 +1604,68 @@ var HelpersCore = /** @class */ (function (_super) {
1820
1604
  /**
1821
1605
  * @deprecated
1822
1606
  */
1823
- HelpersCore.prototype.checkProcess = function (dirPath, command) {
1607
+ checkProcess(dirPath, command) {
1824
1608
  if (!core_imports_1.fse.existsSync(dirPath)) {
1825
- index_1.Helpers.error("\nPath for process cwd doesn't exist: ".concat(dirPath, "\ncommand: ").concat(command, "\n"));
1609
+ index_1.Helpers.error(`
1610
+ Path for process cwd doesn't exist: ${dirPath}
1611
+ command: ${command}
1612
+ `);
1826
1613
  }
1827
1614
  if (!command) {
1828
- index_1.Helpers.error("Bad command: ".concat(command));
1615
+ index_1.Helpers.error(`Bad command: ${command}`);
1829
1616
  }
1830
- };
1617
+ }
1831
1618
  //#endregion
1832
1619
  //#endregion
1833
1620
  //#region methods / modify line by line
1834
1621
  //#region @backend
1835
- HelpersCore.prototype.modifyLineByLine = function (data, outputLineReplace, prefix, extractFromLine) {
1836
- var checkExtract = core_imports_2._.isArray(extractFromLine) && extractFromLine.length > 0;
1837
- var modifyOutput = core_imports_2._.isFunction(outputLineReplace);
1622
+ modifyLineByLine(data, outputLineReplace, prefix, extractFromLine) {
1623
+ const checkExtract = core_imports_2._.isArray(extractFromLine) && extractFromLine.length > 0;
1624
+ let modifyOutput = core_imports_2._.isFunction(outputLineReplace);
1838
1625
  if (modifyOutput && core_imports_2._.isString(data)) {
1839
1626
  data = data
1840
1627
  .split(/\r?\n/)
1841
- .map(function (line) {
1842
- return outputLineReplace(line);
1843
- })
1628
+ .map(line => outputLineReplace(line))
1844
1629
  .join('\n');
1845
1630
  }
1846
1631
  if (prefix && core_imports_2._.isString(data)) {
1847
1632
  return data
1848
1633
  .split('\n')
1849
- .map(function (singleLine) {
1634
+ .map(singleLine => {
1850
1635
  if (!singleLine ||
1851
1636
  singleLine.trim().length === 0 ||
1852
1637
  singleLine.trim() === '.') {
1853
1638
  return singleLine;
1854
1639
  }
1855
1640
  if (checkExtract) {
1856
- var sFuncs = extractFromLine.filter(function (f) { return core_imports_2._.isString(f); });
1857
- if (sFuncs.filter(function (f) { return singleLine.search(f) !== -1; })
1641
+ const sFuncs = extractFromLine.filter(f => core_imports_2._.isString(f));
1642
+ if (sFuncs.filter(f => singleLine.search(f) !== -1)
1858
1643
  .length === sFuncs.length) {
1859
- var fun = extractFromLine.find(function (f) { return core_imports_2._.isFunction(f); });
1644
+ const fun = extractFromLine.find(f => core_imports_2._.isFunction(f));
1860
1645
  if (fun) {
1861
- var s_1 = singleLine;
1862
- sFuncs.forEach(function (f) {
1863
- s_1 = s_1.replace(f, '');
1646
+ let s = singleLine;
1647
+ sFuncs.forEach(f => {
1648
+ s = s.replace(f, '');
1864
1649
  });
1865
- fun(s_1.trim());
1650
+ fun(s.trim());
1866
1651
  }
1867
1652
  }
1868
1653
  }
1869
- return "".concat(prefix, " ").concat(singleLine);
1654
+ return `${prefix} ${singleLine}`;
1870
1655
  })
1871
1656
  .join('\n');
1872
1657
  }
1873
1658
  return data;
1874
- };
1659
+ }
1875
1660
  //#endregion
1876
1661
  //#endregion
1877
1662
  //#region methods / is folder
1878
1663
  //#region @backend
1879
- HelpersCore.prototype.isFolder = function (pathToFileOrMaybeFolder) {
1664
+ isFolder(pathToFileOrMaybeFolder) {
1880
1665
  return !!(pathToFileOrMaybeFolder &&
1881
1666
  core_imports_1.fse.existsSync(pathToFileOrMaybeFolder) &&
1882
1667
  core_imports_1.fse.lstatSync(pathToFileOrMaybeFolder).isDirectory());
1883
- };
1668
+ }
1884
1669
  //#endregion
1885
1670
  //#endregion
1886
1671
  //#region methods / values
@@ -1888,10 +1673,10 @@ var HelpersCore = /** @class */ (function (_super) {
1888
1673
  * Quick fix for object values
1889
1674
  * @deprecated
1890
1675
  */
1891
- HelpersCore.prototype.values = function (obj) {
1676
+ values(obj) {
1892
1677
  if (core_imports_2._.isObject(obj) && !Array.isArray(obj)) {
1893
- var values = [];
1894
- for (var key in obj) {
1678
+ const values = [];
1679
+ for (const key in obj) {
1895
1680
  if (Object.prototype.hasOwnProperty.call(obj, key)) {
1896
1681
  // @ts-ignore
1897
1682
  values.push(obj[key]);
@@ -1900,61 +1685,46 @@ var HelpersCore = /** @class */ (function (_super) {
1900
1685
  return values;
1901
1686
  }
1902
1687
  return [];
1903
- };
1688
+ }
1904
1689
  //#endregion
1905
1690
  //#region methods / is file
1906
- //#region @backend
1907
1691
  /**
1908
1692
  * does not make sense
1909
1693
  * @deprecated
1910
1694
  */
1911
- HelpersCore.prototype.isFile = function (pathToFileOrMaybeFolder) {
1695
+ isFile(pathToFileOrMaybeFolder) {
1696
+ //#region @backendFunc
1912
1697
  return (pathToFileOrMaybeFolder &&
1913
1698
  core_imports_1.fse.existsSync(pathToFileOrMaybeFolder) &&
1914
1699
  !core_imports_1.fse.lstatSync(pathToFileOrMaybeFolder).isDirectory());
1915
- };
1916
- //#endregion
1700
+ //#endregion
1701
+ }
1917
1702
  //#endregion
1918
1703
  //#region methods / read file
1919
- //#region @backend
1920
- HelpersCore.prototype.tryReadFile = function (absoluteFilePath_1) {
1921
- return tslib_1.__awaiter(this, arguments, void 0, function (absoluteFilePath, // @ts-ignore
1922
- defaultValueWhenNotExists, notTrim) {
1923
- var fileContent, error_3;
1924
- if (defaultValueWhenNotExists === void 0) { defaultValueWhenNotExists = void 0; }
1925
- if (notTrim === void 0) { notTrim = false; }
1926
- return tslib_1.__generator(this, function (_a) {
1927
- switch (_a.label) {
1928
- case 0:
1929
- if (!(process.platform === 'win32')) return [3 /*break*/, 6];
1930
- _a.label = 1;
1931
- case 1:
1932
- if (!true) return [3 /*break*/, 6];
1933
- _a.label = 2;
1934
- case 2:
1935
- _a.trys.push([2, 3, , 5]);
1936
- fileContent = index_1.Helpers.readFile(absoluteFilePath, defaultValueWhenNotExists, notTrim);
1937
- return [2 /*return*/, fileContent];
1938
- case 3:
1939
- error_3 = _a.sent();
1940
- index_1.Helpers.error("Not able to read locked file: ".concat(absoluteFilePath), true, true);
1941
- return [4 /*yield*/, index_1.Helpers.wait(2)];
1942
- case 4:
1943
- _a.sent();
1944
- return [3 /*break*/, 5];
1945
- case 5: return [3 /*break*/, 1];
1946
- case 6: return [2 /*return*/, index_1.Helpers.readFile(absoluteFilePath, defaultValueWhenNotExists, notTrim)];
1704
+ async tryReadFile(absoluteFilePath, // @ts-ignore
1705
+ defaultValueWhenNotExists = void 0, notTrim = false) {
1706
+ //#region @backendFunc
1707
+ if (process.platform === 'win32') {
1708
+ while (true) {
1709
+ try {
1710
+ const fileContent = index_1.Helpers.readFile(absoluteFilePath, defaultValueWhenNotExists, notTrim);
1711
+ return fileContent;
1947
1712
  }
1948
- });
1949
- });
1950
- };
1713
+ catch (error) {
1714
+ index_1.Helpers.error(`Not able to read locked file: ${absoluteFilePath}`, true, true);
1715
+ await index_1.Helpers.wait(2);
1716
+ }
1717
+ }
1718
+ }
1719
+ return index_1.Helpers.readFile(absoluteFilePath, defaultValueWhenNotExists, notTrim);
1720
+ //#endregion
1721
+ }
1951
1722
  /**
1952
1723
  * wrapper for fs.readFileSync
1953
1724
  */
1954
- HelpersCore.prototype.readFile = function (absoluteFilePath, // @ts-ignore
1955
- defaultValueWhenNotExists, notTrim) {
1956
- if (defaultValueWhenNotExists === void 0) { defaultValueWhenNotExists = void 0; }
1957
- if (notTrim === void 0) { notTrim = false; }
1725
+ readFile(absoluteFilePath, // @ts-ignore
1726
+ defaultValueWhenNotExists = void 0, notTrim = false) {
1727
+ //#region @backendFunc
1958
1728
  if (core_imports_2._.isArray(absoluteFilePath)) {
1959
1729
  absoluteFilePath = core_imports_2.path.join.apply(this, absoluteFilePath);
1960
1730
  }
@@ -1968,28 +1738,26 @@ var HelpersCore = /** @class */ (function (_super) {
1968
1738
  if (notTrim) {
1969
1739
  return core_imports_1.fse
1970
1740
  .readFileSync(absoluteFilePath, {
1971
- encoding: encoding,
1741
+ encoding,
1972
1742
  })
1973
1743
  .toString();
1974
1744
  }
1975
1745
  return core_imports_1.fse
1976
1746
  .readFileSync(absoluteFilePath, {
1977
- encoding: encoding,
1747
+ encoding,
1978
1748
  })
1979
1749
  .toString()
1980
1750
  .trim();
1981
- };
1982
- //#endregion
1751
+ //#endregion
1752
+ }
1983
1753
  //#endregion
1984
1754
  //#region methods / read json
1985
- //#region @backend
1986
1755
  /**
1987
1756
  * read json from absolute path
1988
1757
  * @returns json object
1989
1758
  */
1990
- HelpersCore.prototype.readJson = function (absoluteFilePath, defaultValue, useJson5) {
1991
- if (defaultValue === void 0) { defaultValue = {}; }
1992
- if (useJson5 === void 0) { useJson5 = false; }
1759
+ readJson(absoluteFilePath, defaultValue = {}, useJson5 = false) {
1760
+ //#region @backendFunc
1993
1761
  if (core_imports_2._.isArray(absoluteFilePath)) {
1994
1762
  absoluteFilePath = core_imports_2.path.join.apply(this, absoluteFilePath);
1995
1763
  }
@@ -1998,8 +1766,8 @@ var HelpersCore = /** @class */ (function (_super) {
1998
1766
  return {};
1999
1767
  }
2000
1768
  try {
2001
- var fileContent = index_1.Helpers.readFile(absoluteFilePath);
2002
- var json = void 0;
1769
+ const fileContent = index_1.Helpers.readFile(absoluteFilePath);
1770
+ let json;
2003
1771
  // @ts-ignore
2004
1772
  json = index_1.Helpers.parse(fileContent, useJson5 || absoluteFilePath.endsWith('.json5'));
2005
1773
  return json;
@@ -2007,16 +1775,18 @@ var HelpersCore = /** @class */ (function (_super) {
2007
1775
  catch (error) {
2008
1776
  return defaultValue;
2009
1777
  }
2010
- };
2011
- HelpersCore.prototype.readJson5 = function (absoluteFilePath, defaultValue) {
2012
- if (defaultValue === void 0) { defaultValue = {}; }
1778
+ //#endregion
1779
+ }
1780
+ readJson5(absoluteFilePath, defaultValue = {}) {
1781
+ //#region @backendFunc
2013
1782
  return index_1.Helpers.readJson(absoluteFilePath, defaultValue, true);
2014
- };
2015
- HelpersCore.prototype.readJsonC = function (absoluteFilePath, defaultValue) {
2016
- if (defaultValue === void 0) { defaultValue = {}; }
1783
+ //#endregion
1784
+ }
1785
+ readJsonC(absoluteFilePath, defaultValue = {}) {
1786
+ //#region @backendFunc
2017
1787
  return this.readJson5(absoluteFilePath, defaultValue);
2018
- };
2019
- //#endregion
1788
+ //#endregion
1789
+ }
2020
1790
  //#endregion
2021
1791
  //#region methods / parse
2022
1792
  //#region @backend
@@ -2024,60 +1794,48 @@ var HelpersCore = /** @class */ (function (_super) {
2024
1794
  * parse json from string
2025
1795
  * @returns parse json object
2026
1796
  */
2027
- HelpersCore.prototype.parse = function (jsonInstring, useJson5) {
2028
- if (useJson5 === void 0) { useJson5 = false; }
1797
+ parse(jsonInstring, useJson5 = false) {
2029
1798
  if (!core_imports_2._.isString(jsonInstring)) {
2030
1799
  index_1.Helpers.log(jsonInstring);
2031
- index_1.Helpers.warn("[taon-core] Trying to parse no a string...");
1800
+ index_1.Helpers.warn(`[taon-core] Trying to parse no a string...`);
2032
1801
  return jsonInstring;
2033
1802
  }
2034
1803
  return (useJson5 ? core_imports_1.json5.parse(jsonInstring) : JSON.parse(jsonInstring));
2035
- };
1804
+ }
2036
1805
  //#endregion
2037
1806
  //#endregion
2038
1807
  //#region methods / compilation wrapper
2039
1808
  //#region @backend
2040
- HelpersCore.prototype.compilationWrapper = function (fn_1) {
2041
- return tslib_1.__awaiter(this, arguments, void 0, function (fn, taskName, executionType) {
2042
- // global?.spinner?.start();
2043
- function currentDate() {
2044
- return "[".concat((0, core_imports_1.dateformat)(new Date(), 'HH:MM:ss'), "]");
2045
- }
2046
- if (taskName === void 0) { taskName = 'Task'; }
2047
- if (executionType === void 0) { executionType = 'Compilation of'; }
2048
- return tslib_1.__generator(this, function (_a) {
2049
- switch (_a.label) {
2050
- case 0:
2051
- if (!fn || !core_imports_2._.isFunction(fn)) {
2052
- index_1.Helpers.error("".concat(executionType, " wrapper: \"").concat(fn, "\" is not a function."));
2053
- process.exit(1);
2054
- }
2055
- index_1.Helpers.log("".concat(currentDate(), " ").concat(executionType, " \"").concat(taskName, "\" Started.."));
2056
- return [4 /*yield*/, index_1.Helpers.runSyncOrAsync({ functionFn: fn })];
2057
- case 1:
2058
- _a.sent();
2059
- index_1.Helpers.log("".concat(currentDate(), " ").concat(executionType, " \"").concat(taskName, "\" Done\u2713"));
2060
- return [2 /*return*/];
2061
- }
2062
- });
2063
- });
2064
- };
1809
+ async compilationWrapper(fn, taskName = 'Task', executionType = 'Compilation of') {
1810
+ // global?.spinner?.start();
1811
+ function currentDate() {
1812
+ return `[${(0, core_imports_1.dateformat)(new Date(), 'HH:MM:ss')}]`;
1813
+ }
1814
+ if (!fn || !core_imports_2._.isFunction(fn)) {
1815
+ index_1.Helpers.error(`${executionType} wrapper: "${fn}" is not a function.`);
1816
+ process.exit(1);
1817
+ }
1818
+ index_1.Helpers.log(`${currentDate()} ${executionType} "${taskName}" Started..`);
1819
+ await index_1.Helpers.runSyncOrAsync({ functionFn: fn });
1820
+ index_1.Helpers.log(`${currentDate()} ${executionType} "${taskName}" Done\u2713`);
1821
+ // global?.spinner?.stop();
1822
+ }
2065
1823
  //#endregion
2066
1824
  //#endregion
2067
1825
  //#region methods / replace in line
2068
- HelpersCore.prototype.replaceLinesInFile = function (absoluteFilePath, lineReplaceFn) {
1826
+ replaceLinesInFile(absoluteFilePath, lineReplaceFn) {
2069
1827
  //#region @backend
2070
- var file = index_1.Helpers.readFile(absoluteFilePath) || '';
1828
+ const file = index_1.Helpers.readFile(absoluteFilePath) || '';
2071
1829
  index_1.Helpers.writeFile(absoluteFilePath, file.split('\n').map(lineReplaceFn).join('\n'));
2072
1830
  //#endregion
2073
- };
1831
+ }
2074
1832
  //#endregion
2075
1833
  //#region methods / write file
2076
1834
  //#region @backend
2077
1835
  /**
2078
1836
  * wrapper for fs.writeFileSync
2079
1837
  */
2080
- HelpersCore.prototype.writeFile = function (absoluteFilePath, input,
1838
+ writeFile(absoluteFilePath, input,
2081
1839
  //#endregion
2082
1840
  options) {
2083
1841
  if (core_imports_2._.isArray(absoluteFilePath)) {
@@ -2087,7 +1845,7 @@ var HelpersCore = /** @class */ (function (_super) {
2087
1845
  // Helpers.info(`[taon-core] writeFile: ${absoluteFilePath}`);
2088
1846
  // debugger
2089
1847
  if (index_1.Helpers.isExistedSymlink(absoluteFilePath)) {
2090
- var beforePath = absoluteFilePath;
1848
+ const beforePath = absoluteFilePath;
2091
1849
  absoluteFilePath = core_imports_1.fse.realpathSync(absoluteFilePath);
2092
1850
  // Helpers.logWarn(
2093
1851
  // `[taon-core] WRITTING JSON into real path:
@@ -2097,8 +1855,8 @@ var HelpersCore = /** @class */ (function (_super) {
2097
1855
  // forceTrace,
2098
1856
  // );
2099
1857
  }
2100
- var _a = options || {}, preventParentFile = _a.preventParentFile, overrideSameFile = _a.overrideSameFile;
2101
- var dontWriteSameFile = !overrideSameFile;
1858
+ const { preventParentFile, overrideSameFile } = options || {};
1859
+ const dontWriteSameFile = !overrideSameFile;
2102
1860
  if (preventParentFile) {
2103
1861
  if (index_1.Helpers.isFile(core_imports_2.path.dirname(absoluteFilePath)) &&
2104
1862
  core_imports_1.fse.existsSync(core_imports_2.path.dirname(absoluteFilePath))) {
@@ -2107,11 +1865,16 @@ var HelpersCore = /** @class */ (function (_super) {
2107
1865
  }
2108
1866
  if (core_imports_1.fse.existsSync(absoluteFilePath) &&
2109
1867
  core_imports_1.fse.lstatSync(absoluteFilePath).isDirectory()) {
2110
- index_1.Helpers.warn("[taon-core] Trying to write file content into directory: ".concat(absoluteFilePath));
1868
+ index_1.Helpers.warn(`[taon-core] Trying to write file content into directory: ${absoluteFilePath}`);
2111
1869
  return false;
2112
1870
  }
2113
1871
  if (!core_imports_1.fse.existsSync(core_imports_2.path.dirname(absoluteFilePath))) {
2114
- index_1.Helpers.mkdirp(core_imports_2.path.dirname(absoluteFilePath));
1872
+ try {
1873
+ index_1.Helpers.mkdirp(core_imports_2.path.dirname(absoluteFilePath));
1874
+ }
1875
+ catch (error) {
1876
+ index_1.Helpers.error(`Not able to create directory: ${core_imports_2.path.dirname(absoluteFilePath)}`);
1877
+ }
2115
1878
  }
2116
1879
  if (index_1.Helpers.isBuffer(input)) {
2117
1880
  core_imports_1.fse.writeFileSync(absoluteFilePath, input);
@@ -2125,7 +1888,7 @@ var HelpersCore = /** @class */ (function (_super) {
2125
1888
  }
2126
1889
  if (dontWriteSameFile) {
2127
1890
  if (core_imports_1.fse.existsSync(absoluteFilePath)) {
2128
- var existedInput = index_1.Helpers.readFile(absoluteFilePath);
1891
+ const existedInput = index_1.Helpers.readFile(absoluteFilePath);
2129
1892
  if (input === existedInput) {
2130
1893
  // Helpers.log(`[helpers][writeFile] not writing same file (good thing): ${absoluteFilePath}`);
2131
1894
  return false;
@@ -2133,10 +1896,10 @@ var HelpersCore = /** @class */ (function (_super) {
2133
1896
  }
2134
1897
  }
2135
1898
  core_imports_1.fse.writeFileSync(absoluteFilePath, input, {
2136
- encoding: encoding,
1899
+ encoding,
2137
1900
  });
2138
1901
  return true;
2139
- };
1902
+ }
2140
1903
  //#endregion
2141
1904
  //#endregion
2142
1905
  //#region methods / write json
@@ -2144,12 +1907,12 @@ var HelpersCore = /** @class */ (function (_super) {
2144
1907
  /**
2145
1908
  * wrapper for fs.writeFileSync
2146
1909
  */
2147
- HelpersCore.prototype.writeJson = function (absoluteFilePath, input, optoins) {
1910
+ writeJson(absoluteFilePath, input, optoins) {
2148
1911
  if (core_imports_2._.isArray(absoluteFilePath)) {
2149
1912
  absoluteFilePath = core_imports_2.path.join.apply(this, absoluteFilePath);
2150
1913
  }
2151
1914
  absoluteFilePath = absoluteFilePath;
2152
- var _a = optoins || {}, preventParentFile = _a.preventParentFile, writeJson5 = _a.writeJson5;
1915
+ const { preventParentFile, writeJson5 } = optoins || {};
2153
1916
  if (preventParentFile) {
2154
1917
  if (index_1.Helpers.isFile(core_imports_2.path.dirname(absoluteFilePath)) &&
2155
1918
  core_imports_1.fse.existsSync(core_imports_2.path.dirname(absoluteFilePath))) {
@@ -2160,13 +1923,14 @@ var HelpersCore = /** @class */ (function (_super) {
2160
1923
  index_1.Helpers.mkdirp(core_imports_2.path.dirname(absoluteFilePath));
2161
1924
  }
2162
1925
  if (writeJson5) {
2163
- var existedContent = index_1.Helpers.readFile(absoluteFilePath) || '{}';
1926
+ const existedContent = index_1.Helpers.readFile(absoluteFilePath) || '{}';
2164
1927
  try {
2165
1928
  var writer = json5Write.load(existedContent);
2166
1929
  }
2167
1930
  catch (error) {
2168
- console.error(error === null || error === void 0 ? void 0 : error.message);
2169
- index_1.Helpers.error("Pleas fix your jsonc file (json with comments) in\n ".concat(absoluteFilePath), false, true);
1931
+ console.error(error?.message);
1932
+ index_1.Helpers.error(`Pleas fix your jsonc file (json with comments) in
1933
+ ${absoluteFilePath}`, false, true);
2170
1934
  }
2171
1935
  writer.write(input);
2172
1936
  index_1.Helpers.writeFile(absoluteFilePath, this.removeEmptyLineFromString(writer.toSource({
@@ -2177,18 +1941,18 @@ var HelpersCore = /** @class */ (function (_super) {
2177
1941
  }
2178
1942
  else {
2179
1943
  core_imports_1.fse.writeJSONSync(absoluteFilePath, input, {
2180
- encoding: encoding,
1944
+ encoding,
2181
1945
  spaces: 2,
2182
1946
  });
2183
1947
  }
2184
1948
  return true;
2185
- };
2186
- HelpersCore.prototype.writeJson5 = function (absoluteFilePath, input) {
1949
+ }
1950
+ writeJson5(absoluteFilePath, input) {
2187
1951
  return index_1.Helpers.writeJson(absoluteFilePath, input, { writeJson5: true });
2188
- };
2189
- HelpersCore.prototype.writeJsonC = function (absoluteFilePath, input) {
1952
+ }
1953
+ writeJsonC(absoluteFilePath, input) {
2190
1954
  return this.writeJson5(absoluteFilePath, input);
2191
- };
1955
+ }
2192
1956
  //#endregion
2193
1957
  //#endregion
2194
1958
  //#region methods / folders from
@@ -2197,51 +1961,40 @@ var HelpersCore = /** @class */ (function (_super) {
2197
1961
  * return absolute paths for folders inside folders
2198
1962
  * @returns absoulte pathes to folders from path
2199
1963
  */
2200
- HelpersCore.prototype.foldersFrom = function (pathToFolder, options) {
1964
+ foldersFrom(pathToFolder, options) {
2201
1965
  if (core_imports_2._.isArray(pathToFolder)) {
2202
1966
  pathToFolder = (0, core_imports_2.crossPlatformPath)(pathToFolder);
2203
1967
  }
2204
1968
  if (!index_1.Helpers.exists(pathToFolder)) {
2205
1969
  return [];
2206
1970
  }
2207
- var recursive = (options || {}).recursive;
2208
- var directories = [];
1971
+ const { recursive } = options || {};
1972
+ let directories = [];
2209
1973
  // Helper function to read a directory
2210
- var readDirectory = function (folderPath) {
2211
- var e_3, _a;
1974
+ const readDirectory = (folderPath) => {
2212
1975
  try {
2213
- var files = core_imports_1.fse.readdirSync(folderPath, { withFileTypes: true });
2214
- try {
2215
- for (var files_1 = tslib_1.__values(files), files_1_1 = files_1.next(); !files_1_1.done; files_1_1 = files_1.next()) {
2216
- var file = files_1_1.value;
2217
- if (file.isDirectory() &&
2218
- !index_1.Helpers.isSymlinkFileExitedOrUnexisted([folderPath, file.name])) {
2219
- var dirPath = (0, core_imports_2.crossPlatformPath)([folderPath, file.name]);
2220
- // console.log('dirPath', dirPath)
2221
- directories.push(dirPath);
2222
- // If recursive, read the directory found
2223
- if (recursive) {
2224
- readDirectory(dirPath);
2225
- }
1976
+ const files = core_imports_1.fse.readdirSync(folderPath, { withFileTypes: true });
1977
+ for (const file of files) {
1978
+ if (file.isDirectory() &&
1979
+ !index_1.Helpers.isSymlinkFileExitedOrUnexisted([folderPath, file.name])) {
1980
+ const dirPath = (0, core_imports_2.crossPlatformPath)([folderPath, file.name]);
1981
+ // console.log('dirPath', dirPath)
1982
+ directories.push(dirPath);
1983
+ // If recursive, read the directory found
1984
+ if (recursive) {
1985
+ readDirectory(dirPath);
2226
1986
  }
2227
1987
  }
2228
1988
  }
2229
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
2230
- finally {
2231
- try {
2232
- if (files_1_1 && !files_1_1.done && (_a = files_1.return)) _a.call(files_1);
2233
- }
2234
- finally { if (e_3) throw e_3.error; }
2235
- }
2236
1989
  }
2237
1990
  catch (err) {
2238
- index_1.Helpers.error("Error reading directory ".concat(folderPath, ": ").concat(err));
1991
+ index_1.Helpers.error(`Error reading directory ${folderPath}: ${err}`);
2239
1992
  }
2240
1993
  };
2241
1994
  // Start reading from the initial folder
2242
1995
  readDirectory(pathToFolder);
2243
1996
  return directories;
2244
- };
1997
+ }
2245
1998
  //#endregion
2246
1999
  //#endregion
2247
2000
  //#region methods / links from
@@ -2249,21 +2002,20 @@ var HelpersCore = /** @class */ (function (_super) {
2249
2002
  /**
2250
2003
  * @returns absolute pathes to links from path
2251
2004
  */
2252
- HelpersCore.prototype.linksToFoldersFrom = function (pathToFolder, outputRealPath) {
2253
- if (outputRealPath === void 0) { outputRealPath = false; }
2005
+ linksToFoldersFrom(pathToFolder, outputRealPath = false) {
2254
2006
  if (core_imports_2._.isArray(pathToFolder)) {
2255
- pathToFolder = core_imports_2.path.join.apply(core_imports_2.path, tslib_1.__spreadArray([], tslib_1.__read(pathToFolder), false));
2007
+ pathToFolder = core_imports_2.path.join(...pathToFolder);
2256
2008
  }
2257
2009
  if (!index_1.Helpers.exists(pathToFolder)) {
2258
2010
  return [];
2259
2011
  }
2260
2012
  return (core_imports_1.fse
2261
2013
  .readdirSync(pathToFolder)
2262
- .map(function (f) { return core_imports_2.path.join(pathToFolder, f); })
2263
- .filter(function (f) { return core_imports_1.fse.existsSync(f) && core_imports_1.fse.lstatSync(f).isSymbolicLink(); })
2264
- .map(function (f) {
2265
- var realPath = core_imports_1.fse.realpathSync(f);
2266
- var isFolder = index_1.Helpers.isFolder(realPath);
2014
+ .map(f => core_imports_2.path.join(pathToFolder, f))
2015
+ .filter(f => core_imports_1.fse.existsSync(f) && core_imports_1.fse.lstatSync(f).isSymbolicLink())
2016
+ .map(f => {
2017
+ const realPath = core_imports_1.fse.realpathSync(f);
2018
+ const isFolder = index_1.Helpers.isFolder(realPath);
2267
2019
  if (isFolder) {
2268
2020
  if (outputRealPath) {
2269
2021
  return realPath;
@@ -2273,10 +2025,10 @@ var HelpersCore = /** @class */ (function (_super) {
2273
2025
  }
2274
2026
  }
2275
2027
  })
2276
- .filter(function (f) { return !!f; })
2028
+ .filter(f => !!f)
2277
2029
  // @ts-ignore
2278
- .map(function (f) { return (0, core_imports_2.crossPlatformPath)(f); }));
2279
- };
2030
+ .map(f => (0, core_imports_2.crossPlatformPath)(f)));
2031
+ }
2280
2032
  //#endregion
2281
2033
  //#endregion
2282
2034
  //#region methods / links to folders from path
@@ -2284,30 +2036,30 @@ var HelpersCore = /** @class */ (function (_super) {
2284
2036
  /**
2285
2037
  * @returns absolute paths for folders inside folders
2286
2038
  */
2287
- HelpersCore.prototype.linksToFolderFrom = function (pathToFolder) {
2039
+ linksToFolderFrom(pathToFolder) {
2288
2040
  // options = (options || {}) as any;
2289
2041
  // if (_.isUndefined(options.linksOnlyTo)) {
2290
2042
  // options.linksOnlyTo = 'both';
2291
2043
  // }
2292
2044
  if (core_imports_2._.isArray(pathToFolder)) {
2293
- pathToFolder = core_imports_2.path.join.apply(core_imports_2.path, tslib_1.__spreadArray([], tslib_1.__read(pathToFolder), false));
2045
+ pathToFolder = core_imports_2.path.join(...pathToFolder);
2294
2046
  }
2295
2047
  if (!index_1.Helpers.exists(pathToFolder)) {
2296
2048
  return [];
2297
2049
  }
2298
2050
  return core_imports_1.fse
2299
2051
  .readdirSync(pathToFolder)
2300
- .map(function (f) { return core_imports_2.path.join(pathToFolder, f); })
2301
- .filter(function (f) {
2302
- var res = false;
2052
+ .map(f => core_imports_2.path.join(pathToFolder, f))
2053
+ .filter(f => {
2054
+ let res = false;
2303
2055
  if (index_1.Helpers.isExistedSymlink(f)) {
2304
- var realPath = core_imports_1.fse.realpathSync(f);
2056
+ const realPath = core_imports_1.fse.realpathSync(f);
2305
2057
  return index_1.Helpers.isFolder(realPath);
2306
2058
  }
2307
2059
  return res;
2308
2060
  })
2309
- .map(function (f) { return (0, core_imports_2.crossPlatformPath)(f); });
2310
- };
2061
+ .map(f => (0, core_imports_2.crossPlatformPath)(f));
2062
+ }
2311
2063
  //#endregion
2312
2064
  //#endregion
2313
2065
  //#region methods / files from
@@ -2315,78 +2067,77 @@ var HelpersCore = /** @class */ (function (_super) {
2315
2067
  /**
2316
2068
  * return absolute paths for folders inside folders
2317
2069
  */
2318
- HelpersCore.prototype.filesFrom = function (pathToFolder, recrusive, incudeUnexistedLinks) {
2319
- var _this = this;
2320
- if (recrusive === void 0) { recrusive = false; }
2321
- if (incudeUnexistedLinks === void 0) { incudeUnexistedLinks = false; }
2070
+ filesFrom(pathToFolder, recrusive = false, incudeUnexistedLinks = false) {
2322
2071
  if (core_imports_2._.isArray(pathToFolder)) {
2323
- pathToFolder = core_imports_2.path.join.apply(core_imports_2.path, tslib_1.__spreadArray([], tslib_1.__read(pathToFolder), false));
2072
+ pathToFolder = core_imports_2.path.join(...pathToFolder);
2324
2073
  }
2325
2074
  if (!index_1.Helpers.exists(pathToFolder)) {
2326
2075
  return [];
2327
2076
  }
2328
2077
  if (recrusive && incudeUnexistedLinks) {
2329
- return core_imports_1.glob.sync("".concat(pathToFolder, "/**/*.*"));
2078
+ return core_imports_1.glob.sync(`${pathToFolder}/**/*.*`);
2330
2079
  }
2331
2080
  if (recrusive) {
2332
- var all = core_imports_1.fse
2081
+ const all = core_imports_1.fse
2333
2082
  .readdirSync(pathToFolder)
2334
- .map(function (f) { return (0, core_imports_2.crossPlatformPath)([pathToFolder, f]); });
2335
- var folders_1 = [];
2336
- var files = all.filter(function (f) {
2083
+ .map(f => (0, core_imports_2.crossPlatformPath)([pathToFolder, f]));
2084
+ const folders = [];
2085
+ const files = all.filter(f => {
2337
2086
  if (core_imports_1.fse.lstatSync(f).isDirectory()) {
2338
- folders_1.push(f);
2087
+ folders.push(f);
2339
2088
  return false;
2340
2089
  }
2341
2090
  return true;
2342
2091
  });
2343
- return tslib_1.__spreadArray(tslib_1.__spreadArray([], tslib_1.__read(files), false), tslib_1.__read(folders_1
2344
- .map(function (f) { return _this.filesFrom(f, recrusive); })
2345
- .reduce(function (a, b) {
2346
- return a.concat(b);
2347
- }, [])), false).map(function (f) { return (0, core_imports_2.crossPlatformPath)(f); });
2092
+ return [
2093
+ ...files,
2094
+ ...folders
2095
+ .map(f => this.filesFrom(f, recrusive))
2096
+ .reduce((a, b) => {
2097
+ return a.concat(b);
2098
+ }, []),
2099
+ ].map(f => (0, core_imports_2.crossPlatformPath)(f));
2348
2100
  }
2349
2101
  return core_imports_1.fse
2350
2102
  .readdirSync(pathToFolder)
2351
- .map(function (f) { return (0, core_imports_2.crossPlatformPath)(core_imports_2.path.join(pathToFolder, f)); })
2352
- .filter(function (f) {
2103
+ .map(f => (0, core_imports_2.crossPlatformPath)(core_imports_2.path.join(pathToFolder, f)))
2104
+ .filter(f => {
2353
2105
  return !core_imports_1.fse.lstatSync(f).isDirectory();
2354
2106
  });
2355
- };
2107
+ }
2356
2108
  //#endregion
2357
2109
  //#endregion
2358
2110
  //#region methods / open folder in file explorer
2359
2111
  //#region @backend
2360
- HelpersCore.prototype.openFolderInFileExploer = function (folderPath) {
2112
+ openFolderInFileExploer(folderPath) {
2361
2113
  if (process.platform === 'win32') {
2362
2114
  folderPath = (0, core_imports_1.win32Path)(folderPath);
2363
2115
  }
2364
2116
  try {
2365
- index_1.Helpers.info("Opening path.. \"".concat(folderPath, "\""));
2117
+ index_1.Helpers.info(`Opening path.. "${folderPath}"`);
2366
2118
  if (process.platform === 'win32') {
2367
- index_1.Helpers.run("explorer .", { cwd: folderPath }).sync();
2119
+ index_1.Helpers.run(`explorer .`, { cwd: folderPath }).sync();
2368
2120
  return;
2369
2121
  }
2370
2122
  if (process.platform === 'darwin') {
2371
- index_1.Helpers.run("open .", { cwd: folderPath }).sync();
2123
+ index_1.Helpers.run(`open .`, { cwd: folderPath }).sync();
2372
2124
  return;
2373
2125
  }
2374
- index_1.Helpers.run("xdg-open .", { cwd: folderPath }).sync();
2126
+ index_1.Helpers.run(`xdg-open .`, { cwd: folderPath }).sync();
2375
2127
  }
2376
2128
  catch (error) {
2377
- index_1.Helpers.warn("Not able to open in file explorer: \"".concat(folderPath, "\""), false);
2129
+ index_1.Helpers.warn(`Not able to open in file explorer: "${folderPath}"`, false);
2378
2130
  }
2379
- };
2131
+ }
2380
2132
  //#endregion
2381
2133
  //#endregion
2382
2134
  //#region methods / hide node warnings
2383
- HelpersCore.prototype.hideNodeWarnings = function () {
2135
+ hideNodeWarnings() {
2384
2136
  //#region @backend
2385
- var process = require('process');
2137
+ const process = require('process');
2386
2138
  process.removeAllListeners('warning');
2387
2139
  //#endregion
2388
- };
2389
- return HelpersCore;
2390
- }(helpers_messages_1.HelpersMessages));
2140
+ }
2141
+ }
2391
2142
  exports.HelpersCore = HelpersCore;
2392
2143
  //# sourceMappingURL=helpers.js.map