tnp-core 18.0.37 → 18.0.40
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/assets/shared/shared_folder_info.txt +1 -1
- package/browser/esm2022/lib/helpers-isomorphic.mjs +26 -30
- package/browser/esm2022/lib/helpers-messages.mjs +18 -1
- package/browser/esm2022/lib/helpers.mjs +22 -28
- package/browser/esm2022/lib/index.mjs +2 -2
- package/browser/esm2022/lib/required-global-npm-packages.mjs +79 -0
- package/browser/esm2022/lib/utils.mjs +323 -9
- package/browser/fesm2022/tnp-core.mjs +2404 -2077
- package/browser/fesm2022/tnp-core.mjs.map +1 -1
- package/browser/lib/helpers-isomorphic.d.ts +20 -0
- package/browser/lib/helpers-messages.d.ts +6 -0
- package/browser/lib/helpers.d.ts +16 -2
- package/browser/lib/index.d.ts +1 -1
- package/{websql/lib/required.d.ts → browser/lib/required-global-npm-packages.d.ts} +4 -0
- package/browser/lib/utils.d.ts +94 -43
- package/cli.backend.js +2 -2
- package/client/esm2022/lib/helpers-isomorphic.mjs +26 -30
- package/client/esm2022/lib/helpers-messages.mjs +18 -1
- package/client/esm2022/lib/helpers.mjs +22 -28
- package/client/esm2022/lib/index.mjs +2 -2
- package/client/esm2022/lib/required-global-npm-packages.mjs +79 -0
- package/client/esm2022/lib/utils.mjs +323 -9
- package/client/fesm2022/tnp-core.mjs +2404 -2077
- package/client/fesm2022/tnp-core.mjs.map +1 -1
- package/client/lib/helpers-isomorphic.d.ts +20 -0
- package/client/lib/helpers-messages.d.ts +6 -0
- package/client/lib/helpers.d.ts +16 -2
- package/client/lib/index.d.ts +1 -1
- package/{browser/lib/required.d.ts → client/lib/required-global-npm-packages.d.ts} +4 -0
- package/client/lib/utils.d.ts +94 -43
- package/lib/core-cli.js +3 -3
- package/lib/core-cli.js.map +1 -1
- package/lib/helpers-isomorphic.d.ts +20 -0
- package/lib/helpers-isomorphic.js +25 -35
- package/lib/helpers-isomorphic.js.map +1 -1
- package/lib/helpers-messages.d.ts +6 -0
- package/lib/helpers-messages.js +19 -0
- package/lib/helpers-messages.js.map +1 -1
- package/lib/helpers.d.ts +14 -0
- package/lib/helpers.js +33 -28
- package/lib/helpers.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/node-chalk-mock.js +2 -2
- package/lib/node-path-mock.js +2 -2
- package/lib/{required.d.ts → required-global-npm-packages.d.ts} +6 -2
- package/lib/{required.js → required-global-npm-packages.js} +8 -1
- package/lib/required-global-npm-packages.js.map +1 -0
- package/lib/utils.d.ts +94 -43
- package/lib/utils.js +383 -14
- package/lib/utils.js.map +1 -1
- package/package.json +3 -3
- package/tmp-environment.json +37 -31
- package/websql/esm2022/lib/helpers-isomorphic.mjs +26 -29
- package/websql/esm2022/lib/helpers-messages.mjs +18 -1
- package/websql/esm2022/lib/helpers.mjs +22 -28
- package/websql/esm2022/lib/index.mjs +2 -2
- package/websql/esm2022/lib/required-global-npm-packages.mjs +79 -0
- package/websql/esm2022/lib/utils.mjs +322 -9
- package/websql/fesm2022/tnp-core.mjs +2506 -2179
- package/websql/fesm2022/tnp-core.mjs.map +1 -1
- package/websql/lib/helpers-isomorphic.d.ts +20 -0
- package/websql/lib/helpers-messages.d.ts +6 -0
- package/websql/lib/helpers.d.ts +16 -2
- package/websql/lib/index.d.ts +1 -1
- package/{client/lib/required.d.ts → websql/lib/required-global-npm-packages.d.ts} +4 -0
- package/websql/lib/utils.d.ts +94 -43
- package/browser/esm2022/lib/required.mjs +0 -72
- package/client/esm2022/lib/required.mjs +0 -72
- package/lib/required.js.map +0 -1
- package/websql/esm2022/lib/required.mjs +0 -72
package/lib/utils.d.ts
CHANGED
@@ -10,6 +10,10 @@ export declare namespace Utils {
|
|
10
10
|
export function removeChalkSpecialChars(str: string): string;
|
11
11
|
export const fullDateTime: () => string;
|
12
12
|
export const fullDate: () => string;
|
13
|
+
export const getFreePort: (options?: {
|
14
|
+
startFrom?: number;
|
15
|
+
howManyFreePortsAfterThatPort?: number;
|
16
|
+
}) => Promise<number>;
|
13
17
|
interface AttrJsoncProp {
|
14
18
|
name: string;
|
15
19
|
value?: any;
|
@@ -91,56 +95,103 @@ export declare namespace Utils {
|
|
91
95
|
*/
|
92
96
|
function numValue(pixelsCss: string | number): number;
|
93
97
|
}
|
94
|
-
export
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
* unitil this string is in output of stderr
|
112
|
-
*/
|
113
|
-
stderr?: string | string[];
|
114
|
-
/**
|
115
|
-
* by default only resolve when exit code is 0
|
116
|
-
*/
|
117
|
-
resolveAfterAnyExitCode?: boolean;
|
118
|
-
};
|
98
|
+
export {};
|
99
|
+
}
|
100
|
+
export declare namespace UtilsProcess {
|
101
|
+
interface ProcessStartOptions {
|
102
|
+
/**
|
103
|
+
* by default is process.cwd();
|
104
|
+
*/
|
105
|
+
cwd?: string;
|
106
|
+
/**
|
107
|
+
* by default is false
|
108
|
+
*/
|
109
|
+
showCommand?: boolean;
|
110
|
+
/**
|
111
|
+
* Modify output line by line
|
112
|
+
*/
|
113
|
+
outputLineReplace?: (outputLineStderOrStdout: string) => string;
|
114
|
+
resolvePromiseMsg?: {
|
119
115
|
/**
|
120
|
-
*
|
116
|
+
* until this string is in output of stdout
|
121
117
|
*/
|
122
|
-
|
118
|
+
stdout?: string | string[];
|
123
119
|
/**
|
124
|
-
*
|
120
|
+
* until this string is in output of stderr
|
125
121
|
*/
|
126
|
-
|
127
|
-
askToTryAgainOnError?: boolean;
|
128
|
-
exitOnErrorCallback?: (code: number) => void;
|
122
|
+
stderr?: string | string[];
|
129
123
|
/**
|
130
|
-
*
|
124
|
+
* by default only resolve when exit code is 0
|
131
125
|
*/
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
126
|
+
resolveAfterAnyExitCode?: boolean;
|
127
|
+
};
|
128
|
+
/**
|
129
|
+
* Prefix messages output from child_process
|
130
|
+
*/
|
131
|
+
prefix?: string;
|
132
|
+
/**
|
133
|
+
* Try command again after fail after n milliseconds
|
134
|
+
*/
|
135
|
+
tryAgainWhenFailAfter?: number;
|
136
|
+
askToTryAgainOnError?: boolean;
|
137
|
+
exitOnErrorCallback?: (code: number) => void;
|
138
|
+
/**
|
139
|
+
* Use big buffer for big webpack logs
|
140
|
+
* (it may slow down smaller processes execution)
|
141
|
+
*/
|
142
|
+
biggerBuffer?: boolean;
|
143
|
+
hideOutput?: {
|
144
|
+
stdout?: boolean;
|
145
|
+
stderr?: boolean;
|
146
|
+
};
|
142
147
|
}
|
143
|
-
|
148
|
+
/**
|
149
|
+
* TODO IMPLEMENT
|
150
|
+
* start async node process
|
151
|
+
*/
|
152
|
+
function startAsync(command: string, options?: ProcessStartOptions): Promise<void>;
|
153
|
+
/**
|
154
|
+
* TODO IMPLEMENT
|
155
|
+
*/
|
156
|
+
function startSync(command: string, options?: ProcessStartOptions): void;
|
157
|
+
const getGitBashPath: () => string;
|
158
|
+
/**
|
159
|
+
* TODO IMPLEMENT
|
160
|
+
* start async node process
|
161
|
+
*/
|
162
|
+
const startInNewTerminalWindow: (command: string, options?: Pick<ProcessStartOptions, "cwd" | "hideOutput">) => any;
|
163
|
+
const getBashOrShellName: () => "browser" | "cmd" | "powershell" | "gitbash" | "cygwin" | "unknown" | "bash" | "zsh" | "fish" | "sh";
|
164
|
+
}
|
165
|
+
export declare namespace UtilsOs {
|
166
|
+
/**
|
167
|
+
* check if script is running in client browser
|
168
|
+
* (websql model -> is also considered as browser
|
169
|
+
* because it is running in browser)
|
170
|
+
*/
|
171
|
+
const isRunningInBrowser: () => boolean;
|
172
|
+
/**
|
173
|
+
* check if script is running in nodejs
|
174
|
+
* (backend script or electron script)
|
175
|
+
*/
|
176
|
+
const isRunningInNode: () => boolean;
|
177
|
+
/**
|
178
|
+
* check if script is running special
|
179
|
+
* browser mode that has sql.js backend
|
180
|
+
* and executes sql queries in browser
|
181
|
+
*/
|
182
|
+
const isRunningInWebSQL: () => boolean;
|
183
|
+
/**
|
184
|
+
* check whether the current process is running inside
|
185
|
+
* Electron backend or browser.
|
186
|
+
*/
|
187
|
+
const isRunningInElectron: () => boolean;
|
188
|
+
/**
|
189
|
+
* Check wether the current process is running inside
|
190
|
+
* windows subsystem for linux (WSL).
|
191
|
+
*/
|
192
|
+
const isRunningInWsl: () => boolean;
|
193
|
+
const isRunningInDocker: () => boolean;
|
194
|
+
const isRunningInLinuxGraphicsCapableEnvironment: () => boolean;
|
144
195
|
}
|
145
196
|
export declare namespace UtilsString {
|
146
197
|
const kebabCaseNoSplitNumbers: (input: string) => string;
|
package/lib/utils.js
CHANGED
@@ -1,17 +1,22 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.UtilsString = exports.Utils = void 0;
|
3
|
+
exports.UtilsString = exports.UtilsOs = exports.UtilsProcess = exports.Utils = void 0;
|
4
4
|
var tslib_1 = require("tslib");
|
5
5
|
var core_models_1 = require("./core-models");
|
6
6
|
var axios_1 = require("axios");
|
7
7
|
var core_imports_1 = require("./core-imports");
|
8
|
+
var index_1 = require("./index");
|
8
9
|
//#region @backend
|
9
10
|
var core_imports_2 = require("./core-imports");
|
11
|
+
var core_imports_3 = require("./core-imports");
|
10
12
|
var buffer_1 = require("buffer");
|
11
13
|
//#endregion
|
12
14
|
var BLOB_SUPPORTED_IN_SQLJS = false;
|
15
|
+
//#region utils
|
13
16
|
var Utils;
|
14
17
|
(function (Utils) {
|
18
|
+
var _this = this;
|
19
|
+
//#region utils / uniq array
|
15
20
|
Utils.uniqArray = function (array, uniqueProperty) {
|
16
21
|
var seen = {};
|
17
22
|
return array
|
@@ -22,6 +27,8 @@ var Utils;
|
|
22
27
|
: (seen[uniqueProperty ? item[uniqueProperty] : item] = true);
|
23
28
|
});
|
24
29
|
};
|
30
|
+
//#endregion
|
31
|
+
//#region utils / escape string for reg exp
|
25
32
|
/**
|
26
33
|
* Example:
|
27
34
|
* new RegExp(escapeStringForRegEx('a.b.c'),'g') => /a\.b\.c/g
|
@@ -29,6 +36,8 @@ var Utils;
|
|
29
36
|
Utils.escapeStringForRegEx = function (stringForRegExp) {
|
30
37
|
return stringForRegExp.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
|
31
38
|
};
|
39
|
+
//#endregion
|
40
|
+
//#region utils / remove chalk special chars
|
32
41
|
function removeChalkSpecialChars(str) {
|
33
42
|
// Regex to match ANSI escape sequences used by Chalk
|
34
43
|
var ansiRegex = /\u001b\[[0-9;]*m/g;
|
@@ -36,16 +45,66 @@ var Utils;
|
|
36
45
|
return str.replace(ansiRegex, '');
|
37
46
|
}
|
38
47
|
Utils.removeChalkSpecialChars = removeChalkSpecialChars;
|
48
|
+
//#endregion
|
49
|
+
//#region utils / full date time
|
39
50
|
Utils.fullDateTime = function () {
|
40
51
|
//#region @backendFunc
|
41
|
-
return (0,
|
52
|
+
return (0, core_imports_3.dateformat)(new Date(), 'dd-mm-yyyy HH:MM:ss');
|
42
53
|
//#endregion
|
43
54
|
};
|
55
|
+
//#endregion
|
56
|
+
//#region utils / full date
|
44
57
|
Utils.fullDate = function () {
|
45
58
|
//#region @backendFunc
|
46
|
-
return (0,
|
59
|
+
return (0, core_imports_3.dateformat)(new Date(), 'dd-mm-yyyy');
|
47
60
|
//#endregion
|
48
61
|
};
|
62
|
+
//#endregion
|
63
|
+
//#region utils / get free port
|
64
|
+
var takenPorts = [];
|
65
|
+
Utils.getFreePort = function (options) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
66
|
+
var startFrom, howManyFreePortsAfterThatPort, max, i, port, err_1;
|
67
|
+
return tslib_1.__generator(this, function (_a) {
|
68
|
+
switch (_a.label) {
|
69
|
+
case 0:
|
70
|
+
//#region @backendFunc
|
71
|
+
options = options || {};
|
72
|
+
options.startFrom = options.startFrom || 3000;
|
73
|
+
startFrom = options.startFrom;
|
74
|
+
howManyFreePortsAfterThatPort = options.howManyFreePortsAfterThatPort || 1;
|
75
|
+
max = 5000;
|
76
|
+
i = 0;
|
77
|
+
if (core_imports_1._.isNumber(startFrom)) {
|
78
|
+
while (takenPorts.includes(startFrom)) {
|
79
|
+
startFrom += 1 + howManyFreePortsAfterThatPort;
|
80
|
+
}
|
81
|
+
}
|
82
|
+
_a.label = 1;
|
83
|
+
case 1:
|
84
|
+
if (!true) return [3 /*break*/, 6];
|
85
|
+
_a.label = 2;
|
86
|
+
case 2:
|
87
|
+
_a.trys.push([2, 4, , 5]);
|
88
|
+
return [4 /*yield*/, core_imports_1.portfinder.getPortPromise({ port: startFrom })];
|
89
|
+
case 3:
|
90
|
+
port = _a.sent();
|
91
|
+
takenPorts.push(port);
|
92
|
+
return [2 /*return*/, port];
|
93
|
+
case 4:
|
94
|
+
err_1 = _a.sent();
|
95
|
+
console.log(err_1);
|
96
|
+
index_1.Helpers.warn("Trying to assign port :".concat(startFrom, " but already in use."), false);
|
97
|
+
return [3 /*break*/, 5];
|
98
|
+
case 5:
|
99
|
+
startFrom += 1;
|
100
|
+
if (i++ === max) {
|
101
|
+
index_1.Helpers.error("[taon-helpers]] failed to assign free port after ".concat(max, " trys..."));
|
102
|
+
}
|
103
|
+
return [3 /*break*/, 1];
|
104
|
+
case 6: return [2 /*return*/];
|
105
|
+
}
|
106
|
+
});
|
107
|
+
}); };
|
49
108
|
var json;
|
50
109
|
(function (json) {
|
51
110
|
json.getAtrributies = function (jsonDeepPath, // lodash path to property in json ex. deep.path.to.prop
|
@@ -724,22 +783,330 @@ var Utils;
|
|
724
783
|
//#endregion
|
725
784
|
})(css = Utils.css || (Utils.css = {}));
|
726
785
|
//#endregion
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
786
|
+
})(Utils || (exports.Utils = Utils = {}));
|
787
|
+
//#endregion
|
788
|
+
//#region utils process
|
789
|
+
var UtilsProcess;
|
790
|
+
(function (UtilsProcess) {
|
791
|
+
//#endregion
|
792
|
+
//#region utils process / TODO start async
|
793
|
+
/**
|
794
|
+
* TODO IMPLEMENT
|
795
|
+
* start async node process
|
796
|
+
*/
|
797
|
+
function startAsync(command, options) {
|
798
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
799
|
+
return tslib_1.__generator(this, function (_a) {
|
732
800
|
return [2 /*return*/];
|
733
|
-
});
|
801
|
+
});
|
802
|
+
});
|
803
|
+
}
|
804
|
+
UtilsProcess.startAsync = startAsync;
|
805
|
+
//#endregion
|
806
|
+
//#region utils process / TODO start sync
|
807
|
+
/**
|
808
|
+
* TODO IMPLEMENT
|
809
|
+
*/
|
810
|
+
function startSync(command, options) {
|
811
|
+
// TODO @LAST
|
812
|
+
}
|
813
|
+
UtilsProcess.startSync = startSync;
|
814
|
+
//#endregion
|
815
|
+
//#region utils process / get git bash path
|
816
|
+
UtilsProcess.getGitBashPath = function () {
|
817
|
+
//#region @backendFunc
|
818
|
+
if (process.platform !== 'win32') {
|
819
|
+
return null;
|
820
|
+
}
|
821
|
+
try {
|
822
|
+
// Execute the 'where' command to find bash.exe
|
823
|
+
var gitBashPath = core_imports_2.child_process
|
824
|
+
.execSync('where bash.exe', { encoding: 'utf8' })
|
825
|
+
.split('\n')[0]
|
826
|
+
.trim();
|
827
|
+
if (gitBashPath) {
|
828
|
+
return (0, core_imports_1.crossPlatformPath)(gitBashPath);
|
829
|
+
}
|
830
|
+
return null; // Return the first match
|
831
|
+
}
|
832
|
+
catch (err) {
|
833
|
+
return null;
|
834
|
+
}
|
835
|
+
//#endregion
|
836
|
+
};
|
837
|
+
//#endregion
|
838
|
+
//#region utils process / start process in new graphical terminal window
|
839
|
+
/**
|
840
|
+
* TODO IMPLEMENT
|
841
|
+
* start async node process
|
842
|
+
*/
|
843
|
+
UtilsProcess.startInNewTerminalWindow = function (command, options) {
|
844
|
+
var e_3, _a;
|
845
|
+
//#region @backendFunc
|
846
|
+
var platform = process.platform;
|
847
|
+
options = options || {};
|
848
|
+
options.cwd = options.cwd || process.cwd();
|
849
|
+
if (platform === 'win32') {
|
850
|
+
var gitBashPath = UtilsProcess.getGitBashPath();
|
851
|
+
// const currentBash = getBashOrShellName();
|
852
|
+
// console.log('gitBashPath', gitBashPath);
|
853
|
+
// console.log('currentBash', currentBash);
|
854
|
+
if (gitBashPath) {
|
855
|
+
return (0, core_imports_2.spawn)('start bash', ['-c', "".concat(command)], // Use '-c' to execute a single command in Git Bash
|
856
|
+
{
|
857
|
+
detached: true, // Detached process
|
858
|
+
stdio: 'ignore', // Ignore stdio
|
859
|
+
cwd: options === null || options === void 0 ? void 0 : options.cwd,
|
860
|
+
}).unref(); // Ensure the parent process can exit independently
|
861
|
+
}
|
862
|
+
console.error("\n\n\n Please install git bash to use this cli (https://gitforwindows.org/)\n\n\n ");
|
863
|
+
// For Windows
|
864
|
+
return (0, core_imports_2.spawn)('cmd', ['/c', 'start', 'cmd', '/k', "".concat(command)], {
|
865
|
+
detached: true,
|
866
|
+
stdio: 'ignore',
|
867
|
+
cwd: options === null || options === void 0 ? void 0 : options.cwd,
|
868
|
+
}).unref();
|
734
869
|
}
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
870
|
+
else if (platform === 'darwin') {
|
871
|
+
// For macOS
|
872
|
+
return (0, core_imports_2.spawn)('osascript', ['-e', "tell application \"Terminal\" to do script \"".concat(command, "\"")], {
|
873
|
+
detached: true,
|
874
|
+
stdio: 'ignore',
|
875
|
+
cwd: options === null || options === void 0 ? void 0 : options.cwd,
|
876
|
+
}).unref();
|
877
|
+
}
|
878
|
+
else if (platform === 'linux') {
|
879
|
+
if (!UtilsOs.isRunningInLinuxGraphicsCapableEnvironment()) {
|
880
|
+
var child_1 = core_imports_2.child_process.spawn(command, {
|
881
|
+
detached: true,
|
882
|
+
cwd: options === null || options === void 0 ? void 0 : options.cwd,
|
883
|
+
stdio: 'ignore',
|
884
|
+
});
|
885
|
+
child_1.unref();
|
886
|
+
return;
|
887
|
+
}
|
888
|
+
// For Linux (gnome-terminal as an example)
|
889
|
+
var terminals = [
|
890
|
+
{ cmd: 'gnome-terminal', args: ['--'] },
|
891
|
+
{ cmd: 'konsole', args: ['-e'] },
|
892
|
+
{ cmd: 'xfce4-terminal', args: ['-e'] },
|
893
|
+
{ cmd: 'xterm', args: ['-e'] },
|
894
|
+
{ cmd: 'lxterminal', args: ['-e'] },
|
895
|
+
{ cmd: 'mate-terminal', args: ['-e'] },
|
896
|
+
{ cmd: 'terminator', args: ['-e'] },
|
897
|
+
{ cmd: 'tilix', args: ['-e'] },
|
898
|
+
{ cmd: 'alacritty', args: ['-e'] },
|
899
|
+
{ cmd: 'urxvt', args: ['-e'] },
|
900
|
+
];
|
901
|
+
var terminalCommand = '';
|
902
|
+
var terminalArgs = [];
|
903
|
+
try {
|
904
|
+
for (var terminals_1 = tslib_1.__values(terminals), terminals_1_1 = terminals_1.next(); !terminals_1_1.done; terminals_1_1 = terminals_1.next()) {
|
905
|
+
var term = terminals_1_1.value;
|
906
|
+
try {
|
907
|
+
core_imports_2.child_process.execSync("which ".concat(term.cmd), {
|
908
|
+
stdio: 'ignore',
|
909
|
+
cwd: options === null || options === void 0 ? void 0 : options.cwd,
|
910
|
+
});
|
911
|
+
terminalCommand = term.cmd;
|
912
|
+
terminalArgs = tslib_1.__spreadArray(tslib_1.__spreadArray([], tslib_1.__read(term.args), false), [command], false);
|
913
|
+
break;
|
914
|
+
}
|
915
|
+
catch (err) {
|
916
|
+
// Terminal not found, continue to the next
|
917
|
+
}
|
918
|
+
}
|
919
|
+
}
|
920
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
921
|
+
finally {
|
922
|
+
try {
|
923
|
+
if (terminals_1_1 && !terminals_1_1.done && (_a = terminals_1.return)) _a.call(terminals_1);
|
924
|
+
}
|
925
|
+
finally { if (e_3) throw e_3.error; }
|
926
|
+
}
|
927
|
+
if (!terminalCommand) {
|
928
|
+
console.error('No supported terminal emulator found.');
|
929
|
+
return;
|
930
|
+
}
|
931
|
+
var child = (0, core_imports_2.spawn)(terminalCommand, terminalArgs, {
|
932
|
+
detached: true,
|
933
|
+
stdio: 'ignore',
|
934
|
+
});
|
935
|
+
child.unref();
|
936
|
+
}
|
937
|
+
else {
|
938
|
+
index_1.Helpers.throw("Unsupported platform: ".concat(platform));
|
939
|
+
}
|
940
|
+
//#endregion
|
941
|
+
};
|
739
942
|
//#endregion
|
740
|
-
|
943
|
+
//#region utils process / get bash or shell name
|
944
|
+
UtilsProcess.getBashOrShellName = function () {
|
945
|
+
/* */
|
946
|
+
/* */
|
947
|
+
//#region @backendFunc
|
948
|
+
var platform = process.platform; // Identify the platform: 'win32', 'darwin', 'linux'
|
949
|
+
var shell = process.env.SHELL || process.env.ComSpec || ''; // Common shell environment variables
|
950
|
+
if (platform === 'win32') {
|
951
|
+
if (shell.includes('cmd.exe'))
|
952
|
+
return 'cmd';
|
953
|
+
if (shell.includes('powershell.exe') || shell.includes('pwsh'))
|
954
|
+
return 'powershell';
|
955
|
+
// Heuristic for Git Bash
|
956
|
+
if (process.env.MSYSTEM &&
|
957
|
+
process.env.MSYSTEM.toLowerCase().includes('mingw')) {
|
958
|
+
return 'gitbash';
|
959
|
+
}
|
960
|
+
// Heuristic for Cygwin
|
961
|
+
if (shell.includes('cygwin')) {
|
962
|
+
return 'cygwin';
|
963
|
+
}
|
964
|
+
return 'unknown'; // Default for unrecognized shells on Windows
|
965
|
+
}
|
966
|
+
else {
|
967
|
+
// For macOS and Linux
|
968
|
+
if (shell.includes('bash'))
|
969
|
+
return 'bash';
|
970
|
+
if (shell.includes('zsh'))
|
971
|
+
return 'zsh';
|
972
|
+
if (shell.includes('fish'))
|
973
|
+
return 'fish';
|
974
|
+
if (shell.includes('sh'))
|
975
|
+
return 'sh';
|
976
|
+
return 'unknown'; // Default for unrecognized shells on Unix-based systems
|
977
|
+
}
|
978
|
+
//#endregion
|
979
|
+
};
|
980
|
+
//#endregion
|
981
|
+
})(UtilsProcess || (exports.UtilsProcess = UtilsProcess = {}));
|
982
|
+
//#endregion
|
983
|
+
//#region utils os
|
984
|
+
var UtilsOs;
|
985
|
+
(function (UtilsOs) {
|
986
|
+
//#region utils os / is running in browser
|
987
|
+
/**
|
988
|
+
* check if script is running in client browser
|
989
|
+
* (websql model -> is also considered as browser
|
990
|
+
* because it is running in browser)
|
991
|
+
*/
|
992
|
+
UtilsOs.isRunningInBrowser = function () {
|
993
|
+
//#region @backend
|
994
|
+
return false;
|
995
|
+
//#endregion
|
996
|
+
return true;
|
997
|
+
};
|
998
|
+
//#endregion
|
999
|
+
//#region utils os / is running in node
|
1000
|
+
/**
|
1001
|
+
* check if script is running in nodejs
|
1002
|
+
* (backend script or electron script)
|
1003
|
+
*/
|
1004
|
+
UtilsOs.isRunningInNode = function () {
|
1005
|
+
//#region @backend
|
1006
|
+
return true;
|
1007
|
+
//#endregion
|
1008
|
+
return false;
|
1009
|
+
};
|
1010
|
+
//#endregion
|
1011
|
+
//#region utils os / is running in websql
|
1012
|
+
/**
|
1013
|
+
* check if script is running special
|
1014
|
+
* browser mode that has sql.js backend
|
1015
|
+
* and executes sql queries in browser
|
1016
|
+
*/
|
1017
|
+
UtilsOs.isRunningInWebSQL = function () {
|
1018
|
+
//#region @backend
|
1019
|
+
return false;
|
1020
|
+
//#endregion
|
1021
|
+
/* */
|
1022
|
+
/* */
|
1023
|
+
return false;
|
1024
|
+
};
|
1025
|
+
//#endregion
|
1026
|
+
//#region utils os / is running in electron
|
1027
|
+
/**
|
1028
|
+
* check whether the current process is running inside
|
1029
|
+
* Electron backend or browser.
|
1030
|
+
*/
|
1031
|
+
UtilsOs.isRunningInElectron = function () {
|
1032
|
+
// Renderer process
|
1033
|
+
// @ts-ignore
|
1034
|
+
if (typeof window !== 'undefined' &&
|
1035
|
+
typeof window.process === 'object' &&
|
1036
|
+
window.process.type === 'renderer') {
|
1037
|
+
return true;
|
1038
|
+
}
|
1039
|
+
// Main process
|
1040
|
+
// @ts-ignore
|
1041
|
+
if (typeof process !== 'undefined' &&
|
1042
|
+
typeof process.versions === 'object' &&
|
1043
|
+
!!process.versions.electron) {
|
1044
|
+
return true;
|
1045
|
+
}
|
1046
|
+
// Detect the user agent when the `nodeIntegration` option is set to false
|
1047
|
+
if (typeof navigator === 'object' &&
|
1048
|
+
typeof navigator.userAgent === 'string' &&
|
1049
|
+
navigator.userAgent.indexOf('Electron') >= 0) {
|
1050
|
+
return true;
|
1051
|
+
}
|
1052
|
+
return false;
|
1053
|
+
};
|
1054
|
+
//#endregion
|
1055
|
+
//#region utils os / is running in wsl
|
1056
|
+
/**
|
1057
|
+
* Check wether the current process is running inside
|
1058
|
+
* windows subsystem for linux (WSL).
|
1059
|
+
*/
|
1060
|
+
UtilsOs.isRunningInWsl = function () {
|
1061
|
+
//#region @backendFunc
|
1062
|
+
if (process.platform !== 'linux') {
|
1063
|
+
return false;
|
1064
|
+
}
|
1065
|
+
if (core_imports_1.os.release().toLowerCase().includes('microsoft')) {
|
1066
|
+
return true;
|
1067
|
+
}
|
1068
|
+
try {
|
1069
|
+
return core_imports_3.fse
|
1070
|
+
.readFileSync('/proc/version', 'utf8')
|
1071
|
+
.toLowerCase()
|
1072
|
+
.includes('microsoft');
|
1073
|
+
}
|
1074
|
+
catch (_) {
|
1075
|
+
return false;
|
1076
|
+
}
|
1077
|
+
//#endregion
|
1078
|
+
};
|
1079
|
+
//#endregion
|
1080
|
+
//#region utils os / is running in docker
|
1081
|
+
UtilsOs.isRunningInDocker = function () {
|
1082
|
+
//#region @backendFunc
|
1083
|
+
try {
|
1084
|
+
var cgroup = core_imports_3.fse.readFileSync('/proc/1/cgroup', 'utf8');
|
1085
|
+
return /docker|kubepods|containerd/.test(cgroup);
|
1086
|
+
}
|
1087
|
+
catch (e) {
|
1088
|
+
return false; // If the file does not exist or cannot be read, assume not running in Docker
|
1089
|
+
}
|
1090
|
+
//#endregion
|
1091
|
+
};
|
1092
|
+
//#endregion
|
1093
|
+
//#region utils os / is running in linux graphics capable environment
|
1094
|
+
UtilsOs.isRunningInLinuxGraphicsCapableEnvironment = function () {
|
1095
|
+
//#region @backendFunc
|
1096
|
+
if (core_imports_1.os.platform() !== 'linux') {
|
1097
|
+
return false;
|
1098
|
+
}
|
1099
|
+
// Check for the DISPLAY environment variable
|
1100
|
+
return !!process.env.DISPLAY;
|
1101
|
+
//#endregion
|
1102
|
+
};
|
1103
|
+
//#endregion
|
1104
|
+
})(UtilsOs || (exports.UtilsOs = UtilsOs = {}));
|
1105
|
+
//#endregion
|
1106
|
+
//#region utils string
|
741
1107
|
var UtilsString;
|
742
1108
|
(function (UtilsString) {
|
1109
|
+
//#region utils string / kebab case no split numbers
|
743
1110
|
UtilsString.kebabCaseNoSplitNumbers = function (input) {
|
744
1111
|
return (input
|
745
1112
|
// Match spaces or any kind of whitespace and replace with a hyphen
|
@@ -749,5 +1116,7 @@ var UtilsString;
|
|
749
1116
|
// Convert everything to lowercase
|
750
1117
|
.toLowerCase());
|
751
1118
|
};
|
1119
|
+
//#endregion
|
752
1120
|
})(UtilsString || (exports.UtilsString = UtilsString = {}));
|
1121
|
+
//#endregion
|
753
1122
|
//# sourceMappingURL=utils.js.map
|