tnp-core 16.100.20 → 16.100.22
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 -81
- 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 +288 -25
- 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 +479 -144
- 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 +172 -164
- package/browser/lib/helpers.d.ts +4 -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 -81
- 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 +288 -25
- 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 +479 -144
- 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 +172 -164
- package/client/lib/helpers.d.ts +4 -3
- package/client/lib/utils.d.ts +1 -1
- package/client/package.json +41 -30
- 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 +172 -164
- package/lib/core-models.js +92 -80
- 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 +11 -10
- package/lib/helpers.js +247 -116
- 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 +45 -34
- 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 -81
- 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 +288 -27
- 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 +479 -146
- 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 +172 -164
- package/websql/lib/helpers.d.ts +4 -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
|
@@ -993,13 +1032,15 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
993
1032
|
* start command as synchronous nodej proces
|
994
1033
|
*/
|
995
1034
|
sync: function () {
|
1035
|
+
// TODO buffer
|
996
1036
|
//#region @backendFunc
|
997
1037
|
// @ts-ignore
|
998
1038
|
if (core_imports_1._.isArray(options.extractFromLine)) {
|
999
1039
|
index_1.Helpers.error("[tnp-helper] extractFromLine only for:\n - asyncAsPromise\n - async\n - unitlOutputContains\n\n ", false, true);
|
1000
1040
|
}
|
1001
1041
|
// @ts-ignore
|
1002
|
-
if (core_imports_1._.isNumber(options.tryAgainWhenFailAfter) &&
|
1042
|
+
if (core_imports_1._.isNumber(options.tryAgainWhenFailAfter) &&
|
1043
|
+
options.tryAgainWhenFailAfter > 0) {
|
1003
1044
|
// TODO try again when fail
|
1004
1045
|
// try {
|
1005
1046
|
var proc = index_1.Helpers.runSyncIn(command, options);
|
@@ -1017,6 +1058,7 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1017
1058
|
* @param detach (default: false) - if true process will be detached
|
1018
1059
|
*/
|
1019
1060
|
async: function (detach) {
|
1061
|
+
//#region websqlFunc
|
1020
1062
|
//#region mock of process
|
1021
1063
|
/* */
|
1022
1064
|
/* */
|
@@ -1106,6 +1148,16 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1106
1148
|
/* */
|
1107
1149
|
/* */
|
1108
1150
|
/* */
|
1151
|
+
/* */
|
1152
|
+
/* */
|
1153
|
+
/* */
|
1154
|
+
/* */
|
1155
|
+
/* */
|
1156
|
+
/* */
|
1157
|
+
/* */
|
1158
|
+
/* */
|
1159
|
+
/* */
|
1160
|
+
/* */
|
1109
1161
|
if (detach === void 0) { detach = false; }
|
1110
1162
|
//#endregion
|
1111
1163
|
//#region @backendFunc
|
@@ -1163,7 +1215,7 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1163
1215
|
if (!isResolved && core_imports_1._.isArray(stderMsg)) {
|
1164
1216
|
for (var index = 0; index < stderMsg.length; index++) {
|
1165
1217
|
var rejectm = stderMsg[index];
|
1166
|
-
if (
|
1218
|
+
if (data.search(rejectm) !== -1) {
|
1167
1219
|
index_1.Helpers.info("[unitlOutputContains] Rejected move to next step...");
|
1168
1220
|
isResolved = true;
|
1169
1221
|
setTimeout(function () {
|
@@ -1181,8 +1233,9 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1181
1233
|
if (isResolved) {
|
1182
1234
|
for (var index = 0; index < stdoutMsg.length; index++) {
|
1183
1235
|
var m = stdoutMsg[index];
|
1184
|
-
if (
|
1185
|
-
stdoutOutputContainsCallback &&
|
1236
|
+
if (data.search(m) !== -1) {
|
1237
|
+
stdoutOutputContainsCallback &&
|
1238
|
+
stdoutOutputContainsCallback();
|
1186
1239
|
break;
|
1187
1240
|
}
|
1188
1241
|
}
|
@@ -1190,9 +1243,10 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1190
1243
|
else {
|
1191
1244
|
for (var index = 0; index < stdoutMsg.length; index++) {
|
1192
1245
|
var m = stdoutMsg[index];
|
1193
|
-
if (
|
1246
|
+
if (data.search(m) !== -1) {
|
1194
1247
|
index_1.Helpers.info("[unitlOutputContains] Move to next step...");
|
1195
|
-
stdoutOutputContainsCallback &&
|
1248
|
+
stdoutOutputContainsCallback &&
|
1249
|
+
stdoutOutputContainsCallback();
|
1196
1250
|
isResolved = true;
|
1197
1251
|
setTimeout(function () {
|
1198
1252
|
resolve(void 0);
|
@@ -1204,7 +1258,7 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1204
1258
|
if (!isResolved && core_imports_1._.isArray(stderMsg)) {
|
1205
1259
|
for (var index = 0; index < stderMsg.length; index++) {
|
1206
1260
|
var rejectm = stderMsg[index];
|
1207
|
-
if (
|
1261
|
+
if (data.search(rejectm) !== -1) {
|
1208
1262
|
index_1.Helpers.info("[unitlOutputContains] Rejected move to next step...");
|
1209
1263
|
isResolved = true;
|
1210
1264
|
setTimeout(function () {
|
@@ -1218,7 +1272,7 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1218
1272
|
});
|
1219
1273
|
});
|
1220
1274
|
//#endregion
|
1221
|
-
}
|
1275
|
+
},
|
1222
1276
|
};
|
1223
1277
|
};
|
1224
1278
|
//#endregion
|
@@ -1236,7 +1290,7 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1236
1290
|
switch (_a.label) {
|
1237
1291
|
case 0:
|
1238
1292
|
response = {
|
1239
|
-
value: defaultValue
|
1293
|
+
value: defaultValue,
|
1240
1294
|
};
|
1241
1295
|
if (!(global.tnpNonInteractive && !mustAnswerQuestion)) return [3 /*break*/, 1];
|
1242
1296
|
index_1.Helpers.info("".concat(message, " - AUTORESPONSE: ").concat(defaultValue ? 'YES' : 'NO'));
|
@@ -1247,7 +1301,7 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1247
1301
|
message: message,
|
1248
1302
|
initial: defaultValue,
|
1249
1303
|
active: 'yes',
|
1250
|
-
inactive: 'no'
|
1304
|
+
inactive: 'no',
|
1251
1305
|
})];
|
1252
1306
|
case 2:
|
1253
1307
|
response = _a.sent();
|
@@ -1275,15 +1329,17 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1275
1329
|
//#region methods / get stdio
|
1276
1330
|
//#region @backend
|
1277
1331
|
HelpersCore.prototype.getStdio = function (options) {
|
1278
|
-
var
|
1279
|
-
|
1280
|
-
|
1281
|
-
// inheritFromParentProcerss = false
|
1282
|
-
;
|
1332
|
+
var
|
1333
|
+
// @ts-ignore
|
1334
|
+
output = options.output, silence = options.silence, stdio = options.stdio;
|
1283
1335
|
if (typeof stdio !== 'undefined') {
|
1284
1336
|
return stdio;
|
1285
1337
|
}
|
1286
|
-
var resstdio = output
|
1338
|
+
var resstdio = output
|
1339
|
+
? [0, 1, 2]
|
1340
|
+
: core_imports_1._.isBoolean(silence) && silence
|
1341
|
+
? 'ignore'
|
1342
|
+
: undefined;
|
1287
1343
|
// if (pipeToParentProcerss) {
|
1288
1344
|
// stdio = ['pipe', 'pipe', 'pipe'] as any;
|
1289
1345
|
// }
|
@@ -1407,12 +1463,12 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1407
1463
|
};
|
1408
1464
|
HelpersCore.prototype.execute = function (command, cwd, options) {
|
1409
1465
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
1410
|
-
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;
|
1411
1467
|
var _this = this;
|
1412
1468
|
return tslib_1.__generator(this, function (_b) {
|
1413
1469
|
switch (_b.label) {
|
1414
1470
|
case 0:
|
1415
|
-
_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;
|
1416
1472
|
//#endregion
|
1417
1473
|
command = index_1.Helpers._fixCommand(command);
|
1418
1474
|
// let {
|
@@ -1435,18 +1491,49 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1435
1491
|
}
|
1436
1492
|
handlProc = function (proc) {
|
1437
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
|
+
// : [];
|
1438
1513
|
//#region handle stdout data
|
1439
1514
|
proc.stdout.on('data', function (rawData) {
|
1440
|
-
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
|
+
// }
|
1441
1526
|
data = index_1.Helpers.modifyLineByLine(data, // @ts-ignore
|
1442
1527
|
outputLineReplace, prefix, extractFromLine);
|
1443
1528
|
if (!hideOutput.stdout) {
|
1444
1529
|
process.stdout.write(data);
|
1445
1530
|
}
|
1446
|
-
if (!isResolved && core_imports_1._.isArray(resolvePromiseMsg.stdout)) {
|
1447
|
-
|
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
|
1448
1535
|
var m = resolvePromiseMsg.stdout[index];
|
1449
|
-
if (
|
1536
|
+
if (data.search(m) !== -1) {
|
1450
1537
|
// Helpers.info(`[unitlOutputContains] Move to next step...`)
|
1451
1538
|
isResolved = true;
|
1452
1539
|
resolve(void 0);
|
@@ -1454,10 +1541,12 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1454
1541
|
}
|
1455
1542
|
}
|
1456
1543
|
}
|
1457
|
-
if (!isResolved && core_imports_1._.isArray(resolvePromiseMsg.stderr)) {
|
1458
|
-
|
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
|
1459
1548
|
var rejectm = resolvePromiseMsg.stderr[index];
|
1460
|
-
if (
|
1549
|
+
if (data.search(rejectm) !== -1) {
|
1461
1550
|
// Helpers.info(`[unitlOutputContains] Rejected move to next step...`);
|
1462
1551
|
isResolved = true;
|
1463
1552
|
reject();
|
@@ -1510,7 +1599,17 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1510
1599
|
//#endregion
|
1511
1600
|
//#region handle stdout error
|
1512
1601
|
proc.stdout.on('error', function (rawData) {
|
1513
|
-
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
|
+
// }
|
1514
1613
|
data = index_1.Helpers.modifyLineByLine(data, // @ts-ignore
|
1515
1614
|
outputLineReplace, prefix, extractFromLine);
|
1516
1615
|
if (!hideOutput.stdout) {
|
@@ -1521,16 +1620,18 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1521
1620
|
//#endregion
|
1522
1621
|
//#region handle stder data
|
1523
1622
|
proc.stderr.on('data', function (rawData) {
|
1524
|
-
var data = (
|
1623
|
+
var data = (rawData === null || rawData === void 0 ? void 0 : rawData.toString()) || '';
|
1525
1624
|
data = index_1.Helpers.modifyLineByLine(data, // @ts-ignore
|
1526
1625
|
outputLineReplace, prefix, extractFromLine);
|
1527
1626
|
if (!hideOutput.stderr) {
|
1528
1627
|
process.stderr.write(data);
|
1529
1628
|
}
|
1530
|
-
if (!isResolved && core_imports_1._.isArray(resolvePromiseMsg.stderr)) {
|
1531
|
-
|
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
|
1532
1633
|
var rejectm = resolvePromiseMsg.stderr[index];
|
1533
|
-
if (
|
1634
|
+
if (data.search(rejectm) !== -1) {
|
1534
1635
|
// Helpers.info(`[unitlOutputContains] Rejected move to next step...`);
|
1535
1636
|
isResolved = true;
|
1536
1637
|
reject();
|
@@ -1543,7 +1644,7 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1543
1644
|
//#endregion
|
1544
1645
|
//#region handle stder error
|
1545
1646
|
proc.stderr.on('error', function (rawData) {
|
1546
|
-
var data = (
|
1647
|
+
var data = (rawData === null || rawData === void 0 ? void 0 : rawData.toString()) || '';
|
1547
1648
|
data = index_1.Helpers.modifyLineByLine(data, // @ts-ignore
|
1548
1649
|
outputLineReplace, prefix, extractFromLine);
|
1549
1650
|
// @ts-ignore
|
@@ -1604,31 +1705,42 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1604
1705
|
//#region methods / modify line by line
|
1605
1706
|
//#region @backend
|
1606
1707
|
HelpersCore.prototype.modifyLineByLine = function (data, outputLineReplace, prefix, extractFromLine) {
|
1607
|
-
var checkExtract =
|
1708
|
+
var checkExtract = core_imports_1._.isArray(extractFromLine) && extractFromLine.length > 0;
|
1608
1709
|
var modifyOutput = core_imports_1._.isFunction(outputLineReplace);
|
1609
1710
|
if (modifyOutput && core_imports_1._.isString(data)) {
|
1610
|
-
data = data
|
1611
|
-
|
1711
|
+
data = data
|
1712
|
+
.split(/\r?\n/)
|
1713
|
+
.map(function (line) {
|
1714
|
+
return outputLineReplace(line);
|
1715
|
+
})
|
1716
|
+
.join('\n');
|
1612
1717
|
}
|
1613
1718
|
if (prefix && core_imports_1._.isString(data)) {
|
1614
|
-
return data
|
1615
|
-
|
1719
|
+
return data
|
1720
|
+
.split('\n')
|
1721
|
+
.map(function (singleLine) {
|
1722
|
+
if (!singleLine ||
|
1723
|
+
singleLine.trim().length === 0 ||
|
1724
|
+
singleLine.trim() === '.') {
|
1616
1725
|
return singleLine;
|
1617
1726
|
}
|
1618
1727
|
if (checkExtract) {
|
1619
|
-
var sFuncs = extractFromLine
|
1620
|
-
|
1621
|
-
|
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) {
|
1622
1731
|
var fun = extractFromLine.find(function (f) { return core_imports_1._.isFunction(f); });
|
1623
1732
|
if (fun) {
|
1624
1733
|
var s_1 = singleLine;
|
1625
|
-
sFuncs.forEach(function (f) {
|
1734
|
+
sFuncs.forEach(function (f) {
|
1735
|
+
s_1 = s_1.replace(f, '');
|
1736
|
+
});
|
1626
1737
|
fun(s_1.trim());
|
1627
1738
|
}
|
1628
1739
|
}
|
1629
1740
|
}
|
1630
1741
|
return "".concat(prefix, " ").concat(singleLine);
|
1631
|
-
})
|
1742
|
+
})
|
1743
|
+
.join('\n');
|
1632
1744
|
}
|
1633
1745
|
return data;
|
1634
1746
|
};
|
@@ -1669,8 +1781,9 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1669
1781
|
* @deprecated
|
1670
1782
|
*/
|
1671
1783
|
HelpersCore.prototype.isFile = function (pathToFileOrMaybeFolder) {
|
1672
|
-
return
|
1673
|
-
|
1784
|
+
return (pathToFileOrMaybeFolder &&
|
1785
|
+
core_imports_1.fse.existsSync(pathToFileOrMaybeFolder) &&
|
1786
|
+
!core_imports_1.fse.lstatSync(pathToFileOrMaybeFolder).isDirectory());
|
1674
1787
|
};
|
1675
1788
|
//#endregion
|
1676
1789
|
//#endregion
|
@@ -1708,8 +1821,8 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1708
1821
|
});
|
1709
1822
|
};
|
1710
1823
|
/**
|
1711
|
-
|
1712
|
-
|
1824
|
+
* wrapper for fs.readFileSync
|
1825
|
+
*/
|
1713
1826
|
HelpersCore.prototype.readFile = function (absoluteFilePath, // @ts-ignore
|
1714
1827
|
defaultValueWhenNotExists, notTrim) {
|
1715
1828
|
if (defaultValueWhenNotExists === void 0) { defaultValueWhenNotExists = void 0; }
|
@@ -1725,13 +1838,18 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1725
1838
|
return defaultValueWhenNotExists;
|
1726
1839
|
}
|
1727
1840
|
if (notTrim) {
|
1728
|
-
return core_imports_1.fse
|
1729
|
-
|
1730
|
-
|
1841
|
+
return core_imports_1.fse
|
1842
|
+
.readFileSync(absoluteFilePath, {
|
1843
|
+
encoding: encoding,
|
1844
|
+
})
|
1845
|
+
.toString();
|
1731
1846
|
}
|
1732
|
-
return core_imports_1.fse
|
1733
|
-
|
1734
|
-
|
1847
|
+
return core_imports_1.fse
|
1848
|
+
.readFileSync(absoluteFilePath, {
|
1849
|
+
encoding: encoding,
|
1850
|
+
})
|
1851
|
+
.toString()
|
1852
|
+
.trim();
|
1735
1853
|
};
|
1736
1854
|
//#endregion
|
1737
1855
|
//#endregion
|
@@ -1827,9 +1945,9 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1827
1945
|
/**
|
1828
1946
|
* wrapper for fs.writeFileSync
|
1829
1947
|
*/
|
1830
|
-
HelpersCore.prototype.writeFile = function (absoluteFilePath, input
|
1948
|
+
HelpersCore.prototype.writeFile = function (absoluteFilePath, input,
|
1831
1949
|
//#endregion
|
1832
|
-
|
1950
|
+
options) {
|
1833
1951
|
if (core_imports_1._.isArray(absoluteFilePath)) {
|
1834
1952
|
absoluteFilePath = core_imports_1.path.join.apply(this, absoluteFilePath);
|
1835
1953
|
}
|
@@ -1839,12 +1957,19 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1839
1957
|
if (index_1.Helpers.isExistedSymlink(absoluteFilePath)) {
|
1840
1958
|
var beforePath = absoluteFilePath;
|
1841
1959
|
absoluteFilePath = core_imports_1.fse.realpathSync(absoluteFilePath);
|
1842
|
-
|
1960
|
+
// Helpers.logWarn(
|
1961
|
+
// `[firedev-core] WRITTING JSON into real path:
|
1962
|
+
// original: ${beforePath}
|
1963
|
+
// real : ${absoluteFilePath}
|
1964
|
+
// `,
|
1965
|
+
// forceTrace,
|
1966
|
+
// );
|
1843
1967
|
}
|
1844
1968
|
var _a = options || {}, preventParentFile = _a.preventParentFile, overrideSameFile = _a.overrideSameFile;
|
1845
1969
|
var dontWriteSameFile = !overrideSameFile;
|
1846
1970
|
if (preventParentFile) {
|
1847
|
-
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))) {
|
1848
1973
|
core_imports_1.fse.unlinkSync(core_imports_1.path.dirname(absoluteFilePath));
|
1849
1974
|
}
|
1850
1975
|
}
|
@@ -1871,7 +1996,7 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1871
1996
|
}
|
1872
1997
|
}
|
1873
1998
|
core_imports_1.fse.writeFileSync(absoluteFilePath, input, {
|
1874
|
-
encoding: encoding
|
1999
|
+
encoding: encoding,
|
1875
2000
|
});
|
1876
2001
|
return true;
|
1877
2002
|
};
|
@@ -1889,7 +2014,8 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1889
2014
|
absoluteFilePath = absoluteFilePath;
|
1890
2015
|
var _a = optoins || {}, preventParentFile = _a.preventParentFile, writeJson5 = _a.writeJson5;
|
1891
2016
|
if (preventParentFile) {
|
1892
|
-
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))) {
|
1893
2019
|
core_imports_1.fse.unlinkSync(core_imports_1.path.dirname(absoluteFilePath));
|
1894
2020
|
}
|
1895
2021
|
}
|
@@ -1909,13 +2035,13 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1909
2035
|
index_1.Helpers.writeFile(absoluteFilePath, this.removeEmptyLineFromString(writer.toSource({
|
1910
2036
|
quote: 'double',
|
1911
2037
|
trailingComma: false,
|
1912
|
-
quoteKeys: true
|
2038
|
+
quoteKeys: true,
|
1913
2039
|
})));
|
1914
2040
|
}
|
1915
2041
|
else {
|
1916
2042
|
core_imports_1.fse.writeJSONSync(absoluteFilePath, input, {
|
1917
2043
|
encoding: encoding,
|
1918
|
-
spaces: 2
|
2044
|
+
spaces: 2,
|
1919
2045
|
});
|
1920
2046
|
}
|
1921
2047
|
return true;
|
@@ -1948,8 +2074,8 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1948
2074
|
try {
|
1949
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()) {
|
1950
2076
|
var file = files_1_1.value;
|
1951
|
-
if (file.isDirectory()
|
1952
|
-
|
2077
|
+
if (file.isDirectory() &&
|
2078
|
+
!index_1.Helpers.isSymlinkFileExitedOrUnexisted([folderPath, file.name])) {
|
1953
2079
|
var dirPath = (0, core_imports_1.crossPlatformPath)([folderPath, file.name]);
|
1954
2080
|
// console.log('dirPath', dirPath)
|
1955
2081
|
directories.push(dirPath);
|
@@ -1991,7 +2117,8 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1991
2117
|
if (!index_1.Helpers.exists(pathToFolder)) {
|
1992
2118
|
return [];
|
1993
2119
|
}
|
1994
|
-
return core_imports_1.fse
|
2120
|
+
return (core_imports_1.fse
|
2121
|
+
.readdirSync(pathToFolder)
|
1995
2122
|
.map(function (f) { return core_imports_1.path.join(pathToFolder, f); })
|
1996
2123
|
.filter(function (f) { return core_imports_1.fse.existsSync(f) && core_imports_1.fse.lstatSync(f).isSymbolicLink(); })
|
1997
2124
|
.map(function (f) {
|
@@ -2005,9 +2132,10 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
2005
2132
|
return f;
|
2006
2133
|
}
|
2007
2134
|
}
|
2008
|
-
})
|
2135
|
+
})
|
2136
|
+
.filter(function (f) { return !!f; })
|
2009
2137
|
// @ts-ignore
|
2010
|
-
.map(function (f) { return (0, core_imports_1.crossPlatformPath)(f); });
|
2138
|
+
.map(function (f) { return (0, core_imports_1.crossPlatformPath)(f); }));
|
2011
2139
|
};
|
2012
2140
|
//#endregion
|
2013
2141
|
//#endregion
|
@@ -2027,7 +2155,8 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
2027
2155
|
if (!index_1.Helpers.exists(pathToFolder)) {
|
2028
2156
|
return [];
|
2029
2157
|
}
|
2030
|
-
return core_imports_1.fse
|
2158
|
+
return core_imports_1.fse
|
2159
|
+
.readdirSync(pathToFolder)
|
2031
2160
|
.map(function (f) { return core_imports_1.path.join(pathToFolder, f); })
|
2032
2161
|
.filter(function (f) {
|
2033
2162
|
var res = false;
|
@@ -2060,7 +2189,8 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
2060
2189
|
return core_imports_1.glob.sync("".concat(pathToFolder, "/**/*.*"));
|
2061
2190
|
}
|
2062
2191
|
if (recrusive) {
|
2063
|
-
var all = core_imports_1.fse
|
2192
|
+
var all = core_imports_1.fse
|
2193
|
+
.readdirSync(pathToFolder)
|
2064
2194
|
.map(function (f) { return core_imports_1.path.join(pathToFolder, f); });
|
2065
2195
|
var folders_1 = [];
|
2066
2196
|
var files = all.filter(function (f) {
|
@@ -2076,7 +2206,8 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
2076
2206
|
return a.concat(b);
|
2077
2207
|
}, [])), false).map(function (f) { return (0, core_imports_1.crossPlatformPath)(f); });
|
2078
2208
|
}
|
2079
|
-
return core_imports_1.fse
|
2209
|
+
return core_imports_1.fse
|
2210
|
+
.readdirSync(pathToFolder)
|
2080
2211
|
.map(function (f) { return (0, core_imports_1.crossPlatformPath)(core_imports_1.path.join(pathToFolder, f)); })
|
2081
2212
|
.filter(function (f) {
|
2082
2213
|
return !core_imports_1.fse.lstatSync(f).isDirectory();
|