@qodalis/cli-core 0.0.6 → 0.0.8
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 +54 -10
- package/esm2022/lib/interfaces/index.mjs +1 -1
- package/esm2022/lib/models/index.mjs +137 -1
- package/esm2022/lib/modules/index.mjs +3 -4
- package/esm2022/lib/types/CancellablePromise.mjs +26 -0
- package/esm2022/lib/types/index.mjs +2 -0
- package/esm2022/lib/utils/index.mjs +4 -1
- package/esm2022/lib/utils/object-describer.mjs +134 -0
- package/esm2022/public-api.mjs +2 -1
- package/fesm2022/qodalis-cli-core.mjs +298 -3
- package/fesm2022/qodalis-cli-core.mjs.map +1 -1
- package/lib/interfaces/index.d.ts +78 -9
- package/lib/models/index.d.ts +170 -5
- package/lib/types/CancellablePromise.d.ts +8 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/utils/index.d.ts +3 -0
- package/lib/utils/object-describer.d.ts +12 -0
- package/package.json +2 -2
- package/public-api.d.ts +1 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Terminal } from '@xterm/xterm';
|
|
2
2
|
import { Observable, Subject } from 'rxjs';
|
|
3
|
-
import { CliBackgroundColor, CliForegroundColor, CliOptions, CliProcessCommand, ICliUser, ICliUserSession } from '../models';
|
|
3
|
+
import { CliBackgroundColor, CliForegroundColor, CliOptions, CliProcessCommand, CliProcessorMetadata, ICliUser, ICliUserSession } from '../models';
|
|
4
4
|
export interface ICliCommandAuthor {
|
|
5
5
|
/**
|
|
6
6
|
* The name of the author
|
|
@@ -41,9 +41,9 @@ export interface ICliCommandProcessor {
|
|
|
41
41
|
*/
|
|
42
42
|
version?: string;
|
|
43
43
|
/**
|
|
44
|
-
*
|
|
44
|
+
* The metadata for the command processor
|
|
45
45
|
*/
|
|
46
|
-
|
|
46
|
+
metadata?: CliProcessorMetadata;
|
|
47
47
|
/**
|
|
48
48
|
* Processors that are nested under this processor
|
|
49
49
|
*/
|
|
@@ -189,7 +189,7 @@ export interface ICliTerminalWriter {
|
|
|
189
189
|
* @param objects The objects to write to the table
|
|
190
190
|
* @returns void
|
|
191
191
|
*/
|
|
192
|
-
|
|
192
|
+
writeObjectsAsTable(objects: any[]): void;
|
|
193
193
|
/**
|
|
194
194
|
* Write a table to the terminal
|
|
195
195
|
* @param headers The headers of the table
|
|
@@ -216,7 +216,19 @@ export interface ICliProgressBar {
|
|
|
216
216
|
* Represents a spinner for the CLI
|
|
217
217
|
*/
|
|
218
218
|
export interface ICliSpinner extends ICliProgressBar {
|
|
219
|
+
/**
|
|
220
|
+
* Set the text of the spinner
|
|
221
|
+
* @param text The text to set
|
|
222
|
+
*/
|
|
223
|
+
setText: (text: string) => void;
|
|
219
224
|
}
|
|
225
|
+
export type CliPercentageProgressBarUpdateValueOptions = {
|
|
226
|
+
/**
|
|
227
|
+
* The type of update to perform
|
|
228
|
+
* @default 'replace'
|
|
229
|
+
*/
|
|
230
|
+
type?: 'replace' | 'increment';
|
|
231
|
+
};
|
|
220
232
|
/**
|
|
221
233
|
* Represents a progress bar for the CLI
|
|
222
234
|
*/
|
|
@@ -226,12 +238,17 @@ export interface ICliPercentageProgressBar extends ICliProgressBar {
|
|
|
226
238
|
* @param progress The progress to update to
|
|
227
239
|
* @returns void
|
|
228
240
|
*/
|
|
229
|
-
update: (progress: number) => void;
|
|
241
|
+
update: (progress: number, options?: CliPercentageProgressBarUpdateValueOptions) => void;
|
|
230
242
|
/**
|
|
231
243
|
* Complete the progress bar
|
|
232
244
|
* @returns void
|
|
233
245
|
*/
|
|
234
246
|
complete: () => void;
|
|
247
|
+
/**
|
|
248
|
+
* Set the text of the spinner
|
|
249
|
+
* @param text The text to set
|
|
250
|
+
*/
|
|
251
|
+
setText: (text: string) => void;
|
|
235
252
|
}
|
|
236
253
|
/**
|
|
237
254
|
* Represents a clipboard for the CLI
|
|
@@ -281,6 +298,45 @@ export interface ICliCommandExecutorService {
|
|
|
281
298
|
*/
|
|
282
299
|
unregisterProcessor(processor: ICliCommandProcessor): void;
|
|
283
300
|
}
|
|
301
|
+
export interface ICliExecutionProcess {
|
|
302
|
+
/**
|
|
303
|
+
* Indicates if the process has exited
|
|
304
|
+
*/
|
|
305
|
+
exited?: boolean;
|
|
306
|
+
/**
|
|
307
|
+
* The exit code of the process
|
|
308
|
+
*/
|
|
309
|
+
exitCode?: number;
|
|
310
|
+
/**
|
|
311
|
+
* Indicates if the process is running
|
|
312
|
+
*/
|
|
313
|
+
running: boolean;
|
|
314
|
+
/**
|
|
315
|
+
* The data of the process
|
|
316
|
+
*/
|
|
317
|
+
data: string | undefined;
|
|
318
|
+
/**
|
|
319
|
+
* Exit the process
|
|
320
|
+
* @param code The exit code
|
|
321
|
+
* @returns void
|
|
322
|
+
*/
|
|
323
|
+
exit: (code?: number) => void;
|
|
324
|
+
/**
|
|
325
|
+
* Output data from the process
|
|
326
|
+
* @param data The data to output
|
|
327
|
+
*/
|
|
328
|
+
output(data: string): void;
|
|
329
|
+
/**
|
|
330
|
+
* Start the process
|
|
331
|
+
* @returns void
|
|
332
|
+
*/
|
|
333
|
+
start: () => void;
|
|
334
|
+
/**
|
|
335
|
+
* End the process
|
|
336
|
+
* @returns void
|
|
337
|
+
*/
|
|
338
|
+
end: () => void;
|
|
339
|
+
}
|
|
284
340
|
/**
|
|
285
341
|
* Represents the context in which a command is executed
|
|
286
342
|
*/
|
|
@@ -329,6 +385,15 @@ export interface ICliExecutionContext {
|
|
|
329
385
|
* The prompt to use for prompting the user for input
|
|
330
386
|
*/
|
|
331
387
|
showPrompt: () => void;
|
|
388
|
+
/**
|
|
389
|
+
* Set the current main processor
|
|
390
|
+
* @param processor The processor to set
|
|
391
|
+
*/
|
|
392
|
+
setMainProcessor(processor: ICliCommandProcessor): void;
|
|
393
|
+
/**
|
|
394
|
+
* The process to use for exiting the CLI
|
|
395
|
+
*/
|
|
396
|
+
process: ICliExecutionProcess;
|
|
332
397
|
}
|
|
333
398
|
/**
|
|
334
399
|
* Represents a data store for storing data associated with commands
|
|
@@ -375,12 +440,16 @@ export interface ICliUsersStoreService {
|
|
|
375
440
|
* Gets the current users
|
|
376
441
|
* @returns An observable that emits the current users
|
|
377
442
|
*/
|
|
378
|
-
getUsers(
|
|
443
|
+
getUsers(options?: {
|
|
444
|
+
query?: string;
|
|
445
|
+
skip?: number;
|
|
446
|
+
take?: number;
|
|
447
|
+
}): Observable<ICliUser[]>;
|
|
379
448
|
/**
|
|
380
|
-
*
|
|
381
|
-
* @param
|
|
449
|
+
* Creates a user
|
|
450
|
+
* @param user The user to create
|
|
382
451
|
*/
|
|
383
|
-
|
|
452
|
+
createUser(user: Omit<ICliUser, 'id'>): Promise<ICliUser>;
|
|
384
453
|
/**
|
|
385
454
|
* Gets a user by id
|
|
386
455
|
* @param id The id of the user to get
|
package/lib/models/index.d.ts
CHANGED
|
@@ -4,6 +4,10 @@ export type CliProcessCommand = {
|
|
|
4
4
|
* The command that was entered
|
|
5
5
|
*/
|
|
6
6
|
command: string;
|
|
7
|
+
/**
|
|
8
|
+
* The data that was entered
|
|
9
|
+
*/
|
|
10
|
+
data?: string;
|
|
7
11
|
/**
|
|
8
12
|
* The chain of commands that were entered
|
|
9
13
|
*/
|
|
@@ -42,7 +46,123 @@ export declare enum CliBackgroundColor {
|
|
|
42
46
|
Cyan = "\u001B[46m",
|
|
43
47
|
White = "\u001B[47m"
|
|
44
48
|
}
|
|
45
|
-
export
|
|
49
|
+
export declare enum CliIcon {
|
|
50
|
+
CheckIcon = "\u2714",
|
|
51
|
+
CrossIcon = "\u2718",
|
|
52
|
+
InfoIcon = "\u2139",
|
|
53
|
+
WarningIcon = "\u26A0",
|
|
54
|
+
QuestionMark = "?",
|
|
55
|
+
Exclamation = "\u2757",
|
|
56
|
+
Ellipsis = "\u2026",
|
|
57
|
+
Dot = "\u2022",
|
|
58
|
+
Bullet = "\u2023",
|
|
59
|
+
ArrowRight = "\u2192",
|
|
60
|
+
ArrowLeft = "\u2190",
|
|
61
|
+
ArrowUp = "\u2191",
|
|
62
|
+
ArrowDown = "\u2193",
|
|
63
|
+
ArrowRightFilled = "\u25B6",
|
|
64
|
+
ArrowLeftFilled = "\u25C0",
|
|
65
|
+
ArrowUpFilled = "\u25B2",
|
|
66
|
+
ArrowDownFilled = "\u25BC",
|
|
67
|
+
DoubleArrowRight = "\u00BB",
|
|
68
|
+
DoubleArrowLeft = "\u00AB",
|
|
69
|
+
Star = "\u2605",
|
|
70
|
+
StarEmpty = "\u2606",
|
|
71
|
+
Plus = "+",
|
|
72
|
+
Minus = "-",
|
|
73
|
+
Progress = "\u23F3",
|
|
74
|
+
Success = "\u2705",
|
|
75
|
+
Failure = "\u274C",
|
|
76
|
+
Clock = "\u23F0",
|
|
77
|
+
Timer = "\u23F1",
|
|
78
|
+
Alarm = "\uD83D\uDD14",
|
|
79
|
+
Calendar = "\uD83D\uDCC5",
|
|
80
|
+
Folder = "\uD83D\uDCC1",
|
|
81
|
+
FolderOpen = "\uD83D\uDCC2",
|
|
82
|
+
File = "\uD83D\uDCC4",
|
|
83
|
+
Archive = "\uD83D\uDDC3",
|
|
84
|
+
Link = "\uD83D\uDD17",
|
|
85
|
+
Chain = "\u26D3",
|
|
86
|
+
Bookmark = "\uD83D\uDD16",
|
|
87
|
+
Edit = "\u270F",
|
|
88
|
+
Trash = "\uD83D\uDDD1",
|
|
89
|
+
Add = "\u2795",
|
|
90
|
+
Remove = "\u2796",
|
|
91
|
+
Reload = "\uD83D\uDD04",
|
|
92
|
+
Save = "\uD83D\uDCBE",
|
|
93
|
+
Undo = "\u21A9",
|
|
94
|
+
Redo = "\u21AA",
|
|
95
|
+
Play = "\u25B6",
|
|
96
|
+
Pause = "\u23F8",
|
|
97
|
+
Stop = "\u23F9",
|
|
98
|
+
Cancel = "\u274E",
|
|
99
|
+
User = "\uD83D\uDC64",
|
|
100
|
+
Group = "\uD83D\uDC65",
|
|
101
|
+
Lock = "\uD83D\uDD12",
|
|
102
|
+
Unlock = "\uD83D\uDD13",
|
|
103
|
+
Help = "\u2753",
|
|
104
|
+
Key = "\uD83D\uDD11",
|
|
105
|
+
Shield = "\uD83D\uDEE1",
|
|
106
|
+
Gear = "\u2699",
|
|
107
|
+
Settings = "\u2699\uFE0F",
|
|
108
|
+
Theme = "\uD83C\uDFA8",
|
|
109
|
+
Light = "\uD83D\uDCA1",
|
|
110
|
+
Bug = "\uD83D\uDC1E",
|
|
111
|
+
Wrench = "\uD83D\uDD27",
|
|
112
|
+
Hammer = "\uD83D\uDD28",
|
|
113
|
+
Terminal = "\uD83D\uDCBB",
|
|
114
|
+
Database = "\uD83D\uDDC4",
|
|
115
|
+
Server = "\uD83D\uDDA5",
|
|
116
|
+
Cloud = "\u2601",
|
|
117
|
+
Network = "\uD83C\uDF10",
|
|
118
|
+
Monitor = "\uD83D\uDDA5",
|
|
119
|
+
Printer = "\uD83D\uDDA8",
|
|
120
|
+
USB = "\uD83D\uDD0C",
|
|
121
|
+
Speaker = "\uD83D\uDD0A",
|
|
122
|
+
Microphone = "\uD83C\uDF99",
|
|
123
|
+
Camera = "\uD83D\uDCF7",
|
|
124
|
+
Video = "\uD83C\uDFA5",
|
|
125
|
+
Music = "\uD83C\uDFB5",
|
|
126
|
+
Phone = "\uD83D\uDCDE",
|
|
127
|
+
Package = "\uD83D\uDCE6",
|
|
128
|
+
Plugin = "\uD83D\uDD0C",
|
|
129
|
+
Extension = "\uD83E\uDDE9",
|
|
130
|
+
Module = "\uD83D\uDCE6",
|
|
131
|
+
Evaluate = "\uD83D\uDD0D",
|
|
132
|
+
Variable = "\uD83D\uDD27",
|
|
133
|
+
Script = "\uD83D\uDCDC",
|
|
134
|
+
Code = "\uD83D\uDCBE",
|
|
135
|
+
Logs = "\uD83D\uDCDC",
|
|
136
|
+
Power = "\u23FB",
|
|
137
|
+
Heart = "\u2764",
|
|
138
|
+
Flame = "\uD83D\uDD25",
|
|
139
|
+
Growth = "\uD83D\uDCC8",
|
|
140
|
+
Decline = "\uD83D\uDCC9",
|
|
141
|
+
WarningFilled = "\u26A0\uFE0F",
|
|
142
|
+
Sun = "\u2600",
|
|
143
|
+
Moon = "\uD83C\uDF19",
|
|
144
|
+
Rain = "\uD83C\uDF27",
|
|
145
|
+
Snow = "\u2744",
|
|
146
|
+
Lightning = "\u26A1",
|
|
147
|
+
Tree = "\uD83C\uDF32",
|
|
148
|
+
Smile = "\uD83D\uDE0A",
|
|
149
|
+
Sad = "\uD83D\uDE22",
|
|
150
|
+
Angry = "\uD83D\uDE21",
|
|
151
|
+
Clap = "\uD83D\uDC4F",
|
|
152
|
+
ThumbsUp = "\uD83D\uDC4D",
|
|
153
|
+
ThumbsDown = "\uD83D\uDC4E",
|
|
154
|
+
Rocket = "\uD83D\uDE80",
|
|
155
|
+
Globe = "\uD83C\uDF0D",
|
|
156
|
+
Medal = "\uD83C\uDFC5",
|
|
157
|
+
Trophy = "\uD83C\uDFC6",
|
|
158
|
+
Flag = "\uD83D\uDEA9",
|
|
159
|
+
StarFilled = "\u2B50",
|
|
160
|
+
StarOutline = "\u2729",
|
|
161
|
+
Fireworks = "\uD83C\uDF86",
|
|
162
|
+
Balloon = "\uD83C\uDF88",
|
|
163
|
+
Gift = "\uD83C\uDF81"
|
|
164
|
+
}
|
|
165
|
+
export type ICliUser = {
|
|
46
166
|
/**
|
|
47
167
|
* The id of the user
|
|
48
168
|
*/
|
|
@@ -55,7 +175,12 @@ export interface ICliUser extends Record<string, any> {
|
|
|
55
175
|
* The email of the user
|
|
56
176
|
*/
|
|
57
177
|
email: string;
|
|
58
|
-
|
|
178
|
+
/**
|
|
179
|
+
* The groups the user belongs to
|
|
180
|
+
* @default []
|
|
181
|
+
*/
|
|
182
|
+
groups?: string[];
|
|
183
|
+
};
|
|
59
184
|
export interface ICliUserSession {
|
|
60
185
|
/**
|
|
61
186
|
* The user associated with the session
|
|
@@ -69,15 +194,29 @@ export interface ICliUserSession {
|
|
|
69
194
|
/**
|
|
70
195
|
* Options for the CLI
|
|
71
196
|
*/
|
|
72
|
-
export type CliOptions = {
|
|
197
|
+
export type CliOptions = Record<string, any> & {
|
|
73
198
|
/**
|
|
74
199
|
* The welcome message to display when the CLI starts
|
|
75
200
|
*/
|
|
76
201
|
welcomeMessage?: string;
|
|
77
202
|
/**
|
|
78
|
-
*
|
|
203
|
+
* If true, the welcome message is hidden
|
|
204
|
+
* @default false
|
|
205
|
+
*/
|
|
206
|
+
hideWelcomeMessage?: boolean;
|
|
207
|
+
/**
|
|
208
|
+
* Users module options
|
|
79
209
|
*/
|
|
80
|
-
|
|
210
|
+
usersModule?: {
|
|
211
|
+
/**
|
|
212
|
+
* If true, the users module is enabled
|
|
213
|
+
*/
|
|
214
|
+
enabled: boolean;
|
|
215
|
+
/**
|
|
216
|
+
* Hide the prompt to display when the CLI is ready to accept input
|
|
217
|
+
*/
|
|
218
|
+
hideUserName?: boolean;
|
|
219
|
+
};
|
|
81
220
|
/**
|
|
82
221
|
* Custom terminal options
|
|
83
222
|
*/
|
|
@@ -108,3 +247,29 @@ export interface Package {
|
|
|
108
247
|
*/
|
|
109
248
|
dependencies?: Package[];
|
|
110
249
|
}
|
|
250
|
+
/**
|
|
251
|
+
* Represents command processor metadata
|
|
252
|
+
*/
|
|
253
|
+
export type CliProcessorMetadata = Record<string, any> & {
|
|
254
|
+
/**
|
|
255
|
+
* If true, the processor is sealed and cannot be extended
|
|
256
|
+
*/
|
|
257
|
+
sealed?: boolean;
|
|
258
|
+
/**
|
|
259
|
+
* If true, the processor requires the server to be running
|
|
260
|
+
*/
|
|
261
|
+
requireServer?: boolean;
|
|
262
|
+
/**
|
|
263
|
+
* The module the processor belongs to
|
|
264
|
+
*/
|
|
265
|
+
module?: string;
|
|
266
|
+
/**
|
|
267
|
+
* An icon to display for the processor
|
|
268
|
+
*/
|
|
269
|
+
icon?: CliIcon | string;
|
|
270
|
+
};
|
|
271
|
+
export declare const enums: {
|
|
272
|
+
CliForegroundColor: typeof CliForegroundColor;
|
|
273
|
+
CliBackgroundColor: typeof CliBackgroundColor;
|
|
274
|
+
CliIcon: typeof CliIcon;
|
|
275
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './CancellablePromise';
|
package/lib/utils/index.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { ICliCommandParameterDescriptor } from '../interfaces';
|
|
2
2
|
import { CliBackgroundColor } from '../models';
|
|
3
|
+
import { ObjectDescriber } from './object-describer';
|
|
3
4
|
export declare const getParameterValue: (p: ICliCommandParameterDescriptor, args: Record<string, any>) => any | undefined;
|
|
4
5
|
export declare const formatJson: (json: any) => string;
|
|
5
6
|
export declare const colorizeJson: (jsonString: any) => string;
|
|
6
7
|
export declare const toQueryString: (params: Record<string, any>) => string;
|
|
7
8
|
export declare const highlightTextWithBg: (text: string, pattern: RegExp, bgColor?: CliBackgroundColor) => string;
|
|
8
9
|
export declare const getRightOfWord: (command: string, word: string) => string | undefined;
|
|
10
|
+
export * from './object-describer';
|
|
9
11
|
export declare const utils: {
|
|
10
12
|
getParameterValue: (p: ICliCommandParameterDescriptor, args: Record<string, any>) => any | undefined;
|
|
11
13
|
formatJson: (json: any) => string;
|
|
@@ -13,4 +15,5 @@ export declare const utils: {
|
|
|
13
15
|
toQueryString: (params: Record<string, any>) => string;
|
|
14
16
|
highlightTextWithBg: (text: string, pattern: RegExp, bgColor?: CliBackgroundColor) => string;
|
|
15
17
|
getRightOfWord: (command: string, word: string) => string | undefined;
|
|
18
|
+
ObjectDescriber: typeof ObjectDescriber;
|
|
16
19
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ICliCommandProcessor } from '../interfaces';
|
|
2
|
+
export declare class ObjectDescriber {
|
|
3
|
+
static describe(obj: any, options?: {
|
|
4
|
+
filter?: (o: {
|
|
5
|
+
funcName: string;
|
|
6
|
+
func: any;
|
|
7
|
+
args: string[];
|
|
8
|
+
}) => boolean;
|
|
9
|
+
}): ICliCommandProcessor[];
|
|
10
|
+
static supportsDynamicArgs(func: any): boolean;
|
|
11
|
+
static getFunctionArguments(func: any): string[];
|
|
12
|
+
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qodalis/cli-core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "Core Angular CLI for @qodalis extensions.",
|
|
5
5
|
"author": "Nicolae Lupei, Qodalis Solutions",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "https://github.com/qodalis-solutions/
|
|
9
|
+
"url": "https://github.com/qodalis-solutions/angular-web-cli"
|
|
10
10
|
},
|
|
11
11
|
"homepage": "https://qodalis.com",
|
|
12
12
|
"keywords": [
|
package/public-api.d.ts
CHANGED