context-mapper-mcp 1.0.1 → 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.
- package/dist/generators/builtin/plantuml-adapter.d.ts +60 -0
- package/dist/generators/builtin/plantuml-adapter.d.ts.map +1 -0
- package/dist/generators/builtin/plantuml-adapter.js +119 -0
- package/dist/generators/builtin/plantuml-adapter.js.map +1 -0
- package/dist/generators/cli/config.d.ts +105 -0
- package/dist/generators/cli/config.d.ts.map +1 -0
- package/dist/generators/cli/config.js +168 -0
- package/dist/generators/cli/config.js.map +1 -0
- package/dist/generators/cli/context-map.d.ts +26 -0
- package/dist/generators/cli/context-map.d.ts.map +1 -0
- package/dist/generators/cli/context-map.js +124 -0
- package/dist/generators/cli/context-map.js.map +1 -0
- package/dist/generators/cli/executor.d.ts +95 -0
- package/dist/generators/cli/executor.d.ts.map +1 -0
- package/dist/generators/cli/executor.js +277 -0
- package/dist/generators/cli/executor.js.map +1 -0
- package/dist/generators/cli/generic.d.ts +54 -0
- package/dist/generators/cli/generic.d.ts.map +1 -0
- package/dist/generators/cli/generic.js +224 -0
- package/dist/generators/cli/generic.js.map +1 -0
- package/dist/generators/cli/manager.d.ts +83 -0
- package/dist/generators/cli/manager.d.ts.map +1 -0
- package/dist/generators/cli/manager.js +281 -0
- package/dist/generators/cli/manager.js.map +1 -0
- package/dist/generators/cli/mdsl.d.ts +26 -0
- package/dist/generators/cli/mdsl.d.ts.map +1 -0
- package/dist/generators/cli/mdsl.js +118 -0
- package/dist/generators/cli/mdsl.js.map +1 -0
- package/dist/generators/interfaces.d.ts +144 -0
- package/dist/generators/interfaces.d.ts.map +1 -0
- package/dist/generators/interfaces.js +59 -0
- package/dist/generators/interfaces.js.map +1 -0
- package/dist/generators/registry.d.ts +100 -0
- package/dist/generators/registry.d.ts.map +1 -0
- package/dist/generators/registry.js +169 -0
- package/dist/generators/registry.js.map +1 -0
- package/dist/index.js +180 -3
- package/dist/index.js.map +1 -1
- package/dist/tools/cli-tools.d.ts +103 -0
- package/dist/tools/cli-tools.d.ts.map +1 -0
- package/dist/tools/cli-tools.js +220 -0
- package/dist/tools/cli-tools.js.map +1 -0
- package/dist/tools/generation-tools.d.ts +73 -1
- package/dist/tools/generation-tools.d.ts.map +1 -1
- package/dist/tools/generation-tools.js +160 -1
- package/dist/tools/generation-tools.js.map +1 -1
- package/dist/utils/temp-files.d.ts +77 -0
- package/dist/utils/temp-files.d.ts.map +1 -0
- package/dist/utils/temp-files.js +164 -0
- package/dist/utils/temp-files.js.map +1 -0
- package/package.json +4 -1
- package/src/templates/FullReportTemplate.md.ftl +297 -0
- package/src/templates/GlossaryTemplate.md.ftl +132 -0
- package/src/templates/JHipster-Microservices.jdl.ftl +139 -0
- package/src/templates/JHipster-Monolith.jdl.ftl +159 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generator Interfaces and Types
|
|
3
|
+
* Defines the contract for all generators (builtin and CLI-based)
|
|
4
|
+
*/
|
|
5
|
+
import type { CMLModel } from '../model/types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Error types for generator failures
|
|
8
|
+
*/
|
|
9
|
+
export type GeneratorErrorType = 'CLI_NOT_FOUND' | 'CLI_DOWNLOAD_FAILED' | 'JAVA_NOT_FOUND' | 'JAVA_VERSION_INCOMPATIBLE' | 'EXECUTION_FAILED' | 'EXECUTION_TIMEOUT' | 'INVALID_CML' | 'TEMPLATE_NOT_FOUND' | 'OUTPUT_NOT_FOUND' | 'INTERNAL_ERROR';
|
|
10
|
+
/**
|
|
11
|
+
* Structured error for generator failures
|
|
12
|
+
*/
|
|
13
|
+
export interface GeneratorError {
|
|
14
|
+
type: GeneratorErrorType;
|
|
15
|
+
message: string;
|
|
16
|
+
suggestion?: string;
|
|
17
|
+
details?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Output from a generator
|
|
21
|
+
*/
|
|
22
|
+
export interface GeneratorOutput {
|
|
23
|
+
/** Type of output */
|
|
24
|
+
type: 'file' | 'content';
|
|
25
|
+
/** File path (for type: 'file') */
|
|
26
|
+
path?: string;
|
|
27
|
+
/** Content (for type: 'content') */
|
|
28
|
+
content?: string;
|
|
29
|
+
/** Output format */
|
|
30
|
+
format: string;
|
|
31
|
+
/** Description of the output */
|
|
32
|
+
description?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Result from running a generator
|
|
36
|
+
*/
|
|
37
|
+
export interface GeneratorResult {
|
|
38
|
+
success: boolean;
|
|
39
|
+
outputs?: GeneratorOutput[];
|
|
40
|
+
error?: GeneratorError;
|
|
41
|
+
warnings?: string[];
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Options passed to a generator
|
|
45
|
+
*/
|
|
46
|
+
export interface GeneratorOptions {
|
|
47
|
+
/** Output directory for file outputs */
|
|
48
|
+
outputDir?: string;
|
|
49
|
+
/** Timeout in milliseconds */
|
|
50
|
+
timeout?: number;
|
|
51
|
+
/** Generator-specific options */
|
|
52
|
+
[key: string]: unknown;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Context Map generator specific options
|
|
56
|
+
*/
|
|
57
|
+
export interface ContextMapGeneratorOptions extends GeneratorOptions {
|
|
58
|
+
/** Output format for the image */
|
|
59
|
+
format?: 'png' | 'svg';
|
|
60
|
+
/** Width of the image */
|
|
61
|
+
width?: number;
|
|
62
|
+
/** Height of the image */
|
|
63
|
+
height?: number;
|
|
64
|
+
/** Fix the width */
|
|
65
|
+
fixWidth?: boolean;
|
|
66
|
+
/** Fix the height */
|
|
67
|
+
fixHeight?: boolean;
|
|
68
|
+
/** Generate for specific bounded contexts only */
|
|
69
|
+
boundedContexts?: string[];
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* MDSL generator specific options
|
|
73
|
+
*/
|
|
74
|
+
export interface MDSLGeneratorOptions extends GeneratorOptions {
|
|
75
|
+
/** Generate for specific bounded contexts only */
|
|
76
|
+
boundedContexts?: string[];
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Generic/Freemarker generator specific options
|
|
80
|
+
*/
|
|
81
|
+
export interface GenericGeneratorOptions extends GeneratorOptions {
|
|
82
|
+
/** Path to the Freemarker template file */
|
|
83
|
+
templatePath: string;
|
|
84
|
+
/** Output file name (without directory) */
|
|
85
|
+
outputFileName?: string;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Generator interface - all generators must implement this
|
|
89
|
+
*/
|
|
90
|
+
export interface IGenerator {
|
|
91
|
+
/** Unique name for this generator */
|
|
92
|
+
name: string;
|
|
93
|
+
/** Human-readable description */
|
|
94
|
+
description: string;
|
|
95
|
+
/** Whether this generator requires the CLI */
|
|
96
|
+
requiresCLI: boolean;
|
|
97
|
+
/** Supported output formats */
|
|
98
|
+
outputFormats: string[];
|
|
99
|
+
/**
|
|
100
|
+
* Run the generator
|
|
101
|
+
* @param model The CML model to generate from
|
|
102
|
+
* @param options Generator options
|
|
103
|
+
* @returns Generator result with outputs or error
|
|
104
|
+
*/
|
|
105
|
+
generate(model: CMLModel, options?: GeneratorOptions): Promise<GeneratorResult>;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Generator availability status
|
|
109
|
+
*/
|
|
110
|
+
export interface GeneratorAvailability {
|
|
111
|
+
name: string;
|
|
112
|
+
available: boolean;
|
|
113
|
+
requiresCLI: boolean;
|
|
114
|
+
reason?: string;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Create a successful generator result
|
|
118
|
+
*/
|
|
119
|
+
export declare function createSuccessResult(outputs: GeneratorOutput[], warnings?: string[]): GeneratorResult;
|
|
120
|
+
/**
|
|
121
|
+
* Create a failed generator result
|
|
122
|
+
*/
|
|
123
|
+
export declare function createErrorResult(type: GeneratorErrorType, message: string, suggestion?: string, details?: string): GeneratorResult;
|
|
124
|
+
/**
|
|
125
|
+
* Helper to create CLI not found error
|
|
126
|
+
*/
|
|
127
|
+
export declare function cliNotFoundError(): GeneratorResult;
|
|
128
|
+
/**
|
|
129
|
+
* Helper to create Java not found error
|
|
130
|
+
*/
|
|
131
|
+
export declare function javaNotFoundError(): GeneratorResult;
|
|
132
|
+
/**
|
|
133
|
+
* Helper to create Java version error
|
|
134
|
+
*/
|
|
135
|
+
export declare function javaVersionError(foundVersion: string): GeneratorResult;
|
|
136
|
+
/**
|
|
137
|
+
* Helper to create execution timeout error
|
|
138
|
+
*/
|
|
139
|
+
export declare function executionTimeoutError(timeoutMs: number): GeneratorResult;
|
|
140
|
+
/**
|
|
141
|
+
* Helper to create template not found error
|
|
142
|
+
*/
|
|
143
|
+
export declare function templateNotFoundError(templatePath: string): GeneratorResult;
|
|
144
|
+
//# sourceMappingURL=interfaces.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../src/generators/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElD;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAC1B,eAAe,GACf,qBAAqB,GACrB,gBAAgB,GAChB,2BAA2B,GAC3B,kBAAkB,GAClB,mBAAmB,GACnB,aAAa,GACb,oBAAoB,GACpB,kBAAkB,GAClB,gBAAgB,CAAC;AAErB;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,kBAAkB,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,qBAAqB;IACrB,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,mCAAmC;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oCAAoC;IACpC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oBAAoB;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iCAAiC;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,8CAA8C;IAC9C,WAAW,EAAE,OAAO,CAAC;IACrB,+BAA+B;IAC/B,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;CACjF;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,OAAO,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,eAAe,EAAE,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,GAAG,eAAe,CAMpG;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,kBAAkB,EACxB,OAAO,EAAE,MAAM,EACf,UAAU,CAAC,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE,MAAM,GACf,eAAe,CAUjB;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,eAAe,CAMlD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,eAAe,CAMnD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,eAAe,CAMtE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,eAAe,CAMxE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,MAAM,GAAG,eAAe,CAM3E"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generator Interfaces and Types
|
|
3
|
+
* Defines the contract for all generators (builtin and CLI-based)
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Create a successful generator result
|
|
7
|
+
*/
|
|
8
|
+
export function createSuccessResult(outputs, warnings) {
|
|
9
|
+
return {
|
|
10
|
+
success: true,
|
|
11
|
+
outputs,
|
|
12
|
+
warnings,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Create a failed generator result
|
|
17
|
+
*/
|
|
18
|
+
export function createErrorResult(type, message, suggestion, details) {
|
|
19
|
+
return {
|
|
20
|
+
success: false,
|
|
21
|
+
error: {
|
|
22
|
+
type,
|
|
23
|
+
message,
|
|
24
|
+
suggestion,
|
|
25
|
+
details,
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Helper to create CLI not found error
|
|
31
|
+
*/
|
|
32
|
+
export function cliNotFoundError() {
|
|
33
|
+
return createErrorResult('CLI_NOT_FOUND', 'Context Mapper CLI not found', 'Run cml_download_cli to download and install the CLI, or use cml_configure_cli to set a custom path');
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Helper to create Java not found error
|
|
37
|
+
*/
|
|
38
|
+
export function javaNotFoundError() {
|
|
39
|
+
return createErrorResult('JAVA_NOT_FOUND', 'Java runtime not found', 'Install JDK 17+ from https://adoptium.net or set JAVA_HOME environment variable');
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Helper to create Java version error
|
|
43
|
+
*/
|
|
44
|
+
export function javaVersionError(foundVersion) {
|
|
45
|
+
return createErrorResult('JAVA_VERSION_INCOMPATIBLE', `Java 17+ required, found ${foundVersion}`, 'Upgrade Java to version 17 or later from https://adoptium.net');
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Helper to create execution timeout error
|
|
49
|
+
*/
|
|
50
|
+
export function executionTimeoutError(timeoutMs) {
|
|
51
|
+
return createErrorResult('EXECUTION_TIMEOUT', `CLI timed out after ${timeoutMs}ms`, 'Try increasing the timeout in generator options');
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Helper to create template not found error
|
|
55
|
+
*/
|
|
56
|
+
export function templateNotFoundError(templatePath) {
|
|
57
|
+
return createErrorResult('TEMPLATE_NOT_FOUND', `Template not found: ${templatePath}`, 'Verify the template path exists and is accessible');
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=interfaces.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/generators/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAsIH;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAA0B,EAAE,QAAmB;IACjF,OAAO;QACL,OAAO,EAAE,IAAI;QACb,OAAO;QACP,QAAQ;KACT,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAC/B,IAAwB,EACxB,OAAe,EACf,UAAmB,EACnB,OAAgB;IAEhB,OAAO;QACL,OAAO,EAAE,KAAK;QACd,KAAK,EAAE;YACL,IAAI;YACJ,OAAO;YACP,UAAU;YACV,OAAO;SACR;KACF,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB;IAC9B,OAAO,iBAAiB,CACtB,eAAe,EACf,8BAA8B,EAC9B,qGAAqG,CACtG,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB;IAC/B,OAAO,iBAAiB,CACtB,gBAAgB,EAChB,wBAAwB,EACxB,iFAAiF,CAClF,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,YAAoB;IACnD,OAAO,iBAAiB,CACtB,2BAA2B,EAC3B,4BAA4B,YAAY,EAAE,EAC1C,+DAA+D,CAChE,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,SAAiB;IACrD,OAAO,iBAAiB,CACtB,mBAAmB,EACnB,uBAAuB,SAAS,IAAI,EACpC,iDAAiD,CAClD,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,YAAoB;IACxD,OAAO,iBAAiB,CACtB,oBAAoB,EACpB,uBAAuB,YAAY,EAAE,EACrC,mDAAmD,CACpD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generator Registry - Dependency Injection Container for Generators
|
|
3
|
+
* Manages registration and retrieval of all generators (builtin and CLI-based)
|
|
4
|
+
*/
|
|
5
|
+
import type { IGenerator, GeneratorAvailability } from './interfaces.js';
|
|
6
|
+
/**
|
|
7
|
+
* Registry for managing generators
|
|
8
|
+
*/
|
|
9
|
+
declare class GeneratorRegistry {
|
|
10
|
+
private generators;
|
|
11
|
+
private cliAvailable;
|
|
12
|
+
private javaAvailable;
|
|
13
|
+
/**
|
|
14
|
+
* Register a generator
|
|
15
|
+
* @param generator The generator to register
|
|
16
|
+
* @throws Error if a generator with the same name is already registered
|
|
17
|
+
*/
|
|
18
|
+
register(generator: IGenerator): void;
|
|
19
|
+
/**
|
|
20
|
+
* Unregister a generator
|
|
21
|
+
* @param name Name of the generator to unregister
|
|
22
|
+
* @returns true if the generator was removed, false if it didn't exist
|
|
23
|
+
*/
|
|
24
|
+
unregister(name: string): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Get a generator by name
|
|
27
|
+
* @param name Name of the generator
|
|
28
|
+
* @returns The generator or undefined if not found
|
|
29
|
+
*/
|
|
30
|
+
get(name: string): IGenerator | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Check if a generator is registered
|
|
33
|
+
* @param name Name of the generator
|
|
34
|
+
* @returns true if the generator is registered
|
|
35
|
+
*/
|
|
36
|
+
has(name: string): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Get all registered generators
|
|
39
|
+
* @returns Array of all registered generators
|
|
40
|
+
*/
|
|
41
|
+
getAll(): IGenerator[];
|
|
42
|
+
/**
|
|
43
|
+
* Get all generator names
|
|
44
|
+
* @returns Array of all registered generator names
|
|
45
|
+
*/
|
|
46
|
+
getNames(): string[];
|
|
47
|
+
/**
|
|
48
|
+
* Get generators filtered by whether they require CLI
|
|
49
|
+
* @param requiresCLI If true, return only CLI generators; if false, return only builtin
|
|
50
|
+
* @returns Filtered array of generators
|
|
51
|
+
*/
|
|
52
|
+
getByType(requiresCLI: boolean): IGenerator[];
|
|
53
|
+
/**
|
|
54
|
+
* Update CLI availability status
|
|
55
|
+
* @param available Whether CLI is available
|
|
56
|
+
*/
|
|
57
|
+
setCLIAvailable(available: boolean): void;
|
|
58
|
+
/**
|
|
59
|
+
* Check if CLI is available
|
|
60
|
+
*/
|
|
61
|
+
isCLIAvailable(): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Update Java availability status
|
|
64
|
+
* @param available Whether Java is available
|
|
65
|
+
*/
|
|
66
|
+
setJavaAvailable(available: boolean): void;
|
|
67
|
+
/**
|
|
68
|
+
* Check if Java is available
|
|
69
|
+
*/
|
|
70
|
+
isJavaAvailable(): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Get availability status for all generators
|
|
73
|
+
* @returns Array of availability statuses
|
|
74
|
+
*/
|
|
75
|
+
getAvailability(): GeneratorAvailability[];
|
|
76
|
+
/**
|
|
77
|
+
* Get only available generators
|
|
78
|
+
* @returns Array of available generators
|
|
79
|
+
*/
|
|
80
|
+
getAvailable(): IGenerator[];
|
|
81
|
+
/**
|
|
82
|
+
* Clear all registered generators
|
|
83
|
+
*/
|
|
84
|
+
clear(): void;
|
|
85
|
+
/**
|
|
86
|
+
* Get count of registered generators
|
|
87
|
+
*/
|
|
88
|
+
get size(): number;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Get the global generator registry instance
|
|
92
|
+
* @returns The singleton GeneratorRegistry instance
|
|
93
|
+
*/
|
|
94
|
+
export declare function getGeneratorRegistry(): GeneratorRegistry;
|
|
95
|
+
/**
|
|
96
|
+
* Reset the global registry (mainly for testing)
|
|
97
|
+
*/
|
|
98
|
+
export declare function resetGeneratorRegistry(): void;
|
|
99
|
+
export { GeneratorRegistry };
|
|
100
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/generators/registry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAEzE;;GAEG;AACH,cAAM,iBAAiB;IACrB,OAAO,CAAC,UAAU,CAAsC;IACxD,OAAO,CAAC,YAAY,CAAkB;IACtC,OAAO,CAAC,aAAa,CAAkB;IAEvC;;;;OAIG;IACH,QAAQ,CAAC,SAAS,EAAE,UAAU,GAAG,IAAI;IAOrC;;;;OAIG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIjC;;;;OAIG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS;IAIzC;;;;OAIG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI1B;;;OAGG;IACH,MAAM,IAAI,UAAU,EAAE;IAItB;;;OAGG;IACH,QAAQ,IAAI,MAAM,EAAE;IAIpB;;;;OAIG;IACH,SAAS,CAAC,WAAW,EAAE,OAAO,GAAG,UAAU,EAAE;IAI7C;;;OAGG;IACH,eAAe,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI;IAIzC;;OAEG;IACH,cAAc,IAAI,OAAO;IAIzB;;;OAGG;IACH,gBAAgB,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI;IAI1C;;OAEG;IACH,eAAe,IAAI,OAAO;IAI1B;;;OAGG;IACH,eAAe,IAAI,qBAAqB,EAAE;IAyB1C;;;OAGG;IACH,YAAY,IAAI,UAAU,EAAE;IAS5B;;OAEG;IACH,KAAK,IAAI,IAAI;IAIb;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;CACF;AAKD;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,iBAAiB,CAKxD;AAED;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,IAAI,CAK7C;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generator Registry - Dependency Injection Container for Generators
|
|
3
|
+
* Manages registration and retrieval of all generators (builtin and CLI-based)
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Registry for managing generators
|
|
7
|
+
*/
|
|
8
|
+
class GeneratorRegistry {
|
|
9
|
+
generators = new Map();
|
|
10
|
+
cliAvailable = false;
|
|
11
|
+
javaAvailable = false;
|
|
12
|
+
/**
|
|
13
|
+
* Register a generator
|
|
14
|
+
* @param generator The generator to register
|
|
15
|
+
* @throws Error if a generator with the same name is already registered
|
|
16
|
+
*/
|
|
17
|
+
register(generator) {
|
|
18
|
+
if (this.generators.has(generator.name)) {
|
|
19
|
+
throw new Error(`Generator '${generator.name}' is already registered`);
|
|
20
|
+
}
|
|
21
|
+
this.generators.set(generator.name, generator);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Unregister a generator
|
|
25
|
+
* @param name Name of the generator to unregister
|
|
26
|
+
* @returns true if the generator was removed, false if it didn't exist
|
|
27
|
+
*/
|
|
28
|
+
unregister(name) {
|
|
29
|
+
return this.generators.delete(name);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Get a generator by name
|
|
33
|
+
* @param name Name of the generator
|
|
34
|
+
* @returns The generator or undefined if not found
|
|
35
|
+
*/
|
|
36
|
+
get(name) {
|
|
37
|
+
return this.generators.get(name);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Check if a generator is registered
|
|
41
|
+
* @param name Name of the generator
|
|
42
|
+
* @returns true if the generator is registered
|
|
43
|
+
*/
|
|
44
|
+
has(name) {
|
|
45
|
+
return this.generators.has(name);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Get all registered generators
|
|
49
|
+
* @returns Array of all registered generators
|
|
50
|
+
*/
|
|
51
|
+
getAll() {
|
|
52
|
+
return Array.from(this.generators.values());
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Get all generator names
|
|
56
|
+
* @returns Array of all registered generator names
|
|
57
|
+
*/
|
|
58
|
+
getNames() {
|
|
59
|
+
return Array.from(this.generators.keys());
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Get generators filtered by whether they require CLI
|
|
63
|
+
* @param requiresCLI If true, return only CLI generators; if false, return only builtin
|
|
64
|
+
* @returns Filtered array of generators
|
|
65
|
+
*/
|
|
66
|
+
getByType(requiresCLI) {
|
|
67
|
+
return this.getAll().filter(g => g.requiresCLI === requiresCLI);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Update CLI availability status
|
|
71
|
+
* @param available Whether CLI is available
|
|
72
|
+
*/
|
|
73
|
+
setCLIAvailable(available) {
|
|
74
|
+
this.cliAvailable = available;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Check if CLI is available
|
|
78
|
+
*/
|
|
79
|
+
isCLIAvailable() {
|
|
80
|
+
return this.cliAvailable;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Update Java availability status
|
|
84
|
+
* @param available Whether Java is available
|
|
85
|
+
*/
|
|
86
|
+
setJavaAvailable(available) {
|
|
87
|
+
this.javaAvailable = available;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Check if Java is available
|
|
91
|
+
*/
|
|
92
|
+
isJavaAvailable() {
|
|
93
|
+
return this.javaAvailable;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Get availability status for all generators
|
|
97
|
+
* @returns Array of availability statuses
|
|
98
|
+
*/
|
|
99
|
+
getAvailability() {
|
|
100
|
+
return this.getAll().map(generator => {
|
|
101
|
+
const requiresCLI = generator.requiresCLI;
|
|
102
|
+
let available = true;
|
|
103
|
+
let reason;
|
|
104
|
+
if (requiresCLI) {
|
|
105
|
+
if (!this.javaAvailable) {
|
|
106
|
+
available = false;
|
|
107
|
+
reason = 'Java runtime not available';
|
|
108
|
+
}
|
|
109
|
+
else if (!this.cliAvailable) {
|
|
110
|
+
available = false;
|
|
111
|
+
reason = 'CLI not installed (run cml_download_cli)';
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
name: generator.name,
|
|
116
|
+
available,
|
|
117
|
+
requiresCLI,
|
|
118
|
+
reason,
|
|
119
|
+
};
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Get only available generators
|
|
124
|
+
* @returns Array of available generators
|
|
125
|
+
*/
|
|
126
|
+
getAvailable() {
|
|
127
|
+
return this.getAll().filter(generator => {
|
|
128
|
+
if (!generator.requiresCLI) {
|
|
129
|
+
return true;
|
|
130
|
+
}
|
|
131
|
+
return this.javaAvailable && this.cliAvailable;
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Clear all registered generators
|
|
136
|
+
*/
|
|
137
|
+
clear() {
|
|
138
|
+
this.generators.clear();
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Get count of registered generators
|
|
142
|
+
*/
|
|
143
|
+
get size() {
|
|
144
|
+
return this.generators.size;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
// Singleton instance
|
|
148
|
+
let registryInstance = null;
|
|
149
|
+
/**
|
|
150
|
+
* Get the global generator registry instance
|
|
151
|
+
* @returns The singleton GeneratorRegistry instance
|
|
152
|
+
*/
|
|
153
|
+
export function getGeneratorRegistry() {
|
|
154
|
+
if (!registryInstance) {
|
|
155
|
+
registryInstance = new GeneratorRegistry();
|
|
156
|
+
}
|
|
157
|
+
return registryInstance;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Reset the global registry (mainly for testing)
|
|
161
|
+
*/
|
|
162
|
+
export function resetGeneratorRegistry() {
|
|
163
|
+
if (registryInstance) {
|
|
164
|
+
registryInstance.clear();
|
|
165
|
+
}
|
|
166
|
+
registryInstance = null;
|
|
167
|
+
}
|
|
168
|
+
export { GeneratorRegistry };
|
|
169
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/generators/registry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;GAEG;AACH,MAAM,iBAAiB;IACb,UAAU,GAA4B,IAAI,GAAG,EAAE,CAAC;IAChD,YAAY,GAAY,KAAK,CAAC;IAC9B,aAAa,GAAY,KAAK,CAAC;IAEvC;;;;OAIG;IACH,QAAQ,CAAC,SAAqB;QAC5B,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;YACxC,MAAM,IAAI,KAAK,CAAC,cAAc,SAAS,CAAC,IAAI,yBAAyB,CAAC,CAAC;QACzE,CAAC;QACD,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IACjD,CAAC;IAED;;;;OAIG;IACH,UAAU,CAAC,IAAY;QACrB,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;IAED;;;;OAIG;IACH,GAAG,CAAC,IAAY;QACd,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;IAED;;;;OAIG;IACH,GAAG,CAAC,IAAY;QACd,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;IAED;;;OAGG;IACH,MAAM;QACJ,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC;IAC9C,CAAC;IAED;;;OAGG;IACH,QAAQ;QACN,OAAO,KAAK,CAAC,IAAI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