tnp-core 16.100.19 → 16.100.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -20
- package/assets/shared/shared_folder_info.txt +1 -1
- package/browser/README.md +24 -24
- package/browser/esm2022/lib/core-config.mjs +4 -3
- package/browser/esm2022/lib/core-imports.mjs +35 -4
- package/browser/esm2022/lib/core-models.mjs +93 -80
- package/browser/esm2022/lib/framework-name.mjs +4 -3
- package/browser/esm2022/lib/helpers-isomorphic.mjs +13 -7
- package/browser/esm2022/lib/helpers-messages.mjs +13 -10
- package/browser/esm2022/lib/helpers.mjs +427 -153
- package/browser/esm2022/lib/index.mjs +1 -1
- package/browser/esm2022/lib/node-chalk-mock.mjs +1 -1
- package/browser/esm2022/lib/node-path-mock.mjs +21 -14
- package/browser/esm2022/lib/progress-data.mjs +4 -1
- package/browser/esm2022/lib/utils.mjs +17 -9
- package/browser/fesm2022/tnp-core.mjs +618 -271
- package/browser/fesm2022/tnp-core.mjs.map +1 -1
- package/browser/lib/core-imports.d.ts +1 -1
- package/browser/lib/core-models.d.ts +175 -165
- package/browser/lib/helpers.d.ts +21 -3
- package/browser/lib/utils.d.ts +1 -1
- package/cli.backend.js +3 -3
- package/client/README.md +24 -24
- package/client/esm2022/lib/core-config.mjs +4 -3
- package/client/esm2022/lib/core-imports.mjs +35 -4
- package/client/esm2022/lib/core-models.mjs +93 -80
- package/client/esm2022/lib/framework-name.mjs +4 -3
- package/client/esm2022/lib/helpers-isomorphic.mjs +13 -7
- package/client/esm2022/lib/helpers-messages.mjs +13 -10
- package/client/esm2022/lib/helpers.mjs +427 -153
- package/client/esm2022/lib/index.mjs +1 -1
- package/client/esm2022/lib/node-chalk-mock.mjs +1 -1
- package/client/esm2022/lib/node-path-mock.mjs +21 -14
- package/client/esm2022/lib/progress-data.mjs +4 -1
- package/client/esm2022/lib/utils.mjs +17 -9
- package/client/fesm2022/tnp-core.mjs +618 -271
- package/client/fesm2022/tnp-core.mjs.map +1 -1
- package/client/lib/core-imports.d.ts +1 -1
- package/client/lib/core-models.d.ts +175 -165
- package/client/lib/helpers.d.ts +21 -3
- package/client/lib/utils.d.ts +1 -1
- package/client/package.json +50 -39
- package/firedev.jsonc +69 -73
- package/lib/core-config.js +2 -2
- package/lib/core-config.js.map +1 -1
- package/lib/core-imports.d.ts +3 -5
- package/lib/core-imports.js +7 -8
- package/lib/core-imports.js.map +1 -1
- package/lib/core-models.d.ts +175 -165
- package/lib/core-models.js +92 -79
- package/lib/core-models.js.map +1 -1
- package/lib/framework-name.js +5 -4
- package/lib/framework-name.js.map +1 -1
- package/lib/helpers-isomorphic.js +12 -6
- package/lib/helpers-isomorphic.js.map +1 -1
- package/lib/helpers-messages.js +31 -18
- package/lib/helpers-messages.js.map +1 -1
- package/lib/helpers.d.ts +26 -11
- package/lib/helpers.js +268 -124
- package/lib/helpers.js.map +1 -1
- package/lib/node-chalk-mock.js +3 -3
- package/lib/node-path-mock.js +3 -3
- package/lib/progress-data.js.map +1 -1
- package/lib/utils.d.ts +1 -1
- package/lib/utils.js +12 -10
- package/lib/utils.js.map +1 -1
- package/package.json +2 -2
- package/tmp-environment.json +54 -43
- package/websql/README.md +24 -24
- package/websql/esm2022/lib/core-config.mjs +4 -3
- package/websql/esm2022/lib/core-imports.mjs +35 -4
- package/websql/esm2022/lib/core-models.mjs +93 -80
- package/websql/esm2022/lib/framework-name.mjs +4 -3
- package/websql/esm2022/lib/helpers-isomorphic.mjs +13 -7
- package/websql/esm2022/lib/helpers-messages.mjs +13 -10
- package/websql/esm2022/lib/helpers.mjs +427 -155
- package/websql/esm2022/lib/index.mjs +1 -1
- package/websql/esm2022/lib/node-chalk-mock.mjs +1 -1
- package/websql/esm2022/lib/node-path-mock.mjs +21 -14
- package/websql/esm2022/lib/progress-data.mjs +4 -1
- package/websql/esm2022/lib/utils.mjs +17 -9
- package/websql/fesm2022/tnp-core.mjs +618 -273
- package/websql/fesm2022/tnp-core.mjs.map +1 -1
- package/websql/lib/core-imports.d.ts +1 -1
- package/websql/lib/core-models.d.ts +175 -165
- package/websql/lib/helpers.d.ts +21 -3
- package/websql/lib/utils.d.ts +1 -1
package/lib/helpers.js
CHANGED
@@ -21,6 +21,10 @@ var prompts = require('prompts');
|
|
21
21
|
var WEBSQL_PROC_MOCK_PROCESSES_PID = {};
|
22
22
|
var WEBSQL_PROC_MOCK_PROCESSES_PPID = {};
|
23
23
|
//#endregion
|
24
|
+
// TODO UNCOMMENT
|
25
|
+
// const globalProcessStdout = {};
|
26
|
+
// const globalProcessStder = {};
|
27
|
+
// const maxProcessHistoryLinesChekc = 20;
|
24
28
|
var HelpersCore = /** @class */ (function (_super) {
|
25
29
|
tslib_1.__extends(HelpersCore, _super);
|
26
30
|
//#endregion
|
@@ -55,7 +59,7 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
55
59
|
get: function () {
|
56
60
|
return {
|
57
61
|
mochaTest: function () {
|
58
|
-
return
|
62
|
+
return typeof global['it'] === 'function';
|
59
63
|
},
|
60
64
|
cliMode: function () {
|
61
65
|
return !!global['globalSystemToolMode'];
|
@@ -93,6 +97,7 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
93
97
|
/* */
|
94
98
|
/* */
|
95
99
|
/* */
|
100
|
+
/* */
|
96
101
|
},
|
97
102
|
enumerable: false,
|
98
103
|
configurable: true
|
@@ -136,9 +141,9 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
136
141
|
//#endregion
|
137
142
|
//#region methods / get electron window
|
138
143
|
HelpersCore.prototype.getElectronWindow = function (_a) {
|
144
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.allowRunningInsecureContent, allowRunningInsecureContent = _c === void 0 ? true : _c;
|
139
145
|
//#region @backendFunc
|
140
146
|
// const size = screen.getPrimaryDisplay().workAreaSize;
|
141
|
-
var _b = _a === void 0 ? {} : _a, _c = _b.allowRunningInsecureContent, allowRunningInsecureContent = _c === void 0 ? true : _c;
|
142
147
|
// // Create the browser window.
|
143
148
|
// const win = new BrowserWindow({
|
144
149
|
// x: 0,
|
@@ -162,12 +167,15 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
162
167
|
return core_imports_1._.first(media === null || media === void 0 ? void 0 : media.split('/'));
|
163
168
|
};
|
164
169
|
//#endregion
|
170
|
+
//#region methods / sleep
|
165
171
|
HelpersCore.prototype.sleep = function (seconds) {
|
166
172
|
if (seconds === void 0) { seconds = 1; }
|
167
173
|
//#region @backendFunc
|
168
174
|
return index_1.Helpers.run("sleep ".concat(seconds)).sync();
|
169
175
|
//#endregion
|
170
176
|
};
|
177
|
+
//#endregion
|
178
|
+
//#region methods / remove if exists
|
171
179
|
HelpersCore.prototype.removeIfExists = function (absoluteFileOrFolderPath) {
|
172
180
|
//#region @backendFunc
|
173
181
|
if (Array.isArray(absoluteFileOrFolderPath)) {
|
@@ -191,6 +199,8 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
191
199
|
}
|
192
200
|
//#endregion
|
193
201
|
};
|
202
|
+
//#endregion
|
203
|
+
//#region methods / remove file if exists
|
194
204
|
HelpersCore.prototype.removeFileIfExists = function (absoluteFilePath) {
|
195
205
|
//#region @backendFunc
|
196
206
|
if (Array.isArray(absoluteFilePath)) {
|
@@ -206,6 +216,8 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
206
216
|
}
|
207
217
|
//#endregion
|
208
218
|
};
|
219
|
+
//#endregion
|
220
|
+
//#region methods / remove folder if exists
|
209
221
|
HelpersCore.prototype.removeFolderIfExists = function (absoluteFolderPath) {
|
210
222
|
//#region @backendFunc
|
211
223
|
if (Array.isArray(absoluteFolderPath)) {
|
@@ -222,13 +234,16 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
222
234
|
}
|
223
235
|
//#endregion
|
224
236
|
};
|
237
|
+
//#endregion
|
238
|
+
//#region methods / remove empty line from string
|
225
239
|
/**
|
226
240
|
* leave max 1 empty line
|
227
241
|
*/
|
228
242
|
HelpersCore.prototype.removeEmptyLineFromString = function (str) {
|
229
243
|
var lines = (str || '').split('\n');
|
230
244
|
var previousWasEmpty = false;
|
231
|
-
return lines
|
245
|
+
return lines
|
246
|
+
.filter(function (line) {
|
232
247
|
if (line.trim() === '') {
|
233
248
|
if (previousWasEmpty) {
|
234
249
|
// Skip this line because the previous line was also empty
|
@@ -245,9 +260,11 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
245
260
|
previousWasEmpty = false;
|
246
261
|
return true;
|
247
262
|
}
|
248
|
-
})
|
263
|
+
})
|
264
|
+
.join('\n');
|
249
265
|
};
|
250
|
-
|
266
|
+
//#endregion
|
267
|
+
//#region methods / try remove empty dir
|
251
268
|
/**
|
252
269
|
* @deprecated
|
253
270
|
*/
|
@@ -279,16 +296,17 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
279
296
|
}
|
280
297
|
//#endregion
|
281
298
|
};
|
299
|
+
//#endregion
|
282
300
|
//#region methods / remove file or folder
|
283
301
|
HelpersCore.prototype.remove = function (fileOrFolderPathOrPatter, exactFolder) {
|
284
302
|
if (exactFolder === void 0) { exactFolder = false; }
|
285
303
|
//#region @backendFunc
|
286
304
|
if (Array.isArray(fileOrFolderPathOrPatter)) {
|
287
|
-
fileOrFolderPathOrPatter =
|
305
|
+
fileOrFolderPathOrPatter = (0, core_imports_1.crossPlatformPath)(fileOrFolderPathOrPatter);
|
288
306
|
}
|
289
307
|
index_1.Helpers.log("[firedev-core][remove]: ".concat(fileOrFolderPathOrPatter), 1);
|
290
308
|
if (exactFolder) {
|
291
|
-
core_imports_1.rimraf.sync(fileOrFolderPathOrPatter, { glob: false, disableGlob: true
|
309
|
+
core_imports_1.rimraf.sync(fileOrFolderPathOrPatter, { glob: false, disableGlob: true });
|
292
310
|
return;
|
293
311
|
}
|
294
312
|
core_imports_1.rimraf.sync(fileOrFolderPathOrPatter);
|
@@ -306,7 +324,6 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
306
324
|
index_1.Helpers.log("Killing parent on ".concat(process.pid));
|
307
325
|
process.exit();
|
308
326
|
};
|
309
|
-
;
|
310
327
|
//#endregion
|
311
328
|
//#endregion
|
312
329
|
//#region methods / check if function is class
|
@@ -318,7 +335,9 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
318
335
|
if (typeof funcOrClass === 'function') {
|
319
336
|
// Check if it has a prototype property
|
320
337
|
// console.log('Object.getOwnPropertyNames(funcOrClass.prototype)', Object.getOwnPropertyNames(funcOrClass.prototype).filter(f => f !== 'constructor'))
|
321
|
-
isClass =
|
338
|
+
isClass =
|
339
|
+
!!funcOrClass.prototype &&
|
340
|
+
Object.getOwnPropertyNames(funcOrClass.prototype).filter(function (f) { return f !== 'constructor'; }).length > 0;
|
322
341
|
}
|
323
342
|
// console.log('is class: ' + isClass, funcOrClass)
|
324
343
|
return isClass;
|
@@ -480,6 +499,7 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
480
499
|
if (!speedUpProcess) {
|
481
500
|
core_imports_1.rimraf.sync(linkDest);
|
482
501
|
}
|
502
|
+
// console.log({ targetExisted, linkDest });
|
483
503
|
if (process.platform === 'win32') {
|
484
504
|
// const resolvedTarget = crossPlatformPath(path.resolve(targetExisted));
|
485
505
|
// console.log(`resolved target from ${targetExisted} = ${resolvedTarget}, isFile: ${targetIsFile}`)
|
@@ -500,24 +520,19 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
500
520
|
// if (destIsLink) {
|
501
521
|
// fse.unlinkSync(linkDest)
|
502
522
|
// }
|
503
|
-
if (windowsHardLink) {
|
523
|
+
if (windowsHardLink) {
|
524
|
+
// ADMIN RIGHT REQURED??
|
504
525
|
core_imports_1.fse.symlinkSync(targetExisted, linkDest, 'dir');
|
505
526
|
}
|
506
527
|
else {
|
507
528
|
if (targetIsFile) {
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
index_1.Helpers.run(winLinkCommand, {
|
516
|
-
biggerBuffer: false,
|
517
|
-
output: showSymlinkOutputOnWindows,
|
518
|
-
silence: !showSymlinkOutputOnWindows,
|
519
|
-
}).sync();
|
520
|
-
}
|
529
|
+
var winLinkCommand = "mklink ".concat(windowsHardLink ? '/D' : targetIsFile ? '/H' : '/j', " \"").concat(linkDest, "\" \"").concat(targetExisted, "\"");
|
530
|
+
var showSymlinkOutputOnWindows = forceTrace;
|
531
|
+
index_1.Helpers.run(winLinkCommand, {
|
532
|
+
biggerBuffer: false,
|
533
|
+
output: showSymlinkOutputOnWindows,
|
534
|
+
silence: !showSymlinkOutputOnWindows,
|
535
|
+
}).sync();
|
521
536
|
}
|
522
537
|
else {
|
523
538
|
core_imports_1.fse.symlinkSync(targetExisted, linkDest, 'junction');
|
@@ -558,13 +573,15 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
558
573
|
//#region @backend
|
559
574
|
HelpersCore.prototype.mkdirp = function (folderPath) {
|
560
575
|
if (core_imports_1._.isArray(folderPath)) {
|
561
|
-
folderPath =
|
576
|
+
folderPath = (0, core_imports_1.crossPlatformPath)(folderPath);
|
562
577
|
}
|
563
578
|
if (!core_imports_1.path.isAbsolute(folderPath)) {
|
564
579
|
index_1.Helpers.warn("[firedev-core][mkdirp] Path is not absolute, abort ".concat(folderPath), true);
|
565
580
|
return;
|
566
581
|
}
|
567
|
-
if (core_imports_1._.isString(folderPath) &&
|
582
|
+
if (core_imports_1._.isString(folderPath) &&
|
583
|
+
folderPath.startsWith('/tmp ') &&
|
584
|
+
core_imports_1.os.platform() === 'darwin') {
|
568
585
|
index_1.Helpers.warn("[firedev-core][mkdirp] On mac osx /tmp is changed to /private/tmp", false);
|
569
586
|
folderPath = folderPath.replace("/tmp/", '/private/tmp/');
|
570
587
|
}
|
@@ -575,8 +592,11 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
575
592
|
index_1.Helpers.log("[firedev-core][mkdirp] folder path already exists: ".concat(folderPath));
|
576
593
|
}
|
577
594
|
else {
|
578
|
-
// if(Helpers.isSymlinkFileExitedOrUnexisted(folderPath)) {
|
579
|
-
//
|
595
|
+
// if (Helpers.isSymlinkFileExitedOrUnexisted(path.dirname(folderPath))) {
|
596
|
+
// // TODO SUPER HACK
|
597
|
+
// try {
|
598
|
+
// Helpers.removeFileIfExists(path.dirname(folderPath));
|
599
|
+
// } catch (error) {}
|
580
600
|
// }
|
581
601
|
index_1.Helpers.log("[firedev-core][mkdirp] ".concat(folderPath), 1);
|
582
602
|
core_imports_1.fse.mkdirpSync(folderPath);
|
@@ -607,14 +627,16 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
607
627
|
}
|
608
628
|
}
|
609
629
|
try {
|
610
|
-
var linkToUnexitedLink = core_imports_1.fse
|
630
|
+
var linkToUnexitedLink = core_imports_1.fse
|
631
|
+
.lstatSync(possibleSymlink)
|
632
|
+
.isSymbolicLink();
|
611
633
|
if (linkToUnexitedLink) {
|
612
634
|
var fileLink = core_imports_1.fse.readlinkSync(possibleSymlink);
|
613
635
|
if (absoluteFileMatch) {
|
614
636
|
fileLink = core_imports_1.fse.realpathSync(fileLink);
|
615
637
|
}
|
616
638
|
fileLink = (0, core_imports_1.crossPlatformPath)(fileLink);
|
617
|
-
return
|
639
|
+
return fileLink === destUrl;
|
618
640
|
}
|
619
641
|
return false;
|
620
642
|
}
|
@@ -647,15 +669,18 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
647
669
|
HelpersCore.prototype.isUnexistedLink = function (filePath) {
|
648
670
|
//#region @backendFunc
|
649
671
|
if (core_imports_1._.isArray(filePath)) {
|
650
|
-
filePath = (0, core_imports_1.crossPlatformPath)(
|
672
|
+
filePath = (0, core_imports_1.crossPlatformPath)(filePath);
|
651
673
|
}
|
652
674
|
filePath = index_1.Helpers.removeSlashAtEnd(filePath);
|
653
675
|
if (process.platform === 'win32') {
|
654
676
|
filePath = core_imports_1.path.win32.normalize(filePath);
|
655
677
|
}
|
656
678
|
try {
|
657
|
-
var linkToUnexitedLink = core_imports_1.fse
|
658
|
-
|
679
|
+
var linkToUnexitedLink = core_imports_1.fse
|
680
|
+
.lstatSync(filePath)
|
681
|
+
.isSymbolicLink();
|
682
|
+
return (linkToUnexitedLink &&
|
683
|
+
!core_imports_1.fse.existsSync(core_imports_1.fse.readlinkSync(filePath)));
|
659
684
|
}
|
660
685
|
catch (error) {
|
661
686
|
return false;
|
@@ -670,15 +695,18 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
670
695
|
HelpersCore.prototype.isExistedSymlink = function (filePath) {
|
671
696
|
//#region @backendFunc
|
672
697
|
if (core_imports_1._.isArray(filePath)) {
|
673
|
-
filePath = (0, core_imports_1.crossPlatformPath)(
|
698
|
+
filePath = (0, core_imports_1.crossPlatformPath)(filePath);
|
674
699
|
}
|
675
700
|
filePath = index_1.Helpers.removeSlashAtEnd(filePath);
|
676
701
|
if (process.platform === 'win32') {
|
677
702
|
filePath = core_imports_1.path.win32.normalize(filePath);
|
678
703
|
}
|
679
704
|
try {
|
680
|
-
var linkToUnexitedLink = core_imports_1.fse
|
681
|
-
|
705
|
+
var linkToUnexitedLink = core_imports_1.fse
|
706
|
+
.lstatSync(filePath)
|
707
|
+
.isSymbolicLink();
|
708
|
+
return (linkToUnexitedLink &&
|
709
|
+
core_imports_1.fse.existsSync(core_imports_1.fse.readlinkSync(filePath)));
|
682
710
|
}
|
683
711
|
catch (error) {
|
684
712
|
return false;
|
@@ -708,12 +736,10 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
708
736
|
//#endregion
|
709
737
|
//#endregion
|
710
738
|
//#region methods / exists
|
711
|
-
HelpersCore.prototype.exists = function (folderOrFilePath
|
712
|
-
// , allowUnexistedLinks = false
|
713
|
-
) {
|
739
|
+
HelpersCore.prototype.exists = function (folderOrFilePath) {
|
714
740
|
//#region @backendFunc
|
715
741
|
if (core_imports_1._.isArray(folderOrFilePath)) {
|
716
|
-
folderOrFilePath =
|
742
|
+
folderOrFilePath = (0, core_imports_1.crossPlatformPath)(folderOrFilePath);
|
717
743
|
}
|
718
744
|
if (!folderOrFilePath) {
|
719
745
|
index_1.Helpers.warn("[firedev-core][exists] Path is not a string, abort.. \"".concat(folderOrFilePath, "\""), true);
|
@@ -732,12 +758,13 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
732
758
|
* this is HACK for running procesess inside processes
|
733
759
|
*/
|
734
760
|
HelpersCore.prototype._fixCommand = function (command) {
|
735
|
-
if ((command.startsWith('tnp ') || command.startsWith('firedev ')) // TODO every cli projects here that uses run and need to kill process easly!
|
736
|
-
&&
|
737
|
-
|
761
|
+
if ((command.startsWith('tnp ') || command.startsWith('firedev ')) && // TODO every cli projects here that uses run and need to kill process easly!
|
762
|
+
command.search('-spinner=false') === -1 &&
|
763
|
+
command.search('-spinner=off') === -1) {
|
738
764
|
command = "".concat(command, " -spinner=false");
|
739
765
|
}
|
740
|
-
if (global.skipCoreCheck &&
|
766
|
+
if (global.skipCoreCheck &&
|
767
|
+
(command.startsWith('tnp ') || command.startsWith('firedev '))) {
|
741
768
|
command = "".concat(command, " --skipCoreCheck");
|
742
769
|
}
|
743
770
|
return command;
|
@@ -789,7 +816,7 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
789
816
|
});
|
790
817
|
}
|
791
818
|
});
|
792
|
-
}
|
819
|
+
},
|
793
820
|
//#endregion
|
794
821
|
};
|
795
822
|
};
|
@@ -863,7 +890,8 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
863
890
|
// @ts-ignore
|
864
891
|
var env = opt.gatherColors ? tslib_1.__assign(tslib_1.__assign({}, process.env), { FORCE_COLOR: '1' }) : {};
|
865
892
|
// output = Helpers.run(command, { output: false, cwd, biggerBuffer }).sync().toString().trim()
|
866
|
-
output = (((_a = core_imports_1.child_process
|
893
|
+
output = (((_a = core_imports_1.child_process
|
894
|
+
.execSync(command, {
|
867
895
|
cwd: cwd,
|
868
896
|
stdio: ['ignore', 'pipe', opt.showStder ? 'pipe' : 'ignore'],
|
869
897
|
maxBuffer: opt.biggerBuffer ? index_1.Helpers.bigMaxBuffer : void 0,
|
@@ -889,13 +917,14 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
889
917
|
};
|
890
918
|
//#endregion
|
891
919
|
//#endregion
|
920
|
+
//#region methods / kill process by port
|
892
921
|
HelpersCore.prototype.killProcessByPort = function (portOrPortsToKill, options) {
|
893
922
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
894
923
|
var showOutoput, index, port, org, e_2;
|
895
924
|
return tslib_1.__generator(this, function (_a) {
|
896
925
|
switch (_a.label) {
|
897
926
|
case 0:
|
898
|
-
showOutoput =
|
927
|
+
showOutoput = !options || !options.silent;
|
899
928
|
if (!core_imports_1._.isArray(portOrPortsToKill)) {
|
900
929
|
portOrPortsToKill = [portOrPortsToKill];
|
901
930
|
}
|
@@ -908,7 +937,8 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
908
937
|
org = port;
|
909
938
|
port = Number(port);
|
910
939
|
if (!core_imports_1._.isNumber(port)) {
|
911
|
-
showOutoput &&
|
940
|
+
showOutoput &&
|
941
|
+
index_1.Helpers.warn("[firedev-helpers] Can't kill on port: \"".concat(org, "\""));
|
912
942
|
return [2 /*return*/];
|
913
943
|
}
|
914
944
|
_a.label = 2;
|
@@ -918,11 +948,13 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
918
948
|
case 3:
|
919
949
|
_a.sent();
|
920
950
|
// run(`fkill -f :${port} &> /dev/null`, { output: false }).sync()
|
921
|
-
showOutoput &&
|
951
|
+
showOutoput &&
|
952
|
+
index_1.Helpers.info("[firedev-helpers] Processs killed successfully on port: ".concat(port));
|
922
953
|
return [3 /*break*/, 5];
|
923
954
|
case 4:
|
924
955
|
e_2 = _a.sent();
|
925
|
-
showOutoput &&
|
956
|
+
showOutoput &&
|
957
|
+
index_1.Helpers.warn("[firedev-helpers] No process to kill on port: ".concat(port, "... "), false);
|
926
958
|
return [3 /*break*/, 5];
|
927
959
|
case 5:
|
928
960
|
index++;
|
@@ -932,6 +964,8 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
932
964
|
});
|
933
965
|
});
|
934
966
|
};
|
967
|
+
//#endregion
|
968
|
+
//#region methods / kill on port
|
935
969
|
HelpersCore.prototype.killOnPort = function (portOrPortsToKill, options) {
|
936
970
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
937
971
|
return tslib_1.__generator(this, function (_a) {
|
@@ -942,6 +976,7 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
942
976
|
});
|
943
977
|
});
|
944
978
|
};
|
979
|
+
//#endregion
|
945
980
|
//#region methods / kill process
|
946
981
|
HelpersCore.prototype.killProcess = function (byPid) {
|
947
982
|
//#region @backend
|
@@ -969,6 +1004,10 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
969
1004
|
/* */
|
970
1005
|
/* */
|
971
1006
|
/* */
|
1007
|
+
/* */
|
1008
|
+
/* */
|
1009
|
+
/* */
|
1010
|
+
/* */
|
972
1011
|
};
|
973
1012
|
//#endregion
|
974
1013
|
//#region methods / run
|
@@ -989,14 +1028,19 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
989
1028
|
}
|
990
1029
|
//#endregion
|
991
1030
|
return {
|
992
|
-
|
1031
|
+
/**
|
1032
|
+
* start command as synchronous nodej proces
|
1033
|
+
*/
|
993
1034
|
sync: function () {
|
1035
|
+
// TODO buffer
|
1036
|
+
//#region @backendFunc
|
994
1037
|
// @ts-ignore
|
995
1038
|
if (core_imports_1._.isArray(options.extractFromLine)) {
|
996
1039
|
index_1.Helpers.error("[tnp-helper] extractFromLine only for:\n - asyncAsPromise\n - async\n - unitlOutputContains\n\n ", false, true);
|
997
1040
|
}
|
998
1041
|
// @ts-ignore
|
999
|
-
if (core_imports_1._.isNumber(options.tryAgainWhenFailAfter) &&
|
1042
|
+
if (core_imports_1._.isNumber(options.tryAgainWhenFailAfter) &&
|
1043
|
+
options.tryAgainWhenFailAfter > 0) {
|
1000
1044
|
// TODO try again when fail
|
1001
1045
|
// try {
|
1002
1046
|
var proc = index_1.Helpers.runSyncIn(command, options);
|
@@ -1007,10 +1051,14 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1007
1051
|
// }
|
1008
1052
|
}
|
1009
1053
|
return index_1.Helpers.runSyncIn(command, options);
|
1054
|
+
//#endregion
|
1010
1055
|
},
|
1011
|
-
|
1012
|
-
|
1056
|
+
/**
|
1057
|
+
* start command as asynchronous nodej proces
|
1058
|
+
* @param detach (default: false) - if true process will be detached
|
1059
|
+
*/
|
1013
1060
|
async: function (detach) {
|
1061
|
+
//#region websqlFunc
|
1014
1062
|
//#region mock of process
|
1015
1063
|
/* */
|
1016
1064
|
/* */
|
@@ -1100,6 +1148,16 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1100
1148
|
/* */
|
1101
1149
|
/* */
|
1102
1150
|
/* */
|
1151
|
+
/* */
|
1152
|
+
/* */
|
1153
|
+
/* */
|
1154
|
+
/* */
|
1155
|
+
/* */
|
1156
|
+
/* */
|
1157
|
+
/* */
|
1158
|
+
/* */
|
1159
|
+
/* */
|
1160
|
+
/* */
|
1103
1161
|
if (detach === void 0) { detach = false; }
|
1104
1162
|
//#endregion
|
1105
1163
|
//#region @backendFunc
|
@@ -1107,10 +1165,13 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1107
1165
|
options.detach = detach;
|
1108
1166
|
return index_1.Helpers.runAsyncIn(command, options);
|
1109
1167
|
//#endregion
|
1168
|
+
//#endregion
|
1110
1169
|
},
|
1111
|
-
|
1112
|
-
|
1170
|
+
/**
|
1171
|
+
* start command as asynchronous nodej proces inside promise
|
1172
|
+
*/
|
1113
1173
|
asyncAsPromise: function () {
|
1174
|
+
//#region @backendFunc
|
1114
1175
|
var isResolved = false;
|
1115
1176
|
return new Promise(function (resolve, reject) {
|
1116
1177
|
var proc = index_1.Helpers.runAsyncIn(command, options);
|
@@ -1127,11 +1188,15 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1127
1188
|
}
|
1128
1189
|
});
|
1129
1190
|
});
|
1191
|
+
//#endregion
|
1130
1192
|
},
|
1131
|
-
|
1132
|
-
|
1193
|
+
/**
|
1194
|
+
* start command as asynchronous nodej proces inside promise
|
1195
|
+
* and wait until output contains some string
|
1196
|
+
*/
|
1133
1197
|
unitlOutputContains: function (stdoutMsg, stderMsg, timeout, stdoutOutputContainsCallback) {
|
1134
1198
|
if (timeout === void 0) { timeout = 0; }
|
1199
|
+
//#region @backendFunc
|
1135
1200
|
var isResolved = false;
|
1136
1201
|
return new Promise(function (resolve, reject) {
|
1137
1202
|
if (core_imports_1._.isString(stdoutMsg)) {
|
@@ -1150,7 +1215,7 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1150
1215
|
if (!isResolved && core_imports_1._.isArray(stderMsg)) {
|
1151
1216
|
for (var index = 0; index < stderMsg.length; index++) {
|
1152
1217
|
var rejectm = stderMsg[index];
|
1153
|
-
if (
|
1218
|
+
if (data.search(rejectm) !== -1) {
|
1154
1219
|
index_1.Helpers.info("[unitlOutputContains] Rejected move to next step...");
|
1155
1220
|
isResolved = true;
|
1156
1221
|
setTimeout(function () {
|
@@ -1168,8 +1233,9 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1168
1233
|
if (isResolved) {
|
1169
1234
|
for (var index = 0; index < stdoutMsg.length; index++) {
|
1170
1235
|
var m = stdoutMsg[index];
|
1171
|
-
if (
|
1172
|
-
stdoutOutputContainsCallback &&
|
1236
|
+
if (data.search(m) !== -1) {
|
1237
|
+
stdoutOutputContainsCallback &&
|
1238
|
+
stdoutOutputContainsCallback();
|
1173
1239
|
break;
|
1174
1240
|
}
|
1175
1241
|
}
|
@@ -1177,9 +1243,10 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1177
1243
|
else {
|
1178
1244
|
for (var index = 0; index < stdoutMsg.length; index++) {
|
1179
1245
|
var m = stdoutMsg[index];
|
1180
|
-
if (
|
1246
|
+
if (data.search(m) !== -1) {
|
1181
1247
|
index_1.Helpers.info("[unitlOutputContains] Move to next step...");
|
1182
|
-
stdoutOutputContainsCallback &&
|
1248
|
+
stdoutOutputContainsCallback &&
|
1249
|
+
stdoutOutputContainsCallback();
|
1183
1250
|
isResolved = true;
|
1184
1251
|
setTimeout(function () {
|
1185
1252
|
resolve(void 0);
|
@@ -1191,7 +1258,7 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1191
1258
|
if (!isResolved && core_imports_1._.isArray(stderMsg)) {
|
1192
1259
|
for (var index = 0; index < stderMsg.length; index++) {
|
1193
1260
|
var rejectm = stderMsg[index];
|
1194
|
-
if (
|
1261
|
+
if (data.search(rejectm) !== -1) {
|
1195
1262
|
index_1.Helpers.info("[unitlOutputContains] Rejected move to next step...");
|
1196
1263
|
isResolved = true;
|
1197
1264
|
setTimeout(function () {
|
@@ -1204,8 +1271,8 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1204
1271
|
}
|
1205
1272
|
});
|
1206
1273
|
});
|
1207
|
-
|
1208
|
-
|
1274
|
+
//#endregion
|
1275
|
+
},
|
1209
1276
|
};
|
1210
1277
|
};
|
1211
1278
|
//#endregion
|
@@ -1223,7 +1290,7 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1223
1290
|
switch (_a.label) {
|
1224
1291
|
case 0:
|
1225
1292
|
response = {
|
1226
|
-
value: defaultValue
|
1293
|
+
value: defaultValue,
|
1227
1294
|
};
|
1228
1295
|
if (!(global.tnpNonInteractive && !mustAnswerQuestion)) return [3 /*break*/, 1];
|
1229
1296
|
index_1.Helpers.info("".concat(message, " - AUTORESPONSE: ").concat(defaultValue ? 'YES' : 'NO'));
|
@@ -1234,7 +1301,7 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1234
1301
|
message: message,
|
1235
1302
|
initial: defaultValue,
|
1236
1303
|
active: 'yes',
|
1237
|
-
inactive: 'no'
|
1304
|
+
inactive: 'no',
|
1238
1305
|
})];
|
1239
1306
|
case 2:
|
1240
1307
|
response = _a.sent();
|
@@ -1262,15 +1329,17 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1262
1329
|
//#region methods / get stdio
|
1263
1330
|
//#region @backend
|
1264
1331
|
HelpersCore.prototype.getStdio = function (options) {
|
1265
|
-
var
|
1266
|
-
|
1267
|
-
|
1268
|
-
// inheritFromParentProcerss = false
|
1269
|
-
;
|
1332
|
+
var
|
1333
|
+
// @ts-ignore
|
1334
|
+
output = options.output, silence = options.silence, stdio = options.stdio;
|
1270
1335
|
if (typeof stdio !== 'undefined') {
|
1271
1336
|
return stdio;
|
1272
1337
|
}
|
1273
|
-
var resstdio = output
|
1338
|
+
var resstdio = output
|
1339
|
+
? [0, 1, 2]
|
1340
|
+
: core_imports_1._.isBoolean(silence) && silence
|
1341
|
+
? 'ignore'
|
1342
|
+
: undefined;
|
1274
1343
|
// if (pipeToParentProcerss) {
|
1275
1344
|
// stdio = ['pipe', 'pipe', 'pipe'] as any;
|
1276
1345
|
// }
|
@@ -1394,12 +1463,12 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1394
1463
|
};
|
1395
1464
|
HelpersCore.prototype.execute = function (command, cwd, options) {
|
1396
1465
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
1397
|
-
var _a, hideOutput, resolvePromiseMsg, outputLineReplace, prefix, extractFromLine, exitOnErrorCallback, askToTryAgainOnError, childProcess, isResolved, handlProc, error_1;
|
1466
|
+
var _a, hideOutput, resolvePromiseMsg, outputLineReplace, prefix, extractFromLine, exitOnErrorCallback, askToTryAgainOnError, similarProcessKey, childProcess, isResolved, handlProc, error_1;
|
1398
1467
|
var _this = this;
|
1399
1468
|
return tslib_1.__generator(this, function (_b) {
|
1400
1469
|
switch (_b.label) {
|
1401
1470
|
case 0:
|
1402
|
-
_a = options || {}, hideOutput = _a.hideOutput, resolvePromiseMsg = _a.resolvePromiseMsg, outputLineReplace = _a.outputLineReplace, prefix = _a.prefix, extractFromLine = _a.extractFromLine, exitOnErrorCallback = _a.exitOnErrorCallback, askToTryAgainOnError = _a.askToTryAgainOnError;
|
1471
|
+
_a = options || {}, hideOutput = _a.hideOutput, resolvePromiseMsg = _a.resolvePromiseMsg, outputLineReplace = _a.outputLineReplace, prefix = _a.prefix, extractFromLine = _a.extractFromLine, exitOnErrorCallback = _a.exitOnErrorCallback, askToTryAgainOnError = _a.askToTryAgainOnError, similarProcessKey = _a.similarProcessKey;
|
1403
1472
|
//#endregion
|
1404
1473
|
command = index_1.Helpers._fixCommand(command);
|
1405
1474
|
// let {
|
@@ -1422,18 +1491,49 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1422
1491
|
}
|
1423
1492
|
handlProc = function (proc) {
|
1424
1493
|
return new Promise(function (resolve, reject) {
|
1494
|
+
// TODO UNCOMMENT + TEST
|
1495
|
+
// if (
|
1496
|
+
// similarProcessKey &&
|
1497
|
+
// !Array.isArray(globalProcessStdout[similarProcessKey])
|
1498
|
+
// ) {
|
1499
|
+
// globalProcessStdout[similarProcessKey] = [];
|
1500
|
+
// }
|
1501
|
+
// if (
|
1502
|
+
// similarProcessKey &&
|
1503
|
+
// !Array.isArray(globalProcessStder[similarProcessKey])
|
1504
|
+
// ) {
|
1505
|
+
// globalProcessStder[similarProcessKey] = [];
|
1506
|
+
// }
|
1507
|
+
// let lastRawDataStdout = similarProcessKey
|
1508
|
+
// ? globalProcessStdout[similarProcessKey]
|
1509
|
+
// : [];
|
1510
|
+
// let lastRawDataStder = similarProcessKey
|
1511
|
+
// ? globalProcessStder[similarProcessKey]
|
1512
|
+
// : [];
|
1425
1513
|
//#region handle stdout data
|
1426
1514
|
proc.stdout.on('data', function (rawData) {
|
1427
|
-
var data = (
|
1515
|
+
var data = (rawData === null || rawData === void 0 ? void 0 : rawData.toString()) || '';
|
1516
|
+
// TODO UNCOMMENT + TEST
|
1517
|
+
// if (data !== '' && lastRawDataStdout.includes(data.trim())) {
|
1518
|
+
// // console.warn(`[execute][stdout] Same data as last one, skip...`);
|
1519
|
+
// // process.stdout.write('-');
|
1520
|
+
// return;
|
1521
|
+
// }
|
1522
|
+
// lastRawDataStdout.push(data.trim());
|
1523
|
+
// if (lastRawDataStdout.length > maxProcessHistoryLinesChekc) {
|
1524
|
+
// lastRawDataStdout.shift();
|
1525
|
+
// }
|
1428
1526
|
data = index_1.Helpers.modifyLineByLine(data, // @ts-ignore
|
1429
1527
|
outputLineReplace, prefix, extractFromLine);
|
1430
1528
|
if (!hideOutput.stdout) {
|
1431
1529
|
process.stdout.write(data);
|
1432
1530
|
}
|
1433
|
-
if (!isResolved && core_imports_1._.isArray(resolvePromiseMsg.stdout)) {
|
1434
|
-
|
1531
|
+
if (!isResolved && core_imports_1._.isArray(resolvePromiseMsg.stdout)) {
|
1532
|
+
// @ts-ignore
|
1533
|
+
for (var index = 0; index < resolvePromiseMsg.stdout.length; index++) {
|
1534
|
+
// @ts-ignore
|
1435
1535
|
var m = resolvePromiseMsg.stdout[index];
|
1436
|
-
if (
|
1536
|
+
if (data.search(m) !== -1) {
|
1437
1537
|
// Helpers.info(`[unitlOutputContains] Move to next step...`)
|
1438
1538
|
isResolved = true;
|
1439
1539
|
resolve(void 0);
|
@@ -1441,10 +1541,12 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1441
1541
|
}
|
1442
1542
|
}
|
1443
1543
|
}
|
1444
|
-
if (!isResolved && core_imports_1._.isArray(resolvePromiseMsg.stderr)) {
|
1445
|
-
|
1544
|
+
if (!isResolved && core_imports_1._.isArray(resolvePromiseMsg.stderr)) {
|
1545
|
+
// @ts-ignore
|
1546
|
+
for (var index = 0; index < resolvePromiseMsg.stderr.length; index++) {
|
1547
|
+
// @ts-ignore
|
1446
1548
|
var rejectm = resolvePromiseMsg.stderr[index];
|
1447
|
-
if (
|
1549
|
+
if (data.search(rejectm) !== -1) {
|
1448
1550
|
// Helpers.info(`[unitlOutputContains] Rejected move to next step...`);
|
1449
1551
|
isResolved = true;
|
1450
1552
|
reject();
|
@@ -1497,7 +1599,17 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1497
1599
|
//#endregion
|
1498
1600
|
//#region handle stdout error
|
1499
1601
|
proc.stdout.on('error', function (rawData) {
|
1500
|
-
var data = (
|
1602
|
+
var data = (rawData === null || rawData === void 0 ? void 0 : rawData.toString()) || '';
|
1603
|
+
// TODO UNCOMMENT + TEST
|
1604
|
+
// if (data !== '' && lastRawDataStder.includes(data.trim())) {
|
1605
|
+
// // console.warn(`[execute][stder] Same data as last one, skip...`);
|
1606
|
+
// // process.stdout.write('-');
|
1607
|
+
// return;
|
1608
|
+
// }
|
1609
|
+
// lastRawDataStder.push(data.trim());
|
1610
|
+
// if (lastRawDataStder.length > maxProcessHistoryLinesChekc) {
|
1611
|
+
// lastRawDataStder.shift();
|
1612
|
+
// }
|
1501
1613
|
data = index_1.Helpers.modifyLineByLine(data, // @ts-ignore
|
1502
1614
|
outputLineReplace, prefix, extractFromLine);
|
1503
1615
|
if (!hideOutput.stdout) {
|
@@ -1508,16 +1620,18 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1508
1620
|
//#endregion
|
1509
1621
|
//#region handle stder data
|
1510
1622
|
proc.stderr.on('data', function (rawData) {
|
1511
|
-
var data = (
|
1623
|
+
var data = (rawData === null || rawData === void 0 ? void 0 : rawData.toString()) || '';
|
1512
1624
|
data = index_1.Helpers.modifyLineByLine(data, // @ts-ignore
|
1513
1625
|
outputLineReplace, prefix, extractFromLine);
|
1514
1626
|
if (!hideOutput.stderr) {
|
1515
1627
|
process.stderr.write(data);
|
1516
1628
|
}
|
1517
|
-
if (!isResolved && core_imports_1._.isArray(resolvePromiseMsg.stderr)) {
|
1518
|
-
|
1629
|
+
if (!isResolved && core_imports_1._.isArray(resolvePromiseMsg.stderr)) {
|
1630
|
+
// @ts-ignore
|
1631
|
+
for (var index = 0; index < resolvePromiseMsg.stderr.length; index++) {
|
1632
|
+
// @ts-ignore
|
1519
1633
|
var rejectm = resolvePromiseMsg.stderr[index];
|
1520
|
-
if (
|
1634
|
+
if (data.search(rejectm) !== -1) {
|
1521
1635
|
// Helpers.info(`[unitlOutputContains] Rejected move to next step...`);
|
1522
1636
|
isResolved = true;
|
1523
1637
|
reject();
|
@@ -1530,7 +1644,7 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1530
1644
|
//#endregion
|
1531
1645
|
//#region handle stder error
|
1532
1646
|
proc.stderr.on('error', function (rawData) {
|
1533
|
-
var data = (
|
1647
|
+
var data = (rawData === null || rawData === void 0 ? void 0 : rawData.toString()) || '';
|
1534
1648
|
data = index_1.Helpers.modifyLineByLine(data, // @ts-ignore
|
1535
1649
|
outputLineReplace, prefix, extractFromLine);
|
1536
1650
|
// @ts-ignore
|
@@ -1591,31 +1705,42 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1591
1705
|
//#region methods / modify line by line
|
1592
1706
|
//#region @backend
|
1593
1707
|
HelpersCore.prototype.modifyLineByLine = function (data, outputLineReplace, prefix, extractFromLine) {
|
1594
|
-
var checkExtract =
|
1708
|
+
var checkExtract = core_imports_1._.isArray(extractFromLine) && extractFromLine.length > 0;
|
1595
1709
|
var modifyOutput = core_imports_1._.isFunction(outputLineReplace);
|
1596
1710
|
if (modifyOutput && core_imports_1._.isString(data)) {
|
1597
|
-
data = data
|
1598
|
-
|
1711
|
+
data = data
|
1712
|
+
.split(/\r?\n/)
|
1713
|
+
.map(function (line) {
|
1714
|
+
return outputLineReplace(line);
|
1715
|
+
})
|
1716
|
+
.join('\n');
|
1599
1717
|
}
|
1600
1718
|
if (prefix && core_imports_1._.isString(data)) {
|
1601
|
-
return data
|
1602
|
-
|
1719
|
+
return data
|
1720
|
+
.split('\n')
|
1721
|
+
.map(function (singleLine) {
|
1722
|
+
if (!singleLine ||
|
1723
|
+
singleLine.trim().length === 0 ||
|
1724
|
+
singleLine.trim() === '.') {
|
1603
1725
|
return singleLine;
|
1604
1726
|
}
|
1605
1727
|
if (checkExtract) {
|
1606
|
-
var sFuncs = extractFromLine
|
1607
|
-
|
1608
|
-
|
1728
|
+
var sFuncs = extractFromLine.filter(function (f) { return core_imports_1._.isString(f); });
|
1729
|
+
if (sFuncs.filter(function (f) { return singleLine.search(f) !== -1; })
|
1730
|
+
.length === sFuncs.length) {
|
1609
1731
|
var fun = extractFromLine.find(function (f) { return core_imports_1._.isFunction(f); });
|
1610
1732
|
if (fun) {
|
1611
1733
|
var s_1 = singleLine;
|
1612
|
-
sFuncs.forEach(function (f) {
|
1734
|
+
sFuncs.forEach(function (f) {
|
1735
|
+
s_1 = s_1.replace(f, '');
|
1736
|
+
});
|
1613
1737
|
fun(s_1.trim());
|
1614
1738
|
}
|
1615
1739
|
}
|
1616
1740
|
}
|
1617
1741
|
return "".concat(prefix, " ").concat(singleLine);
|
1618
|
-
})
|
1742
|
+
})
|
1743
|
+
.join('\n');
|
1619
1744
|
}
|
1620
1745
|
return data;
|
1621
1746
|
};
|
@@ -1656,8 +1781,9 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1656
1781
|
* @deprecated
|
1657
1782
|
*/
|
1658
1783
|
HelpersCore.prototype.isFile = function (pathToFileOrMaybeFolder) {
|
1659
|
-
return
|
1660
|
-
|
1784
|
+
return (pathToFileOrMaybeFolder &&
|
1785
|
+
core_imports_1.fse.existsSync(pathToFileOrMaybeFolder) &&
|
1786
|
+
!core_imports_1.fse.lstatSync(pathToFileOrMaybeFolder).isDirectory());
|
1661
1787
|
};
|
1662
1788
|
//#endregion
|
1663
1789
|
//#endregion
|
@@ -1695,8 +1821,8 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1695
1821
|
});
|
1696
1822
|
};
|
1697
1823
|
/**
|
1698
|
-
|
1699
|
-
|
1824
|
+
* wrapper for fs.readFileSync
|
1825
|
+
*/
|
1700
1826
|
HelpersCore.prototype.readFile = function (absoluteFilePath, // @ts-ignore
|
1701
1827
|
defaultValueWhenNotExists, notTrim) {
|
1702
1828
|
if (defaultValueWhenNotExists === void 0) { defaultValueWhenNotExists = void 0; }
|
@@ -1712,13 +1838,18 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1712
1838
|
return defaultValueWhenNotExists;
|
1713
1839
|
}
|
1714
1840
|
if (notTrim) {
|
1715
|
-
return core_imports_1.fse
|
1716
|
-
|
1717
|
-
|
1841
|
+
return core_imports_1.fse
|
1842
|
+
.readFileSync(absoluteFilePath, {
|
1843
|
+
encoding: encoding,
|
1844
|
+
})
|
1845
|
+
.toString();
|
1718
1846
|
}
|
1719
|
-
return core_imports_1.fse
|
1720
|
-
|
1721
|
-
|
1847
|
+
return core_imports_1.fse
|
1848
|
+
.readFileSync(absoluteFilePath, {
|
1849
|
+
encoding: encoding,
|
1850
|
+
})
|
1851
|
+
.toString()
|
1852
|
+
.trim();
|
1722
1853
|
};
|
1723
1854
|
//#endregion
|
1724
1855
|
//#endregion
|
@@ -1814,9 +1945,9 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1814
1945
|
/**
|
1815
1946
|
* wrapper for fs.writeFileSync
|
1816
1947
|
*/
|
1817
|
-
HelpersCore.prototype.writeFile = function (absoluteFilePath, input
|
1948
|
+
HelpersCore.prototype.writeFile = function (absoluteFilePath, input,
|
1818
1949
|
//#endregion
|
1819
|
-
|
1950
|
+
options) {
|
1820
1951
|
if (core_imports_1._.isArray(absoluteFilePath)) {
|
1821
1952
|
absoluteFilePath = core_imports_1.path.join.apply(this, absoluteFilePath);
|
1822
1953
|
}
|
@@ -1826,12 +1957,19 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1826
1957
|
if (index_1.Helpers.isExistedSymlink(absoluteFilePath)) {
|
1827
1958
|
var beforePath = absoluteFilePath;
|
1828
1959
|
absoluteFilePath = core_imports_1.fse.realpathSync(absoluteFilePath);
|
1829
|
-
|
1960
|
+
// Helpers.logWarn(
|
1961
|
+
// `[firedev-core] WRITTING JSON into real path:
|
1962
|
+
// original: ${beforePath}
|
1963
|
+
// real : ${absoluteFilePath}
|
1964
|
+
// `,
|
1965
|
+
// forceTrace,
|
1966
|
+
// );
|
1830
1967
|
}
|
1831
1968
|
var _a = options || {}, preventParentFile = _a.preventParentFile, overrideSameFile = _a.overrideSameFile;
|
1832
1969
|
var dontWriteSameFile = !overrideSameFile;
|
1833
1970
|
if (preventParentFile) {
|
1834
|
-
if (index_1.Helpers.isFile(core_imports_1.path.dirname(absoluteFilePath)) &&
|
1971
|
+
if (index_1.Helpers.isFile(core_imports_1.path.dirname(absoluteFilePath)) &&
|
1972
|
+
core_imports_1.fse.existsSync(core_imports_1.path.dirname(absoluteFilePath))) {
|
1835
1973
|
core_imports_1.fse.unlinkSync(core_imports_1.path.dirname(absoluteFilePath));
|
1836
1974
|
}
|
1837
1975
|
}
|
@@ -1858,7 +1996,7 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1858
1996
|
}
|
1859
1997
|
}
|
1860
1998
|
core_imports_1.fse.writeFileSync(absoluteFilePath, input, {
|
1861
|
-
encoding: encoding
|
1999
|
+
encoding: encoding,
|
1862
2000
|
});
|
1863
2001
|
return true;
|
1864
2002
|
};
|
@@ -1876,7 +2014,8 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1876
2014
|
absoluteFilePath = absoluteFilePath;
|
1877
2015
|
var _a = optoins || {}, preventParentFile = _a.preventParentFile, writeJson5 = _a.writeJson5;
|
1878
2016
|
if (preventParentFile) {
|
1879
|
-
if (index_1.Helpers.isFile(core_imports_1.path.dirname(absoluteFilePath)) &&
|
2017
|
+
if (index_1.Helpers.isFile(core_imports_1.path.dirname(absoluteFilePath)) &&
|
2018
|
+
core_imports_1.fse.existsSync(core_imports_1.path.dirname(absoluteFilePath))) {
|
1880
2019
|
core_imports_1.fse.unlinkSync(core_imports_1.path.dirname(absoluteFilePath));
|
1881
2020
|
}
|
1882
2021
|
}
|
@@ -1896,13 +2035,13 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1896
2035
|
index_1.Helpers.writeFile(absoluteFilePath, this.removeEmptyLineFromString(writer.toSource({
|
1897
2036
|
quote: 'double',
|
1898
2037
|
trailingComma: false,
|
1899
|
-
quoteKeys: true
|
2038
|
+
quoteKeys: true,
|
1900
2039
|
})));
|
1901
2040
|
}
|
1902
2041
|
else {
|
1903
2042
|
core_imports_1.fse.writeJSONSync(absoluteFilePath, input, {
|
1904
2043
|
encoding: encoding,
|
1905
|
-
spaces: 2
|
2044
|
+
spaces: 2,
|
1906
2045
|
});
|
1907
2046
|
}
|
1908
2047
|
return true;
|
@@ -1935,8 +2074,8 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1935
2074
|
try {
|
1936
2075
|
for (var files_1 = tslib_1.__values(files), files_1_1 = files_1.next(); !files_1_1.done; files_1_1 = files_1.next()) {
|
1937
2076
|
var file = files_1_1.value;
|
1938
|
-
if (file.isDirectory()
|
1939
|
-
|
2077
|
+
if (file.isDirectory() &&
|
2078
|
+
!index_1.Helpers.isSymlinkFileExitedOrUnexisted([folderPath, file.name])) {
|
1940
2079
|
var dirPath = (0, core_imports_1.crossPlatformPath)([folderPath, file.name]);
|
1941
2080
|
// console.log('dirPath', dirPath)
|
1942
2081
|
directories.push(dirPath);
|
@@ -1978,7 +2117,8 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1978
2117
|
if (!index_1.Helpers.exists(pathToFolder)) {
|
1979
2118
|
return [];
|
1980
2119
|
}
|
1981
|
-
return core_imports_1.fse
|
2120
|
+
return (core_imports_1.fse
|
2121
|
+
.readdirSync(pathToFolder)
|
1982
2122
|
.map(function (f) { return core_imports_1.path.join(pathToFolder, f); })
|
1983
2123
|
.filter(function (f) { return core_imports_1.fse.existsSync(f) && core_imports_1.fse.lstatSync(f).isSymbolicLink(); })
|
1984
2124
|
.map(function (f) {
|
@@ -1992,9 +2132,10 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1992
2132
|
return f;
|
1993
2133
|
}
|
1994
2134
|
}
|
1995
|
-
})
|
2135
|
+
})
|
2136
|
+
.filter(function (f) { return !!f; })
|
1996
2137
|
// @ts-ignore
|
1997
|
-
.map(function (f) { return (0, core_imports_1.crossPlatformPath)(f); });
|
2138
|
+
.map(function (f) { return (0, core_imports_1.crossPlatformPath)(f); }));
|
1998
2139
|
};
|
1999
2140
|
//#endregion
|
2000
2141
|
//#endregion
|
@@ -2014,7 +2155,8 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
2014
2155
|
if (!index_1.Helpers.exists(pathToFolder)) {
|
2015
2156
|
return [];
|
2016
2157
|
}
|
2017
|
-
return core_imports_1.fse
|
2158
|
+
return core_imports_1.fse
|
2159
|
+
.readdirSync(pathToFolder)
|
2018
2160
|
.map(function (f) { return core_imports_1.path.join(pathToFolder, f); })
|
2019
2161
|
.filter(function (f) {
|
2020
2162
|
var res = false;
|
@@ -2047,7 +2189,8 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
2047
2189
|
return core_imports_1.glob.sync("".concat(pathToFolder, "/**/*.*"));
|
2048
2190
|
}
|
2049
2191
|
if (recrusive) {
|
2050
|
-
var all = core_imports_1.fse
|
2192
|
+
var all = core_imports_1.fse
|
2193
|
+
.readdirSync(pathToFolder)
|
2051
2194
|
.map(function (f) { return core_imports_1.path.join(pathToFolder, f); });
|
2052
2195
|
var folders_1 = [];
|
2053
2196
|
var files = all.filter(function (f) {
|
@@ -2063,7 +2206,8 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
2063
2206
|
return a.concat(b);
|
2064
2207
|
}, [])), false).map(function (f) { return (0, core_imports_1.crossPlatformPath)(f); });
|
2065
2208
|
}
|
2066
|
-
return core_imports_1.fse
|
2209
|
+
return core_imports_1.fse
|
2210
|
+
.readdirSync(pathToFolder)
|
2067
2211
|
.map(function (f) { return (0, core_imports_1.crossPlatformPath)(core_imports_1.path.join(pathToFolder, f)); })
|
2068
2212
|
.filter(function (f) {
|
2069
2213
|
return !core_imports_1.fse.lstatSync(f).isDirectory();
|