tnp-core 18.0.46 → 18.0.49

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 (104) hide show
  1. package/README.md +20 -20
  2. package/assets/shared/shared_folder_info.txt +1 -1
  3. package/browser/README.md +24 -24
  4. package/browser/esm2022/lib/core-imports.mjs +65 -9
  5. package/browser/esm2022/lib/core-models.mjs +61 -9
  6. package/browser/esm2022/lib/helpers-messages.mjs +9 -4
  7. package/browser/esm2022/lib/helpers.mjs +164 -373
  8. package/browser/esm2022/lib/utils.mjs +769 -190
  9. package/browser/fesm2022/tnp-core.mjs +1548 -1062
  10. package/browser/fesm2022/tnp-core.mjs.map +1 -1
  11. package/browser/lib/core-imports.d.ts +41 -1
  12. package/browser/lib/core-models.d.ts +68 -38
  13. package/browser/lib/helpers-messages.d.ts +6 -3
  14. package/browser/lib/helpers.d.ts +22 -0
  15. package/browser/lib/utils.d.ts +77 -13
  16. package/cli.backend.d.ts +1 -0
  17. package/cli.backend.js +15 -2
  18. package/cli.backend.js.map +1 -1
  19. package/client/README.md +24 -24
  20. package/client/esm2022/lib/core-imports.mjs +65 -9
  21. package/client/esm2022/lib/core-models.mjs +61 -9
  22. package/client/esm2022/lib/helpers-messages.mjs +9 -4
  23. package/client/esm2022/lib/helpers.mjs +164 -373
  24. package/client/esm2022/lib/utils.mjs +769 -190
  25. package/client/fesm2022/tnp-core.mjs +1548 -1062
  26. package/client/fesm2022/tnp-core.mjs.map +1 -1
  27. package/client/lib/core-imports.d.ts +41 -1
  28. package/client/lib/core-models.d.ts +68 -38
  29. package/client/lib/helpers-messages.d.ts +6 -3
  30. package/client/lib/helpers.d.ts +22 -0
  31. package/client/lib/utils.d.ts +77 -13
  32. package/index.js +15 -2
  33. package/index.js.map +1 -1
  34. package/lib/build-info._auto-generated_.js.map +1 -1
  35. package/lib/command-exists.js +20 -20
  36. package/lib/command-exists.js.map +1 -1
  37. package/lib/core-cli.js +49 -66
  38. package/lib/core-cli.js.map +1 -1
  39. package/lib/core-config.js.map +1 -1
  40. package/lib/core-imports.d.ts +41 -25
  41. package/lib/core-imports.js +202 -80
  42. package/lib/core-imports.js.map +1 -1
  43. package/lib/core-models.d.ts +68 -38
  44. package/lib/core-models.js +62 -8
  45. package/lib/core-models.js.map +1 -1
  46. package/lib/framework-name.js +2 -2
  47. package/lib/framework-name.js.map +1 -1
  48. package/lib/helpers-isomorphic.js +33 -52
  49. package/lib/helpers-isomorphic.js.map +1 -1
  50. package/lib/helpers-messages.d.ts +6 -3
  51. package/lib/helpers-messages.js +79 -102
  52. package/lib/helpers-messages.js.map +1 -1
  53. package/lib/helpers.d.ts +21 -3
  54. package/lib/helpers.js +723 -971
  55. package/lib/helpers.js.map +1 -1
  56. package/lib/index._auto-generated_.js.map +1 -1
  57. package/lib/index.js +23 -10
  58. package/lib/index.js.map +1 -1
  59. package/lib/node-chalk-mock.js +2 -2
  60. package/lib/node-chalk-mock.js.map +1 -1
  61. package/lib/node-path-mock.js +2 -2
  62. package/lib/node-path-mock.js.map +1 -1
  63. package/lib/progress-data.js +21 -23
  64. package/lib/progress-data.js.map +1 -1
  65. package/lib/public-api.js +19 -6
  66. package/lib/public-api.js.map +1 -1
  67. package/lib/required-global-npm-packages.js.map +1 -1
  68. package/lib/required.d.ts +44 -0
  69. package/lib/safe-types/glob.d.ts +102 -0
  70. package/lib/safe-types/minimatch/assert-valid-pattern.d.ts +1 -0
  71. package/lib/safe-types/minimatch/ast.d.ts +17 -0
  72. package/lib/safe-types/minimatch/brace-expressions.d.ts +7 -0
  73. package/lib/safe-types/minimatch/escape.d.ts +11 -0
  74. package/lib/safe-types/minimatch/index.d copy.d.ts +93 -0
  75. package/lib/safe-types/minimatch/index.d.ts +93 -0
  76. package/lib/safe-types/minimatch/unescapd.d.ts +16 -0
  77. package/lib/safe-types/minimatch/unescape.d.ts +16 -0
  78. package/lib/safe-types/minimatch.d.ts +0 -0
  79. package/lib/safe-types/rimraf.d.ts +28 -0
  80. package/lib/utils.d.ts +89 -14
  81. package/lib/utils.js +1261 -1075
  82. package/lib/utils.js.map +1 -1
  83. package/migrations/index.js +15 -2
  84. package/migrations/index.js.map +1 -1
  85. package/migrations/migrations_index._auto-generated_.js.map +1 -1
  86. package/package.json +25 -91
  87. package/src.d.ts +1 -1
  88. package/tmp-environment.json +8 -404
  89. package/websql/README.md +24 -24
  90. package/websql/esm2022/lib/core-imports.mjs +65 -9
  91. package/websql/esm2022/lib/core-models.mjs +61 -9
  92. package/websql/esm2022/lib/helpers-messages.mjs +9 -4
  93. package/websql/esm2022/lib/helpers.mjs +164 -373
  94. package/websql/esm2022/lib/utils.mjs +766 -187
  95. package/websql/fesm2022/tnp-core.mjs +1546 -1060
  96. package/websql/fesm2022/tnp-core.mjs.map +1 -1
  97. package/websql/lib/core-imports.d.ts +41 -1
  98. package/websql/lib/core-models.d.ts +68 -38
  99. package/websql/lib/helpers-messages.d.ts +6 -3
  100. package/websql/lib/helpers.d.ts +22 -0
  101. package/websql/lib/utils.d.ts +77 -13
  102. package/browser/package.json +0 -25
  103. package/taon.jsonc +0 -65
  104. 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
  }
@@ -577,12 +576,20 @@ var HelpersCore = /** @class */ (function (_super) {
577
576
  // console.log(`resolved target from ${targetExisted} = ${resolvedTarget}, isFile: ${targetIsFile}`)
578
577
  if (index_1.Helpers.isSymlinkFileExitedOrUnexisted(targetExisted)) {
579
578
  // Helpers.info(`FIXING TARGET FOR WINDOWS`)
580
- targetExisted = (0, core_imports_2.crossPlatformPath)(core_imports_1.fse.realpathSync(targetExisted));
579
+ try {
580
+ targetExisted = (0, core_imports_2.crossPlatformPath)(core_imports_1.fse.realpathSync(targetExisted));
581
+ }
582
+ catch (error) {
583
+ index_1.Helpers.warn(`[tnp-helpers] Error while resolving target for windows link
584
+ target: "${targetExisted}"
585
+ link: "${linkDest}"
586
+ `, true);
587
+ }
581
588
  // TODO QUICK_FIX on windows you can't create link to link
582
589
  }
583
590
  // targetExisted = path.win32.normalize(targetExisted).replace(/\\$/, '');
584
591
  // linkDest = path.win32.normalize(linkDest).replace(/\\$/, '');
585
- var targetIsFile = index_1.Helpers.isFile(targetExisted);
592
+ const targetIsFile = index_1.Helpers.isFile(targetExisted);
586
593
  // const destIsLink = Helpers.isExistedSymlink(linkDest) || Helpers.isUnexistedLink(linkDest)
587
594
  // console.log({
588
595
  // targetExisted,
@@ -598,8 +605,8 @@ var HelpersCore = /** @class */ (function (_super) {
598
605
  }
599
606
  else {
600
607
  if (targetIsFile) {
601
- var winLinkCommand = "mklink ".concat(windowsHardLink ? '/D' : targetIsFile ? '/H' : '/j', " \"").concat(linkDest, "\" \"").concat(targetExisted, "\"");
602
- var showSymlinkOutputOnWindows = forceTrace;
608
+ const winLinkCommand = `mklink ${windowsHardLink ? '/D' : targetIsFile ? '/H' : '/j'} "${linkDest}" "${targetExisted}"`;
609
+ const showSymlinkOutputOnWindows = forceTrace;
603
610
  index_1.Helpers.run(winLinkCommand, {
604
611
  biggerBuffer: false,
605
612
  output: showSymlinkOutputOnWindows,
@@ -638,33 +645,33 @@ var HelpersCore = /** @class */ (function (_super) {
638
645
  else {
639
646
  core_imports_1.fse.symlinkSync(targetExisted, linkDest);
640
647
  }
641
- };
648
+ }
642
649
  //#endregion
643
650
  //#endregion
644
651
  //#region methods / mkdirp
645
652
  //#region @backend
646
- HelpersCore.prototype.createFolder = function (folderPath) {
653
+ createFolder(folderPath) {
647
654
  return index_1.Helpers.mkdirp(folderPath);
648
- };
649
- HelpersCore.prototype.mkdirp = function (folderPath) {
655
+ }
656
+ mkdirp(folderPath) {
650
657
  if (core_imports_2._.isArray(folderPath)) {
651
658
  folderPath = (0, core_imports_2.crossPlatformPath)(folderPath);
652
659
  }
653
660
  if (!core_imports_2.path.isAbsolute(folderPath)) {
654
- 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);
655
662
  return;
656
663
  }
657
664
  if (core_imports_2._.isString(folderPath) &&
658
665
  folderPath.startsWith('/tmp ') &&
659
666
  core_imports_1.os.platform() === 'darwin') {
660
- index_1.Helpers.warn("[taon-core][mkdirp] On mac osx /tmp is changed to /private/tmp", false);
661
- 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/');
662
669
  }
663
670
  if (index_1.Helpers.isUnexistedLink(folderPath)) {
664
671
  index_1.Helpers.remove(folderPath);
665
672
  }
666
673
  if (core_imports_1.fse.existsSync(folderPath)) {
667
- 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}`);
668
675
  }
669
676
  else {
670
677
  // if (Helpers.isSymlinkFileExitedOrUnexisted(path.dirname(folderPath))) {
@@ -673,10 +680,10 @@ var HelpersCore = /** @class */ (function (_super) {
673
680
  // Helpers.removeFileIfExists(path.dirname(folderPath));
674
681
  // } catch (error) {}
675
682
  // }
676
- index_1.Helpers.log("[taon-core][mkdirp] ".concat(folderPath), 1);
683
+ index_1.Helpers.log(`[taon-core][mkdirp] ${folderPath}`, 1);
677
684
  core_imports_1.fse.mkdirpSync(folderPath);
678
685
  }
679
- };
686
+ }
680
687
  //#endregion
681
688
  //#endregion
682
689
  //#region methods / is symlink that matches url
@@ -684,13 +691,12 @@ var HelpersCore = /** @class */ (function (_super) {
684
691
  * symlink may have existed or unexisted destiantion url
685
692
  * @param destUrl M
686
693
  */
687
- HelpersCore.prototype.isSymlinkThatMatchesUrl = function (possibleSymlink, destUrl, absoluteFileMatch) {
688
- if (absoluteFileMatch === void 0) { absoluteFileMatch = false; }
694
+ isSymlinkThatMatchesUrl(possibleSymlink, destUrl, absoluteFileMatch = false) {
689
695
  //#region @backendFunc
690
696
  destUrl = (0, core_imports_2.crossPlatformPath)(destUrl);
691
697
  if (index_1.Helpers.exists(possibleSymlink)) {
692
698
  if (index_1.Helpers.isExistedSymlink(possibleSymlink)) {
693
- var fileLink = core_imports_1.fse.readlinkSync(possibleSymlink);
699
+ let fileLink = core_imports_1.fse.readlinkSync(possibleSymlink);
694
700
  if (absoluteFileMatch) {
695
701
  fileLink = core_imports_1.fse.realpathSync(fileLink);
696
702
  }
@@ -702,11 +708,11 @@ var HelpersCore = /** @class */ (function (_super) {
702
708
  }
703
709
  }
704
710
  try {
705
- var linkToUnexitedLink = core_imports_1.fse
711
+ const linkToUnexitedLink = core_imports_1.fse
706
712
  .lstatSync(possibleSymlink)
707
713
  .isSymbolicLink();
708
714
  if (linkToUnexitedLink) {
709
- var fileLink = core_imports_1.fse.readlinkSync(possibleSymlink);
715
+ let fileLink = core_imports_1.fse.readlinkSync(possibleSymlink);
710
716
  if (absoluteFileMatch) {
711
717
  fileLink = core_imports_1.fse.realpathSync(fileLink);
712
718
  }
@@ -719,29 +725,29 @@ var HelpersCore = /** @class */ (function (_super) {
719
725
  return false;
720
726
  }
721
727
  //#endregion
722
- };
728
+ }
723
729
  //#endregion
724
730
  //#region methods / is symlink file existed or unexisted
725
- HelpersCore.prototype.isSymlinkFileExitedOrUnexisted = function (filePath) {
731
+ isSymlinkFileExitedOrUnexisted(filePath) {
726
732
  //#region @backendFunc
727
733
  if (core_imports_2._.isArray(filePath)) {
728
- 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));
729
735
  }
730
736
  try {
731
- var linkToUnexitedLink = core_imports_1.fse.lstatSync(filePath).isSymbolicLink();
737
+ const linkToUnexitedLink = core_imports_1.fse.lstatSync(filePath).isSymbolicLink();
732
738
  return linkToUnexitedLink;
733
739
  }
734
740
  catch (error) {
735
741
  return false;
736
742
  }
737
743
  //#endregion
738
- };
744
+ }
739
745
  //#endregion
740
746
  //#region methods / is unexisted link
741
747
  /**
742
748
  * If symbolnk link that target file does not exits
743
749
  */
744
- HelpersCore.prototype.isUnexistedLink = function (filePath) {
750
+ isUnexistedLink(filePath) {
745
751
  //#region @backendFunc
746
752
  if (core_imports_2._.isArray(filePath)) {
747
753
  filePath = (0, core_imports_2.crossPlatformPath)(filePath);
@@ -751,7 +757,7 @@ var HelpersCore = /** @class */ (function (_super) {
751
757
  filePath = core_imports_2.path.win32.normalize(filePath);
752
758
  }
753
759
  try {
754
- var linkToUnexitedLink = core_imports_1.fse
760
+ const linkToUnexitedLink = core_imports_1.fse
755
761
  .lstatSync(filePath)
756
762
  .isSymbolicLink();
757
763
  return (linkToUnexitedLink &&
@@ -761,13 +767,13 @@ var HelpersCore = /** @class */ (function (_super) {
761
767
  return false;
762
768
  }
763
769
  //#endregion
764
- };
770
+ }
765
771
  //#endregion
766
772
  //#region methods / is exited symlink
767
773
  /**
768
774
  * @param existedLink check if source of link exists
769
775
  */
770
- HelpersCore.prototype.isExistedSymlink = function (filePath) {
776
+ isExistedSymlink(filePath) {
771
777
  //#region @backendFunc
772
778
  if (core_imports_2._.isArray(filePath)) {
773
779
  filePath = (0, core_imports_2.crossPlatformPath)(filePath);
@@ -777,7 +783,7 @@ var HelpersCore = /** @class */ (function (_super) {
777
783
  filePath = core_imports_2.path.win32.normalize(filePath);
778
784
  }
779
785
  try {
780
- var linkToUnexitedLink = core_imports_1.fse
786
+ const linkToUnexitedLink = core_imports_1.fse
781
787
  .lstatSync(filePath)
782
788
  .isSymbolicLink();
783
789
  return (linkToUnexitedLink &&
@@ -787,12 +793,12 @@ var HelpersCore = /** @class */ (function (_super) {
787
793
  return false;
788
794
  }
789
795
  //#endregion
790
- };
796
+ }
791
797
  //#endregion
792
798
  //#region methods / path contain link
793
799
  //#region @backend
794
- HelpersCore.prototype.pathContainLink = function (p) {
795
- var previous;
800
+ pathContainLink(p) {
801
+ let previous;
796
802
  while (true) {
797
803
  p = (0, core_imports_2.crossPlatformPath)(core_imports_2.path.dirname(p));
798
804
  // @ts-ignore
@@ -807,180 +813,163 @@ var HelpersCore = /** @class */ (function (_super) {
807
813
  }
808
814
  previous = p;
809
815
  }
810
- };
816
+ }
811
817
  //#endregion
812
818
  //#endregion
813
819
  //#region methods / exists
814
- HelpersCore.prototype.exists = function (folderOrFilePath) {
820
+ exists(folderOrFilePath) {
815
821
  //#region @backendFunc
816
822
  if (core_imports_2._.isArray(folderOrFilePath)) {
817
823
  folderOrFilePath = (0, core_imports_2.crossPlatformPath)(folderOrFilePath);
818
824
  }
819
825
  if (!folderOrFilePath) {
820
- 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);
821
827
  return false;
822
828
  }
823
829
  if (!core_imports_2.path.isAbsolute(folderOrFilePath)) {
824
- 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);
825
835
  return false;
826
836
  }
827
837
  return core_imports_1.fse.existsSync(folderOrFilePath);
828
838
  //#endregion
829
- };
839
+ }
830
840
  //#endregion
831
841
  //#region methods / fix command
832
842
  /**
833
843
  * this is HACK for running procesess inside processes
834
844
  */
835
- HelpersCore.prototype._fixCommand = function (command) {
845
+ _fixCommand(command) {
836
846
  if ((command.startsWith('tnp ') || command.startsWith('taon ')) && // TODO every cli projects here that uses run and need to kill process easly!
837
847
  command.search('-spinner=false') === -1 &&
838
848
  command.search('-spinner=off') === -1) {
839
- command = "".concat(command, " -spinner=false");
849
+ command = `${command} -spinner=false`;
840
850
  }
841
851
  if (global.skipCoreCheck &&
842
852
  (command.startsWith('tnp ') || command.startsWith('taon '))) {
843
- command = "".concat(command, " --skipCoreCheck");
853
+ command = `${command} --skipCoreCheck`;
844
854
  }
845
855
  return command;
846
- };
856
+ }
847
857
  //#endregion
848
858
  //#region methods / command
849
- HelpersCore.prototype.command = function (command) {
859
+ command(command) {
850
860
  // console.log({ command })
851
861
  command = index_1.Helpers._fixCommand(command);
852
862
  return {
853
863
  //#region @backend
854
- getherOutput: function (options) {
864
+ getherOutput(options) {
855
865
  if (!options) {
856
866
  options = {};
857
867
  }
858
- return new Promise(function (resolve) {
868
+ return new Promise(resolve => {
859
869
  // @ts-ignore
860
- var ommitStder = options.ommitStder, cwd = options.cwd, biggerBuffer = options.biggerBuffer, gatherColors = options.gatherColors;
870
+ let { ommitStder, cwd, biggerBuffer, gatherColors } = options;
861
871
  if (!cwd) {
862
872
  cwd = process.cwd();
863
873
  }
864
- var maxBuffer = biggerBuffer ? index_1.Helpers.bigMaxBuffer : void 0;
865
- var env = gatherColors ? tslib_1.__assign(tslib_1.__assign({}, process.env), { FORCE_COLOR: '1' }) : {};
866
- var proc = core_imports_1.child_process.exec(command, {
867
- cwd: cwd, // @ts-ignore
868
- 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,
869
879
  env: env,
870
880
  });
871
- var gatheredData = '';
872
- proc.on('exit', function (code) {
881
+ let gatheredData = '';
882
+ proc.on('exit', code => {
873
883
  resolve(gatheredData);
874
884
  });
875
885
  // @ts-ignore
876
- proc.stdout.on('data', function (data) {
877
- gatheredData = "".concat(gatheredData).concat((data === null || data === void 0 ? void 0 : data.toString()) || '');
886
+ proc.stdout.on('data', data => {
887
+ gatheredData = `${gatheredData}${data?.toString() || ''}`;
878
888
  });
879
889
  // @ts-ignore
880
- proc.stdout.on('error', function (data) {
881
- gatheredData = "".concat(gatheredData).concat((data === null || data === void 0 ? void 0 : data.toString()) || '');
890
+ proc.stdout.on('error', data => {
891
+ gatheredData = `${gatheredData}${data?.toString() || ''}`;
882
892
  });
883
893
  if (!ommitStder) {
884
894
  // @ts-ignore
885
- proc.stderr.on('data', function (data) {
886
- gatheredData = "".concat(gatheredData).concat((data === null || data === void 0 ? void 0 : data.toString()) || '');
895
+ proc.stderr.on('data', data => {
896
+ gatheredData = `${gatheredData}${data?.toString() || ''}`;
887
897
  });
888
898
  // @ts-ignore
889
- proc.stderr.on('error', function (data) {
890
- gatheredData = "".concat(gatheredData).concat((data === null || data === void 0 ? void 0 : data.toString()) || '');
899
+ proc.stderr.on('error', data => {
900
+ gatheredData = `${gatheredData}${data?.toString() || ''}`;
891
901
  });
892
902
  }
893
903
  });
894
904
  },
895
905
  //#endregion
896
906
  };
897
- };
907
+ }
898
908
  //#endregion
899
909
  //#region methods / wait
900
- HelpersCore.prototype.wait = function (second) {
901
- return new Promise(function (resolve, reject) {
902
- setTimeout(function () {
903
- resolve(void 0);
904
- }, second * 1000);
905
- });
906
- };
907
- HelpersCore.prototype.timeout = function (seconds) {
908
- return tslib_1.__awaiter(this, void 0, void 0, function () {
909
- return tslib_1.__generator(this, function (_a) {
910
- switch (_a.label) {
911
- case 0: return [4 /*yield*/, index_1.Helpers.wait(seconds)];
912
- case 1: return [2 /*return*/, _a.sent()];
913
- }
914
- });
915
- });
916
- };
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
+ }
917
919
  //#endregion
918
920
  //#region methods / command output as string async
919
921
  //#region @backend
920
- HelpersCore.prototype.commnadOutputAsStringAsync = function (command_1) {
921
- return tslib_1.__awaiter(this, arguments, void 0, function (command, cwd, options) {
922
- var opt, output, splited, e_1;
923
- if (cwd === void 0) { cwd = (0, core_imports_2.crossPlatformPath)(process.cwd()); }
924
- return tslib_1.__generator(this, function (_a) {
925
- switch (_a.label) {
926
- case 0:
927
- command = index_1.Helpers._fixCommand(command);
928
- opt = (options || {});
929
- output = '';
930
- _a.label = 1;
931
- case 1:
932
- _a.trys.push([1, 3, , 4]);
933
- return [4 /*yield*/, index_1.Helpers.command(command).getherOutput({
934
- cwd: cwd, // @ts-ignore
935
- biggerBuffer: opt.biggerBuffer, // @ts-ignore
936
- ommitStder: !opt.showStder, // @ts-ignore
937
- gatherColors: opt.gatherColors,
938
- })];
939
- case 2:
940
- output = _a.sent();
941
- // console.log({
942
- // output
943
- // })
944
- // @ts-ignore
945
- if (!opt.showOnlyLastLine) {
946
- return [2 /*return*/, output.replace(/[^\x00-\xFF]/g, '')];
947
- }
948
- splited = (output || '').split('\n');
949
- output = (splited.pop() || '').replace(/[^\x00-\xFF]/g, '');
950
- return [3 /*break*/, 4];
951
- case 3:
952
- e_1 = _a.sent();
953
- // @ts-ignore
954
- if (opt.showErrorWarning) {
955
- index_1.Helpers.warn("[taon-helepr] Not able to get output from command:\n \"".concat(command, "\"\n "));
956
- }
957
- return [3 /*break*/, 4];
958
- case 4: return [2 /*return*/, output];
959
- }
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,
960
932
  });
961
- });
962
- };
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
+ }
963
953
  //#endregion
964
954
  //#endregion
965
955
  //#region methods / command output as string
966
956
  //#region @backend
967
- HelpersCore.prototype.commnadOutputAsString = function (command, cwd, options) {
968
- var _a;
969
- if (cwd === void 0) { cwd = (0, core_imports_2.crossPlatformPath)(process.cwd()); }
957
+ commnadOutputAsString(command, cwd = (0, core_imports_2.crossPlatformPath)(process.cwd()), options) {
970
958
  command = index_1.Helpers._fixCommand(command);
971
- var opt = (options || {});
972
- var output = '';
959
+ const opt = (options || {});
960
+ let output = '';
973
961
  try {
974
962
  // @ts-ignore
975
- 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' } : {};
976
964
  // output = Helpers.run(command, { output: false, cwd, biggerBuffer }).sync().toString().trim()
977
- output = (((_a = core_imports_1.child_process
965
+ output = (core_imports_1.child_process
978
966
  .execSync(command, {
979
- cwd: cwd, // @ts-ignore
967
+ cwd, // @ts-ignore
980
968
  stdio: ['ignore', 'pipe', opt.showStder ? 'pipe' : 'ignore'], // @ts-ignore
981
969
  maxBuffer: opt.biggerBuffer ? index_1.Helpers.bigMaxBuffer : void 0,
982
970
  env: env,
983
- })) === null || _a === void 0 ? void 0 : _a.toString()) || '').trim();
971
+ })
972
+ ?.toString() || '').trim();
984
973
  // console.log({
985
974
  // output
986
975
  // })
@@ -988,86 +977,78 @@ var HelpersCore = /** @class */ (function (_super) {
988
977
  if (!opt.showOnlyLastLine) {
989
978
  return output.replace(/[^\x00-\xFF]/g, '');
990
979
  }
991
- var splited = (output || '').split('\n');
980
+ const splited = (output || '').split('\n');
992
981
  output = (splited.pop() || '').replace(/[^\x00-\xFF]/g, '');
993
982
  }
994
983
  catch (e) {
995
984
  // @ts-ignore
996
985
  if (opt.showErrorWarning) {
997
- 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
+ `);
998
990
  }
999
991
  }
1000
992
  return output;
1001
- };
993
+ }
1002
994
  //#endregion
1003
995
  //#endregion
1004
996
  //#region methods / kill process by port
1005
- HelpersCore.prototype.killProcessByPort = function (portOrPortsToKill, options) {
1006
- return tslib_1.__awaiter(this, void 0, void 0, function () {
1007
- var showOutoput, index, port, org, e_2;
1008
- return tslib_1.__generator(this, function (_a) {
1009
- switch (_a.label) {
1010
- case 0:
1011
- showOutoput = !options || !options.silent;
1012
- if (!core_imports_2._.isArray(portOrPortsToKill)) {
1013
- portOrPortsToKill = [portOrPortsToKill];
1014
- }
1015
- index = 0;
1016
- _a.label = 1;
1017
- case 1:
1018
- if (!(index < portOrPortsToKill.length)) return [3 /*break*/, 6];
1019
- port = portOrPortsToKill[index];
1020
- index_1.Helpers.info("[taon-helpers] Killing process on port: ".concat(port));
1021
- org = port;
1022
- port = Number(port);
1023
- if (!core_imports_2._.isNumber(port)) {
1024
- showOutoput &&
1025
- index_1.Helpers.warn("[taon-helpers] Can't kill on port: \"".concat(org, "\""));
1026
- return [2 /*return*/];
1027
- }
1028
- _a.label = 2;
1029
- case 2:
1030
- _a.trys.push([2, 4, , 5]);
1031
- return [4 /*yield*/, (0, core_imports_1.fkill)(":".concat(port), { force: true })];
1032
- case 3:
1033
- _a.sent();
1034
- // run(`fkill -f :${port} &> /dev/null`, { output: false }).sync()
1035
- showOutoput &&
1036
- index_1.Helpers.info("[taon-helpers] Processs killed successfully on port: ".concat(port));
1037
- return [3 /*break*/, 5];
1038
- case 4:
1039
- e_2 = _a.sent();
1040
- showOutoput &&
1041
- index_1.Helpers.warn("[taon-helpers] No process to kill on port: ".concat(port, "... "), false);
1042
- return [3 /*break*/, 5];
1043
- case 5:
1044
- index++;
1045
- return [3 /*break*/, 1];
1046
- case 6: return [2 /*return*/];
1047
- }
1048
- });
1049
- });
1050
- };
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
+ }
1051
1039
  //#endregion
1052
1040
  //#region methods / kill on port
1053
- HelpersCore.prototype.killOnPort = function (portOrPortsToKill, options) {
1054
- return tslib_1.__awaiter(this, void 0, void 0, function () {
1055
- return tslib_1.__generator(this, function (_a) {
1056
- switch (_a.label) {
1057
- case 0: return [4 /*yield*/, index_1.Helpers.killProcessByPort(portOrPortsToKill, options)];
1058
- case 1: return [2 /*return*/, _a.sent()];
1059
- }
1060
- });
1061
- });
1062
- };
1041
+ async killOnPort(portOrPortsToKill, options) {
1042
+ return await index_1.Helpers.killProcessByPort(portOrPortsToKill, options);
1043
+ }
1063
1044
  //#endregion
1064
1045
  //#region methods / kill process
1065
- HelpersCore.prototype.killProcess = function (byPid) {
1046
+ killProcess(byPid) {
1066
1047
  //#region @backend
1067
1048
  // Helpers.run(`kill -9 ${byPid}`).sync()
1068
1049
  //#endregion
1069
1050
  //#region @backend
1070
- index_1.Helpers.run("fkill --force ".concat(byPid)).sync();
1051
+ index_1.Helpers.run(`fkill --force ${byPid}`).sync();
1071
1052
  // return;
1072
1053
  //#endregion
1073
1054
  /* */
@@ -1092,10 +1073,10 @@ var HelpersCore = /** @class */ (function (_super) {
1092
1073
  /* */
1093
1074
  /* */
1094
1075
  /* */
1095
- };
1076
+ }
1096
1077
  //#endregion
1097
1078
  //#region methods / run
1098
- HelpersCore.prototype.run = function (command, options) {
1079
+ run(command, options) {
1099
1080
  command = index_1.Helpers._fixCommand(command);
1100
1081
  // console.log({ command })
1101
1082
  //#region @backend
@@ -1108,26 +1089,31 @@ var HelpersCore = /** @class */ (function (_super) {
1108
1089
  if (options.cwd === void 0)
1109
1090
  options.cwd = (0, core_imports_2.crossPlatformPath)(process.cwd());
1110
1091
  if (!core_imports_2._.isString(command)) {
1111
- index_1.Helpers.error("[taon-helpers] command is not a string");
1092
+ index_1.Helpers.error(`[taon-helpers] command is not a string`);
1112
1093
  }
1113
1094
  //#endregion
1114
1095
  return {
1115
1096
  /**
1116
1097
  * start command as synchronous nodej proces
1117
1098
  */
1118
- sync: function () {
1099
+ sync() {
1119
1100
  // TODO buffer
1120
1101
  //#region @backendFunc
1121
1102
  // @ts-ignore
1122
1103
  if (core_imports_2._.isArray(options.extractFromLine)) {
1123
- 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);
1124
1110
  }
1125
1111
  // @ts-ignore
1126
1112
  if (core_imports_2._.isNumber(options.tryAgainWhenFailAfter) &&
1127
1113
  options.tryAgainWhenFailAfter > 0) {
1128
1114
  // TODO try again when fail
1129
1115
  // try {
1130
- var proc = index_1.Helpers.runSyncIn(command, options);
1116
+ const proc = index_1.Helpers.runSyncIn(command, options);
1131
1117
  return proc;
1132
1118
  // } catch (error) {
1133
1119
  // TODO: WAIT FUNCTION HERE
@@ -1141,7 +1127,7 @@ var HelpersCore = /** @class */ (function (_super) {
1141
1127
  * start command as asynchronous nodej proces
1142
1128
  * @param detach (default: false) - if true process will be detached
1143
1129
  */
1144
- async: function (detach) {
1130
+ async(detach = false) {
1145
1131
  //#region websqlFunc
1146
1132
  //#region mock of process
1147
1133
  /* */
@@ -1242,7 +1228,6 @@ var HelpersCore = /** @class */ (function (_super) {
1242
1228
  /* */
1243
1229
  /* */
1244
1230
  /* */
1245
- if (detach === void 0) { detach = false; }
1246
1231
  //#endregion
1247
1232
  //#region @backendFunc
1248
1233
  // @ts-ignore
@@ -1254,18 +1239,18 @@ var HelpersCore = /** @class */ (function (_super) {
1254
1239
  /**
1255
1240
  * start command as asynchronous nodej proces inside promise
1256
1241
  */
1257
- asyncAsPromise: function () {
1242
+ asyncAsPromise() {
1258
1243
  //#region @backendFunc
1259
- var isResolved = false;
1260
- return new Promise(function (resolve, reject) {
1261
- var proc = index_1.Helpers.runAsyncIn(command, options);
1262
- 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', () => {
1263
1248
  if (!isResolved) {
1264
1249
  isResolved = true;
1265
1250
  resolve(void 0);
1266
1251
  }
1267
1252
  });
1268
- proc.on('error', function () {
1253
+ proc.on('error', () => {
1269
1254
  if (!isResolved) {
1270
1255
  isResolved = true;
1271
1256
  reject();
@@ -1274,12 +1259,12 @@ var HelpersCore = /** @class */ (function (_super) {
1274
1259
  });
1275
1260
  //#endregion
1276
1261
  },
1277
- unitlOutput: function (optionsOutput) {
1262
+ unitlOutput(optionsOutput) {
1278
1263
  //#region @backendFunc
1279
1264
  optionsOutput = optionsOutput || {};
1280
- var stdoutMsg = optionsOutput.stdoutMsg, stderMsg = optionsOutput.stderMsg, timeout = optionsOutput.timeout, stdoutOutputContainsCallback = optionsOutput.stdoutOutputContainsCallback;
1281
- var isResolved = false;
1282
- return new Promise(function (resolve, reject) {
1265
+ let { stdoutMsg, stderMsg, timeout, stdoutOutputContainsCallback } = optionsOutput;
1266
+ let isResolved = false;
1267
+ return new Promise((resolve, reject) => {
1283
1268
  if (core_imports_2._.isString(stdoutMsg)) {
1284
1269
  stdoutMsg = [stdoutMsg];
1285
1270
  }
@@ -1287,23 +1272,23 @@ var HelpersCore = /** @class */ (function (_super) {
1287
1272
  stderMsg = [stderMsg];
1288
1273
  }
1289
1274
  if (!core_imports_2._.isArray(stdoutMsg)) {
1290
- reject("[unitlOutputContains] Message not a array");
1275
+ reject(`[unitlOutputContains] Message not a array`);
1291
1276
  }
1292
- var proc = index_1.Helpers.runAsyncIn(command, options);
1293
- proc.on('exit', function () {
1294
- console.info("EXIT OF PROCESS");
1277
+ const proc = index_1.Helpers.runAsyncIn(command, options);
1278
+ proc.on('exit', () => {
1279
+ console.info(`EXIT OF PROCESS`);
1295
1280
  });
1296
1281
  //#region stderr
1297
1282
  // @ts-ignore
1298
- proc.stderr.on('data', function (message) {
1299
- var data = message.toString().trim();
1283
+ proc.stderr.on('data', message => {
1284
+ const data = message.toString().trim();
1300
1285
  if (!isResolved && core_imports_2._.isArray(stderMsg)) {
1301
- for (var index = 0; index < stderMsg.length; index++) {
1302
- var rejectm = stderMsg[index];
1286
+ for (let index = 0; index < stderMsg.length; index++) {
1287
+ const rejectm = stderMsg[index];
1303
1288
  if (data.search(rejectm) !== -1) {
1304
- console.info("[unitlOutputContains] Rejected move to next step...");
1289
+ console.info(`[unitlOutputContains] Rejected move to next step...`);
1305
1290
  isResolved = true;
1306
- setTimeout(function () {
1291
+ setTimeout(() => {
1307
1292
  reject();
1308
1293
  proc.kill('SIGINT');
1309
1294
  }, timeout);
@@ -1315,13 +1300,13 @@ var HelpersCore = /** @class */ (function (_super) {
1315
1300
  //#endregion
1316
1301
  //#region stdout
1317
1302
  // @ts-ignore
1318
- proc.stdout.on('data', function (message) {
1319
- var data = message.toString().trim();
1303
+ proc.stdout.on('data', message => {
1304
+ const data = message.toString().trim();
1320
1305
  if (isResolved) {
1321
- for (var index = 0; index < stdoutMsg.length; index++) {
1322
- var m = stdoutMsg[index];
1306
+ for (let index = 0; index < stdoutMsg.length; index++) {
1307
+ const m = stdoutMsg[index];
1323
1308
  if (data.search(m) !== -1) {
1324
- console.info("[unitlOutputContains][is resolved] Move to next step...");
1309
+ console.info(`[unitlOutputContains][is resolved] Move to next step...`);
1325
1310
  stdoutOutputContainsCallback &&
1326
1311
  stdoutOutputContainsCallback();
1327
1312
  break;
@@ -1329,14 +1314,14 @@ var HelpersCore = /** @class */ (function (_super) {
1329
1314
  }
1330
1315
  }
1331
1316
  else {
1332
- for (var index = 0; index < stdoutMsg.length; index++) {
1333
- var m = stdoutMsg[index];
1317
+ for (let index = 0; index < stdoutMsg.length; index++) {
1318
+ const m = stdoutMsg[index];
1334
1319
  if (data.search(m) !== -1) {
1335
- console.info("[unitlOutputContains] Move to next step...");
1320
+ console.info(`[unitlOutputContains] Move to next step...`);
1336
1321
  stdoutOutputContainsCallback &&
1337
1322
  stdoutOutputContainsCallback();
1338
1323
  isResolved = true;
1339
- setTimeout(function () {
1324
+ setTimeout(() => {
1340
1325
  resolve(void 0);
1341
1326
  }, timeout);
1342
1327
  break;
@@ -1344,12 +1329,12 @@ var HelpersCore = /** @class */ (function (_super) {
1344
1329
  }
1345
1330
  }
1346
1331
  if (!isResolved && core_imports_2._.isArray(stderMsg)) {
1347
- for (var index = 0; index < stderMsg.length; index++) {
1348
- var rejectm = stderMsg[index];
1332
+ for (let index = 0; index < stderMsg.length; index++) {
1333
+ const rejectm = stderMsg[index];
1349
1334
  if (data.search(rejectm) !== -1) {
1350
- console.info("[unitlOutputContains] Rejected move to next step...");
1335
+ console.info(`[unitlOutputContains] Rejected move to next step...`);
1351
1336
  isResolved = true;
1352
- setTimeout(function () {
1337
+ setTimeout(() => {
1353
1338
  reject();
1354
1339
  proc.kill('SIGINT');
1355
1340
  }, timeout);
@@ -1367,11 +1352,10 @@ var HelpersCore = /** @class */ (function (_super) {
1367
1352
  * start command as asynchronous nodej proces inside promise
1368
1353
  * and wait until output contains some string
1369
1354
  */
1370
- unitlOutputContains: function (stdoutMsg, stderMsg, timeout, stdoutOutputContainsCallback) {
1371
- if (timeout === void 0) { timeout = 0; }
1355
+ unitlOutputContains(stdoutMsg, stderMsg, timeout = 0, stdoutOutputContainsCallback) {
1372
1356
  //#region @backendFunc
1373
- var isResolved = false;
1374
- return new Promise(function (resolve, reject) {
1357
+ let isResolved = false;
1358
+ return new Promise((resolve, reject) => {
1375
1359
  if (core_imports_2._.isString(stdoutMsg)) {
1376
1360
  stdoutMsg = [stdoutMsg];
1377
1361
  }
@@ -1379,19 +1363,19 @@ var HelpersCore = /** @class */ (function (_super) {
1379
1363
  stderMsg = [stderMsg];
1380
1364
  }
1381
1365
  if (!core_imports_2._.isArray(stdoutMsg)) {
1382
- reject("[unitlOutputContains] Message not a array");
1366
+ reject(`[unitlOutputContains] Message not a array`);
1383
1367
  }
1384
- var proc = index_1.Helpers.runAsyncIn(command, options);
1368
+ const proc = index_1.Helpers.runAsyncIn(command, options);
1385
1369
  // @ts-ignore
1386
- proc.stderr.on('data', function (message) {
1387
- var data = message.toString().trim();
1370
+ proc.stderr.on('data', message => {
1371
+ const data = message.toString().trim();
1388
1372
  if (!isResolved && core_imports_2._.isArray(stderMsg)) {
1389
- for (var index = 0; index < stderMsg.length; index++) {
1390
- var rejectm = stderMsg[index];
1373
+ for (let index = 0; index < stderMsg.length; index++) {
1374
+ const rejectm = stderMsg[index];
1391
1375
  if (data.search(rejectm) !== -1) {
1392
- index_1.Helpers.info("[unitlOutputContains] Rejected move to next step...");
1376
+ index_1.Helpers.info(`[unitlOutputContains] Rejected move to next step...`);
1393
1377
  isResolved = true;
1394
- setTimeout(function () {
1378
+ setTimeout(() => {
1395
1379
  reject();
1396
1380
  proc.kill('SIGINT');
1397
1381
  }, timeout);
@@ -1401,11 +1385,11 @@ var HelpersCore = /** @class */ (function (_super) {
1401
1385
  }
1402
1386
  });
1403
1387
  // @ts-ignore
1404
- proc.stdout.on('data', function (message) {
1405
- var data = message.toString().trim();
1388
+ proc.stdout.on('data', message => {
1389
+ const data = message.toString().trim();
1406
1390
  if (isResolved) {
1407
- for (var index = 0; index < stdoutMsg.length; index++) {
1408
- var m = stdoutMsg[index];
1391
+ for (let index = 0; index < stdoutMsg.length; index++) {
1392
+ const m = stdoutMsg[index];
1409
1393
  if (data.search(m) !== -1) {
1410
1394
  stdoutOutputContainsCallback &&
1411
1395
  stdoutOutputContainsCallback();
@@ -1414,14 +1398,14 @@ var HelpersCore = /** @class */ (function (_super) {
1414
1398
  }
1415
1399
  }
1416
1400
  else {
1417
- for (var index = 0; index < stdoutMsg.length; index++) {
1418
- var m = stdoutMsg[index];
1401
+ for (let index = 0; index < stdoutMsg.length; index++) {
1402
+ const m = stdoutMsg[index];
1419
1403
  if (data.search(m) !== -1) {
1420
- index_1.Helpers.info("[unitlOutputContains] Move to next step...");
1404
+ index_1.Helpers.info(`[unitlOutputContains] Move to next step...`);
1421
1405
  stdoutOutputContainsCallback &&
1422
1406
  stdoutOutputContainsCallback();
1423
1407
  isResolved = true;
1424
- setTimeout(function () {
1408
+ setTimeout(() => {
1425
1409
  resolve(void 0);
1426
1410
  }, timeout);
1427
1411
  break;
@@ -1429,12 +1413,12 @@ var HelpersCore = /** @class */ (function (_super) {
1429
1413
  }
1430
1414
  }
1431
1415
  if (!isResolved && core_imports_2._.isArray(stderMsg)) {
1432
- for (var index = 0; index < stderMsg.length; index++) {
1433
- var rejectm = stderMsg[index];
1416
+ for (let index = 0; index < stderMsg.length; index++) {
1417
+ const rejectm = stderMsg[index];
1434
1418
  if (data.search(rejectm) !== -1) {
1435
- index_1.Helpers.info("[unitlOutputContains] Rejected move to next step...");
1419
+ index_1.Helpers.info(`[unitlOutputContains] Rejected move to next step...`);
1436
1420
  isResolved = true;
1437
- setTimeout(function () {
1421
+ setTimeout(() => {
1438
1422
  reject();
1439
1423
  proc.kill('SIGINT');
1440
1424
  }, timeout);
@@ -1447,45 +1431,36 @@ var HelpersCore = /** @class */ (function (_super) {
1447
1431
  //#endregion
1448
1432
  },
1449
1433
  };
1450
- };
1434
+ }
1451
1435
  //#endregion
1452
1436
  //#region methods / question yest no
1453
1437
  /**
1454
1438
  * @deprecated use UtilsTerminal.confirm
1455
1439
  */
1456
- HelpersCore.prototype.questionYesNo = function (message_1, callbackTrue_1, callbackFalse_1) {
1457
- return tslib_1.__awaiter(this, arguments, void 0, function (message, callbackTrue, callbackFalse, defaultValue) {
1458
- if (defaultValue === void 0) { defaultValue = true; }
1459
- return tslib_1.__generator(this, function (_a) {
1460
- switch (_a.label) {
1461
- case 0: return [4 /*yield*/, utils_1.UtilsTerminal.confirm({
1462
- message: message,
1463
- callbackTrue: callbackTrue,
1464
- callbackFalse: callbackFalse,
1465
- defaultValue: defaultValue,
1466
- })
1467
- //#endregion
1468
- ];
1469
- case 1:
1470
- //#region @backendFunc
1471
- return [2 /*return*/, _a.sent()
1472
- //#endregion
1473
- ];
1474
- }
1475
- });
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,
1476
1447
  });
1477
- };
1448
+ //#endregion
1449
+ }
1478
1450
  //#endregion
1479
1451
  //#region methods / get stdio
1480
1452
  //#region @backend
1481
- HelpersCore.prototype.getStdio = function (options) {
1482
- var
1453
+ getStdio(options) {
1454
+ const {
1483
1455
  // @ts-ignore
1484
- output = options.output, silence = options.silence, stdio = options.stdio;
1456
+ output, silence, stdio,
1457
+ // pipeToParentProcerss = false,
1458
+ // inheritFromParentProcerss = false
1459
+ } = options;
1485
1460
  if (typeof stdio !== 'undefined') {
1486
1461
  return stdio;
1487
1462
  }
1488
- var resstdio = output
1463
+ let resstdio = output
1489
1464
  ? [0, 1, 2]
1490
1465
  : core_imports_2._.isBoolean(silence) && silence
1491
1466
  ? 'ignore'
@@ -1497,37 +1472,37 @@ var HelpersCore = /** @class */ (function (_super) {
1497
1472
  // stdio = ['inherit', 'inherit', 'inherit'] as any;
1498
1473
  // }
1499
1474
  return resstdio;
1500
- };
1475
+ }
1501
1476
  //#endregion
1502
1477
  //#endregion
1503
1478
  //#region methods / run sync in
1504
1479
  //#region @backend
1505
- HelpersCore.prototype.runSyncIn = function (command, options) {
1480
+ runSyncIn(command, options) {
1506
1481
  // @ts-ignore
1507
- var cwd = options.cwd, biggerBuffer = options.biggerBuffer;
1508
- var maxBuffer = biggerBuffer ? index_1.Helpers.bigMaxBuffer : undefined;
1509
- 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);
1510
1485
  index_1.Helpers.checkProcess(cwd, command);
1511
- return core_imports_1.child_process.execSync(command, { stdio: stdio, cwd: cwd, maxBuffer: maxBuffer });
1512
- };
1486
+ return core_imports_1.child_process.execSync(command, { stdio, cwd, maxBuffer });
1487
+ }
1513
1488
  //#endregion
1514
1489
  //#endregion
1515
1490
  //#region methods / run async in
1516
1491
  //#region @backend
1517
- HelpersCore.prototype.runAsyncIn = function (command, options) {
1492
+ runAsyncIn(command, options) {
1518
1493
  // @ts-ignore
1519
- var output = options.output, cwd = options.cwd, biggerBuffer = options.biggerBuffer, outputLineReplace = options.outputLineReplace, extractFromLine = options.extractFromLine, detach = options.detach;
1520
- var maxBuffer = biggerBuffer ? index_1.Helpers.bigMaxBuffer : undefined;
1521
- 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);
1522
1497
  index_1.Helpers.checkProcess(cwd, command);
1523
- var proc;
1498
+ let proc;
1524
1499
  if (detach) {
1525
1500
  //#region detached
1526
- var cmd = core_imports_2._.first(command.split(' '));
1527
- var argsForCmd = command.split(' ').slice(1);
1528
- 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(' ')}"`);
1529
1504
  if (process.platform === 'win32') {
1530
- proc = (0, core_imports_1.spawn)(cmd, argsForCmd, { cwd: cwd, detached: true });
1505
+ proc = (0, core_imports_1.spawn)(cmd, argsForCmd, { cwd, detached: true });
1531
1506
  // proc = child_process.spawn(cmd, argsForCmd, {
1532
1507
  // cwd,
1533
1508
  // detached: true,
@@ -1541,16 +1516,20 @@ var HelpersCore = /** @class */ (function (_super) {
1541
1516
  }
1542
1517
  else {
1543
1518
  // @ts-ignore
1544
- 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 });
1545
1520
  }
1546
- 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
+ `);
1547
1526
  // proc = child.exec(`${command} &`, { cwd, maxBuffer, });
1548
1527
  //#endregion
1549
1528
  }
1550
1529
  else {
1551
1530
  // Helpers.log(`Command to execture: ${command}`)
1552
- var env = tslib_1.__assign(tslib_1.__assign({}, process.env), { FORCE_COLOR: '1' });
1553
- 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 });
1554
1533
  // if (global.globalSystemToolMode) {
1555
1534
  // proc.on('exit', (code) => {
1556
1535
  // Helpers.log('EXITING BIG PROCESS');
@@ -1564,14 +1543,13 @@ var HelpersCore = /** @class */ (function (_super) {
1564
1543
  }
1565
1544
  return index_1.Helpers.logProc(proc, detach ? true : output, detach ? void 0 : stdio, outputLineReplace, // @ts-ignore
1566
1545
  options.prefix, extractFromLine);
1567
- };
1546
+ }
1568
1547
  //#endregion
1569
1548
  //#endregion
1570
1549
  //#region methods / log process
1571
1550
  //#region @backend
1572
1551
  //#region log process
1573
- HelpersCore.prototype.logProc = function (proc, output, stdio, outputLineReplace, prefix, extractFromLine) {
1574
- if (output === void 0) { output = true; }
1552
+ logProc(proc, output = true, stdio, outputLineReplace, prefix, extractFromLine) {
1575
1553
  index_1.Helpers.processes.push(proc);
1576
1554
  if (stdio) {
1577
1555
  // @ts-ignore
@@ -1582,28 +1560,28 @@ var HelpersCore = /** @class */ (function (_super) {
1582
1560
  }
1583
1561
  if (output) {
1584
1562
  // @ts-ignore
1585
- proc.stdout.on('data', function (data) {
1563
+ proc.stdout.on('data', data => {
1586
1564
  // if (data?.toString().search('was unexpected at this time') !== -1) {
1587
1565
  // console.log('!!!COMMAND',command)
1588
1566
  // }
1589
1567
  process.stdout.write(index_1.Helpers.modifyLineByLine(data, outputLineReplace, prefix, extractFromLine));
1590
1568
  });
1591
1569
  // @ts-ignore
1592
- proc.stdout.on('error', function (data) {
1570
+ proc.stdout.on('error', data => {
1593
1571
  // if (data?.toString().search('was unexpected at this time') !== -1) {
1594
1572
  // console.log('!!!COMMAND',command)
1595
1573
  // }
1596
1574
  console.log(index_1.Helpers.modifyLineByLine(data, outputLineReplace, prefix, extractFromLine));
1597
1575
  });
1598
1576
  // @ts-ignore
1599
- proc.stderr.on('data', function (data) {
1577
+ proc.stderr.on('data', data => {
1600
1578
  // if (data?.toString().search('was unexpected at this time') !== -1) {
1601
1579
  // console.log('!!!COMMAND',command)
1602
1580
  // }
1603
1581
  process.stderr.write(index_1.Helpers.modifyLineByLine(data, outputLineReplace, prefix, extractFromLine));
1604
1582
  });
1605
1583
  // @ts-ignore
1606
- proc.stderr.on('error', function (data) {
1584
+ proc.stderr.on('error', data => {
1607
1585
  // if (data?.toString().search('was unexpected at this time') !== -1) {
1608
1586
  // console.log('!!!COMMAND',command)
1609
1587
  // }
@@ -1611,207 +1589,14 @@ var HelpersCore = /** @class */ (function (_super) {
1611
1589
  });
1612
1590
  }
1613
1591
  return proc;
1614
- };
1615
- //#endregion
1616
- HelpersCore.prototype.execute = function (command, cwd, options) {
1617
- return tslib_1.__awaiter(this, void 0, void 0, function () {
1618
- var _a, hideOutput, resolvePromiseMsg, outputLineReplace, prefix, extractFromLine, exitOnErrorCallback, askToTryAgainOnError, resolvePromiseMsgCallback, similarProcessKey, _b, stderResolvePromiseMsgCallback, stdoutResolvePromiseMsgCallback, childProcess, isResolved, handlProc, error_1;
1619
- var _this = this;
1620
- return tslib_1.__generator(this, function (_c) {
1621
- switch (_c.label) {
1622
- case 0:
1623
- _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;
1624
- command = index_1.Helpers._fixCommand(command);
1625
- _b = resolvePromiseMsgCallback || {}, stderResolvePromiseMsgCallback = _b.stderr, stdoutResolvePromiseMsgCallback = _b.stdout;
1626
- // let {
1627
- // stderMsgForPromiseResolve,
1628
- // stdoutMsgForPromiseResolve
1629
- // } = resolvePromiseMsg || {};
1630
- // processes.push(proc);
1631
- if (!resolvePromiseMsg) {
1632
- resolvePromiseMsg = {};
1633
- }
1634
- if (!hideOutput) {
1635
- hideOutput = {};
1636
- }
1637
- isResolved = false;
1638
- if (core_imports_2._.isString(resolvePromiseMsg.stdout)) {
1639
- resolvePromiseMsg.stdout = [resolvePromiseMsg.stdout];
1640
- }
1641
- if (core_imports_2._.isString(resolvePromiseMsg.stderr)) {
1642
- resolvePromiseMsg.stderr = [resolvePromiseMsg.stderr];
1643
- }
1644
- handlProc = function (proc) {
1645
- return new Promise(function (resolve, reject) {
1646
- // console.log(
1647
- // `[execute] Process started...`,
1648
- // (resolvePromiseMsg.stdout as string[]).map(c => `"${c}"`).join(','),
1649
- // );
1650
- //#region handle stdout data
1651
- proc.stdout.on('data', function (rawData) {
1652
- var data = (rawData === null || rawData === void 0 ? void 0 : rawData.toString()) || '';
1653
- data = index_1.Helpers.modifyLineByLine(data, // @ts-ignore
1654
- outputLineReplace, prefix, extractFromLine);
1655
- if (!hideOutput.stdout) {
1656
- process.stdout.write(data);
1657
- }
1658
- if (core_imports_2._.isArray(resolvePromiseMsg.stdout)) {
1659
- for (var index = 0; index < resolvePromiseMsg.stdout.length; index++) {
1660
- // console.log(`DATA STDOUT: ${chalk.gray(data)}`);
1661
- var resolveCompilationMessage = resolvePromiseMsg.stdout[index];
1662
- if (data.search(resolveCompilationMessage) !== -1) {
1663
- // Helpers.info(`[unitlOutputContains] AAA...`);
1664
- stdoutResolvePromiseMsgCallback &&
1665
- stdoutResolvePromiseMsgCallback();
1666
- if (!isResolved) {
1667
- isResolved = true;
1668
- resolve(void 0);
1669
- }
1670
- break;
1671
- }
1672
- }
1673
- }
1674
- // TODO NOT NEEDED
1675
- if (core_imports_2._.isArray(resolvePromiseMsg.stderr)) {
1676
- for (var index = 0; index < resolvePromiseMsg.stderr.length; index++) {
1677
- var rejectm = resolvePromiseMsg.stderr[index];
1678
- if (data.search(rejectm) !== -1) {
1679
- // Helpers.info(`[unitlOutputContains] Rejected move to next step...`);
1680
- stdoutResolvePromiseMsgCallback &&
1681
- stdoutResolvePromiseMsgCallback();
1682
- if (!isResolved) {
1683
- isResolved = true;
1684
- reject();
1685
- proc.kill('SIGINT');
1686
- }
1687
- break;
1688
- }
1689
- }
1690
- }
1691
- });
1692
- //#endregion
1693
- //#region handle exit process
1694
- proc.on('exit', function (code) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
1695
- var error_2;
1696
- return tslib_1.__generator(this, function (_a) {
1697
- switch (_a.label) {
1698
- case 0:
1699
- if (!hideOutput.acceptAllExitCodeAsSuccess) return [3 /*break*/, 1];
1700
- resolve(void 0);
1701
- return [3 /*break*/, 9];
1702
- case 1:
1703
- if (!(code !== 0)) return [3 /*break*/, 8];
1704
- if (!core_imports_2._.isFunction(exitOnErrorCallback)) return [3 /*break*/, 6];
1705
- _a.label = 2;
1706
- case 2:
1707
- _a.trys.push([2, 4, , 5]);
1708
- return [4 /*yield*/, this.runSyncOrAsync({
1709
- functionFn: exitOnErrorCallback,
1710
- arrayOfParams: [code],
1711
- })];
1712
- case 3:
1713
- _a.sent();
1714
- reject("Command failed with code=".concat(code));
1715
- return [3 /*break*/, 5];
1716
- case 4:
1717
- error_2 = _a.sent();
1718
- reject(error_2);
1719
- return [3 /*break*/, 5];
1720
- case 5: return [3 /*break*/, 7];
1721
- case 6:
1722
- reject("Command failed with code=".concat(code));
1723
- _a.label = 7;
1724
- case 7: return [3 /*break*/, 9];
1725
- case 8:
1726
- resolve(void 0);
1727
- _a.label = 9;
1728
- case 9: return [2 /*return*/];
1729
- }
1730
- });
1731
- }); });
1732
- //#endregion
1733
- //#region handle stdout error
1734
- proc.stdout.on('error', function (rawData) {
1735
- var data = (rawData === null || rawData === void 0 ? void 0 : rawData.toString()) || '';
1736
- data = index_1.Helpers.modifyLineByLine(data, // @ts-ignore
1737
- outputLineReplace, prefix, extractFromLine);
1738
- if (!hideOutput.stdout) {
1739
- process.stdout.write(JSON.stringify(data));
1740
- }
1741
- // console.log(data);
1742
- });
1743
- //#endregion
1744
- //#region handle stder data
1745
- proc.stderr.on('data', function (rawData) {
1746
- var data = (rawData === null || rawData === void 0 ? void 0 : rawData.toString()) || '';
1747
- data = index_1.Helpers.modifyLineByLine(data, // @ts-ignore
1748
- outputLineReplace, prefix, extractFromLine);
1749
- if (!hideOutput.stderr) {
1750
- process.stderr.write(data);
1751
- }
1752
- if (core_imports_2._.isArray(resolvePromiseMsg.stderr)) {
1753
- // @ts-ignore
1754
- for (var index = 0; index < resolvePromiseMsg.stderr.length; index++) {
1755
- // @ts-ignore
1756
- var rejectm = resolvePromiseMsg.stderr[index];
1757
- if (data.search(rejectm) !== -1) {
1758
- // Helpers.info(`[unitlOutputContains] Rejected move to next step...`);
1759
- stderResolvePromiseMsgCallback &&
1760
- stderResolvePromiseMsgCallback();
1761
- if (!isResolved) {
1762
- isResolved = true;
1763
- reject();
1764
- proc.kill('SIGINT');
1765
- }
1766
- break;
1767
- }
1768
- }
1769
- }
1770
- });
1771
- //#endregion
1772
- //#region handle stder error
1773
- proc.stderr.on('error', function (rawData) {
1774
- var data = (rawData === null || rawData === void 0 ? void 0 : rawData.toString()) || '';
1775
- data = index_1.Helpers.modifyLineByLine(data, // @ts-ignore
1776
- outputLineReplace, prefix, extractFromLine);
1777
- // @ts-ignore
1778
- if (!hideOutput.stderr) {
1779
- process.stderr.write(JSON.stringify(data));
1780
- }
1781
- // console.log(data);
1782
- });
1783
- //#endregion
1784
- });
1785
- };
1786
- _c.label = 1;
1787
- case 1:
1788
- if (!true) return [3 /*break*/, 9];
1789
- childProcess = core_imports_1.child_process.exec(command, { cwd: cwd });
1790
- _c.label = 2;
1791
- case 2:
1792
- _c.trys.push([2, 4, , 8]);
1793
- return [4 /*yield*/, handlProc(childProcess)];
1794
- case 3:
1795
- _c.sent();
1796
- return [3 /*break*/, 9];
1797
- case 4:
1798
- error_1 = _c.sent();
1799
- index_1.Helpers.error("Command failed:\n\n".concat(command, "\n\nin location: ").concat(cwd, "\n\n "), true, true);
1800
- if (!askToTryAgainOnError) return [3 /*break*/, 6];
1801
- return [4 /*yield*/, index_1.Helpers.questionYesNo("Try again this command ?")];
1802
- case 5:
1803
- if (!(_c.sent())) {
1804
- throw error_1;
1805
- }
1806
- return [3 /*break*/, 7];
1807
- case 6: throw error_1;
1808
- case 7: return [3 /*break*/, 8];
1809
- case 8: return [3 /*break*/, 1];
1810
- case 9: return [2 /*return*/];
1811
- }
1812
- });
1813
- });
1814
- };
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
+ }
1815
1600
  //#endregion
1816
1601
  //#endregion
1817
1602
  //#region methods / check process
@@ -1819,67 +1604,68 @@ var HelpersCore = /** @class */ (function (_super) {
1819
1604
  /**
1820
1605
  * @deprecated
1821
1606
  */
1822
- HelpersCore.prototype.checkProcess = function (dirPath, command) {
1607
+ checkProcess(dirPath, command) {
1823
1608
  if (!core_imports_1.fse.existsSync(dirPath)) {
1824
- 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
+ `);
1825
1613
  }
1826
1614
  if (!command) {
1827
- index_1.Helpers.error("Bad command: ".concat(command));
1615
+ index_1.Helpers.error(`Bad command: ${command}`);
1828
1616
  }
1829
- };
1617
+ }
1830
1618
  //#endregion
1831
1619
  //#endregion
1832
1620
  //#region methods / modify line by line
1833
1621
  //#region @backend
1834
- HelpersCore.prototype.modifyLineByLine = function (data, outputLineReplace, prefix, extractFromLine) {
1835
- var checkExtract = core_imports_2._.isArray(extractFromLine) && extractFromLine.length > 0;
1836
- 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);
1837
1625
  if (modifyOutput && core_imports_2._.isString(data)) {
1838
1626
  data = data
1839
1627
  .split(/\r?\n/)
1840
- .map(function (line) {
1841
- return outputLineReplace(line);
1842
- })
1628
+ .map(line => outputLineReplace(line))
1843
1629
  .join('\n');
1844
1630
  }
1845
1631
  if (prefix && core_imports_2._.isString(data)) {
1846
1632
  return data
1847
1633
  .split('\n')
1848
- .map(function (singleLine) {
1634
+ .map(singleLine => {
1849
1635
  if (!singleLine ||
1850
1636
  singleLine.trim().length === 0 ||
1851
1637
  singleLine.trim() === '.') {
1852
1638
  return singleLine;
1853
1639
  }
1854
1640
  if (checkExtract) {
1855
- var sFuncs = extractFromLine.filter(function (f) { return core_imports_2._.isString(f); });
1856
- 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)
1857
1643
  .length === sFuncs.length) {
1858
- var fun = extractFromLine.find(function (f) { return core_imports_2._.isFunction(f); });
1644
+ const fun = extractFromLine.find(f => core_imports_2._.isFunction(f));
1859
1645
  if (fun) {
1860
- var s_1 = singleLine;
1861
- sFuncs.forEach(function (f) {
1862
- s_1 = s_1.replace(f, '');
1646
+ let s = singleLine;
1647
+ sFuncs.forEach(f => {
1648
+ s = s.replace(f, '');
1863
1649
  });
1864
- fun(s_1.trim());
1650
+ fun(s.trim());
1865
1651
  }
1866
1652
  }
1867
1653
  }
1868
- return "".concat(prefix, " ").concat(singleLine);
1654
+ return `${prefix} ${singleLine}`;
1869
1655
  })
1870
1656
  .join('\n');
1871
1657
  }
1872
1658
  return data;
1873
- };
1659
+ }
1874
1660
  //#endregion
1875
1661
  //#endregion
1876
1662
  //#region methods / is folder
1877
1663
  //#region @backend
1878
- HelpersCore.prototype.isFolder = function (pathToFileOrMaybeFolder) {
1664
+ isFolder(pathToFileOrMaybeFolder) {
1879
1665
  return !!(pathToFileOrMaybeFolder &&
1880
1666
  core_imports_1.fse.existsSync(pathToFileOrMaybeFolder) &&
1881
1667
  core_imports_1.fse.lstatSync(pathToFileOrMaybeFolder).isDirectory());
1882
- };
1668
+ }
1883
1669
  //#endregion
1884
1670
  //#endregion
1885
1671
  //#region methods / values
@@ -1887,10 +1673,10 @@ var HelpersCore = /** @class */ (function (_super) {
1887
1673
  * Quick fix for object values
1888
1674
  * @deprecated
1889
1675
  */
1890
- HelpersCore.prototype.values = function (obj) {
1676
+ values(obj) {
1891
1677
  if (core_imports_2._.isObject(obj) && !Array.isArray(obj)) {
1892
- var values = [];
1893
- for (var key in obj) {
1678
+ const values = [];
1679
+ for (const key in obj) {
1894
1680
  if (Object.prototype.hasOwnProperty.call(obj, key)) {
1895
1681
  // @ts-ignore
1896
1682
  values.push(obj[key]);
@@ -1899,61 +1685,46 @@ var HelpersCore = /** @class */ (function (_super) {
1899
1685
  return values;
1900
1686
  }
1901
1687
  return [];
1902
- };
1688
+ }
1903
1689
  //#endregion
1904
1690
  //#region methods / is file
1905
- //#region @backend
1906
1691
  /**
1907
1692
  * does not make sense
1908
1693
  * @deprecated
1909
1694
  */
1910
- HelpersCore.prototype.isFile = function (pathToFileOrMaybeFolder) {
1695
+ isFile(pathToFileOrMaybeFolder) {
1696
+ //#region @backendFunc
1911
1697
  return (pathToFileOrMaybeFolder &&
1912
1698
  core_imports_1.fse.existsSync(pathToFileOrMaybeFolder) &&
1913
1699
  !core_imports_1.fse.lstatSync(pathToFileOrMaybeFolder).isDirectory());
1914
- };
1915
- //#endregion
1700
+ //#endregion
1701
+ }
1916
1702
  //#endregion
1917
1703
  //#region methods / read file
1918
- //#region @backend
1919
- HelpersCore.prototype.tryReadFile = function (absoluteFilePath_1) {
1920
- return tslib_1.__awaiter(this, arguments, void 0, function (absoluteFilePath, // @ts-ignore
1921
- defaultValueWhenNotExists, notTrim) {
1922
- var fileContent, error_3;
1923
- if (defaultValueWhenNotExists === void 0) { defaultValueWhenNotExists = void 0; }
1924
- if (notTrim === void 0) { notTrim = false; }
1925
- return tslib_1.__generator(this, function (_a) {
1926
- switch (_a.label) {
1927
- case 0:
1928
- if (!(process.platform === 'win32')) return [3 /*break*/, 6];
1929
- _a.label = 1;
1930
- case 1:
1931
- if (!true) return [3 /*break*/, 6];
1932
- _a.label = 2;
1933
- case 2:
1934
- _a.trys.push([2, 3, , 5]);
1935
- fileContent = index_1.Helpers.readFile(absoluteFilePath, defaultValueWhenNotExists, notTrim);
1936
- return [2 /*return*/, fileContent];
1937
- case 3:
1938
- error_3 = _a.sent();
1939
- index_1.Helpers.error("Not able to read locked file: ".concat(absoluteFilePath), true, true);
1940
- return [4 /*yield*/, index_1.Helpers.wait(2)];
1941
- case 4:
1942
- _a.sent();
1943
- return [3 /*break*/, 5];
1944
- case 5: return [3 /*break*/, 1];
1945
- 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;
1946
1712
  }
1947
- });
1948
- });
1949
- };
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
+ }
1950
1722
  /**
1951
1723
  * wrapper for fs.readFileSync
1952
1724
  */
1953
- HelpersCore.prototype.readFile = function (absoluteFilePath, // @ts-ignore
1954
- defaultValueWhenNotExists, notTrim) {
1955
- if (defaultValueWhenNotExists === void 0) { defaultValueWhenNotExists = void 0; }
1956
- if (notTrim === void 0) { notTrim = false; }
1725
+ readFile(absoluteFilePath, // @ts-ignore
1726
+ defaultValueWhenNotExists = void 0, notTrim = false) {
1727
+ //#region @backendFunc
1957
1728
  if (core_imports_2._.isArray(absoluteFilePath)) {
1958
1729
  absoluteFilePath = core_imports_2.path.join.apply(this, absoluteFilePath);
1959
1730
  }
@@ -1967,28 +1738,26 @@ var HelpersCore = /** @class */ (function (_super) {
1967
1738
  if (notTrim) {
1968
1739
  return core_imports_1.fse
1969
1740
  .readFileSync(absoluteFilePath, {
1970
- encoding: encoding,
1741
+ encoding,
1971
1742
  })
1972
1743
  .toString();
1973
1744
  }
1974
1745
  return core_imports_1.fse
1975
1746
  .readFileSync(absoluteFilePath, {
1976
- encoding: encoding,
1747
+ encoding,
1977
1748
  })
1978
1749
  .toString()
1979
1750
  .trim();
1980
- };
1981
- //#endregion
1751
+ //#endregion
1752
+ }
1982
1753
  //#endregion
1983
1754
  //#region methods / read json
1984
- //#region @backend
1985
1755
  /**
1986
1756
  * read json from absolute path
1987
1757
  * @returns json object
1988
1758
  */
1989
- HelpersCore.prototype.readJson = function (absoluteFilePath, defaultValue, useJson5) {
1990
- if (defaultValue === void 0) { defaultValue = {}; }
1991
- if (useJson5 === void 0) { useJson5 = false; }
1759
+ readJson(absoluteFilePath, defaultValue = {}, useJson5 = false) {
1760
+ //#region @backendFunc
1992
1761
  if (core_imports_2._.isArray(absoluteFilePath)) {
1993
1762
  absoluteFilePath = core_imports_2.path.join.apply(this, absoluteFilePath);
1994
1763
  }
@@ -1997,8 +1766,8 @@ var HelpersCore = /** @class */ (function (_super) {
1997
1766
  return {};
1998
1767
  }
1999
1768
  try {
2000
- var fileContent = index_1.Helpers.readFile(absoluteFilePath);
2001
- var json = void 0;
1769
+ const fileContent = index_1.Helpers.readFile(absoluteFilePath);
1770
+ let json;
2002
1771
  // @ts-ignore
2003
1772
  json = index_1.Helpers.parse(fileContent, useJson5 || absoluteFilePath.endsWith('.json5'));
2004
1773
  return json;
@@ -2006,16 +1775,18 @@ var HelpersCore = /** @class */ (function (_super) {
2006
1775
  catch (error) {
2007
1776
  return defaultValue;
2008
1777
  }
2009
- };
2010
- HelpersCore.prototype.readJson5 = function (absoluteFilePath, defaultValue) {
2011
- if (defaultValue === void 0) { defaultValue = {}; }
1778
+ //#endregion
1779
+ }
1780
+ readJson5(absoluteFilePath, defaultValue = {}) {
1781
+ //#region @backendFunc
2012
1782
  return index_1.Helpers.readJson(absoluteFilePath, defaultValue, true);
2013
- };
2014
- HelpersCore.prototype.readJsonC = function (absoluteFilePath, defaultValue) {
2015
- if (defaultValue === void 0) { defaultValue = {}; }
1783
+ //#endregion
1784
+ }
1785
+ readJsonC(absoluteFilePath, defaultValue = {}) {
1786
+ //#region @backendFunc
2016
1787
  return this.readJson5(absoluteFilePath, defaultValue);
2017
- };
2018
- //#endregion
1788
+ //#endregion
1789
+ }
2019
1790
  //#endregion
2020
1791
  //#region methods / parse
2021
1792
  //#region @backend
@@ -2023,60 +1794,48 @@ var HelpersCore = /** @class */ (function (_super) {
2023
1794
  * parse json from string
2024
1795
  * @returns parse json object
2025
1796
  */
2026
- HelpersCore.prototype.parse = function (jsonInstring, useJson5) {
2027
- if (useJson5 === void 0) { useJson5 = false; }
1797
+ parse(jsonInstring, useJson5 = false) {
2028
1798
  if (!core_imports_2._.isString(jsonInstring)) {
2029
1799
  index_1.Helpers.log(jsonInstring);
2030
- 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...`);
2031
1801
  return jsonInstring;
2032
1802
  }
2033
1803
  return (useJson5 ? core_imports_1.json5.parse(jsonInstring) : JSON.parse(jsonInstring));
2034
- };
1804
+ }
2035
1805
  //#endregion
2036
1806
  //#endregion
2037
1807
  //#region methods / compilation wrapper
2038
1808
  //#region @backend
2039
- HelpersCore.prototype.compilationWrapper = function (fn_1) {
2040
- return tslib_1.__awaiter(this, arguments, void 0, function (fn, taskName, executionType) {
2041
- // global?.spinner?.start();
2042
- function currentDate() {
2043
- return "[".concat((0, core_imports_1.dateformat)(new Date(), 'HH:MM:ss'), "]");
2044
- }
2045
- if (taskName === void 0) { taskName = 'Task'; }
2046
- if (executionType === void 0) { executionType = 'Compilation of'; }
2047
- return tslib_1.__generator(this, function (_a) {
2048
- switch (_a.label) {
2049
- case 0:
2050
- if (!fn || !core_imports_2._.isFunction(fn)) {
2051
- index_1.Helpers.error("".concat(executionType, " wrapper: \"").concat(fn, "\" is not a function."));
2052
- process.exit(1);
2053
- }
2054
- index_1.Helpers.log("".concat(currentDate(), " ").concat(executionType, " \"").concat(taskName, "\" Started.."));
2055
- return [4 /*yield*/, index_1.Helpers.runSyncOrAsync({ functionFn: fn })];
2056
- case 1:
2057
- _a.sent();
2058
- index_1.Helpers.log("".concat(currentDate(), " ").concat(executionType, " \"").concat(taskName, "\" Done\u2713"));
2059
- return [2 /*return*/];
2060
- }
2061
- });
2062
- });
2063
- };
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
+ }
2064
1823
  //#endregion
2065
1824
  //#endregion
2066
1825
  //#region methods / replace in line
2067
- HelpersCore.prototype.replaceLinesInFile = function (absoluteFilePath, lineReplaceFn) {
1826
+ replaceLinesInFile(absoluteFilePath, lineReplaceFn) {
2068
1827
  //#region @backend
2069
- var file = index_1.Helpers.readFile(absoluteFilePath) || '';
1828
+ const file = index_1.Helpers.readFile(absoluteFilePath) || '';
2070
1829
  index_1.Helpers.writeFile(absoluteFilePath, file.split('\n').map(lineReplaceFn).join('\n'));
2071
1830
  //#endregion
2072
- };
1831
+ }
2073
1832
  //#endregion
2074
1833
  //#region methods / write file
2075
1834
  //#region @backend
2076
1835
  /**
2077
1836
  * wrapper for fs.writeFileSync
2078
1837
  */
2079
- HelpersCore.prototype.writeFile = function (absoluteFilePath, input,
1838
+ writeFile(absoluteFilePath, input,
2080
1839
  //#endregion
2081
1840
  options) {
2082
1841
  if (core_imports_2._.isArray(absoluteFilePath)) {
@@ -2086,7 +1845,7 @@ var HelpersCore = /** @class */ (function (_super) {
2086
1845
  // Helpers.info(`[taon-core] writeFile: ${absoluteFilePath}`);
2087
1846
  // debugger
2088
1847
  if (index_1.Helpers.isExistedSymlink(absoluteFilePath)) {
2089
- var beforePath = absoluteFilePath;
1848
+ const beforePath = absoluteFilePath;
2090
1849
  absoluteFilePath = core_imports_1.fse.realpathSync(absoluteFilePath);
2091
1850
  // Helpers.logWarn(
2092
1851
  // `[taon-core] WRITTING JSON into real path:
@@ -2096,8 +1855,8 @@ var HelpersCore = /** @class */ (function (_super) {
2096
1855
  // forceTrace,
2097
1856
  // );
2098
1857
  }
2099
- var _a = options || {}, preventParentFile = _a.preventParentFile, overrideSameFile = _a.overrideSameFile;
2100
- var dontWriteSameFile = !overrideSameFile;
1858
+ const { preventParentFile, overrideSameFile } = options || {};
1859
+ const dontWriteSameFile = !overrideSameFile;
2101
1860
  if (preventParentFile) {
2102
1861
  if (index_1.Helpers.isFile(core_imports_2.path.dirname(absoluteFilePath)) &&
2103
1862
  core_imports_1.fse.existsSync(core_imports_2.path.dirname(absoluteFilePath))) {
@@ -2106,11 +1865,16 @@ var HelpersCore = /** @class */ (function (_super) {
2106
1865
  }
2107
1866
  if (core_imports_1.fse.existsSync(absoluteFilePath) &&
2108
1867
  core_imports_1.fse.lstatSync(absoluteFilePath).isDirectory()) {
2109
- 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}`);
2110
1869
  return false;
2111
1870
  }
2112
1871
  if (!core_imports_1.fse.existsSync(core_imports_2.path.dirname(absoluteFilePath))) {
2113
- 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
+ }
2114
1878
  }
2115
1879
  if (index_1.Helpers.isBuffer(input)) {
2116
1880
  core_imports_1.fse.writeFileSync(absoluteFilePath, input);
@@ -2124,7 +1888,7 @@ var HelpersCore = /** @class */ (function (_super) {
2124
1888
  }
2125
1889
  if (dontWriteSameFile) {
2126
1890
  if (core_imports_1.fse.existsSync(absoluteFilePath)) {
2127
- var existedInput = index_1.Helpers.readFile(absoluteFilePath);
1891
+ const existedInput = index_1.Helpers.readFile(absoluteFilePath);
2128
1892
  if (input === existedInput) {
2129
1893
  // Helpers.log(`[helpers][writeFile] not writing same file (good thing): ${absoluteFilePath}`);
2130
1894
  return false;
@@ -2132,10 +1896,10 @@ var HelpersCore = /** @class */ (function (_super) {
2132
1896
  }
2133
1897
  }
2134
1898
  core_imports_1.fse.writeFileSync(absoluteFilePath, input, {
2135
- encoding: encoding,
1899
+ encoding,
2136
1900
  });
2137
1901
  return true;
2138
- };
1902
+ }
2139
1903
  //#endregion
2140
1904
  //#endregion
2141
1905
  //#region methods / write json
@@ -2143,12 +1907,12 @@ var HelpersCore = /** @class */ (function (_super) {
2143
1907
  /**
2144
1908
  * wrapper for fs.writeFileSync
2145
1909
  */
2146
- HelpersCore.prototype.writeJson = function (absoluteFilePath, input, optoins) {
1910
+ writeJson(absoluteFilePath, input, optoins) {
2147
1911
  if (core_imports_2._.isArray(absoluteFilePath)) {
2148
1912
  absoluteFilePath = core_imports_2.path.join.apply(this, absoluteFilePath);
2149
1913
  }
2150
1914
  absoluteFilePath = absoluteFilePath;
2151
- var _a = optoins || {}, preventParentFile = _a.preventParentFile, writeJson5 = _a.writeJson5;
1915
+ const { preventParentFile, writeJson5 } = optoins || {};
2152
1916
  if (preventParentFile) {
2153
1917
  if (index_1.Helpers.isFile(core_imports_2.path.dirname(absoluteFilePath)) &&
2154
1918
  core_imports_1.fse.existsSync(core_imports_2.path.dirname(absoluteFilePath))) {
@@ -2159,13 +1923,14 @@ var HelpersCore = /** @class */ (function (_super) {
2159
1923
  index_1.Helpers.mkdirp(core_imports_2.path.dirname(absoluteFilePath));
2160
1924
  }
2161
1925
  if (writeJson5) {
2162
- var existedContent = index_1.Helpers.readFile(absoluteFilePath) || '{}';
1926
+ const existedContent = index_1.Helpers.readFile(absoluteFilePath) || '{}';
2163
1927
  try {
2164
1928
  var writer = json5Write.load(existedContent);
2165
1929
  }
2166
1930
  catch (error) {
2167
- console.error(error === null || error === void 0 ? void 0 : error.message);
2168
- 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);
2169
1934
  }
2170
1935
  writer.write(input);
2171
1936
  index_1.Helpers.writeFile(absoluteFilePath, this.removeEmptyLineFromString(writer.toSource({
@@ -2176,18 +1941,18 @@ var HelpersCore = /** @class */ (function (_super) {
2176
1941
  }
2177
1942
  else {
2178
1943
  core_imports_1.fse.writeJSONSync(absoluteFilePath, input, {
2179
- encoding: encoding,
1944
+ encoding,
2180
1945
  spaces: 2,
2181
1946
  });
2182
1947
  }
2183
1948
  return true;
2184
- };
2185
- HelpersCore.prototype.writeJson5 = function (absoluteFilePath, input) {
1949
+ }
1950
+ writeJson5(absoluteFilePath, input) {
2186
1951
  return index_1.Helpers.writeJson(absoluteFilePath, input, { writeJson5: true });
2187
- };
2188
- HelpersCore.prototype.writeJsonC = function (absoluteFilePath, input) {
1952
+ }
1953
+ writeJsonC(absoluteFilePath, input) {
2189
1954
  return this.writeJson5(absoluteFilePath, input);
2190
- };
1955
+ }
2191
1956
  //#endregion
2192
1957
  //#endregion
2193
1958
  //#region methods / folders from
@@ -2196,51 +1961,40 @@ var HelpersCore = /** @class */ (function (_super) {
2196
1961
  * return absolute paths for folders inside folders
2197
1962
  * @returns absoulte pathes to folders from path
2198
1963
  */
2199
- HelpersCore.prototype.foldersFrom = function (pathToFolder, options) {
1964
+ foldersFrom(pathToFolder, options) {
2200
1965
  if (core_imports_2._.isArray(pathToFolder)) {
2201
1966
  pathToFolder = (0, core_imports_2.crossPlatformPath)(pathToFolder);
2202
1967
  }
2203
1968
  if (!index_1.Helpers.exists(pathToFolder)) {
2204
1969
  return [];
2205
1970
  }
2206
- var recursive = (options || {}).recursive;
2207
- var directories = [];
1971
+ const { recursive } = options || {};
1972
+ let directories = [];
2208
1973
  // Helper function to read a directory
2209
- var readDirectory = function (folderPath) {
2210
- var e_3, _a;
1974
+ const readDirectory = (folderPath) => {
2211
1975
  try {
2212
- var files = core_imports_1.fse.readdirSync(folderPath, { withFileTypes: true });
2213
- try {
2214
- for (var files_1 = tslib_1.__values(files), files_1_1 = files_1.next(); !files_1_1.done; files_1_1 = files_1.next()) {
2215
- var file = files_1_1.value;
2216
- if (file.isDirectory() &&
2217
- !index_1.Helpers.isSymlinkFileExitedOrUnexisted([folderPath, file.name])) {
2218
- var dirPath = (0, core_imports_2.crossPlatformPath)([folderPath, file.name]);
2219
- // console.log('dirPath', dirPath)
2220
- directories.push(dirPath);
2221
- // If recursive, read the directory found
2222
- if (recursive) {
2223
- readDirectory(dirPath);
2224
- }
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);
2225
1986
  }
2226
1987
  }
2227
1988
  }
2228
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
2229
- finally {
2230
- try {
2231
- if (files_1_1 && !files_1_1.done && (_a = files_1.return)) _a.call(files_1);
2232
- }
2233
- finally { if (e_3) throw e_3.error; }
2234
- }
2235
1989
  }
2236
1990
  catch (err) {
2237
- index_1.Helpers.error("Error reading directory ".concat(folderPath, ": ").concat(err));
1991
+ index_1.Helpers.error(`Error reading directory ${folderPath}: ${err}`);
2238
1992
  }
2239
1993
  };
2240
1994
  // Start reading from the initial folder
2241
1995
  readDirectory(pathToFolder);
2242
1996
  return directories;
2243
- };
1997
+ }
2244
1998
  //#endregion
2245
1999
  //#endregion
2246
2000
  //#region methods / links from
@@ -2248,21 +2002,20 @@ var HelpersCore = /** @class */ (function (_super) {
2248
2002
  /**
2249
2003
  * @returns absolute pathes to links from path
2250
2004
  */
2251
- HelpersCore.prototype.linksToFoldersFrom = function (pathToFolder, outputRealPath) {
2252
- if (outputRealPath === void 0) { outputRealPath = false; }
2005
+ linksToFoldersFrom(pathToFolder, outputRealPath = false) {
2253
2006
  if (core_imports_2._.isArray(pathToFolder)) {
2254
- 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);
2255
2008
  }
2256
2009
  if (!index_1.Helpers.exists(pathToFolder)) {
2257
2010
  return [];
2258
2011
  }
2259
2012
  return (core_imports_1.fse
2260
2013
  .readdirSync(pathToFolder)
2261
- .map(function (f) { return core_imports_2.path.join(pathToFolder, f); })
2262
- .filter(function (f) { return core_imports_1.fse.existsSync(f) && core_imports_1.fse.lstatSync(f).isSymbolicLink(); })
2263
- .map(function (f) {
2264
- var realPath = core_imports_1.fse.realpathSync(f);
2265
- 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);
2266
2019
  if (isFolder) {
2267
2020
  if (outputRealPath) {
2268
2021
  return realPath;
@@ -2272,10 +2025,10 @@ var HelpersCore = /** @class */ (function (_super) {
2272
2025
  }
2273
2026
  }
2274
2027
  })
2275
- .filter(function (f) { return !!f; })
2028
+ .filter(f => !!f)
2276
2029
  // @ts-ignore
2277
- .map(function (f) { return (0, core_imports_2.crossPlatformPath)(f); }));
2278
- };
2030
+ .map(f => (0, core_imports_2.crossPlatformPath)(f)));
2031
+ }
2279
2032
  //#endregion
2280
2033
  //#endregion
2281
2034
  //#region methods / links to folders from path
@@ -2283,30 +2036,30 @@ var HelpersCore = /** @class */ (function (_super) {
2283
2036
  /**
2284
2037
  * @returns absolute paths for folders inside folders
2285
2038
  */
2286
- HelpersCore.prototype.linksToFolderFrom = function (pathToFolder) {
2039
+ linksToFolderFrom(pathToFolder) {
2287
2040
  // options = (options || {}) as any;
2288
2041
  // if (_.isUndefined(options.linksOnlyTo)) {
2289
2042
  // options.linksOnlyTo = 'both';
2290
2043
  // }
2291
2044
  if (core_imports_2._.isArray(pathToFolder)) {
2292
- 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);
2293
2046
  }
2294
2047
  if (!index_1.Helpers.exists(pathToFolder)) {
2295
2048
  return [];
2296
2049
  }
2297
2050
  return core_imports_1.fse
2298
2051
  .readdirSync(pathToFolder)
2299
- .map(function (f) { return core_imports_2.path.join(pathToFolder, f); })
2300
- .filter(function (f) {
2301
- var res = false;
2052
+ .map(f => core_imports_2.path.join(pathToFolder, f))
2053
+ .filter(f => {
2054
+ let res = false;
2302
2055
  if (index_1.Helpers.isExistedSymlink(f)) {
2303
- var realPath = core_imports_1.fse.realpathSync(f);
2056
+ const realPath = core_imports_1.fse.realpathSync(f);
2304
2057
  return index_1.Helpers.isFolder(realPath);
2305
2058
  }
2306
2059
  return res;
2307
2060
  })
2308
- .map(function (f) { return (0, core_imports_2.crossPlatformPath)(f); });
2309
- };
2061
+ .map(f => (0, core_imports_2.crossPlatformPath)(f));
2062
+ }
2310
2063
  //#endregion
2311
2064
  //#endregion
2312
2065
  //#region methods / files from
@@ -2314,78 +2067,77 @@ var HelpersCore = /** @class */ (function (_super) {
2314
2067
  /**
2315
2068
  * return absolute paths for folders inside folders
2316
2069
  */
2317
- HelpersCore.prototype.filesFrom = function (pathToFolder, recrusive, incudeUnexistedLinks) {
2318
- var _this = this;
2319
- if (recrusive === void 0) { recrusive = false; }
2320
- if (incudeUnexistedLinks === void 0) { incudeUnexistedLinks = false; }
2070
+ filesFrom(pathToFolder, recrusive = false, incudeUnexistedLinks = false) {
2321
2071
  if (core_imports_2._.isArray(pathToFolder)) {
2322
- 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);
2323
2073
  }
2324
2074
  if (!index_1.Helpers.exists(pathToFolder)) {
2325
2075
  return [];
2326
2076
  }
2327
2077
  if (recrusive && incudeUnexistedLinks) {
2328
- return core_imports_1.glob.sync("".concat(pathToFolder, "/**/*.*"));
2078
+ return core_imports_1.glob.sync(`${pathToFolder}/**/*.*`);
2329
2079
  }
2330
2080
  if (recrusive) {
2331
- var all = core_imports_1.fse
2081
+ const all = core_imports_1.fse
2332
2082
  .readdirSync(pathToFolder)
2333
- .map(function (f) { return (0, core_imports_2.crossPlatformPath)([pathToFolder, f]); });
2334
- var folders_1 = [];
2335
- 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 => {
2336
2086
  if (core_imports_1.fse.lstatSync(f).isDirectory()) {
2337
- folders_1.push(f);
2087
+ folders.push(f);
2338
2088
  return false;
2339
2089
  }
2340
2090
  return true;
2341
2091
  });
2342
- return tslib_1.__spreadArray(tslib_1.__spreadArray([], tslib_1.__read(files), false), tslib_1.__read(folders_1
2343
- .map(function (f) { return _this.filesFrom(f, recrusive); })
2344
- .reduce(function (a, b) {
2345
- return a.concat(b);
2346
- }, [])), 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));
2347
2100
  }
2348
2101
  return core_imports_1.fse
2349
2102
  .readdirSync(pathToFolder)
2350
- .map(function (f) { return (0, core_imports_2.crossPlatformPath)(core_imports_2.path.join(pathToFolder, f)); })
2351
- .filter(function (f) {
2103
+ .map(f => (0, core_imports_2.crossPlatformPath)(core_imports_2.path.join(pathToFolder, f)))
2104
+ .filter(f => {
2352
2105
  return !core_imports_1.fse.lstatSync(f).isDirectory();
2353
2106
  });
2354
- };
2107
+ }
2355
2108
  //#endregion
2356
2109
  //#endregion
2357
2110
  //#region methods / open folder in file explorer
2358
2111
  //#region @backend
2359
- HelpersCore.prototype.openFolderInFileExploer = function (folderPath) {
2112
+ openFolderInFileExploer(folderPath) {
2360
2113
  if (process.platform === 'win32') {
2361
2114
  folderPath = (0, core_imports_1.win32Path)(folderPath);
2362
2115
  }
2363
2116
  try {
2364
- index_1.Helpers.info("Opening path.. \"".concat(folderPath, "\""));
2117
+ index_1.Helpers.info(`Opening path.. "${folderPath}"`);
2365
2118
  if (process.platform === 'win32') {
2366
- index_1.Helpers.run("explorer .", { cwd: folderPath }).sync();
2119
+ index_1.Helpers.run(`explorer .`, { cwd: folderPath }).sync();
2367
2120
  return;
2368
2121
  }
2369
2122
  if (process.platform === 'darwin') {
2370
- index_1.Helpers.run("open .", { cwd: folderPath }).sync();
2123
+ index_1.Helpers.run(`open .`, { cwd: folderPath }).sync();
2371
2124
  return;
2372
2125
  }
2373
- index_1.Helpers.run("xdg-open .", { cwd: folderPath }).sync();
2126
+ index_1.Helpers.run(`xdg-open .`, { cwd: folderPath }).sync();
2374
2127
  }
2375
2128
  catch (error) {
2376
- 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);
2377
2130
  }
2378
- };
2131
+ }
2379
2132
  //#endregion
2380
2133
  //#endregion
2381
2134
  //#region methods / hide node warnings
2382
- HelpersCore.prototype.hideNodeWarnings = function () {
2135
+ hideNodeWarnings() {
2383
2136
  //#region @backend
2384
- var process = require('process');
2137
+ const process = require('process');
2385
2138
  process.removeAllListeners('warning');
2386
2139
  //#endregion
2387
- };
2388
- return HelpersCore;
2389
- }(helpers_messages_1.HelpersMessages));
2140
+ }
2141
+ }
2390
2142
  exports.HelpersCore = HelpersCore;
2391
2143
  //# sourceMappingURL=helpers.js.map