@navios/commander 1.5.0 → 1.5.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/.turbo/turbo-build.log +49 -0
- package/.turbo/turbo-check.log +2 -0
- package/.turbo/turbo-lint.log +3 -0
- package/.turbo/turbo-test$colon$ci.log +117 -0
- package/CHANGELOG.md +3 -3
- package/README.md +8 -16
- package/dist/src/commander.factory.d.mts +126 -122
- package/dist/src/commander.factory.d.mts.map +1 -1
- package/dist/src/commands/help.command.d.mts +15 -11
- package/dist/src/commands/help.command.d.mts.map +1 -1
- package/dist/src/commands/index.d.mts +2 -2
- package/dist/src/decorators/cli-module.decorator.d.mts +51 -40
- package/dist/src/decorators/cli-module.decorator.d.mts.map +1 -1
- package/dist/src/decorators/command.decorator.d.mts +49 -37
- package/dist/src/decorators/command.decorator.d.mts.map +1 -1
- package/dist/src/decorators/index.d.mts +3 -3
- package/dist/src/define-environment.d.mts +9 -8
- package/dist/src/define-environment.d.mts.map +1 -1
- package/dist/src/index.d.mts +10 -10
- package/dist/src/interfaces/abstract-cli-adapter.interface.d.mts +45 -45
- package/dist/src/interfaces/command-handler.interface.d.mts +9 -9
- package/dist/src/interfaces/commander-execution-context.interface.d.mts +30 -30
- package/dist/src/interfaces/commander-execution-context.interface.d.mts.map +1 -1
- package/dist/src/interfaces/environment.interface.d.mts +7 -7
- package/dist/src/interfaces/index.d.mts +5 -5
- package/dist/src/legacy-compat/decorators/cli-module.decorator.d.mts +6 -5
- package/dist/src/legacy-compat/decorators/cli-module.decorator.d.mts.map +1 -1
- package/dist/src/legacy-compat/decorators/command.decorator.d.mts +7 -6
- package/dist/src/legacy-compat/decorators/command.decorator.d.mts.map +1 -1
- package/dist/src/legacy-compat/decorators/index.d.mts +3 -3
- package/dist/src/legacy-compat/index.d.mts +3 -3
- package/dist/src/metadata/command-entry.metadata.d.mts +5 -5
- package/dist/src/metadata/command-entry.metadata.d.mts.map +1 -1
- package/dist/src/metadata/command.metadata.d.mts +30 -24
- package/dist/src/metadata/command.metadata.d.mts.map +1 -1
- package/dist/src/metadata/index.d.mts +3 -3
- package/dist/src/overrides/help.command.d.mts +15 -11
- package/dist/src/overrides/help.command.d.mts.map +1 -1
- package/dist/src/services/cli-parser.service.d.mts +54 -54
- package/dist/src/services/cli-parser.service.d.mts.map +1 -1
- package/dist/src/services/command-registry.service.d.mts +75 -74
- package/dist/src/services/command-registry.service.d.mts.map +1 -1
- package/dist/src/services/commander-adapter.service.d.mts +49 -48
- package/dist/src/services/commander-adapter.service.d.mts.map +1 -1
- package/dist/src/services/index.d.mts +4 -4
- package/dist/src/tokens/execution-context.token.d.mts +9 -4
- package/dist/src/tokens/execution-context.token.d.mts.map +1 -1
- package/dist/src/tokens/help-command.token.d.mts +5 -4
- package/dist/src/tokens/index.d.mts +2 -2
- package/dist/src/utils/index.d.mts +2 -2
- package/dist/src/utils/runtime.d.mts +2 -2
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/tsdown.config.d.mts +3 -3
- package/dist/vitest.config.d.mts +3 -3
- package/lib/{cli-module.decorator-CRaNGvgl.d.cts → cli-module.decorator-BzsOEMPH.d.cts} +54 -53
- package/lib/cli-module.decorator-BzsOEMPH.d.cts.map +1 -0
- package/lib/{cli-module.decorator-bsP5gEn7.d.mts → cli-module.decorator-CCV_elPP.d.mts} +116 -115
- package/lib/cli-module.decorator-CCV_elPP.d.mts.map +1 -0
- package/lib/{cli-module.decorator-CkP22084.cjs → cli-module.decorator-CXt38aqF.cjs} +2 -2
- package/lib/cli-module.decorator-CXt38aqF.cjs.map +1 -0
- package/lib/{cli-module.decorator-UGbtkRYc.mjs → cli-module.decorator-DAjf_r_W.mjs} +2 -2
- package/lib/cli-module.decorator-DAjf_r_W.mjs.map +1 -0
- package/lib/{command.decorator-UrNJmQN0.cjs → command.decorator-HziankUv.cjs} +3 -3
- package/lib/command.decorator-HziankUv.cjs.map +1 -0
- package/lib/{command.decorator-DVLSAqYZ.mjs → command.decorator-QiRU7ny3.mjs} +3 -3
- package/lib/command.decorator-QiRU7ny3.mjs.map +1 -0
- package/lib/{help-command.token-CMWYI6em.cjs → help-command.token-DamE31Aw.cjs} +4 -4
- package/lib/{help-command.token-CMWYI6em.cjs.map → help-command.token-DamE31Aw.cjs.map} +1 -1
- package/lib/{help-command.token-C0Kgj60o.mjs → help-command.token-XHx3WkoD.mjs} +4 -4
- package/lib/{help-command.token-C0Kgj60o.mjs.map → help-command.token-XHx3WkoD.mjs.map} +1 -1
- package/lib/{help.command-dtZbhq0w.mjs → help.command-Bynoll_7.mjs} +5 -8
- package/lib/help.command-Bynoll_7.mjs.map +1 -0
- package/lib/{help.command-DQyv6ali.cjs → help.command-DvKmMpB7.cjs} +6 -9
- package/lib/help.command-DvKmMpB7.cjs.map +1 -0
- package/lib/index.cjs +102 -102
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +283 -283
- package/lib/index.d.cts.map +1 -1
- package/lib/index.d.mts +221 -221
- package/lib/index.d.mts.map +1 -1
- package/lib/index.mjs +101 -101
- package/lib/index.mjs.map +1 -1
- package/lib/legacy-compat/index.cjs +6 -28
- package/lib/legacy-compat/index.cjs.map +1 -1
- package/lib/legacy-compat/index.d.cts +3 -2
- package/lib/legacy-compat/index.d.cts.map +1 -1
- package/lib/legacy-compat/index.d.mts +3 -2
- package/lib/legacy-compat/index.d.mts.map +1 -1
- package/lib/legacy-compat/index.mjs +4 -25
- package/lib/legacy-compat/index.mjs.map +1 -1
- package/package.json +26 -16
- package/src/__tests__/commander.factory.e2e.spec.mts +22 -66
- package/src/commands/help.command.mts +1 -1
- package/src/decorators/cli-module.decorator.mts +4 -9
- package/src/decorators/command.decorator.mts +4 -4
- package/src/define-environment.mts +4 -4
- package/src/interfaces/command-handler.interface.mts +1 -1
- package/src/interfaces/commander-execution-context.interface.mts +1 -1
- package/src/legacy-compat/decorators/cli-module.decorator.mts +2 -1
- package/src/legacy-compat/decorators/command.decorator.mts +3 -2
- package/src/metadata/command-entry.metadata.mts +3 -6
- package/src/metadata/command.metadata.mts +6 -8
- package/src/overrides/help.command.mts +2 -2
- package/src/services/__tests__/cli-parser.service.spec.mts +23 -178
- package/src/services/cli-parser.service.mts +23 -27
- package/src/services/command-registry.service.mts +5 -5
- package/src/services/commander-adapter.service.mts +10 -27
- package/src/tokens/execution-context.token.mts +4 -6
- package/tsconfig.json +3 -0
- package/lib/cli-module.decorator-CRaNGvgl.d.cts.map +0 -1
- package/lib/cli-module.decorator-CkP22084.cjs.map +0 -1
- package/lib/cli-module.decorator-UGbtkRYc.mjs.map +0 -1
- package/lib/cli-module.decorator-bsP5gEn7.d.mts.map +0 -1
- package/lib/command.decorator-DVLSAqYZ.mjs.map +0 -1
- package/lib/command.decorator-UrNJmQN0.cjs.map +0 -1
- package/lib/help.command-DQyv6ali.cjs.map +0 -1
- package/lib/help.command-dtZbhq0w.mjs.map +0 -1
- package/project.json +0 -66
package/lib/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as CommandHandler, i as CommandOptions, n as CliModuleOptions, r as Command, t as CliModule } from "./cli-module.decorator-
|
|
1
|
+
import { a as CommandHandler, i as CommandOptions, n as CliModuleOptions, r as Command, t as CliModule } from "./cli-module.decorator-BzsOEMPH.cjs";
|
|
2
2
|
import { AbstractAdapterInterface, AdapterEnvironment, AnyInjectableType, ClassType, ClassTypeWithInstance, InjectionToken, LogLevel, ModuleMetadata, NaviosApplication, NaviosModule } from "@navios/core";
|
|
3
|
-
import {
|
|
3
|
+
import { z } from "zod/v4";
|
|
4
4
|
export * from "@navios/core";
|
|
5
5
|
|
|
6
6
|
//#region src/commands/help.command.d.mts
|
|
@@ -28,44 +28,44 @@ declare class HelpCommand implements CommandHandler<HelpOptions> {
|
|
|
28
28
|
*/
|
|
29
29
|
interface AbstractCliAdapterInterface extends AbstractAdapterInterface {
|
|
30
30
|
/**
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
31
|
+
* Run the CLI application with the given arguments.
|
|
32
|
+
* Parses arguments and executes the matching command.
|
|
33
|
+
*
|
|
34
|
+
* @param argv - Command-line arguments array (defaults to `process.argv`)
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* const adapter = app.getAdapter() as AbstractCliAdapterInterface
|
|
39
|
+
* await adapter.run(process.argv)
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
42
|
run(argv?: string[]): Promise<void>;
|
|
43
43
|
/**
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
44
|
+
* Execute a command programmatically with the provided options.
|
|
45
|
+
*
|
|
46
|
+
* @param path - The command path (e.g., 'greet', 'user:create')
|
|
47
|
+
* @param options - The command options object
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```typescript
|
|
51
|
+
* await adapter.executeCommand('user:create', {
|
|
52
|
+
* name: 'John',
|
|
53
|
+
* email: 'john@example.com',
|
|
54
|
+
* })
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
57
|
executeCommand(path: string, options: Record<string, unknown>): Promise<void>;
|
|
58
58
|
/**
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
59
|
+
* Get all registered command paths and their class references.
|
|
60
|
+
*
|
|
61
|
+
* @returns Array of objects containing path and class
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```typescript
|
|
65
|
+
* const commands = adapter.getAllCommands()
|
|
66
|
+
* commands.forEach(({ path }) => console.log(path))
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
69
|
getAllCommands(): Array<{
|
|
70
70
|
path: string;
|
|
71
71
|
class: unknown;
|
|
@@ -109,39 +109,39 @@ interface CliEnvironment extends AdapterEnvironment {
|
|
|
109
109
|
*/
|
|
110
110
|
interface CommanderLoggerOptions {
|
|
111
111
|
/**
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
112
|
+
* Enabled log levels.
|
|
113
|
+
* @default ['log', 'error', 'warn', 'debug', 'verbose', 'fatal']
|
|
114
|
+
*/
|
|
115
115
|
logLevels?: LogLevel[];
|
|
116
116
|
/**
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
117
|
+
* If true, will print the process ID in the log message.
|
|
118
|
+
* @default false
|
|
119
|
+
*/
|
|
120
120
|
showPid?: boolean;
|
|
121
121
|
/**
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
122
|
+
* If true, will print the log level in the log message.
|
|
123
|
+
* @default true
|
|
124
|
+
*/
|
|
125
125
|
showLogLevel?: boolean;
|
|
126
126
|
/**
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
127
|
+
* If true, will print the prefix/app name in the log message.
|
|
128
|
+
* @default false
|
|
129
|
+
*/
|
|
130
130
|
showPrefix?: boolean;
|
|
131
131
|
/**
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
132
|
+
* If true, will print the context in the log message.
|
|
133
|
+
* @default true
|
|
134
|
+
*/
|
|
135
135
|
showContext?: boolean;
|
|
136
136
|
/**
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
137
|
+
* If true, will print the absolute timestamp in the log message.
|
|
138
|
+
* @default false
|
|
139
|
+
*/
|
|
140
140
|
showTimestamp?: boolean;
|
|
141
141
|
/**
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
142
|
+
* If enabled, will print timestamp difference between current and previous log message.
|
|
143
|
+
* @default false
|
|
144
|
+
*/
|
|
145
145
|
showTimeDiff?: boolean;
|
|
146
146
|
}
|
|
147
147
|
/**
|
|
@@ -152,52 +152,52 @@ interface CommanderLoggerOptions {
|
|
|
152
152
|
*/
|
|
153
153
|
interface CommanderTuiOptions {
|
|
154
154
|
/**
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
155
|
+
* Exit on Ctrl+C.
|
|
156
|
+
* @default true
|
|
157
|
+
*/
|
|
158
158
|
exitOnCtrlC?: boolean;
|
|
159
159
|
/**
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
160
|
+
* Adapter to use for the TUI.
|
|
161
|
+
* @default 'none'
|
|
162
|
+
*/
|
|
163
163
|
adapter?: 'react' | 'solid' | 'ink' | 'none';
|
|
164
164
|
/**
|
|
165
|
-
|
|
166
|
-
|
|
165
|
+
* Sidebar width in columns.
|
|
166
|
+
*/
|
|
167
167
|
sidebarWidth?: number;
|
|
168
168
|
/**
|
|
169
|
-
|
|
170
|
-
|
|
169
|
+
* Sidebar position.
|
|
170
|
+
*/
|
|
171
171
|
sidebarPosition?: 'left' | 'right';
|
|
172
172
|
/**
|
|
173
|
-
|
|
174
|
-
|
|
173
|
+
* Sidebar header title.
|
|
174
|
+
*/
|
|
175
175
|
sidebarTitle?: string;
|
|
176
176
|
/**
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
177
|
+
* Auto close after all screens complete successfully.
|
|
178
|
+
* Set to true for default delay (5000ms), or specify delay in milliseconds.
|
|
179
|
+
*/
|
|
180
180
|
autoClose?: boolean | number;
|
|
181
181
|
/**
|
|
182
|
-
|
|
183
|
-
|
|
182
|
+
* Theme preset name ('dark', 'light', 'high-contrast') or custom theme object.
|
|
183
|
+
*/
|
|
184
184
|
theme?: string | Record<string, unknown>;
|
|
185
185
|
/**
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
186
|
+
* Enable mouse support.
|
|
187
|
+
* @default false
|
|
188
|
+
*/
|
|
189
189
|
useMouse?: boolean;
|
|
190
190
|
/**
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
191
|
+
* Hide the default console logger screen from the sidebar.
|
|
192
|
+
* @default false
|
|
193
|
+
*/
|
|
194
194
|
hideDefaultScreen?: boolean;
|
|
195
195
|
/**
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
196
|
+
* Use OpenTUI for terminal rendering.
|
|
197
|
+
* When true: Full TUI with sidebar, scrolling, interactive prompts.
|
|
198
|
+
* When false: Stdout mode - static screens print immediately, others on completion.
|
|
199
|
+
* @default true for Node.js, false for Bun (OpenTUI not supported)
|
|
200
|
+
*/
|
|
201
201
|
useOpenTUI?: boolean;
|
|
202
202
|
}
|
|
203
203
|
/**
|
|
@@ -207,23 +207,23 @@ interface CommanderTuiOptions {
|
|
|
207
207
|
*/
|
|
208
208
|
interface CommanderFactoryOptions {
|
|
209
209
|
/**
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
210
|
+
* Enabled log levels.
|
|
211
|
+
* @default ['log', 'error', 'warn', 'debug', 'verbose', 'fatal']
|
|
212
|
+
*/
|
|
213
213
|
logLevels?: LogLevel[];
|
|
214
214
|
/**
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
215
|
+
* Logger display options. These override the default CLI-friendly logger settings.
|
|
216
|
+
* Ignored when enableTUI is true.
|
|
217
|
+
*/
|
|
218
218
|
logger?: CommanderLoggerOptions;
|
|
219
219
|
/**
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
220
|
+
* Enable TUI mode with @navios/commander-tui.
|
|
221
|
+
* Requires @navios/commander-tui to be installed.
|
|
222
|
+
*/
|
|
223
223
|
enableTUI?: boolean;
|
|
224
224
|
/**
|
|
225
|
-
|
|
226
|
-
|
|
225
|
+
* TUI-specific options. Only used when enableTUI is true.
|
|
226
|
+
*/
|
|
227
227
|
tuiOptions?: CommanderTuiOptions;
|
|
228
228
|
}
|
|
229
229
|
/**
|
|
@@ -262,21 +262,21 @@ interface CommanderFactoryOptions {
|
|
|
262
262
|
*/
|
|
263
263
|
declare class CommanderFactory {
|
|
264
264
|
/**
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
265
|
+
* Creates a new CLI application instance configured with the provided module.
|
|
266
|
+
*
|
|
267
|
+
* @param appModule - The root CLI module class decorated with `@CliModule`
|
|
268
|
+
* @param options - Optional configuration options for the CLI application
|
|
269
|
+
* @returns A promise that resolves to a configured NaviosApplication instance
|
|
270
|
+
*
|
|
271
|
+
* @example
|
|
272
|
+
* ```typescript
|
|
273
|
+
* const app = await CommanderFactory.create(AppModule)
|
|
274
|
+
* await app.init()
|
|
275
|
+
*
|
|
276
|
+
* const adapter = app.getAdapter()
|
|
277
|
+
* await adapter.run(process.argv)
|
|
278
|
+
* ```
|
|
279
|
+
*/
|
|
280
280
|
static create<TModule extends NaviosModule = NaviosModule>(appModule: ClassTypeWithInstance<TModule>, options?: CommanderFactoryOptions): Promise<NaviosApplication<CliEnvironment>>;
|
|
281
281
|
}
|
|
282
282
|
//#endregion
|
|
@@ -293,20 +293,20 @@ declare const CommandMetadataKey: unique symbol;
|
|
|
293
293
|
*/
|
|
294
294
|
interface CommandMetadata {
|
|
295
295
|
/**
|
|
296
|
-
|
|
297
|
-
|
|
296
|
+
* The command path (e.g., 'greet', 'user:create').
|
|
297
|
+
*/
|
|
298
298
|
path: string;
|
|
299
299
|
/**
|
|
300
|
-
|
|
301
|
-
|
|
300
|
+
* Optional description of the command for help text.
|
|
301
|
+
*/
|
|
302
302
|
description?: string;
|
|
303
303
|
/**
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
optionsSchema?: ZodObject;
|
|
304
|
+
* Optional zod/v4 schema for validating command options.
|
|
305
|
+
*/
|
|
306
|
+
optionsSchema?: z.ZodObject;
|
|
307
307
|
/**
|
|
308
|
-
|
|
309
|
-
|
|
308
|
+
* Map of custom attributes that can be attached to the command.
|
|
309
|
+
*/
|
|
310
310
|
customAttributes: Map<string | symbol, any>;
|
|
311
311
|
}
|
|
312
312
|
/**
|
|
@@ -317,10 +317,10 @@ interface CommandMetadata {
|
|
|
317
317
|
* @param context - The decorator context
|
|
318
318
|
* @param path - The command path
|
|
319
319
|
* @param description - Optional description for help text
|
|
320
|
-
* @param optionsSchema - Optional
|
|
320
|
+
* @param optionsSchema - Optional zod/v4 schema
|
|
321
321
|
* @returns The command metadata
|
|
322
322
|
*/
|
|
323
|
-
declare function getCommandMetadata(target: ClassType, context: ClassDecoratorContext, path: string, description?: string, optionsSchema?: ZodObject): CommandMetadata;
|
|
323
|
+
declare function getCommandMetadata(target: ClassType, context: ClassDecoratorContext, path: string, description?: string, optionsSchema?: z.ZodObject): CommandMetadata;
|
|
324
324
|
/**
|
|
325
325
|
* Extracts command metadata from a class.
|
|
326
326
|
*
|
|
@@ -371,84 +371,105 @@ declare class CommanderExecutionContext {
|
|
|
371
371
|
private readonly commandPath;
|
|
372
372
|
private readonly options;
|
|
373
373
|
/**
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
374
|
+
* @internal
|
|
375
|
+
* Creates a new execution context.
|
|
376
|
+
*/
|
|
377
377
|
constructor(command: CommandMetadata, commandPath: string, options: any);
|
|
378
378
|
/**
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
379
|
+
* Gets the command metadata.
|
|
380
|
+
*
|
|
381
|
+
* @returns The command metadata including path and options schema
|
|
382
|
+
*/
|
|
383
383
|
getCommand(): CommandMetadata;
|
|
384
384
|
/**
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
385
|
+
* Gets the command path that was invoked.
|
|
386
|
+
*
|
|
387
|
+
* @returns The command path (e.g., 'greet', 'user:create')
|
|
388
|
+
*/
|
|
389
389
|
getCommandPath(): string;
|
|
390
390
|
/**
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
391
|
+
* Gets the validated command options.
|
|
392
|
+
*
|
|
393
|
+
* Options are validated against the command's zod/v4 schema if one was provided.
|
|
394
|
+
*
|
|
395
|
+
* @returns The validated options object
|
|
396
|
+
*/
|
|
397
397
|
getOptions(): any;
|
|
398
398
|
}
|
|
399
399
|
//#endregion
|
|
400
|
-
//#region src/services/
|
|
400
|
+
//#region src/services/cli-parser.service.d.mts
|
|
401
401
|
/**
|
|
402
|
-
*
|
|
403
|
-
* Handles command discovery, registration, parsing, and execution.
|
|
402
|
+
* Result of parsing command-line arguments.
|
|
404
403
|
*
|
|
405
404
|
* @public
|
|
406
405
|
*/
|
|
407
|
-
|
|
408
|
-
private container;
|
|
409
|
-
private commandRegistry;
|
|
410
|
-
private cliParser;
|
|
411
|
-
private logger;
|
|
412
|
-
private options;
|
|
413
|
-
private isReady;
|
|
406
|
+
interface ParsedCliArgs {
|
|
414
407
|
/**
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
408
|
+
* The command path (e.g., 'greet', 'user:create').
|
|
409
|
+
* Multi-word commands are joined with spaces.
|
|
410
|
+
*/
|
|
411
|
+
command: string;
|
|
419
412
|
/**
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
413
|
+
* Parsed options as key-value pairs.
|
|
414
|
+
* Keys are converted from kebab-case to camelCase.
|
|
415
|
+
*/
|
|
416
|
+
options: Record<string, any>;
|
|
424
417
|
/**
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
418
|
+
* Positional arguments that don't match any option flags.
|
|
419
|
+
*/
|
|
420
|
+
positionals: string[];
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* Service for parsing command-line arguments.
|
|
424
|
+
*
|
|
425
|
+
* Handles parsing of various CLI argument formats including:
|
|
426
|
+
* - Long options: `--key value` or `--key=value`
|
|
427
|
+
* - Short options: `-k value` or `-abc` (multiple flags)
|
|
428
|
+
* - Boolean flags
|
|
429
|
+
* - Array options
|
|
430
|
+
* - Positional arguments
|
|
431
|
+
*
|
|
432
|
+
* @public
|
|
433
|
+
*/
|
|
434
|
+
declare class CliParserService {
|
|
428
435
|
/**
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
436
|
+
* Parses command-line arguments from process.argv
|
|
437
|
+
* Commands can be multi-word (e.g., 'db migrate', 'cache clear')
|
|
438
|
+
* Expected format: node script.js command [subcommand...] --flag value --boolean-flag positional1 positional2
|
|
439
|
+
*
|
|
440
|
+
* @param argv - Array of command-line arguments (typically process.argv)
|
|
441
|
+
* @param optionsSchema - Optional zod/v4 schema to determine boolean flags and option types
|
|
442
|
+
* @returns Parsed command (space-separated if multi-word), options, and positional arguments
|
|
443
|
+
*/
|
|
444
|
+
parse(argv: string[], optionsSchema?: z.ZodObject): ParsedCliArgs;
|
|
445
|
+
/**
|
|
446
|
+
* Converts kebab-case to camelCase
|
|
447
|
+
*/
|
|
448
|
+
private camelCase;
|
|
432
449
|
/**
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
450
|
+
* Attempts to parse string values into appropriate types
|
|
451
|
+
*/
|
|
452
|
+
private parseValue;
|
|
436
453
|
/**
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
454
|
+
* Extracts boolean field names from a zod/v4 schema
|
|
455
|
+
* Handles z.ZodObject, zod/v4Optional, and zod/v4Default wrappers
|
|
456
|
+
*/
|
|
457
|
+
private extractBooleanFields;
|
|
441
458
|
/**
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
459
|
+
* Extracts array field names from a zod/v4 schema
|
|
460
|
+
* Handles z.ZodObject, zod/v4Optional, and zod/v4Default wrappers
|
|
461
|
+
*/
|
|
462
|
+
private extractArrayFields;
|
|
445
463
|
/**
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
464
|
+
* Checks if a zod/v4 schema represents a boolean type
|
|
465
|
+
* Unwraps zod/v4Optional and zod/v4Default using zod/v4 v4 API
|
|
466
|
+
*/
|
|
467
|
+
private isSchemaBoolean;
|
|
468
|
+
/**
|
|
469
|
+
* Checks if a zod/v4 schema represents an array type
|
|
470
|
+
* Unwraps zod/v4Optional and zod/v4Default using zod/v4 v4 API
|
|
471
|
+
*/
|
|
472
|
+
private isSchemaArray;
|
|
452
473
|
}
|
|
453
474
|
//#endregion
|
|
454
475
|
//#region src/metadata/command-entry.metadata.d.mts
|
|
@@ -490,16 +511,16 @@ declare function extractModuleCommands(moduleClass: ClassType): Set<ClassType>;
|
|
|
490
511
|
*/
|
|
491
512
|
interface RegisteredCommand {
|
|
492
513
|
/**
|
|
493
|
-
|
|
494
|
-
|
|
514
|
+
* The command class
|
|
515
|
+
*/
|
|
495
516
|
class: ClassType;
|
|
496
517
|
/**
|
|
497
|
-
|
|
498
|
-
|
|
518
|
+
* The command metadata from @Command decorator
|
|
519
|
+
*/
|
|
499
520
|
metadata: CommandMetadata;
|
|
500
521
|
/**
|
|
501
|
-
|
|
502
|
-
|
|
522
|
+
* Name of the module this command belongs to
|
|
523
|
+
*/
|
|
503
524
|
moduleName: string;
|
|
504
525
|
}
|
|
505
526
|
/**
|
|
@@ -511,138 +532,117 @@ interface RegisteredCommand {
|
|
|
511
532
|
declare class CommandRegistryService {
|
|
512
533
|
private commands;
|
|
513
534
|
/**
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
535
|
+
* Register a command with its metadata.
|
|
536
|
+
*
|
|
537
|
+
* @param path - The command path (e.g., 'greet', 'user:create')
|
|
538
|
+
* @param command - The registered command data
|
|
539
|
+
* @throws Error if a command with the same path is already registered
|
|
540
|
+
*/
|
|
520
541
|
register(path: string, command: RegisteredCommand): void;
|
|
521
542
|
/**
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
543
|
+
* Get a command by its path.
|
|
544
|
+
*
|
|
545
|
+
* @param path - The command path
|
|
546
|
+
* @returns The registered command or undefined if not found
|
|
547
|
+
*/
|
|
527
548
|
getByPath(path: string): RegisteredCommand | undefined;
|
|
528
549
|
/**
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
550
|
+
* Get all registered commands.
|
|
551
|
+
*
|
|
552
|
+
* @returns Map of path to registered command
|
|
553
|
+
*/
|
|
533
554
|
getAll(): Map<string, RegisteredCommand>;
|
|
534
555
|
/**
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
556
|
+
* Get all registered commands as an array of path and class pairs.
|
|
557
|
+
* Useful for listing available commands.
|
|
558
|
+
*
|
|
559
|
+
* @returns Array of objects containing path and class
|
|
560
|
+
*/
|
|
540
561
|
getAllAsArray(): Array<{
|
|
541
562
|
path: string;
|
|
542
563
|
class: ClassType;
|
|
543
564
|
}>;
|
|
544
565
|
/**
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
566
|
+
* Formats help text listing all available commands with descriptions.
|
|
567
|
+
*
|
|
568
|
+
* @returns Formatted string listing all commands
|
|
569
|
+
*/
|
|
549
570
|
formatCommandList(): string;
|
|
550
571
|
/**
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
572
|
+
* Formats help text for a specific command.
|
|
573
|
+
*
|
|
574
|
+
* @param commandPath - The command path to show help for
|
|
575
|
+
* @returns Formatted string with command help
|
|
576
|
+
*/
|
|
556
577
|
formatCommandHelp(commandPath: string): string;
|
|
557
578
|
/**
|
|
558
|
-
|
|
559
|
-
|
|
579
|
+
* Gets a human-readable type name from a zod/v4 schema.
|
|
580
|
+
*/
|
|
560
581
|
private getSchemaTypeName;
|
|
561
582
|
/**
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
583
|
+
* Gets metadata from a zod/v4 schema, traversing innerType if needed.
|
|
584
|
+
* zod/v4 v4 stores meta at the outermost layer when .meta() is called last,
|
|
585
|
+
* or in innerType when .meta() is called before .optional()/.default().
|
|
586
|
+
*/
|
|
566
587
|
private getSchemaMeta;
|
|
567
588
|
/**
|
|
568
|
-
|
|
569
|
-
|
|
589
|
+
* Clear all registered commands.
|
|
590
|
+
*/
|
|
570
591
|
clear(): void;
|
|
571
592
|
}
|
|
572
593
|
//#endregion
|
|
573
|
-
//#region src/services/
|
|
594
|
+
//#region src/services/commander-adapter.service.d.mts
|
|
574
595
|
/**
|
|
575
|
-
*
|
|
596
|
+
* CLI adapter service that implements the AbstractCliAdapterInterface.
|
|
597
|
+
* Handles command discovery, registration, parsing, and execution.
|
|
576
598
|
*
|
|
577
599
|
* @public
|
|
578
600
|
*/
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
601
|
+
declare class CommanderAdapterService implements AbstractCliAdapterInterface {
|
|
602
|
+
private container;
|
|
603
|
+
private commandRegistry;
|
|
604
|
+
private cliParser;
|
|
605
|
+
private logger;
|
|
606
|
+
private options;
|
|
607
|
+
private isReady;
|
|
585
608
|
/**
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
options:
|
|
609
|
+
* Sets up the adapter with the provided options.
|
|
610
|
+
* Called during application initialization.
|
|
611
|
+
*/
|
|
612
|
+
setupAdapter(options: CliAdapterOptions): Promise<void>;
|
|
590
613
|
/**
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
/**
|
|
596
|
-
* Service for parsing command-line arguments.
|
|
597
|
-
*
|
|
598
|
-
* Handles parsing of various CLI argument formats including:
|
|
599
|
-
* - Long options: `--key value` or `--key=value`
|
|
600
|
-
* - Short options: `-k value` or `-abc` (multiple flags)
|
|
601
|
-
* - Boolean flags
|
|
602
|
-
* - Array options
|
|
603
|
-
* - Positional arguments
|
|
604
|
-
*
|
|
605
|
-
* @public
|
|
606
|
-
*/
|
|
607
|
-
declare class CliParserService {
|
|
614
|
+
* Called after all modules are loaded.
|
|
615
|
+
* Iterates through modules and extracts commands from customEntries.
|
|
616
|
+
*/
|
|
617
|
+
onModulesInit(modules: Map<string, ModuleMetadata>): Promise<void>;
|
|
608
618
|
/**
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
*
|
|
613
|
-
* @param argv - Array of command-line arguments (typically process.argv)
|
|
614
|
-
* @param optionsSchema - Optional Zod schema to determine boolean flags and option types
|
|
615
|
-
* @returns Parsed command (space-separated if multi-word), options, and positional arguments
|
|
616
|
-
*/
|
|
617
|
-
parse(argv: string[], optionsSchema?: ZodObject): ParsedCliArgs;
|
|
618
|
-
/**
|
|
619
|
-
* Converts kebab-case to camelCase
|
|
620
|
-
*/
|
|
621
|
-
private camelCase;
|
|
619
|
+
* Registers built-in commands like help.
|
|
620
|
+
*/
|
|
621
|
+
private registerBuiltInCommands;
|
|
622
622
|
/**
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
623
|
+
* Signals that the adapter is ready to handle commands.
|
|
624
|
+
*/
|
|
625
|
+
ready(): Promise<void>;
|
|
626
626
|
/**
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
private extractBooleanFields;
|
|
627
|
+
* Disposes of the adapter and cleans up resources.
|
|
628
|
+
*/
|
|
629
|
+
dispose(): Promise<void>;
|
|
631
630
|
/**
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
631
|
+
* Run the CLI application with the given arguments.
|
|
632
|
+
* Parses arguments and executes the matching command.
|
|
633
|
+
*/
|
|
634
|
+
run(argv?: string[]): Promise<void>;
|
|
636
635
|
/**
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
private isSchemaBoolean;
|
|
636
|
+
* Execute a command programmatically with the provided options.
|
|
637
|
+
*/
|
|
638
|
+
executeCommand(path: string, options?: Record<string, unknown>): Promise<void>;
|
|
641
639
|
/**
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
640
|
+
* Get all registered command paths and their class references.
|
|
641
|
+
*/
|
|
642
|
+
getAllCommands(): Array<{
|
|
643
|
+
path: string;
|
|
644
|
+
class: ClassType;
|
|
645
|
+
}>;
|
|
646
646
|
}
|
|
647
647
|
//#endregion
|
|
648
648
|
//#region src/define-environment.d.mts
|