@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.
Files changed (119) hide show
  1. package/.turbo/turbo-build.log +49 -0
  2. package/.turbo/turbo-check.log +2 -0
  3. package/.turbo/turbo-lint.log +3 -0
  4. package/.turbo/turbo-test$colon$ci.log +117 -0
  5. package/CHANGELOG.md +3 -3
  6. package/README.md +8 -16
  7. package/dist/src/commander.factory.d.mts +126 -122
  8. package/dist/src/commander.factory.d.mts.map +1 -1
  9. package/dist/src/commands/help.command.d.mts +15 -11
  10. package/dist/src/commands/help.command.d.mts.map +1 -1
  11. package/dist/src/commands/index.d.mts +2 -2
  12. package/dist/src/decorators/cli-module.decorator.d.mts +51 -40
  13. package/dist/src/decorators/cli-module.decorator.d.mts.map +1 -1
  14. package/dist/src/decorators/command.decorator.d.mts +49 -37
  15. package/dist/src/decorators/command.decorator.d.mts.map +1 -1
  16. package/dist/src/decorators/index.d.mts +3 -3
  17. package/dist/src/define-environment.d.mts +9 -8
  18. package/dist/src/define-environment.d.mts.map +1 -1
  19. package/dist/src/index.d.mts +10 -10
  20. package/dist/src/interfaces/abstract-cli-adapter.interface.d.mts +45 -45
  21. package/dist/src/interfaces/command-handler.interface.d.mts +9 -9
  22. package/dist/src/interfaces/commander-execution-context.interface.d.mts +30 -30
  23. package/dist/src/interfaces/commander-execution-context.interface.d.mts.map +1 -1
  24. package/dist/src/interfaces/environment.interface.d.mts +7 -7
  25. package/dist/src/interfaces/index.d.mts +5 -5
  26. package/dist/src/legacy-compat/decorators/cli-module.decorator.d.mts +6 -5
  27. package/dist/src/legacy-compat/decorators/cli-module.decorator.d.mts.map +1 -1
  28. package/dist/src/legacy-compat/decorators/command.decorator.d.mts +7 -6
  29. package/dist/src/legacy-compat/decorators/command.decorator.d.mts.map +1 -1
  30. package/dist/src/legacy-compat/decorators/index.d.mts +3 -3
  31. package/dist/src/legacy-compat/index.d.mts +3 -3
  32. package/dist/src/metadata/command-entry.metadata.d.mts +5 -5
  33. package/dist/src/metadata/command-entry.metadata.d.mts.map +1 -1
  34. package/dist/src/metadata/command.metadata.d.mts +30 -24
  35. package/dist/src/metadata/command.metadata.d.mts.map +1 -1
  36. package/dist/src/metadata/index.d.mts +3 -3
  37. package/dist/src/overrides/help.command.d.mts +15 -11
  38. package/dist/src/overrides/help.command.d.mts.map +1 -1
  39. package/dist/src/services/cli-parser.service.d.mts +54 -54
  40. package/dist/src/services/cli-parser.service.d.mts.map +1 -1
  41. package/dist/src/services/command-registry.service.d.mts +75 -74
  42. package/dist/src/services/command-registry.service.d.mts.map +1 -1
  43. package/dist/src/services/commander-adapter.service.d.mts +49 -48
  44. package/dist/src/services/commander-adapter.service.d.mts.map +1 -1
  45. package/dist/src/services/index.d.mts +4 -4
  46. package/dist/src/tokens/execution-context.token.d.mts +9 -4
  47. package/dist/src/tokens/execution-context.token.d.mts.map +1 -1
  48. package/dist/src/tokens/help-command.token.d.mts +5 -4
  49. package/dist/src/tokens/index.d.mts +2 -2
  50. package/dist/src/utils/index.d.mts +2 -2
  51. package/dist/src/utils/runtime.d.mts +2 -2
  52. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  53. package/dist/tsconfig.tsbuildinfo +1 -1
  54. package/dist/tsdown.config.d.mts +3 -3
  55. package/dist/vitest.config.d.mts +3 -3
  56. package/lib/{cli-module.decorator-CRaNGvgl.d.cts → cli-module.decorator-BzsOEMPH.d.cts} +54 -53
  57. package/lib/cli-module.decorator-BzsOEMPH.d.cts.map +1 -0
  58. package/lib/{cli-module.decorator-bsP5gEn7.d.mts → cli-module.decorator-CCV_elPP.d.mts} +116 -115
  59. package/lib/cli-module.decorator-CCV_elPP.d.mts.map +1 -0
  60. package/lib/{cli-module.decorator-CkP22084.cjs → cli-module.decorator-CXt38aqF.cjs} +2 -2
  61. package/lib/cli-module.decorator-CXt38aqF.cjs.map +1 -0
  62. package/lib/{cli-module.decorator-UGbtkRYc.mjs → cli-module.decorator-DAjf_r_W.mjs} +2 -2
  63. package/lib/cli-module.decorator-DAjf_r_W.mjs.map +1 -0
  64. package/lib/{command.decorator-UrNJmQN0.cjs → command.decorator-HziankUv.cjs} +3 -3
  65. package/lib/command.decorator-HziankUv.cjs.map +1 -0
  66. package/lib/{command.decorator-DVLSAqYZ.mjs → command.decorator-QiRU7ny3.mjs} +3 -3
  67. package/lib/command.decorator-QiRU7ny3.mjs.map +1 -0
  68. package/lib/{help-command.token-CMWYI6em.cjs → help-command.token-DamE31Aw.cjs} +4 -4
  69. package/lib/{help-command.token-CMWYI6em.cjs.map → help-command.token-DamE31Aw.cjs.map} +1 -1
  70. package/lib/{help-command.token-C0Kgj60o.mjs → help-command.token-XHx3WkoD.mjs} +4 -4
  71. package/lib/{help-command.token-C0Kgj60o.mjs.map → help-command.token-XHx3WkoD.mjs.map} +1 -1
  72. package/lib/{help.command-dtZbhq0w.mjs → help.command-Bynoll_7.mjs} +5 -8
  73. package/lib/help.command-Bynoll_7.mjs.map +1 -0
  74. package/lib/{help.command-DQyv6ali.cjs → help.command-DvKmMpB7.cjs} +6 -9
  75. package/lib/help.command-DvKmMpB7.cjs.map +1 -0
  76. package/lib/index.cjs +102 -102
  77. package/lib/index.cjs.map +1 -1
  78. package/lib/index.d.cts +283 -283
  79. package/lib/index.d.cts.map +1 -1
  80. package/lib/index.d.mts +221 -221
  81. package/lib/index.d.mts.map +1 -1
  82. package/lib/index.mjs +101 -101
  83. package/lib/index.mjs.map +1 -1
  84. package/lib/legacy-compat/index.cjs +6 -28
  85. package/lib/legacy-compat/index.cjs.map +1 -1
  86. package/lib/legacy-compat/index.d.cts +3 -2
  87. package/lib/legacy-compat/index.d.cts.map +1 -1
  88. package/lib/legacy-compat/index.d.mts +3 -2
  89. package/lib/legacy-compat/index.d.mts.map +1 -1
  90. package/lib/legacy-compat/index.mjs +4 -25
  91. package/lib/legacy-compat/index.mjs.map +1 -1
  92. package/package.json +26 -16
  93. package/src/__tests__/commander.factory.e2e.spec.mts +22 -66
  94. package/src/commands/help.command.mts +1 -1
  95. package/src/decorators/cli-module.decorator.mts +4 -9
  96. package/src/decorators/command.decorator.mts +4 -4
  97. package/src/define-environment.mts +4 -4
  98. package/src/interfaces/command-handler.interface.mts +1 -1
  99. package/src/interfaces/commander-execution-context.interface.mts +1 -1
  100. package/src/legacy-compat/decorators/cli-module.decorator.mts +2 -1
  101. package/src/legacy-compat/decorators/command.decorator.mts +3 -2
  102. package/src/metadata/command-entry.metadata.mts +3 -6
  103. package/src/metadata/command.metadata.mts +6 -8
  104. package/src/overrides/help.command.mts +2 -2
  105. package/src/services/__tests__/cli-parser.service.spec.mts +23 -178
  106. package/src/services/cli-parser.service.mts +23 -27
  107. package/src/services/command-registry.service.mts +5 -5
  108. package/src/services/commander-adapter.service.mts +10 -27
  109. package/src/tokens/execution-context.token.mts +4 -6
  110. package/tsconfig.json +3 -0
  111. package/lib/cli-module.decorator-CRaNGvgl.d.cts.map +0 -1
  112. package/lib/cli-module.decorator-CkP22084.cjs.map +0 -1
  113. package/lib/cli-module.decorator-UGbtkRYc.mjs.map +0 -1
  114. package/lib/cli-module.decorator-bsP5gEn7.d.mts.map +0 -1
  115. package/lib/command.decorator-DVLSAqYZ.mjs.map +0 -1
  116. package/lib/command.decorator-UrNJmQN0.cjs.map +0 -1
  117. package/lib/help.command-DQyv6ali.cjs.map +0 -1
  118. package/lib/help.command-dtZbhq0w.mjs.map +0 -1
  119. package/project.json +0 -66
@@ -0,0 +1,49 @@
1
+
2
+ ℹ tsdown v0.19.0 powered by rolldown v1.0.0-beta.59
3
+ ℹ config file: /Volumes/Dev/Projects/navios/commander/packages/commander/tsdown.config.mts
4
+ ℹ entry: src/index.mts, src/legacy-compat/index.mts
5
+ ℹ target: es2022
6
+ ℹ tsconfig: tsconfig.json
7
+ ℹ Build start
8
+ ℹ Cleaning 37 files
9
+ ℹ [CJS] lib/index.d.cts.map 29.35 kB │ gzip: 8.31 kB
10
+ ℹ [CJS] lib/cli-module.decorator-BzsOEMPH.d.cts.map  8.31 kB │ gzip: 2.71 kB
11
+ ℹ [CJS] lib/legacy-compat/index.d.cts.map  2.42 kB │ gzip: 0.82 kB
12
+ ℹ [CJS] lib/index.d.cts 20.64 kB │ gzip: 5.38 kB
13
+ ℹ [CJS] lib/legacy-compat/index.d.cts  1.94 kB │ gzip: 0.70 kB
14
+ ℹ [CJS] lib/cli-module.decorator-BzsOEMPH.d.cts  6.28 kB │ gzip: 1.96 kB
15
+ ℹ [CJS] 6 files, total: 68.94 kB
16
+ ℹ [CJS] lib/index.cjs 48.62 kB │ gzip: 7.97 kB
17
+ ℹ [CJS] lib/legacy-compat/index.cjs  2.53 kB │ gzip: 0.90 kB
18
+ ℹ [CJS] lib/index.cjs.map 43.31 kB │ gzip: 11.63 kB
19
+ ℹ [CJS] lib/help-command.token-DamE31Aw.cjs 14.04 kB │ gzip: 3.87 kB
20
+ ℹ [CJS] lib/help.command-DvKmMpB7.cjs 10.48 kB │ gzip: 2.87 kB
21
+ ℹ [CJS] lib/help-command.token-DamE31Aw.cjs.map  9.64 kB │ gzip: 3.30 kB
22
+ ℹ [CJS] lib/command.decorator-HziankUv.cjs.map  9.07 kB │ gzip: 2.85 kB
23
+ ℹ [CJS] lib/command.decorator-HziankUv.cjs  5.12 kB │ gzip: 1.57 kB
24
+ ℹ [CJS] lib/cli-module.decorator-CXt38aqF.cjs.map  4.77 kB │ gzip: 1.78 kB
25
+ ℹ [CJS] lib/legacy-compat/index.cjs.map  3.39 kB │ gzip: 1.04 kB
26
+ ℹ [CJS] lib/help.command-DvKmMpB7.cjs.map  2.50 kB │ gzip: 0.98 kB
27
+ ℹ [CJS] lib/cli-module.decorator-CXt38aqF.cjs  2.12 kB │ gzip: 0.96 kB
28
+ ℹ [CJS] 12 files, total: 155.59 kB
29
+ ✔ Build complete in 524ms
30
+ ℹ [ESM] lib/index.mjs 47.19 kB │ gzip: 7.82 kB
31
+ ℹ [ESM] lib/legacy-compat/index.mjs  2.13 kB │ gzip: 0.75 kB
32
+ ℹ [ESM] lib/index.mjs.map 43.35 kB │ gzip: 11.61 kB
33
+ ℹ [ESM] lib/index.d.mts.map 21.06 kB │ gzip: 6.49 kB
34
+ ℹ [ESM] lib/cli-module.decorator-CCV_elPP.d.mts.map 16.74 kB │ gzip: 4.96 kB
35
+ ℹ [ESM] lib/help-command.token-XHx3WkoD.mjs 13.81 kB │ gzip: 3.83 kB
36
+ ℹ [ESM] lib/help.command-Bynoll_7.mjs 10.34 kB │ gzip: 2.85 kB
37
+ ℹ [ESM] lib/help-command.token-XHx3WkoD.mjs.map  9.64 kB │ gzip: 3.29 kB
38
+ ℹ [ESM] lib/command.decorator-QiRU7ny3.mjs.map  9.08 kB │ gzip: 2.85 kB
39
+ ℹ [ESM] lib/cli-module.decorator-DAjf_r_W.mjs.map  4.79 kB │ gzip: 1.78 kB
40
+ ℹ [ESM] lib/command.decorator-QiRU7ny3.mjs  4.36 kB │ gzip: 1.49 kB
41
+ ℹ [ESM] lib/legacy-compat/index.mjs.map  3.40 kB │ gzip: 1.05 kB
42
+ ℹ [ESM] lib/help.command-Bynoll_7.mjs.map  2.51 kB │ gzip: 0.97 kB
43
+ ℹ [ESM] lib/legacy-compat/index.d.mts.map  2.42 kB │ gzip: 0.82 kB
44
+ ℹ [ESM] lib/cli-module.decorator-DAjf_r_W.mjs  1.98 kB │ gzip: 0.89 kB
45
+ ℹ [ESM] lib/index.d.mts 15.31 kB │ gzip: 4.45 kB
46
+ ℹ [ESM] lib/legacy-compat/index.d.mts  1.94 kB │ gzip: 0.70 kB
47
+ ℹ [ESM] lib/cli-module.decorator-CCV_elPP.d.mts 12.09 kB │ gzip: 3.35 kB
48
+ ℹ [ESM] 18 files, total: 222.13 kB
49
+ ✔ Build complete in 533ms
@@ -0,0 +1,2 @@
1
+
2
+ 
@@ -0,0 +1,3 @@
1
+
2
+ Found 0 warnings and 0 errors.
3
+ Finished in 26ms on 34 files with 90 rules using 16 threads.
@@ -0,0 +1,117 @@
1
+
2
+ [?25lTesting types with tsc and vue-tsc is an experimental feature.
3
+ Breaking changes might not follow SemVer, please pin Vitest's version when using it.
4
+
5
+  RUN  v4.0.17 /Volumes/Dev/Projects/navios/commander/packages/commander
6
+
7
+ [?2026h
8
+  ❯ src/services/__tests__/cli-parser.service.spec.mts [queued]
9
+
10
+  Test Files 0 passed (2)
11
+  Tests 0 passed (0)
12
+  Start at 03:26:05
13
+  Duration 0ms
14
+ [?2026l[?2026h ✓ src/services/__tests__/cli-parser.service.spec.mts (40 tests) 6ms
15
+
16
+  ❯ src/__tests__/commander.factory.e2e.spec.mts 0/36
17
+
18
+  Test Files 1 passed (2)
19
+  Tests 40 passed (76)
20
+  Start at 03:26:05
21
+  Duration 100ms
22
+ [?2026l  DEBUG [ModuleLoaderService]  Module TestModule_dy4bqj loaded
23
+   DEBUG [NaviosApplication]  Navios application initialized
24
+ stdout | src/__tests__/commander.factory.e2e.spec.mts > CommanderApplication E2E - run() with different argv > simple command without options > should execute command with minimal argv
25
+ Hello, World!
26
+
27
+   DEBUG [ModuleLoaderService]  Module TestModule_dy4bqj loaded
28
+   DEBUG [NaviosApplication]  Navios application initialized
29
+ stdout | src/__tests__/commander.factory.e2e.spec.mts > CommanderApplication E2E - run() with different argv > simple command without options > should execute command with absolute path in argv
30
+ Hello, World!
31
+
32
+   DEBUG [ModuleLoaderService]  Module TestModule_dy4bqj loaded
33
+   DEBUG [NaviosApplication]  Navios application initialized
34
+   DEBUG [ModuleLoaderService]  Module TestModule_dy4bqj loaded
35
+   DEBUG [NaviosApplication]  Navios application initialized
36
+   DEBUG [ModuleLoaderService]  Module DeployModule_clcbp1 loaded
37
+   DEBUG [NaviosApplication]  Navios application initialized
38
+   DEBUG [ModuleLoaderService]  Module BuildModule_fdlhzv loaded
39
+   DEBUG [NaviosApplication]  Navios application initialized
40
+   DEBUG [ModuleLoaderService]  Module TestModule_dy4bqj loaded
41
+   DEBUG [NaviosApplication]  Navios application initialized
42
+   DEBUG [ModuleLoaderService]  Module TestModule_dy4bqj loaded
43
+   DEBUG [NaviosApplication]  Navios application initialized
44
+   DEBUG [ModuleLoaderService]  Module TestModule_dy4bqj loaded
45
+   DEBUG [NaviosApplication]  Navios application initialized
46
+   DEBUG [ModuleLoaderService]  Module TestModule_dy4bqj loaded
47
+   DEBUG [NaviosApplication]  Navios application initialized
48
+   DEBUG [ModuleLoaderService]  Module TestModule_dy4bqj loaded
49
+   DEBUG [NaviosApplication]  Navios application initialized
50
+   DEBUG [ModuleLoaderService]  Module TestModule_dy4bqj loaded
51
+   DEBUG [NaviosApplication]  Navios application initialized
52
+   DEBUG [ModuleLoaderService]  Module TestModule_dy4bqj loaded
53
+   DEBUG [NaviosApplication]  Navios application initialized
54
+   DEBUG [ModuleLoaderService]  Module TestModule_dy4bqj loaded
55
+   DEBUG [NaviosApplication]  Navios application initialized
56
+   DEBUG [ModuleLoaderService]  Module TestModule_dy4bqj loaded
57
+   DEBUG [NaviosApplication]  Navios application initialized
58
+   DEBUG [ModuleLoaderService]  Module TestModule_dy4bqj loaded
59
+   DEBUG [NaviosApplication]  Navios application initialized
60
+   DEBUG [ModuleLoaderService]  Module TestModule_dy4bqj loaded
61
+   DEBUG [NaviosApplication]  Navios application initialized
62
+   DEBUG [ModuleLoaderService]  Module RollbackModule_bva5p1 loaded
63
+   DEBUG [NaviosApplication]  Navios application initialized
64
+   DEBUG [ModuleLoaderService]  Module TestModule_dy4bqj loaded
65
+   DEBUG [NaviosApplication]  Navios application initialized
66
+   ERROR [Commander]  Error: [Navios Commander] Command not found: invalid
67
+   LOG [Commander]  
68
+   LOG [Commander]  Available commands:
69
+
70
+ help Show available commands or help for a specific command
71
+ valid
72
+   DEBUG [ModuleLoaderService]  Module TestModule_dy4bqj loaded
73
+   DEBUG [NaviosApplication]  Navios application initialized
74
+   ERROR [Commander]  Error: [Navios Commander] No command provided
75
+   DEBUG [ModuleLoaderService]  Module TestModule_dy4bqj loaded
76
+   DEBUG [NaviosApplication]  Navios application initialized
77
+   DEBUG [ModuleLoaderService]  Module TestModule_dy4bqj loaded
78
+   DEBUG [NaviosApplication]  Navios application initialized
79
+   DEBUG [ModuleLoaderService]  Module TestModule_dy4bqj loaded
80
+   DEBUG [NaviosApplication]  Navios application initialized
81
+   DEBUG [ModuleLoaderService]  Module TestModule_dy4bqj loaded
82
+   DEBUG [NaviosApplication]  Navios application initialized
83
+   DEBUG [ModuleLoaderService]  Module TestModule_dy4bqj loaded
84
+   DEBUG [NaviosApplication]  Navios application initialized
85
+   DEBUG [ModuleLoaderService]  Module TestModule_dy4bqj loaded
86
+   DEBUG [NaviosApplication]  Navios application initialized
87
+   DEBUG [ModuleLoaderService]  Module TestModule_dy4bqj loaded
88
+   DEBUG [NaviosApplication]  Navios application initialized
89
+   DEBUG [ModuleLoaderService]  Module JsonModule_5wfcr9 loaded
90
+   DEBUG [NaviosApplication]  Navios application initialized
91
+   DEBUG [ModuleLoaderService]  Module TestModule_dy4bqj loaded
92
+   DEBUG [NaviosApplication]  Navios application initialized
93
+   DEBUG [ModuleLoaderService]  Module TestModule_dy4bqj loaded
94
+   DEBUG [NaviosApplication]  Navios application initialized
95
+   DEBUG [ModuleLoaderService]  Module TestModule_dy4bqj loaded
96
+   DEBUG [NaviosApplication]  Navios application initialized
97
+   DEBUG [ModuleLoaderService]  Module TestModule_dy4bqj loaded
98
+   DEBUG [NaviosApplication]  Navios application initialized
99
+   DEBUG [ModuleLoaderService]  Module UserModule_sf0k39 loaded
100
+   DEBUG [ModuleLoaderService]  Module AdminModule_v7hlb7 loaded
101
+   DEBUG [ModuleLoaderService]  Module AppModule_fuvatb loaded
102
+   DEBUG [NaviosApplication]  Navios application initialized
103
+   DEBUG [ModuleLoaderService]  Module AppModule_fuvatb loaded
104
+   DEBUG [NaviosApplication]  Navios application initialized
105
+   DEBUG [ModuleLoaderService]  Module AppModule_fuvatb loaded
106
+   DEBUG [NaviosApplication]  Navios application initialized
107
+   DEBUG [ModuleLoaderService]  Module AppModule_fuvatb loaded
108
+   DEBUG [NaviosApplication]  Navios application initialized
109
+ ✓ src/__tests__/commander.factory.e2e.spec.mts (36 tests) 21ms
110
+
111
+  Test Files  2 passed (2)
112
+  Tests  76 passed (76)
113
+ Type Errors  no errors
114
+  Start at  03:26:05
115
+  Duration  199ms (transform 98ms, setup 0ms, import 190ms, tests 28ms, environment 0ms)
116
+
117
+ [?25h
package/CHANGELOG.md CHANGED
@@ -77,7 +77,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77
77
 
78
78
  - **Stable Release**: First stable release of @navios/commander
79
79
  - Production-ready CLI command framework for Navios
80
- - Type-safe command definitions with Zod validation
80
+ - Type-safe command definitions with zod/v4 validation
81
81
  - Seamless integration with Navios dependency injection
82
82
 
83
83
  ## [1.0.0-alpha.4] - 2026-01-09
@@ -94,8 +94,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
94
94
  - Descriptions displayed in `--help` output
95
95
  - **Built-in Help Command**: Automatic `help` command with `--help` flag support
96
96
  - Shows all available commands with descriptions
97
- - Per-command help with option details from Zod schema metadata
98
- - Supports `.meta({ description: '...' })` on Zod fields for option descriptions
97
+ - Per-command help with option details from zod/v4 schema metadata
98
+ - Supports `.meta({ description: '...' })` on zod/v4 fields for option descriptions
99
99
  - **Command Registry Service**: New `CommandRegistryService` for managing registered commands
100
100
  - Replaces module-level command tracking
101
101
  - Provides `register()`, `getByPath()`, `getAllAsArray()`, and `clear()` methods
package/README.md CHANGED
@@ -5,16 +5,16 @@ A CLI command framework built on `@navios/core` that provides a decorator-based
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
- npm install @navios/commander zod
8
+ npm install @navios/commander zod/v4
9
9
  ```
10
10
 
11
11
  ## Features
12
12
 
13
13
  - **Decorator-based**: Use `@Command` and `@CliModule` decorators to define commands and modules
14
14
  - **Dependency Injection**: Full DI support via `@navios/core` with request-scoped command execution
15
- - **Schema Validation**: Built-in support for Zod schemas to validate command options
15
+ - **Schema Validation**: Built-in support for zod/v4 schemas to validate command options
16
16
  - **Modular Architecture**: Organize commands into modules with imports support
17
- - **Built-in Help**: Automatic `help` command and `--help` flag support with Zod meta descriptions
17
+ - **Built-in Help**: Automatic `help` command and `--help` flag support with zod/v4 meta descriptions
18
18
 
19
19
  ## Usage
20
20
 
@@ -25,7 +25,7 @@ Commands are defined using the `@Command` decorator. Each command must implement
25
25
  ```typescript
26
26
  import { Command, CommandHandler } from '@navios/commander'
27
27
 
28
- import { z } from 'zod'
28
+ import { z } from 'zod/v4'
29
29
 
30
30
  const greetOptionsSchema = z.object({
31
31
  name: z.string().meta({ description: 'Name of the person to greet' }),
@@ -95,15 +95,9 @@ node dist/cli.js greet --name World --greeting Hi
95
95
  ### Advanced Example with Dependency Injection
96
96
 
97
97
  ```typescript
98
- import {
99
- CliModule,
100
- Command,
101
- CommandHandler,
102
- inject,
103
- Injectable,
104
- } from '@navios/commander'
98
+ import { CliModule, Command, CommandHandler, inject, Injectable } from '@navios/commander'
105
99
 
106
- import { z } from 'zod'
100
+ import { z } from 'zod/v4'
107
101
 
108
102
  // Service
109
103
  @Injectable()
@@ -122,9 +116,7 @@ const userOptionsSchema = z.object({
122
116
  path: 'user:show',
123
117
  optionsSchema: userOptionsSchema,
124
118
  })
125
- export class ShowUserCommand implements CommandHandler<
126
- z.infer<typeof userOptionsSchema>
127
- > {
119
+ export class ShowUserCommand implements CommandHandler<z.infer<typeof userOptionsSchema>> {
128
120
  private userService = inject(UserService)
129
121
 
130
122
  async execute(options: { userId: string }) {
@@ -247,7 +239,7 @@ Defines a CLI command.
247
239
 
248
240
  - `path: string` - The command path (e.g., 'user:create', 'db:migrate')
249
241
  - `description?: string` - Optional description for help text
250
- - `optionsSchema?: ZodSchema` - Optional Zod schema for validating command options
242
+ - `optionsSchema?: zod/v4Schema` - Optional zod/v4 schema for validating command options
251
243
 
252
244
  #### `@CliModule(options)`
253
245
 
@@ -1,5 +1,6 @@
1
- import type { ClassTypeWithInstance, LogLevel, NaviosApplication, NaviosModule } from '@navios/core';
2
- import type { CliEnvironment } from './interfaces/environment.interface.mjs';
1
+ import type { ClassTypeWithInstance, LogLevel, NaviosApplication, NaviosModule } from '@navios/core'
2
+
3
+ import type { CliEnvironment } from './interfaces/environment.interface.mjs'
3
4
  /**
4
5
  * Logger display options for CLI applications.
5
6
  * All options default to false for cleaner CLI output.
@@ -7,41 +8,41 @@ import type { CliEnvironment } from './interfaces/environment.interface.mjs';
7
8
  * @public
8
9
  */
9
10
  export interface CommanderLoggerOptions {
10
- /**
11
- * Enabled log levels.
12
- * @default ['log', 'error', 'warn', 'debug', 'verbose', 'fatal']
13
- */
14
- logLevels?: LogLevel[];
15
- /**
16
- * If true, will print the process ID in the log message.
17
- * @default false
18
- */
19
- showPid?: boolean;
20
- /**
21
- * If true, will print the log level in the log message.
22
- * @default true
23
- */
24
- showLogLevel?: boolean;
25
- /**
26
- * If true, will print the prefix/app name in the log message.
27
- * @default false
28
- */
29
- showPrefix?: boolean;
30
- /**
31
- * If true, will print the context in the log message.
32
- * @default true
33
- */
34
- showContext?: boolean;
35
- /**
36
- * If true, will print the absolute timestamp in the log message.
37
- * @default false
38
- */
39
- showTimestamp?: boolean;
40
- /**
41
- * If enabled, will print timestamp difference between current and previous log message.
42
- * @default false
43
- */
44
- showTimeDiff?: boolean;
11
+ /**
12
+ * Enabled log levels.
13
+ * @default ['log', 'error', 'warn', 'debug', 'verbose', 'fatal']
14
+ */
15
+ logLevels?: LogLevel[]
16
+ /**
17
+ * If true, will print the process ID in the log message.
18
+ * @default false
19
+ */
20
+ showPid?: boolean
21
+ /**
22
+ * If true, will print the log level in the log message.
23
+ * @default true
24
+ */
25
+ showLogLevel?: boolean
26
+ /**
27
+ * If true, will print the prefix/app name in the log message.
28
+ * @default false
29
+ */
30
+ showPrefix?: boolean
31
+ /**
32
+ * If true, will print the context in the log message.
33
+ * @default true
34
+ */
35
+ showContext?: boolean
36
+ /**
37
+ * If true, will print the absolute timestamp in the log message.
38
+ * @default false
39
+ */
40
+ showTimestamp?: boolean
41
+ /**
42
+ * If enabled, will print timestamp difference between current and previous log message.
43
+ * @default false
44
+ */
45
+ showTimeDiff?: boolean
45
46
  }
46
47
  /**
47
48
  * TUI-specific options for terminal UI mode.
@@ -50,54 +51,54 @@ export interface CommanderLoggerOptions {
50
51
  * @public
51
52
  */
52
53
  export interface CommanderTuiOptions {
53
- /**
54
- * Exit on Ctrl+C.
55
- * @default true
56
- */
57
- exitOnCtrlC?: boolean;
58
- /**
59
- * Adapter to use for the TUI.
60
- * @default 'none'
61
- */
62
- adapter?: 'react' | 'solid' | 'ink' | 'none';
63
- /**
64
- * Sidebar width in columns.
65
- */
66
- sidebarWidth?: number;
67
- /**
68
- * Sidebar position.
69
- */
70
- sidebarPosition?: 'left' | 'right';
71
- /**
72
- * Sidebar header title.
73
- */
74
- sidebarTitle?: string;
75
- /**
76
- * Auto close after all screens complete successfully.
77
- * Set to true for default delay (5000ms), or specify delay in milliseconds.
78
- */
79
- autoClose?: boolean | number;
80
- /**
81
- * Theme preset name ('dark', 'light', 'high-contrast') or custom theme object.
82
- */
83
- theme?: string | Record<string, unknown>;
84
- /**
85
- * Enable mouse support.
86
- * @default false
87
- */
88
- useMouse?: boolean;
89
- /**
90
- * Hide the default console logger screen from the sidebar.
91
- * @default false
92
- */
93
- hideDefaultScreen?: boolean;
94
- /**
95
- * Use OpenTUI for terminal rendering.
96
- * When true: Full TUI with sidebar, scrolling, interactive prompts.
97
- * When false: Stdout mode - static screens print immediately, others on completion.
98
- * @default true for Node.js, false for Bun (OpenTUI not supported)
99
- */
100
- useOpenTUI?: boolean;
54
+ /**
55
+ * Exit on Ctrl+C.
56
+ * @default true
57
+ */
58
+ exitOnCtrlC?: boolean
59
+ /**
60
+ * Adapter to use for the TUI.
61
+ * @default 'none'
62
+ */
63
+ adapter?: 'react' | 'solid' | 'ink' | 'none'
64
+ /**
65
+ * Sidebar width in columns.
66
+ */
67
+ sidebarWidth?: number
68
+ /**
69
+ * Sidebar position.
70
+ */
71
+ sidebarPosition?: 'left' | 'right'
72
+ /**
73
+ * Sidebar header title.
74
+ */
75
+ sidebarTitle?: string
76
+ /**
77
+ * Auto close after all screens complete successfully.
78
+ * Set to true for default delay (5000ms), or specify delay in milliseconds.
79
+ */
80
+ autoClose?: boolean | number
81
+ /**
82
+ * Theme preset name ('dark', 'light', 'high-contrast') or custom theme object.
83
+ */
84
+ theme?: string | Record<string, unknown>
85
+ /**
86
+ * Enable mouse support.
87
+ * @default false
88
+ */
89
+ useMouse?: boolean
90
+ /**
91
+ * Hide the default console logger screen from the sidebar.
92
+ * @default false
93
+ */
94
+ hideDefaultScreen?: boolean
95
+ /**
96
+ * Use OpenTUI for terminal rendering.
97
+ * When true: Full TUI with sidebar, scrolling, interactive prompts.
98
+ * When false: Stdout mode - static screens print immediately, others on completion.
99
+ * @default true for Node.js, false for Bun (OpenTUI not supported)
100
+ */
101
+ useOpenTUI?: boolean
101
102
  }
102
103
  /**
103
104
  * Configuration options for CommanderFactory.
@@ -105,25 +106,25 @@ export interface CommanderTuiOptions {
105
106
  * @public
106
107
  */
107
108
  export interface CommanderFactoryOptions {
108
- /**
109
- * Enabled log levels.
110
- * @default ['log', 'error', 'warn', 'debug', 'verbose', 'fatal']
111
- */
112
- logLevels?: LogLevel[];
113
- /**
114
- * Logger display options. These override the default CLI-friendly logger settings.
115
- * Ignored when enableTUI is true.
116
- */
117
- logger?: CommanderLoggerOptions;
118
- /**
119
- * Enable TUI mode with @navios/commander-tui.
120
- * Requires @navios/commander-tui to be installed.
121
- */
122
- enableTUI?: boolean;
123
- /**
124
- * TUI-specific options. Only used when enableTUI is true.
125
- */
126
- tuiOptions?: CommanderTuiOptions;
109
+ /**
110
+ * Enabled log levels.
111
+ * @default ['log', 'error', 'warn', 'debug', 'verbose', 'fatal']
112
+ */
113
+ logLevels?: LogLevel[]
114
+ /**
115
+ * Logger display options. These override the default CLI-friendly logger settings.
116
+ * Ignored when enableTUI is true.
117
+ */
118
+ logger?: CommanderLoggerOptions
119
+ /**
120
+ * Enable TUI mode with @navios/commander-tui.
121
+ * Requires @navios/commander-tui to be installed.
122
+ */
123
+ enableTUI?: boolean
124
+ /**
125
+ * TUI-specific options. Only used when enableTUI is true.
126
+ */
127
+ tuiOptions?: CommanderTuiOptions
127
128
  }
128
129
  /**
129
130
  * Factory class for creating CLI applications.
@@ -160,22 +161,25 @@ export interface CommanderFactoryOptions {
160
161
  * ```
161
162
  */
162
163
  export declare class CommanderFactory {
163
- /**
164
- * Creates a new CLI application instance configured with the provided module.
165
- *
166
- * @param appModule - The root CLI module class decorated with `@CliModule`
167
- * @param options - Optional configuration options for the CLI application
168
- * @returns A promise that resolves to a configured NaviosApplication instance
169
- *
170
- * @example
171
- * ```typescript
172
- * const app = await CommanderFactory.create(AppModule)
173
- * await app.init()
174
- *
175
- * const adapter = app.getAdapter()
176
- * await adapter.run(process.argv)
177
- * ```
178
- */
179
- static create<TModule extends NaviosModule = NaviosModule>(appModule: ClassTypeWithInstance<TModule>, options?: CommanderFactoryOptions): Promise<NaviosApplication<CliEnvironment>>;
164
+ /**
165
+ * Creates a new CLI application instance configured with the provided module.
166
+ *
167
+ * @param appModule - The root CLI module class decorated with `@CliModule`
168
+ * @param options - Optional configuration options for the CLI application
169
+ * @returns A promise that resolves to a configured NaviosApplication instance
170
+ *
171
+ * @example
172
+ * ```typescript
173
+ * const app = await CommanderFactory.create(AppModule)
174
+ * await app.init()
175
+ *
176
+ * const adapter = app.getAdapter()
177
+ * await adapter.run(process.argv)
178
+ * ```
179
+ */
180
+ static create<TModule extends NaviosModule = NaviosModule>(
181
+ appModule: ClassTypeWithInstance<TModule>,
182
+ options?: CommanderFactoryOptions,
183
+ ): Promise<NaviosApplication<CliEnvironment>>
180
184
  }
181
- //# sourceMappingURL=commander.factory.d.mts.map
185
+ //# sourceMappingURL=commander.factory.d.mts.map
@@ -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;AAKpG,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;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,KAAK,GAAG,MAAM,CAAA;IAC5C;;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;IAC3B;;;;;OAKG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB;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;CAgF9C"}
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;AAKpG,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;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,KAAK,GAAG,MAAM,CAAA;IAC5C;;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;IAC3B;;;;;OAKG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB;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;IACH,OAAa,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,CA+E5C;CACF"}
@@ -1,18 +1,22 @@
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>;
1
+ import { z } from 'zod/v4'
2
+
3
+ import type { CommandHandler } from '../interfaces/command-handler.interface.mjs'
4
+ declare const helpOptionsSchema: z.ZodObject<
5
+ {
6
+ command: z.ZodOptional<z.ZodString>
7
+ },
8
+ z.core.$strip
9
+ >
10
+ type HelpOptions = z.infer<typeof helpOptionsSchema>
7
11
  /**
8
12
  * Built-in help command that lists all available commands or shows help for a specific command.
9
13
  *
10
14
  * @public
11
15
  */
12
16
  export declare class HelpCommand implements CommandHandler<HelpOptions> {
13
- private logger;
14
- private commandRegistry;
15
- execute(options: HelpOptions): Promise<void>;
17
+ private logger
18
+ private commandRegistry
19
+ execute(options: HelpOptions): Promise<void>
16
20
  }
17
- export {};
18
- //# sourceMappingURL=help.command.d.mts.map
21
+ export {}
22
+ //# sourceMappingURL=help.command.d.mts.map
@@ -1 +1 @@
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
+ {"version":3,"file":"help.command.d.mts","sourceRoot":"","sources":["../../../src/commands/help.command.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAM1B,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,CAMjD;CACF"}
@@ -1,2 +1,2 @@
1
- export * from './help.command.mjs';
2
- //# sourceMappingURL=index.d.mts.map
1
+ export * from './help.command.mjs'
2
+ //# sourceMappingURL=index.d.mts.map