@navios/commander 0.8.0 → 1.0.0-alpha.2
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 +21 -0
- package/README.md +3 -0
- package/dist/src/decorators/cli-module.decorator.d.mts +19 -2
- package/dist/src/decorators/cli-module.decorator.d.mts.map +1 -1
- package/dist/src/decorators/command.decorator.d.mts +12 -2
- package/dist/src/decorators/command.decorator.d.mts.map +1 -1
- package/dist/src/metadata/cli-module.metadata.d.mts +4 -0
- package/dist/src/metadata/cli-module.metadata.d.mts.map +1 -1
- package/dist/src/services/module-loader.service.d.mts +2 -0
- package/dist/src/services/module-loader.service.d.mts.map +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/lib/index.cjs +2033 -188
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +41 -3
- package/lib/index.d.cts.map +1 -1
- package/lib/index.d.mts +41 -3
- package/lib/index.d.mts.map +1 -1
- package/lib/index.mjs +1998 -191
- package/lib/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/decorators/cli-module.decorator.mts +31 -2
- package/src/decorators/command.decorator.mts +19 -2
- package/src/metadata/cli-module.metadata.mts +5 -0
- package/src/services/module-loader.service.mts +74 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,27 @@ 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.0.0-alpha.2] - 2026-01-07
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **Module Overrides**: New `overrides` option in `@CliModule()` decorator for service override classes
|
|
13
|
+
- Service override classes are imported for side effects to ensure their `@Injectable` decorators execute
|
|
14
|
+
- Overrides should use the same `InjectionToken` as the original service with a higher priority
|
|
15
|
+
- `CliModuleLoaderService` validates overrides and logs warnings if override is not active or not registered
|
|
16
|
+
- Mirrors the same functionality as `@Module()` in `@navios/core`
|
|
17
|
+
- **Logger Integration**: `CliModuleLoaderService` now uses the `Logger` service for consistent logging
|
|
18
|
+
|
|
19
|
+
### Dependencies
|
|
20
|
+
|
|
21
|
+
- Updated to support `@navios/core` ^1.0.0-alpha.2
|
|
22
|
+
|
|
23
|
+
## [0.9.0] - 2025-12-23
|
|
24
|
+
|
|
25
|
+
### Dependencies
|
|
26
|
+
|
|
27
|
+
- Updated to support `@navios/di` ^0.9.0
|
|
28
|
+
|
|
8
29
|
## [0.8.0] - 2025-12-21
|
|
9
30
|
|
|
10
31
|
### Dependencies
|
package/README.md
CHANGED
|
@@ -55,6 +55,8 @@ import { GreetCommand } from './greet.command'
|
|
|
55
55
|
|
|
56
56
|
@CliModule({
|
|
57
57
|
commands: [GreetCommand],
|
|
58
|
+
// Optional: overrides for service implementations with higher priority
|
|
59
|
+
// overrides: [OverrideService],
|
|
58
60
|
})
|
|
59
61
|
export class AppModule {}
|
|
60
62
|
```
|
|
@@ -239,6 +241,7 @@ Defines a CLI module.
|
|
|
239
241
|
|
|
240
242
|
- `commands?: ClassType[]` - Array of command classes
|
|
241
243
|
- `imports?: ClassType[]` - Array of other modules to import
|
|
244
|
+
- `overrides?: ClassType[]` - Array of service override classes to import for side effects (ensures `@Injectable` decorators execute)
|
|
242
245
|
|
|
243
246
|
### Interfaces
|
|
244
247
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ClassType } from '@navios/core';
|
|
1
|
+
import type { ClassType, Registry } from '@navios/core';
|
|
2
2
|
/**
|
|
3
3
|
* Options for the `@CliModule` decorator.
|
|
4
4
|
*
|
|
@@ -15,6 +15,23 @@ export interface CliModuleOptions {
|
|
|
15
15
|
* Imported modules' commands will be available in this module.
|
|
16
16
|
*/
|
|
17
17
|
imports?: ClassType[] | Set<ClassType>;
|
|
18
|
+
/**
|
|
19
|
+
* Service override classes to import for side effects.
|
|
20
|
+
* These classes are imported to ensure their @Injectable decorators execute,
|
|
21
|
+
* allowing them to register with the DI system. Overrides should use the same
|
|
22
|
+
* InjectionToken as the original service with a higher priority.
|
|
23
|
+
*/
|
|
24
|
+
overrides?: ClassType[] | Set<ClassType>;
|
|
25
|
+
/**
|
|
26
|
+
* Priority level for the module.
|
|
27
|
+
* Higher priority modules will be loaded first.
|
|
28
|
+
*/
|
|
29
|
+
priority?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Registry to use for the module.
|
|
32
|
+
* Registry is used to store the module and its commands.
|
|
33
|
+
*/
|
|
34
|
+
registry?: Registry;
|
|
18
35
|
}
|
|
19
36
|
/**
|
|
20
37
|
* Decorator that marks a class as a CLI module.
|
|
@@ -38,5 +55,5 @@ export interface CliModuleOptions {
|
|
|
38
55
|
* export class AppModule {}
|
|
39
56
|
* ```
|
|
40
57
|
*/
|
|
41
|
-
export declare function CliModule({ commands, imports }?: CliModuleOptions): (target: ClassType, context: ClassDecoratorContext) => ClassType;
|
|
58
|
+
export declare function CliModule({ commands, imports, overrides, priority, registry, }?: CliModuleOptions): (target: ClassType, context: ClassDecoratorContext) => ClassType;
|
|
42
59
|
//# sourceMappingURL=cli-module.decorator.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-module.decorator.d.mts","sourceRoot":"","sources":["../../../src/decorators/cli-module.decorator.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"cli-module.decorator.d.mts","sourceRoot":"","sources":["../../../src/decorators/cli-module.decorator.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAMvD;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,QAAQ,CAAC,EAAE,SAAS,EAAE,GAAG,GAAG,CAAC,SAAS,CAAC,CAAA;IACvC;;;OAGG;IACH,OAAO,CAAC,EAAE,SAAS,EAAE,GAAG,GAAG,CAAC,SAAS,CAAC,CAAA;IACtC;;;;;OAKG;IACH,SAAS,CAAC,EAAE,SAAS,EAAE,GAAG,GAAG,CAAC,SAAS,CAAC,CAAA;IACxC;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;;OAGG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAA;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,SAAS,CACvB,EACE,QAAa,EACb,OAAY,EACZ,SAAc,EACd,QAAQ,EACR,QAAQ,GACT,GAAE,gBAIF,IAEO,QAAQ,SAAS,EAAE,SAAS,qBAAqB,eA0B1D"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ClassType } from '@navios/core';
|
|
1
|
+
import type { ClassType, Registry } from '@navios/core';
|
|
2
2
|
import type { ZodObject } from 'zod';
|
|
3
3
|
/**
|
|
4
4
|
* Options for the `@Command` decorator.
|
|
@@ -16,6 +16,16 @@ export interface CommandOptions {
|
|
|
16
16
|
* If provided, options will be validated and parsed according to this schema.
|
|
17
17
|
*/
|
|
18
18
|
optionsSchema?: ZodObject;
|
|
19
|
+
/**
|
|
20
|
+
* Priority level for the command.
|
|
21
|
+
* Higher priority commands will be loaded first.
|
|
22
|
+
*/
|
|
23
|
+
priority?: number;
|
|
24
|
+
/**
|
|
25
|
+
* Registry to use for the command.
|
|
26
|
+
* Registry is used to store the command and its options schema.
|
|
27
|
+
*/
|
|
28
|
+
registry?: Registry;
|
|
19
29
|
}
|
|
20
30
|
/**
|
|
21
31
|
* Decorator that marks a class as a CLI command.
|
|
@@ -47,5 +57,5 @@ export interface CommandOptions {
|
|
|
47
57
|
* }
|
|
48
58
|
* ```
|
|
49
59
|
*/
|
|
50
|
-
export declare function Command({ path, optionsSchema }: CommandOptions): (target: ClassType, context: ClassDecoratorContext) => ClassType;
|
|
60
|
+
export declare function Command({ path, optionsSchema, priority, registry, }: CommandOptions): (target: ClassType, context: ClassDecoratorContext) => ClassType;
|
|
51
61
|
//# 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,MAAM,cAAc,CAAA;
|
|
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,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,aAAa,EACb,QAAQ,EACR,QAAQ,GACT,EAAE,cAAc,IACE,QAAQ,SAAS,EAAE,SAAS,qBAAqB,eAiBnE"}
|
|
@@ -18,6 +18,10 @@ export interface CliModuleMetadata {
|
|
|
18
18
|
* Set of other modules imported by this module.
|
|
19
19
|
*/
|
|
20
20
|
imports: Set<ClassType>;
|
|
21
|
+
/**
|
|
22
|
+
* Set of service override classes imported for side effects.
|
|
23
|
+
*/
|
|
24
|
+
overrides: Set<ClassType>;
|
|
21
25
|
/**
|
|
22
26
|
* Map of custom attributes that can be attached to the module.
|
|
23
27
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-module.metadata.d.mts","sourceRoot":"","sources":["../../../src/metadata/cli-module.metadata.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAE7C;;;GAGG;AACH,eAAO,MAAM,oBAAoB,eAAiC,CAAA;AAElE;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,QAAQ,EAAE,GAAG,CAAC,SAAS,CAAC,CAAA;IACxB;;OAEG;IACH,OAAO,EAAE,GAAG,CAAC,SAAS,CAAC,CAAA;IACvB;;OAEG;IACH,gBAAgB,EAAE,GAAG,CAAC,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,CAAA;CAC5C;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,SAAS,EACjB,OAAO,EAAE,qBAAqB,GAC7B,iBAAiB,
|
|
1
|
+
{"version":3,"file":"cli-module.metadata.d.mts","sourceRoot":"","sources":["../../../src/metadata/cli-module.metadata.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAE7C;;;GAGG;AACH,eAAO,MAAM,oBAAoB,eAAiC,CAAA;AAElE;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,QAAQ,EAAE,GAAG,CAAC,SAAS,CAAC,CAAA;IACxB;;OAEG;IACH,OAAO,EAAE,GAAG,CAAC,SAAS,CAAC,CAAA;IACvB;;OAEG;IACH,SAAS,EAAE,GAAG,CAAC,SAAS,CAAC,CAAA;IACzB;;OAEG;IACH,gBAAgB,EAAE,GAAG,CAAC,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,CAAA;CAC5C;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,SAAS,EACjB,OAAO,EAAE,qBAAqB,GAC7B,iBAAiB,CAqBnB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,SAAS,GAAG,iBAAiB,CAS7E;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAG/D"}
|
|
@@ -26,6 +26,7 @@ export interface CommandWithMetadata {
|
|
|
26
26
|
* @public
|
|
27
27
|
*/
|
|
28
28
|
export declare class CliModuleLoaderService {
|
|
29
|
+
private logger;
|
|
29
30
|
protected container: Container;
|
|
30
31
|
private modulesMetadata;
|
|
31
32
|
private loadedModules;
|
|
@@ -40,6 +41,7 @@ export declare class CliModuleLoaderService {
|
|
|
40
41
|
*/
|
|
41
42
|
loadModules(appModule: ClassTypeWithInstance<NaviosModule>): Promise<void>;
|
|
42
43
|
private traverseModules;
|
|
44
|
+
private validateOverrides;
|
|
43
45
|
private mergeMetadata;
|
|
44
46
|
/**
|
|
45
47
|
* Gets all loaded module metadata.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-loader.service.d.mts","sourceRoot":"","sources":["../../../src/services/module-loader.service.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAEvE,OAAO,
|
|
1
|
+
{"version":3,"file":"module-loader.service.d.mts","sourceRoot":"","sources":["../../../src/services/module-loader.service.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAEvE,OAAO,EACL,SAAS,EAKV,MAAM,cAAc,CAAA;AAErB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAO/E;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,KAAK,EAAE,qBAAqB,CAAC,cAAc,CAAC,CAAA;IAC5C;;OAEG;IACH,QAAQ,EAAE,eAAe,CAAA;CAC1B;AAED;;;;;;;GAOG;AACH,qBACa,sBAAsB;IACjC,OAAO,CAAC,MAAM,CAEZ;IACF,SAAS,CAAC,SAAS,YAAoB;IACvC,OAAO,CAAC,eAAe,CAA4C;IACnE,OAAO,CAAC,aAAa,CAA8B;IACnD,OAAO,CAAC,gBAAgB,CAA8C;IACtE,OAAO,CAAC,WAAW,CAAQ;IAE3B;;;;;;OAMG;IACG,WAAW,CAAC,SAAS,EAAE,qBAAqB,CAAC,YAAY,CAAC;YAQlD,eAAe;IAqC7B,OAAO,CAAC,iBAAiB;IA6DzB,OAAO,CAAC,aAAa;IAcrB;;;;OAIG;IACH,aAAa,IAAI,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC;IAI/C;;;;OAIG;IACH,cAAc,IAAI,GAAG,CAAC,MAAM,EAAE,qBAAqB,CAAC,GAAG,CAAC,CAAC;IAUzD;;;;OAIG;IACH,0BAA0B,IAAI,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC;IAI9D;;;OAGG;IACH,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,mBAAmB,GAAG,SAAS;IAI/D;;OAEG;IACH,OAAO;CAMR"}
|