tnp-core 19.0.68 → 19.0.69
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/browser/fesm2022/tnp-core.mjs +1014 -156
- package/browser/fesm2022/tnp-core.mjs.map +1 -1
- package/browser/lib/helpers.d.ts +11 -0
- package/browser/lib/utils.d.ts +96 -20
- package/browser/package.json +1 -1
- package/cli.backend.js +2 -2
- package/lib/build-info._auto-generated_.d.ts +1 -1
- package/lib/build-info._auto-generated_.js +1 -1
- package/lib/core-cli.js +5 -5
- package/lib/core-cli.js.map +1 -1
- package/lib/env/env.angular-node-app.d.ts +1 -2
- package/lib/env/env.angular-node-app.js +3 -4
- package/lib/env/env.angular-node-app.js.map +1 -1
- package/lib/env/env.docs-webapp.d.ts +1 -2
- package/lib/env/env.docs-webapp.js +3 -4
- package/lib/env/env.docs-webapp.js.map +1 -1
- package/lib/env/env.electron-app.d.ts +1 -2
- package/lib/env/env.electron-app.js +3 -4
- package/lib/env/env.electron-app.js.map +1 -1
- package/lib/env/env.mobile-app.d.ts +1 -2
- package/lib/env/env.mobile-app.js +3 -4
- package/lib/env/env.mobile-app.js.map +1 -1
- package/lib/env/env.npm-lib-and-cli-tool.d.ts +1 -2
- package/lib/env/env.npm-lib-and-cli-tool.js +3 -4
- package/lib/env/env.npm-lib-and-cli-tool.js.map +1 -1
- package/lib/env/env.vscode-plugin.d.ts +1 -2
- package/lib/env/env.vscode-plugin.js +3 -4
- package/lib/env/env.vscode-plugin.js.map +1 -1
- package/lib/env.backend.d.ts +34 -0
- package/lib/env.backend.js +40 -0
- package/lib/env.backend.js.map +1 -0
- package/lib/env.browser.d.ts +34 -0
- package/lib/helpers-messages.js +3 -1
- package/lib/helpers-messages.js.map +1 -1
- package/lib/helpers.d.ts +12 -1
- package/lib/helpers.js +11 -0
- package/lib/helpers.js.map +1 -1
- package/lib/node-chalk-mock.js +2 -2
- package/lib/node-path-mock.js +2 -2
- package/lib/required.d.ts +44 -0
- package/lib/required.js +76 -0
- package/lib/required.js.map +1 -0
- package/lib/utils.d.ts +96 -20
- package/lib/utils.js +1032 -221
- package/lib/utils.js.map +1 -1
- package/package.json +2 -2
- package/tmp-environment.json +7 -11
- package/websql/fesm2022/tnp-core.mjs +1014 -156
- package/websql/fesm2022/tnp-core.mjs.map +1 -1
- package/websql/lib/helpers.d.ts +11 -0
- package/websql/lib/utils.d.ts +96 -20
- package/websql/package.json +1 -1
- package/browser/lib/command-exists.d.ts +0 -3
- package/env.d.ts +0 -2
- package/environments/angular-node-app/env.angular-node-app.__.d.ts +0 -3
- package/environments/angular-node-app/env.angular-node-app.dev.d.ts +0 -3
- package/environments/angular-node-app/env.angular-node-app.localhost.d.ts +0 -3
- package/environments/angular-node-app/env.angular-node-app.prod.d.ts +0 -3
- package/environments/angular-node-app/env.angular-node-app.stage.d.ts +0 -3
- package/environments/docs-webapp/env.docs-webapp.__.d.ts +0 -3
- package/environments/electron-app/env.electron-app.__.d.ts +0 -3
- package/environments/electron-app/env.electron-app.prod.d.ts +0 -3
- package/environments/mobile-app/env.mobile-app.__.d.ts +0 -3
- package/environments/mobile-app/env.mobile-app.prod.d.ts +0 -3
- package/environments/npm-lib-and-cli-tool/env.npm-lib-and-cli-tool.__.d.ts +0 -3
- package/environments/npm-lib-and-cli-tool/env.npm-lib-and-cli-tool.prod.d.ts +0 -3
- package/environments/vscode-plugin/env.vscode-plugin.__.d.ts +0 -6
- package/environments/vscode-plugin/env.vscode-plugin.prod.d.ts +0 -4
- package/websql/lib/command-exists.d.ts +0 -3
|
@@ -1020,7 +1020,11 @@ var Utils;
|
|
|
1020
1020
|
* Example:
|
|
1021
1021
|
* new RegExp(escapeStringForRegEx('a.b.c'),'g') => /a\.b\.c/g
|
|
1022
1022
|
*/
|
|
1023
|
-
Utils.escapeStringForRegEx = (stringForRegExp) => {
|
|
1023
|
+
Utils.escapeStringForRegEx = (stringForRegExp, options) => {
|
|
1024
|
+
options = options || {};
|
|
1025
|
+
if (options?.skipEscapeSlashAndDash) {
|
|
1026
|
+
return stringForRegExp.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
1027
|
+
}
|
|
1024
1028
|
return stringForRegExp.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
1025
1029
|
};
|
|
1026
1030
|
//#endregion
|
|
@@ -2324,6 +2328,78 @@ var UtilsProcess;
|
|
|
2324
2328
|
return (void 0);
|
|
2325
2329
|
};
|
|
2326
2330
|
//#endregion
|
|
2331
|
+
//#region utils process / kill all other node processes except itself
|
|
2332
|
+
/**
|
|
2333
|
+
* Kills all Node.js processes except the current process.
|
|
2334
|
+
* Works on Windows, macOS, and Linux.
|
|
2335
|
+
* @returns {number} Number of processes killed
|
|
2336
|
+
*/
|
|
2337
|
+
UtilsProcess.killAllOtherNodeProcesses = async () => {
|
|
2338
|
+
/* */
|
|
2339
|
+
/* */
|
|
2340
|
+
/* */
|
|
2341
|
+
/* */
|
|
2342
|
+
/* */
|
|
2343
|
+
/* */
|
|
2344
|
+
/* */
|
|
2345
|
+
/* */
|
|
2346
|
+
/* */
|
|
2347
|
+
/* */
|
|
2348
|
+
/* */
|
|
2349
|
+
/* */
|
|
2350
|
+
/* */
|
|
2351
|
+
/* */
|
|
2352
|
+
/* */
|
|
2353
|
+
/* */
|
|
2354
|
+
/* */
|
|
2355
|
+
/* */
|
|
2356
|
+
/* */
|
|
2357
|
+
/* */
|
|
2358
|
+
/* */
|
|
2359
|
+
/* */
|
|
2360
|
+
/* */
|
|
2361
|
+
/* */
|
|
2362
|
+
/* */
|
|
2363
|
+
/* */
|
|
2364
|
+
/* */
|
|
2365
|
+
/* */
|
|
2366
|
+
/* */
|
|
2367
|
+
/* */
|
|
2368
|
+
/* */
|
|
2369
|
+
/* */
|
|
2370
|
+
/* */
|
|
2371
|
+
/* */
|
|
2372
|
+
/* */
|
|
2373
|
+
/* */
|
|
2374
|
+
/* */
|
|
2375
|
+
/* */
|
|
2376
|
+
/* */
|
|
2377
|
+
/* */
|
|
2378
|
+
/* */
|
|
2379
|
+
/* */
|
|
2380
|
+
/* */
|
|
2381
|
+
/* */
|
|
2382
|
+
/* */
|
|
2383
|
+
/* */
|
|
2384
|
+
/* */
|
|
2385
|
+
/* */
|
|
2386
|
+
/* */
|
|
2387
|
+
/* */
|
|
2388
|
+
/* */
|
|
2389
|
+
/* */
|
|
2390
|
+
/* */
|
|
2391
|
+
/* */
|
|
2392
|
+
/* */
|
|
2393
|
+
/* */
|
|
2394
|
+
/* */
|
|
2395
|
+
/* */
|
|
2396
|
+
/* */
|
|
2397
|
+
/* */
|
|
2398
|
+
/* */
|
|
2399
|
+
return (void 0);
|
|
2400
|
+
};
|
|
2401
|
+
//#endregion
|
|
2402
|
+
//#region utils process / is node version ok
|
|
2327
2403
|
UtilsProcess.isNodeVersionOk = (options) => {
|
|
2328
2404
|
if (!globalThis || !globalThis.process || !globalThis.process.version) {
|
|
2329
2405
|
return false;
|
|
@@ -2349,8 +2425,221 @@ var UtilsProcess;
|
|
|
2349
2425
|
}
|
|
2350
2426
|
return ok;
|
|
2351
2427
|
};
|
|
2428
|
+
//#endregion
|
|
2352
2429
|
})(UtilsProcess || (UtilsProcess = {}));
|
|
2353
2430
|
//#endregion
|
|
2431
|
+
//#region TODO IN_PROGRESS utils exec process
|
|
2432
|
+
/**
|
|
2433
|
+
* ! TODO @LAST @IN_PROGRESS
|
|
2434
|
+
* - async process execution utils
|
|
2435
|
+
* - export when ready
|
|
2436
|
+
* - should be ready for everything async refactor
|
|
2437
|
+
*/
|
|
2438
|
+
var UtilsExecProc;
|
|
2439
|
+
(function (UtilsExecProc) {
|
|
2440
|
+
/**
|
|
2441
|
+
* ! TODO @IN_PROGRESS implement all options and test
|
|
2442
|
+
*/
|
|
2443
|
+
class ExecProcResult {
|
|
2444
|
+
constructor(child, command) {
|
|
2445
|
+
this.child = child;
|
|
2446
|
+
this.command = command;
|
|
2447
|
+
}
|
|
2448
|
+
async waitUntilDoneOrThrow(options) {
|
|
2449
|
+
/* */
|
|
2450
|
+
/* */
|
|
2451
|
+
/* */
|
|
2452
|
+
/* */
|
|
2453
|
+
/* */
|
|
2454
|
+
/* */
|
|
2455
|
+
/* */
|
|
2456
|
+
/* */
|
|
2457
|
+
/* */
|
|
2458
|
+
/* */
|
|
2459
|
+
/* */
|
|
2460
|
+
/* */
|
|
2461
|
+
/* */
|
|
2462
|
+
/* */
|
|
2463
|
+
/* */
|
|
2464
|
+
/* */
|
|
2465
|
+
/* */
|
|
2466
|
+
/* */
|
|
2467
|
+
/* */
|
|
2468
|
+
return (void 0);
|
|
2469
|
+
}
|
|
2470
|
+
}
|
|
2471
|
+
UtilsExecProc.ExecProcResult = ExecProcResult;
|
|
2472
|
+
/**
|
|
2473
|
+
* @TODO @IN_PROGRESS
|
|
2474
|
+
*/
|
|
2475
|
+
UtilsExecProc.spawnAsync = (command, options) => {
|
|
2476
|
+
options = options || {};
|
|
2477
|
+
options.cwd = crossPlatformPath(options.cwd || process.cwd());
|
|
2478
|
+
const [cmd, ...args] = command.split(' ');
|
|
2479
|
+
const child = spawn(cmd, args, { stdio: 'inherit', ...options });
|
|
2480
|
+
return new ExecProcResult(child, command);
|
|
2481
|
+
};
|
|
2482
|
+
/**
|
|
2483
|
+
* @TODO @IN_PROGRESS
|
|
2484
|
+
*/
|
|
2485
|
+
UtilsExecProc.spawnAdminSudo = async (command, options) => {
|
|
2486
|
+
/* */
|
|
2487
|
+
/* */
|
|
2488
|
+
/* */
|
|
2489
|
+
/* */
|
|
2490
|
+
/* */
|
|
2491
|
+
/* */
|
|
2492
|
+
/* */
|
|
2493
|
+
/* */
|
|
2494
|
+
/* */
|
|
2495
|
+
return (void 0);
|
|
2496
|
+
};
|
|
2497
|
+
//#region utils exec process / execute until end or throw
|
|
2498
|
+
/**
|
|
2499
|
+
* @TODO @IN_PROGRESS
|
|
2500
|
+
*/
|
|
2501
|
+
UtilsExecProc.executeUntilEndOrThrow = async ({ command, cwd, }) => {
|
|
2502
|
+
/* */
|
|
2503
|
+
/* */
|
|
2504
|
+
/* */
|
|
2505
|
+
return (void 0);
|
|
2506
|
+
};
|
|
2507
|
+
//#endregion
|
|
2508
|
+
})(UtilsExecProc || (UtilsExecProc = {}));
|
|
2509
|
+
//#endregion
|
|
2510
|
+
//#region TODO IN_PROGRESS utils files folders operations
|
|
2511
|
+
/**
|
|
2512
|
+
* TODO @LAST @IN_PROGRESS
|
|
2513
|
+
* - utils for files and folders operations
|
|
2514
|
+
* - export when ready
|
|
2515
|
+
* - should be ready for everything async refactor
|
|
2516
|
+
*/
|
|
2517
|
+
var UtilsFilesFoldersOperations;
|
|
2518
|
+
(function (UtilsFilesFoldersOperations) {
|
|
2519
|
+
//#endregion
|
|
2520
|
+
//#region utils files folders operations / remove file or folder or link
|
|
2521
|
+
/**
|
|
2522
|
+
* remove file or folder or link
|
|
2523
|
+
*/
|
|
2524
|
+
UtilsFilesFoldersOperations.remove = async (absolutePath, options) => {
|
|
2525
|
+
/* */
|
|
2526
|
+
/* */
|
|
2527
|
+
/* */
|
|
2528
|
+
/* */
|
|
2529
|
+
/* */
|
|
2530
|
+
return (void 0);
|
|
2531
|
+
};
|
|
2532
|
+
//#endregion
|
|
2533
|
+
//#region utils files folders operations / remove file or folder or link
|
|
2534
|
+
/**
|
|
2535
|
+
* remove file or folder or link
|
|
2536
|
+
*/
|
|
2537
|
+
UtilsFilesFoldersOperations.removeByPattern = async (globPattern, options) => {
|
|
2538
|
+
/* */
|
|
2539
|
+
/* */
|
|
2540
|
+
/* */
|
|
2541
|
+
/* */
|
|
2542
|
+
/* */
|
|
2543
|
+
return (void 0);
|
|
2544
|
+
};
|
|
2545
|
+
//#endregion
|
|
2546
|
+
//#region utils files folders operations / get files from
|
|
2547
|
+
async function getFilesFromAsync(folderOrLinkToFolder, options = {}) {
|
|
2548
|
+
return null;
|
|
2549
|
+
/* */
|
|
2550
|
+
/* */
|
|
2551
|
+
/* */
|
|
2552
|
+
/* */
|
|
2553
|
+
/* */
|
|
2554
|
+
/* */
|
|
2555
|
+
/* */
|
|
2556
|
+
/* */
|
|
2557
|
+
/* */
|
|
2558
|
+
/* */
|
|
2559
|
+
/* */
|
|
2560
|
+
/* */
|
|
2561
|
+
/* */
|
|
2562
|
+
/* */
|
|
2563
|
+
/* */
|
|
2564
|
+
/* */
|
|
2565
|
+
/* */
|
|
2566
|
+
/* */
|
|
2567
|
+
/* */
|
|
2568
|
+
/* */
|
|
2569
|
+
/* */
|
|
2570
|
+
/* */
|
|
2571
|
+
/* */
|
|
2572
|
+
/* */
|
|
2573
|
+
/* */
|
|
2574
|
+
/* */
|
|
2575
|
+
/* */
|
|
2576
|
+
/* */
|
|
2577
|
+
/* */
|
|
2578
|
+
/* */
|
|
2579
|
+
/* */
|
|
2580
|
+
/* */
|
|
2581
|
+
/* */
|
|
2582
|
+
/* */
|
|
2583
|
+
/* */
|
|
2584
|
+
/* */
|
|
2585
|
+
/* */
|
|
2586
|
+
/* */
|
|
2587
|
+
/* */
|
|
2588
|
+
/* */
|
|
2589
|
+
/* */
|
|
2590
|
+
/* */
|
|
2591
|
+
/* */
|
|
2592
|
+
/* */
|
|
2593
|
+
/* */
|
|
2594
|
+
/* */
|
|
2595
|
+
/* */
|
|
2596
|
+
/* */
|
|
2597
|
+
/* */
|
|
2598
|
+
/* */
|
|
2599
|
+
/* */
|
|
2600
|
+
/* */
|
|
2601
|
+
/* */
|
|
2602
|
+
/* */
|
|
2603
|
+
/* */
|
|
2604
|
+
/* */
|
|
2605
|
+
return (void 0);
|
|
2606
|
+
}
|
|
2607
|
+
UtilsFilesFoldersOperations.getFilesFromAsync = getFilesFromAsync;
|
|
2608
|
+
//#endregion
|
|
2609
|
+
//#region utils files folders operations / read file
|
|
2610
|
+
/**
|
|
2611
|
+
* TODO @IN_PROGRESS
|
|
2612
|
+
*/
|
|
2613
|
+
UtilsFilesFoldersOperations.readFileAsync = async (absoluteFilePath, options) => {
|
|
2614
|
+
return void 0;
|
|
2615
|
+
};
|
|
2616
|
+
/* */
|
|
2617
|
+
/* */
|
|
2618
|
+
/**
|
|
2619
|
+
* TODO @IN_PROGRESS
|
|
2620
|
+
*/
|
|
2621
|
+
UtilsFilesFoldersOperations.writeFileAsync = async (absoluteFilePath, input, options) => {
|
|
2622
|
+
return void 0;
|
|
2623
|
+
};
|
|
2624
|
+
//#endregion
|
|
2625
|
+
//#region utils files folders operations / is existed symlink
|
|
2626
|
+
/**
|
|
2627
|
+
* TODO @IN_PROGRESS
|
|
2628
|
+
*/
|
|
2629
|
+
UtilsFilesFoldersOperations.isExistedSymlink = async (absoluteFilePath) => {
|
|
2630
|
+
return void 0;
|
|
2631
|
+
};
|
|
2632
|
+
//#endregion
|
|
2633
|
+
//#region utils files folders operations / is un existed link
|
|
2634
|
+
/**
|
|
2635
|
+
* TODO @IN_PROGRESS
|
|
2636
|
+
*/
|
|
2637
|
+
UtilsFilesFoldersOperations.isUnExistedLink = async (absoluteFilePath) => {
|
|
2638
|
+
return void 0;
|
|
2639
|
+
};
|
|
2640
|
+
//#endregion
|
|
2641
|
+
})(UtilsFilesFoldersOperations || (UtilsFilesFoldersOperations = {}));
|
|
2642
|
+
//#endregion
|
|
2354
2643
|
//#region utils os
|
|
2355
2644
|
var UtilsOs;
|
|
2356
2645
|
(function (UtilsOs) {
|
|
@@ -2391,9 +2680,11 @@ var UtilsOs;
|
|
|
2391
2680
|
return false;
|
|
2392
2681
|
};
|
|
2393
2682
|
//#endregion
|
|
2683
|
+
//#region utils os / is running in ssr mode
|
|
2394
2684
|
UtilsOs.isRunningInSSRMode = () => {
|
|
2395
2685
|
return typeof globalThis.window === 'undefined';
|
|
2396
2686
|
};
|
|
2687
|
+
//#endregion
|
|
2397
2688
|
//#region utils os / is running in electron
|
|
2398
2689
|
/**
|
|
2399
2690
|
* check whether the current process is running inside
|
|
@@ -2590,6 +2881,7 @@ var UtilsOs;
|
|
|
2590
2881
|
return (void 0);
|
|
2591
2882
|
};
|
|
2592
2883
|
//#endregion
|
|
2884
|
+
//#region utils os / is running in os with graphics capable environment
|
|
2593
2885
|
UtilsOs.isRunningInOsWithGraphicsCapableEnvironment = () => {
|
|
2594
2886
|
/* */
|
|
2595
2887
|
/* */
|
|
@@ -2601,6 +2893,7 @@ var UtilsOs;
|
|
|
2601
2893
|
/* */
|
|
2602
2894
|
return (void 0);
|
|
2603
2895
|
};
|
|
2896
|
+
//#endregion
|
|
2604
2897
|
//#region utils os / is running in cli mode
|
|
2605
2898
|
/**
|
|
2606
2899
|
* Check whether the current process is running in CLI mode.
|
|
@@ -2719,6 +3012,7 @@ var UtilsOs;
|
|
|
2719
3012
|
return (void 0);
|
|
2720
3013
|
};
|
|
2721
3014
|
//#endregion
|
|
3015
|
+
//#region utils os / open folder in vscode
|
|
2722
3016
|
UtilsOs.openFolderInVSCode = (folderPath) => {
|
|
2723
3017
|
/* */
|
|
2724
3018
|
/* */
|
|
@@ -2735,6 +3029,8 @@ var UtilsOs;
|
|
|
2735
3029
|
/* */
|
|
2736
3030
|
return (void 0);
|
|
2737
3031
|
};
|
|
3032
|
+
//#endregion
|
|
3033
|
+
//#region utils os / open folder in file explorer
|
|
2738
3034
|
UtilsOs.openFolderInFileExplorer = (folderPath) => {
|
|
2739
3035
|
/* */
|
|
2740
3036
|
/* */
|
|
@@ -2771,8 +3067,12 @@ var UtilsOs;
|
|
|
2771
3067
|
console.warn(`UtilsOs.openFolderInFileExplorer is not supported in browser mode`);
|
|
2772
3068
|
//#endregion
|
|
2773
3069
|
};
|
|
3070
|
+
//#endregion
|
|
2774
3071
|
//#region utils os / get real home directory
|
|
2775
3072
|
UtilsOs.getRealHomeDir = () => {
|
|
3073
|
+
//#region @browser
|
|
3074
|
+
return '';
|
|
3075
|
+
//#endregion
|
|
2776
3076
|
/* */
|
|
2777
3077
|
/* */
|
|
2778
3078
|
/* */
|
|
@@ -2835,30 +3135,141 @@ var UtilsOs;
|
|
|
2835
3135
|
UtilsOs.isWebSQL = UtilsOs.isRunningInWebSQL();
|
|
2836
3136
|
UtilsOs.isVscodeExtension = UtilsOs.isRunningInVscodeExtension();
|
|
2837
3137
|
UtilsOs.isSSRMode = UtilsOs.isRunningInSSRMode();
|
|
2838
|
-
|
|
2839
|
-
//#
|
|
2840
|
-
//#region
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
.replace(/([a-z0-9])([A-Z])/g, '$1-$2')
|
|
2850
|
-
// Convert everything to lowercase
|
|
2851
|
-
.toLowerCase());
|
|
3138
|
+
UtilsOs.isRunningInWindows = process.platform == 'win32';
|
|
3139
|
+
//#region utils os / command exists
|
|
3140
|
+
//#region helpers
|
|
3141
|
+
const fileNotExists = async (commandName) => {
|
|
3142
|
+
try {
|
|
3143
|
+
await fse.access(commandName, fse.constants.F_OK);
|
|
3144
|
+
return false;
|
|
3145
|
+
}
|
|
3146
|
+
catch {
|
|
3147
|
+
return true;
|
|
3148
|
+
}
|
|
2852
3149
|
};
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
3150
|
+
const fileNotExistsSync = (commandName) => {
|
|
3151
|
+
try {
|
|
3152
|
+
fse.accessSync(commandName, fse.constants.F_OK);
|
|
3153
|
+
return false;
|
|
3154
|
+
}
|
|
3155
|
+
catch {
|
|
3156
|
+
return true;
|
|
3157
|
+
}
|
|
3158
|
+
};
|
|
3159
|
+
const localExecutable = async (commandName) => {
|
|
3160
|
+
try {
|
|
3161
|
+
await fse.access(commandName, fse.constants.F_OK | fse.constants.X_OK);
|
|
3162
|
+
return true;
|
|
3163
|
+
}
|
|
3164
|
+
catch {
|
|
3165
|
+
return false;
|
|
3166
|
+
}
|
|
3167
|
+
};
|
|
3168
|
+
const localExecutableSync = (commandName) => {
|
|
3169
|
+
try {
|
|
3170
|
+
fse.accessSync(commandName, fse.constants.F_OK | fse.constants.X_OK);
|
|
3171
|
+
return true;
|
|
3172
|
+
}
|
|
3173
|
+
catch {
|
|
3174
|
+
return false;
|
|
3175
|
+
}
|
|
3176
|
+
};
|
|
3177
|
+
//#endregion
|
|
3178
|
+
//#region command exists (Unix / Windows)
|
|
3179
|
+
const commandExistsUnix = async (commandName) => {
|
|
3180
|
+
const isFileMissing = await fileNotExists(commandName);
|
|
3181
|
+
if (isFileMissing) {
|
|
3182
|
+
try {
|
|
3183
|
+
const stdout = child_process.execSync(`command -v ${commandName} 2>/dev/null && { echo >&1 '${commandName} found'; exit 0; }`, { encoding: 'utf-8' });
|
|
3184
|
+
return !!stdout;
|
|
3185
|
+
}
|
|
3186
|
+
catch {
|
|
3187
|
+
return false;
|
|
3188
|
+
}
|
|
3189
|
+
}
|
|
3190
|
+
return await localExecutable(commandName);
|
|
3191
|
+
};
|
|
3192
|
+
const commandExistsWindows = async (commandName) => {
|
|
3193
|
+
try {
|
|
3194
|
+
const stdout = await Helpers.commandOutputAsStringAsync(`where ${commandName}`);
|
|
3195
|
+
return !!stdout;
|
|
3196
|
+
}
|
|
3197
|
+
catch {
|
|
3198
|
+
return false;
|
|
3199
|
+
}
|
|
3200
|
+
};
|
|
3201
|
+
const commandExistsUnixSync = (commandName) => {
|
|
3202
|
+
if (fileNotExistsSync(commandName)) {
|
|
3203
|
+
try {
|
|
3204
|
+
const stdout = child_process.execSync(`command -v ${commandName} 2>/dev/null && { echo >&1 '${commandName} found'; exit 0; }`, { encoding: 'utf-8' });
|
|
3205
|
+
return !!stdout;
|
|
3206
|
+
}
|
|
3207
|
+
catch {
|
|
3208
|
+
return false;
|
|
3209
|
+
}
|
|
3210
|
+
}
|
|
3211
|
+
return localExecutableSync(commandName);
|
|
3212
|
+
};
|
|
3213
|
+
const commandExistsWindowsSync = (commandName) => {
|
|
3214
|
+
try {
|
|
3215
|
+
const stdout = Helpers.commandOutputAsString(`where ${commandName}`);
|
|
3216
|
+
return !!stdout;
|
|
3217
|
+
}
|
|
3218
|
+
catch {
|
|
3219
|
+
return false;
|
|
3220
|
+
}
|
|
3221
|
+
};
|
|
3222
|
+
//#endregion
|
|
3223
|
+
//#region exported API
|
|
3224
|
+
UtilsOs.commandExistsAsync = async (commandName) => {
|
|
3225
|
+
try {
|
|
3226
|
+
if (UtilsOs.isRunningInWindows) {
|
|
3227
|
+
return await commandExistsWindows(commandName);
|
|
3228
|
+
}
|
|
3229
|
+
else {
|
|
3230
|
+
return await commandExistsUnix(commandName);
|
|
3231
|
+
}
|
|
3232
|
+
}
|
|
3233
|
+
catch (error) {
|
|
3234
|
+
if (frameworkName === 'tnp')
|
|
3235
|
+
console.error(error);
|
|
3236
|
+
return false;
|
|
3237
|
+
}
|
|
3238
|
+
};
|
|
3239
|
+
/**
|
|
3240
|
+
* @deprecated use commandExistsAsync
|
|
3241
|
+
*/
|
|
3242
|
+
UtilsOs.commandExistsSync = (commandName) => {
|
|
3243
|
+
return UtilsOs.isRunningInWindows
|
|
3244
|
+
? commandExistsWindowsSync(commandName)
|
|
3245
|
+
: commandExistsUnixSync(commandName);
|
|
3246
|
+
};
|
|
3247
|
+
//#endregion
|
|
3248
|
+
//#endregion
|
|
3249
|
+
})(UtilsOs || (UtilsOs = {}));
|
|
3250
|
+
//#endregion
|
|
3251
|
+
//#region utils string
|
|
3252
|
+
var UtilsString;
|
|
3253
|
+
(function (UtilsString) {
|
|
3254
|
+
//#region utils string / kebab case no split numbers
|
|
3255
|
+
UtilsString.kebabCaseNoSplitNumbers = (input) => {
|
|
3256
|
+
return (input
|
|
3257
|
+
// Match spaces or any kind of whitespace and replace with a hyphen
|
|
3258
|
+
.replace(/\s+/g, '-')
|
|
3259
|
+
// Match uppercase letters and replace them with a hyphen and the lowercase version of the letter
|
|
3260
|
+
.replace(/([a-z0-9])([A-Z])/g, '$1-$2')
|
|
3261
|
+
// Convert everything to lowercase
|
|
3262
|
+
.toLowerCase());
|
|
3263
|
+
};
|
|
3264
|
+
//#endregion
|
|
3265
|
+
})(UtilsString || (UtilsString = {}));
|
|
3266
|
+
//#endregion
|
|
3267
|
+
//#region utils migrations
|
|
3268
|
+
/**
|
|
3269
|
+
* Taon migration utilities
|
|
3270
|
+
*/
|
|
3271
|
+
var UtilsMigrations;
|
|
3272
|
+
(function (UtilsMigrations) {
|
|
2862
3273
|
UtilsMigrations.getTimestampFromClassName = (className) => {
|
|
2863
3274
|
const [maybeTimestamp1, maybeTimestamp2] = className.split('_') || [];
|
|
2864
3275
|
// console.log({ maybeTimestamp1, maybeTimestamp2 });
|
|
@@ -2893,13 +3304,13 @@ var UtilsMigrations;
|
|
|
2893
3304
|
var UtilsTerminal;
|
|
2894
3305
|
(function (UtilsTerminal) {
|
|
2895
3306
|
//#endregion
|
|
2896
|
-
//#region wait
|
|
3307
|
+
//#region utils terminal / wait
|
|
2897
3308
|
UtilsTerminal.wait = Utils.wait;
|
|
2898
3309
|
//#endregion
|
|
2899
|
-
//#region wait milliseconds
|
|
3310
|
+
//#region utils terminal / wait milliseconds
|
|
2900
3311
|
UtilsTerminal.waitMilliseconds = Utils.waitMilliseconds;
|
|
2901
3312
|
//#endregion
|
|
2902
|
-
//#region is verbose mode
|
|
3313
|
+
//#region utils terminal / is verbose mode
|
|
2903
3314
|
/**
|
|
2904
3315
|
* Check if cli is running in verbose mode
|
|
2905
3316
|
* @returns true if cli is running with arugment -verbose
|
|
@@ -2910,6 +3321,7 @@ var UtilsTerminal;
|
|
|
2910
3321
|
return (void 0);
|
|
2911
3322
|
};
|
|
2912
3323
|
//#endregion
|
|
3324
|
+
//#region utils terminal / wait for user any key
|
|
2913
3325
|
UtilsTerminal.waitForUserAnyKey = async (callback, options) => {
|
|
2914
3326
|
/* */
|
|
2915
3327
|
/* */
|
|
@@ -2956,7 +3368,8 @@ var UtilsTerminal;
|
|
|
2956
3368
|
/* */
|
|
2957
3369
|
return (void 0);
|
|
2958
3370
|
};
|
|
2959
|
-
//#
|
|
3371
|
+
//#endregion
|
|
3372
|
+
//#region utils terminal / get terminal height
|
|
2960
3373
|
UtilsTerminal.getTerminalHeight = () => {
|
|
2961
3374
|
/* */
|
|
2962
3375
|
/* */
|
|
@@ -2983,7 +3396,7 @@ var UtilsTerminal;
|
|
|
2983
3396
|
return (void 0);
|
|
2984
3397
|
};
|
|
2985
3398
|
//#endregion
|
|
2986
|
-
//#region clear
|
|
3399
|
+
//#region utils terminal / clear
|
|
2987
3400
|
UtilsTerminal.clearConsole = () => {
|
|
2988
3401
|
/* */
|
|
2989
3402
|
/* */
|
|
@@ -3031,7 +3444,7 @@ var UtilsTerminal;
|
|
|
3031
3444
|
// }
|
|
3032
3445
|
};
|
|
3033
3446
|
//#endregion
|
|
3034
|
-
//#region transform choices
|
|
3447
|
+
//#region utils terminal / transform choices
|
|
3035
3448
|
const transformChoices = (choices) => {
|
|
3036
3449
|
/* */
|
|
3037
3450
|
/* */
|
|
@@ -3053,7 +3466,7 @@ var UtilsTerminal;
|
|
|
3053
3466
|
return (void 0);
|
|
3054
3467
|
};
|
|
3055
3468
|
//#endregion
|
|
3056
|
-
//#region multiselect
|
|
3469
|
+
//#region utils terminal / multiselect
|
|
3057
3470
|
UtilsTerminal.multiselect = async (options) => {
|
|
3058
3471
|
/* */
|
|
3059
3472
|
/* */
|
|
@@ -3137,10 +3550,34 @@ var UtilsTerminal;
|
|
|
3137
3550
|
/* */
|
|
3138
3551
|
/* */
|
|
3139
3552
|
/* */
|
|
3553
|
+
/* */
|
|
3554
|
+
/* */
|
|
3555
|
+
/* */
|
|
3556
|
+
/* */
|
|
3557
|
+
/* */
|
|
3558
|
+
/* */
|
|
3559
|
+
/* */
|
|
3560
|
+
/* */
|
|
3561
|
+
/* */
|
|
3562
|
+
/* */
|
|
3563
|
+
/* */
|
|
3564
|
+
/* */
|
|
3565
|
+
/* */
|
|
3566
|
+
/* */
|
|
3567
|
+
/* */
|
|
3568
|
+
/* */
|
|
3569
|
+
/* */
|
|
3570
|
+
/* */
|
|
3571
|
+
/* */
|
|
3572
|
+
/* */
|
|
3573
|
+
/* */
|
|
3574
|
+
/* */
|
|
3575
|
+
/* */
|
|
3576
|
+
/* */
|
|
3140
3577
|
return (void 0);
|
|
3141
3578
|
};
|
|
3142
3579
|
//#endregion
|
|
3143
|
-
//#region multiselect and execute
|
|
3580
|
+
//#region utils terminal / multiselect and execute
|
|
3144
3581
|
/**
|
|
3145
3582
|
* Similar to select but executes action if provided
|
|
3146
3583
|
* @returns selected and executed value
|
|
@@ -3197,7 +3634,7 @@ var UtilsTerminal;
|
|
|
3197
3634
|
return (void 0);
|
|
3198
3635
|
};
|
|
3199
3636
|
//#endregion
|
|
3200
|
-
//#region select and execute
|
|
3637
|
+
//#region utils terminal / select and execute
|
|
3201
3638
|
/**
|
|
3202
3639
|
* Similar to select but executes action if provided
|
|
3203
3640
|
* @returns selected and executed value
|
|
@@ -3241,7 +3678,7 @@ var UtilsTerminal;
|
|
|
3241
3678
|
return (void 0);
|
|
3242
3679
|
};
|
|
3243
3680
|
//#endregion
|
|
3244
|
-
//#region select
|
|
3681
|
+
//#region utils terminal / select
|
|
3245
3682
|
UtilsTerminal.select = async (options) => {
|
|
3246
3683
|
/* */
|
|
3247
3684
|
/* */
|
|
@@ -3319,17 +3756,18 @@ var UtilsTerminal;
|
|
|
3319
3756
|
/* */
|
|
3320
3757
|
/* */
|
|
3321
3758
|
/* */
|
|
3759
|
+
/* */
|
|
3322
3760
|
return (void 0);
|
|
3323
3761
|
};
|
|
3324
3762
|
//#endregion
|
|
3325
|
-
//#region pipe enter to stdin
|
|
3763
|
+
//#region utils terminal / pipe enter to stdin
|
|
3326
3764
|
UtilsTerminal.pipeEnterToStdin = () => {
|
|
3327
3765
|
/* */
|
|
3328
3766
|
/* */
|
|
3329
3767
|
return (void 0);
|
|
3330
3768
|
};
|
|
3331
3769
|
//#endregion
|
|
3332
|
-
//#region input
|
|
3770
|
+
//#region utils terminal / input
|
|
3333
3771
|
UtilsTerminal.input = async ({ defaultValue, question, required, validate, }) => {
|
|
3334
3772
|
/* */
|
|
3335
3773
|
/* */
|
|
@@ -3358,7 +3796,7 @@ var UtilsTerminal;
|
|
|
3358
3796
|
return (void 0);
|
|
3359
3797
|
};
|
|
3360
3798
|
//#endregion
|
|
3361
|
-
//#region confirm
|
|
3799
|
+
//#region utils terminal / confirm
|
|
3362
3800
|
UtilsTerminal.confirm = async (options) => {
|
|
3363
3801
|
/* */
|
|
3364
3802
|
/* */
|
|
@@ -3442,7 +3880,7 @@ var UtilsTerminal;
|
|
|
3442
3880
|
return (void 0);
|
|
3443
3881
|
};
|
|
3444
3882
|
//#endregion
|
|
3445
|
-
//#region press any key to continue
|
|
3883
|
+
//#region utils terminal / press any key to continue
|
|
3446
3884
|
UtilsTerminal.pressAnyKeyToContinueAsync = (options) => {
|
|
3447
3885
|
/* */
|
|
3448
3886
|
/* */
|
|
@@ -3465,7 +3903,19 @@ var UtilsTerminal;
|
|
|
3465
3903
|
return (void 0);
|
|
3466
3904
|
};
|
|
3467
3905
|
//#endregion
|
|
3468
|
-
//#region press any key
|
|
3906
|
+
//#region utils terminal / press any key to try again error occurred
|
|
3907
|
+
UtilsTerminal.pressAnyKeyToTryAgainErrorOccurred = async (error) => {
|
|
3908
|
+
/* */
|
|
3909
|
+
/* */
|
|
3910
|
+
/* */
|
|
3911
|
+
/* */
|
|
3912
|
+
/* */
|
|
3913
|
+
/* */
|
|
3914
|
+
/* */
|
|
3915
|
+
return (void 0);
|
|
3916
|
+
};
|
|
3917
|
+
//#endregion
|
|
3918
|
+
//#region utils terminal / press any key
|
|
3469
3919
|
/**
|
|
3470
3920
|
* @deprecated use UtilsTerminal.pressAnyKeyToContinueAsync()
|
|
3471
3921
|
*/
|
|
@@ -3500,7 +3950,7 @@ var UtilsTerminal;
|
|
|
3500
3950
|
return (void 0);
|
|
3501
3951
|
};
|
|
3502
3952
|
//#endregion
|
|
3503
|
-
//#region preview long list as select
|
|
3953
|
+
//#region utils terminal / preview long list as select
|
|
3504
3954
|
UtilsTerminal.previewLongList = async (list, listName = 'List') => {
|
|
3505
3955
|
/* */
|
|
3506
3956
|
/* */
|
|
@@ -3522,7 +3972,7 @@ var UtilsTerminal;
|
|
|
3522
3972
|
return (void 0);
|
|
3523
3973
|
};
|
|
3524
3974
|
//#endregion
|
|
3525
|
-
//#region preview long list with 'less' (git log like)
|
|
3975
|
+
//#region utils terminal / preview long list with 'less' (git log like)
|
|
3526
3976
|
/**
|
|
3527
3977
|
* Displays a long list in the console using a pager like `less`.
|
|
3528
3978
|
* Returns a Promise that resolves when the user exits the pager.
|
|
@@ -3576,7 +4026,7 @@ var UtilsTerminal;
|
|
|
3576
4026
|
return (void 0);
|
|
3577
4027
|
};
|
|
3578
4028
|
//#endregion
|
|
3579
|
-
//#region draw big text
|
|
4029
|
+
//#region utils terminal / draw big text
|
|
3580
4030
|
UtilsTerminal.drawBigText = async (text, options) => {
|
|
3581
4031
|
/* */
|
|
3582
4032
|
/* */
|
|
@@ -3600,6 +4050,125 @@ var UtilsTerminal;
|
|
|
3600
4050
|
return (void 0);
|
|
3601
4051
|
};
|
|
3602
4052
|
//#endregion
|
|
4053
|
+
//#region utils terminal / configure bash or shell
|
|
4054
|
+
/**
|
|
4055
|
+
* @TODO @IN_PROGRESS
|
|
4056
|
+
* - export when done
|
|
4057
|
+
* Configure bash or powershell prompt to show current folder and git branch
|
|
4058
|
+
*/
|
|
4059
|
+
const configureBashOrShell = async () => {
|
|
4060
|
+
/* */
|
|
4061
|
+
/* */
|
|
4062
|
+
/* */
|
|
4063
|
+
/* */
|
|
4064
|
+
/* */
|
|
4065
|
+
/* */
|
|
4066
|
+
/* */
|
|
4067
|
+
/* */
|
|
4068
|
+
/* */
|
|
4069
|
+
/* */
|
|
4070
|
+
/* */
|
|
4071
|
+
/* */
|
|
4072
|
+
/* */
|
|
4073
|
+
/* */
|
|
4074
|
+
/* */
|
|
4075
|
+
/* */
|
|
4076
|
+
/* */
|
|
4077
|
+
/* */
|
|
4078
|
+
/* */
|
|
4079
|
+
/* */
|
|
4080
|
+
/* */
|
|
4081
|
+
/* */
|
|
4082
|
+
/* */
|
|
4083
|
+
/* */
|
|
4084
|
+
/* */
|
|
4085
|
+
/* */
|
|
4086
|
+
/* */
|
|
4087
|
+
/* */
|
|
4088
|
+
/* */
|
|
4089
|
+
/* */
|
|
4090
|
+
/* */
|
|
4091
|
+
/* */
|
|
4092
|
+
/* */
|
|
4093
|
+
/* */
|
|
4094
|
+
/* */
|
|
4095
|
+
/* */
|
|
4096
|
+
/* */
|
|
4097
|
+
/* */
|
|
4098
|
+
/* */
|
|
4099
|
+
/* */
|
|
4100
|
+
/* */
|
|
4101
|
+
/* */
|
|
4102
|
+
/* */
|
|
4103
|
+
/* */
|
|
4104
|
+
/* */
|
|
4105
|
+
/* */
|
|
4106
|
+
/* */
|
|
4107
|
+
/* */
|
|
4108
|
+
/* */
|
|
4109
|
+
/* */
|
|
4110
|
+
/* */
|
|
4111
|
+
/* */
|
|
4112
|
+
/* */
|
|
4113
|
+
/* */
|
|
4114
|
+
/* */
|
|
4115
|
+
/* */
|
|
4116
|
+
/* */
|
|
4117
|
+
/* */
|
|
4118
|
+
/* */
|
|
4119
|
+
/* */
|
|
4120
|
+
/* */
|
|
4121
|
+
/* */
|
|
4122
|
+
/* */
|
|
4123
|
+
/* */
|
|
4124
|
+
/* */
|
|
4125
|
+
/* */
|
|
4126
|
+
/* */
|
|
4127
|
+
/* */
|
|
4128
|
+
/* */
|
|
4129
|
+
/* */
|
|
4130
|
+
/* */
|
|
4131
|
+
/* */
|
|
4132
|
+
/* */
|
|
4133
|
+
/* */
|
|
4134
|
+
/* */
|
|
4135
|
+
/* */
|
|
4136
|
+
/* */
|
|
4137
|
+
/* */
|
|
4138
|
+
/* */
|
|
4139
|
+
/* */
|
|
4140
|
+
/* */
|
|
4141
|
+
/* */
|
|
4142
|
+
/* */
|
|
4143
|
+
/* */
|
|
4144
|
+
/* */
|
|
4145
|
+
/* */
|
|
4146
|
+
/* */
|
|
4147
|
+
/* */
|
|
4148
|
+
/* */
|
|
4149
|
+
/* */
|
|
4150
|
+
/* */
|
|
4151
|
+
/* */
|
|
4152
|
+
/* */
|
|
4153
|
+
/* */
|
|
4154
|
+
/* */
|
|
4155
|
+
/* */
|
|
4156
|
+
/* */
|
|
4157
|
+
/* */
|
|
4158
|
+
/* */
|
|
4159
|
+
/* */
|
|
4160
|
+
/* */
|
|
4161
|
+
/* */
|
|
4162
|
+
/* */
|
|
4163
|
+
/* */
|
|
4164
|
+
/* */
|
|
4165
|
+
/* */
|
|
4166
|
+
/* */
|
|
4167
|
+
/* */
|
|
4168
|
+
/* */
|
|
4169
|
+
return (void 0);
|
|
4170
|
+
};
|
|
4171
|
+
//#endregion
|
|
3603
4172
|
})(UtilsTerminal || (UtilsTerminal = {}));
|
|
3604
4173
|
//#endregion
|
|
3605
4174
|
//#region utils json
|
|
@@ -4176,100 +4745,145 @@ var UtilsDotFile;
|
|
|
4176
4745
|
//#endregion
|
|
4177
4746
|
})(UtilsDotFile || (UtilsDotFile = {}));
|
|
4178
4747
|
//#endregion
|
|
4179
|
-
//#region utils
|
|
4180
|
-
var
|
|
4181
|
-
(function (
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4748
|
+
//#region utils etc hosts
|
|
4749
|
+
var UtilsEtcHosts;
|
|
4750
|
+
(function (UtilsEtcHosts) {
|
|
4751
|
+
UtilsEtcHosts.SIMULATE_DOMAIN_TAG = '@simulatedDomainByTaon';
|
|
4752
|
+
//#endregion
|
|
4753
|
+
//#region utils etc hosts / get etc hosts path
|
|
4754
|
+
UtilsEtcHosts.getPath = () => {
|
|
4755
|
+
let HOST_FILE_PATH = '';
|
|
4756
|
+
/* */
|
|
4757
|
+
/* */
|
|
4758
|
+
/* */
|
|
4759
|
+
/* */
|
|
4760
|
+
/* */
|
|
4761
|
+
return crossPlatformPath(HOST_FILE_PATH);
|
|
4192
4762
|
};
|
|
4193
4763
|
//#endregion
|
|
4194
|
-
//#region utils
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
? /^(https?:\/\/)([a-zA-Z0-9-]{1,63}\.)+[a-zA-Z]{2,}$/ // with protocol
|
|
4202
|
-
: /^([a-zA-Z0-9-]{1,63}\.)+[a-zA-Z]{2,}$/; // without protocol
|
|
4203
|
-
if (typeof options?.shouldIncludeProtocol === 'string' &&
|
|
4204
|
-
options?.shouldIncludeProtocol === 'http' &&
|
|
4205
|
-
!url.startsWith('http://')) {
|
|
4206
|
-
return false; // if http is required, but url does not start with http://
|
|
4207
|
-
}
|
|
4208
|
-
if (typeof options?.shouldIncludeProtocol === 'string' &&
|
|
4209
|
-
options?.shouldIncludeProtocol === 'https' &&
|
|
4210
|
-
!url.startsWith('https://')) {
|
|
4211
|
-
return false; // if https is required, but url does not start with https://
|
|
4212
|
-
}
|
|
4213
|
-
return domainRegex.test(url.trim());
|
|
4764
|
+
//#region utils etc hosts / get lines from etc hosts
|
|
4765
|
+
UtilsEtcHosts.getLines = () => {
|
|
4766
|
+
/* */
|
|
4767
|
+
/* */
|
|
4768
|
+
/* */
|
|
4769
|
+
/* */
|
|
4770
|
+
return (void 0);
|
|
4214
4771
|
};
|
|
4215
4772
|
//#endregion
|
|
4216
|
-
//#region utils
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
|
|
4222
|
-
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
|
|
4237
|
-
|
|
4238
|
-
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
if (options.forceDomain) {
|
|
4244
|
-
const domain = portOrHost;
|
|
4245
|
-
url = new URL(domain.startsWith('http') ? domain : `http://${portOrHost}`);
|
|
4246
|
-
}
|
|
4247
|
-
}
|
|
4248
|
-
return url;
|
|
4773
|
+
//#region utils etc hosts / get tokens from line
|
|
4774
|
+
UtilsEtcHosts.getTokensData = (line) => {
|
|
4775
|
+
/* */
|
|
4776
|
+
/* */
|
|
4777
|
+
/* */
|
|
4778
|
+
/* */
|
|
4779
|
+
/* */
|
|
4780
|
+
/* */
|
|
4781
|
+
/* */
|
|
4782
|
+
/* */
|
|
4783
|
+
/* */
|
|
4784
|
+
/* */
|
|
4785
|
+
/* */
|
|
4786
|
+
/* */
|
|
4787
|
+
/* */
|
|
4788
|
+
/* */
|
|
4789
|
+
/* */
|
|
4790
|
+
/* */
|
|
4791
|
+
/* */
|
|
4792
|
+
/* */
|
|
4793
|
+
/* */
|
|
4794
|
+
/* */
|
|
4795
|
+
/* */
|
|
4796
|
+
/* */
|
|
4797
|
+
/* */
|
|
4798
|
+
/* */
|
|
4799
|
+
return (void 0);
|
|
4249
4800
|
};
|
|
4250
4801
|
//#endregion
|
|
4251
|
-
//#region utils
|
|
4252
|
-
|
|
4253
|
-
let HOST_FILE_PATH = '';
|
|
4802
|
+
//#region utils etc hosts / specyfic entry exists
|
|
4803
|
+
UtilsEtcHosts.specificEntryExists = (domain, ip) => {
|
|
4254
4804
|
/* */
|
|
4255
4805
|
/* */
|
|
4256
4806
|
/* */
|
|
4257
4807
|
/* */
|
|
4258
4808
|
/* */
|
|
4259
|
-
|
|
4809
|
+
/* */
|
|
4810
|
+
/* */
|
|
4811
|
+
/* */
|
|
4812
|
+
/* */
|
|
4813
|
+
return (void 0);
|
|
4260
4814
|
};
|
|
4261
4815
|
//#endregion
|
|
4262
|
-
//#region utils
|
|
4816
|
+
//#region utils etc hosts / get Etc Host Entry By Domain
|
|
4817
|
+
UtilsEtcHosts.getEntriesByDomain = (domain) => {
|
|
4818
|
+
/* */
|
|
4819
|
+
/* */
|
|
4820
|
+
/* */
|
|
4821
|
+
/* */
|
|
4822
|
+
/* */
|
|
4823
|
+
/* */
|
|
4824
|
+
/* */
|
|
4825
|
+
/* */
|
|
4826
|
+
/* */
|
|
4827
|
+
/* */
|
|
4828
|
+
/* */
|
|
4829
|
+
/* */
|
|
4830
|
+
/* */
|
|
4831
|
+
/* */
|
|
4832
|
+
/* */
|
|
4833
|
+
/* */
|
|
4834
|
+
return (void 0);
|
|
4835
|
+
};
|
|
4836
|
+
//#endregion
|
|
4837
|
+
//#region utils etc hosts / get etc host entries by comment
|
|
4838
|
+
UtilsEtcHosts.getEntryByComment = (commentOfEntry) => {
|
|
4839
|
+
/* */
|
|
4840
|
+
/* */
|
|
4841
|
+
/* */
|
|
4842
|
+
/* */
|
|
4843
|
+
/* */
|
|
4844
|
+
/* */
|
|
4845
|
+
/* */
|
|
4846
|
+
/* */
|
|
4847
|
+
/* */
|
|
4848
|
+
/* */
|
|
4849
|
+
/* */
|
|
4850
|
+
/* */
|
|
4851
|
+
/* */
|
|
4852
|
+
/* */
|
|
4853
|
+
/* */
|
|
4854
|
+
/* */
|
|
4855
|
+
/* */
|
|
4856
|
+
return (void 0);
|
|
4857
|
+
};
|
|
4858
|
+
//#endregion
|
|
4859
|
+
//#region utils etc hosts / get etc host entries by ip
|
|
4263
4860
|
/**
|
|
4264
|
-
*
|
|
4861
|
+
* Returns all host entries for a given IP address.
|
|
4265
4862
|
*/
|
|
4266
|
-
|
|
4863
|
+
UtilsEtcHosts.getEntriesByIp = (ip) => {
|
|
4864
|
+
/* */
|
|
4865
|
+
/* */
|
|
4866
|
+
/* */
|
|
4867
|
+
/* */
|
|
4868
|
+
/* */
|
|
4869
|
+
/* */
|
|
4870
|
+
/* */
|
|
4871
|
+
/* */
|
|
4872
|
+
/* */
|
|
4873
|
+
/* */
|
|
4267
4874
|
/* */
|
|
4268
4875
|
/* */
|
|
4269
4876
|
/* */
|
|
4270
4877
|
/* */
|
|
4271
4878
|
/* */
|
|
4272
4879
|
/* */
|
|
4880
|
+
/* */
|
|
4881
|
+
/* */
|
|
4882
|
+
return (void 0);
|
|
4883
|
+
};
|
|
4884
|
+
//#endregion
|
|
4885
|
+
//#region utils etc hosts / remove entry by domain
|
|
4886
|
+
UtilsEtcHosts.removeEntryByDomain = (domain) => {
|
|
4273
4887
|
/* */
|
|
4274
4888
|
/* */
|
|
4275
4889
|
/* */
|
|
@@ -4286,8 +4900,8 @@ var UtilsNetwork;
|
|
|
4286
4900
|
return (void 0);
|
|
4287
4901
|
};
|
|
4288
4902
|
//#endregion
|
|
4289
|
-
//#region utils
|
|
4290
|
-
|
|
4903
|
+
//#region utils etc hosts / simulate domain in etc hosts
|
|
4904
|
+
UtilsEtcHosts.simulateDomain = async (domainOrDomains, options) => {
|
|
4291
4905
|
/* */
|
|
4292
4906
|
/* */
|
|
4293
4907
|
/* */
|
|
@@ -4321,21 +4935,6 @@ var UtilsNetwork;
|
|
|
4321
4935
|
/* */
|
|
4322
4936
|
/* */
|
|
4323
4937
|
/* */
|
|
4324
|
-
return (void 0);
|
|
4325
|
-
};
|
|
4326
|
-
//#endregion
|
|
4327
|
-
//#region utils network / get etc host entries by ip
|
|
4328
|
-
/**
|
|
4329
|
-
* Returns all host entries for a given IP address.
|
|
4330
|
-
*
|
|
4331
|
-
* Example output:
|
|
4332
|
-
* getEtcHostEntryByIp("127.0.0.1")
|
|
4333
|
-
* => [
|
|
4334
|
-
* { domains: ["localhost"], comment: null },
|
|
4335
|
-
* { domains: ["myapp.local", "dev.local"], comment: "local testing" }
|
|
4336
|
-
* ]
|
|
4337
|
-
*/
|
|
4338
|
-
UtilsNetwork.getEtcHostEntryByIp = (ip) => {
|
|
4339
4938
|
/* */
|
|
4340
4939
|
/* */
|
|
4341
4940
|
/* */
|
|
@@ -4366,14 +4965,6 @@ var UtilsNetwork;
|
|
|
4366
4965
|
/* */
|
|
4367
4966
|
/* */
|
|
4368
4967
|
/* */
|
|
4369
|
-
return (void 0);
|
|
4370
|
-
};
|
|
4371
|
-
//#endregion
|
|
4372
|
-
//#region utils network / removeEtcHost
|
|
4373
|
-
/**
|
|
4374
|
-
* Remove all lines containing the given domain
|
|
4375
|
-
*/
|
|
4376
|
-
UtilsNetwork.removeEtcHost = (domain) => {
|
|
4377
4968
|
/* */
|
|
4378
4969
|
/* */
|
|
4379
4970
|
/* */
|
|
@@ -4387,27 +4978,12 @@ var UtilsNetwork;
|
|
|
4387
4978
|
/* */
|
|
4388
4979
|
/* */
|
|
4389
4980
|
/* */
|
|
4390
|
-
return (void 0);
|
|
4391
|
-
};
|
|
4392
|
-
//#endregion
|
|
4393
|
-
//#region utils network / etc host without localhost
|
|
4394
|
-
UtilsNetwork.etcHostHasProperLocalhostIp4Entry = () => {
|
|
4395
4981
|
/* */
|
|
4396
4982
|
/* */
|
|
4397
4983
|
/* */
|
|
4398
|
-
return (void 0);
|
|
4399
|
-
};
|
|
4400
|
-
UtilsNetwork.etcHostHasProperLocalhostIp6Entry = () => {
|
|
4401
4984
|
/* */
|
|
4402
4985
|
/* */
|
|
4403
4986
|
/* */
|
|
4404
|
-
return (void 0);
|
|
4405
|
-
};
|
|
4406
|
-
//#endregion
|
|
4407
|
-
// Utility to escape domain for RegExp
|
|
4408
|
-
const escapeRegExp = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
4409
|
-
//#region utils network / simulate domain in etc hosts
|
|
4410
|
-
UtilsNetwork.simulateDomain = async (domainOrDomains, options) => {
|
|
4411
4987
|
/* */
|
|
4412
4988
|
/* */
|
|
4413
4989
|
/* */
|
|
@@ -4419,6 +4995,16 @@ var UtilsNetwork;
|
|
|
4419
4995
|
/* */
|
|
4420
4996
|
/* */
|
|
4421
4997
|
/* */
|
|
4998
|
+
/* */
|
|
4999
|
+
return (void 0);
|
|
5000
|
+
};
|
|
5001
|
+
//#endregion
|
|
5002
|
+
})(UtilsEtcHosts || (UtilsEtcHosts = {}));
|
|
5003
|
+
//#endregion
|
|
5004
|
+
//#region utils network
|
|
5005
|
+
var UtilsNetwork;
|
|
5006
|
+
(function (UtilsNetwork) {
|
|
5007
|
+
async function checkPing(host, timeoutMs = 3000) {
|
|
4422
5008
|
/* */
|
|
4423
5009
|
/* */
|
|
4424
5010
|
/* */
|
|
@@ -4454,9 +5040,18 @@ var UtilsNetwork;
|
|
|
4454
5040
|
/* */
|
|
4455
5041
|
/* */
|
|
4456
5042
|
/* */
|
|
5043
|
+
/* */
|
|
5044
|
+
/* */
|
|
5045
|
+
return (void 0);
|
|
5046
|
+
}
|
|
5047
|
+
UtilsNetwork.checkPing = checkPing;
|
|
5048
|
+
UtilsNetwork.checkIfServerPings = async (host, timeoutMs = 3000) => {
|
|
4457
5049
|
/* */
|
|
4458
5050
|
/* */
|
|
4459
5051
|
/* */
|
|
5052
|
+
return (void 0);
|
|
5053
|
+
};
|
|
5054
|
+
UtilsNetwork.checkIfServerOnline = async (host, port = 80, timeoutMs = 3000) => {
|
|
4460
5055
|
/* */
|
|
4461
5056
|
/* */
|
|
4462
5057
|
/* */
|
|
@@ -4474,6 +5069,93 @@ var UtilsNetwork;
|
|
|
4474
5069
|
/* */
|
|
4475
5070
|
/* */
|
|
4476
5071
|
/* */
|
|
5072
|
+
/* */
|
|
5073
|
+
return (void 0);
|
|
5074
|
+
};
|
|
5075
|
+
//#endregion
|
|
5076
|
+
//#region utils network / isValidIp
|
|
5077
|
+
UtilsNetwork.isValidIp = (ip) => {
|
|
5078
|
+
if (!_.isString(ip)) {
|
|
5079
|
+
return false;
|
|
5080
|
+
}
|
|
5081
|
+
ip = ip.trim();
|
|
5082
|
+
if (ip === 'localhost') {
|
|
5083
|
+
return true;
|
|
5084
|
+
}
|
|
5085
|
+
return /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(ip);
|
|
5086
|
+
};
|
|
5087
|
+
//#endregion
|
|
5088
|
+
//#region utils network / isValidDomain
|
|
5089
|
+
UtilsNetwork.isValidDomain = (url, options) => {
|
|
5090
|
+
if (!url || typeof url !== 'string')
|
|
5091
|
+
return false;
|
|
5092
|
+
const shouldIncludeProtocol = !!options?.shouldIncludeProtocol;
|
|
5093
|
+
// Build regex depending on protocol requirement
|
|
5094
|
+
const domainRegex = shouldIncludeProtocol
|
|
5095
|
+
? /^(https?:\/\/)([a-zA-Z0-9-]{1,63}\.)+[a-zA-Z]{2,}$/ // with protocol
|
|
5096
|
+
: /^([a-zA-Z0-9-]{1,63}\.)+[a-zA-Z]{2,}$/; // without protocol
|
|
5097
|
+
if (typeof options?.shouldIncludeProtocol === 'string' &&
|
|
5098
|
+
options?.shouldIncludeProtocol === 'http' &&
|
|
5099
|
+
!url.startsWith('http://')) {
|
|
5100
|
+
return false; // if http is required, but url does not start with http://
|
|
5101
|
+
}
|
|
5102
|
+
if (typeof options?.shouldIncludeProtocol === 'string' &&
|
|
5103
|
+
options?.shouldIncludeProtocol === 'https' &&
|
|
5104
|
+
!url.startsWith('https://')) {
|
|
5105
|
+
return false; // if https is required, but url does not start with https://
|
|
5106
|
+
}
|
|
5107
|
+
return domainRegex.test(url.trim());
|
|
5108
|
+
};
|
|
5109
|
+
//#endregion
|
|
5110
|
+
//#region utils network / urlParse
|
|
5111
|
+
UtilsNetwork.urlParse = (portOrHost, options) => {
|
|
5112
|
+
options = options || {};
|
|
5113
|
+
let url;
|
|
5114
|
+
const defaultProtocol = options.httpsIfNotProvided ? 'https:' : 'http:';
|
|
5115
|
+
if (portOrHost instanceof URL) {
|
|
5116
|
+
url = portOrHost;
|
|
5117
|
+
}
|
|
5118
|
+
else if (_.isNumber(portOrHost)) {
|
|
5119
|
+
url = new URL(`${defaultProtocol}//localhost:${portOrHost}`);
|
|
5120
|
+
}
|
|
5121
|
+
else if (!_.isNaN(Number(portOrHost))) {
|
|
5122
|
+
url = new URL(`${defaultProtocol}//localhost:${Number(portOrHost)}`);
|
|
5123
|
+
}
|
|
5124
|
+
else if (_.isString(portOrHost)) {
|
|
5125
|
+
try {
|
|
5126
|
+
url = new URL(portOrHost);
|
|
5127
|
+
}
|
|
5128
|
+
catch (error) { }
|
|
5129
|
+
if (UtilsNetwork.isValidIp(portOrHost)) {
|
|
5130
|
+
try {
|
|
5131
|
+
url = new URL(`${defaultProtocol}//${portOrHost}`);
|
|
5132
|
+
}
|
|
5133
|
+
catch (error) {
|
|
5134
|
+
Helpers.warn(`Not able to get port from ${portOrHost}`);
|
|
5135
|
+
}
|
|
5136
|
+
}
|
|
5137
|
+
if (options.forceDomain) {
|
|
5138
|
+
const domain = portOrHost;
|
|
5139
|
+
url = new URL(domain.startsWith('http') ? domain : `http://${portOrHost}`);
|
|
5140
|
+
}
|
|
5141
|
+
}
|
|
5142
|
+
return url;
|
|
5143
|
+
};
|
|
5144
|
+
//#endregion
|
|
5145
|
+
//#region utils network / get etc hosts path
|
|
5146
|
+
UtilsNetwork.getEtcHostsPath = UtilsEtcHosts.getPath;
|
|
5147
|
+
//#endregion
|
|
5148
|
+
//#region utils network / simulate domain tag constant
|
|
5149
|
+
/**
|
|
5150
|
+
* @deprecated use UtilsEtcHosts.SIMULATE_DOMAIN_TAG instead
|
|
5151
|
+
*/
|
|
5152
|
+
UtilsNetwork.SIMULATE_DOMAIN_TAG = UtilsEtcHosts.SIMULATE_DOMAIN_TAG;
|
|
5153
|
+
//#endregion
|
|
5154
|
+
//#region utils network / setEtcHost
|
|
5155
|
+
/**
|
|
5156
|
+
* Add or update a hosts entry
|
|
5157
|
+
*/
|
|
5158
|
+
UtilsNetwork.setEtcHost = (domain, ip = '127.0.0.1', comment = '') => {
|
|
4477
5159
|
/* */
|
|
4478
5160
|
/* */
|
|
4479
5161
|
/* */
|
|
@@ -4498,15 +5180,177 @@ var UtilsNetwork;
|
|
|
4498
5180
|
/* */
|
|
4499
5181
|
/* */
|
|
4500
5182
|
/* */
|
|
5183
|
+
return (void 0);
|
|
5184
|
+
};
|
|
5185
|
+
//#endregion
|
|
5186
|
+
//#region utils network / get Etc Host Entry By Domain
|
|
5187
|
+
/**
|
|
5188
|
+
* @deprecated use UtilsEtcHosts.getEntriesByDomain instead
|
|
5189
|
+
*/
|
|
5190
|
+
UtilsNetwork.getEtcHostEntriesByDomain = UtilsEtcHosts.getEntriesByDomain;
|
|
5191
|
+
//#endregion
|
|
5192
|
+
//#region utils network / get etc host entries by comment
|
|
5193
|
+
/**
|
|
5194
|
+
* @deprecated use UtilsEtcHosts.getEntryByComment instead
|
|
5195
|
+
*/
|
|
5196
|
+
UtilsNetwork.getEtcHostEntryByComment = UtilsEtcHosts.getEntryByComment;
|
|
5197
|
+
//#endregion
|
|
5198
|
+
//#region utils network / get etc host entries by ip
|
|
5199
|
+
/**
|
|
5200
|
+
* @deprecated use UtilsEtcHosts.getEntriesByIp instead
|
|
5201
|
+
*/
|
|
5202
|
+
UtilsNetwork.getEtcHostEntryByIp = UtilsEtcHosts.getEntriesByIp;
|
|
5203
|
+
//#endregion
|
|
5204
|
+
//#region utils network / removeEtcHost
|
|
5205
|
+
/**
|
|
5206
|
+
* Remove all lines containing the given domain
|
|
5207
|
+
* @deprecated use UtilsEtcHosts.removeEntryByDomain instead
|
|
5208
|
+
*/
|
|
5209
|
+
UtilsNetwork.removeEtcHost = UtilsEtcHosts.removeEntryByDomain;
|
|
5210
|
+
//#endregion
|
|
5211
|
+
//#region utils network / etc host without localhost
|
|
5212
|
+
UtilsNetwork.etcHostHasProperLocalhostIp4Entry = () => {
|
|
4501
5213
|
/* */
|
|
4502
5214
|
/* */
|
|
4503
5215
|
/* */
|
|
5216
|
+
return (void 0);
|
|
5217
|
+
};
|
|
5218
|
+
UtilsNetwork.etcHostHasProperLocalhostIp6Entry = () => {
|
|
4504
5219
|
/* */
|
|
4505
5220
|
/* */
|
|
4506
5221
|
/* */
|
|
4507
5222
|
return (void 0);
|
|
4508
5223
|
};
|
|
4509
5224
|
//#endregion
|
|
5225
|
+
//#region utils network / simulate domain in etc hosts
|
|
5226
|
+
/**
|
|
5227
|
+
* @deprecated use UtilsEtcHosts.simulateDomain instead
|
|
5228
|
+
*/
|
|
5229
|
+
UtilsNetwork.simulateDomain = UtilsEtcHosts.simulateDomain;
|
|
5230
|
+
//#endregion
|
|
5231
|
+
//#region utils network / get local public ip addresses / get interface type from name
|
|
5232
|
+
const isVirtualInterface = (name) => {
|
|
5233
|
+
const lname = name.toLowerCase();
|
|
5234
|
+
return (lname.includes('virtual') ||
|
|
5235
|
+
lname.includes('vmware') ||
|
|
5236
|
+
lname.includes('vbox') ||
|
|
5237
|
+
lname.includes('hyper-v') ||
|
|
5238
|
+
lname.includes('wsl') ||
|
|
5239
|
+
lname.includes('docker') ||
|
|
5240
|
+
lname.includes('veth') ||
|
|
5241
|
+
lname.includes('default switch'));
|
|
5242
|
+
};
|
|
5243
|
+
const interfaceTypeFromName = (name) => {
|
|
5244
|
+
const lname = name.toLowerCase();
|
|
5245
|
+
if (isVirtualInterface(lname))
|
|
5246
|
+
return 'virtual';
|
|
5247
|
+
if (lname.includes('eth') || lname.includes('en') || lname.includes('lan'))
|
|
5248
|
+
return 'lan';
|
|
5249
|
+
if (lname.includes('wl') ||
|
|
5250
|
+
lname.includes('wi-fi') ||
|
|
5251
|
+
lname.includes('wifi'))
|
|
5252
|
+
return 'wifi';
|
|
5253
|
+
return 'other';
|
|
5254
|
+
};
|
|
5255
|
+
const sortByPriority = (a, b) => {
|
|
5256
|
+
const typePriority = { lan: 1, wifi: 2, other: 3, virtual: 4 };
|
|
5257
|
+
const pa = typePriority[a.type];
|
|
5258
|
+
const pb = typePriority[b.type];
|
|
5259
|
+
if (pa !== pb)
|
|
5260
|
+
return pa - pb;
|
|
5261
|
+
// Secondary heuristic for tie-breaking (e.g., Ethernet 5 before vEthernet)
|
|
5262
|
+
const nameA = a.interfaceName.toLowerCase();
|
|
5263
|
+
const nameB = b.interfaceName.toLowerCase();
|
|
5264
|
+
// prefer physical-looking names
|
|
5265
|
+
const physPriority = (name) => name.includes('ethernet') && !name.includes('vethernet') ? 0 : 1;
|
|
5266
|
+
const diff = physPriority(nameA) - physPriority(nameB);
|
|
5267
|
+
if (diff !== 0)
|
|
5268
|
+
return diff;
|
|
5269
|
+
return nameA.localeCompare(nameB);
|
|
5270
|
+
};
|
|
5271
|
+
//#endregion
|
|
5272
|
+
//#region utils network / get local public ip addresses / get local ip addresses
|
|
5273
|
+
/**
|
|
5274
|
+
* Returns all local IP addresses in preferred order:
|
|
5275
|
+
* LAN → Wi-Fi → Other → Virtual
|
|
5276
|
+
*/
|
|
5277
|
+
UtilsNetwork.getLocalIpAddresses = async () => {
|
|
5278
|
+
const interfaces = os.networkInterfaces();
|
|
5279
|
+
const all = [];
|
|
5280
|
+
for (const [name, addrs] of Object.entries(interfaces)) {
|
|
5281
|
+
if (!addrs)
|
|
5282
|
+
continue;
|
|
5283
|
+
for (const addr of addrs) {
|
|
5284
|
+
if (addr.internal)
|
|
5285
|
+
continue;
|
|
5286
|
+
all.push({
|
|
5287
|
+
interfaceName: name,
|
|
5288
|
+
address: addr.address,
|
|
5289
|
+
family: addr.family,
|
|
5290
|
+
internal: addr.internal,
|
|
5291
|
+
type: interfaceTypeFromName(name),
|
|
5292
|
+
});
|
|
5293
|
+
}
|
|
5294
|
+
}
|
|
5295
|
+
all.sort(sortByPriority);
|
|
5296
|
+
return all;
|
|
5297
|
+
};
|
|
5298
|
+
//#endregion
|
|
5299
|
+
//#region utils network / get local public ip addresses / get first local active ip address
|
|
5300
|
+
/**
|
|
5301
|
+
* Returns first active local ipv4 IP (LAN preferred over Wi-Fi).
|
|
5302
|
+
*/
|
|
5303
|
+
UtilsNetwork.getFirstIpV4LocalActiveIpAddress = async () => {
|
|
5304
|
+
const all = await UtilsNetwork.getLocalIpAddresses().then(a => a.filter(f => f.family === 'IPv4'));
|
|
5305
|
+
return all.length > 0 ? all[0].address : null;
|
|
5306
|
+
};
|
|
5307
|
+
//#endregion
|
|
5308
|
+
//#region utils network / get local public ip addresses / get current public ip address
|
|
5309
|
+
/**
|
|
5310
|
+
* Returns current public IP address (or null if undetectable).
|
|
5311
|
+
*/
|
|
5312
|
+
UtilsNetwork.getCurrentPublicIpAddress = async () => {
|
|
5313
|
+
const urls = [
|
|
5314
|
+
'https://api.ipify.org?format=json',
|
|
5315
|
+
'https://ifconfig.me/ip',
|
|
5316
|
+
'https://icanhazip.com',
|
|
5317
|
+
];
|
|
5318
|
+
for (const url of urls) {
|
|
5319
|
+
try {
|
|
5320
|
+
const ip = await new Promise((resolve, reject) => {
|
|
5321
|
+
https
|
|
5322
|
+
.get(url, res => {
|
|
5323
|
+
let data = '';
|
|
5324
|
+
res.on('data', chunk => (data += chunk));
|
|
5325
|
+
res.on('end', () => {
|
|
5326
|
+
try {
|
|
5327
|
+
const match = data.match(/(\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b)/);
|
|
5328
|
+
if (match)
|
|
5329
|
+
resolve(match[1]);
|
|
5330
|
+
else if (data.trim().length > 0)
|
|
5331
|
+
resolve(data.trim());
|
|
5332
|
+
else
|
|
5333
|
+
reject(new Error('no ip found'));
|
|
5334
|
+
}
|
|
5335
|
+
catch (e) {
|
|
5336
|
+
reject(e);
|
|
5337
|
+
}
|
|
5338
|
+
});
|
|
5339
|
+
})
|
|
5340
|
+
.on('error', reject)
|
|
5341
|
+
.setTimeout(3000, () => reject(new Error('timeout')));
|
|
5342
|
+
});
|
|
5343
|
+
if (ip)
|
|
5344
|
+
return ip;
|
|
5345
|
+
}
|
|
5346
|
+
catch {
|
|
5347
|
+
// try next
|
|
5348
|
+
}
|
|
5349
|
+
}
|
|
5350
|
+
return null;
|
|
5351
|
+
};
|
|
5352
|
+
//#endregion
|
|
5353
|
+
//#endregion
|
|
4510
5354
|
})(UtilsNetwork || (UtilsNetwork = {}));
|
|
4511
5355
|
//#endregion
|
|
4512
5356
|
//#region utils process logger
|
|
@@ -5150,6 +5994,8 @@ class HelpersMessages extends HelpersIsomorphic {
|
|
|
5150
5994
|
/* */
|
|
5151
5995
|
/* */
|
|
5152
5996
|
/* */
|
|
5997
|
+
/* */
|
|
5998
|
+
/* */
|
|
5153
5999
|
}
|
|
5154
6000
|
//#endregion
|
|
5155
6001
|
//#region info
|
|
@@ -6745,6 +7591,9 @@ class HelpersCore extends HelpersMessages {
|
|
|
6745
7591
|
}
|
|
6746
7592
|
//#endregion
|
|
6747
7593
|
//#region methods / kill process
|
|
7594
|
+
/**
|
|
7595
|
+
* @deprecated use UtilsProcess.killProcess
|
|
7596
|
+
*/
|
|
6748
7597
|
killProcess(byPid) {
|
|
6749
7598
|
/* */
|
|
6750
7599
|
/* */
|
|
@@ -6776,6 +7625,10 @@ class HelpersCore extends HelpersMessages {
|
|
|
6776
7625
|
}
|
|
6777
7626
|
//#endregion
|
|
6778
7627
|
//#region methods / run
|
|
7628
|
+
/**
|
|
7629
|
+
* @deprecated use UtilsProcess
|
|
7630
|
+
* or native child_process exec, spawn
|
|
7631
|
+
*/
|
|
6779
7632
|
run(command, options) {
|
|
6780
7633
|
command = Helpers._fixCommand(command);
|
|
6781
7634
|
// console.log({ command })
|
|
@@ -7924,6 +8777,10 @@ class HelpersCore extends HelpersMessages {
|
|
|
7924
8777
|
/* */
|
|
7925
8778
|
/* */
|
|
7926
8779
|
//#endregion
|
|
8780
|
+
/**
|
|
8781
|
+
* return absolute paths for files inside folder or link to folder
|
|
8782
|
+
* @returns absoulte pathes to files from path
|
|
8783
|
+
*/
|
|
7927
8784
|
getFilesFrom(folderOrLinkToFolder, options = {}) {
|
|
7928
8785
|
/* */
|
|
7929
8786
|
/* */
|
|
@@ -8164,6 +9021,7 @@ const requiredForDev = {
|
|
|
8164
9021
|
],
|
|
8165
9022
|
};
|
|
8166
9023
|
|
|
9024
|
+
//#region imports
|
|
8167
9025
|
//#endregion
|
|
8168
9026
|
class CLI {
|
|
8169
9027
|
static { this.chalk = chalk; }
|
|
@@ -8254,5 +9112,5 @@ let Helpers = HelpersCore.InstanceCore;
|
|
|
8254
9112
|
* Generated bundle index. Do not edit.
|
|
8255
9113
|
*/
|
|
8256
9114
|
|
|
8257
|
-
export { $, CLI, CoreConfig, HelpersCore as CoreHelpers, CoreModels, FilePathMetaData, Helpers, PROGRESS_DATA, Utils, UtilsCliClassMethod, UtilsDotFile, UtilsJson, UtilsMigrations, UtilsNetwork, UtilsOs, UtilsProcess, UtilsProcessLogger, UtilsString, UtilsTerminal, UtilsYaml, chalk, child_process, chokidar, crossPlatformPath, fg, fkill, frameworkName, frameworkNameBe, fse, glob, http, https, isElevated, mkdirp, ncp, net, os, path, ps, psList, requiredForDev, rimraf, spawn, win32Path };
|
|
9115
|
+
export { $, CLI, CoreConfig, HelpersCore as CoreHelpers, CoreModels, FilePathMetaData, Helpers, PROGRESS_DATA, Utils, UtilsCliClassMethod, UtilsDotFile, UtilsEtcHosts, UtilsJson, UtilsMigrations, UtilsNetwork, UtilsOs, UtilsProcess, UtilsProcessLogger, UtilsString, UtilsTerminal, UtilsYaml, chalk, child_process, chokidar, crossPlatformPath, fg, fkill, frameworkName, frameworkNameBe, fse, glob, http, https, isElevated, mkdirp, ncp, net, os, path, ps, psList, requiredForDev, rimraf, spawn, win32Path };
|
|
8258
9116
|
//# sourceMappingURL=tnp-core.mjs.map
|