@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.
Files changed (76) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/README.md +22 -0
  3. package/dist/src/commander.factory.d.mts +59 -0
  4. package/dist/src/commander.factory.d.mts.map +1 -1
  5. package/dist/src/commands/help.command.d.mts.map +1 -1
  6. package/dist/src/decorators/command.decorator.d.mts +9 -2
  7. package/dist/src/decorators/command.decorator.d.mts.map +1 -1
  8. package/dist/src/legacy-compat/decorators/cli-module.decorator.d.mts +26 -0
  9. package/dist/src/legacy-compat/decorators/cli-module.decorator.d.mts.map +1 -0
  10. package/dist/src/legacy-compat/decorators/command.decorator.d.mts +34 -0
  11. package/dist/src/legacy-compat/decorators/command.decorator.d.mts.map +1 -0
  12. package/dist/src/legacy-compat/decorators/index.d.mts +3 -0
  13. package/dist/src/legacy-compat/decorators/index.d.mts.map +1 -0
  14. package/dist/src/legacy-compat/index.d.mts +28 -0
  15. package/dist/src/legacy-compat/index.d.mts.map +1 -0
  16. package/dist/src/overrides/help.command.d.mts +18 -0
  17. package/dist/src/overrides/help.command.d.mts.map +1 -0
  18. package/dist/src/tokens/help-command.token.d.mts +4 -0
  19. package/dist/src/tokens/help-command.token.d.mts.map +1 -0
  20. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  21. package/dist/tsconfig.tsbuildinfo +1 -1
  22. package/lib/cli-module.decorator-CkP22084.cjs +71 -0
  23. package/lib/cli-module.decorator-CkP22084.cjs.map +1 -0
  24. package/lib/cli-module.decorator-DGuGfpex.d.mts +411 -0
  25. package/lib/cli-module.decorator-DGuGfpex.d.mts.map +1 -0
  26. package/lib/cli-module.decorator-DVl8009Q.d.cts +213 -0
  27. package/lib/cli-module.decorator-DVl8009Q.d.cts.map +1 -0
  28. package/lib/cli-module.decorator-UGbtkRYc.mjs +66 -0
  29. package/lib/cli-module.decorator-UGbtkRYc.mjs.map +1 -0
  30. package/lib/command.decorator-DVLSAqYZ.mjs +135 -0
  31. package/lib/command.decorator-DVLSAqYZ.mjs.map +1 -0
  32. package/lib/command.decorator-UrNJmQN0.cjs +176 -0
  33. package/lib/command.decorator-UrNJmQN0.cjs.map +1 -0
  34. package/lib/help-command.token-C0Kgj60o.mjs +427 -0
  35. package/lib/help-command.token-C0Kgj60o.mjs.map +1 -0
  36. package/lib/help-command.token-CMWYI6em.cjs +438 -0
  37. package/lib/help-command.token-CMWYI6em.cjs.map +1 -0
  38. package/lib/help.command-DQyv6ali.cjs +317 -0
  39. package/lib/help.command-DQyv6ali.cjs.map +1 -0
  40. package/lib/help.command-dtZbhq0w.mjs +318 -0
  41. package/lib/help.command-dtZbhq0w.mjs.map +1 -0
  42. package/lib/index.cjs +45 -627
  43. package/lib/index.cjs.map +1 -1
  44. package/lib/index.d.cts +139 -281
  45. package/lib/index.d.cts.map +1 -1
  46. package/lib/index.d.mts +62 -402
  47. package/lib/index.d.mts.map +1 -1
  48. package/lib/index.mjs +30 -612
  49. package/lib/index.mjs.map +1 -1
  50. package/lib/legacy-compat/index.cjs +108 -0
  51. package/lib/legacy-compat/index.cjs.map +1 -0
  52. package/lib/legacy-compat/index.d.cts +63 -0
  53. package/lib/legacy-compat/index.d.cts.map +1 -0
  54. package/lib/legacy-compat/index.d.mts +63 -0
  55. package/lib/legacy-compat/index.d.mts.map +1 -0
  56. package/lib/legacy-compat/index.mjs +101 -0
  57. package/lib/legacy-compat/index.mjs.map +1 -0
  58. package/package.json +20 -3
  59. package/src/commander.factory.mts +107 -8
  60. package/src/commands/help.command.mts +4 -3
  61. package/src/decorators/command.decorator.mts +17 -8
  62. package/src/legacy-compat/decorators/cli-module.decorator.mts +46 -0
  63. package/src/legacy-compat/decorators/command.decorator.mts +46 -0
  64. package/src/legacy-compat/decorators/index.mts +2 -0
  65. package/src/legacy-compat/index.mts +31 -0
  66. package/src/overrides/help.command.mts +40 -0
  67. package/src/tokens/help-command.token.mts +5 -0
  68. package/tsconfig.json +0 -3
  69. package/tsconfig.spec.json +1 -1
  70. package/tsdown.config.mts +1 -1
  71. package/dist/src/commander.application.d.mts +0 -147
  72. package/dist/src/commander.application.d.mts.map +0 -1
  73. package/dist/src/metadata/cli-module.metadata.d.mts +0 -60
  74. package/dist/src/metadata/cli-module.metadata.d.mts.map +0 -1
  75. package/dist/src/services/module-loader.service.d.mts +0 -74
  76. package/dist/src/services/module-loader.service.d.mts.map +0 -1
@@ -1,60 +0,0 @@
1
- import type { ClassType } from '@navios/core';
2
- /**
3
- * @internal
4
- * Symbol key used to store CLI module metadata on classes.
5
- */
6
- export declare const CliModuleMetadataKey: unique symbol;
7
- /**
8
- * Metadata associated with a CLI module.
9
- *
10
- * @public
11
- */
12
- export interface CliModuleMetadata {
13
- /**
14
- * Set of command classes registered in this module.
15
- */
16
- commands: Set<ClassType>;
17
- /**
18
- * Set of other modules imported by this module.
19
- */
20
- imports: Set<ClassType>;
21
- /**
22
- * Set of service override classes imported for side effects.
23
- */
24
- overrides: Set<ClassType>;
25
- /**
26
- * Map of custom attributes that can be attached to the module.
27
- */
28
- customAttributes: Map<string | symbol, any>;
29
- }
30
- /**
31
- * Gets or creates CLI module metadata for a class.
32
- *
33
- * @internal
34
- * @param target - The module class
35
- * @param context - The decorator context
36
- * @returns The module metadata
37
- */
38
- export declare function getCliModuleMetadata(target: ClassType, context: ClassDecoratorContext): CliModuleMetadata;
39
- /**
40
- * Extracts CLI module metadata from a class.
41
- *
42
- * @param target - The module class
43
- * @returns The module metadata
44
- * @throws {Error} If the class is not decorated with @CliModule
45
- *
46
- * @example
47
- * ```typescript
48
- * const metadata = extractCliModuleMetadata(AppModule)
49
- * console.log(metadata.commands.size) // Number of commands
50
- * ```
51
- */
52
- export declare function extractCliModuleMetadata(target: ClassType): CliModuleMetadata;
53
- /**
54
- * Checks if a class has CLI module metadata.
55
- *
56
- * @param target - The class to check
57
- * @returns `true` if the class is decorated with @CliModule, `false` otherwise
58
- */
59
- export declare function hasCliModuleMetadata(target: ClassType): boolean;
60
- //# sourceMappingURL=cli-module.metadata.d.mts.map
@@ -1 +0,0 @@
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"}
@@ -1,74 +0,0 @@
1
- import type { ClassTypeWithInstance, NaviosModule } from '@navios/core';
2
- import { Container } from '@navios/core';
3
- import type { CommandHandler } from '../interfaces/index.mjs';
4
- import type { CliModuleMetadata, CommandMetadata } from '../metadata/index.mjs';
5
- /**
6
- * Command class with its associated metadata.
7
- *
8
- * @public
9
- */
10
- export interface CommandWithMetadata {
11
- /**
12
- * The command class constructor.
13
- */
14
- class: ClassTypeWithInstance<CommandHandler>;
15
- /**
16
- * The command metadata including path and options schema.
17
- */
18
- metadata: CommandMetadata;
19
- }
20
- /**
21
- * Service for loading and managing CLI modules and commands.
22
- *
23
- * Handles module traversal, command registration, and metadata collection.
24
- * This service is used internally by CommanderApplication.
25
- *
26
- * @public
27
- */
28
- export declare class CliModuleLoaderService {
29
- private logger;
30
- protected container: Container;
31
- private modulesMetadata;
32
- private loadedModules;
33
- private commandsMetadata;
34
- private initialized;
35
- /**
36
- * Loads all modules starting from the root app module.
37
- *
38
- * Traverses the module tree, loads imported modules, and collects command metadata.
39
- *
40
- * @param appModule - The root CLI module
41
- */
42
- loadModules(appModule: ClassTypeWithInstance<NaviosModule>): Promise<void>;
43
- private traverseModules;
44
- private validateOverrides;
45
- private mergeMetadata;
46
- /**
47
- * Gets all loaded module metadata.
48
- *
49
- * @returns Map of module names to their metadata
50
- */
51
- getAllModules(): Map<string, CliModuleMetadata>;
52
- /**
53
- * Gets all command classes indexed by command class name.
54
- *
55
- * @returns Map of command class names to command classes
56
- */
57
- getAllCommands(): Map<string, ClassTypeWithInstance<any>>;
58
- /**
59
- * Get all commands with their metadata, indexed by command path.
60
- * This is populated during loadModules, so path information is available
61
- * before parsing CLI argv.
62
- */
63
- getAllCommandsWithMetadata(): Map<string, CommandWithMetadata>;
64
- /**
65
- * Get a command by its path, with metadata already extracted.
66
- * Returns undefined if command is not found.
67
- */
68
- getCommandByPath(path: string): CommandWithMetadata | undefined;
69
- /**
70
- * Disposes of all loaded modules and commands, clearing internal state.
71
- */
72
- dispose(): void;
73
- }
74
- //# sourceMappingURL=module-loader.service.d.mts.map
@@ -1 +0,0 @@
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"}