@navios/commander 1.0.0 → 1.1.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.
Files changed (42) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/src/commander.factory.d.mts +59 -0
  3. package/dist/src/commander.factory.d.mts.map +1 -1
  4. package/dist/src/commands/help.command.d.mts.map +1 -1
  5. package/dist/src/decorators/command.decorator.d.mts +9 -2
  6. package/dist/src/decorators/command.decorator.d.mts.map +1 -1
  7. package/dist/src/overrides/help.command.d.mts +18 -0
  8. package/dist/src/overrides/help.command.d.mts.map +1 -0
  9. package/dist/src/tokens/help-command.token.d.mts +4 -0
  10. package/dist/src/tokens/help-command.token.d.mts.map +1 -0
  11. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  12. package/dist/tsconfig.tsbuildinfo +1 -1
  13. package/lib/help-command.token-BPEgaaxY.mjs +558 -0
  14. package/lib/help-command.token-BPEgaaxY.mjs.map +1 -0
  15. package/lib/help-command.token-DcvTjwbA.cjs +611 -0
  16. package/lib/help-command.token-DcvTjwbA.cjs.map +1 -0
  17. package/lib/help.command-D9lsIDIe.cjs +316 -0
  18. package/lib/help.command-D9lsIDIe.cjs.map +1 -0
  19. package/lib/help.command-DtokRzad.mjs +317 -0
  20. package/lib/help.command-DtokRzad.mjs.map +1 -0
  21. package/lib/index.cjs +43 -566
  22. package/lib/index.cjs.map +1 -1
  23. package/lib/index.d.cts +184 -119
  24. package/lib/index.d.cts.map +1 -1
  25. package/lib/index.d.mts +184 -119
  26. package/lib/index.d.mts.map +1 -1
  27. package/lib/index.mjs +28 -551
  28. package/lib/index.mjs.map +1 -1
  29. package/package.json +10 -3
  30. package/src/commander.factory.mts +107 -8
  31. package/src/commands/help.command.mts +4 -3
  32. package/src/decorators/command.decorator.mts +17 -8
  33. package/src/overrides/help.command.mts +40 -0
  34. package/src/tokens/help-command.token.mts +5 -0
  35. package/tsconfig.json +0 -3
  36. package/tsconfig.spec.json +1 -1
  37. package/dist/src/commander.application.d.mts +0 -147
  38. package/dist/src/commander.application.d.mts.map +0 -1
  39. package/dist/src/metadata/cli-module.metadata.d.mts +0 -60
  40. package/dist/src/metadata/cli-module.metadata.d.mts.map +0 -1
  41. package/dist/src/services/module-loader.service.d.mts +0 -74
  42. package/dist/src/services/module-loader.service.d.mts.map +0 -1
package/CHANGELOG.md CHANGED
@@ -5,6 +5,32 @@ 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.1.0] - 2026-01-10
9
+
10
+ ### Added
11
+
12
+ - **TUI Mode Support** - New `enableTUI` option in `CommanderFactory.create()` to enable terminal UI mode
13
+ - Dynamically imports `@navios/commander-tui` when enabled
14
+ - Auto-binds `ScreenManager` with configurable options
15
+ - Falls back to standard console logger when TUI is disabled
16
+ - **TUI Options** - New `CommanderTuiOptions` interface for TUI-specific configuration
17
+ - `exitOnCtrlC`, `sidebarWidth`, `sidebarPosition`, `sidebarTitle`
18
+ - `autoClose` with configurable delay
19
+ - `theme` support (preset name or custom object)
20
+ - `useMouse` and `hideDefaultScreen` options
21
+ - **Log Levels Configuration** - New `logLevels` option in `CommanderFactoryOptions`
22
+ - **Command Token Option** - New `token` option in `@Command()` decorator for custom injection tokens
23
+ - **Help Command Token** - New `HelpCommandToken` for overriding the built-in help command
24
+
25
+ ### Changed
26
+
27
+ - **Optional TUI Dependency** - `@navios/commander-tui` is now an optional peer dependency
28
+ - **Command Decorator** - Internal token handling refactored to support custom tokens
29
+
30
+ ### Dependencies
31
+
32
+ - Added optional peer dependency: `@navios/commander-tui` ^1.0.0
33
+
8
34
  ## [1.0.0] - 2026-01-09
9
35
 
10
36
  ### Added
@@ -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":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,QAAQ,EACR,iBAAiB,EACjB,YAAY,EACb,MAAM,cAAc,CAAA;AAIrB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAA;AAI5E;;;;;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;;;;GAIG;AACH,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,MAAM,CAAC,EAAE,sBAAsB,CAAA;CAChC;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;CAgB9C"}
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,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,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":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6CAA6C,CAAA;AAKjF,QAAA,MAAM,iBAAiB;;iBAErB,CAAA;AAEF,KAAK,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAA;AAEpD;;;;GAIG;AACH,qBAKa,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
+ {"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 type { ClassType, Registry } from '@navios/core';
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) => ClassType;
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;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAA;AAMpC;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B;;;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,aAAa,EACb,QAAQ,EACR,QAAQ,GACT,EAAE,cAAc,IACE,QAAQ,SAAS,EAAE,SAAS,qBAAqB,eAiBnE"}
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,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,4 @@
1
+ import { InjectionToken } from '@navios/core';
2
+ import type { HelpCommand } from '../overrides/help.command.mjs';
3
+ export declare const HelpCommandToken: InjectionToken<HelpCommand, undefined, false>;
4
+ //# sourceMappingURL=help-command.token.d.mts.map
@@ -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"}