@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,349 +0,0 @@
|
|
|
1
|
-
import { Observable, Subscription } from 'rxjs';
|
|
2
|
-
import { CliBackgroundColor, CliForegroundColor, CliLogLevel, CliProcessCommand, CliProvider, CliState } from '../models';
|
|
3
|
-
import { ICliExecutionContext } from './execution-context';
|
|
4
|
-
import { ICliCommandChildProcessor, ICliCommandProcessor } from './command-processor';
|
|
5
|
-
export interface ICliTerminalWriter {
|
|
6
|
-
/**
|
|
7
|
-
* Write text to the terminal
|
|
8
|
-
* @param text The text to write
|
|
9
|
-
*/
|
|
10
|
-
write(text: string): void;
|
|
11
|
-
/**
|
|
12
|
-
* Write text to the terminal followed by a newline
|
|
13
|
-
* @param text The text to write
|
|
14
|
-
*/
|
|
15
|
-
writeln(text?: string): void;
|
|
16
|
-
/**
|
|
17
|
-
* Write a success message to the terminal
|
|
18
|
-
* @param messag The message to write
|
|
19
|
-
* @returns void
|
|
20
|
-
*/
|
|
21
|
-
writeSuccess: (message: string) => void;
|
|
22
|
-
/**
|
|
23
|
-
* Write an info message to the terminal
|
|
24
|
-
* @param messag The message to write
|
|
25
|
-
* @returns void
|
|
26
|
-
*/
|
|
27
|
-
writeInfo: (message: string) => void;
|
|
28
|
-
/**
|
|
29
|
-
* Write an error message to the terminal
|
|
30
|
-
* @param message The message to write
|
|
31
|
-
* @returns void
|
|
32
|
-
*/
|
|
33
|
-
writeError: (message: string) => void;
|
|
34
|
-
/**
|
|
35
|
-
* Write a warning message to the terminal
|
|
36
|
-
* @param message The message to write
|
|
37
|
-
* @returns void
|
|
38
|
-
*/
|
|
39
|
-
writeWarning: (message: string) => void;
|
|
40
|
-
/**
|
|
41
|
-
* Write a message to the terminal with the specified color
|
|
42
|
-
* @param message The message to write
|
|
43
|
-
* @param color The color to use
|
|
44
|
-
* @returns void
|
|
45
|
-
*/
|
|
46
|
-
wrapInColor: (text: string, color: CliForegroundColor) => string;
|
|
47
|
-
/**
|
|
48
|
-
* Write a message to the terminal with the specified background color
|
|
49
|
-
* @param message The message to write
|
|
50
|
-
* @param color The background color to use
|
|
51
|
-
* @returns void
|
|
52
|
-
*/
|
|
53
|
-
wrapInBackgroundColor: (text: string, color: CliBackgroundColor) => string;
|
|
54
|
-
/**
|
|
55
|
-
* Write a JSON object to the terminal
|
|
56
|
-
* @param json The JSON object to write
|
|
57
|
-
* @returns void
|
|
58
|
-
*/
|
|
59
|
-
writeJson: (json: any) => void;
|
|
60
|
-
/**
|
|
61
|
-
* Write content to a file
|
|
62
|
-
* @param fileName The name of the file to write to
|
|
63
|
-
* @param content The content to write to the file
|
|
64
|
-
* @returns void
|
|
65
|
-
*/
|
|
66
|
-
writeToFile: (fileName: string, content: string) => void;
|
|
67
|
-
/**
|
|
68
|
-
* Write an object array as a table to the terminal
|
|
69
|
-
* @param objects The objects to write to the table
|
|
70
|
-
* @returns void
|
|
71
|
-
*/
|
|
72
|
-
writeObjectsAsTable(objects: any[]): void;
|
|
73
|
-
/**
|
|
74
|
-
* Write a table to the terminal
|
|
75
|
-
* @param headers The headers of the table
|
|
76
|
-
* @param rows The rows of the table
|
|
77
|
-
* @returns void
|
|
78
|
-
*/
|
|
79
|
-
writeTable(headers: string[], rows: string[][]): void;
|
|
80
|
-
/**
|
|
81
|
-
* Write a divider to the terminal
|
|
82
|
-
* @param options The options for the divider
|
|
83
|
-
* @returns void
|
|
84
|
-
*/
|
|
85
|
-
writeDivider(options?: {
|
|
86
|
-
color?: CliForegroundColor;
|
|
87
|
-
length?: number;
|
|
88
|
-
char?: string;
|
|
89
|
-
}): void;
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Represents a clipboard for the CLI
|
|
93
|
-
*/
|
|
94
|
-
export interface ICliClipboard {
|
|
95
|
-
/**
|
|
96
|
-
* Write text to the clipboard
|
|
97
|
-
* @param text The text to write to the clipboard
|
|
98
|
-
* @returns void
|
|
99
|
-
*/
|
|
100
|
-
write: (text: string) => Promise<void>;
|
|
101
|
-
/**
|
|
102
|
-
* Read text from the clipboard
|
|
103
|
-
* @returns The text read from the clipboard
|
|
104
|
-
*/
|
|
105
|
-
read: () => Promise<string>;
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Represents a service that executes commands
|
|
109
|
-
*/
|
|
110
|
-
export interface ICliCommandExecutorService {
|
|
111
|
-
/**
|
|
112
|
-
*
|
|
113
|
-
* @param command
|
|
114
|
-
* @param context
|
|
115
|
-
*/
|
|
116
|
-
showHelp(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
117
|
-
/**
|
|
118
|
-
* Execute a command
|
|
119
|
-
* @param command The command to execute
|
|
120
|
-
* @param context The context in which the command is executed
|
|
121
|
-
*/
|
|
122
|
-
executeCommand(command: string, context: ICliExecutionContext): Promise<void>;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Represents a registry for command processors
|
|
126
|
-
*/
|
|
127
|
-
export interface ICliCommandProcessorRegistry {
|
|
128
|
-
/**
|
|
129
|
-
* The processors registered with the registry
|
|
130
|
-
*/
|
|
131
|
-
readonly processors: ICliCommandProcessor[];
|
|
132
|
-
/**
|
|
133
|
-
* Find a processor for a command
|
|
134
|
-
* @param mainCommand
|
|
135
|
-
* @param chainCommands
|
|
136
|
-
*/
|
|
137
|
-
findProcessor(mainCommand: string, chainCommands: string[]): ICliCommandProcessor | undefined;
|
|
138
|
-
/**
|
|
139
|
-
* Recursively searches for a processor matching the given command.
|
|
140
|
-
* @param mainCommand The main command name.
|
|
141
|
-
* @param chainCommands The remaining chain commands (if any).
|
|
142
|
-
* @param processors The list of available processors.
|
|
143
|
-
* @returns The matching processor or undefined if not found.
|
|
144
|
-
*/
|
|
145
|
-
findProcessorInCollection(mainCommand: string, chainCommands: string[], processors: ICliCommandProcessor[]): ICliCommandProcessor | undefined;
|
|
146
|
-
/**
|
|
147
|
-
* Get the root processor for a child processor
|
|
148
|
-
* @param child The child processor
|
|
149
|
-
*/
|
|
150
|
-
getRootProcessor(child: ICliCommandChildProcessor): ICliCommandProcessor;
|
|
151
|
-
/**
|
|
152
|
-
* Register a processor
|
|
153
|
-
* @param processor
|
|
154
|
-
*/
|
|
155
|
-
registerProcessor(processor: ICliCommandProcessor): void;
|
|
156
|
-
/**
|
|
157
|
-
* Unregister a processor
|
|
158
|
-
* @param processor
|
|
159
|
-
*/
|
|
160
|
-
unregisterProcessor(processor: ICliCommandProcessor): void;
|
|
161
|
-
}
|
|
162
|
-
export interface ICliExecutionProcess {
|
|
163
|
-
/**
|
|
164
|
-
* Indicates if the process has exited
|
|
165
|
-
*/
|
|
166
|
-
exited?: boolean;
|
|
167
|
-
/**
|
|
168
|
-
* The exit code of the process
|
|
169
|
-
*/
|
|
170
|
-
exitCode?: number;
|
|
171
|
-
/**
|
|
172
|
-
* Indicates if the process is running
|
|
173
|
-
*/
|
|
174
|
-
running: boolean;
|
|
175
|
-
/**
|
|
176
|
-
* The data of the process
|
|
177
|
-
*/
|
|
178
|
-
data: any | undefined;
|
|
179
|
-
/**
|
|
180
|
-
* Exit the process
|
|
181
|
-
* @param code The exit code
|
|
182
|
-
* @returns void
|
|
183
|
-
*/
|
|
184
|
-
exit: (
|
|
185
|
-
/**
|
|
186
|
-
* The exit code
|
|
187
|
-
*/
|
|
188
|
-
code?: number,
|
|
189
|
-
/**
|
|
190
|
-
* Options for exiting the process
|
|
191
|
-
*/
|
|
192
|
-
options?: {
|
|
193
|
-
/**
|
|
194
|
-
* Indicates if the exit should be silent, i.e. not throw an error
|
|
195
|
-
*/
|
|
196
|
-
silent?: boolean;
|
|
197
|
-
}) => void;
|
|
198
|
-
/**
|
|
199
|
-
* Output data from the process
|
|
200
|
-
* @param data The data to output
|
|
201
|
-
*/
|
|
202
|
-
output(data: any): void;
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Represents a key-value store for the CLI
|
|
206
|
-
*/
|
|
207
|
-
export interface ICliKeyValueStore {
|
|
208
|
-
/**
|
|
209
|
-
* Retrieves a value by key.
|
|
210
|
-
* @param key - The key to retrieve the value for.
|
|
211
|
-
* @returns A promise resolving to the value or undefined if not found.
|
|
212
|
-
*/
|
|
213
|
-
get<T = any>(key: string): Promise<T | undefined>;
|
|
214
|
-
/**
|
|
215
|
-
* Sets a key-value pair in the store.
|
|
216
|
-
* @param key - The key to set.
|
|
217
|
-
* @param value - The value to store.
|
|
218
|
-
* @returns A promise resolving when the value is stored.
|
|
219
|
-
*/
|
|
220
|
-
set(key: string, value: any): Promise<void>;
|
|
221
|
-
/**
|
|
222
|
-
* Removes a key-value pair by key.
|
|
223
|
-
* @param key - The key to remove.
|
|
224
|
-
* @returns A promise resolving when the key is removed.
|
|
225
|
-
*/
|
|
226
|
-
remove(key: string): Promise<void>;
|
|
227
|
-
/**
|
|
228
|
-
* Clears all key-value pairs from the store.
|
|
229
|
-
* @returns A promise resolving when the store is cleared.
|
|
230
|
-
*/
|
|
231
|
-
clear(): Promise<void>;
|
|
232
|
-
}
|
|
233
|
-
/**
|
|
234
|
-
* Represents a store for storing data associated with commands
|
|
235
|
-
*/
|
|
236
|
-
export interface ICliStateStore {
|
|
237
|
-
/**
|
|
238
|
-
* Get the current state as an object.
|
|
239
|
-
*/
|
|
240
|
-
getState<T extends CliState = CliState>(): T;
|
|
241
|
-
/**
|
|
242
|
-
* Update the state with new values. Supports partial updates.
|
|
243
|
-
* @param newState Partial state to merge with the current state.
|
|
244
|
-
*/
|
|
245
|
-
updateState(newState: Partial<CliState>): void;
|
|
246
|
-
/**
|
|
247
|
-
* Select a specific property or computed value from the state.
|
|
248
|
-
* @param selector A function to project a slice of the state.
|
|
249
|
-
* @returns Observable of the selected value.
|
|
250
|
-
*/
|
|
251
|
-
select<K>(selector: (state: CliState) => K): Observable<K>;
|
|
252
|
-
/**
|
|
253
|
-
* Subscribe to state changes.
|
|
254
|
-
* @param callback Callback function to handle state changes.
|
|
255
|
-
* @returns Subscription object to manage the subscription.
|
|
256
|
-
*/
|
|
257
|
-
subscribe(callback: (state: CliState) => void): Subscription;
|
|
258
|
-
/**
|
|
259
|
-
* Reset the state to its initial value.
|
|
260
|
-
*/
|
|
261
|
-
reset(): void;
|
|
262
|
-
/**
|
|
263
|
-
* Persist the state to storage.
|
|
264
|
-
*/
|
|
265
|
-
persist(): Promise<void>;
|
|
266
|
-
/**
|
|
267
|
-
* Initialize the state from storage.
|
|
268
|
-
*/
|
|
269
|
-
initialize(): Promise<void>;
|
|
270
|
-
}
|
|
271
|
-
/**
|
|
272
|
-
* Represents a service that pings the server
|
|
273
|
-
*/
|
|
274
|
-
export interface ICliPingServerService {
|
|
275
|
-
/**
|
|
276
|
-
* Pings the server
|
|
277
|
-
*/
|
|
278
|
-
ping(): Promise<void>;
|
|
279
|
-
}
|
|
280
|
-
/**
|
|
281
|
-
* Represents a module for the CLI
|
|
282
|
-
*/
|
|
283
|
-
export interface ICliUmdModule {
|
|
284
|
-
/**
|
|
285
|
-
* The name of the module
|
|
286
|
-
*/
|
|
287
|
-
name: string;
|
|
288
|
-
/**
|
|
289
|
-
* The processors for the module
|
|
290
|
-
*/
|
|
291
|
-
processors: ICliCommandProcessor[];
|
|
292
|
-
}
|
|
293
|
-
/**
|
|
294
|
-
* Represents a logger for the CLI
|
|
295
|
-
*/
|
|
296
|
-
export interface ICliLogger {
|
|
297
|
-
/**
|
|
298
|
-
* Set the log level of the logger
|
|
299
|
-
* @param level The log level to set
|
|
300
|
-
* @returns void
|
|
301
|
-
* @default CliLogLevel.ERROR
|
|
302
|
-
*/
|
|
303
|
-
setCliLogLevel(level: CliLogLevel): void;
|
|
304
|
-
/**
|
|
305
|
-
* Log a message
|
|
306
|
-
* @param args The arguments to log
|
|
307
|
-
*/
|
|
308
|
-
log(...args: any[]): void;
|
|
309
|
-
/**
|
|
310
|
-
* Log a message
|
|
311
|
-
* @param args The arguments to log
|
|
312
|
-
*/
|
|
313
|
-
info(...args: any[]): void;
|
|
314
|
-
/**
|
|
315
|
-
* Log a message
|
|
316
|
-
* @param args The arguments to log
|
|
317
|
-
*/
|
|
318
|
-
warn(...args: any[]): void;
|
|
319
|
-
/**
|
|
320
|
-
* Log a message
|
|
321
|
-
* @param args The arguments to log
|
|
322
|
-
*/
|
|
323
|
-
error(...args: any[]): void;
|
|
324
|
-
/**
|
|
325
|
-
* Log a message
|
|
326
|
-
* @param args The arguments to log
|
|
327
|
-
*/
|
|
328
|
-
debug(...args: any[]): void;
|
|
329
|
-
}
|
|
330
|
-
/**
|
|
331
|
-
* Represents a service provider for the CLI
|
|
332
|
-
*/
|
|
333
|
-
export interface ICliServiceProvider {
|
|
334
|
-
/**
|
|
335
|
-
* Get a service
|
|
336
|
-
* @param service The service to get
|
|
337
|
-
*/
|
|
338
|
-
get<T>(service: any): T;
|
|
339
|
-
/**
|
|
340
|
-
* Set a service
|
|
341
|
-
* @param definition The definition of the service
|
|
342
|
-
*/
|
|
343
|
-
set(definition: CliProvider | CliProvider[]): void;
|
|
344
|
-
}
|
|
345
|
-
export * from './execution-context';
|
|
346
|
-
export * from './command-processor';
|
|
347
|
-
export * from './progress-bars';
|
|
348
|
-
export * from './command-hooks';
|
|
349
|
-
export * from './users';
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
export interface ICliProgressBar {
|
|
2
|
-
/**
|
|
3
|
-
* Indicates if the progress bar is running
|
|
4
|
-
*/
|
|
5
|
-
isRunning: boolean;
|
|
6
|
-
/**
|
|
7
|
-
* Show the progress bar
|
|
8
|
-
*/
|
|
9
|
-
show: (text?: string) => void;
|
|
10
|
-
/**
|
|
11
|
-
* Hide the progress bar
|
|
12
|
-
*/
|
|
13
|
-
hide: () => void;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Represents a spinner for the CLI
|
|
17
|
-
*/
|
|
18
|
-
export interface ICliSpinner extends ICliProgressBar {
|
|
19
|
-
/**
|
|
20
|
-
* Set the text of the spinner
|
|
21
|
-
* @param text The text to set
|
|
22
|
-
*/
|
|
23
|
-
setText: (text: string) => void;
|
|
24
|
-
}
|
|
25
|
-
export type CliPercentageProgressBarUpdateValueOptions = {
|
|
26
|
-
/**
|
|
27
|
-
* The type of update to perform
|
|
28
|
-
* @default 'replace'
|
|
29
|
-
*/
|
|
30
|
-
type?: 'replace' | 'increment';
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* Represents a progress bar for the CLI
|
|
34
|
-
*/
|
|
35
|
-
export interface ICliPercentageProgressBar extends ICliProgressBar {
|
|
36
|
-
/**
|
|
37
|
-
* Update the progress of the progress bar
|
|
38
|
-
* @param progress The progress to update to
|
|
39
|
-
* @returns void
|
|
40
|
-
*/
|
|
41
|
-
update: (progress: number, options?: CliPercentageProgressBarUpdateValueOptions) => void;
|
|
42
|
-
/**
|
|
43
|
-
* Complete the progress bar
|
|
44
|
-
* @returns void
|
|
45
|
-
*/
|
|
46
|
-
complete: () => void;
|
|
47
|
-
/**
|
|
48
|
-
* Set the text of the spinner
|
|
49
|
-
* @param text The text to set
|
|
50
|
-
*/
|
|
51
|
-
setText: (text: string) => void;
|
|
52
|
-
}
|
|
53
|
-
export type CliTextAnimatorOptions = {
|
|
54
|
-
/**
|
|
55
|
-
* The speed of the animation
|
|
56
|
-
* @default 100
|
|
57
|
-
*/
|
|
58
|
-
speed?: number;
|
|
59
|
-
/**
|
|
60
|
-
* The text will be removed after typing
|
|
61
|
-
*/
|
|
62
|
-
removeAfterTyping?: boolean;
|
|
63
|
-
};
|
|
64
|
-
export interface ICliTextAnimator extends ICliProgressBar {
|
|
65
|
-
/**
|
|
66
|
-
* Show animated text in a typing and erasing effect.
|
|
67
|
-
* @param text
|
|
68
|
-
* @param options
|
|
69
|
-
* @returns
|
|
70
|
-
*/
|
|
71
|
-
showText: (text: string, options?: CliTextAnimatorOptions) => void;
|
|
72
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { ICliUserSession, ICliUser, CliAddUser } from '../models';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
|
-
/**
|
|
4
|
-
* Represents a service that manages user sessions in the CLI
|
|
5
|
-
*/
|
|
6
|
-
export interface ICliUserSessionService {
|
|
7
|
-
/**
|
|
8
|
-
* Gets the current user session
|
|
9
|
-
* @returns An observable that emits the current user session
|
|
10
|
-
*/
|
|
11
|
-
getUserSession(): Observable<ICliUserSession | undefined>;
|
|
12
|
-
/**
|
|
13
|
-
* Sets the current user session
|
|
14
|
-
* @param session The session to set
|
|
15
|
-
*/
|
|
16
|
-
setUserSession(session: ICliUserSession): Promise<void>;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Represents a service that manages users in the CLI
|
|
20
|
-
*/
|
|
21
|
-
export interface ICliUsersStoreService {
|
|
22
|
-
/**
|
|
23
|
-
* Gets the current users
|
|
24
|
-
* @returns An observable that emits the current users
|
|
25
|
-
*/
|
|
26
|
-
getUsers(options?: {
|
|
27
|
-
query?: string;
|
|
28
|
-
skip?: number;
|
|
29
|
-
take?: number;
|
|
30
|
-
}): Observable<ICliUser[]>;
|
|
31
|
-
/**
|
|
32
|
-
* Creates a user
|
|
33
|
-
* @param user The user to create
|
|
34
|
-
*/
|
|
35
|
-
createUser(user: CliAddUser): Promise<ICliUser>;
|
|
36
|
-
/**
|
|
37
|
-
* Gets a user by id
|
|
38
|
-
* @param id The id of the user to get
|
|
39
|
-
* @returns An observable that emits the user with the specified id
|
|
40
|
-
*/
|
|
41
|
-
getUser(id: string): Observable<ICliUser | undefined>;
|
|
42
|
-
}
|