@navios/commander 1.1.0 → 1.3.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 +18 -0
- package/README.md +72 -0
- package/dist/src/commander.factory.d.mts +5 -0
- package/dist/src/commander.factory.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/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-BPEgaaxY.mjs → help-command.token-C0Kgj60o.mjs} +3 -134
- package/lib/help-command.token-C0Kgj60o.mjs.map +1 -0
- package/lib/{help-command.token-DcvTjwbA.cjs → help-command.token-CMWYI6em.cjs} +1 -174
- package/lib/help-command.token-CMWYI6em.cjs.map +1 -0
- package/lib/{help.command-D9lsIDIe.cjs → help.command-DQyv6ali.cjs} +4 -3
- package/lib/{help.command-DtokRzad.mjs.map → help.command-DQyv6ali.cjs.map} +1 -1
- package/lib/{help.command-DtokRzad.mjs → help.command-dtZbhq0w.mjs} +3 -2
- package/lib/{help.command-D9lsIDIe.cjs.map → help.command-dtZbhq0w.mjs.map} +1 -1
- package/lib/index.cjs +19 -76
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +7 -209
- package/lib/index.d.cts.map +1 -1
- package/lib/index.d.mts +7 -407
- package/lib/index.d.mts.map +1 -1
- package/lib/index.mjs +7 -64
- 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 +11 -1
- package/src/commander.factory.mts +10 -0
- 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/tsdown.config.mts +1 -1
- package/lib/help-command.token-BPEgaaxY.mjs.map +0 -1
- package/lib/help-command.token-DcvTjwbA.cjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,24 @@ 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.3.0] - 2026-01-13
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **TUI Adapter Selection** - New `adapter` option in `CommanderTuiOptions` to choose the TUI framework
|
|
13
|
+
- `'react'` (default) - Uses React-based TUI components
|
|
14
|
+
- `'solid'` - Uses Solid.js-based TUI components
|
|
15
|
+
- Dynamically imports the appropriate adapter module
|
|
16
|
+
|
|
17
|
+
## [1.2.0] - 2026-01-11
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
|
|
21
|
+
- **Legacy Compatibility Module** - New `@navios/commander/legacy-compat` subpath export for projects using TypeScript experimental decorators
|
|
22
|
+
- `Command` decorator wrapper that converts legacy decorator API to Stage 3 format
|
|
23
|
+
- `CliModule` decorator wrapper for legacy compatibility
|
|
24
|
+
- Re-exports `@navios/core/legacy-compat` utilities for convenience
|
|
25
|
+
|
|
8
26
|
## [1.1.0] - 2026-01-10
|
|
9
27
|
|
|
10
28
|
### Added
|
package/README.md
CHANGED
|
@@ -312,6 +312,78 @@ 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
|
+
## TUI Mode
|
|
316
|
+
|
|
317
|
+
Commander supports an optional Terminal User Interface (TUI) mode for rich, interactive CLI experiences.
|
|
318
|
+
|
|
319
|
+
### Enabling TUI
|
|
320
|
+
|
|
321
|
+
```typescript
|
|
322
|
+
import { CommanderFactory } from '@navios/commander'
|
|
323
|
+
|
|
324
|
+
const app = await CommanderFactory.create(AppModule, {
|
|
325
|
+
enableTUI: true,
|
|
326
|
+
tuiOptions: {
|
|
327
|
+
theme: 'dark',
|
|
328
|
+
autoClose: { enabled: true, delay: 3000 },
|
|
329
|
+
},
|
|
330
|
+
})
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
### Choosing a Framework Adapter
|
|
334
|
+
|
|
335
|
+
The TUI supports both React and Solid.js rendering frameworks:
|
|
336
|
+
|
|
337
|
+
```typescript
|
|
338
|
+
const app = await CommanderFactory.create(AppModule, {
|
|
339
|
+
enableTUI: true,
|
|
340
|
+
tuiOptions: {
|
|
341
|
+
adapter: 'react', // 'react' (default) or 'solid'
|
|
342
|
+
theme: 'dark',
|
|
343
|
+
},
|
|
344
|
+
})
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
For Solid.js support, install the optional dependency:
|
|
348
|
+
|
|
349
|
+
```bash
|
|
350
|
+
npm install solid-js
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
### TUI Options
|
|
354
|
+
|
|
355
|
+
- `adapter` - Framework adapter: `'react'` (default) or `'solid'`
|
|
356
|
+
- `theme` - Theme preset: `'dark'`, `'light'`, or `'high-contrast'`
|
|
357
|
+
- `exitOnCtrlC` - Exit on Ctrl+C (default: `true`)
|
|
358
|
+
- `sidebarWidth` - Sidebar width in columns
|
|
359
|
+
- `sidebarPosition` - Sidebar position: `'left'` or `'right'`
|
|
360
|
+
- `sidebarTitle` - Sidebar title text
|
|
361
|
+
- `autoClose` - Auto-close configuration with `enabled` and `delay`
|
|
362
|
+
- `useMouse` - Enable mouse support (default: `true`)
|
|
363
|
+
- `hideDefaultScreen` - Hide the default screen
|
|
364
|
+
|
|
365
|
+
## Legacy Decorator Support
|
|
366
|
+
|
|
367
|
+
If your project uses TypeScript experimental decorators (legacy mode), you can import from the `legacy-compat` subpath:
|
|
368
|
+
|
|
369
|
+
```typescript
|
|
370
|
+
import { Command, CliModule, CommandHandler } from '@navios/commander/legacy-compat'
|
|
371
|
+
|
|
372
|
+
@Command({ path: 'greet' })
|
|
373
|
+
export class GreetCommand implements CommandHandler {
|
|
374
|
+
async execute() {
|
|
375
|
+
console.log('Hello!')
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
@CliModule({
|
|
380
|
+
commands: [GreetCommand],
|
|
381
|
+
})
|
|
382
|
+
export class AppModule {}
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
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.
|
|
386
|
+
|
|
315
387
|
## License
|
|
316
388
|
|
|
317
389
|
MIT
|
|
@@ -1 +1 @@
|
|
|
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,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AAmB;IAClC;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAA;IAC3B;;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;CAiE9C"}
|
|
@@ -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"}
|