tnp-core 21.0.161 → 21.0.162
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/VERIFIED-BUILD-DATA.jsonc +3 -3
- package/browser/fesm2022/tnp-core-browser.mjs +1399 -1023
- package/browser/fesm2022/tnp-core-browser.mjs.map +1 -1
- package/browser/package.json +1 -1
- package/browser/types/tnp-core-browser.d.ts +50 -9
- package/browser-prod/fesm2022/tnp-core-browser-prod.mjs +1362 -992
- package/browser-prod/fesm2022/tnp-core-browser-prod.mjs.map +1 -1
- package/browser-prod/package.json +1 -1
- package/browser-prod/types/tnp-core-browser-prod.d.ts +48 -9
- package/browser-prod.split-namespaces.json +18 -0
- package/lib/build-info._auto-generated_.d.ts +1 -1
- package/lib/build-info._auto-generated_.js +1 -1
- package/lib/config.js +4 -3
- package/lib/config.js.map +1 -1
- package/lib/core-imports.d.ts +1 -9
- package/lib/core-imports.js +3 -90
- package/lib/core-imports.js.map +1 -1
- package/lib/cross-platform-path.d.ts +5 -0
- package/lib/cross-platform-path.js +79 -0
- package/lib/cross-platform-path.js.map +1 -0
- package/lib/env/env.angular-node-app.d.ts +1 -0
- package/lib/env/env.angular-node-app.js +6 -2
- package/lib/env/env.angular-node-app.js.map +1 -1
- package/lib/env/env.docs-webapp.d.ts +1 -0
- package/lib/env/env.docs-webapp.js +6 -2
- package/lib/env/env.docs-webapp.js.map +1 -1
- package/lib/env/env.electron-app.d.ts +1 -0
- package/lib/env/env.electron-app.js +6 -2
- package/lib/env/env.electron-app.js.map +1 -1
- package/lib/env/env.mobile-app.d.ts +1 -0
- package/lib/env/env.mobile-app.js +6 -2
- package/lib/env/env.mobile-app.js.map +1 -1
- package/lib/env/env.npm-lib-and-cli-tool.d.ts +1 -0
- package/lib/env/env.npm-lib-and-cli-tool.js +6 -2
- package/lib/env/env.npm-lib-and-cli-tool.js.map +1 -1
- package/lib/env/env.vscode-plugin.d.ts +1 -0
- package/lib/env/env.vscode-plugin.js +6 -2
- package/lib/env/env.vscode-plugin.js.map +1 -1
- package/lib/global-task-manager.js +2 -1
- package/lib/global-task-manager.js.map +1 -1
- package/lib/helpers.js +37 -36
- package/lib/helpers.js.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/lib/package.json +1 -1
- package/lib/start-cli.js +2 -2
- package/lib/start-cli.js.map +1 -1
- package/lib/utils-dot-file.js +8 -7
- package/lib/utils-dot-file.js.map +1 -1
- package/lib/utils-etc-hosts.js +3 -2
- package/lib/utils-etc-hosts.js.map +1 -1
- package/lib/utils-exec-proc.js +2 -1
- package/lib/utils-exec-proc.js.map +1 -1
- package/lib/utils-files-folders.js +31 -29
- package/lib/utils-files-folders.js.map +1 -1
- package/lib/utils-json.js +4 -3
- package/lib/utils-json.js.map +1 -1
- package/lib/utils-os.js +35 -34
- package/lib/utils-os.js.map +1 -1
- package/lib/utils-process-logger.js +4 -3
- package/lib/utils-process-logger.js.map +1 -1
- package/lib/utils-process.d.ts +1 -0
- package/lib/utils-process.js +18 -4
- package/lib/utils-process.js.map +1 -1
- package/lib/utils-secret-env.d.ts +41 -0
- package/lib/utils-secret-env.js +376 -0
- package/lib/utils-secret-env.js.map +1 -0
- package/lib/utils-terminal.js +4 -3
- package/lib/utils-terminal.js.map +1 -1
- package/lib-esm/lib/build-info._auto-generated_.d.ts +1 -1
- package/lib-esm/lib/build-info._auto-generated_.js +1 -1
- package/lib-esm/lib/config.js +2 -1
- package/lib-esm/lib/config.js.map +1 -1
- package/lib-esm/lib/core-imports.d.ts +1 -9
- package/lib-esm/lib/core-imports.js +1 -88
- package/lib-esm/lib/core-imports.js.map +1 -1
- package/lib-esm/lib/cross-platform-path.d.ts +5 -0
- package/lib-esm/lib/cross-platform-path.js +74 -0
- package/lib-esm/lib/cross-platform-path.js.map +1 -0
- package/lib-esm/lib/env/env.angular-node-app.d.ts +1 -0
- package/lib-esm/lib/env/env.angular-node-app.js +3 -0
- package/lib-esm/lib/env/env.angular-node-app.js.map +1 -1
- package/lib-esm/lib/env/env.docs-webapp.d.ts +1 -0
- package/lib-esm/lib/env/env.docs-webapp.js +3 -0
- package/lib-esm/lib/env/env.docs-webapp.js.map +1 -1
- package/lib-esm/lib/env/env.electron-app.d.ts +1 -0
- package/lib-esm/lib/env/env.electron-app.js +3 -0
- package/lib-esm/lib/env/env.electron-app.js.map +1 -1
- package/lib-esm/lib/env/env.mobile-app.d.ts +1 -0
- package/lib-esm/lib/env/env.mobile-app.js +3 -0
- package/lib-esm/lib/env/env.mobile-app.js.map +1 -1
- package/lib-esm/lib/env/env.npm-lib-and-cli-tool.d.ts +1 -0
- package/lib-esm/lib/env/env.npm-lib-and-cli-tool.js +3 -0
- package/lib-esm/lib/env/env.npm-lib-and-cli-tool.js.map +1 -1
- package/lib-esm/lib/env/env.vscode-plugin.d.ts +1 -0
- package/lib-esm/lib/env/env.vscode-plugin.js +3 -0
- package/lib-esm/lib/env/env.vscode-plugin.js.map +1 -1
- package/lib-esm/lib/global-task-manager.js +2 -1
- package/lib-esm/lib/global-task-manager.js.map +1 -1
- package/lib-esm/lib/helpers.js +4 -3
- package/lib-esm/lib/helpers.js.map +1 -1
- package/lib-esm/lib/index.d.ts +2 -0
- package/lib-esm/lib/index.js +2 -0
- package/lib-esm/lib/index.js.map +1 -1
- package/lib-esm/lib/start-cli.js +2 -2
- package/lib-esm/lib/start-cli.js.map +1 -1
- package/lib-esm/lib/utils-dot-file.js +2 -1
- package/lib-esm/lib/utils-dot-file.js.map +1 -1
- package/lib-esm/lib/utils-etc-hosts.js +3 -2
- package/lib-esm/lib/utils-etc-hosts.js.map +1 -1
- package/lib-esm/lib/utils-exec-proc.js +2 -1
- package/lib-esm/lib/utils-exec-proc.js.map +1 -1
- package/lib-esm/lib/utils-files-folders.js +3 -1
- package/lib-esm/lib/utils-files-folders.js.map +1 -1
- package/lib-esm/lib/utils-json.js +2 -1
- package/lib-esm/lib/utils-json.js.map +1 -1
- package/lib-esm/lib/utils-os.js +2 -1
- package/lib-esm/lib/utils-os.js.map +1 -1
- package/lib-esm/lib/utils-process-logger.js +2 -1
- package/lib-esm/lib/utils-process-logger.js.map +1 -1
- package/lib-esm/lib/utils-process.d.ts +1 -0
- package/lib-esm/lib/utils-process.js +16 -1
- package/lib-esm/lib/utils-process.js.map +1 -1
- package/lib-esm/lib/utils-secret-env.d.ts +41 -0
- package/lib-esm/lib/utils-secret-env.js +372 -0
- package/lib-esm/lib/utils-secret-env.js.map +1 -0
- package/lib-esm/lib/utils-terminal.js +2 -1
- package/lib-esm/lib/utils-terminal.js.map +1 -1
- package/lib-prod/build-info._auto-generated_.d.ts +1 -1
- package/lib-prod/build-info._auto-generated_.js +1 -1
- package/lib-prod/config.js +2 -1
- package/lib-prod/config.js.map +1 -1
- package/lib-prod/core-cli.js.map +1 -1
- package/lib-prod/core-imports.d.ts +1 -9
- package/lib-prod/core-imports.js +1 -86
- package/lib-prod/core-imports.js.map +1 -1
- package/lib-prod/cross-platform-path.d.ts +5 -0
- package/lib-prod/cross-platform-path.js +74 -0
- package/lib-prod/cross-platform-path.js.map +1 -0
- package/lib-prod/env/env.angular-node-app.d.ts +1 -0
- package/lib-prod/env/env.angular-node-app.js +3 -0
- package/lib-prod/env/env.angular-node-app.js.map +1 -1
- package/lib-prod/env/env.docs-webapp.d.ts +1 -0
- package/lib-prod/env/env.docs-webapp.js +3 -0
- package/lib-prod/env/env.docs-webapp.js.map +1 -1
- package/lib-prod/env/env.electron-app.d.ts +1 -0
- package/lib-prod/env/env.electron-app.js +3 -0
- package/lib-prod/env/env.electron-app.js.map +1 -1
- package/lib-prod/env/env.mobile-app.d.ts +1 -0
- package/lib-prod/env/env.mobile-app.js +3 -0
- package/lib-prod/env/env.mobile-app.js.map +1 -1
- package/lib-prod/env/env.npm-lib-and-cli-tool.d.ts +1 -0
- package/lib-prod/env/env.npm-lib-and-cli-tool.js +3 -0
- package/lib-prod/env/env.npm-lib-and-cli-tool.js.map +1 -1
- package/lib-prod/env/env.vscode-plugin.d.ts +1 -0
- package/lib-prod/env/env.vscode-plugin.js +3 -0
- package/lib-prod/env/env.vscode-plugin.js.map +1 -1
- package/lib-prod/global-task-manager.js +2 -1
- package/lib-prod/global-task-manager.js.map +1 -1
- package/lib-prod/helpers.js +4 -3
- package/lib-prod/helpers.js.map +1 -1
- package/lib-prod/index.d.ts +2 -0
- package/lib-prod/index.js +2 -0
- package/lib-prod/index.js.map +1 -1
- package/lib-prod/package.json +1 -1
- package/lib-prod/start-cli.js +2 -2
- package/lib-prod/start-cli.js.map +1 -1
- package/lib-prod/utils-dot-file.js +2 -1
- package/lib-prod/utils-dot-file.js.map +1 -1
- package/lib-prod/utils-etc-hosts.js +3 -2
- package/lib-prod/utils-etc-hosts.js.map +1 -1
- package/lib-prod/utils-exec-proc.js +2 -1
- package/lib-prod/utils-exec-proc.js.map +1 -1
- package/lib-prod/utils-files-folders.js +3 -1
- package/lib-prod/utils-files-folders.js.map +1 -1
- package/lib-prod/utils-json.js +2 -1
- package/lib-prod/utils-json.js.map +1 -1
- package/lib-prod/utils-os.js +2 -1
- package/lib-prod/utils-os.js.map +1 -1
- package/lib-prod/utils-process-logger.js +2 -1
- package/lib-prod/utils-process-logger.js.map +1 -1
- package/lib-prod/utils-process.d.ts +1 -0
- package/lib-prod/utils-process.js +14 -1
- package/lib-prod/utils-process.js.map +1 -1
- package/lib-prod/utils-secret-env.d.ts +39 -0
- package/lib-prod/utils-secret-env.js +367 -0
- package/lib-prod/utils-secret-env.js.map +1 -0
- package/lib-prod/utils-terminal.js +2 -1
- package/lib-prod/utils-terminal.js.map +1 -1
- package/lib-prod.split-namespaces.json +18 -0
- package/package.json +1 -1
- package/websql/fesm2022/tnp-core-websql.mjs +1399 -1023
- package/websql/fesm2022/tnp-core-websql.mjs.map +1 -1
- package/websql/package.json +1 -1
- package/websql/types/tnp-core-websql.d.ts +50 -9
- package/websql-prod/fesm2022/tnp-core-websql-prod.mjs +1360 -990
- package/websql-prod/fesm2022/tnp-core-websql-prod.mjs.map +1 -1
- package/websql-prod/package.json +1 -1
- package/websql-prod/types/tnp-core-websql-prod.d.ts +48 -9
- package/websql-prod.split-namespaces.json +18 -0
|
@@ -1322,85 +1322,6 @@ let ps = void 0;
|
|
|
1322
1322
|
//#endregion
|
|
1323
1323
|
//#region set up browser mocks / mock fg
|
|
1324
1324
|
let fg = void 0;
|
|
1325
|
-
/* */
|
|
1326
|
-
/* */
|
|
1327
|
-
/* */
|
|
1328
|
-
/* */
|
|
1329
|
-
//#endregion
|
|
1330
|
-
//#endregion
|
|
1331
|
-
//#region crossPlatformPath
|
|
1332
|
-
//#region transform unix path to win32 path
|
|
1333
|
-
/**
|
|
1334
|
-
* transform unix path to win32 path
|
|
1335
|
-
*/
|
|
1336
|
-
const win32Path = (p) => {
|
|
1337
|
-
/* */
|
|
1338
|
-
/* */
|
|
1339
|
-
/* */
|
|
1340
|
-
/* */
|
|
1341
|
-
if (/^\/[a-z]\//.test(p)) {
|
|
1342
|
-
p = p.replace(/^\/[a-z]\//, `${p.charAt(1).toUpperCase()}:/`);
|
|
1343
|
-
}
|
|
1344
|
-
// return _.upperFirst(path.win32.normalize(p)); // TODO maybe not needed
|
|
1345
|
-
return path.win32.normalize(p);
|
|
1346
|
-
};
|
|
1347
|
-
//#endregion
|
|
1348
|
-
/**
|
|
1349
|
-
* This funciton will replace // to /
|
|
1350
|
-
*/
|
|
1351
|
-
const crossPlatformPath = (pathStringOrPathParts) => {
|
|
1352
|
-
if (Array.isArray(pathStringOrPathParts)) {
|
|
1353
|
-
pathStringOrPathParts = pathStringOrPathParts.join('/');
|
|
1354
|
-
}
|
|
1355
|
-
if (typeof pathStringOrPathParts !== 'string') {
|
|
1356
|
-
return pathStringOrPathParts;
|
|
1357
|
-
}
|
|
1358
|
-
// debugger;
|
|
1359
|
-
if (typeof pathStringOrPathParts === 'string' &&
|
|
1360
|
-
/^[A-Z]\:/.test(pathStringOrPathParts)) {
|
|
1361
|
-
pathStringOrPathParts = _.lowerFirst(pathStringOrPathParts);
|
|
1362
|
-
}
|
|
1363
|
-
const isExtendedLengthPath = /^\\\\\?\\/.test(pathStringOrPathParts);
|
|
1364
|
-
const hasNonAscii = /[^\u0000-\u0080]+/.test(pathStringOrPathParts); // eslint-disable-line no-control-regex
|
|
1365
|
-
if (isExtendedLengthPath) {
|
|
1366
|
-
console.warn(`[taon-core][crossPlatformPath]: Path starts with \\\\,
|
|
1367
|
-
this is not supported in crossPlatformPath`);
|
|
1368
|
-
/* */
|
|
1369
|
-
/* */
|
|
1370
|
-
/* */
|
|
1371
|
-
/* */
|
|
1372
|
-
}
|
|
1373
|
-
if (hasNonAscii) {
|
|
1374
|
-
const allNonAscii = pathStringOrPathParts.match(/[^\u0000-\u0080]+/g) || '';
|
|
1375
|
-
console.warn(`[taon-core][crossPlatformPath]: path below contains non-ascii characters (${allNonAscii}):
|
|
1376
|
-
"${pathStringOrPathParts}"`);
|
|
1377
|
-
console.warn(pathStringOrPathParts);
|
|
1378
|
-
}
|
|
1379
|
-
pathStringOrPathParts = (pathStringOrPathParts || '')
|
|
1380
|
-
.replace(/\\/g, '/')
|
|
1381
|
-
.replace(/\/\//g, '/')
|
|
1382
|
-
.replace(/\/\//g, '/'); // TODO probably not needed
|
|
1383
|
-
let isWindows = false;
|
|
1384
|
-
/* */
|
|
1385
|
-
/* */
|
|
1386
|
-
/* */
|
|
1387
|
-
/* */
|
|
1388
|
-
const regexWinPath1 = /^(\/)[a-zA-Z]\:/;
|
|
1389
|
-
// handle supported gitbash path
|
|
1390
|
-
// (nodejs require need to use /c/ instead of c:/)
|
|
1391
|
-
if (isWindows && regexWinPath1.test(pathStringOrPathParts)) {
|
|
1392
|
-
pathStringOrPathParts = pathStringOrPathParts.slice(1);
|
|
1393
|
-
}
|
|
1394
|
-
// let isUnixLike = !isWindows;
|
|
1395
|
-
// const regexWinPath2 = /^(\\)[a-zA-Z]\:/;
|
|
1396
|
-
// if (isUnixLike && regexWinPath2.test(pathStringOrPathParts)) {
|
|
1397
|
-
// console.warn(
|
|
1398
|
-
// `[taon-core][crossPlatformPath]: Path starts with \\ and not from /`,
|
|
1399
|
-
// );
|
|
1400
|
-
// console.trace(`path: "${pathStringOrPathParts}"`);
|
|
1401
|
-
// }
|
|
1402
|
-
return pathStringOrPathParts;
|
|
1403
|
-
};
|
|
1404
1325
|
//#endregion
|
|
1405
1326
|
|
|
1406
1327
|
var UtilsHttp;
|
|
@@ -1848,6 +1769,74 @@ var UtilsProgress;
|
|
|
1848
1769
|
//#endregion
|
|
1849
1770
|
})(UtilsProgress || (UtilsProgress = {}));
|
|
1850
1771
|
|
|
1772
|
+
/**
|
|
1773
|
+
* This funciton will replace // to /
|
|
1774
|
+
*/
|
|
1775
|
+
const crossPlatformPath = (pathStringOrPathParts) => {
|
|
1776
|
+
if (Array.isArray(pathStringOrPathParts)) {
|
|
1777
|
+
pathStringOrPathParts = pathStringOrPathParts.join('/');
|
|
1778
|
+
}
|
|
1779
|
+
if (typeof pathStringOrPathParts !== 'string') {
|
|
1780
|
+
return pathStringOrPathParts;
|
|
1781
|
+
}
|
|
1782
|
+
// debugger;
|
|
1783
|
+
if (typeof pathStringOrPathParts === 'string' &&
|
|
1784
|
+
/^[A-Z]\:/.test(pathStringOrPathParts)) {
|
|
1785
|
+
pathStringOrPathParts = _.lowerFirst(pathStringOrPathParts);
|
|
1786
|
+
}
|
|
1787
|
+
const isExtendedLengthPath = /^\\\\\?\\/.test(pathStringOrPathParts);
|
|
1788
|
+
const hasNonAscii = /[^\u0000-\u0080]+/.test(pathStringOrPathParts);
|
|
1789
|
+
if (isExtendedLengthPath) {
|
|
1790
|
+
Helpers.warn(`[taon-core][crossPlatformPath]: Path starts with \\\\,
|
|
1791
|
+
this is not supported in crossPlatformPath`);
|
|
1792
|
+
/* */
|
|
1793
|
+
/* */
|
|
1794
|
+
/* */
|
|
1795
|
+
/* */
|
|
1796
|
+
}
|
|
1797
|
+
if (hasNonAscii) {
|
|
1798
|
+
const allNonAscii = pathStringOrPathParts.match(/[^\u0000-\u0080]+/g) || '';
|
|
1799
|
+
Helpers.warn(`[taon-core][crossPlatformPath]: path below contains non-ascii characters (${allNonAscii}):
|
|
1800
|
+
"${pathStringOrPathParts}"`);
|
|
1801
|
+
Helpers.warn(pathStringOrPathParts);
|
|
1802
|
+
}
|
|
1803
|
+
pathStringOrPathParts = (pathStringOrPathParts || '')
|
|
1804
|
+
.replace(/\\/g, '/')
|
|
1805
|
+
.replace(/\/\//g, '/')
|
|
1806
|
+
.replace(/\/\//g, '/'); // TODO probably not needed
|
|
1807
|
+
let isWindows = false;
|
|
1808
|
+
/* */
|
|
1809
|
+
/* */
|
|
1810
|
+
/* */
|
|
1811
|
+
/* */
|
|
1812
|
+
const regexWinPath1 = /^(\/)[a-zA-Z]\:/;
|
|
1813
|
+
// handle supported gitbash path
|
|
1814
|
+
// (nodejs require need to use /c/ instead of c:/)
|
|
1815
|
+
if (isWindows && regexWinPath1.test(pathStringOrPathParts)) {
|
|
1816
|
+
pathStringOrPathParts = pathStringOrPathParts.slice(1);
|
|
1817
|
+
}
|
|
1818
|
+
// let isUnixLike = !isWindows;
|
|
1819
|
+
// const regexWinPath2 = /^(\\)[a-zA-Z]\:/;
|
|
1820
|
+
// if (isUnixLike && regexWinPath2.test(pathStringOrPathParts)) {
|
|
1821
|
+
// console.warn(
|
|
1822
|
+
// `[taon-core][crossPlatformPath]: Path starts with \\ and not from /`,
|
|
1823
|
+
// );
|
|
1824
|
+
// console.trace(`path: "${pathStringOrPathParts}"`);
|
|
1825
|
+
// }
|
|
1826
|
+
return pathStringOrPathParts;
|
|
1827
|
+
};
|
|
1828
|
+
const win32Path = (p) => {
|
|
1829
|
+
/* */
|
|
1830
|
+
/* */
|
|
1831
|
+
/* */
|
|
1832
|
+
/* */
|
|
1833
|
+
if (/^\/[a-z]\//.test(p)) {
|
|
1834
|
+
p = p.replace(/^\/[a-z]\//, `${p.charAt(1).toUpperCase()}:/`);
|
|
1835
|
+
}
|
|
1836
|
+
// return _.upperFirst(path.win32.normalize(p)); // TODO maybe not needed
|
|
1837
|
+
return path.win32.normalize(p);
|
|
1838
|
+
};
|
|
1839
|
+
|
|
1851
1840
|
// @taonSkipCut
|
|
1852
1841
|
// @ts-ignore
|
|
1853
1842
|
const isCloudflareWorker = typeof WebSocketPair !== 'undefined';
|
|
@@ -2292,15 +2281,30 @@ const taonActionFromParent = 'taon-action-from-parent';
|
|
|
2292
2281
|
|
|
2293
2282
|
//#region imports
|
|
2294
2283
|
//#endregion
|
|
2295
|
-
var
|
|
2296
|
-
(function (
|
|
2297
|
-
//#region utils
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2284
|
+
var UtilsFilesFoldersSync;
|
|
2285
|
+
(function (UtilsFilesFoldersSync) {
|
|
2286
|
+
//#region utils files folders sync / ignore folder files patterns
|
|
2287
|
+
UtilsFilesFoldersSync.IGNORE_FOLDERS_FILES_PATTERNS = [
|
|
2288
|
+
// '**/node_modules/**/*.*',
|
|
2289
|
+
'**/node_modules/**',
|
|
2290
|
+
// '**/node_modules',
|
|
2291
|
+
// '**/git/**/*.*',
|
|
2292
|
+
'**/.git/**/**',
|
|
2293
|
+
// '**/.git',
|
|
2294
|
+
// `**/${dotTaonFolder}/**/*.*`,
|
|
2295
|
+
`**/${dotTaonFolder}/**`,
|
|
2296
|
+
// `**/${dotTaonFolder}`,
|
|
2297
|
+
// `**/${dotTnpFolder}/**/*.*`,
|
|
2298
|
+
`**/${dotTnpFolder}/**`,
|
|
2299
|
+
// `**/${dotTnpFolder}`,
|
|
2300
|
+
'**/tmp-*',
|
|
2301
|
+
// `**/tmp-*/**/*.*`,
|
|
2302
|
+
'**/tmp-*/**',
|
|
2303
|
+
];
|
|
2304
|
+
//#endregion
|
|
2305
|
+
//#region utils files folders sync / read file
|
|
2306
|
+
UtilsFilesFoldersSync.readFile = (absoluteFilePath, // @ts-ignore
|
|
2307
|
+
options) => {
|
|
2304
2308
|
/* */
|
|
2305
2309
|
/* */
|
|
2306
2310
|
/* */
|
|
@@ -2339,6 +2343,15 @@ var UtilsProcess;
|
|
|
2339
2343
|
/* */
|
|
2340
2344
|
/* */
|
|
2341
2345
|
/* */
|
|
2346
|
+
/* */
|
|
2347
|
+
/* */
|
|
2348
|
+
/* */
|
|
2349
|
+
/* */
|
|
2350
|
+
return (void 0);
|
|
2351
|
+
};
|
|
2352
|
+
//#endregion
|
|
2353
|
+
//#region utils files folders sync / write file
|
|
2354
|
+
UtilsFilesFoldersSync.writeFile = (absoluteFilePath, input, options) => {
|
|
2342
2355
|
/* */
|
|
2343
2356
|
/* */
|
|
2344
2357
|
/* */
|
|
@@ -2370,11 +2383,6 @@ var UtilsProcess;
|
|
|
2370
2383
|
/* */
|
|
2371
2384
|
/* */
|
|
2372
2385
|
/* */
|
|
2373
|
-
return (void 0);
|
|
2374
|
-
};
|
|
2375
|
-
//#endregion
|
|
2376
|
-
//#region utils process / get git bash path
|
|
2377
|
-
UtilsProcess.getGitBashPath = () => {
|
|
2378
2386
|
/* */
|
|
2379
2387
|
/* */
|
|
2380
2388
|
/* */
|
|
@@ -2393,15 +2401,6 @@ var UtilsProcess;
|
|
|
2393
2401
|
/* */
|
|
2394
2402
|
/* */
|
|
2395
2403
|
/* */
|
|
2396
|
-
return (void 0);
|
|
2397
|
-
};
|
|
2398
|
-
//#endregion
|
|
2399
|
-
//#region utils process / start process in new graphical terminal window
|
|
2400
|
-
/**
|
|
2401
|
-
* TODO IMPLEMENT
|
|
2402
|
-
* start async node process
|
|
2403
|
-
*/
|
|
2404
|
-
UtilsProcess.startInNewTerminalWindow = (command, options) => {
|
|
2405
2404
|
/* */
|
|
2406
2405
|
/* */
|
|
2407
2406
|
/* */
|
|
@@ -2460,6 +2459,12 @@ var UtilsProcess;
|
|
|
2460
2459
|
/* */
|
|
2461
2460
|
/* */
|
|
2462
2461
|
/* */
|
|
2462
|
+
/* */
|
|
2463
|
+
/* */
|
|
2464
|
+
return (void 0);
|
|
2465
|
+
};
|
|
2466
|
+
//#region utils files folders sync / walk fs tree
|
|
2467
|
+
const walkFsTree = (root, options) => {
|
|
2463
2468
|
/* */
|
|
2464
2469
|
/* */
|
|
2465
2470
|
/* */
|
|
@@ -2513,14 +2518,6 @@ var UtilsProcess;
|
|
|
2513
2518
|
/* */
|
|
2514
2519
|
/* */
|
|
2515
2520
|
/* */
|
|
2516
|
-
return (void 0);
|
|
2517
|
-
};
|
|
2518
|
-
//#endregion
|
|
2519
|
-
//#region utils process / get bash or shell name
|
|
2520
|
-
UtilsProcess.getBashOrShellName = () => {
|
|
2521
|
-
//#region @browser
|
|
2522
|
-
return 'browser';
|
|
2523
|
-
//#endregion
|
|
2524
2521
|
/* */
|
|
2525
2522
|
/* */
|
|
2526
2523
|
/* */
|
|
@@ -2553,14 +2550,6 @@ var UtilsProcess;
|
|
|
2553
2550
|
/* */
|
|
2554
2551
|
/* */
|
|
2555
2552
|
/* */
|
|
2556
|
-
return (void 0);
|
|
2557
|
-
};
|
|
2558
|
-
//#endregion
|
|
2559
|
-
//#region utils process / get current process and child processes usage
|
|
2560
|
-
/**
|
|
2561
|
-
* Get CPU and memory usage for a single PID.
|
|
2562
|
-
*/
|
|
2563
|
-
UtilsProcess.getUsageForPid = async (pid) => {
|
|
2564
2553
|
/* */
|
|
2565
2554
|
/* */
|
|
2566
2555
|
/* */
|
|
@@ -2585,14 +2574,11 @@ var UtilsProcess;
|
|
|
2585
2574
|
return (void 0);
|
|
2586
2575
|
};
|
|
2587
2576
|
//#endregion
|
|
2588
|
-
//#region utils
|
|
2577
|
+
//#region utils files folders sync / get files from
|
|
2589
2578
|
/**
|
|
2590
|
-
*
|
|
2591
|
-
* Uses `ps -o pid= --ppid <pid>` to find child processes.
|
|
2579
|
+
* return absolute paths for files inside folder or link to folder
|
|
2592
2580
|
*/
|
|
2593
|
-
|
|
2594
|
-
/* */
|
|
2595
|
-
/* */
|
|
2581
|
+
UtilsFilesFoldersSync.getFilesFrom = (folderOrLinkToFolder, options) => {
|
|
2596
2582
|
/* */
|
|
2597
2583
|
/* */
|
|
2598
2584
|
/* */
|
|
@@ -2608,17 +2594,13 @@ var UtilsProcess;
|
|
|
2608
2594
|
/* */
|
|
2609
2595
|
/* */
|
|
2610
2596
|
return (void 0);
|
|
2611
|
-
}
|
|
2597
|
+
};
|
|
2612
2598
|
//#endregion
|
|
2613
|
-
//#region utils
|
|
2599
|
+
//#region utils files and folder sync / get folders from
|
|
2614
2600
|
/**
|
|
2615
|
-
*
|
|
2616
|
-
* Uses `wmic process where (ParentProcessId=<pid>) get ProcessId` to find child processes.
|
|
2601
|
+
* return absolute paths for folders inside folder or link to folder
|
|
2617
2602
|
*/
|
|
2618
|
-
|
|
2619
|
-
/* */
|
|
2620
|
-
/* */
|
|
2621
|
-
/* */
|
|
2603
|
+
UtilsFilesFoldersSync.getFoldersFrom = (folderOrLinkToFolder, options) => {
|
|
2622
2604
|
/* */
|
|
2623
2605
|
/* */
|
|
2624
2606
|
/* */
|
|
@@ -2634,30 +2616,15 @@ var UtilsProcess;
|
|
|
2634
2616
|
/* */
|
|
2635
2617
|
/* */
|
|
2636
2618
|
return (void 0);
|
|
2637
|
-
}
|
|
2619
|
+
};
|
|
2638
2620
|
//#endregion
|
|
2639
|
-
//#
|
|
2640
|
-
|
|
2641
|
-
* Cross-platform function to list *direct* child PIDs of a given PID.
|
|
2642
|
-
* Uses the appropriate command depending on `process.platform`.
|
|
2643
|
-
*/
|
|
2644
|
-
async function getChildPidsOnce(pid) {
|
|
2645
|
-
/* */
|
|
2621
|
+
//#endregion
|
|
2622
|
+
UtilsFilesFoldersSync.copyFolder = (sourceDir, destinationDir, options) => {
|
|
2646
2623
|
/* */
|
|
2647
2624
|
/* */
|
|
2648
2625
|
/* */
|
|
2649
2626
|
/* */
|
|
2650
2627
|
/* */
|
|
2651
|
-
return (void 0);
|
|
2652
|
-
}
|
|
2653
|
-
UtilsProcess.getChildPidsOnce = getChildPidsOnce;
|
|
2654
|
-
//#endregion
|
|
2655
|
-
//#region utils process / get current process and child usage
|
|
2656
|
-
/**
|
|
2657
|
-
* Get CPU and memory usage for the current process (the Node.js process itself),
|
|
2658
|
-
* plus any child processes spawned by it.
|
|
2659
|
-
*/
|
|
2660
|
-
UtilsProcess.getCurrentProcessAndChildUsage = async () => {
|
|
2661
2628
|
/* */
|
|
2662
2629
|
/* */
|
|
2663
2630
|
/* */
|
|
@@ -2671,6 +2638,13 @@ var UtilsProcess;
|
|
|
2671
2638
|
/* */
|
|
2672
2639
|
/* */
|
|
2673
2640
|
/* */
|
|
2641
|
+
/* */
|
|
2642
|
+
/* */
|
|
2643
|
+
/* */
|
|
2644
|
+
return (void 0);
|
|
2645
|
+
};
|
|
2646
|
+
//#region utils files folders sync / copy
|
|
2647
|
+
UtilsFilesFoldersSync.copy = (sourceDir, destinationDir, options) => {
|
|
2674
2648
|
/* */
|
|
2675
2649
|
/* */
|
|
2676
2650
|
/* */
|
|
@@ -2683,15 +2657,6 @@ var UtilsProcess;
|
|
|
2683
2657
|
/* */
|
|
2684
2658
|
/* */
|
|
2685
2659
|
/* */
|
|
2686
|
-
return (void 0);
|
|
2687
|
-
};
|
|
2688
|
-
//#endregion
|
|
2689
|
-
//#region utils process / kill all java processes
|
|
2690
|
-
/**
|
|
2691
|
-
* Kills all running Java processes cross‑platform.
|
|
2692
|
-
* @returns Promise<boolean> true if processes were killed, false if none found
|
|
2693
|
-
*/
|
|
2694
|
-
UtilsProcess.killAllJava = async () => {
|
|
2695
2660
|
/* */
|
|
2696
2661
|
/* */
|
|
2697
2662
|
/* */
|
|
@@ -2719,11 +2684,6 @@ var UtilsProcess;
|
|
|
2719
2684
|
/* */
|
|
2720
2685
|
/* */
|
|
2721
2686
|
/* */
|
|
2722
|
-
return (void 0);
|
|
2723
|
-
};
|
|
2724
|
-
//#endregion
|
|
2725
|
-
//#region utils process / kill process by pid or child process
|
|
2726
|
-
UtilsProcess.killProcess = async (pidOrProcess) => {
|
|
2727
2687
|
/* */
|
|
2728
2688
|
/* */
|
|
2729
2689
|
/* */
|
|
@@ -2750,15 +2710,6 @@ var UtilsProcess;
|
|
|
2750
2710
|
/* */
|
|
2751
2711
|
/* */
|
|
2752
2712
|
/* */
|
|
2753
|
-
return (void 0);
|
|
2754
|
-
};
|
|
2755
|
-
//#endregion
|
|
2756
|
-
//#region utils process / kill process on port
|
|
2757
|
-
UtilsProcess.killProcessOnPort = async (port) => {
|
|
2758
|
-
if (!port || isNaN(port) || UtilsOs.isBrowser) {
|
|
2759
|
-
Helpers.warn(`[UtilsProcess.killProcessOnPort]: Invalid port number: ${port}`);
|
|
2760
|
-
return false;
|
|
2761
|
-
}
|
|
2762
2713
|
/* */
|
|
2763
2714
|
/* */
|
|
2764
2715
|
/* */
|
|
@@ -2815,16 +2766,6 @@ var UtilsProcess;
|
|
|
2815
2766
|
/* */
|
|
2816
2767
|
/* */
|
|
2817
2768
|
/* */
|
|
2818
|
-
return (void 0);
|
|
2819
|
-
};
|
|
2820
|
-
//#endregion
|
|
2821
|
-
//#region utils process / kill all other node processes except itself
|
|
2822
|
-
/**
|
|
2823
|
-
* Kills all Node.js processes except the current process.
|
|
2824
|
-
* Works on Windows, macOS, and Linux.
|
|
2825
|
-
* @returns {number} Number of processes killed
|
|
2826
|
-
*/
|
|
2827
|
-
UtilsProcess.killAllOtherNodeProcesses = async () => {
|
|
2828
2769
|
/* */
|
|
2829
2770
|
/* */
|
|
2830
2771
|
/* */
|
|
@@ -2887,37 +2828,6 @@ var UtilsProcess;
|
|
|
2887
2828
|
/* */
|
|
2888
2829
|
/* */
|
|
2889
2830
|
/* */
|
|
2890
|
-
return (void 0);
|
|
2891
|
-
};
|
|
2892
|
-
//#endregion
|
|
2893
|
-
//#region utils process / is node version ok
|
|
2894
|
-
UtilsProcess.isNodeVersionOk = (options) => {
|
|
2895
|
-
if (!globalThis || !globalThis.process || !globalThis.process.version) {
|
|
2896
|
-
return false;
|
|
2897
|
-
}
|
|
2898
|
-
options = options || {};
|
|
2899
|
-
options.required = options.required || '18.0.0';
|
|
2900
|
-
const current = globalThis.process.version.replace(/^v/, '');
|
|
2901
|
-
const [curMajor, curMinor, curPatch] = current.split('.').map(Number);
|
|
2902
|
-
const [reqMajor, reqMinor, reqPatch] = options.required
|
|
2903
|
-
.replace(/^v/, '')
|
|
2904
|
-
.split('.')
|
|
2905
|
-
.map(Number);
|
|
2906
|
-
const ok = curMajor > reqMajor ||
|
|
2907
|
-
(curMajor === reqMajor && curMinor > reqMinor) ||
|
|
2908
|
-
(curMajor === reqMajor && curMinor === reqMinor && curPatch >= reqPatch);
|
|
2909
|
-
if (options?.log) {
|
|
2910
|
-
console.log(ok
|
|
2911
|
-
? `✅ Node.js version OK (required ≥ ${options.required}, current ${current})`
|
|
2912
|
-
: `❌ Node.js version too low (required ≥ ${options.required}, current ${current})`);
|
|
2913
|
-
}
|
|
2914
|
-
if (options?.throwErrorIfNotOk && !ok) {
|
|
2915
|
-
throw new Error(`Node.js version too low (required ≥ ${options.required}, current ${current})`);
|
|
2916
|
-
}
|
|
2917
|
-
return ok;
|
|
2918
|
-
};
|
|
2919
|
-
//#endregion
|
|
2920
|
-
UtilsProcess.getPathOfExecutable = async (command) => {
|
|
2921
2831
|
/* */
|
|
2922
2832
|
/* */
|
|
2923
2833
|
/* */
|
|
@@ -2936,95 +2846,14 @@ var UtilsProcess;
|
|
|
2936
2846
|
/* */
|
|
2937
2847
|
/* */
|
|
2938
2848
|
/* */
|
|
2939
|
-
return (void 0);
|
|
2940
|
-
};
|
|
2941
|
-
})(UtilsProcess || (UtilsProcess = {}));
|
|
2942
|
-
|
|
2943
|
-
//#region imports
|
|
2944
|
-
//#endregion
|
|
2945
|
-
var UtilsOs;
|
|
2946
|
-
(function (UtilsOs) {
|
|
2947
|
-
//#region utils os / is running in browser
|
|
2948
|
-
/**
|
|
2949
|
-
* check if script is running in client browser
|
|
2950
|
-
* (websql model -> is also considered as browser
|
|
2951
|
-
* because it is running in browser)
|
|
2952
|
-
*/
|
|
2953
|
-
UtilsOs.isRunningInBrowser = () => {
|
|
2954
2849
|
/* */
|
|
2955
2850
|
/* */
|
|
2956
|
-
return true;
|
|
2957
|
-
};
|
|
2958
|
-
//#endregion
|
|
2959
|
-
//#region utils os / is running in node
|
|
2960
|
-
/**
|
|
2961
|
-
* check if script is running in nodejs
|
|
2962
|
-
* (backend script or electron script)
|
|
2963
|
-
*/
|
|
2964
|
-
UtilsOs.isRunningInNode = () => {
|
|
2965
2851
|
/* */
|
|
2966
2852
|
/* */
|
|
2967
|
-
return false;
|
|
2968
|
-
};
|
|
2969
|
-
//#endregion
|
|
2970
|
-
//#region utils os / is running in websql
|
|
2971
|
-
/**
|
|
2972
|
-
* check if script is running special
|
|
2973
|
-
* browser mode that has sql.js backend
|
|
2974
|
-
* and executes sql queries in browser
|
|
2975
|
-
*/
|
|
2976
|
-
UtilsOs.isRunningInWebSQL = () => {
|
|
2977
2853
|
/* */
|
|
2978
2854
|
/* */
|
|
2979
2855
|
/* */
|
|
2980
2856
|
/* */
|
|
2981
|
-
return false;
|
|
2982
|
-
};
|
|
2983
|
-
//#endregion
|
|
2984
|
-
//#region utils os / is running in ssr mode
|
|
2985
|
-
UtilsOs.isRunningInSSRMode = () => {
|
|
2986
|
-
return typeof globalThis.window === 'undefined';
|
|
2987
|
-
};
|
|
2988
|
-
//#endregion
|
|
2989
|
-
//#region utils os / is running in electron
|
|
2990
|
-
/**
|
|
2991
|
-
* check whether the current process is running inside
|
|
2992
|
-
* Cloudflare worker
|
|
2993
|
-
*/
|
|
2994
|
-
UtilsOs.isRunningInCloudflareWorker = () => {
|
|
2995
|
-
return isCloudflareWorker;
|
|
2996
|
-
};
|
|
2997
|
-
//#endregion
|
|
2998
|
-
//#region utils os / is running in electron
|
|
2999
|
-
/**
|
|
3000
|
-
* check whether the current process is running inside
|
|
3001
|
-
* Electron backend or browser.
|
|
3002
|
-
*/
|
|
3003
|
-
UtilsOs.isRunningInElectron = () => {
|
|
3004
|
-
// Electron main or renderer (most reliable)
|
|
3005
|
-
if (typeof process !== 'undefined' && process?.versions?.electron) {
|
|
3006
|
-
return true;
|
|
3007
|
-
}
|
|
3008
|
-
// Renderer with nodeIntegration
|
|
3009
|
-
if (typeof globalThis !== 'undefined' &&
|
|
3010
|
-
globalThis?.process?.type === 'renderer') {
|
|
3011
|
-
return true;
|
|
3012
|
-
}
|
|
3013
|
-
// Renderer with nodeIntegration disabled
|
|
3014
|
-
if (typeof navigator === 'object' &&
|
|
3015
|
-
typeof navigator.userAgent === 'string' &&
|
|
3016
|
-
/Electron/i.test(navigator.userAgent)) {
|
|
3017
|
-
return true;
|
|
3018
|
-
}
|
|
3019
|
-
return false;
|
|
3020
|
-
};
|
|
3021
|
-
//#endregion
|
|
3022
|
-
//#region utils os / is running in vscode extension
|
|
3023
|
-
/**
|
|
3024
|
-
* Check whether the current process is running inside
|
|
3025
|
-
* a Visual Studio Code extension.
|
|
3026
|
-
*/
|
|
3027
|
-
UtilsOs.isRunningInVscodeExtension = () => {
|
|
3028
2857
|
/* */
|
|
3029
2858
|
/* */
|
|
3030
2859
|
/* */
|
|
@@ -3034,18 +2863,17 @@ var UtilsOs;
|
|
|
3034
2863
|
/* */
|
|
3035
2864
|
/* */
|
|
3036
2865
|
return (void 0);
|
|
3037
|
-
return false;
|
|
3038
2866
|
};
|
|
3039
2867
|
//#endregion
|
|
3040
|
-
//#region utils
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
2868
|
+
//#region utils files folders sync / filter dont copy
|
|
2869
|
+
UtilsFilesFoldersSync.filterDontCopy = (basePathFoldersTosSkip, projectOrBasepath) => {
|
|
2870
|
+
/* */
|
|
2871
|
+
/* */
|
|
2872
|
+
/* */
|
|
2873
|
+
/* */
|
|
2874
|
+
/* */
|
|
2875
|
+
/* */
|
|
2876
|
+
/* */
|
|
3049
2877
|
/* */
|
|
3050
2878
|
/* */
|
|
3051
2879
|
/* */
|
|
@@ -3066,8 +2894,8 @@ var UtilsOs;
|
|
|
3066
2894
|
return (void 0);
|
|
3067
2895
|
};
|
|
3068
2896
|
//#endregion
|
|
3069
|
-
//#region utils
|
|
3070
|
-
|
|
2897
|
+
//#region utils files folders sync / filter only copy
|
|
2898
|
+
UtilsFilesFoldersSync.filterOnlyCopy = (basePathFoldersOnlyToInclude, projectOrBasepath) => {
|
|
3071
2899
|
/* */
|
|
3072
2900
|
/* */
|
|
3073
2901
|
/* */
|
|
@@ -3089,6 +2917,11 @@ var UtilsOs;
|
|
|
3089
2917
|
/* */
|
|
3090
2918
|
/* */
|
|
3091
2919
|
/* */
|
|
2920
|
+
return (void 0);
|
|
2921
|
+
};
|
|
2922
|
+
//#endregion
|
|
2923
|
+
//#region utils files folders sync / copy file
|
|
2924
|
+
UtilsFilesFoldersSync.copyFile = (sourcePath, destinationPath, options) => {
|
|
3092
2925
|
/* */
|
|
3093
2926
|
/* */
|
|
3094
2927
|
/* */
|
|
@@ -3110,18 +2943,12 @@ var UtilsOs;
|
|
|
3110
2943
|
/* */
|
|
3111
2944
|
/* */
|
|
3112
2945
|
/* */
|
|
3113
|
-
return (void 0);
|
|
3114
|
-
};
|
|
3115
|
-
UtilsOs.isRunningInWindowsCmd = () => {
|
|
3116
2946
|
/* */
|
|
3117
2947
|
/* */
|
|
3118
2948
|
/* */
|
|
3119
2949
|
/* */
|
|
3120
2950
|
/* */
|
|
3121
2951
|
/* */
|
|
3122
|
-
return (void 0);
|
|
3123
|
-
};
|
|
3124
|
-
UtilsOs.isRunningInWindowsGitBash = () => {
|
|
3125
2952
|
/* */
|
|
3126
2953
|
/* */
|
|
3127
2954
|
/* */
|
|
@@ -3130,14 +2957,6 @@ var UtilsOs;
|
|
|
3130
2957
|
/* */
|
|
3131
2958
|
/* */
|
|
3132
2959
|
/* */
|
|
3133
|
-
return (void 0);
|
|
3134
|
-
};
|
|
3135
|
-
//#endregion
|
|
3136
|
-
//#region utils os / is running in docker
|
|
3137
|
-
UtilsOs.isRunningInDocker = () => {
|
|
3138
|
-
//#region @browser
|
|
3139
|
-
return false;
|
|
3140
|
-
//#endregion
|
|
3141
2960
|
/* */
|
|
3142
2961
|
/* */
|
|
3143
2962
|
/* */
|
|
@@ -3183,14 +3002,6 @@ var UtilsOs;
|
|
|
3183
3002
|
/* */
|
|
3184
3003
|
/* */
|
|
3185
3004
|
/* */
|
|
3186
|
-
return (void 0);
|
|
3187
|
-
};
|
|
3188
|
-
//#endregion
|
|
3189
|
-
//#region utils os / is running in linux distro
|
|
3190
|
-
/**
|
|
3191
|
-
* check what linux you are running
|
|
3192
|
-
*/
|
|
3193
|
-
UtilsOs.isRunningInLinuxDistro = (linuxType) => {
|
|
3194
3005
|
/* */
|
|
3195
3006
|
/* */
|
|
3196
3007
|
/* */
|
|
@@ -3213,17 +3024,22 @@ var UtilsOs;
|
|
|
3213
3024
|
/* */
|
|
3214
3025
|
/* */
|
|
3215
3026
|
/* */
|
|
3027
|
+
return (void 0);
|
|
3028
|
+
};
|
|
3029
|
+
//#endregion
|
|
3030
|
+
//#region utils files folders sync / move
|
|
3031
|
+
/**
|
|
3032
|
+
* @deprecated use .copy and then .remove on
|
|
3033
|
+
* source folder..
|
|
3034
|
+
*
|
|
3035
|
+
* This method is messing with parcel watcher
|
|
3036
|
+
* (moved files are not detected)
|
|
3037
|
+
*/
|
|
3038
|
+
UtilsFilesFoldersSync.move = (from, to, options) => {
|
|
3216
3039
|
/* */
|
|
3217
3040
|
/* */
|
|
3218
3041
|
/* */
|
|
3219
3042
|
/* */
|
|
3220
|
-
//#region @browser
|
|
3221
|
-
return false;
|
|
3222
|
-
//#endregion
|
|
3223
|
-
};
|
|
3224
|
-
//#endregion
|
|
3225
|
-
//#region utils os / is running in linux graphics capable environment
|
|
3226
|
-
UtilsOs.isRunningInLinuxGraphicsCapableEnvironment = () => {
|
|
3227
3043
|
/* */
|
|
3228
3044
|
/* */
|
|
3229
3045
|
/* */
|
|
@@ -3231,11 +3047,6 @@ var UtilsOs;
|
|
|
3231
3047
|
/* */
|
|
3232
3048
|
/* */
|
|
3233
3049
|
/* */
|
|
3234
|
-
return (void 0);
|
|
3235
|
-
};
|
|
3236
|
-
//#endregion
|
|
3237
|
-
//#region utils os / is running in os with graphics capable environment
|
|
3238
|
-
UtilsOs.isRunningInOsWithGraphicsCapableEnvironment = () => {
|
|
3239
3050
|
/* */
|
|
3240
3051
|
/* */
|
|
3241
3052
|
/* */
|
|
@@ -3244,38 +3055,11 @@ var UtilsOs;
|
|
|
3244
3055
|
/* */
|
|
3245
3056
|
/* */
|
|
3246
3057
|
/* */
|
|
3247
|
-
return (void 0);
|
|
3248
|
-
};
|
|
3249
|
-
//#endregion
|
|
3250
|
-
//#region utils os / is running in cli mode
|
|
3251
|
-
/**
|
|
3252
|
-
* Check whether the current process is running in CLI mode.
|
|
3253
|
-
*/
|
|
3254
|
-
UtilsOs.isRunningInCliMode = () => {
|
|
3255
|
-
//#region @browser
|
|
3256
|
-
return false;
|
|
3257
|
-
//#endregion
|
|
3258
3058
|
/* */
|
|
3259
3059
|
/* */
|
|
3260
|
-
return (void 0);
|
|
3261
|
-
};
|
|
3262
|
-
//#endregion
|
|
3263
|
-
//#region utils os / is running in mocha test
|
|
3264
|
-
/**
|
|
3265
|
-
* Check whether the current process is running in mocha test.
|
|
3266
|
-
*/
|
|
3267
|
-
UtilsOs.isRunningInMochaTest = () => {
|
|
3268
|
-
//#region @browser
|
|
3269
|
-
return false;
|
|
3270
|
-
//#endregion
|
|
3271
3060
|
/* */
|
|
3272
3061
|
/* */
|
|
3273
3062
|
/* */
|
|
3274
|
-
return (void 0);
|
|
3275
|
-
};
|
|
3276
|
-
//#endregion
|
|
3277
|
-
//#region utils os / is port in use
|
|
3278
|
-
const isPortInUseOnHost = (port, host) => {
|
|
3279
3063
|
/* */
|
|
3280
3064
|
/* */
|
|
3281
3065
|
/* */
|
|
@@ -3301,45 +3085,6 @@ var UtilsOs;
|
|
|
3301
3085
|
/* */
|
|
3302
3086
|
/* */
|
|
3303
3087
|
/* */
|
|
3304
|
-
return (void 0);
|
|
3305
|
-
};
|
|
3306
|
-
/**
|
|
3307
|
-
* Checks if a given port is already in use (bound by another process).
|
|
3308
|
-
*
|
|
3309
|
-
* @param port - The port number to check.
|
|
3310
|
-
* @param host - The hostname or IP address to bind to (default: '127.0.0.1').
|
|
3311
|
-
* @returns Promise<boolean> - Resolves to `true` if the port is in use, otherwise `false`.
|
|
3312
|
-
*/
|
|
3313
|
-
UtilsOs.isPortInUse = async (port, options) => {
|
|
3314
|
-
/* */
|
|
3315
|
-
/* */
|
|
3316
|
-
/* */
|
|
3317
|
-
/* */
|
|
3318
|
-
/* */
|
|
3319
|
-
/* */
|
|
3320
|
-
/* */
|
|
3321
|
-
/* */
|
|
3322
|
-
/* */
|
|
3323
|
-
/* */
|
|
3324
|
-
/* */
|
|
3325
|
-
/* */
|
|
3326
|
-
/* */
|
|
3327
|
-
return (void 0);
|
|
3328
|
-
};
|
|
3329
|
-
//#endregion
|
|
3330
|
-
//#region utils os / is docker available
|
|
3331
|
-
/**
|
|
3332
|
-
* Check if docker is available on this system
|
|
3333
|
-
* and it is running (daemon active)
|
|
3334
|
-
*/
|
|
3335
|
-
UtilsOs.isDockerAvailable = async () => {
|
|
3336
|
-
if (UtilsOs.isBrowser) {
|
|
3337
|
-
return false;
|
|
3338
|
-
}
|
|
3339
|
-
/* */
|
|
3340
|
-
/* */
|
|
3341
|
-
/* */
|
|
3342
|
-
/* */
|
|
3343
3088
|
/* */
|
|
3344
3089
|
/* */
|
|
3345
3090
|
/* */
|
|
@@ -3368,68 +3113,50 @@ var UtilsOs;
|
|
|
3368
3113
|
return (void 0);
|
|
3369
3114
|
};
|
|
3370
3115
|
//#endregion
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
/* */
|
|
3392
|
-
/* */
|
|
3393
|
-
/* */
|
|
3394
|
-
/* */
|
|
3395
|
-
/* */
|
|
3396
|
-
/* */
|
|
3397
|
-
/* */
|
|
3116
|
+
})(UtilsFilesFoldersSync || (UtilsFilesFoldersSync = {}));
|
|
3117
|
+
/**
|
|
3118
|
+
* TODO @LAST @IN_PROGRESS
|
|
3119
|
+
* - utils for files and folders operations
|
|
3120
|
+
* - export when ready
|
|
3121
|
+
* - should be ready for everything async refactor
|
|
3122
|
+
*/
|
|
3123
|
+
var UtilsFilesFolders;
|
|
3124
|
+
(function (UtilsFilesFolders) {
|
|
3125
|
+
//#region utils files folders / ignore folder files patterns
|
|
3126
|
+
/**
|
|
3127
|
+
* Patterns that should be always ignored
|
|
3128
|
+
*/
|
|
3129
|
+
UtilsFilesFolders.IGNORE_FOLDERS_FILES_PATTERNS = UtilsFilesFoldersSync.IGNORE_FOLDERS_FILES_PATTERNS;
|
|
3130
|
+
//#endregion
|
|
3131
|
+
//#region utils files folders operations / remove file or folder or link
|
|
3132
|
+
/**
|
|
3133
|
+
* remove file or folder or link
|
|
3134
|
+
*/
|
|
3135
|
+
const remove = async (absolutePath, options) => {
|
|
3398
3136
|
/* */
|
|
3399
3137
|
/* */
|
|
3400
3138
|
/* */
|
|
3401
3139
|
/* */
|
|
3402
3140
|
/* */
|
|
3403
3141
|
return (void 0);
|
|
3404
|
-
//#region @browser
|
|
3405
|
-
console.warn(`UtilsOs.openFolderInFileExplorer is not supported in browser mode`);
|
|
3406
|
-
//#endregion
|
|
3407
3142
|
};
|
|
3408
3143
|
//#endregion
|
|
3409
|
-
//#region utils
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
/* */
|
|
3415
|
-
/* */
|
|
3416
|
-
/* */
|
|
3417
|
-
/* */
|
|
3418
|
-
/* */
|
|
3419
|
-
/* */
|
|
3420
|
-
/* */
|
|
3421
|
-
/* */
|
|
3422
|
-
/* */
|
|
3423
|
-
/* */
|
|
3424
|
-
/* */
|
|
3425
|
-
/* */
|
|
3426
|
-
/* */
|
|
3427
|
-
/* */
|
|
3144
|
+
//#region utils files folders operations / remove file or folder or link
|
|
3145
|
+
/**
|
|
3146
|
+
* remove file or folder or link
|
|
3147
|
+
*/
|
|
3148
|
+
const removeByPattern = async (globPattern, options) => {
|
|
3428
3149
|
/* */
|
|
3429
3150
|
/* */
|
|
3430
3151
|
/* */
|
|
3431
3152
|
/* */
|
|
3432
3153
|
/* */
|
|
3154
|
+
return (void 0);
|
|
3155
|
+
};
|
|
3156
|
+
//#endregion
|
|
3157
|
+
//#region utils files folders operations / get files from
|
|
3158
|
+
async function getFilesFromAsync(folderOrLinkToFolder, options = {}) {
|
|
3159
|
+
return null;
|
|
3433
3160
|
/* */
|
|
3434
3161
|
/* */
|
|
3435
3162
|
/* */
|
|
@@ -3463,11 +3190,6 @@ var UtilsOs;
|
|
|
3463
3190
|
/* */
|
|
3464
3191
|
/* */
|
|
3465
3192
|
/* */
|
|
3466
|
-
return (void 0);
|
|
3467
|
-
};
|
|
3468
|
-
const MANAGED_TEMP_FOLDER_NAME = '__temp__folders__with__exp__date';
|
|
3469
|
-
const TEMP_METADATA_FILE_NAME = '__temp_folder_metadata__.json';
|
|
3470
|
-
UtilsOs.getTempFolder = (options = {}) => {
|
|
3471
3193
|
/* */
|
|
3472
3194
|
/* */
|
|
3473
3195
|
/* */
|
|
@@ -3491,6 +3213,168 @@ var UtilsOs;
|
|
|
3491
3213
|
/* */
|
|
3492
3214
|
/* */
|
|
3493
3215
|
/* */
|
|
3216
|
+
return (void 0);
|
|
3217
|
+
}
|
|
3218
|
+
//#endregion
|
|
3219
|
+
//#region utils files folders operations / read file
|
|
3220
|
+
/**
|
|
3221
|
+
* TODO @IN_PROGRESS
|
|
3222
|
+
*/
|
|
3223
|
+
const readFileAsync = async (absoluteFilePath, options) => {
|
|
3224
|
+
return void 0;
|
|
3225
|
+
};
|
|
3226
|
+
/* */
|
|
3227
|
+
/* */
|
|
3228
|
+
/**
|
|
3229
|
+
* TODO @IN_PROGRESS
|
|
3230
|
+
*/
|
|
3231
|
+
const writeFileAsync = async (absoluteFilePath, input, options) => {
|
|
3232
|
+
return void 0;
|
|
3233
|
+
};
|
|
3234
|
+
//#endregion
|
|
3235
|
+
//#region utils files folders operations / is existed symlink
|
|
3236
|
+
/**
|
|
3237
|
+
* TODO @IN_PROGRESS
|
|
3238
|
+
*/
|
|
3239
|
+
const isExistedSymlink = async (absoluteFilePath) => {
|
|
3240
|
+
return void 0;
|
|
3241
|
+
};
|
|
3242
|
+
//#endregion
|
|
3243
|
+
//#region utils files folders operations / is un existed link
|
|
3244
|
+
/**
|
|
3245
|
+
* TODO @IN_PROGRESS
|
|
3246
|
+
*/
|
|
3247
|
+
const isUnExistedLink = async (absoluteFilePath) => {
|
|
3248
|
+
return void 0;
|
|
3249
|
+
};
|
|
3250
|
+
//#endregion
|
|
3251
|
+
})(UtilsFilesFolders || (UtilsFilesFolders = {}));
|
|
3252
|
+
|
|
3253
|
+
var UtilsJson;
|
|
3254
|
+
(function (UtilsJson) {
|
|
3255
|
+
//#region get attributes from jsonc or json5 file
|
|
3256
|
+
/**
|
|
3257
|
+
* ! TODO handle packages like zone.js with dot
|
|
3258
|
+
* Get attributes from jsonc or json5 file
|
|
3259
|
+
* @param jsonDeepPath lodash path to property in json ex. deep.path.to.prop
|
|
3260
|
+
* @param fileContent jsonc or json5 - json with comments
|
|
3261
|
+
* @returns array of attributes
|
|
3262
|
+
*/
|
|
3263
|
+
UtilsJson.getAtrributiesFromJsonWithComments = (jsonDeepPath, // lodash path to property in json ex. deep.path.to.prop
|
|
3264
|
+
fileContent) => {
|
|
3265
|
+
const lines = fileContent.split('\n');
|
|
3266
|
+
// split path to parts but keep part if is for example 'sql.js
|
|
3267
|
+
const pathParts = jsonDeepPath.split('.').reduce((a, b) => {
|
|
3268
|
+
if (a.length === 0) {
|
|
3269
|
+
return [b];
|
|
3270
|
+
}
|
|
3271
|
+
const last = a[a.length - 1];
|
|
3272
|
+
if ((last.startsWith(`['`) && b.endsWith(`']`)) ||
|
|
3273
|
+
(last.startsWith(`["`) && b.endsWith(`"]`))) {
|
|
3274
|
+
a[a.length - 1] = [last, b].join('.');
|
|
3275
|
+
}
|
|
3276
|
+
else {
|
|
3277
|
+
a.push(b);
|
|
3278
|
+
}
|
|
3279
|
+
return a;
|
|
3280
|
+
}, []);
|
|
3281
|
+
// console.log({ pathParts });
|
|
3282
|
+
// const pathParts = jsonDeepPath.split('.');
|
|
3283
|
+
// const keyName = pathParts.pop()!.replace(/^\["(.+)"\]$/, '$1');
|
|
3284
|
+
const keyName = pathParts.pop().replace(/^\["(.+)"\]$/, '$1');
|
|
3285
|
+
let currentPath = '';
|
|
3286
|
+
let attributes = [];
|
|
3287
|
+
let collectedComments = [];
|
|
3288
|
+
for (const line of lines) {
|
|
3289
|
+
const trimmedLine = line.trim();
|
|
3290
|
+
if (trimmedLine.startsWith('//')) {
|
|
3291
|
+
// Collect comments
|
|
3292
|
+
collectedComments.push(trimmedLine);
|
|
3293
|
+
// trimmedLine.startsWith('//pizda') &&
|
|
3294
|
+
// console.log('pushlin line', { trimmedLine });
|
|
3295
|
+
}
|
|
3296
|
+
else if (trimmedLine.startsWith('"') || trimmedLine.startsWith("'")) {
|
|
3297
|
+
// Extract the key from the line
|
|
3298
|
+
const match = trimmedLine.match(/["']([^"']+)["']\s*:/);
|
|
3299
|
+
// console.log({ match0: match && match[0], match1: match && match[1] });
|
|
3300
|
+
if (match) {
|
|
3301
|
+
const key = match[1];
|
|
3302
|
+
currentPath = currentPath
|
|
3303
|
+
? `${currentPath}.${key.includes('.') ? `['${key}']` : key}`
|
|
3304
|
+
: key;
|
|
3305
|
+
// console.log({ key });
|
|
3306
|
+
// Check if the current path matches the jsonDeepPath
|
|
3307
|
+
if ((currentPath.endsWith(keyName) &&
|
|
3308
|
+
!currentPath.endsWith('/' + keyName)) ||
|
|
3309
|
+
currentPath.endsWith(`['${keyName}']`)) {
|
|
3310
|
+
// console.log('extract attributes', {
|
|
3311
|
+
// keyName,
|
|
3312
|
+
// collectedCommentsLength: collectedComments.length,
|
|
3313
|
+
// });
|
|
3314
|
+
// Process the collected comments to extract attributes
|
|
3315
|
+
attributes = extractAttributesFromComments(collectedComments);
|
|
3316
|
+
break;
|
|
3317
|
+
}
|
|
3318
|
+
// Reset collected comments as they only relate to the next key
|
|
3319
|
+
collectedComments = [];
|
|
3320
|
+
}
|
|
3321
|
+
}
|
|
3322
|
+
}
|
|
3323
|
+
return attributes;
|
|
3324
|
+
};
|
|
3325
|
+
//#endregion
|
|
3326
|
+
//#region get attributes from comment
|
|
3327
|
+
UtilsJson.getAttributiesFromComment = (comment, attributes = []) => {
|
|
3328
|
+
// Match @name=value OR @name
|
|
3329
|
+
// Values can be "..." or '...' or unquoted token without @
|
|
3330
|
+
const attrRegex = /@(\w+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s@]+)))?/g;
|
|
3331
|
+
let match;
|
|
3332
|
+
while ((match = attrRegex.exec(comment)) !== null) {
|
|
3333
|
+
const [, name, doubleQuoted, singleQuoted, unquoted] = match;
|
|
3334
|
+
const value = doubleQuoted ?? singleQuoted ?? unquoted;
|
|
3335
|
+
const existingAttribute = attributes.find(attr => attr.name === `@${name}`);
|
|
3336
|
+
if (existingAttribute) {
|
|
3337
|
+
if (value !== undefined) {
|
|
3338
|
+
if (Array.isArray(existingAttribute.value)) {
|
|
3339
|
+
existingAttribute.value.push(value);
|
|
3340
|
+
}
|
|
3341
|
+
else {
|
|
3342
|
+
existingAttribute.value = [existingAttribute.value, value];
|
|
3343
|
+
}
|
|
3344
|
+
}
|
|
3345
|
+
}
|
|
3346
|
+
else {
|
|
3347
|
+
attributes.push({
|
|
3348
|
+
name: `@${name}`,
|
|
3349
|
+
value: value !== undefined ? value : true,
|
|
3350
|
+
});
|
|
3351
|
+
}
|
|
3352
|
+
}
|
|
3353
|
+
// Normalize single values not to be arrays
|
|
3354
|
+
attributes.forEach(attr => {
|
|
3355
|
+
if (Array.isArray(attr.value) && attr.value.length === 1) {
|
|
3356
|
+
attr.value = attr.value[0];
|
|
3357
|
+
}
|
|
3358
|
+
});
|
|
3359
|
+
return attributes;
|
|
3360
|
+
};
|
|
3361
|
+
//#endregion
|
|
3362
|
+
//#region extract attributes from comments
|
|
3363
|
+
const extractAttributesFromComments = (comments) => {
|
|
3364
|
+
const attributes = [];
|
|
3365
|
+
// console.log({ comments });
|
|
3366
|
+
for (const comment of comments) {
|
|
3367
|
+
UtilsJson.getAttributiesFromComment(comment, attributes);
|
|
3368
|
+
}
|
|
3369
|
+
return attributes;
|
|
3370
|
+
};
|
|
3371
|
+
//#endregion
|
|
3372
|
+
//#region read json
|
|
3373
|
+
/**
|
|
3374
|
+
* read json from absolute path
|
|
3375
|
+
* @returns json object
|
|
3376
|
+
*/
|
|
3377
|
+
UtilsJson.readJson = (absoluteFilePath, defaultValue = {}, useJson5 = false) => {
|
|
3494
3378
|
/* */
|
|
3495
3379
|
/* */
|
|
3496
3380
|
/* */
|
|
@@ -3510,8 +3394,56 @@ var UtilsOs;
|
|
|
3510
3394
|
/* */
|
|
3511
3395
|
/* */
|
|
3512
3396
|
/* */
|
|
3397
|
+
return (void 0);
|
|
3398
|
+
};
|
|
3399
|
+
//#endregion
|
|
3400
|
+
//#region read json with comments
|
|
3401
|
+
UtilsJson.readJsonWithComments = (absoluteFilePath, defaultValue = {}) => {
|
|
3513
3402
|
/* */
|
|
3514
3403
|
/* */
|
|
3404
|
+
return (void 0);
|
|
3405
|
+
};
|
|
3406
|
+
//#endregion
|
|
3407
|
+
//#region lodash path validation
|
|
3408
|
+
UtilsJson.validateLodashPath = (lodashGetPath) => {
|
|
3409
|
+
if (_.isArray(lodashGetPath)) {
|
|
3410
|
+
lodashGetPath = lodashGetPath.join('.');
|
|
3411
|
+
}
|
|
3412
|
+
if (!_.isString(lodashGetPath)) {
|
|
3413
|
+
throw new Error(`Invalid lodash path: path cannot be empty.`);
|
|
3414
|
+
}
|
|
3415
|
+
const path = lodashGetPath.trim();
|
|
3416
|
+
/**
|
|
3417
|
+
* Allowed:
|
|
3418
|
+
* foo
|
|
3419
|
+
* foo.bar
|
|
3420
|
+
* foo.bar.baz
|
|
3421
|
+
* foo[0].bar
|
|
3422
|
+
* foo.bar[123].baz
|
|
3423
|
+
*
|
|
3424
|
+
* Rejected:
|
|
3425
|
+
* foo..bar
|
|
3426
|
+
* .foo
|
|
3427
|
+
* foo.
|
|
3428
|
+
* foo[]
|
|
3429
|
+
* foo[abc]
|
|
3430
|
+
* foo[asd].bar
|
|
3431
|
+
*/
|
|
3432
|
+
const validPathRegex = /^[a-zA-Z_$][a-zA-Z0-9_$]*(?:\[\d+\])*(?:\.[a-zA-Z_$][a-zA-Z0-9_$]*(?:\[\d+\])*)*$/;
|
|
3433
|
+
if (!validPathRegex.test(path)) {
|
|
3434
|
+
throw new Error(`Invalid lodash path: "${path}"`);
|
|
3435
|
+
}
|
|
3436
|
+
const forbiddenKeys = ['__proto__', 'prototype', 'constructor'];
|
|
3437
|
+
const parts = path.replace(/\[(\d+)\]/g, '.$1').split('.');
|
|
3438
|
+
const forbiddenKey = parts.find(part => forbiddenKeys.includes(part));
|
|
3439
|
+
if (forbiddenKey) {
|
|
3440
|
+
throw new Error(`Invalid lodash path: forbidden key "${forbiddenKey}" in "${path}"`);
|
|
3441
|
+
}
|
|
3442
|
+
return path;
|
|
3443
|
+
};
|
|
3444
|
+
//#endregion
|
|
3445
|
+
//#region get value
|
|
3446
|
+
UtilsJson.getValue = (filepath, lodashGetPath, options) => {
|
|
3515
3447
|
/* */
|
|
3516
3448
|
/* */
|
|
3517
3449
|
/* */
|
|
@@ -3531,6 +3463,11 @@ var UtilsOs;
|
|
|
3531
3463
|
/* */
|
|
3532
3464
|
/* */
|
|
3533
3465
|
/* */
|
|
3466
|
+
return (void 0);
|
|
3467
|
+
};
|
|
3468
|
+
//#endregion
|
|
3469
|
+
//#region set value
|
|
3470
|
+
UtilsJson.setValue = (filepath, lodashGetPath, value, options) => {
|
|
3534
3471
|
/* */
|
|
3535
3472
|
/* */
|
|
3536
3473
|
/* */
|
|
@@ -3555,11 +3492,21 @@ var UtilsOs;
|
|
|
3555
3492
|
/* */
|
|
3556
3493
|
return (void 0);
|
|
3557
3494
|
};
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3495
|
+
//#endregion
|
|
3496
|
+
})(UtilsJson || (UtilsJson = {}));
|
|
3497
|
+
|
|
3498
|
+
//#region imports
|
|
3499
|
+
//#endregion
|
|
3500
|
+
var UtilsProcess;
|
|
3501
|
+
(function (UtilsProcess) {
|
|
3502
|
+
//#region utils process / start async child process command until
|
|
3503
|
+
/**
|
|
3504
|
+
* This let you start child process and resolve promise when some
|
|
3505
|
+
* condition is met. It is useful for example when you want to start
|
|
3506
|
+
* process and wait until some output is in stdout or stderr.
|
|
3507
|
+
*/
|
|
3508
|
+
UtilsProcess.startAsyncChildProcessCommandUntil = async (command, options) => {
|
|
3509
|
+
/* */
|
|
3563
3510
|
/* */
|
|
3564
3511
|
/* */
|
|
3565
3512
|
/* */
|
|
@@ -3575,9 +3522,6 @@ var UtilsOs;
|
|
|
3575
3522
|
/* */
|
|
3576
3523
|
/* */
|
|
3577
3524
|
/* */
|
|
3578
|
-
return (void 0);
|
|
3579
|
-
}
|
|
3580
|
-
function cleanupExpiredTempFolders(managedTempRoot) {
|
|
3581
3525
|
/* */
|
|
3582
3526
|
/* */
|
|
3583
3527
|
/* */
|
|
@@ -3624,9 +3568,6 @@ var UtilsOs;
|
|
|
3624
3568
|
/* */
|
|
3625
3569
|
/* */
|
|
3626
3570
|
/* */
|
|
3627
|
-
return (void 0);
|
|
3628
|
-
}
|
|
3629
|
-
function sanitizeTempFolderPrefix(prefix) {
|
|
3630
3571
|
/* */
|
|
3631
3572
|
/* */
|
|
3632
3573
|
/* */
|
|
@@ -3635,41 +3576,10 @@ var UtilsOs;
|
|
|
3635
3576
|
/* */
|
|
3636
3577
|
/* */
|
|
3637
3578
|
return (void 0);
|
|
3638
|
-
}
|
|
3639
|
-
UtilsOs.EditorArr = [
|
|
3640
|
-
'code',
|
|
3641
|
-
'codium',
|
|
3642
|
-
'cursor',
|
|
3643
|
-
'theia',
|
|
3644
|
-
'idea',
|
|
3645
|
-
'idea64',
|
|
3646
|
-
];
|
|
3647
|
-
//#endregion
|
|
3648
|
-
//#region utils os / editor processes
|
|
3649
|
-
UtilsOs.EDITOR_PROCESSES = {
|
|
3650
|
-
code: ['code', 'Code'],
|
|
3651
|
-
codium: ['codium', 'VSCodium'],
|
|
3652
|
-
cursor: ['cursor', 'Cursor'],
|
|
3653
|
-
theia: ['theia', 'TheiaIDE'],
|
|
3654
|
-
'code-oss': [
|
|
3655
|
-
'code',
|
|
3656
|
-
'Code',
|
|
3657
|
-
'codium',
|
|
3658
|
-
'VSCodium',
|
|
3659
|
-
'cursor',
|
|
3660
|
-
'Cursor',
|
|
3661
|
-
'theia',
|
|
3662
|
-
'TheiaIDE',
|
|
3663
|
-
],
|
|
3664
|
-
idea: ['idea', 'idea64', 'IntelliJ IDEA'],
|
|
3665
|
-
idea64: ['idea64', 'idea', 'IntelliJ IDEA'],
|
|
3666
3579
|
};
|
|
3667
3580
|
//#endregion
|
|
3668
|
-
//#region utils
|
|
3669
|
-
|
|
3670
|
-
/* */
|
|
3671
|
-
/* */
|
|
3672
|
-
/* */
|
|
3581
|
+
//#region utils process / get git bash path
|
|
3582
|
+
UtilsProcess.getGitBashPath = () => {
|
|
3673
3583
|
/* */
|
|
3674
3584
|
/* */
|
|
3675
3585
|
/* */
|
|
@@ -3682,11 +3592,6 @@ var UtilsOs;
|
|
|
3682
3592
|
/* */
|
|
3683
3593
|
/* */
|
|
3684
3594
|
/* */
|
|
3685
|
-
return (void 0);
|
|
3686
|
-
};
|
|
3687
|
-
//#endregion
|
|
3688
|
-
//#region utils os / kill all editors
|
|
3689
|
-
UtilsOs.killAllEditor = (editor) => {
|
|
3690
3595
|
/* */
|
|
3691
3596
|
/* */
|
|
3692
3597
|
/* */
|
|
@@ -3696,8 +3601,12 @@ var UtilsOs;
|
|
|
3696
3601
|
return (void 0);
|
|
3697
3602
|
};
|
|
3698
3603
|
//#endregion
|
|
3699
|
-
//#region utils
|
|
3700
|
-
|
|
3604
|
+
//#region utils process / start process in new graphical terminal window
|
|
3605
|
+
/**
|
|
3606
|
+
* TODO IMPLEMENT
|
|
3607
|
+
* start async node process
|
|
3608
|
+
*/
|
|
3609
|
+
UtilsProcess.startInNewTerminalWindow = (command, options) => {
|
|
3701
3610
|
/* */
|
|
3702
3611
|
/* */
|
|
3703
3612
|
/* */
|
|
@@ -3748,11 +3657,6 @@ var UtilsOs;
|
|
|
3748
3657
|
/* */
|
|
3749
3658
|
/* */
|
|
3750
3659
|
/* */
|
|
3751
|
-
return (void 0);
|
|
3752
|
-
};
|
|
3753
|
-
//#endregion
|
|
3754
|
-
//#region utils os / get editor keybinding path
|
|
3755
|
-
UtilsOs.getEditorKeybindingPath = (editor) => {
|
|
3756
3660
|
/* */
|
|
3757
3661
|
/* */
|
|
3758
3662
|
/* */
|
|
@@ -3796,11 +3700,6 @@ var UtilsOs;
|
|
|
3796
3700
|
/* */
|
|
3797
3701
|
/* */
|
|
3798
3702
|
/* */
|
|
3799
|
-
return (void 0);
|
|
3800
|
-
};
|
|
3801
|
-
//#endregion
|
|
3802
|
-
//#region utils os / get editor settings json path
|
|
3803
|
-
UtilsOs.getEditorSettingsJsonPath = (editor, platform = process.platform, env = process.env) => {
|
|
3804
3703
|
/* */
|
|
3805
3704
|
/* */
|
|
3806
3705
|
/* */
|
|
@@ -3819,6 +3718,14 @@ var UtilsOs;
|
|
|
3819
3718
|
/* */
|
|
3820
3719
|
/* */
|
|
3821
3720
|
/* */
|
|
3721
|
+
return (void 0);
|
|
3722
|
+
};
|
|
3723
|
+
//#endregion
|
|
3724
|
+
//#region utils process / get bash or shell name
|
|
3725
|
+
UtilsProcess.getBashOrShellName = () => {
|
|
3726
|
+
//#region @browser
|
|
3727
|
+
return 'browser';
|
|
3728
|
+
//#endregion
|
|
3822
3729
|
/* */
|
|
3823
3730
|
/* */
|
|
3824
3731
|
/* */
|
|
@@ -3849,46 +3756,16 @@ var UtilsOs;
|
|
|
3849
3756
|
/* */
|
|
3850
3757
|
/* */
|
|
3851
3758
|
/* */
|
|
3852
|
-
return (void 0);
|
|
3853
|
-
};
|
|
3854
|
-
//#endregion
|
|
3855
|
-
//#region utils os / is running in node debugger
|
|
3856
|
-
UtilsOs.isRunningNodeDebugger = () => {
|
|
3857
|
-
//#region @browser
|
|
3858
|
-
return false;
|
|
3859
|
-
//#endregion
|
|
3860
3759
|
/* */
|
|
3861
3760
|
/* */
|
|
3862
3761
|
return (void 0);
|
|
3863
3762
|
};
|
|
3864
3763
|
//#endregion
|
|
3865
|
-
//#region utils
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
UtilsOs.isNode = UtilsOs.isRunningInNode();
|
|
3871
|
-
UtilsOs.isWebSQL = UtilsOs.isRunningInWebSQL();
|
|
3872
|
-
UtilsOs.isVscodeExtension = UtilsOs.isRunningInVscodeExtension();
|
|
3873
|
-
UtilsOs.isSSRMode = UtilsOs.isRunningInSSRMode();
|
|
3874
|
-
let isRunningInWindowsTmp = false;
|
|
3875
|
-
/* */
|
|
3876
|
-
/* */
|
|
3877
|
-
UtilsOs.isRunningInWindows = isRunningInWindowsTmp;
|
|
3878
|
-
//#endregion
|
|
3879
|
-
//#region utils os / command exists
|
|
3880
|
-
//#region helpers
|
|
3881
|
-
const fileNotExists = async (commandName) => {
|
|
3882
|
-
/* */
|
|
3883
|
-
/* */
|
|
3884
|
-
/* */
|
|
3885
|
-
/* */
|
|
3886
|
-
/* */
|
|
3887
|
-
/* */
|
|
3888
|
-
/* */
|
|
3889
|
-
return (void 0);
|
|
3890
|
-
};
|
|
3891
|
-
const fileNotExistsSync = (commandName) => {
|
|
3764
|
+
//#region utils process / get current process and child processes usage
|
|
3765
|
+
/**
|
|
3766
|
+
* Get CPU and memory usage for a single PID.
|
|
3767
|
+
*/
|
|
3768
|
+
UtilsProcess.getUsageForPid = async (pid) => {
|
|
3892
3769
|
/* */
|
|
3893
3770
|
/* */
|
|
3894
3771
|
/* */
|
|
@@ -3896,9 +3773,6 @@ var UtilsOs;
|
|
|
3896
3773
|
/* */
|
|
3897
3774
|
/* */
|
|
3898
3775
|
/* */
|
|
3899
|
-
return (void 0);
|
|
3900
|
-
};
|
|
3901
|
-
const localExecutable = async (commandName) => {
|
|
3902
3776
|
/* */
|
|
3903
3777
|
/* */
|
|
3904
3778
|
/* */
|
|
@@ -3906,9 +3780,6 @@ var UtilsOs;
|
|
|
3906
3780
|
/* */
|
|
3907
3781
|
/* */
|
|
3908
3782
|
/* */
|
|
3909
|
-
return (void 0);
|
|
3910
|
-
};
|
|
3911
|
-
const localExecutableSync = (commandName) => {
|
|
3912
3783
|
/* */
|
|
3913
3784
|
/* */
|
|
3914
3785
|
/* */
|
|
@@ -3919,8 +3790,13 @@ var UtilsOs;
|
|
|
3919
3790
|
return (void 0);
|
|
3920
3791
|
};
|
|
3921
3792
|
//#endregion
|
|
3922
|
-
//#region
|
|
3923
|
-
|
|
3793
|
+
//#region utils process / get child PIDs
|
|
3794
|
+
/**
|
|
3795
|
+
* Return a list of direct child PIDs for the given PID on a Unix-like system.
|
|
3796
|
+
* Uses `ps -o pid= --ppid <pid>` to find child processes.
|
|
3797
|
+
*/
|
|
3798
|
+
async function getChildPidsUnix(pid) {
|
|
3799
|
+
/* */
|
|
3924
3800
|
/* */
|
|
3925
3801
|
/* */
|
|
3926
3802
|
/* */
|
|
@@ -3937,8 +3813,14 @@ var UtilsOs;
|
|
|
3937
3813
|
/* */
|
|
3938
3814
|
/* */
|
|
3939
3815
|
return (void 0);
|
|
3940
|
-
}
|
|
3941
|
-
|
|
3816
|
+
}
|
|
3817
|
+
//#endregion
|
|
3818
|
+
//#region utils process / get child PIDs on Windows
|
|
3819
|
+
/**
|
|
3820
|
+
* Return a list of direct child PIDs for the given PID on Windows.
|
|
3821
|
+
* Uses `wmic process where (ParentProcessId=<pid>) get ProcessId` to find child processes.
|
|
3822
|
+
*/
|
|
3823
|
+
async function getChildPidsWindows(pid) {
|
|
3942
3824
|
/* */
|
|
3943
3825
|
/* */
|
|
3944
3826
|
/* */
|
|
@@ -3948,9 +3830,6 @@ var UtilsOs;
|
|
|
3948
3830
|
/* */
|
|
3949
3831
|
/* */
|
|
3950
3832
|
/* */
|
|
3951
|
-
return (void 0);
|
|
3952
|
-
};
|
|
3953
|
-
const commandExistsUnixSync = (commandName) => {
|
|
3954
3833
|
/* */
|
|
3955
3834
|
/* */
|
|
3956
3835
|
/* */
|
|
@@ -3958,6 +3837,16 @@ var UtilsOs;
|
|
|
3958
3837
|
/* */
|
|
3959
3838
|
/* */
|
|
3960
3839
|
/* */
|
|
3840
|
+
/* */
|
|
3841
|
+
return (void 0);
|
|
3842
|
+
}
|
|
3843
|
+
//#endregion
|
|
3844
|
+
//#region utils process / get child PIDs once
|
|
3845
|
+
/**
|
|
3846
|
+
* Cross-platform function to list *direct* child PIDs of a given PID.
|
|
3847
|
+
* Uses the appropriate command depending on `process.platform`.
|
|
3848
|
+
*/
|
|
3849
|
+
async function getChildPidsOnce(pid) {
|
|
3961
3850
|
/* */
|
|
3962
3851
|
/* */
|
|
3963
3852
|
/* */
|
|
@@ -3965,8 +3854,15 @@ var UtilsOs;
|
|
|
3965
3854
|
/* */
|
|
3966
3855
|
/* */
|
|
3967
3856
|
return (void 0);
|
|
3968
|
-
}
|
|
3969
|
-
|
|
3857
|
+
}
|
|
3858
|
+
UtilsProcess.getChildPidsOnce = getChildPidsOnce;
|
|
3859
|
+
//#endregion
|
|
3860
|
+
//#region utils process / get current process and child usage
|
|
3861
|
+
/**
|
|
3862
|
+
* Get CPU and memory usage for the current process (the Node.js process itself),
|
|
3863
|
+
* plus any child processes spawned by it.
|
|
3864
|
+
*/
|
|
3865
|
+
UtilsProcess.getCurrentProcessAndChildUsage = async () => {
|
|
3970
3866
|
/* */
|
|
3971
3867
|
/* */
|
|
3972
3868
|
/* */
|
|
@@ -3974,11 +3870,6 @@ var UtilsOs;
|
|
|
3974
3870
|
/* */
|
|
3975
3871
|
/* */
|
|
3976
3872
|
/* */
|
|
3977
|
-
return (void 0);
|
|
3978
|
-
};
|
|
3979
|
-
//#endregion
|
|
3980
|
-
//#region exported API
|
|
3981
|
-
UtilsOs.commandExistsAsync = async (commandName) => {
|
|
3982
3873
|
/* */
|
|
3983
3874
|
/* */
|
|
3984
3875
|
/* */
|
|
@@ -3990,20 +3881,6 @@ var UtilsOs;
|
|
|
3990
3881
|
/* */
|
|
3991
3882
|
/* */
|
|
3992
3883
|
/* */
|
|
3993
|
-
return (void 0);
|
|
3994
|
-
};
|
|
3995
|
-
/**
|
|
3996
|
-
* @deprecated use commandExistsAsync
|
|
3997
|
-
*/
|
|
3998
|
-
UtilsOs.commandExistsSync = (commandName) => {
|
|
3999
|
-
return UtilsOs.isRunningInWindows
|
|
4000
|
-
? commandExistsWindowsSync(commandName)
|
|
4001
|
-
: commandExistsUnixSync(commandName);
|
|
4002
|
-
};
|
|
4003
|
-
//#endregion
|
|
4004
|
-
//#endregion
|
|
4005
|
-
//#region utils os / python module exists
|
|
4006
|
-
UtilsOs.pipxPackageExists = (packageName) => {
|
|
4007
3884
|
/* */
|
|
4008
3885
|
/* */
|
|
4009
3886
|
/* */
|
|
@@ -4013,11 +3890,13 @@ var UtilsOs;
|
|
|
4013
3890
|
/* */
|
|
4014
3891
|
return (void 0);
|
|
4015
3892
|
};
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
3893
|
+
//#endregion
|
|
3894
|
+
//#region utils process / kill all java processes
|
|
3895
|
+
/**
|
|
3896
|
+
* Kills all running Java processes cross‑platform.
|
|
3897
|
+
* @returns Promise<boolean> true if processes were killed, false if none found
|
|
3898
|
+
*/
|
|
3899
|
+
UtilsProcess.killAllJava = async () => {
|
|
4021
3900
|
/* */
|
|
4022
3901
|
/* */
|
|
4023
3902
|
/* */
|
|
@@ -4027,14 +3906,6 @@ var UtilsOs;
|
|
|
4027
3906
|
/* */
|
|
4028
3907
|
/* */
|
|
4029
3908
|
/* */
|
|
4030
|
-
return (void 0);
|
|
4031
|
-
};
|
|
4032
|
-
const normalizeModuleName = (name) => {
|
|
4033
|
-
return name.replace(/-/g, '_');
|
|
4034
|
-
};
|
|
4035
|
-
UtilsOs.pythonModuleExists = async (moduleName,
|
|
4036
|
-
// pythonPath = process.platform === 'win32' ? 'python' : 'python3',
|
|
4037
|
-
pythonPath = 'python3') => {
|
|
4038
3909
|
/* */
|
|
4039
3910
|
/* */
|
|
4040
3911
|
/* */
|
|
@@ -4056,27 +3927,9 @@ var UtilsOs;
|
|
|
4056
3927
|
return (void 0);
|
|
4057
3928
|
};
|
|
4058
3929
|
//#endregion
|
|
4059
|
-
//#region utils
|
|
4060
|
-
|
|
4061
|
-
//#region @browser
|
|
4062
|
-
const widthBrowserConsole = row || 80;
|
|
4063
|
-
console.log('-'.repeat(widthBrowserConsole));
|
|
4064
|
-
//#endregion
|
|
4065
|
-
/* */
|
|
4066
|
-
/* */
|
|
4067
|
-
/* */
|
|
3930
|
+
//#region utils process / kill process by pid or child process
|
|
3931
|
+
UtilsProcess.killProcess = async (pidOrProcess) => {
|
|
4068
3932
|
/* */
|
|
4069
|
-
};
|
|
4070
|
-
//#endregion
|
|
4071
|
-
//#region utils terminal / draw vertical line
|
|
4072
|
-
UtilsOs.drawVerticalLine = (col = 0) => {
|
|
4073
|
-
//#region @browser
|
|
4074
|
-
const heightBrowserConsole = 20;
|
|
4075
|
-
const line = Array.from({ length: heightBrowserConsole })
|
|
4076
|
-
.map(() => '|')
|
|
4077
|
-
.join('\n');
|
|
4078
|
-
console.log(line);
|
|
4079
|
-
//#endregion
|
|
4080
3933
|
/* */
|
|
4081
3934
|
/* */
|
|
4082
3935
|
/* */
|
|
@@ -4086,10 +3939,6 @@ var UtilsOs;
|
|
|
4086
3939
|
/* */
|
|
4087
3940
|
/* */
|
|
4088
3941
|
/* */
|
|
4089
|
-
};
|
|
4090
|
-
//#endregion
|
|
4091
|
-
//#region utils os / get inotify watch count (linux)
|
|
4092
|
-
async function getInotifyWatchCount() {
|
|
4093
3942
|
/* */
|
|
4094
3943
|
/* */
|
|
4095
3944
|
/* */
|
|
@@ -4106,6 +3955,15 @@ var UtilsOs;
|
|
|
4106
3955
|
/* */
|
|
4107
3956
|
/* */
|
|
4108
3957
|
/* */
|
|
3958
|
+
return (void 0);
|
|
3959
|
+
};
|
|
3960
|
+
//#endregion
|
|
3961
|
+
//#region utils process / kill process on port
|
|
3962
|
+
UtilsProcess.killProcessOnPort = async (port) => {
|
|
3963
|
+
if (!port || isNaN(port) || UtilsOs.isBrowser) {
|
|
3964
|
+
Helpers.warn(`[UtilsProcess.killProcessOnPort]: Invalid port number: ${port}`);
|
|
3965
|
+
return false;
|
|
3966
|
+
}
|
|
4109
3967
|
/* */
|
|
4110
3968
|
/* */
|
|
4111
3969
|
/* */
|
|
@@ -4134,29 +3992,6 @@ var UtilsOs;
|
|
|
4134
3992
|
/* */
|
|
4135
3993
|
/* */
|
|
4136
3994
|
/* */
|
|
4137
|
-
return (void 0);
|
|
4138
|
-
}
|
|
4139
|
-
UtilsOs.getInotifyWatchCount = getInotifyWatchCount;
|
|
4140
|
-
//#endregion
|
|
4141
|
-
//#region utils os / send notification
|
|
4142
|
-
UtilsOs.sendNotification = async (opt) => {
|
|
4143
|
-
//#region prepare variables
|
|
4144
|
-
const platform = os.platform();
|
|
4145
|
-
const defaultTimeoutMs = 3000;
|
|
4146
|
-
opt = _.cloneDeep(opt);
|
|
4147
|
-
const consoleNotification = `
|
|
4148
|
-
|
|
4149
|
-
> NOTIFICATION
|
|
4150
|
-
${opt.appName ?? 'App'} / ${opt.title}
|
|
4151
|
-
${opt.subtitle ? opt.subtitle + '\n' : ''}${opt.body ?? ''}
|
|
4152
|
-
|
|
4153
|
-
`;
|
|
4154
|
-
//#endregion
|
|
4155
|
-
//#region @browser
|
|
4156
|
-
UtilsOs.drawVerticalLine();
|
|
4157
|
-
console.log(consoleNotification);
|
|
4158
|
-
UtilsOs.drawVerticalLine();
|
|
4159
|
-
//#endregion
|
|
4160
3995
|
/* */
|
|
4161
3996
|
/* */
|
|
4162
3997
|
/* */
|
|
@@ -4183,6 +4018,18 @@ ${opt.subtitle ? opt.subtitle + '\n' : ''}${opt.body ?? ''}
|
|
|
4183
4018
|
/* */
|
|
4184
4019
|
/* */
|
|
4185
4020
|
/* */
|
|
4021
|
+
/* */
|
|
4022
|
+
/* */
|
|
4023
|
+
return (void 0);
|
|
4024
|
+
};
|
|
4025
|
+
//#endregion
|
|
4026
|
+
//#region utils process / kill all other node processes except itself
|
|
4027
|
+
/**
|
|
4028
|
+
* Kills all Node.js processes except the current process.
|
|
4029
|
+
* Works on Windows, macOS, and Linux.
|
|
4030
|
+
* @returns {number} Number of processes killed
|
|
4031
|
+
*/
|
|
4032
|
+
UtilsProcess.killAllOtherNodeProcesses = async () => {
|
|
4186
4033
|
/* */
|
|
4187
4034
|
/* */
|
|
4188
4035
|
/* */
|
|
@@ -4242,6 +4089,41 @@ ${opt.subtitle ? opt.subtitle + '\n' : ''}${opt.body ?? ''}
|
|
|
4242
4089
|
/* */
|
|
4243
4090
|
/* */
|
|
4244
4091
|
/* */
|
|
4092
|
+
/* */
|
|
4093
|
+
/* */
|
|
4094
|
+
/* */
|
|
4095
|
+
return (void 0);
|
|
4096
|
+
};
|
|
4097
|
+
//#endregion
|
|
4098
|
+
//#region utils process / is node version ok
|
|
4099
|
+
UtilsProcess.isNodeVersionOk = (options) => {
|
|
4100
|
+
if (!globalThis || !globalThis.process || !globalThis.process.version) {
|
|
4101
|
+
return false;
|
|
4102
|
+
}
|
|
4103
|
+
options = options || {};
|
|
4104
|
+
options.required = options.required || '18.0.0';
|
|
4105
|
+
const current = globalThis.process.version.replace(/^v/, '');
|
|
4106
|
+
const [curMajor, curMinor, curPatch] = current.split('.').map(Number);
|
|
4107
|
+
const [reqMajor, reqMinor, reqPatch] = options.required
|
|
4108
|
+
.replace(/^v/, '')
|
|
4109
|
+
.split('.')
|
|
4110
|
+
.map(Number);
|
|
4111
|
+
const ok = curMajor > reqMajor ||
|
|
4112
|
+
(curMajor === reqMajor && curMinor > reqMinor) ||
|
|
4113
|
+
(curMajor === reqMajor && curMinor === reqMinor && curPatch >= reqPatch);
|
|
4114
|
+
if (options?.log) {
|
|
4115
|
+
console.log(ok
|
|
4116
|
+
? `✅ Node.js version OK (required ≥ ${options.required}, current ${current})`
|
|
4117
|
+
: `❌ Node.js version too low (required ≥ ${options.required}, current ${current})`);
|
|
4118
|
+
}
|
|
4119
|
+
if (options?.throwErrorIfNotOk && !ok) {
|
|
4120
|
+
throw new Error(`Node.js version too low (required ≥ ${options.required}, current ${current})`);
|
|
4121
|
+
}
|
|
4122
|
+
return ok;
|
|
4123
|
+
};
|
|
4124
|
+
//#endregion
|
|
4125
|
+
//#region utils process / is current process attached to terminal
|
|
4126
|
+
function isCurrentProcessAttachedToTerminal() {
|
|
4245
4127
|
/* */
|
|
4246
4128
|
/* */
|
|
4247
4129
|
/* */
|
|
@@ -4249,6 +4131,12 @@ ${opt.subtitle ? opt.subtitle + '\n' : ''}${opt.body ?? ''}
|
|
|
4249
4131
|
/* */
|
|
4250
4132
|
/* */
|
|
4251
4133
|
/* */
|
|
4134
|
+
return (void 0);
|
|
4135
|
+
}
|
|
4136
|
+
UtilsProcess.isCurrentProcessAttachedToTerminal = isCurrentProcessAttachedToTerminal;
|
|
4137
|
+
//#endregion
|
|
4138
|
+
//#region utils process / get path of executable
|
|
4139
|
+
UtilsProcess.getPathOfExecutable = async (command) => {
|
|
4252
4140
|
/* */
|
|
4253
4141
|
/* */
|
|
4254
4142
|
/* */
|
|
@@ -4264,22 +4152,99 @@ ${opt.subtitle ? opt.subtitle + '\n' : ''}${opt.body ?? ''}
|
|
|
4264
4152
|
/* */
|
|
4265
4153
|
/* */
|
|
4266
4154
|
/* */
|
|
4267
|
-
};
|
|
4268
|
-
//#endregion
|
|
4269
|
-
//#region utils os / safe exit program clean up fn
|
|
4270
|
-
let isCleaning = false;
|
|
4271
|
-
function safeExitProgramCleanUp(cleanFn) {
|
|
4272
4155
|
/* */
|
|
4273
4156
|
/* */
|
|
4274
4157
|
/* */
|
|
4158
|
+
return (void 0);
|
|
4159
|
+
};
|
|
4160
|
+
//#endregion
|
|
4161
|
+
})(UtilsProcess || (UtilsProcess = {}));
|
|
4162
|
+
|
|
4163
|
+
//#region imports
|
|
4164
|
+
//#endregion
|
|
4165
|
+
var UtilsOs;
|
|
4166
|
+
(function (UtilsOs) {
|
|
4167
|
+
//#region utils os / is running in browser
|
|
4168
|
+
/**
|
|
4169
|
+
* check if script is running in client browser
|
|
4170
|
+
* (websql model -> is also considered as browser
|
|
4171
|
+
* because it is running in browser)
|
|
4172
|
+
*/
|
|
4173
|
+
UtilsOs.isRunningInBrowser = () => {
|
|
4275
4174
|
/* */
|
|
4276
4175
|
/* */
|
|
4176
|
+
return true;
|
|
4177
|
+
};
|
|
4178
|
+
//#endregion
|
|
4179
|
+
//#region utils os / is running in node
|
|
4180
|
+
/**
|
|
4181
|
+
* check if script is running in nodejs
|
|
4182
|
+
* (backend script or electron script)
|
|
4183
|
+
*/
|
|
4184
|
+
UtilsOs.isRunningInNode = () => {
|
|
4277
4185
|
/* */
|
|
4278
4186
|
/* */
|
|
4187
|
+
return false;
|
|
4188
|
+
};
|
|
4189
|
+
//#endregion
|
|
4190
|
+
//#region utils os / is running in websql
|
|
4191
|
+
/**
|
|
4192
|
+
* check if script is running special
|
|
4193
|
+
* browser mode that has sql.js backend
|
|
4194
|
+
* and executes sql queries in browser
|
|
4195
|
+
*/
|
|
4196
|
+
UtilsOs.isRunningInWebSQL = () => {
|
|
4279
4197
|
/* */
|
|
4280
4198
|
/* */
|
|
4281
4199
|
/* */
|
|
4282
4200
|
/* */
|
|
4201
|
+
return false;
|
|
4202
|
+
};
|
|
4203
|
+
//#endregion
|
|
4204
|
+
//#region utils os / is running in ssr mode
|
|
4205
|
+
UtilsOs.isRunningInSSRMode = () => {
|
|
4206
|
+
return typeof globalThis.window === 'undefined';
|
|
4207
|
+
};
|
|
4208
|
+
//#endregion
|
|
4209
|
+
//#region utils os / is running in electron
|
|
4210
|
+
/**
|
|
4211
|
+
* check whether the current process is running inside
|
|
4212
|
+
* Cloudflare worker
|
|
4213
|
+
*/
|
|
4214
|
+
UtilsOs.isRunningInCloudflareWorker = () => {
|
|
4215
|
+
return isCloudflareWorker;
|
|
4216
|
+
};
|
|
4217
|
+
//#endregion
|
|
4218
|
+
//#region utils os / is running in electron
|
|
4219
|
+
/**
|
|
4220
|
+
* check whether the current process is running inside
|
|
4221
|
+
* Electron backend or browser.
|
|
4222
|
+
*/
|
|
4223
|
+
UtilsOs.isRunningInElectron = () => {
|
|
4224
|
+
// Electron main or renderer (most reliable)
|
|
4225
|
+
if (typeof process !== 'undefined' && process?.versions?.electron) {
|
|
4226
|
+
return true;
|
|
4227
|
+
}
|
|
4228
|
+
// Renderer with nodeIntegration
|
|
4229
|
+
if (typeof globalThis !== 'undefined' &&
|
|
4230
|
+
globalThis?.process?.type === 'renderer') {
|
|
4231
|
+
return true;
|
|
4232
|
+
}
|
|
4233
|
+
// Renderer with nodeIntegration disabled
|
|
4234
|
+
if (typeof navigator === 'object' &&
|
|
4235
|
+
typeof navigator.userAgent === 'string' &&
|
|
4236
|
+
/Electron/i.test(navigator.userAgent)) {
|
|
4237
|
+
return true;
|
|
4238
|
+
}
|
|
4239
|
+
return false;
|
|
4240
|
+
};
|
|
4241
|
+
//#endregion
|
|
4242
|
+
//#region utils os / is running in vscode extension
|
|
4243
|
+
/**
|
|
4244
|
+
* Check whether the current process is running inside
|
|
4245
|
+
* a Visual Studio Code extension.
|
|
4246
|
+
*/
|
|
4247
|
+
UtilsOs.isRunningInVscodeExtension = () => {
|
|
4283
4248
|
/* */
|
|
4284
4249
|
/* */
|
|
4285
4250
|
/* */
|
|
@@ -4288,6 +4253,19 @@ ${opt.subtitle ? opt.subtitle + '\n' : ''}${opt.body ?? ''}
|
|
|
4288
4253
|
/* */
|
|
4289
4254
|
/* */
|
|
4290
4255
|
/* */
|
|
4256
|
+
return (void 0);
|
|
4257
|
+
return false;
|
|
4258
|
+
};
|
|
4259
|
+
//#endregion
|
|
4260
|
+
//#region utils os / is running in wsl
|
|
4261
|
+
/**
|
|
4262
|
+
* Check wether the current process is running inside
|
|
4263
|
+
* windows subsystem for linux (WSL).
|
|
4264
|
+
*/
|
|
4265
|
+
UtilsOs.isRunningInWsl = () => {
|
|
4266
|
+
//#region @browser
|
|
4267
|
+
return false;
|
|
4268
|
+
//#endregion
|
|
4291
4269
|
/* */
|
|
4292
4270
|
/* */
|
|
4293
4271
|
/* */
|
|
@@ -4305,6 +4283,11 @@ ${opt.subtitle ? opt.subtitle + '\n' : ''}${opt.body ?? ''}
|
|
|
4305
4283
|
/* */
|
|
4306
4284
|
/* */
|
|
4307
4285
|
/* */
|
|
4286
|
+
return (void 0);
|
|
4287
|
+
};
|
|
4288
|
+
//#endregion
|
|
4289
|
+
//#region utils os / is running in windows / powershell / cmd / gitbash
|
|
4290
|
+
UtilsOs.isRunningInWindowsPowerShell = () => {
|
|
4308
4291
|
/* */
|
|
4309
4292
|
/* */
|
|
4310
4293
|
/* */
|
|
@@ -4321,12 +4304,6 @@ ${opt.subtitle ? opt.subtitle + '\n' : ''}${opt.body ?? ''}
|
|
|
4321
4304
|
/* */
|
|
4322
4305
|
/* */
|
|
4323
4306
|
/* */
|
|
4324
|
-
return (void 0);
|
|
4325
|
-
}
|
|
4326
|
-
UtilsOs.safeExitProgramCleanUp = safeExitProgramCleanUp;
|
|
4327
|
-
//#endregion
|
|
4328
|
-
//#region utils os / where package locationd
|
|
4329
|
-
UtilsOs.whichOrWherePackageLocated = (packageName) => {
|
|
4330
4307
|
/* */
|
|
4331
4308
|
/* */
|
|
4332
4309
|
/* */
|
|
@@ -4353,12 +4330,18 @@ ${opt.subtitle ? opt.subtitle + '\n' : ''}${opt.body ?? ''}
|
|
|
4353
4330
|
/* */
|
|
4354
4331
|
/* */
|
|
4355
4332
|
/* */
|
|
4333
|
+
return (void 0);
|
|
4334
|
+
};
|
|
4335
|
+
UtilsOs.isRunningInWindowsCmd = () => {
|
|
4356
4336
|
/* */
|
|
4357
4337
|
/* */
|
|
4358
4338
|
/* */
|
|
4359
4339
|
/* */
|
|
4360
4340
|
/* */
|
|
4361
4341
|
/* */
|
|
4342
|
+
return (void 0);
|
|
4343
|
+
};
|
|
4344
|
+
UtilsOs.isRunningInWindowsGitBash = () => {
|
|
4362
4345
|
/* */
|
|
4363
4346
|
/* */
|
|
4364
4347
|
/* */
|
|
@@ -4370,58 +4353,14 @@ ${opt.subtitle ? opt.subtitle + '\n' : ''}${opt.body ?? ''}
|
|
|
4370
4353
|
return (void 0);
|
|
4371
4354
|
};
|
|
4372
4355
|
//#endregion
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
/* */
|
|
4382
|
-
return (void 0);
|
|
4383
|
-
return '';
|
|
4384
|
-
};
|
|
4385
|
-
//#endregion
|
|
4386
|
-
//#region taon repo path for global template fn
|
|
4387
|
-
const taonBasePathToGlobalDockerTemplatesFn = () => {
|
|
4388
|
-
/* */
|
|
4389
|
-
/* */
|
|
4390
|
-
/* */
|
|
4391
|
-
/* */
|
|
4392
|
-
/* */
|
|
4393
|
-
/* */
|
|
4394
|
-
return (void 0);
|
|
4395
|
-
return '';
|
|
4396
|
-
};
|
|
4397
|
-
//#endregion
|
|
4398
|
-
|
|
4399
|
-
//#region imports
|
|
4400
|
-
//#endregion
|
|
4401
|
-
var UtilsFilesFoldersSync;
|
|
4402
|
-
(function (UtilsFilesFoldersSync) {
|
|
4403
|
-
//#region utils files folders sync / ignore folder files patterns
|
|
4404
|
-
UtilsFilesFoldersSync.IGNORE_FOLDERS_FILES_PATTERNS = [
|
|
4405
|
-
// '**/node_modules/**/*.*',
|
|
4406
|
-
'**/node_modules/**',
|
|
4407
|
-
// '**/node_modules',
|
|
4408
|
-
// '**/git/**/*.*',
|
|
4409
|
-
'**/.git/**/**',
|
|
4410
|
-
// '**/.git',
|
|
4411
|
-
// `**/${dotTaonFolder}/**/*.*`,
|
|
4412
|
-
`**/${dotTaonFolder}/**`,
|
|
4413
|
-
// `**/${dotTaonFolder}`,
|
|
4414
|
-
// `**/${dotTnpFolder}/**/*.*`,
|
|
4415
|
-
`**/${dotTnpFolder}/**`,
|
|
4416
|
-
// `**/${dotTnpFolder}`,
|
|
4417
|
-
'**/tmp-*',
|
|
4418
|
-
// `**/tmp-*/**/*.*`,
|
|
4419
|
-
'**/tmp-*/**',
|
|
4420
|
-
];
|
|
4421
|
-
//#endregion
|
|
4422
|
-
//#region utils files folders sync / read file
|
|
4423
|
-
UtilsFilesFoldersSync.readFile = (absoluteFilePath, // @ts-ignore
|
|
4424
|
-
options) => {
|
|
4356
|
+
//#region utils os / is running in docker
|
|
4357
|
+
UtilsOs.isRunningInDocker = () => {
|
|
4358
|
+
//#region @browser
|
|
4359
|
+
return false;
|
|
4360
|
+
//#endregion
|
|
4361
|
+
/* */
|
|
4362
|
+
/* */
|
|
4363
|
+
/* */
|
|
4425
4364
|
/* */
|
|
4426
4365
|
/* */
|
|
4427
4366
|
/* */
|
|
@@ -4467,8 +4406,18 @@ var UtilsFilesFoldersSync;
|
|
|
4467
4406
|
return (void 0);
|
|
4468
4407
|
};
|
|
4469
4408
|
//#endregion
|
|
4470
|
-
//#region utils
|
|
4471
|
-
|
|
4409
|
+
//#region utils os / is running in linux distro
|
|
4410
|
+
/**
|
|
4411
|
+
* check what linux you are running
|
|
4412
|
+
*/
|
|
4413
|
+
UtilsOs.isRunningInLinuxDistro = (linuxType) => {
|
|
4414
|
+
/* */
|
|
4415
|
+
/* */
|
|
4416
|
+
/* */
|
|
4417
|
+
/* */
|
|
4418
|
+
/* */
|
|
4419
|
+
/* */
|
|
4420
|
+
/* */
|
|
4472
4421
|
/* */
|
|
4473
4422
|
/* */
|
|
4474
4423
|
/* */
|
|
@@ -4484,6 +4433,29 @@ var UtilsFilesFoldersSync;
|
|
|
4484
4433
|
/* */
|
|
4485
4434
|
/* */
|
|
4486
4435
|
/* */
|
|
4436
|
+
/* */
|
|
4437
|
+
/* */
|
|
4438
|
+
/* */
|
|
4439
|
+
/* */
|
|
4440
|
+
//#region @browser
|
|
4441
|
+
return false;
|
|
4442
|
+
//#endregion
|
|
4443
|
+
};
|
|
4444
|
+
//#endregion
|
|
4445
|
+
//#region utils os / is running in linux graphics capable environment
|
|
4446
|
+
UtilsOs.isRunningInLinuxGraphicsCapableEnvironment = () => {
|
|
4447
|
+
/* */
|
|
4448
|
+
/* */
|
|
4449
|
+
/* */
|
|
4450
|
+
/* */
|
|
4451
|
+
/* */
|
|
4452
|
+
/* */
|
|
4453
|
+
/* */
|
|
4454
|
+
return (void 0);
|
|
4455
|
+
};
|
|
4456
|
+
//#endregion
|
|
4457
|
+
//#region utils os / is running in os with graphics capable environment
|
|
4458
|
+
UtilsOs.isRunningInOsWithGraphicsCapableEnvironment = () => {
|
|
4487
4459
|
/* */
|
|
4488
4460
|
/* */
|
|
4489
4461
|
/* */
|
|
@@ -4492,11 +4464,38 @@ var UtilsFilesFoldersSync;
|
|
|
4492
4464
|
/* */
|
|
4493
4465
|
/* */
|
|
4494
4466
|
/* */
|
|
4467
|
+
return (void 0);
|
|
4468
|
+
};
|
|
4469
|
+
//#endregion
|
|
4470
|
+
//#region utils os / is running in cli mode
|
|
4471
|
+
/**
|
|
4472
|
+
* Check whether the current process is running in CLI mode.
|
|
4473
|
+
*/
|
|
4474
|
+
UtilsOs.isRunningInCliMode = () => {
|
|
4475
|
+
//#region @browser
|
|
4476
|
+
return false;
|
|
4477
|
+
//#endregion
|
|
4495
4478
|
/* */
|
|
4496
4479
|
/* */
|
|
4480
|
+
return (void 0);
|
|
4481
|
+
};
|
|
4482
|
+
//#endregion
|
|
4483
|
+
//#region utils os / is running in mocha test
|
|
4484
|
+
/**
|
|
4485
|
+
* Check whether the current process is running in mocha test.
|
|
4486
|
+
*/
|
|
4487
|
+
UtilsOs.isRunningInMochaTest = () => {
|
|
4488
|
+
//#region @browser
|
|
4489
|
+
return false;
|
|
4490
|
+
//#endregion
|
|
4497
4491
|
/* */
|
|
4498
4492
|
/* */
|
|
4499
4493
|
/* */
|
|
4494
|
+
return (void 0);
|
|
4495
|
+
};
|
|
4496
|
+
//#endregion
|
|
4497
|
+
//#region utils os / is port in use
|
|
4498
|
+
const isPortInUseOnHost = (port, host) => {
|
|
4500
4499
|
/* */
|
|
4501
4500
|
/* */
|
|
4502
4501
|
/* */
|
|
@@ -4522,6 +4521,16 @@ var UtilsFilesFoldersSync;
|
|
|
4522
4521
|
/* */
|
|
4523
4522
|
/* */
|
|
4524
4523
|
/* */
|
|
4524
|
+
return (void 0);
|
|
4525
|
+
};
|
|
4526
|
+
/**
|
|
4527
|
+
* Checks if a given port is already in use (bound by another process).
|
|
4528
|
+
*
|
|
4529
|
+
* @param port - The port number to check.
|
|
4530
|
+
* @param host - The hostname or IP address to bind to (default: '127.0.0.1').
|
|
4531
|
+
* @returns Promise<boolean> - Resolves to `true` if the port is in use, otherwise `false`.
|
|
4532
|
+
*/
|
|
4533
|
+
UtilsOs.isPortInUse = async (port, options) => {
|
|
4525
4534
|
/* */
|
|
4526
4535
|
/* */
|
|
4527
4536
|
/* */
|
|
@@ -4535,6 +4544,18 @@ var UtilsFilesFoldersSync;
|
|
|
4535
4544
|
/* */
|
|
4536
4545
|
/* */
|
|
4537
4546
|
/* */
|
|
4547
|
+
return (void 0);
|
|
4548
|
+
};
|
|
4549
|
+
//#endregion
|
|
4550
|
+
//#region utils os / is docker available
|
|
4551
|
+
/**
|
|
4552
|
+
* Check if docker is available on this system
|
|
4553
|
+
* and it is running (daemon active)
|
|
4554
|
+
*/
|
|
4555
|
+
UtilsOs.isDockerAvailable = async () => {
|
|
4556
|
+
if (UtilsOs.isBrowser) {
|
|
4557
|
+
return false;
|
|
4558
|
+
}
|
|
4538
4559
|
/* */
|
|
4539
4560
|
/* */
|
|
4540
4561
|
/* */
|
|
@@ -4564,6 +4585,11 @@ var UtilsFilesFoldersSync;
|
|
|
4564
4585
|
/* */
|
|
4565
4586
|
/* */
|
|
4566
4587
|
/* */
|
|
4588
|
+
return (void 0);
|
|
4589
|
+
};
|
|
4590
|
+
//#endregion
|
|
4591
|
+
//#region utils os / open folder in file explorer
|
|
4592
|
+
UtilsOs.openFolderInFileExplorer = (folderPath) => {
|
|
4567
4593
|
/* */
|
|
4568
4594
|
/* */
|
|
4569
4595
|
/* */
|
|
@@ -4578,10 +4604,6 @@ var UtilsFilesFoldersSync;
|
|
|
4578
4604
|
/* */
|
|
4579
4605
|
/* */
|
|
4580
4606
|
/* */
|
|
4581
|
-
return (void 0);
|
|
4582
|
-
};
|
|
4583
|
-
//#region utils files folders sync / walk fs tree
|
|
4584
|
-
const walkFsTree = (root, options) => {
|
|
4585
4607
|
/* */
|
|
4586
4608
|
/* */
|
|
4587
4609
|
/* */
|
|
@@ -4598,6 +4620,17 @@ var UtilsFilesFoldersSync;
|
|
|
4598
4620
|
/* */
|
|
4599
4621
|
/* */
|
|
4600
4622
|
/* */
|
|
4623
|
+
return (void 0);
|
|
4624
|
+
//#region @browser
|
|
4625
|
+
console.warn(`UtilsOs.openFolderInFileExplorer is not supported in browser mode`);
|
|
4626
|
+
//#endregion
|
|
4627
|
+
};
|
|
4628
|
+
//#endregion
|
|
4629
|
+
//#region utils os / get real home directory
|
|
4630
|
+
UtilsOs.getRealHomeDir = () => {
|
|
4631
|
+
//#region @browser
|
|
4632
|
+
return '';
|
|
4633
|
+
//#endregion
|
|
4601
4634
|
/* */
|
|
4602
4635
|
/* */
|
|
4603
4636
|
/* */
|
|
@@ -4650,6 +4683,11 @@ var UtilsFilesFoldersSync;
|
|
|
4650
4683
|
/* */
|
|
4651
4684
|
/* */
|
|
4652
4685
|
/* */
|
|
4686
|
+
return (void 0);
|
|
4687
|
+
};
|
|
4688
|
+
const MANAGED_TEMP_FOLDER_NAME = '__temp__folders__with__exp__date';
|
|
4689
|
+
const TEMP_METADATA_FILE_NAME = '__temp_folder_metadata__.json';
|
|
4690
|
+
UtilsOs.getTempFolder = (options = {}) => {
|
|
4653
4691
|
/* */
|
|
4654
4692
|
/* */
|
|
4655
4693
|
/* */
|
|
@@ -4686,14 +4724,6 @@ var UtilsFilesFoldersSync;
|
|
|
4686
4724
|
/* */
|
|
4687
4725
|
/* */
|
|
4688
4726
|
/* */
|
|
4689
|
-
return (void 0);
|
|
4690
|
-
};
|
|
4691
|
-
//#endregion
|
|
4692
|
-
//#region utils files folders sync / get files from
|
|
4693
|
-
/**
|
|
4694
|
-
* return absolute paths for files inside folder or link to folder
|
|
4695
|
-
*/
|
|
4696
|
-
UtilsFilesFoldersSync.getFilesFrom = (folderOrLinkToFolder, options) => {
|
|
4697
4727
|
/* */
|
|
4698
4728
|
/* */
|
|
4699
4729
|
/* */
|
|
@@ -4708,14 +4738,6 @@ var UtilsFilesFoldersSync;
|
|
|
4708
4738
|
/* */
|
|
4709
4739
|
/* */
|
|
4710
4740
|
/* */
|
|
4711
|
-
return (void 0);
|
|
4712
|
-
};
|
|
4713
|
-
//#endregion
|
|
4714
|
-
//#region utils files and folder sync / get folders from
|
|
4715
|
-
/**
|
|
4716
|
-
* return absolute paths for folders inside folder or link to folder
|
|
4717
|
-
*/
|
|
4718
|
-
UtilsFilesFoldersSync.getFoldersFrom = (folderOrLinkToFolder, options) => {
|
|
4719
4741
|
/* */
|
|
4720
4742
|
/* */
|
|
4721
4743
|
/* */
|
|
@@ -4730,11 +4752,6 @@ var UtilsFilesFoldersSync;
|
|
|
4730
4752
|
/* */
|
|
4731
4753
|
/* */
|
|
4732
4754
|
/* */
|
|
4733
|
-
return (void 0);
|
|
4734
|
-
};
|
|
4735
|
-
//#endregion
|
|
4736
|
-
//#endregion
|
|
4737
|
-
UtilsFilesFoldersSync.copyFolder = (sourceDir, destinationDir, options) => {
|
|
4738
4755
|
/* */
|
|
4739
4756
|
/* */
|
|
4740
4757
|
/* */
|
|
@@ -4758,13 +4775,7 @@ var UtilsFilesFoldersSync;
|
|
|
4758
4775
|
/* */
|
|
4759
4776
|
return (void 0);
|
|
4760
4777
|
};
|
|
4761
|
-
|
|
4762
|
-
UtilsFilesFoldersSync.copy = (sourceDir, destinationDir, options) => {
|
|
4763
|
-
/* */
|
|
4764
|
-
/* */
|
|
4765
|
-
/* */
|
|
4766
|
-
/* */
|
|
4767
|
-
/* */
|
|
4778
|
+
function getSystemTempFolder() {
|
|
4768
4779
|
/* */
|
|
4769
4780
|
/* */
|
|
4770
4781
|
/* */
|
|
@@ -4784,6 +4795,9 @@ var UtilsFilesFoldersSync;
|
|
|
4784
4795
|
/* */
|
|
4785
4796
|
/* */
|
|
4786
4797
|
/* */
|
|
4798
|
+
return (void 0);
|
|
4799
|
+
}
|
|
4800
|
+
function cleanupExpiredTempFolders(managedTempRoot) {
|
|
4787
4801
|
/* */
|
|
4788
4802
|
/* */
|
|
4789
4803
|
/* */
|
|
@@ -4830,6 +4844,9 @@ var UtilsFilesFoldersSync;
|
|
|
4830
4844
|
/* */
|
|
4831
4845
|
/* */
|
|
4832
4846
|
/* */
|
|
4847
|
+
return (void 0);
|
|
4848
|
+
}
|
|
4849
|
+
function sanitizeTempFolderPrefix(prefix) {
|
|
4833
4850
|
/* */
|
|
4834
4851
|
/* */
|
|
4835
4852
|
/* */
|
|
@@ -4837,6 +4854,39 @@ var UtilsFilesFoldersSync;
|
|
|
4837
4854
|
/* */
|
|
4838
4855
|
/* */
|
|
4839
4856
|
/* */
|
|
4857
|
+
return (void 0);
|
|
4858
|
+
}
|
|
4859
|
+
UtilsOs.EditorArr = [
|
|
4860
|
+
'code',
|
|
4861
|
+
'codium',
|
|
4862
|
+
'cursor',
|
|
4863
|
+
'theia',
|
|
4864
|
+
'idea',
|
|
4865
|
+
'idea64',
|
|
4866
|
+
];
|
|
4867
|
+
//#endregion
|
|
4868
|
+
//#region utils os / editor processes
|
|
4869
|
+
UtilsOs.EDITOR_PROCESSES = {
|
|
4870
|
+
code: ['code', 'Code'],
|
|
4871
|
+
codium: ['codium', 'VSCodium'],
|
|
4872
|
+
cursor: ['cursor', 'Cursor'],
|
|
4873
|
+
theia: ['theia', 'TheiaIDE'],
|
|
4874
|
+
'code-oss': [
|
|
4875
|
+
'code',
|
|
4876
|
+
'Code',
|
|
4877
|
+
'codium',
|
|
4878
|
+
'VSCodium',
|
|
4879
|
+
'cursor',
|
|
4880
|
+
'Cursor',
|
|
4881
|
+
'theia',
|
|
4882
|
+
'TheiaIDE',
|
|
4883
|
+
],
|
|
4884
|
+
idea: ['idea', 'idea64', 'IntelliJ IDEA'],
|
|
4885
|
+
idea64: ['idea64', 'idea', 'IntelliJ IDEA'],
|
|
4886
|
+
};
|
|
4887
|
+
//#endregion
|
|
4888
|
+
//#region utils os / kill procesesses
|
|
4889
|
+
const killProcesses = (names) => {
|
|
4840
4890
|
/* */
|
|
4841
4891
|
/* */
|
|
4842
4892
|
/* */
|
|
@@ -4852,12 +4902,22 @@ var UtilsFilesFoldersSync;
|
|
|
4852
4902
|
/* */
|
|
4853
4903
|
/* */
|
|
4854
4904
|
/* */
|
|
4905
|
+
return (void 0);
|
|
4906
|
+
};
|
|
4907
|
+
//#endregion
|
|
4908
|
+
//#region utils os / kill all editors
|
|
4909
|
+
UtilsOs.killAllEditor = (editor) => {
|
|
4855
4910
|
/* */
|
|
4856
4911
|
/* */
|
|
4857
4912
|
/* */
|
|
4858
4913
|
/* */
|
|
4859
4914
|
/* */
|
|
4860
4915
|
/* */
|
|
4916
|
+
return (void 0);
|
|
4917
|
+
};
|
|
4918
|
+
//#endregion
|
|
4919
|
+
//#region utils os / detect editor
|
|
4920
|
+
UtilsOs.detectEditor = (options) => {
|
|
4861
4921
|
/* */
|
|
4862
4922
|
/* */
|
|
4863
4923
|
/* */
|
|
@@ -4908,6 +4968,11 @@ var UtilsFilesFoldersSync;
|
|
|
4908
4968
|
/* */
|
|
4909
4969
|
/* */
|
|
4910
4970
|
/* */
|
|
4971
|
+
return (void 0);
|
|
4972
|
+
};
|
|
4973
|
+
//#endregion
|
|
4974
|
+
//#region utils os / get editor keybinding path
|
|
4975
|
+
UtilsOs.getEditorKeybindingPath = (editor) => {
|
|
4911
4976
|
/* */
|
|
4912
4977
|
/* */
|
|
4913
4978
|
/* */
|
|
@@ -4951,6 +5016,11 @@ var UtilsFilesFoldersSync;
|
|
|
4951
5016
|
/* */
|
|
4952
5017
|
/* */
|
|
4953
5018
|
/* */
|
|
5019
|
+
return (void 0);
|
|
5020
|
+
};
|
|
5021
|
+
//#endregion
|
|
5022
|
+
//#region utils os / get editor settings json path
|
|
5023
|
+
UtilsOs.getEditorSettingsJsonPath = (editor, platform = process.platform, env = process.env) => {
|
|
4954
5024
|
/* */
|
|
4955
5025
|
/* */
|
|
4956
5026
|
/* */
|
|
@@ -4977,11 +5047,6 @@ var UtilsFilesFoldersSync;
|
|
|
4977
5047
|
/* */
|
|
4978
5048
|
/* */
|
|
4979
5049
|
/* */
|
|
4980
|
-
return (void 0);
|
|
4981
|
-
};
|
|
4982
|
-
//#endregion
|
|
4983
|
-
//#region utils files folders sync / filter dont copy
|
|
4984
|
-
UtilsFilesFoldersSync.filterDontCopy = (basePathFoldersTosSkip, projectOrBasepath) => {
|
|
4985
5050
|
/* */
|
|
4986
5051
|
/* */
|
|
4987
5052
|
/* */
|
|
@@ -5004,13 +5069,36 @@ var UtilsFilesFoldersSync;
|
|
|
5004
5069
|
/* */
|
|
5005
5070
|
/* */
|
|
5006
5071
|
/* */
|
|
5072
|
+
return (void 0);
|
|
5073
|
+
};
|
|
5074
|
+
//#endregion
|
|
5075
|
+
//#region utils os / is running in node debugger
|
|
5076
|
+
UtilsOs.isRunningNodeDebugger = () => {
|
|
5077
|
+
//#region @browser
|
|
5078
|
+
return false;
|
|
5079
|
+
//#endregion
|
|
5007
5080
|
/* */
|
|
5008
5081
|
/* */
|
|
5009
5082
|
return (void 0);
|
|
5010
5083
|
};
|
|
5011
5084
|
//#endregion
|
|
5012
|
-
//#region utils
|
|
5013
|
-
|
|
5085
|
+
//#region utils os / is [...]
|
|
5086
|
+
// console.log('kurwa')
|
|
5087
|
+
UtilsOs.isNodeVersionOk = (options) => UtilsProcess.isNodeVersionOk(options);
|
|
5088
|
+
UtilsOs.isElectron = UtilsOs.isRunningInElectron();
|
|
5089
|
+
UtilsOs.isBrowser = UtilsOs.isRunningInBrowser();
|
|
5090
|
+
UtilsOs.isNode = UtilsOs.isRunningInNode();
|
|
5091
|
+
UtilsOs.isWebSQL = UtilsOs.isRunningInWebSQL();
|
|
5092
|
+
UtilsOs.isVscodeExtension = UtilsOs.isRunningInVscodeExtension();
|
|
5093
|
+
UtilsOs.isSSRMode = UtilsOs.isRunningInSSRMode();
|
|
5094
|
+
let isRunningInWindowsTmp = false;
|
|
5095
|
+
/* */
|
|
5096
|
+
/* */
|
|
5097
|
+
UtilsOs.isRunningInWindows = isRunningInWindowsTmp;
|
|
5098
|
+
//#endregion
|
|
5099
|
+
//#region utils os / command exists
|
|
5100
|
+
//#region helpers
|
|
5101
|
+
const fileNotExists = async (commandName) => {
|
|
5014
5102
|
/* */
|
|
5015
5103
|
/* */
|
|
5016
5104
|
/* */
|
|
@@ -5018,6 +5106,9 @@ var UtilsFilesFoldersSync;
|
|
|
5018
5106
|
/* */
|
|
5019
5107
|
/* */
|
|
5020
5108
|
/* */
|
|
5109
|
+
return (void 0);
|
|
5110
|
+
};
|
|
5111
|
+
const fileNotExistsSync = (commandName) => {
|
|
5021
5112
|
/* */
|
|
5022
5113
|
/* */
|
|
5023
5114
|
/* */
|
|
@@ -5025,6 +5116,9 @@ var UtilsFilesFoldersSync;
|
|
|
5025
5116
|
/* */
|
|
5026
5117
|
/* */
|
|
5027
5118
|
/* */
|
|
5119
|
+
return (void 0);
|
|
5120
|
+
};
|
|
5121
|
+
const localExecutable = async (commandName) => {
|
|
5028
5122
|
/* */
|
|
5029
5123
|
/* */
|
|
5030
5124
|
/* */
|
|
@@ -5034,11 +5128,7 @@ var UtilsFilesFoldersSync;
|
|
|
5034
5128
|
/* */
|
|
5035
5129
|
return (void 0);
|
|
5036
5130
|
};
|
|
5037
|
-
|
|
5038
|
-
//#region utils files folders sync / copy file
|
|
5039
|
-
UtilsFilesFoldersSync.copyFile = (sourcePath, destinationPath, options) => {
|
|
5040
|
-
/* */
|
|
5041
|
-
/* */
|
|
5131
|
+
const localExecutableSync = (commandName) => {
|
|
5042
5132
|
/* */
|
|
5043
5133
|
/* */
|
|
5044
5134
|
/* */
|
|
@@ -5046,6 +5136,11 @@ var UtilsFilesFoldersSync;
|
|
|
5046
5136
|
/* */
|
|
5047
5137
|
/* */
|
|
5048
5138
|
/* */
|
|
5139
|
+
return (void 0);
|
|
5140
|
+
};
|
|
5141
|
+
//#endregion
|
|
5142
|
+
//#region command exists (Unix / Windows)
|
|
5143
|
+
const commandExistsUnix = async (commandName) => {
|
|
5049
5144
|
/* */
|
|
5050
5145
|
/* */
|
|
5051
5146
|
/* */
|
|
@@ -5061,6 +5156,9 @@ var UtilsFilesFoldersSync;
|
|
|
5061
5156
|
/* */
|
|
5062
5157
|
/* */
|
|
5063
5158
|
/* */
|
|
5159
|
+
return (void 0);
|
|
5160
|
+
};
|
|
5161
|
+
const commandExistsWindows = async (commandName) => {
|
|
5064
5162
|
/* */
|
|
5065
5163
|
/* */
|
|
5066
5164
|
/* */
|
|
@@ -5070,6 +5168,9 @@ var UtilsFilesFoldersSync;
|
|
|
5070
5168
|
/* */
|
|
5071
5169
|
/* */
|
|
5072
5170
|
/* */
|
|
5171
|
+
return (void 0);
|
|
5172
|
+
};
|
|
5173
|
+
const commandExistsUnixSync = (commandName) => {
|
|
5073
5174
|
/* */
|
|
5074
5175
|
/* */
|
|
5075
5176
|
/* */
|
|
@@ -5083,6 +5184,9 @@ var UtilsFilesFoldersSync;
|
|
|
5083
5184
|
/* */
|
|
5084
5185
|
/* */
|
|
5085
5186
|
/* */
|
|
5187
|
+
return (void 0);
|
|
5188
|
+
};
|
|
5189
|
+
const commandExistsWindowsSync = (commandName) => {
|
|
5086
5190
|
/* */
|
|
5087
5191
|
/* */
|
|
5088
5192
|
/* */
|
|
@@ -5090,6 +5194,11 @@ var UtilsFilesFoldersSync;
|
|
|
5090
5194
|
/* */
|
|
5091
5195
|
/* */
|
|
5092
5196
|
/* */
|
|
5197
|
+
return (void 0);
|
|
5198
|
+
};
|
|
5199
|
+
//#endregion
|
|
5200
|
+
//#region exported API
|
|
5201
|
+
UtilsOs.commandExistsAsync = async (commandName) => {
|
|
5093
5202
|
/* */
|
|
5094
5203
|
/* */
|
|
5095
5204
|
/* */
|
|
@@ -5101,6 +5210,20 @@ var UtilsFilesFoldersSync;
|
|
|
5101
5210
|
/* */
|
|
5102
5211
|
/* */
|
|
5103
5212
|
/* */
|
|
5213
|
+
return (void 0);
|
|
5214
|
+
};
|
|
5215
|
+
/**
|
|
5216
|
+
* @deprecated use commandExistsAsync
|
|
5217
|
+
*/
|
|
5218
|
+
UtilsOs.commandExistsSync = (commandName) => {
|
|
5219
|
+
return UtilsOs.isRunningInWindows
|
|
5220
|
+
? commandExistsWindowsSync(commandName)
|
|
5221
|
+
: commandExistsUnixSync(commandName);
|
|
5222
|
+
};
|
|
5223
|
+
//#endregion
|
|
5224
|
+
//#endregion
|
|
5225
|
+
//#region utils os / python module exists
|
|
5226
|
+
UtilsOs.pipxPackageExists = (packageName) => {
|
|
5104
5227
|
/* */
|
|
5105
5228
|
/* */
|
|
5106
5229
|
/* */
|
|
@@ -5108,6 +5231,9 @@ var UtilsFilesFoldersSync;
|
|
|
5108
5231
|
/* */
|
|
5109
5232
|
/* */
|
|
5110
5233
|
/* */
|
|
5234
|
+
return (void 0);
|
|
5235
|
+
};
|
|
5236
|
+
UtilsOs.pipxNestedPackageExists = (mainPackageName, targetNestedFromMainPackage) => {
|
|
5111
5237
|
/* */
|
|
5112
5238
|
/* */
|
|
5113
5239
|
/* */
|
|
@@ -5121,6 +5247,14 @@ var UtilsFilesFoldersSync;
|
|
|
5121
5247
|
/* */
|
|
5122
5248
|
/* */
|
|
5123
5249
|
/* */
|
|
5250
|
+
return (void 0);
|
|
5251
|
+
};
|
|
5252
|
+
const normalizeModuleName = (name) => {
|
|
5253
|
+
return name.replace(/-/g, '_');
|
|
5254
|
+
};
|
|
5255
|
+
UtilsOs.pythonModuleExists = async (moduleName,
|
|
5256
|
+
// pythonPath = process.platform === 'win32' ? 'python' : 'python3',
|
|
5257
|
+
pythonPath = 'python3') => {
|
|
5124
5258
|
/* */
|
|
5125
5259
|
/* */
|
|
5126
5260
|
/* */
|
|
@@ -5142,22 +5276,27 @@ var UtilsFilesFoldersSync;
|
|
|
5142
5276
|
return (void 0);
|
|
5143
5277
|
};
|
|
5144
5278
|
//#endregion
|
|
5145
|
-
//#region utils
|
|
5146
|
-
|
|
5147
|
-
|
|
5148
|
-
|
|
5149
|
-
|
|
5150
|
-
|
|
5151
|
-
* (moved files are not detected)
|
|
5152
|
-
*/
|
|
5153
|
-
UtilsFilesFoldersSync.move = (from, to, options) => {
|
|
5154
|
-
/* */
|
|
5155
|
-
/* */
|
|
5156
|
-
/* */
|
|
5279
|
+
//#region utils terminal / draw horizontal line
|
|
5280
|
+
UtilsOs.drawHorizontalLine = (row = 0) => {
|
|
5281
|
+
//#region @browser
|
|
5282
|
+
const widthBrowserConsole = row || 80;
|
|
5283
|
+
console.log('-'.repeat(widthBrowserConsole));
|
|
5284
|
+
//#endregion
|
|
5157
5285
|
/* */
|
|
5158
5286
|
/* */
|
|
5159
5287
|
/* */
|
|
5160
5288
|
/* */
|
|
5289
|
+
};
|
|
5290
|
+
//#endregion
|
|
5291
|
+
//#region utils terminal / draw vertical line
|
|
5292
|
+
UtilsOs.drawVerticalLine = (col = 0) => {
|
|
5293
|
+
//#region @browser
|
|
5294
|
+
const heightBrowserConsole = 20;
|
|
5295
|
+
const line = Array.from({ length: heightBrowserConsole })
|
|
5296
|
+
.map(() => '|')
|
|
5297
|
+
.join('\n');
|
|
5298
|
+
console.log(line);
|
|
5299
|
+
//#endregion
|
|
5161
5300
|
/* */
|
|
5162
5301
|
/* */
|
|
5163
5302
|
/* */
|
|
@@ -5167,6 +5306,10 @@ var UtilsFilesFoldersSync;
|
|
|
5167
5306
|
/* */
|
|
5168
5307
|
/* */
|
|
5169
5308
|
/* */
|
|
5309
|
+
};
|
|
5310
|
+
//#endregion
|
|
5311
|
+
//#region utils os / get inotify watch count (linux)
|
|
5312
|
+
async function getInotifyWatchCount() {
|
|
5170
5313
|
/* */
|
|
5171
5314
|
/* */
|
|
5172
5315
|
/* */
|
|
@@ -5211,6 +5354,35 @@ var UtilsFilesFoldersSync;
|
|
|
5211
5354
|
/* */
|
|
5212
5355
|
/* */
|
|
5213
5356
|
/* */
|
|
5357
|
+
return (void 0);
|
|
5358
|
+
}
|
|
5359
|
+
UtilsOs.getInotifyWatchCount = getInotifyWatchCount;
|
|
5360
|
+
//#endregion
|
|
5361
|
+
//#region utils os / send notification
|
|
5362
|
+
UtilsOs.sendNotification = async (opt) => {
|
|
5363
|
+
//#region prepare variables
|
|
5364
|
+
const platform = os.platform();
|
|
5365
|
+
const defaultTimeoutMs = 3000;
|
|
5366
|
+
opt = _.cloneDeep(opt);
|
|
5367
|
+
const consoleNotification = `
|
|
5368
|
+
|
|
5369
|
+
> NOTIFICATION
|
|
5370
|
+
${opt.appName ?? 'App'} / ${opt.title}
|
|
5371
|
+
${opt.subtitle ? opt.subtitle + '\n' : ''}${opt.body ?? ''}
|
|
5372
|
+
|
|
5373
|
+
`;
|
|
5374
|
+
//#endregion
|
|
5375
|
+
//#region @browser
|
|
5376
|
+
UtilsOs.drawVerticalLine();
|
|
5377
|
+
console.log(consoleNotification);
|
|
5378
|
+
UtilsOs.drawVerticalLine();
|
|
5379
|
+
//#endregion
|
|
5380
|
+
/* */
|
|
5381
|
+
/* */
|
|
5382
|
+
/* */
|
|
5383
|
+
/* */
|
|
5384
|
+
/* */
|
|
5385
|
+
/* */
|
|
5214
5386
|
/* */
|
|
5215
5387
|
/* */
|
|
5216
5388
|
/* */
|
|
@@ -5225,53 +5397,16 @@ var UtilsFilesFoldersSync;
|
|
|
5225
5397
|
/* */
|
|
5226
5398
|
/* */
|
|
5227
5399
|
/* */
|
|
5228
|
-
return (void 0);
|
|
5229
|
-
};
|
|
5230
|
-
//#endregion
|
|
5231
|
-
})(UtilsFilesFoldersSync || (UtilsFilesFoldersSync = {}));
|
|
5232
|
-
/**
|
|
5233
|
-
* TODO @LAST @IN_PROGRESS
|
|
5234
|
-
* - utils for files and folders operations
|
|
5235
|
-
* - export when ready
|
|
5236
|
-
* - should be ready for everything async refactor
|
|
5237
|
-
*/
|
|
5238
|
-
var UtilsFilesFolders;
|
|
5239
|
-
(function (UtilsFilesFolders) {
|
|
5240
|
-
//#region utils files folders / ignore folder files patterns
|
|
5241
|
-
/**
|
|
5242
|
-
* Patterns that should be always ignored
|
|
5243
|
-
*/
|
|
5244
|
-
UtilsFilesFolders.IGNORE_FOLDERS_FILES_PATTERNS = UtilsFilesFoldersSync.IGNORE_FOLDERS_FILES_PATTERNS;
|
|
5245
|
-
//#endregion
|
|
5246
|
-
//#region utils files folders operations / remove file or folder or link
|
|
5247
|
-
/**
|
|
5248
|
-
* remove file or folder or link
|
|
5249
|
-
*/
|
|
5250
|
-
const remove = async (absolutePath, options) => {
|
|
5251
5400
|
/* */
|
|
5252
5401
|
/* */
|
|
5253
5402
|
/* */
|
|
5254
5403
|
/* */
|
|
5255
5404
|
/* */
|
|
5256
|
-
return (void 0);
|
|
5257
|
-
};
|
|
5258
|
-
//#endregion
|
|
5259
|
-
//#region utils files folders operations / remove file or folder or link
|
|
5260
|
-
/**
|
|
5261
|
-
* remove file or folder or link
|
|
5262
|
-
*/
|
|
5263
|
-
const removeByPattern = async (globPattern, options) => {
|
|
5264
5405
|
/* */
|
|
5265
5406
|
/* */
|
|
5266
5407
|
/* */
|
|
5267
5408
|
/* */
|
|
5268
5409
|
/* */
|
|
5269
|
-
return (void 0);
|
|
5270
|
-
};
|
|
5271
|
-
//#endregion
|
|
5272
|
-
//#region utils files folders operations / get files from
|
|
5273
|
-
async function getFilesFromAsync(folderOrLinkToFolder, options = {}) {
|
|
5274
|
-
return null;
|
|
5275
5410
|
/* */
|
|
5276
5411
|
/* */
|
|
5277
5412
|
/* */
|
|
@@ -5328,168 +5463,6 @@ var UtilsFilesFolders;
|
|
|
5328
5463
|
/* */
|
|
5329
5464
|
/* */
|
|
5330
5465
|
/* */
|
|
5331
|
-
return (void 0);
|
|
5332
|
-
}
|
|
5333
|
-
//#endregion
|
|
5334
|
-
//#region utils files folders operations / read file
|
|
5335
|
-
/**
|
|
5336
|
-
* TODO @IN_PROGRESS
|
|
5337
|
-
*/
|
|
5338
|
-
const readFileAsync = async (absoluteFilePath, options) => {
|
|
5339
|
-
return void 0;
|
|
5340
|
-
};
|
|
5341
|
-
/* */
|
|
5342
|
-
/* */
|
|
5343
|
-
/**
|
|
5344
|
-
* TODO @IN_PROGRESS
|
|
5345
|
-
*/
|
|
5346
|
-
const writeFileAsync = async (absoluteFilePath, input, options) => {
|
|
5347
|
-
return void 0;
|
|
5348
|
-
};
|
|
5349
|
-
//#endregion
|
|
5350
|
-
//#region utils files folders operations / is existed symlink
|
|
5351
|
-
/**
|
|
5352
|
-
* TODO @IN_PROGRESS
|
|
5353
|
-
*/
|
|
5354
|
-
const isExistedSymlink = async (absoluteFilePath) => {
|
|
5355
|
-
return void 0;
|
|
5356
|
-
};
|
|
5357
|
-
//#endregion
|
|
5358
|
-
//#region utils files folders operations / is un existed link
|
|
5359
|
-
/**
|
|
5360
|
-
* TODO @IN_PROGRESS
|
|
5361
|
-
*/
|
|
5362
|
-
const isUnExistedLink = async (absoluteFilePath) => {
|
|
5363
|
-
return void 0;
|
|
5364
|
-
};
|
|
5365
|
-
//#endregion
|
|
5366
|
-
})(UtilsFilesFolders || (UtilsFilesFolders = {}));
|
|
5367
|
-
|
|
5368
|
-
var UtilsJson;
|
|
5369
|
-
(function (UtilsJson) {
|
|
5370
|
-
//#region get attributes from jsonc or json5 file
|
|
5371
|
-
/**
|
|
5372
|
-
* ! TODO handle packages like zone.js with dot
|
|
5373
|
-
* Get attributes from jsonc or json5 file
|
|
5374
|
-
* @param jsonDeepPath lodash path to property in json ex. deep.path.to.prop
|
|
5375
|
-
* @param fileContent jsonc or json5 - json with comments
|
|
5376
|
-
* @returns array of attributes
|
|
5377
|
-
*/
|
|
5378
|
-
UtilsJson.getAtrributiesFromJsonWithComments = (jsonDeepPath, // lodash path to property in json ex. deep.path.to.prop
|
|
5379
|
-
fileContent) => {
|
|
5380
|
-
const lines = fileContent.split('\n');
|
|
5381
|
-
// split path to parts but keep part if is for example 'sql.js
|
|
5382
|
-
const pathParts = jsonDeepPath.split('.').reduce((a, b) => {
|
|
5383
|
-
if (a.length === 0) {
|
|
5384
|
-
return [b];
|
|
5385
|
-
}
|
|
5386
|
-
const last = a[a.length - 1];
|
|
5387
|
-
if ((last.startsWith(`['`) && b.endsWith(`']`)) ||
|
|
5388
|
-
(last.startsWith(`["`) && b.endsWith(`"]`))) {
|
|
5389
|
-
a[a.length - 1] = [last, b].join('.');
|
|
5390
|
-
}
|
|
5391
|
-
else {
|
|
5392
|
-
a.push(b);
|
|
5393
|
-
}
|
|
5394
|
-
return a;
|
|
5395
|
-
}, []);
|
|
5396
|
-
// console.log({ pathParts });
|
|
5397
|
-
// const pathParts = jsonDeepPath.split('.');
|
|
5398
|
-
// const keyName = pathParts.pop()!.replace(/^\["(.+)"\]$/, '$1');
|
|
5399
|
-
const keyName = pathParts.pop().replace(/^\["(.+)"\]$/, '$1');
|
|
5400
|
-
let currentPath = '';
|
|
5401
|
-
let attributes = [];
|
|
5402
|
-
let collectedComments = [];
|
|
5403
|
-
for (const line of lines) {
|
|
5404
|
-
const trimmedLine = line.trim();
|
|
5405
|
-
if (trimmedLine.startsWith('//')) {
|
|
5406
|
-
// Collect comments
|
|
5407
|
-
collectedComments.push(trimmedLine);
|
|
5408
|
-
// trimmedLine.startsWith('//pizda') &&
|
|
5409
|
-
// console.log('pushlin line', { trimmedLine });
|
|
5410
|
-
}
|
|
5411
|
-
else if (trimmedLine.startsWith('"') || trimmedLine.startsWith("'")) {
|
|
5412
|
-
// Extract the key from the line
|
|
5413
|
-
const match = trimmedLine.match(/["']([^"']+)["']\s*:/);
|
|
5414
|
-
// console.log({ match0: match && match[0], match1: match && match[1] });
|
|
5415
|
-
if (match) {
|
|
5416
|
-
const key = match[1];
|
|
5417
|
-
currentPath = currentPath
|
|
5418
|
-
? `${currentPath}.${key.includes('.') ? `['${key}']` : key}`
|
|
5419
|
-
: key;
|
|
5420
|
-
// console.log({ key });
|
|
5421
|
-
// Check if the current path matches the jsonDeepPath
|
|
5422
|
-
if ((currentPath.endsWith(keyName) &&
|
|
5423
|
-
!currentPath.endsWith('/' + keyName)) ||
|
|
5424
|
-
currentPath.endsWith(`['${keyName}']`)) {
|
|
5425
|
-
// console.log('extract attributes', {
|
|
5426
|
-
// keyName,
|
|
5427
|
-
// collectedCommentsLength: collectedComments.length,
|
|
5428
|
-
// });
|
|
5429
|
-
// Process the collected comments to extract attributes
|
|
5430
|
-
attributes = extractAttributesFromComments(collectedComments);
|
|
5431
|
-
break;
|
|
5432
|
-
}
|
|
5433
|
-
// Reset collected comments as they only relate to the next key
|
|
5434
|
-
collectedComments = [];
|
|
5435
|
-
}
|
|
5436
|
-
}
|
|
5437
|
-
}
|
|
5438
|
-
return attributes;
|
|
5439
|
-
};
|
|
5440
|
-
//#endregion
|
|
5441
|
-
//#region get attributes from comment
|
|
5442
|
-
UtilsJson.getAttributiesFromComment = (comment, attributes = []) => {
|
|
5443
|
-
// Match @name=value OR @name
|
|
5444
|
-
// Values can be "..." or '...' or unquoted token without @
|
|
5445
|
-
const attrRegex = /@(\w+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s@]+)))?/g;
|
|
5446
|
-
let match;
|
|
5447
|
-
while ((match = attrRegex.exec(comment)) !== null) {
|
|
5448
|
-
const [, name, doubleQuoted, singleQuoted, unquoted] = match;
|
|
5449
|
-
const value = doubleQuoted ?? singleQuoted ?? unquoted;
|
|
5450
|
-
const existingAttribute = attributes.find(attr => attr.name === `@${name}`);
|
|
5451
|
-
if (existingAttribute) {
|
|
5452
|
-
if (value !== undefined) {
|
|
5453
|
-
if (Array.isArray(existingAttribute.value)) {
|
|
5454
|
-
existingAttribute.value.push(value);
|
|
5455
|
-
}
|
|
5456
|
-
else {
|
|
5457
|
-
existingAttribute.value = [existingAttribute.value, value];
|
|
5458
|
-
}
|
|
5459
|
-
}
|
|
5460
|
-
}
|
|
5461
|
-
else {
|
|
5462
|
-
attributes.push({
|
|
5463
|
-
name: `@${name}`,
|
|
5464
|
-
value: value !== undefined ? value : true,
|
|
5465
|
-
});
|
|
5466
|
-
}
|
|
5467
|
-
}
|
|
5468
|
-
// Normalize single values not to be arrays
|
|
5469
|
-
attributes.forEach(attr => {
|
|
5470
|
-
if (Array.isArray(attr.value) && attr.value.length === 1) {
|
|
5471
|
-
attr.value = attr.value[0];
|
|
5472
|
-
}
|
|
5473
|
-
});
|
|
5474
|
-
return attributes;
|
|
5475
|
-
};
|
|
5476
|
-
//#endregion
|
|
5477
|
-
//#region extract attributes from comments
|
|
5478
|
-
const extractAttributesFromComments = (comments) => {
|
|
5479
|
-
const attributes = [];
|
|
5480
|
-
// console.log({ comments });
|
|
5481
|
-
for (const comment of comments) {
|
|
5482
|
-
UtilsJson.getAttributiesFromComment(comment, attributes);
|
|
5483
|
-
}
|
|
5484
|
-
return attributes;
|
|
5485
|
-
};
|
|
5486
|
-
//#endregion
|
|
5487
|
-
//#region read json
|
|
5488
|
-
/**
|
|
5489
|
-
* read json from absolute path
|
|
5490
|
-
* @returns json object
|
|
5491
|
-
*/
|
|
5492
|
-
UtilsJson.readJson = (absoluteFilePath, defaultValue = {}, useJson5 = false) => {
|
|
5493
5466
|
/* */
|
|
5494
5467
|
/* */
|
|
5495
5468
|
/* */
|
|
@@ -5509,56 +5482,46 @@ var UtilsJson;
|
|
|
5509
5482
|
/* */
|
|
5510
5483
|
/* */
|
|
5511
5484
|
/* */
|
|
5512
|
-
return (void 0);
|
|
5513
|
-
};
|
|
5514
|
-
//#endregion
|
|
5515
|
-
//#region read json with comments
|
|
5516
|
-
UtilsJson.readJsonWithComments = (absoluteFilePath, defaultValue = {}) => {
|
|
5517
5485
|
/* */
|
|
5518
5486
|
/* */
|
|
5519
|
-
return (void 0);
|
|
5520
|
-
};
|
|
5521
|
-
//#endregion
|
|
5522
|
-
//#region lodash path validation
|
|
5523
|
-
UtilsJson.validateLodashPath = (lodashGetPath) => {
|
|
5524
|
-
if (_.isArray(lodashGetPath)) {
|
|
5525
|
-
lodashGetPath = lodashGetPath.join('.');
|
|
5526
|
-
}
|
|
5527
|
-
if (!_.isString(lodashGetPath)) {
|
|
5528
|
-
throw new Error(`Invalid lodash path: path cannot be empty.`);
|
|
5529
|
-
}
|
|
5530
|
-
const path = lodashGetPath.trim();
|
|
5531
|
-
/**
|
|
5532
|
-
* Allowed:
|
|
5533
|
-
* foo
|
|
5534
|
-
* foo.bar
|
|
5535
|
-
* foo.bar.baz
|
|
5536
|
-
* foo[0].bar
|
|
5537
|
-
* foo.bar[123].baz
|
|
5538
|
-
*
|
|
5539
|
-
* Rejected:
|
|
5540
|
-
* foo..bar
|
|
5541
|
-
* .foo
|
|
5542
|
-
* foo.
|
|
5543
|
-
* foo[]
|
|
5544
|
-
* foo[abc]
|
|
5545
|
-
* foo[asd].bar
|
|
5546
|
-
*/
|
|
5547
|
-
const validPathRegex = /^[a-zA-Z_$][a-zA-Z0-9_$]*(?:\[\d+\])*(?:\.[a-zA-Z_$][a-zA-Z0-9_$]*(?:\[\d+\])*)*$/;
|
|
5548
|
-
if (!validPathRegex.test(path)) {
|
|
5549
|
-
throw new Error(`Invalid lodash path: "${path}"`);
|
|
5550
|
-
}
|
|
5551
|
-
const forbiddenKeys = ['__proto__', 'prototype', 'constructor'];
|
|
5552
|
-
const parts = path.replace(/\[(\d+)\]/g, '.$1').split('.');
|
|
5553
|
-
const forbiddenKey = parts.find(part => forbiddenKeys.includes(part));
|
|
5554
|
-
if (forbiddenKey) {
|
|
5555
|
-
throw new Error(`Invalid lodash path: forbidden key "${forbiddenKey}" in "${path}"`);
|
|
5556
|
-
}
|
|
5557
|
-
return path;
|
|
5558
5487
|
};
|
|
5559
5488
|
//#endregion
|
|
5560
|
-
//#region
|
|
5561
|
-
|
|
5489
|
+
//#region utils os / safe exit program clean up fn
|
|
5490
|
+
let isCleaning = false;
|
|
5491
|
+
function safeExitProgramCleanUp(cleanFn) {
|
|
5492
|
+
/* */
|
|
5493
|
+
/* */
|
|
5494
|
+
/* */
|
|
5495
|
+
/* */
|
|
5496
|
+
/* */
|
|
5497
|
+
/* */
|
|
5498
|
+
/* */
|
|
5499
|
+
/* */
|
|
5500
|
+
/* */
|
|
5501
|
+
/* */
|
|
5502
|
+
/* */
|
|
5503
|
+
/* */
|
|
5504
|
+
/* */
|
|
5505
|
+
/* */
|
|
5506
|
+
/* */
|
|
5507
|
+
/* */
|
|
5508
|
+
/* */
|
|
5509
|
+
/* */
|
|
5510
|
+
/* */
|
|
5511
|
+
/* */
|
|
5512
|
+
/* */
|
|
5513
|
+
/* */
|
|
5514
|
+
/* */
|
|
5515
|
+
/* */
|
|
5516
|
+
/* */
|
|
5517
|
+
/* */
|
|
5518
|
+
/* */
|
|
5519
|
+
/* */
|
|
5520
|
+
/* */
|
|
5521
|
+
/* */
|
|
5522
|
+
/* */
|
|
5523
|
+
/* */
|
|
5524
|
+
/* */
|
|
5562
5525
|
/* */
|
|
5563
5526
|
/* */
|
|
5564
5527
|
/* */
|
|
@@ -5579,10 +5542,29 @@ var UtilsJson;
|
|
|
5579
5542
|
/* */
|
|
5580
5543
|
/* */
|
|
5581
5544
|
return (void 0);
|
|
5582
|
-
}
|
|
5545
|
+
}
|
|
5546
|
+
UtilsOs.safeExitProgramCleanUp = safeExitProgramCleanUp;
|
|
5583
5547
|
//#endregion
|
|
5584
|
-
//#region
|
|
5585
|
-
|
|
5548
|
+
//#region utils os / where package locationd
|
|
5549
|
+
UtilsOs.whichOrWherePackageLocated = (packageName) => {
|
|
5550
|
+
/* */
|
|
5551
|
+
/* */
|
|
5552
|
+
/* */
|
|
5553
|
+
/* */
|
|
5554
|
+
/* */
|
|
5555
|
+
/* */
|
|
5556
|
+
/* */
|
|
5557
|
+
/* */
|
|
5558
|
+
/* */
|
|
5559
|
+
/* */
|
|
5560
|
+
/* */
|
|
5561
|
+
/* */
|
|
5562
|
+
/* */
|
|
5563
|
+
/* */
|
|
5564
|
+
/* */
|
|
5565
|
+
/* */
|
|
5566
|
+
/* */
|
|
5567
|
+
/* */
|
|
5586
5568
|
/* */
|
|
5587
5569
|
/* */
|
|
5588
5570
|
/* */
|
|
@@ -5608,7 +5590,31 @@ var UtilsJson;
|
|
|
5608
5590
|
return (void 0);
|
|
5609
5591
|
};
|
|
5610
5592
|
//#endregion
|
|
5611
|
-
})(
|
|
5593
|
+
})(UtilsOs || (UtilsOs = {}));
|
|
5594
|
+
//#region taon repo path in user dir fn
|
|
5595
|
+
const taonRepoPathUserInUserDirFn = () => {
|
|
5596
|
+
/* */
|
|
5597
|
+
/* */
|
|
5598
|
+
/* */
|
|
5599
|
+
/* */
|
|
5600
|
+
/* */
|
|
5601
|
+
/* */
|
|
5602
|
+
return (void 0);
|
|
5603
|
+
return '';
|
|
5604
|
+
};
|
|
5605
|
+
//#endregion
|
|
5606
|
+
//#region taon repo path for global template fn
|
|
5607
|
+
const taonBasePathToGlobalDockerTemplatesFn = () => {
|
|
5608
|
+
/* */
|
|
5609
|
+
/* */
|
|
5610
|
+
/* */
|
|
5611
|
+
/* */
|
|
5612
|
+
/* */
|
|
5613
|
+
/* */
|
|
5614
|
+
return (void 0);
|
|
5615
|
+
return '';
|
|
5616
|
+
};
|
|
5617
|
+
//#endregion
|
|
5612
5618
|
|
|
5613
5619
|
//#region utils process / start async
|
|
5614
5620
|
//#endregion
|
|
@@ -7128,7 +7134,7 @@ var UtilsTerminal;
|
|
|
7128
7134
|
UtilsTerminal.fetchAndDisplay = fetchAndDisplay;
|
|
7129
7135
|
})(UtilsTerminal || (UtilsTerminal = {}));
|
|
7130
7136
|
|
|
7131
|
-
|
|
7137
|
+
/* */
|
|
7132
7138
|
const WEBSQL_PROC_MOCK_PROCESSES_PID = {};
|
|
7133
7139
|
const WEBSQL_PROC_MOCK_PROCESSES_PPID = {};
|
|
7134
7140
|
const KEY = {
|
|
@@ -13880,6 +13886,376 @@ var UtilsJwt;
|
|
|
13880
13886
|
//#endregion
|
|
13881
13887
|
})(UtilsJwt || (UtilsJwt = {}));
|
|
13882
13888
|
|
|
13889
|
+
async function decodeEnv(encryptedValue) {
|
|
13890
|
+
if (!encryptedValue || typeof encryptedValue !== 'string') {
|
|
13891
|
+
return encryptedValue;
|
|
13892
|
+
}
|
|
13893
|
+
if (encryptedValue.startsWith(UtilsSecretEnv.TAON_ENCRYPTED_START) &&
|
|
13894
|
+
encryptedValue.endsWith(UtilsSecretEnv.TAON_ENCRYPTED_END)) {
|
|
13895
|
+
let masterKey = '';
|
|
13896
|
+
try {
|
|
13897
|
+
masterKey =
|
|
13898
|
+
GlobalStorage.get(UtilsSecretEnv.MASTER_PASS_KEY) ||
|
|
13899
|
+
globalThis[UtilsSecretEnv.MASTER_PASS_KEY] ||
|
|
13900
|
+
process.env[UtilsSecretEnv.MASTER_PASS_KEY];
|
|
13901
|
+
}
|
|
13902
|
+
catch (error) {
|
|
13903
|
+
Helpers.warn(`Not able to get master key for ${encryptedValue}`);
|
|
13904
|
+
}
|
|
13905
|
+
return await UtilsSecretEnv.decrypt(encryptedValue, masterKey);
|
|
13906
|
+
}
|
|
13907
|
+
return encryptedValue;
|
|
13908
|
+
}
|
|
13909
|
+
var UtilsSecretEnv;
|
|
13910
|
+
(function (UtilsSecretEnv) {
|
|
13911
|
+
UtilsSecretEnv.MASTER_PASS_KEY = 'TAON_MASTER_PASS_KEY';
|
|
13912
|
+
UtilsSecretEnv.TAON_ENCRYPTED_START = '$$$TAON_ENCRYPTED_START$$$';
|
|
13913
|
+
UtilsSecretEnv.TAON_ENCRYPTED_END = '$$$TAON_ENCRYPTED_END$$$';
|
|
13914
|
+
const VERSION = 'v1';
|
|
13915
|
+
const PBKDF2_ITERATIONS = 600_000;
|
|
13916
|
+
const SALT_LENGTH = 16;
|
|
13917
|
+
const IV_LENGTH = 12;
|
|
13918
|
+
const KEY_LENGTH = 256;
|
|
13919
|
+
//#region helpers
|
|
13920
|
+
function bytesToBase64(bytes) {
|
|
13921
|
+
let binary = '';
|
|
13922
|
+
for (const byte of bytes) {
|
|
13923
|
+
binary += String.fromCharCode(byte);
|
|
13924
|
+
}
|
|
13925
|
+
return btoa(binary);
|
|
13926
|
+
}
|
|
13927
|
+
function base64ToBytes(base64) {
|
|
13928
|
+
const binary = atob(base64);
|
|
13929
|
+
const result = new Uint8Array(binary.length);
|
|
13930
|
+
for (let i = 0; i < binary.length; i++) {
|
|
13931
|
+
result[i] = binary.charCodeAt(i);
|
|
13932
|
+
}
|
|
13933
|
+
return result;
|
|
13934
|
+
}
|
|
13935
|
+
async function deriveKey(password, salt) {
|
|
13936
|
+
const encoder = new TextEncoder();
|
|
13937
|
+
const passwordKey = await crypto.subtle.importKey('raw', encoder.encode(password), 'PBKDF2', false, ['deriveKey']);
|
|
13938
|
+
return crypto.subtle.deriveKey({
|
|
13939
|
+
name: 'PBKDF2',
|
|
13940
|
+
// @ts-ignore
|
|
13941
|
+
salt,
|
|
13942
|
+
iterations: PBKDF2_ITERATIONS,
|
|
13943
|
+
hash: 'SHA-256',
|
|
13944
|
+
}, passwordKey, {
|
|
13945
|
+
name: 'AES-GCM',
|
|
13946
|
+
length: KEY_LENGTH,
|
|
13947
|
+
}, false, ['encrypt', 'decrypt']);
|
|
13948
|
+
}
|
|
13949
|
+
//#endregion
|
|
13950
|
+
//#region encrypt
|
|
13951
|
+
/**
|
|
13952
|
+
* Result format:
|
|
13953
|
+
*
|
|
13954
|
+
* v1:<iterations>:<salt>:<iv>:<ciphertext>
|
|
13955
|
+
*
|
|
13956
|
+
* Salt and IV are intentionally stored with the ciphertext.
|
|
13957
|
+
* They are not secrets.
|
|
13958
|
+
*/
|
|
13959
|
+
async function encrypt(value, password) {
|
|
13960
|
+
const encoder = new TextEncoder();
|
|
13961
|
+
const salt = crypto.getRandomValues(new Uint8Array(SALT_LENGTH));
|
|
13962
|
+
const iv = crypto.getRandomValues(new Uint8Array(IV_LENGTH));
|
|
13963
|
+
const key = await deriveKey(password, salt);
|
|
13964
|
+
const encrypted = await crypto.subtle.encrypt({
|
|
13965
|
+
name: 'AES-GCM',
|
|
13966
|
+
iv,
|
|
13967
|
+
}, key, encoder.encode(value));
|
|
13968
|
+
return [
|
|
13969
|
+
VERSION,
|
|
13970
|
+
PBKDF2_ITERATIONS,
|
|
13971
|
+
bytesToBase64(salt),
|
|
13972
|
+
bytesToBase64(iv),
|
|
13973
|
+
bytesToBase64(new Uint8Array(encrypted)),
|
|
13974
|
+
].join(':');
|
|
13975
|
+
}
|
|
13976
|
+
UtilsSecretEnv.encrypt = encrypt;
|
|
13977
|
+
//#endregion
|
|
13978
|
+
//#region decrypt
|
|
13979
|
+
async function decrypt(encryptedValue, password) {
|
|
13980
|
+
const parts = encryptedValue.split(':');
|
|
13981
|
+
if (parts.length !== 5) {
|
|
13982
|
+
throw new Error('Invalid Taon encrypted value format.');
|
|
13983
|
+
}
|
|
13984
|
+
const [version, iterationsString, saltBase64, ivBase64, ciphertextBase64] = parts;
|
|
13985
|
+
if (version !== VERSION) {
|
|
13986
|
+
throw new Error(`Unsupported Taon encrypted value version: ${version}`);
|
|
13987
|
+
}
|
|
13988
|
+
const iterations = Number(iterationsString);
|
|
13989
|
+
if (!Number.isInteger(iterations) || iterations <= 0) {
|
|
13990
|
+
throw new Error('Invalid PBKDF2 iteration count.');
|
|
13991
|
+
}
|
|
13992
|
+
const salt = base64ToBytes(saltBase64);
|
|
13993
|
+
const iv = base64ToBytes(ivBase64);
|
|
13994
|
+
const ciphertext = base64ToBytes(ciphertextBase64);
|
|
13995
|
+
const encoder = new TextEncoder();
|
|
13996
|
+
const passwordKey = await crypto.subtle.importKey('raw', encoder.encode(password), 'PBKDF2', false, ['deriveKey']);
|
|
13997
|
+
const key = await crypto.subtle.deriveKey({
|
|
13998
|
+
name: 'PBKDF2',
|
|
13999
|
+
// @ts-ignore
|
|
14000
|
+
salt,
|
|
14001
|
+
iterations,
|
|
14002
|
+
hash: 'SHA-256',
|
|
14003
|
+
}, passwordKey, {
|
|
14004
|
+
name: 'AES-GCM',
|
|
14005
|
+
length: KEY_LENGTH,
|
|
14006
|
+
}, false, ['decrypt']);
|
|
14007
|
+
try {
|
|
14008
|
+
const decrypted = await crypto.subtle.decrypt({
|
|
14009
|
+
name: 'AES-GCM',
|
|
14010
|
+
// @ts-ignore
|
|
14011
|
+
iv,
|
|
14012
|
+
}, key, ciphertext);
|
|
14013
|
+
return new TextDecoder().decode(decrypted);
|
|
14014
|
+
}
|
|
14015
|
+
catch {
|
|
14016
|
+
Helpers.error('Unable to decrypt Taon secret. Invalid password or corrupted data.', false, true);
|
|
14017
|
+
}
|
|
14018
|
+
}
|
|
14019
|
+
UtilsSecretEnv.decrypt = decrypt;
|
|
14020
|
+
//#endregion
|
|
14021
|
+
//#region extract static string from arrow function
|
|
14022
|
+
/**
|
|
14023
|
+
* Extracts a static string from forms such as:
|
|
14024
|
+
*
|
|
14025
|
+
* () => 'secret'
|
|
14026
|
+
* () => "secret"
|
|
14027
|
+
* () => `secret`
|
|
14028
|
+
* () => `s${'asd'}ecret`
|
|
14029
|
+
* () => `port-${123}`
|
|
14030
|
+
*
|
|
14031
|
+
* Returns undefined for dynamic expressions:
|
|
14032
|
+
*
|
|
14033
|
+
* () => getSecret()
|
|
14034
|
+
* () => process.env.SECRET
|
|
14035
|
+
* () => `secret-${someVariable}`
|
|
14036
|
+
*/
|
|
14037
|
+
function extractStaticStringFromArrowFunction(contentPropFunction) {
|
|
14038
|
+
const arrowIndex = contentPropFunction.indexOf('=>');
|
|
14039
|
+
if (arrowIndex === -1) {
|
|
14040
|
+
return undefined;
|
|
14041
|
+
}
|
|
14042
|
+
let expression = contentPropFunction.slice(arrowIndex + 2).trim();
|
|
14043
|
+
// Allow:
|
|
14044
|
+
//
|
|
14045
|
+
// () => (`abc`)
|
|
14046
|
+
//
|
|
14047
|
+
if (expression.startsWith('(') && expression.endsWith(')')) {
|
|
14048
|
+
expression = expression.slice(1, -1).trim();
|
|
14049
|
+
}
|
|
14050
|
+
//#region normal quoted string
|
|
14051
|
+
if ((expression.startsWith("'") && expression.endsWith("'")) ||
|
|
14052
|
+
(expression.startsWith('"') && expression.endsWith('"'))) {
|
|
14053
|
+
return parseQuotedString(expression);
|
|
14054
|
+
}
|
|
14055
|
+
//#endregion
|
|
14056
|
+
//#region template literal
|
|
14057
|
+
if (expression.startsWith('`') && expression.endsWith('`')) {
|
|
14058
|
+
return parseStaticTemplateLiteral(expression);
|
|
14059
|
+
}
|
|
14060
|
+
//#endregion
|
|
14061
|
+
return undefined;
|
|
14062
|
+
}
|
|
14063
|
+
UtilsSecretEnv.extractStaticStringFromArrowFunction = extractStaticStringFromArrowFunction;
|
|
14064
|
+
//#endregion
|
|
14065
|
+
//#region parse quoted string
|
|
14066
|
+
function parseQuotedString(expression) {
|
|
14067
|
+
const quote = expression[0];
|
|
14068
|
+
let result = '';
|
|
14069
|
+
for (let i = 1; i < expression.length - 1; i++) {
|
|
14070
|
+
const char = expression[i];
|
|
14071
|
+
if (char !== '\\') {
|
|
14072
|
+
result += char;
|
|
14073
|
+
continue;
|
|
14074
|
+
}
|
|
14075
|
+
i++;
|
|
14076
|
+
if (i >= expression.length - 1) {
|
|
14077
|
+
return undefined;
|
|
14078
|
+
}
|
|
14079
|
+
const escaped = expression[i];
|
|
14080
|
+
switch (escaped) {
|
|
14081
|
+
case 'n':
|
|
14082
|
+
result += '\n';
|
|
14083
|
+
break;
|
|
14084
|
+
case 'r':
|
|
14085
|
+
result += '\r';
|
|
14086
|
+
break;
|
|
14087
|
+
case 't':
|
|
14088
|
+
result += '\t';
|
|
14089
|
+
break;
|
|
14090
|
+
case '\\':
|
|
14091
|
+
result += '\\';
|
|
14092
|
+
break;
|
|
14093
|
+
case "'":
|
|
14094
|
+
result += "'";
|
|
14095
|
+
break;
|
|
14096
|
+
case '"':
|
|
14097
|
+
result += '"';
|
|
14098
|
+
break;
|
|
14099
|
+
default:
|
|
14100
|
+
// Don't try to emulate the entire JS parser.
|
|
14101
|
+
return undefined;
|
|
14102
|
+
}
|
|
14103
|
+
}
|
|
14104
|
+
// Primarily documents intent and catches malformed input.
|
|
14105
|
+
if (expression.at(-1) !== quote) {
|
|
14106
|
+
return undefined;
|
|
14107
|
+
}
|
|
14108
|
+
return result;
|
|
14109
|
+
}
|
|
14110
|
+
//#endregion
|
|
14111
|
+
//#region parse static template literal
|
|
14112
|
+
function parseStaticTemplateLiteral(expression) {
|
|
14113
|
+
const content = expression.slice(1, -1);
|
|
14114
|
+
let result = '';
|
|
14115
|
+
for (let i = 0; i < content.length; i++) {
|
|
14116
|
+
const char = content[i];
|
|
14117
|
+
//#region escaped char
|
|
14118
|
+
if (char === '\\') {
|
|
14119
|
+
i++;
|
|
14120
|
+
if (i >= content.length) {
|
|
14121
|
+
return undefined;
|
|
14122
|
+
}
|
|
14123
|
+
const escaped = content[i];
|
|
14124
|
+
switch (escaped) {
|
|
14125
|
+
case 'n':
|
|
14126
|
+
result += '\n';
|
|
14127
|
+
break;
|
|
14128
|
+
case 'r':
|
|
14129
|
+
result += '\r';
|
|
14130
|
+
break;
|
|
14131
|
+
case 't':
|
|
14132
|
+
result += '\t';
|
|
14133
|
+
break;
|
|
14134
|
+
case '`':
|
|
14135
|
+
result += '`';
|
|
14136
|
+
break;
|
|
14137
|
+
case '\\':
|
|
14138
|
+
result += '\\';
|
|
14139
|
+
break;
|
|
14140
|
+
case '$':
|
|
14141
|
+
result += '$';
|
|
14142
|
+
break;
|
|
14143
|
+
default:
|
|
14144
|
+
return undefined;
|
|
14145
|
+
}
|
|
14146
|
+
continue;
|
|
14147
|
+
}
|
|
14148
|
+
//#endregion
|
|
14149
|
+
//#region interpolation
|
|
14150
|
+
if (char === '$' && content[i + 1] === '{') {
|
|
14151
|
+
const end = findInterpolationEnd(content, i + 2);
|
|
14152
|
+
if (end === -1) {
|
|
14153
|
+
return undefined;
|
|
14154
|
+
}
|
|
14155
|
+
const interpolation = content.slice(i + 2, end).trim();
|
|
14156
|
+
const value = parseStaticPrimitive(interpolation);
|
|
14157
|
+
if (value === undefined) {
|
|
14158
|
+
return undefined;
|
|
14159
|
+
}
|
|
14160
|
+
result += value;
|
|
14161
|
+
i = end;
|
|
14162
|
+
continue;
|
|
14163
|
+
}
|
|
14164
|
+
//#endregion
|
|
14165
|
+
result += char;
|
|
14166
|
+
}
|
|
14167
|
+
return result;
|
|
14168
|
+
}
|
|
14169
|
+
//#endregion
|
|
14170
|
+
//#region find interpolation end
|
|
14171
|
+
function findInterpolationEnd(content, start) {
|
|
14172
|
+
let quote;
|
|
14173
|
+
let escaped = false;
|
|
14174
|
+
for (let i = start; i < content.length; i++) {
|
|
14175
|
+
const char = content[i];
|
|
14176
|
+
if (escaped) {
|
|
14177
|
+
escaped = false;
|
|
14178
|
+
continue;
|
|
14179
|
+
}
|
|
14180
|
+
if (char === '\\') {
|
|
14181
|
+
escaped = true;
|
|
14182
|
+
continue;
|
|
14183
|
+
}
|
|
14184
|
+
if (quote) {
|
|
14185
|
+
if (char === quote) {
|
|
14186
|
+
quote = undefined;
|
|
14187
|
+
}
|
|
14188
|
+
continue;
|
|
14189
|
+
}
|
|
14190
|
+
if (char === "'" || char === '"') {
|
|
14191
|
+
quote = char;
|
|
14192
|
+
continue;
|
|
14193
|
+
}
|
|
14194
|
+
if (char === '}') {
|
|
14195
|
+
return i;
|
|
14196
|
+
}
|
|
14197
|
+
}
|
|
14198
|
+
return -1;
|
|
14199
|
+
}
|
|
14200
|
+
//#endregion
|
|
14201
|
+
//#region parse static primitive
|
|
14202
|
+
function parseStaticPrimitive(expression) {
|
|
14203
|
+
if ((expression.startsWith("'") && expression.endsWith("'")) ||
|
|
14204
|
+
(expression.startsWith('"') && expression.endsWith('"'))) {
|
|
14205
|
+
return parseQuotedString(expression);
|
|
14206
|
+
}
|
|
14207
|
+
if (/^-?(?:\d+\.?\d*|\.\d+)$/.test(expression)) {
|
|
14208
|
+
return String(Number(expression));
|
|
14209
|
+
}
|
|
14210
|
+
if (expression === 'true') {
|
|
14211
|
+
return 'true';
|
|
14212
|
+
}
|
|
14213
|
+
if (expression === 'false') {
|
|
14214
|
+
return 'false';
|
|
14215
|
+
}
|
|
14216
|
+
if (expression === 'null') {
|
|
14217
|
+
return 'null';
|
|
14218
|
+
}
|
|
14219
|
+
return undefined;
|
|
14220
|
+
}
|
|
14221
|
+
//#endregion
|
|
14222
|
+
//#region generate random password
|
|
14223
|
+
/**
|
|
14224
|
+
* Generates a cryptographically secure random password.
|
|
14225
|
+
*
|
|
14226
|
+
* Works in:
|
|
14227
|
+
* - Node.js
|
|
14228
|
+
* - Browser
|
|
14229
|
+
* - Cloudflare Workers
|
|
14230
|
+
*/
|
|
14231
|
+
function generateRandomPassword(length = 32) {
|
|
14232
|
+
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' +
|
|
14233
|
+
'abcdefghijklmnopqrstuvwxyz' +
|
|
14234
|
+
'0123456789' +
|
|
14235
|
+
'!@#$%^&*_-+=';
|
|
14236
|
+
let result = '';
|
|
14237
|
+
// Largest byte value range evenly divisible
|
|
14238
|
+
// by chars.length.
|
|
14239
|
+
const limit = Math.floor(256 / chars.length) * chars.length;
|
|
14240
|
+
while (result.length < length) {
|
|
14241
|
+
const bytes = new Uint8Array(Math.max(32, length - result.length));
|
|
14242
|
+
crypto.getRandomValues(bytes);
|
|
14243
|
+
for (const byte of bytes) {
|
|
14244
|
+
if (byte >= limit) {
|
|
14245
|
+
continue;
|
|
14246
|
+
}
|
|
14247
|
+
result += chars[byte % chars.length];
|
|
14248
|
+
if (result.length === length) {
|
|
14249
|
+
break;
|
|
14250
|
+
}
|
|
14251
|
+
}
|
|
14252
|
+
}
|
|
14253
|
+
return result;
|
|
14254
|
+
}
|
|
14255
|
+
UtilsSecretEnv.generateRandomPassword = generateRandomPassword;
|
|
14256
|
+
//#endregion
|
|
14257
|
+
})(UtilsSecretEnv || (UtilsSecretEnv = {}));
|
|
14258
|
+
|
|
13883
14259
|
const jsoncFormattingOptions = {
|
|
13884
14260
|
insertSpaces: true,
|
|
13885
14261
|
tabSize: 2,
|
|
@@ -14410,5 +14786,5 @@ var index = {};
|
|
|
14410
14786
|
* Generated bundle index. Do not edit.
|
|
14411
14787
|
*/
|
|
14412
14788
|
|
|
14413
|
-
export { $, BaselineSiteJoinprefix, CLI, CoreConfig, CoreModels, DbBinaryFormatEnum, ExecAsyncVscodeError, FilePathMetaData, FilesNames, GlobalLibTypeName, GlobalStorage, GlobalTaskManager, GlobalTaskManagerClass, Helpers, LibTypeArr, LibTypeEnum, PREFIXES, REGEX_REGION, TAGS, TaonStateMachine, Utils, UtilsBinary, UtilsCli, UtilsCliClassMethod, UtilsDotFile, UtilsEnv, UtilsEtcHosts, UtilsExecProc, UtilsFilesFolders, UtilsFilesFoldersSync, UtilsHttp, UtilsI18n, UtilsJson, UtilsJwt, UtilsMdDocs, UtilsMessages, UtilsMigrations, UtilsNetwork, UtilsOs, UtilsProcess, UtilsProcessLogger, UtilsProgress, UtilsProjects, UtilsStdinStdoutLogger, UtilsString, UtilsStringRegex, UtilsSudo, UtilsTerminal, UtilsTime, UtilsWaitNotifier, UtilsYaml, _, appRelatedFiles, areTrustedForPatchUpdate, axios, backendNodejsOnlyFiles, backendWebsqlNodejsFiles, baseTaonDevProjectsNames, chalk, child_process, chokidar, config, crossPlatformPath, dateformat, dockerTemplates, dotTaonFolder, dotTnpFolder, encoding, execAsyncVscode, extAllowedToExportAndReplaceTSJSCodeFiles, extAllowedToReplace, extForSassLikeFiles, extForStyles, extTemplatesFiles, fg, fileName, filesNotAllowedToClean, folderName, frameworkName, frameworkNameBe, frontEndOnly, frontendFiles, fse, glob, globalSpinner, http, https, isCloudflareWorker, isElevated, micromatch, mkdirp, ncp, notAllowedNames, notAllowedProjectNames, notNeededForExportFiles, os, path, ps, psList, requireDefault, requiredForDev, rimraf, spawn, startAsync, stateServiceSuffix, taonActionFromParent, taonBasePathToGlobalDockerTemplatesFn, taonContainers, taonCutNextLineCut, taonPackageName, taonProjects, taonRepoPathUserInUserDirFn, taonSkipCut, tempFoldersName, tnpPackageName, updateJsoncContent, urlRepoTaon, urlRepoTaonContainers, win32Path };
|
|
14789
|
+
export { $, BaselineSiteJoinprefix, CLI, CoreConfig, CoreModels, DbBinaryFormatEnum, ExecAsyncVscodeError, FilePathMetaData, FilesNames, GlobalLibTypeName, GlobalStorage, GlobalTaskManager, GlobalTaskManagerClass, Helpers, LibTypeArr, LibTypeEnum, PREFIXES, REGEX_REGION, TAGS, TaonStateMachine, Utils, UtilsBinary, UtilsCli, UtilsCliClassMethod, UtilsDotFile, UtilsEnv, UtilsEtcHosts, UtilsExecProc, UtilsFilesFolders, UtilsFilesFoldersSync, UtilsHttp, UtilsI18n, UtilsJson, UtilsJwt, UtilsMdDocs, UtilsMessages, UtilsMigrations, UtilsNetwork, UtilsOs, UtilsProcess, UtilsProcessLogger, UtilsProgress, UtilsProjects, UtilsSecretEnv, UtilsStdinStdoutLogger, UtilsString, UtilsStringRegex, UtilsSudo, UtilsTerminal, UtilsTime, UtilsWaitNotifier, UtilsYaml, _, appRelatedFiles, areTrustedForPatchUpdate, axios, backendNodejsOnlyFiles, backendWebsqlNodejsFiles, baseTaonDevProjectsNames, chalk, child_process, chokidar, config, crossPlatformPath, dateformat, decodeEnv, dockerTemplates, dotTaonFolder, dotTnpFolder, encoding, execAsyncVscode, extAllowedToExportAndReplaceTSJSCodeFiles, extAllowedToReplace, extForSassLikeFiles, extForStyles, extTemplatesFiles, fg, fileName, filesNotAllowedToClean, folderName, frameworkName, frameworkNameBe, frontEndOnly, frontendFiles, fse, glob, globalSpinner, http, https, isCloudflareWorker, isElevated, micromatch, mkdirp, ncp, notAllowedNames, notAllowedProjectNames, notNeededForExportFiles, os, path, ps, psList, requireDefault, requiredForDev, rimraf, spawn, startAsync, stateServiceSuffix, taonActionFromParent, taonBasePathToGlobalDockerTemplatesFn, taonContainers, taonCutNextLineCut, taonPackageName, taonProjects, taonRepoPathUserInUserDirFn, taonSkipCut, tempFoldersName, tnpPackageName, updateJsoncContent, urlRepoTaon, urlRepoTaonContainers, win32Path };
|
|
14414
14790
|
//# sourceMappingURL=tnp-core-browser.mjs.map
|