@navios/commander 1.0.0 → 1.2.0
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/CHANGELOG.md +35 -0
- package/README.md +22 -0
- package/dist/src/commander.factory.d.mts +59 -0
- package/dist/src/commander.factory.d.mts.map +1 -1
- package/dist/src/commands/help.command.d.mts.map +1 -1
- package/dist/src/decorators/command.decorator.d.mts +9 -2
- package/dist/src/decorators/command.decorator.d.mts.map +1 -1
- package/dist/src/legacy-compat/decorators/cli-module.decorator.d.mts +26 -0
- package/dist/src/legacy-compat/decorators/cli-module.decorator.d.mts.map +1 -0
- package/dist/src/legacy-compat/decorators/command.decorator.d.mts +34 -0
- package/dist/src/legacy-compat/decorators/command.decorator.d.mts.map +1 -0
- package/dist/src/legacy-compat/decorators/index.d.mts +3 -0
- package/dist/src/legacy-compat/decorators/index.d.mts.map +1 -0
- package/dist/src/legacy-compat/index.d.mts +28 -0
- package/dist/src/legacy-compat/index.d.mts.map +1 -0
- package/dist/src/overrides/help.command.d.mts +18 -0
- package/dist/src/overrides/help.command.d.mts.map +1 -0
- package/dist/src/tokens/help-command.token.d.mts +4 -0
- package/dist/src/tokens/help-command.token.d.mts.map +1 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/lib/cli-module.decorator-CkP22084.cjs +71 -0
- package/lib/cli-module.decorator-CkP22084.cjs.map +1 -0
- package/lib/cli-module.decorator-DGuGfpex.d.mts +411 -0
- package/lib/cli-module.decorator-DGuGfpex.d.mts.map +1 -0
- package/lib/cli-module.decorator-DVl8009Q.d.cts +213 -0
- package/lib/cli-module.decorator-DVl8009Q.d.cts.map +1 -0
- package/lib/cli-module.decorator-UGbtkRYc.mjs +66 -0
- package/lib/cli-module.decorator-UGbtkRYc.mjs.map +1 -0
- package/lib/command.decorator-DVLSAqYZ.mjs +135 -0
- package/lib/command.decorator-DVLSAqYZ.mjs.map +1 -0
- package/lib/command.decorator-UrNJmQN0.cjs +176 -0
- package/lib/command.decorator-UrNJmQN0.cjs.map +1 -0
- package/lib/help-command.token-C0Kgj60o.mjs +427 -0
- package/lib/help-command.token-C0Kgj60o.mjs.map +1 -0
- package/lib/help-command.token-CMWYI6em.cjs +438 -0
- package/lib/help-command.token-CMWYI6em.cjs.map +1 -0
- package/lib/help.command-DQyv6ali.cjs +317 -0
- package/lib/help.command-DQyv6ali.cjs.map +1 -0
- package/lib/help.command-dtZbhq0w.mjs +318 -0
- package/lib/help.command-dtZbhq0w.mjs.map +1 -0
- package/lib/index.cjs +45 -627
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +139 -281
- package/lib/index.d.cts.map +1 -1
- package/lib/index.d.mts +62 -402
- package/lib/index.d.mts.map +1 -1
- package/lib/index.mjs +30 -612
- package/lib/index.mjs.map +1 -1
- package/lib/legacy-compat/index.cjs +108 -0
- package/lib/legacy-compat/index.cjs.map +1 -0
- package/lib/legacy-compat/index.d.cts +63 -0
- package/lib/legacy-compat/index.d.cts.map +1 -0
- package/lib/legacy-compat/index.d.mts +63 -0
- package/lib/legacy-compat/index.d.mts.map +1 -0
- package/lib/legacy-compat/index.mjs +101 -0
- package/lib/legacy-compat/index.mjs.map +1 -0
- package/package.json +20 -3
- package/src/commander.factory.mts +107 -8
- package/src/commands/help.command.mts +4 -3
- package/src/decorators/command.decorator.mts +17 -8
- package/src/legacy-compat/decorators/cli-module.decorator.mts +46 -0
- package/src/legacy-compat/decorators/command.decorator.mts +46 -0
- package/src/legacy-compat/decorators/index.mts +2 -0
- package/src/legacy-compat/index.mts +31 -0
- package/src/overrides/help.command.mts +40 -0
- package/src/tokens/help-command.token.mts +5 -0
- package/tsconfig.json +0 -3
- package/tsconfig.spec.json +1 -1
- package/tsdown.config.mts +1 -1
- package/dist/src/commander.application.d.mts +0 -147
- package/dist/src/commander.application.d.mts.map +0 -1
- package/dist/src/metadata/cli-module.metadata.d.mts +0 -60
- package/dist/src/metadata/cli-module.metadata.d.mts.map +0 -1
- package/dist/src/services/module-loader.service.d.mts +0 -74
- package/dist/src/services/module-loader.service.d.mts.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,41 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.2.0] - 2026-01-11
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **Legacy Compatibility Module** - New `@navios/commander/legacy-compat` subpath export for projects using TypeScript experimental decorators
|
|
13
|
+
- `Command` decorator wrapper that converts legacy decorator API to Stage 3 format
|
|
14
|
+
- `CliModule` decorator wrapper for legacy compatibility
|
|
15
|
+
- Re-exports `@navios/core/legacy-compat` utilities for convenience
|
|
16
|
+
|
|
17
|
+
## [1.1.0] - 2026-01-10
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
|
|
21
|
+
- **TUI Mode Support** - New `enableTUI` option in `CommanderFactory.create()` to enable terminal UI mode
|
|
22
|
+
- Dynamically imports `@navios/commander-tui` when enabled
|
|
23
|
+
- Auto-binds `ScreenManager` with configurable options
|
|
24
|
+
- Falls back to standard console logger when TUI is disabled
|
|
25
|
+
- **TUI Options** - New `CommanderTuiOptions` interface for TUI-specific configuration
|
|
26
|
+
- `exitOnCtrlC`, `sidebarWidth`, `sidebarPosition`, `sidebarTitle`
|
|
27
|
+
- `autoClose` with configurable delay
|
|
28
|
+
- `theme` support (preset name or custom object)
|
|
29
|
+
- `useMouse` and `hideDefaultScreen` options
|
|
30
|
+
- **Log Levels Configuration** - New `logLevels` option in `CommanderFactoryOptions`
|
|
31
|
+
- **Command Token Option** - New `token` option in `@Command()` decorator for custom injection tokens
|
|
32
|
+
- **Help Command Token** - New `HelpCommandToken` for overriding the built-in help command
|
|
33
|
+
|
|
34
|
+
### Changed
|
|
35
|
+
|
|
36
|
+
- **Optional TUI Dependency** - `@navios/commander-tui` is now an optional peer dependency
|
|
37
|
+
- **Command Decorator** - Internal token handling refactored to support custom tokens
|
|
38
|
+
|
|
39
|
+
### Dependencies
|
|
40
|
+
|
|
41
|
+
- Added optional peer dependency: `@navios/commander-tui` ^1.0.0
|
|
42
|
+
|
|
8
43
|
## [1.0.0] - 2026-01-09
|
|
9
44
|
|
|
10
45
|
### Added
|
package/README.md
CHANGED
|
@@ -312,6 +312,28 @@ CLI adapter interface returned by `app.getAdapter()`.
|
|
|
312
312
|
- `async executeCommand(path, options?)` - Executes a command programmatically with options
|
|
313
313
|
- `getAllCommands()` - Returns all registered commands
|
|
314
314
|
|
|
315
|
+
## Legacy Decorator Support
|
|
316
|
+
|
|
317
|
+
If your project uses TypeScript experimental decorators (legacy mode), you can import from the `legacy-compat` subpath:
|
|
318
|
+
|
|
319
|
+
```typescript
|
|
320
|
+
import { Command, CliModule, CommandHandler } from '@navios/commander/legacy-compat'
|
|
321
|
+
|
|
322
|
+
@Command({ path: 'greet' })
|
|
323
|
+
export class GreetCommand implements CommandHandler {
|
|
324
|
+
async execute() {
|
|
325
|
+
console.log('Hello!')
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
@CliModule({
|
|
330
|
+
commands: [GreetCommand],
|
|
331
|
+
})
|
|
332
|
+
export class AppModule {}
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
This provides wrapper decorators that convert the legacy decorator API to Stage 3 format internally, allowing you to use the same decorator syntax while maintaining compatibility with older TypeScript configurations.
|
|
336
|
+
|
|
315
337
|
## License
|
|
316
338
|
|
|
317
339
|
MIT
|
|
@@ -43,16 +43,75 @@ export interface CommanderLoggerOptions {
|
|
|
43
43
|
*/
|
|
44
44
|
showTimeDiff?: boolean;
|
|
45
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* TUI-specific options for terminal UI mode.
|
|
48
|
+
* Only used when enableTUI is true.
|
|
49
|
+
*
|
|
50
|
+
* @public
|
|
51
|
+
*/
|
|
52
|
+
export interface CommanderTuiOptions {
|
|
53
|
+
/**
|
|
54
|
+
* Exit on Ctrl+C.
|
|
55
|
+
* @default true
|
|
56
|
+
*/
|
|
57
|
+
exitOnCtrlC?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Sidebar width in columns.
|
|
60
|
+
*/
|
|
61
|
+
sidebarWidth?: number;
|
|
62
|
+
/**
|
|
63
|
+
* Sidebar position.
|
|
64
|
+
*/
|
|
65
|
+
sidebarPosition?: 'left' | 'right';
|
|
66
|
+
/**
|
|
67
|
+
* Sidebar header title.
|
|
68
|
+
*/
|
|
69
|
+
sidebarTitle?: string;
|
|
70
|
+
/**
|
|
71
|
+
* Auto close after all screens complete successfully.
|
|
72
|
+
* Set to true for default delay (5000ms), or specify delay in milliseconds.
|
|
73
|
+
*/
|
|
74
|
+
autoClose?: boolean | number;
|
|
75
|
+
/**
|
|
76
|
+
* Theme preset name ('dark', 'light', 'high-contrast') or custom theme object.
|
|
77
|
+
*/
|
|
78
|
+
theme?: string | Record<string, unknown>;
|
|
79
|
+
/**
|
|
80
|
+
* Enable mouse support.
|
|
81
|
+
* @default false
|
|
82
|
+
*/
|
|
83
|
+
useMouse?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Hide the default console logger screen from the sidebar.
|
|
86
|
+
* @default false
|
|
87
|
+
*/
|
|
88
|
+
hideDefaultScreen?: boolean;
|
|
89
|
+
}
|
|
46
90
|
/**
|
|
47
91
|
* Configuration options for CommanderFactory.
|
|
48
92
|
*
|
|
49
93
|
* @public
|
|
50
94
|
*/
|
|
51
95
|
export interface CommanderFactoryOptions {
|
|
96
|
+
/**
|
|
97
|
+
* Enabled log levels.
|
|
98
|
+
* @default ['log', 'error', 'warn', 'debug', 'verbose', 'fatal']
|
|
99
|
+
*/
|
|
100
|
+
logLevels?: LogLevel[];
|
|
52
101
|
/**
|
|
53
102
|
* Logger display options. These override the default CLI-friendly logger settings.
|
|
103
|
+
* Ignored when enableTUI is true.
|
|
54
104
|
*/
|
|
55
105
|
logger?: CommanderLoggerOptions;
|
|
106
|
+
/**
|
|
107
|
+
* Enable TUI mode with @navios/commander-tui.
|
|
108
|
+
* Requires @navios/commander-tui to be installed.
|
|
109
|
+
*/
|
|
110
|
+
enableTUI?: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* TUI-specific options. Only used when enableTUI is true.
|
|
113
|
+
*/
|
|
114
|
+
tuiOptions?: CommanderTuiOptions;
|
|
56
115
|
}
|
|
57
116
|
/**
|
|
58
117
|
* Factory class for creating CLI applications.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commander.factory.d.mts","sourceRoot":"","sources":["../../src/commander.factory.mts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"commander.factory.d.mts","sourceRoot":"","sources":["../../src/commander.factory.mts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,QAAQ,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAIpG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAA;AAE5E;;;;;GAKG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAA;IACtB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB;AAED;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IAClC;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;IAC5B;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACxC;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAC5B;AAED;;;;GAIG;AACH,MAAM,WAAW,uBAAuB;IACtC;;;OAGG;IACH,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAA;IACtB;;;OAGG;IACH,MAAM,CAAC,EAAE,sBAAsB,CAAA;IAC/B;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB;;OAEG;IACH,UAAU,CAAC,EAAE,mBAAmB,CAAA;CACjC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,qBAAa,gBAAgB;IAC3B;;;;;;;;;;;;;;;OAeG;WACU,MAAM,CAAC,OAAO,SAAS,YAAY,GAAG,YAAY,EAC7D,SAAS,EAAE,qBAAqB,CAAC,OAAO,CAAC,EACzC,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC,iBAAiB,CAAC,cAAc,CAAC,CAAC;CA4D9C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"help.command.d.mts","sourceRoot":"","sources":["../../../src/commands/help.command.mts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"help.command.d.mts","sourceRoot":"","sources":["../../../src/commands/help.command.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAMvB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6CAA6C,CAAA;AAEjF,QAAA,MAAM,iBAAiB;;iBAErB,CAAA;AAEF,KAAK,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAA;AAEpD;;;;GAIG;AACH,qBAMa,WAAY,YAAW,cAAc,CAAC,WAAW,CAAC;IAC7D,OAAO,CAAC,MAAM,CAA2C;IACzD,OAAO,CAAC,eAAe,CAAiC;IAElD,OAAO,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;CAOnD"}
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { InjectionToken } from '@navios/core';
|
|
2
|
+
import type { ClassType, ClassTypeWithInstance, Registry } from '@navios/core';
|
|
2
3
|
import type { ZodObject } from 'zod';
|
|
4
|
+
import type { CommandHandler } from '../interfaces/index.mjs';
|
|
3
5
|
/**
|
|
4
6
|
* Options for the `@Command` decorator.
|
|
5
7
|
*
|
|
6
8
|
* @public
|
|
7
9
|
*/
|
|
8
10
|
export interface CommandOptions {
|
|
11
|
+
/**
|
|
12
|
+
* The token to use for the command.
|
|
13
|
+
* If provided, the command will be registered with this token.
|
|
14
|
+
*/
|
|
15
|
+
token?: InjectionToken<ClassTypeWithInstance<CommandHandler<any>>>;
|
|
9
16
|
/**
|
|
10
17
|
* The command path that users will invoke from the CLI.
|
|
11
18
|
* Can be a single word (e.g., 'greet') or multi-word with colons (e.g., 'user:create', 'db:migrate').
|
|
@@ -62,5 +69,5 @@ export interface CommandOptions {
|
|
|
62
69
|
* }
|
|
63
70
|
* ```
|
|
64
71
|
*/
|
|
65
|
-
export declare function Command({ path, description, optionsSchema, priority, registry, }: CommandOptions): (target: ClassType, context: ClassDecoratorContext) =>
|
|
72
|
+
export declare function Command({ path, description, token, optionsSchema, priority, registry, }: CommandOptions): (target: ClassType, context: ClassDecoratorContext) => any;
|
|
66
73
|
//# sourceMappingURL=command.decorator.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.decorator.d.mts","sourceRoot":"","sources":["../../../src/decorators/command.decorator.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"command.decorator.d.mts","sourceRoot":"","sources":["../../../src/decorators/command.decorator.mts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,cAAc,EAAE,MAAM,cAAc,CAAA;AAE1E,OAAO,KAAK,EAAE,SAAS,EAAE,qBAAqB,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAC9E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAA;AAIpC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAE7D;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,KAAK,CAAC,EAAE,cAAc,CAAC,qBAAqB,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;IAClE;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;;OAGG;IACH,aAAa,CAAC,EAAE,SAAS,CAAA;IACzB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;;OAGG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAA;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,OAAO,CAAC,EACtB,IAAI,EACJ,WAAW,EACX,KAAK,EACL,aAAa,EACb,QAAQ,EACR,QAAQ,GACT,EAAE,cAAc,IACE,QAAQ,SAAS,EAAE,SAAS,qBAAqB,SAkBnE"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ClassType } from '@navios/core';
|
|
2
|
+
import { type CliModuleOptions } from '../../decorators/cli-module.decorator.mjs';
|
|
3
|
+
export type { CliModuleOptions };
|
|
4
|
+
/**
|
|
5
|
+
* Legacy-compatible CliModule decorator.
|
|
6
|
+
*
|
|
7
|
+
* Works with TypeScript experimental decorators (legacy API).
|
|
8
|
+
*
|
|
9
|
+
* @param options - CLI module configuration options
|
|
10
|
+
* @returns A class decorator compatible with legacy decorator API
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import { CliModule } from '@navios/commander/legacy-compat'
|
|
15
|
+
* import { GreetCommand } from './greet.command'
|
|
16
|
+
* import { UserModule } from './user.module'
|
|
17
|
+
*
|
|
18
|
+
* @CliModule({
|
|
19
|
+
* commands: [GreetCommand],
|
|
20
|
+
* imports: [UserModule]
|
|
21
|
+
* })
|
|
22
|
+
* export class AppModule {}
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare function CliModule(options?: CliModuleOptions): (target: ClassType) => ClassType;
|
|
26
|
+
//# sourceMappingURL=cli-module.decorator.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-module.decorator.d.mts","sourceRoot":"","sources":["../../../../src/legacy-compat/decorators/cli-module.decorator.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAG7C,OAAO,EAEL,KAAK,gBAAgB,EACtB,MAAM,2CAA2C,CAAA;AAElD,YAAY,EAAE,gBAAgB,EAAE,CAAA;AAEhC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,SAAS,CACvB,OAAO,GAAE,gBAMR,IAEgB,QAAQ,SAAS,eAKnC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ClassType } from '@navios/core';
|
|
2
|
+
import { type CommandOptions } from '../../decorators/command.decorator.mjs';
|
|
3
|
+
export type { CommandOptions };
|
|
4
|
+
/**
|
|
5
|
+
* Legacy-compatible Command decorator.
|
|
6
|
+
*
|
|
7
|
+
* Works with TypeScript experimental decorators (legacy API).
|
|
8
|
+
*
|
|
9
|
+
* @param options - Command configuration options
|
|
10
|
+
* @returns A class decorator compatible with legacy decorator API
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import { Command, CommandHandler } from '@navios/commander/legacy-compat'
|
|
15
|
+
* import { z } from 'zod'
|
|
16
|
+
*
|
|
17
|
+
* const optionsSchema = z.object({
|
|
18
|
+
* name: z.string(),
|
|
19
|
+
* greeting: z.string().optional().default('Hello')
|
|
20
|
+
* })
|
|
21
|
+
*
|
|
22
|
+
* @Command({
|
|
23
|
+
* path: 'greet',
|
|
24
|
+
* optionsSchema: optionsSchema
|
|
25
|
+
* })
|
|
26
|
+
* export class GreetCommand implements CommandHandler<z.infer<typeof optionsSchema>> {
|
|
27
|
+
* async execute(options) {
|
|
28
|
+
* console.log(`${options.greeting}, ${options.name}!`)
|
|
29
|
+
* }
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare function Command(options: CommandOptions): (target: ClassType) => any;
|
|
34
|
+
//# sourceMappingURL=command.decorator.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.decorator.d.mts","sourceRoot":"","sources":["../../../../src/legacy-compat/decorators/command.decorator.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAG7C,OAAO,EAEL,KAAK,cAAc,EACpB,MAAM,wCAAwC,CAAA;AAE/C,YAAY,EAAE,cAAc,EAAE,CAAA;AAE9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,cAAc,IAC5B,QAAQ,SAAS,SAKnC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../../src/legacy-compat/decorators/index.mts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAA;AACvC,cAAc,4BAA4B,CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Legacy-compatible decorators for projects using TypeScript experimental decorators.
|
|
3
|
+
*
|
|
4
|
+
* These decorators wrap the Stage 3 decorator implementations and convert
|
|
5
|
+
* the legacy decorator arguments to Stage 3 format internally.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { Command, CliModule, CommandHandler } from '@navios/commander/legacy-compat'
|
|
10
|
+
*
|
|
11
|
+
* @Command({ path: 'greet' })
|
|
12
|
+
* export class GreetCommand implements CommandHandler {
|
|
13
|
+
* async execute() {
|
|
14
|
+
* console.log('Hello!')
|
|
15
|
+
* }
|
|
16
|
+
* }
|
|
17
|
+
*
|
|
18
|
+
* @CliModule({
|
|
19
|
+
* commands: [GreetCommand],
|
|
20
|
+
* })
|
|
21
|
+
* export class AppModule {}
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @packageDocumentation
|
|
25
|
+
*/
|
|
26
|
+
export * from './decorators/index.mjs';
|
|
27
|
+
export * from '@navios/core/legacy-compat';
|
|
28
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/legacy-compat/index.mts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAGH,cAAc,wBAAwB,CAAA;AAGtC,cAAc,4BAA4B,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { CommandHandler } from '../interfaces/command-handler.interface.mjs';
|
|
3
|
+
declare const helpOptionsSchema: z.ZodObject<{
|
|
4
|
+
command: z.ZodOptional<z.ZodString>;
|
|
5
|
+
}, z.core.$strip>;
|
|
6
|
+
type HelpOptions = z.infer<typeof helpOptionsSchema>;
|
|
7
|
+
/**
|
|
8
|
+
* Built-in help command that lists all available commands or shows help for a specific command.
|
|
9
|
+
*
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export declare class HelpCommand implements CommandHandler<HelpOptions> {
|
|
13
|
+
private logger;
|
|
14
|
+
private commandRegistry;
|
|
15
|
+
execute(options: HelpOptions): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=help.command.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help.command.d.mts","sourceRoot":"","sources":["../../../src/overrides/help.command.mts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAMvB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6CAA6C,CAAA;AAEjF,QAAA,MAAM,iBAAiB;;iBAErB,CAAA;AAEF,KAAK,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAA;AAEpD;;;;GAIG;AACH,qBAOa,WAAY,YAAW,cAAc,CAAC,WAAW,CAAC;IAC7D,OAAO,CAAC,MAAM,CAAoF;IAClG,OAAO,CAAC,eAAe,CAAiC;IAElD,OAAO,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;CAOnD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help-command.token.d.mts","sourceRoot":"","sources":["../../../src/tokens/help-command.token.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAE7C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAA;AAEhE,eAAO,MAAM,gBAAgB,+CAAoD,CAAA"}
|