@qodalis/cli-core 0.0.15 → 2.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +399 -31
- package/package.json +16 -23
- package/public-api.d.mts +2322 -0
- package/public-api.d.ts +2322 -8
- package/public-api.js +3597 -0
- package/public-api.js.map +1 -0
- package/public-api.mjs +3545 -0
- package/public-api.mjs.map +1 -0
- package/esm2022/lib/constants/index.mjs +0 -8
- package/esm2022/lib/interfaces/command-hooks.mjs +0 -2
- package/esm2022/lib/interfaces/command-processor.mjs +0 -2
- package/esm2022/lib/interfaces/execution-context.mjs +0 -2
- package/esm2022/lib/interfaces/index.mjs +0 -6
- package/esm2022/lib/interfaces/progress-bars.mjs +0 -2
- package/esm2022/lib/interfaces/users.mjs +0 -2
- package/esm2022/lib/models/index.mjs +0 -175
- package/esm2022/lib/models/services.mjs +0 -2
- package/esm2022/lib/models/users.mjs +0 -2
- package/esm2022/lib/modules/index.mjs +0 -30
- package/esm2022/lib/themes/index.mjs +0 -221
- package/esm2022/lib/types/CancellablePromise.mjs +0 -28
- package/esm2022/lib/types/index.mjs +0 -2
- package/esm2022/lib/utils/delay.mjs +0 -4
- package/esm2022/lib/utils/index.mjs +0 -80
- package/esm2022/lib/utils/object-describer.mjs +0 -134
- package/esm2022/lib/utils/terminal-utils.mjs +0 -16
- package/esm2022/lib/version.mjs +0 -3
- package/esm2022/public-api.mjs +0 -12
- package/esm2022/qodalis-cli-core.mjs +0 -5
- package/fesm2022/qodalis-cli-core.mjs +0 -697
- package/fesm2022/qodalis-cli-core.mjs.map +0 -1
- package/index.d.ts +0 -5
- package/lib/constants/index.d.ts +0 -5
- package/lib/interfaces/command-hooks.d.ts +0 -5
- package/lib/interfaces/command-processor.d.ts +0 -151
- package/lib/interfaces/execution-context.d.ts +0 -109
- package/lib/interfaces/index.d.ts +0 -349
- package/lib/interfaces/progress-bars.d.ts +0 -72
- package/lib/interfaces/users.d.ts +0 -42
- package/lib/models/index.d.ts +0 -293
- package/lib/models/services.d.ts +0 -20
- package/lib/models/users.d.ts +0 -30
- package/lib/modules/index.d.ts +0 -6
- package/lib/themes/index.d.ts +0 -16
- package/lib/types/CancellablePromise.d.ts +0 -8
- package/lib/types/index.d.ts +0 -1
- package/lib/utils/delay.d.ts +0 -1
- package/lib/utils/index.d.ts +0 -24
- package/lib/utils/object-describer.d.ts +0 -12
- package/lib/utils/terminal-utils.d.ts +0 -7
- package/lib/version.d.ts +0 -1
|
@@ -1,697 +0,0 @@
|
|
|
1
|
-
var CliForegroundColor;
|
|
2
|
-
(function (CliForegroundColor) {
|
|
3
|
-
CliForegroundColor["Black"] = "\u001B[30m";
|
|
4
|
-
CliForegroundColor["Red"] = "\u001B[31m";
|
|
5
|
-
CliForegroundColor["Green"] = "\u001B[32m";
|
|
6
|
-
CliForegroundColor["Yellow"] = "\u001B[33m";
|
|
7
|
-
CliForegroundColor["Blue"] = "\u001B[34m";
|
|
8
|
-
CliForegroundColor["Magenta"] = "\u001B[35m";
|
|
9
|
-
CliForegroundColor["Cyan"] = "\u001B[36m";
|
|
10
|
-
CliForegroundColor["White"] = "\u001B[37m";
|
|
11
|
-
CliForegroundColor["Reset"] = "\u001B[0m";
|
|
12
|
-
})(CliForegroundColor || (CliForegroundColor = {}));
|
|
13
|
-
var CliBackgroundColor;
|
|
14
|
-
(function (CliBackgroundColor) {
|
|
15
|
-
CliBackgroundColor["Black"] = "\u001B[40m";
|
|
16
|
-
CliBackgroundColor["Red"] = "\u001B[41m";
|
|
17
|
-
CliBackgroundColor["Green"] = "\u001B[42m";
|
|
18
|
-
CliBackgroundColor["Yellow"] = "\u001B[43m";
|
|
19
|
-
CliBackgroundColor["Blue"] = "\u001B[44m";
|
|
20
|
-
CliBackgroundColor["Magenta"] = "\u001B[45m";
|
|
21
|
-
CliBackgroundColor["Cyan"] = "\u001B[46m";
|
|
22
|
-
CliBackgroundColor["White"] = "\u001B[47m";
|
|
23
|
-
})(CliBackgroundColor || (CliBackgroundColor = {}));
|
|
24
|
-
var CliIcon;
|
|
25
|
-
(function (CliIcon) {
|
|
26
|
-
// General Symbols
|
|
27
|
-
CliIcon["CheckIcon"] = "\u2714";
|
|
28
|
-
CliIcon["CrossIcon"] = "\u2718";
|
|
29
|
-
CliIcon["InfoIcon"] = "\u2139";
|
|
30
|
-
CliIcon["WarningIcon"] = "\u26A0";
|
|
31
|
-
CliIcon["QuestionMark"] = "?";
|
|
32
|
-
CliIcon["Exclamation"] = "\u2757";
|
|
33
|
-
CliIcon["Ellipsis"] = "\u2026";
|
|
34
|
-
CliIcon["Dot"] = "\u2022";
|
|
35
|
-
CliIcon["Bullet"] = "\u2023";
|
|
36
|
-
// Arrows
|
|
37
|
-
CliIcon["ArrowRight"] = "\u2192";
|
|
38
|
-
CliIcon["ArrowLeft"] = "\u2190";
|
|
39
|
-
CliIcon["ArrowUp"] = "\u2191";
|
|
40
|
-
CliIcon["ArrowDown"] = "\u2193";
|
|
41
|
-
CliIcon["ArrowRightFilled"] = "\u25B6";
|
|
42
|
-
CliIcon["ArrowLeftFilled"] = "\u25C0";
|
|
43
|
-
CliIcon["ArrowUpFilled"] = "\u25B2";
|
|
44
|
-
CliIcon["ArrowDownFilled"] = "\u25BC";
|
|
45
|
-
CliIcon["DoubleArrowRight"] = "\u00BB";
|
|
46
|
-
CliIcon["DoubleArrowLeft"] = "\u00AB";
|
|
47
|
-
// Lists and Progress
|
|
48
|
-
CliIcon["Star"] = "\u2605";
|
|
49
|
-
CliIcon["StarEmpty"] = "\u2606";
|
|
50
|
-
CliIcon["Plus"] = "+";
|
|
51
|
-
CliIcon["Minus"] = "-";
|
|
52
|
-
CliIcon["Progress"] = "\u23F3";
|
|
53
|
-
CliIcon["Success"] = "\u2705";
|
|
54
|
-
CliIcon["Failure"] = "\u274C";
|
|
55
|
-
// Time and Calendar
|
|
56
|
-
CliIcon["Clock"] = "\u23F0";
|
|
57
|
-
CliIcon["Timer"] = "\u23F1";
|
|
58
|
-
CliIcon["Alarm"] = "\uD83D\uDD14";
|
|
59
|
-
CliIcon["Calendar"] = "\uD83D\uDCC5";
|
|
60
|
-
// Navigation and Folders
|
|
61
|
-
CliIcon["Folder"] = "\uD83D\uDCC1";
|
|
62
|
-
CliIcon["FolderOpen"] = "\uD83D\uDCC2";
|
|
63
|
-
CliIcon["File"] = "\uD83D\uDCC4";
|
|
64
|
-
CliIcon["Archive"] = "\uD83D\uDDC3";
|
|
65
|
-
CliIcon["Link"] = "\uD83D\uDD17";
|
|
66
|
-
CliIcon["Chain"] = "\u26D3";
|
|
67
|
-
CliIcon["Bookmark"] = "\uD83D\uDD16";
|
|
68
|
-
// Actions
|
|
69
|
-
CliIcon["Edit"] = "\u270F";
|
|
70
|
-
CliIcon["Trash"] = "\uD83D\uDDD1";
|
|
71
|
-
CliIcon["Add"] = "\u2795";
|
|
72
|
-
CliIcon["Remove"] = "\u2796";
|
|
73
|
-
CliIcon["Reload"] = "\uD83D\uDD04";
|
|
74
|
-
CliIcon["Save"] = "\uD83D\uDCBE";
|
|
75
|
-
CliIcon["Undo"] = "\u21A9";
|
|
76
|
-
CliIcon["Redo"] = "\u21AA";
|
|
77
|
-
CliIcon["Play"] = "\u25B6";
|
|
78
|
-
CliIcon["Pause"] = "\u23F8";
|
|
79
|
-
CliIcon["Stop"] = "\u23F9";
|
|
80
|
-
CliIcon["Cancel"] = "\u274E";
|
|
81
|
-
// User and Security
|
|
82
|
-
CliIcon["User"] = "\uD83D\uDC64";
|
|
83
|
-
CliIcon["Group"] = "\uD83D\uDC65";
|
|
84
|
-
CliIcon["Lock"] = "\uD83D\uDD12";
|
|
85
|
-
CliIcon["Unlock"] = "\uD83D\uDD13";
|
|
86
|
-
CliIcon["Help"] = "\u2753";
|
|
87
|
-
CliIcon["Key"] = "\uD83D\uDD11";
|
|
88
|
-
CliIcon["Shield"] = "\uD83D\uDEE1";
|
|
89
|
-
// Tools and Settings
|
|
90
|
-
CliIcon["Gear"] = "\u2699";
|
|
91
|
-
CliIcon["Settings"] = "\u2699\uFE0F";
|
|
92
|
-
CliIcon["Theme"] = "\uD83C\uDFA8";
|
|
93
|
-
CliIcon["Light"] = "\uD83D\uDCA1";
|
|
94
|
-
CliIcon["Bug"] = "\uD83D\uDC1E";
|
|
95
|
-
CliIcon["Wrench"] = "\uD83D\uDD27";
|
|
96
|
-
CliIcon["Hammer"] = "\uD83D\uDD28";
|
|
97
|
-
// Technology and Devices
|
|
98
|
-
CliIcon["Terminal"] = "\uD83D\uDCBB";
|
|
99
|
-
CliIcon["Database"] = "\uD83D\uDDC4";
|
|
100
|
-
CliIcon["Server"] = "\uD83D\uDDA5";
|
|
101
|
-
CliIcon["Cloud"] = "\u2601";
|
|
102
|
-
CliIcon["Network"] = "\uD83C\uDF10";
|
|
103
|
-
CliIcon["Monitor"] = "\uD83D\uDDA5";
|
|
104
|
-
CliIcon["Printer"] = "\uD83D\uDDA8";
|
|
105
|
-
CliIcon["USB"] = "\uD83D\uDD0C";
|
|
106
|
-
CliIcon["Speaker"] = "\uD83D\uDD0A";
|
|
107
|
-
CliIcon["Microphone"] = "\uD83C\uDF99";
|
|
108
|
-
CliIcon["Camera"] = "\uD83D\uDCF7";
|
|
109
|
-
CliIcon["Video"] = "\uD83C\uDFA5";
|
|
110
|
-
CliIcon["Music"] = "\uD83C\uDFB5";
|
|
111
|
-
CliIcon["Phone"] = "\uD83D\uDCDE";
|
|
112
|
-
// Development and Evaluation
|
|
113
|
-
CliIcon["Package"] = "\uD83D\uDCE6";
|
|
114
|
-
CliIcon["Plugin"] = "\uD83D\uDD0C";
|
|
115
|
-
CliIcon["Extension"] = "\uD83E\uDDE9";
|
|
116
|
-
CliIcon["Module"] = "\uD83D\uDCE6";
|
|
117
|
-
CliIcon["Evaluate"] = "\uD83D\uDD0D";
|
|
118
|
-
CliIcon["Variable"] = "\uD83D\uDD27";
|
|
119
|
-
CliIcon["Script"] = "\uD83D\uDCDC";
|
|
120
|
-
CliIcon["Code"] = "\uD83D\uDCBE";
|
|
121
|
-
// Status and Completion
|
|
122
|
-
CliIcon["Logs"] = "\uD83D\uDCDC";
|
|
123
|
-
CliIcon["Power"] = "\u23FB";
|
|
124
|
-
CliIcon["Heart"] = "\u2764";
|
|
125
|
-
CliIcon["Flame"] = "\uD83D\uDD25";
|
|
126
|
-
CliIcon["Growth"] = "\uD83D\uDCC8";
|
|
127
|
-
CliIcon["Decline"] = "\uD83D\uDCC9";
|
|
128
|
-
CliIcon["WarningFilled"] = "\u26A0\uFE0F";
|
|
129
|
-
// Nature and Weather
|
|
130
|
-
CliIcon["Sun"] = "\u2600";
|
|
131
|
-
CliIcon["Moon"] = "\uD83C\uDF19";
|
|
132
|
-
CliIcon["Rain"] = "\uD83C\uDF27";
|
|
133
|
-
CliIcon["Snow"] = "\u2744";
|
|
134
|
-
CliIcon["Lightning"] = "\u26A1";
|
|
135
|
-
CliIcon["Tree"] = "\uD83C\uDF32";
|
|
136
|
-
// Emotions and Expressions
|
|
137
|
-
CliIcon["Smile"] = "\uD83D\uDE0A";
|
|
138
|
-
CliIcon["Sad"] = "\uD83D\uDE22";
|
|
139
|
-
CliIcon["Angry"] = "\uD83D\uDE21";
|
|
140
|
-
CliIcon["Clap"] = "\uD83D\uDC4F";
|
|
141
|
-
CliIcon["ThumbsUp"] = "\uD83D\uDC4D";
|
|
142
|
-
CliIcon["ThumbsDown"] = "\uD83D\uDC4E";
|
|
143
|
-
// Miscellaneous
|
|
144
|
-
CliIcon["Rocket"] = "\uD83D\uDE80";
|
|
145
|
-
CliIcon["Globe"] = "\uD83C\uDF0D";
|
|
146
|
-
CliIcon["Medal"] = "\uD83C\uDFC5";
|
|
147
|
-
CliIcon["Trophy"] = "\uD83C\uDFC6";
|
|
148
|
-
CliIcon["Flag"] = "\uD83D\uDEA9";
|
|
149
|
-
CliIcon["StarFilled"] = "\u2B50";
|
|
150
|
-
CliIcon["StarOutline"] = "\u2729";
|
|
151
|
-
CliIcon["Fireworks"] = "\uD83C\uDF86";
|
|
152
|
-
CliIcon["Balloon"] = "\uD83C\uDF88";
|
|
153
|
-
CliIcon["Gift"] = "\uD83C\uDF81";
|
|
154
|
-
})(CliIcon || (CliIcon = {}));
|
|
155
|
-
/**
|
|
156
|
-
* Represents a log level for the CLI
|
|
157
|
-
*/
|
|
158
|
-
var CliLogLevel;
|
|
159
|
-
(function (CliLogLevel) {
|
|
160
|
-
CliLogLevel[CliLogLevel["None"] = 0] = "None";
|
|
161
|
-
CliLogLevel[CliLogLevel["DEBUG"] = 1] = "DEBUG";
|
|
162
|
-
CliLogLevel[CliLogLevel["LOG"] = 2] = "LOG";
|
|
163
|
-
CliLogLevel[CliLogLevel["INFO"] = 3] = "INFO";
|
|
164
|
-
CliLogLevel[CliLogLevel["WARN"] = 4] = "WARN";
|
|
165
|
-
CliLogLevel[CliLogLevel["ERROR"] = 5] = "ERROR";
|
|
166
|
-
})(CliLogLevel || (CliLogLevel = {}));
|
|
167
|
-
const enums = {
|
|
168
|
-
CliForegroundColor,
|
|
169
|
-
CliBackgroundColor,
|
|
170
|
-
CliIcon,
|
|
171
|
-
CliLogLevel,
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
const DefaultLibraryAuthor = {
|
|
175
|
-
name: 'Nicolae Lupei',
|
|
176
|
-
email: 'nicolae.lupei@qodalis.com',
|
|
177
|
-
};
|
|
178
|
-
const constants = {
|
|
179
|
-
DefaultLibraryAuthor,
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
const delay = (ms) => {
|
|
183
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
class ObjectDescriber {
|
|
187
|
-
static describe(obj, options) {
|
|
188
|
-
const { filter } = options || {};
|
|
189
|
-
const processors = [];
|
|
190
|
-
const keys = Object.keys(obj);
|
|
191
|
-
const functions = keys.filter((key) => typeof obj[key] === 'function');
|
|
192
|
-
for (const func of functions) {
|
|
193
|
-
const funcValue = obj[func];
|
|
194
|
-
const args = this.getFunctionArguments(funcValue);
|
|
195
|
-
if (filter) {
|
|
196
|
-
const shouldInclude = filter({
|
|
197
|
-
funcName: func,
|
|
198
|
-
func: funcValue,
|
|
199
|
-
args,
|
|
200
|
-
});
|
|
201
|
-
if (!shouldInclude) {
|
|
202
|
-
continue;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
const supportsMultipleArgs = args.length > 1;
|
|
206
|
-
const supportsDynamicArgs = this.supportsDynamicArgs(funcValue);
|
|
207
|
-
if (args.length === 0 && !supportsDynamicArgs) {
|
|
208
|
-
continue;
|
|
209
|
-
}
|
|
210
|
-
if (args.length > 0 &&
|
|
211
|
-
args.some((arg) => arg === 'function' || arg === 'func')) {
|
|
212
|
-
continue;
|
|
213
|
-
}
|
|
214
|
-
const processor = {
|
|
215
|
-
command: func,
|
|
216
|
-
description: `A command that executes the function ${func} with the provided arguments`,
|
|
217
|
-
allowUnlistedCommands: true,
|
|
218
|
-
valueRequired: true,
|
|
219
|
-
parameters: [
|
|
220
|
-
{
|
|
221
|
-
name: 'debug',
|
|
222
|
-
description: 'Debug',
|
|
223
|
-
type: 'boolean',
|
|
224
|
-
required: false,
|
|
225
|
-
},
|
|
226
|
-
],
|
|
227
|
-
processCommand: async (command, context) => {
|
|
228
|
-
const debug = command.args['debug'];
|
|
229
|
-
if (debug) {
|
|
230
|
-
context.writer.writeln('Executing command: ' + func);
|
|
231
|
-
context.writer.writeln('Arguments: ' + JSON.stringify(command.args));
|
|
232
|
-
context.writer.writeln('Function: ' + funcValue.toString());
|
|
233
|
-
}
|
|
234
|
-
const argsToCallF = [];
|
|
235
|
-
if (supportsMultipleArgs) {
|
|
236
|
-
for (const arg of args.slice(1)) {
|
|
237
|
-
argsToCallF.push(command.args[arg]);
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
if (supportsDynamicArgs && command.value) {
|
|
241
|
-
const delimiter = command.args['delimiter'] || ',';
|
|
242
|
-
argsToCallF.push(...command.value.split(delimiter));
|
|
243
|
-
}
|
|
244
|
-
if (debug) {
|
|
245
|
-
context.writer.writeln('Arguments after processing: ' +
|
|
246
|
-
JSON.stringify(argsToCallF));
|
|
247
|
-
}
|
|
248
|
-
const result = supportsDynamicArgs && args.length === 0
|
|
249
|
-
? funcValue(...argsToCallF)
|
|
250
|
-
: funcValue(command.value, ...argsToCallF);
|
|
251
|
-
context.writer.write(context.writer.wrapInColor('Result: ', CliForegroundColor.Yellow));
|
|
252
|
-
if (result === null) {
|
|
253
|
-
context.writer.writeln('null');
|
|
254
|
-
}
|
|
255
|
-
else if (result === undefined) {
|
|
256
|
-
context.writer.writeln('undefined');
|
|
257
|
-
}
|
|
258
|
-
else if (typeof result === 'boolean') {
|
|
259
|
-
context.writer.writeln(result.toString());
|
|
260
|
-
}
|
|
261
|
-
else if (typeof result === 'number') {
|
|
262
|
-
context.writer.writeln(result.toString());
|
|
263
|
-
}
|
|
264
|
-
else if (Array.isArray(result)) {
|
|
265
|
-
context.writer.writeJson(result);
|
|
266
|
-
}
|
|
267
|
-
else if (typeof result === 'string') {
|
|
268
|
-
context.writer.writeln(result);
|
|
269
|
-
}
|
|
270
|
-
else if (typeof result === 'object') {
|
|
271
|
-
context.writer.writeJson(result);
|
|
272
|
-
}
|
|
273
|
-
else {
|
|
274
|
-
context.writer.writeln(result?.toString());
|
|
275
|
-
}
|
|
276
|
-
context.process.output(result?.toString());
|
|
277
|
-
},
|
|
278
|
-
writeDescription: (context) => {
|
|
279
|
-
context.writer.writeln(func);
|
|
280
|
-
},
|
|
281
|
-
};
|
|
282
|
-
if (supportsDynamicArgs) {
|
|
283
|
-
processor.parameters?.push({
|
|
284
|
-
name: 'delimiter',
|
|
285
|
-
description: 'Delimiter',
|
|
286
|
-
type: 'string',
|
|
287
|
-
required: false,
|
|
288
|
-
});
|
|
289
|
-
}
|
|
290
|
-
if (supportsMultipleArgs) {
|
|
291
|
-
processor.parameters?.push(...args.slice(1).map((arg) => ({
|
|
292
|
-
name: arg,
|
|
293
|
-
description: arg,
|
|
294
|
-
type: 'string',
|
|
295
|
-
required: false,
|
|
296
|
-
})));
|
|
297
|
-
}
|
|
298
|
-
processors.push(processor);
|
|
299
|
-
}
|
|
300
|
-
return processors;
|
|
301
|
-
}
|
|
302
|
-
static supportsDynamicArgs(func) {
|
|
303
|
-
const funcStr = func.toString();
|
|
304
|
-
return funcStr.includes('arguments');
|
|
305
|
-
}
|
|
306
|
-
static getFunctionArguments(func) {
|
|
307
|
-
const funcStr = func.toString();
|
|
308
|
-
const args = funcStr.match(/\(([^)]*)\)/);
|
|
309
|
-
if (!args) {
|
|
310
|
-
return [];
|
|
311
|
-
}
|
|
312
|
-
return args[1]
|
|
313
|
-
.split(',')
|
|
314
|
-
.map((arg) => arg.trim())
|
|
315
|
-
.filter((arg) => arg !== '');
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
/**
|
|
320
|
-
* Clears the current line in the terminal, accounting for text that wraps across multiple lines.
|
|
321
|
-
* @param terminal The xterm terminal instance
|
|
322
|
-
* @param contentLength The total visible character count on the line (prompt + text)
|
|
323
|
-
*/
|
|
324
|
-
const clearTerminalLine = (terminal, contentLength) => {
|
|
325
|
-
const lines = Math.max(1, Math.ceil(contentLength / terminal.cols));
|
|
326
|
-
for (let i = 0; i < lines; i++) {
|
|
327
|
-
terminal.write('\x1b[2K');
|
|
328
|
-
if (i < lines - 1) {
|
|
329
|
-
terminal.write('\x1b[A');
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
terminal.write('\r');
|
|
333
|
-
};
|
|
334
|
-
|
|
335
|
-
const getParameterValue = (p, args) => {
|
|
336
|
-
if (args[p.name] !== undefined) {
|
|
337
|
-
return args[p.name];
|
|
338
|
-
}
|
|
339
|
-
const matchedAlias = p.aliases?.find((alias) => args[alias] !== undefined);
|
|
340
|
-
return matchedAlias ? args[matchedAlias] : undefined;
|
|
341
|
-
};
|
|
342
|
-
const formatJson = (json) => {
|
|
343
|
-
const identedJson = JSON.stringify(json, null, 2);
|
|
344
|
-
return colorizeJson(identedJson.split('\n').join('\r\n'));
|
|
345
|
-
};
|
|
346
|
-
const colorizeJson = (jsonString) => {
|
|
347
|
-
return jsonString
|
|
348
|
-
.replace(/"([^"]+)":/g, '\x1b[33m"$1":\x1b[0m') // Keys (yellow)
|
|
349
|
-
.replace(/: "([^"]*)"/g, ': \x1b[32m"$1"\x1b[0m') // Strings (green)
|
|
350
|
-
.replace(/: (\d+)/g, ': \x1b[34m$1\x1b[0m') // Numbers (blue)
|
|
351
|
-
.replace(/: (true|false)/g, ': \x1b[35m$1\x1b[0m') // Booleans (magenta)
|
|
352
|
-
.replace(/: (null)/g, ': \x1b[36m$1\x1b[0m'); // Null (cyan)
|
|
353
|
-
};
|
|
354
|
-
const toQueryString = (params) => {
|
|
355
|
-
const searchParams = new URLSearchParams();
|
|
356
|
-
for (const key in params) {
|
|
357
|
-
if (params.hasOwnProperty(key)) {
|
|
358
|
-
const value = params[key];
|
|
359
|
-
// Handle array and non-primitive values
|
|
360
|
-
if (Array.isArray(value)) {
|
|
361
|
-
value.forEach((v) => searchParams.append(key, v.toString()));
|
|
362
|
-
}
|
|
363
|
-
else if (value !== null && value !== undefined) {
|
|
364
|
-
searchParams.append(key, value.toString());
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
return searchParams.toString();
|
|
369
|
-
};
|
|
370
|
-
const highlightTextWithBg = (text, pattern, bgColor = CliBackgroundColor.Yellow) => {
|
|
371
|
-
// Replace matches with background-colored text
|
|
372
|
-
return text.replace(pattern, (match) => `${bgColor}${match}${CliForegroundColor.Reset}`);
|
|
373
|
-
};
|
|
374
|
-
const getRightOfWord = (command, word) => {
|
|
375
|
-
// Find the position of the word in the command
|
|
376
|
-
const index = command.indexOf(word);
|
|
377
|
-
// If the word is found, extract the substring to the right
|
|
378
|
-
if (index !== -1) {
|
|
379
|
-
return command.slice(index + word.length).trim();
|
|
380
|
-
}
|
|
381
|
-
// If the word is not found, return null
|
|
382
|
-
return undefined;
|
|
383
|
-
};
|
|
384
|
-
const colorFirstWord = (text, colorFunction) => {
|
|
385
|
-
if (!text)
|
|
386
|
-
return text;
|
|
387
|
-
// Match leading spaces and first word separately
|
|
388
|
-
const match = text.match(/^(\s*)(\S+)(.*)$/);
|
|
389
|
-
if (!match)
|
|
390
|
-
return text; // If no match, return original text
|
|
391
|
-
const [, leadingSpaces, firstWord, restOfText] = match;
|
|
392
|
-
// Apply color only to the first word
|
|
393
|
-
const firstWordColored = colorFunction(firstWord);
|
|
394
|
-
// Reconstruct string: Keep spaces, color first word, and append rest
|
|
395
|
-
return `${leadingSpaces}${firstWordColored}${restOfText}`;
|
|
396
|
-
};
|
|
397
|
-
const utils = {
|
|
398
|
-
getParameterValue,
|
|
399
|
-
formatJson,
|
|
400
|
-
colorizeJson,
|
|
401
|
-
toQueryString,
|
|
402
|
-
highlightTextWithBg,
|
|
403
|
-
getRightOfWord,
|
|
404
|
-
colorFirstWord,
|
|
405
|
-
ObjectDescriber,
|
|
406
|
-
delay,
|
|
407
|
-
};
|
|
408
|
-
|
|
409
|
-
const initializeBrowserEnvironment = ({ context, handlers, }) => {
|
|
410
|
-
window.cliCore = {
|
|
411
|
-
onUmdModuleBoot: handlers || [],
|
|
412
|
-
bootUmdModule: async (module) => {
|
|
413
|
-
context.logger.log('Booting UMD module', module.name);
|
|
414
|
-
window[module.name] = module;
|
|
415
|
-
for (const handler of handlers) {
|
|
416
|
-
await handler(module);
|
|
417
|
-
}
|
|
418
|
-
},
|
|
419
|
-
...constants,
|
|
420
|
-
...utils,
|
|
421
|
-
...enums,
|
|
422
|
-
};
|
|
423
|
-
window.ngCore = {
|
|
424
|
-
Injectable: () => { },
|
|
425
|
-
};
|
|
426
|
-
};
|
|
427
|
-
const bootUmdModule = async (module) => {
|
|
428
|
-
if (typeof window !== 'undefined') {
|
|
429
|
-
await window.cliCore.bootUmdModule(module);
|
|
430
|
-
}
|
|
431
|
-
else {
|
|
432
|
-
console.log('window is undefined');
|
|
433
|
-
}
|
|
434
|
-
};
|
|
435
|
-
|
|
436
|
-
class CancellablePromise {
|
|
437
|
-
constructor(executor) {
|
|
438
|
-
this.executor = executor;
|
|
439
|
-
this.hasCancelled = false;
|
|
440
|
-
this.abortController = new AbortController();
|
|
441
|
-
}
|
|
442
|
-
execute() {
|
|
443
|
-
return new Promise((resolve, reject) => {
|
|
444
|
-
this.abortController.signal.onabort = () => {
|
|
445
|
-
reject(new Error('Promise cancelled'));
|
|
446
|
-
};
|
|
447
|
-
this.executor((value) => {
|
|
448
|
-
if (!this.hasCancelled) {
|
|
449
|
-
resolve(value);
|
|
450
|
-
}
|
|
451
|
-
}, (reason) => {
|
|
452
|
-
if (!this.hasCancelled) {
|
|
453
|
-
reject(reason);
|
|
454
|
-
}
|
|
455
|
-
});
|
|
456
|
-
});
|
|
457
|
-
}
|
|
458
|
-
cancel() {
|
|
459
|
-
this.hasCancelled = true;
|
|
460
|
-
this.abortController.abort();
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
const DefaultThemes = {
|
|
465
|
-
default: {
|
|
466
|
-
background: '#0c0c0c',
|
|
467
|
-
foreground: '#cccccc',
|
|
468
|
-
green: '#16c60c',
|
|
469
|
-
blue: '#3b78ff',
|
|
470
|
-
yellow: '#FFA500',
|
|
471
|
-
},
|
|
472
|
-
dracula: {
|
|
473
|
-
background: '#282A36',
|
|
474
|
-
foreground: '#F8F8F2',
|
|
475
|
-
cursor: '#50FA7B',
|
|
476
|
-
black: '#21222C',
|
|
477
|
-
red: '#FF5555',
|
|
478
|
-
green: '#50FA7B',
|
|
479
|
-
yellow: '#F1FA8C',
|
|
480
|
-
blue: '#BD93F9',
|
|
481
|
-
magenta: '#FF79C6',
|
|
482
|
-
cyan: '#8BE9FD',
|
|
483
|
-
white: '#F8F8F2',
|
|
484
|
-
brightBlack: '#6272A4',
|
|
485
|
-
brightRed: '#FF6E6E',
|
|
486
|
-
brightGreen: '#69FF94',
|
|
487
|
-
brightYellow: '#FFFFA5',
|
|
488
|
-
brightBlue: '#D6ACFF',
|
|
489
|
-
brightMagenta: '#FF92D0',
|
|
490
|
-
brightCyan: '#A4FFFF',
|
|
491
|
-
brightWhite: '#FFFFFF',
|
|
492
|
-
},
|
|
493
|
-
monokai: {
|
|
494
|
-
background: '#272822',
|
|
495
|
-
foreground: '#F8F8F2',
|
|
496
|
-
cursor: '#F8F8F0',
|
|
497
|
-
black: '#272822',
|
|
498
|
-
red: '#F92672',
|
|
499
|
-
green: '#A6E22E',
|
|
500
|
-
yellow: '#F4BF75',
|
|
501
|
-
blue: '#66D9EF',
|
|
502
|
-
magenta: '#AE81FF',
|
|
503
|
-
cyan: '#A1EFE4',
|
|
504
|
-
white: '#F8F8F2',
|
|
505
|
-
brightBlack: '#75715E',
|
|
506
|
-
brightRed: '#F92672',
|
|
507
|
-
brightGreen: '#A6E22E',
|
|
508
|
-
brightYellow: '#F4BF75',
|
|
509
|
-
brightBlue: '#66D9EF',
|
|
510
|
-
brightMagenta: '#AE81FF',
|
|
511
|
-
brightCyan: '#A1EFE4',
|
|
512
|
-
brightWhite: '#F9F8F5',
|
|
513
|
-
},
|
|
514
|
-
solarizedDark: {
|
|
515
|
-
background: '#002B36',
|
|
516
|
-
foreground: '#839496',
|
|
517
|
-
cursor: '#93A1A1',
|
|
518
|
-
black: '#073642',
|
|
519
|
-
red: '#DC322F',
|
|
520
|
-
green: '#859900',
|
|
521
|
-
yellow: '#B58900',
|
|
522
|
-
blue: '#268BD2',
|
|
523
|
-
magenta: '#D33682',
|
|
524
|
-
cyan: '#2AA198',
|
|
525
|
-
white: '#EEE8D5',
|
|
526
|
-
brightBlack: '#002B36',
|
|
527
|
-
brightRed: '#CB4B16',
|
|
528
|
-
brightGreen: '#586E75',
|
|
529
|
-
brightYellow: '#657B83',
|
|
530
|
-
brightBlue: '#839496',
|
|
531
|
-
brightMagenta: '#6C71C4',
|
|
532
|
-
brightCyan: '#93A1A1',
|
|
533
|
-
brightWhite: '#FDF6E3',
|
|
534
|
-
},
|
|
535
|
-
solarizedLight: {
|
|
536
|
-
background: '#FDF6E3',
|
|
537
|
-
foreground: '#657B83',
|
|
538
|
-
cursor: '#586E75',
|
|
539
|
-
black: '#073642',
|
|
540
|
-
red: '#DC322F',
|
|
541
|
-
green: '#859900',
|
|
542
|
-
yellow: '#B58900',
|
|
543
|
-
blue: '#268BD2',
|
|
544
|
-
magenta: '#D33682',
|
|
545
|
-
cyan: '#2AA198',
|
|
546
|
-
white: '#EEE8D5',
|
|
547
|
-
brightBlack: '#002B36',
|
|
548
|
-
brightRed: '#CB4B16',
|
|
549
|
-
brightGreen: '#586E75',
|
|
550
|
-
brightYellow: '#657B83',
|
|
551
|
-
brightBlue: '#839496',
|
|
552
|
-
brightMagenta: '#6C71C4',
|
|
553
|
-
brightCyan: '#93A1A1',
|
|
554
|
-
brightWhite: '#FDF6E3',
|
|
555
|
-
},
|
|
556
|
-
gruvboxDark: {
|
|
557
|
-
background: '#282828',
|
|
558
|
-
foreground: '#EBDBB2',
|
|
559
|
-
cursor: '#EBDBB2',
|
|
560
|
-
black: '#282828',
|
|
561
|
-
red: '#CC241D',
|
|
562
|
-
green: '#98971A',
|
|
563
|
-
yellow: '#D79921',
|
|
564
|
-
blue: '#458588',
|
|
565
|
-
magenta: '#B16286',
|
|
566
|
-
cyan: '#689D6A',
|
|
567
|
-
white: '#A89984',
|
|
568
|
-
brightBlack: '#928374',
|
|
569
|
-
brightRed: '#FB4934',
|
|
570
|
-
brightGreen: '#B8BB26',
|
|
571
|
-
brightYellow: '#FABD2F',
|
|
572
|
-
brightBlue: '#83A598',
|
|
573
|
-
brightMagenta: '#D3869B',
|
|
574
|
-
brightCyan: '#8EC07C',
|
|
575
|
-
brightWhite: '#EBDBB2',
|
|
576
|
-
},
|
|
577
|
-
gruvboxLight: {
|
|
578
|
-
background: '#FBF1C7',
|
|
579
|
-
foreground: '#3C3836',
|
|
580
|
-
cursor: '#3C3836',
|
|
581
|
-
black: '#FBF1C7',
|
|
582
|
-
red: '#9D0006',
|
|
583
|
-
green: '#79740E',
|
|
584
|
-
yellow: '#B57614',
|
|
585
|
-
blue: '#076678',
|
|
586
|
-
magenta: '#8F3F71',
|
|
587
|
-
cyan: '#427B58',
|
|
588
|
-
white: '#3C3836',
|
|
589
|
-
brightBlack: '#D5C4A1',
|
|
590
|
-
brightRed: '#AF3A03',
|
|
591
|
-
brightGreen: '#B8BB26',
|
|
592
|
-
brightYellow: '#FABD2F',
|
|
593
|
-
brightBlue: '#83A598',
|
|
594
|
-
brightMagenta: '#D3869B',
|
|
595
|
-
brightCyan: '#8EC07C',
|
|
596
|
-
brightWhite: '#EBDBB2',
|
|
597
|
-
},
|
|
598
|
-
nord: {
|
|
599
|
-
background: '#2E3440',
|
|
600
|
-
foreground: '#D8DEE9',
|
|
601
|
-
cursor: '#88C0D0',
|
|
602
|
-
black: '#3B4252',
|
|
603
|
-
red: '#BF616A',
|
|
604
|
-
green: '#A3BE8C',
|
|
605
|
-
yellow: '#EBCB8B',
|
|
606
|
-
blue: '#81A1C1',
|
|
607
|
-
magenta: '#B48EAD',
|
|
608
|
-
cyan: '#88C0D0',
|
|
609
|
-
white: '#E5E9F0',
|
|
610
|
-
brightBlack: '#4C566A',
|
|
611
|
-
brightRed: '#BF616A',
|
|
612
|
-
brightGreen: '#A3BE8C',
|
|
613
|
-
brightYellow: '#EBCB8B',
|
|
614
|
-
brightBlue: '#81A1C1',
|
|
615
|
-
brightMagenta: '#B48EAD',
|
|
616
|
-
brightCyan: '#8FBCBB',
|
|
617
|
-
brightWhite: '#ECEFF4',
|
|
618
|
-
},
|
|
619
|
-
oneDark: {
|
|
620
|
-
background: '#282C34',
|
|
621
|
-
foreground: '#ABB2BF',
|
|
622
|
-
cursor: '#528BFF',
|
|
623
|
-
black: '#282C34',
|
|
624
|
-
red: '#E06C75',
|
|
625
|
-
green: '#98C379',
|
|
626
|
-
yellow: '#E5C07B',
|
|
627
|
-
blue: '#61AFEF',
|
|
628
|
-
magenta: '#C678DD',
|
|
629
|
-
cyan: '#56B6C2',
|
|
630
|
-
white: '#ABB2BF',
|
|
631
|
-
brightBlack: '#5C6370',
|
|
632
|
-
brightRed: '#E06C75',
|
|
633
|
-
brightGreen: '#98C379',
|
|
634
|
-
brightYellow: '#E5C07B',
|
|
635
|
-
brightBlue: '#61AFEF',
|
|
636
|
-
brightMagenta: '#C678DD',
|
|
637
|
-
brightCyan: '#56B6C2',
|
|
638
|
-
brightWhite: '#FFFFFF',
|
|
639
|
-
},
|
|
640
|
-
material: {
|
|
641
|
-
background: '#263238',
|
|
642
|
-
foreground: '#ECEFF1',
|
|
643
|
-
cursor: '#FFCC00',
|
|
644
|
-
black: '#263238',
|
|
645
|
-
red: '#F07178',
|
|
646
|
-
green: '#C3E88D',
|
|
647
|
-
yellow: '#FFCB6B',
|
|
648
|
-
blue: '#82AAFF',
|
|
649
|
-
magenta: '#C792EA',
|
|
650
|
-
cyan: '#89DDFF',
|
|
651
|
-
white: '#EEFFFF',
|
|
652
|
-
brightBlack: '#546E7A',
|
|
653
|
-
brightRed: '#F07178',
|
|
654
|
-
brightGreen: '#C3E88D',
|
|
655
|
-
brightYellow: '#FFCB6B',
|
|
656
|
-
brightBlue: '#82AAFF',
|
|
657
|
-
brightMagenta: '#C792EA',
|
|
658
|
-
brightCyan: '#89DDFF',
|
|
659
|
-
brightWhite: '#FFFFFF',
|
|
660
|
-
},
|
|
661
|
-
yellow: {
|
|
662
|
-
background: '#FFFACD',
|
|
663
|
-
foreground: '#000000',
|
|
664
|
-
cursor: '#FFA500',
|
|
665
|
-
selectionBackground: '#FFD700',
|
|
666
|
-
black: '#3B3A32',
|
|
667
|
-
red: '#D32F2F',
|
|
668
|
-
green: '#388E3C',
|
|
669
|
-
yellow: '#FBC02D',
|
|
670
|
-
blue: '#1976D2',
|
|
671
|
-
magenta: '#8E24AA',
|
|
672
|
-
cyan: '#0097A7',
|
|
673
|
-
white: '#FFFFFF',
|
|
674
|
-
brightBlack: '#616161',
|
|
675
|
-
brightRed: '#FF5252',
|
|
676
|
-
brightGreen: '#69F0AE',
|
|
677
|
-
brightYellow: '#FFEB3B',
|
|
678
|
-
brightBlue: '#64B5F6',
|
|
679
|
-
brightMagenta: '#BA68C8',
|
|
680
|
-
brightCyan: '#4DD0E1',
|
|
681
|
-
brightWhite: '#FAFAFA', // Very Light Gray
|
|
682
|
-
},
|
|
683
|
-
};
|
|
684
|
-
|
|
685
|
-
// Automatically generated during build
|
|
686
|
-
const LIBRARY_VERSION = '0.0.15';
|
|
687
|
-
|
|
688
|
-
/*
|
|
689
|
-
* Public API Surface of core
|
|
690
|
-
*/
|
|
691
|
-
|
|
692
|
-
/**
|
|
693
|
-
* Generated bundle index. Do not edit.
|
|
694
|
-
*/
|
|
695
|
-
|
|
696
|
-
export { CancellablePromise, CliBackgroundColor, CliForegroundColor, CliIcon, CliLogLevel, DefaultLibraryAuthor, DefaultThemes, LIBRARY_VERSION, ObjectDescriber, bootUmdModule, clearTerminalLine, colorFirstWord, colorizeJson, constants, delay, enums, formatJson, getParameterValue, getRightOfWord, highlightTextWithBg, initializeBrowserEnvironment, toQueryString, utils };
|
|
697
|
-
//# sourceMappingURL=qodalis-cli-core.mjs.map
|