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,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PlantUML Adapter
|
|
3
|
+
* Wraps the existing PlantUML generator to implement the IGenerator interface
|
|
4
|
+
*/
|
|
5
|
+
import type { CMLModel } from '../../model/types.js';
|
|
6
|
+
import type { IGenerator, GeneratorResult, GeneratorOptions } from '../interfaces.js';
|
|
7
|
+
/**
|
|
8
|
+
* Options for PlantUML Context Map generator
|
|
9
|
+
*/
|
|
10
|
+
export interface PlantUMLContextMapOptions extends GeneratorOptions {
|
|
11
|
+
/** Include aggregates in the diagram */
|
|
12
|
+
includeAggregates?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Options for PlantUML Aggregate generator
|
|
16
|
+
*/
|
|
17
|
+
export interface PlantUMLAggregateOptions extends GeneratorOptions {
|
|
18
|
+
/** Name of the bounded context */
|
|
19
|
+
contextName: string;
|
|
20
|
+
/** Name of the aggregate */
|
|
21
|
+
aggregateName: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* PlantUML Context Map Generator
|
|
25
|
+
* Generates PlantUML syntax for context map diagrams
|
|
26
|
+
*/
|
|
27
|
+
export declare class PlantUMLContextMapGenerator implements IGenerator {
|
|
28
|
+
name: string;
|
|
29
|
+
description: string;
|
|
30
|
+
requiresCLI: boolean;
|
|
31
|
+
outputFormats: string[];
|
|
32
|
+
generate(model: CMLModel, options?: PlantUMLContextMapOptions): Promise<GeneratorResult>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* PlantUML Aggregate Generator
|
|
36
|
+
* Generates PlantUML syntax for aggregate class diagrams
|
|
37
|
+
*/
|
|
38
|
+
export declare class PlantUMLAggregateGenerator implements IGenerator {
|
|
39
|
+
name: string;
|
|
40
|
+
description: string;
|
|
41
|
+
requiresCLI: boolean;
|
|
42
|
+
outputFormats: string[];
|
|
43
|
+
generate(model: CMLModel, options?: PlantUMLAggregateOptions): Promise<GeneratorResult>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* PlantUML Full Model Generator
|
|
47
|
+
* Generates PlantUML syntax for the complete domain model
|
|
48
|
+
*/
|
|
49
|
+
export declare class PlantUMLFullModelGenerator implements IGenerator {
|
|
50
|
+
name: string;
|
|
51
|
+
description: string;
|
|
52
|
+
requiresCLI: boolean;
|
|
53
|
+
outputFormats: string[];
|
|
54
|
+
generate(model: CMLModel, options?: GeneratorOptions): Promise<GeneratorResult>;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Create all PlantUML generators
|
|
58
|
+
*/
|
|
59
|
+
export declare function createPlantUMLGenerators(): IGenerator[];
|
|
60
|
+
//# sourceMappingURL=plantuml-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plantuml-adapter.d.ts","sourceRoot":"","sources":["../../../src/generators/builtin/plantuml-adapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAa,MAAM,sBAAsB,CAAC;AAChE,OAAO,KAAK,EACV,UAAU,EACV,eAAe,EACf,gBAAgB,EAEjB,MAAM,kBAAkB,CAAC;AAQ1B;;GAEG;AACH,MAAM,WAAW,yBAA0B,SAAQ,gBAAgB;IACjE,wCAAwC;IACxC,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,wBAAyB,SAAQ,gBAAgB;IAChE,kCAAkC;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,4BAA4B;IAC5B,aAAa,EAAE,MAAM,CAAC;CACvB;AAED;;;GAGG;AACH,qBAAa,2BAA4B,YAAW,UAAU;IAC5D,IAAI,SAA0B;IAC9B,WAAW,SAAsF;IACjG,WAAW,UAAS;IACpB,aAAa,WAAgB;IAEvB,QAAQ,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,yBAAyB,GAAG,OAAO,CAAC,eAAe,CAAC;CAoB/F;AAED;;;GAGG;AACH,qBAAa,0BAA2B,YAAW,UAAU;IAC3D,IAAI,SAAwB;IAC5B,WAAW,SAA8D;IACzE,WAAW,UAAS;IACpB,aAAa,WAAgB;IAEvB,QAAQ,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,wBAAwB,GAAG,OAAO,CAAC,eAAe,CAAC;CAmE9F;AAED;;;GAGG;AACH,qBAAa,0BAA2B,YAAW,UAAU;IAC3D,IAAI,SAAyB;IAC7B,WAAW,SAA4D;IACvE,WAAW,UAAS;IACpB,aAAa,WAAgB;IAEvB,QAAQ,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,eAAe,CAAC;CAmBtF;AAED;;GAEG;AACH,wBAAgB,wBAAwB,IAAI,UAAU,EAAE,CAMvD"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PlantUML Adapter
|
|
3
|
+
* Wraps the existing PlantUML generator to implement the IGenerator interface
|
|
4
|
+
*/
|
|
5
|
+
import { createSuccessResult, createErrorResult } from '../interfaces.js';
|
|
6
|
+
import { generateContextMapDiagram, generateAggregateDiagram, generateFullModelDiagram, } from '../plantuml.js';
|
|
7
|
+
/**
|
|
8
|
+
* PlantUML Context Map Generator
|
|
9
|
+
* Generates PlantUML syntax for context map diagrams
|
|
10
|
+
*/
|
|
11
|
+
export class PlantUMLContextMapGenerator {
|
|
12
|
+
name = 'plantuml-context-map';
|
|
13
|
+
description = 'Generate PlantUML context map diagram showing bounded contexts and relationships';
|
|
14
|
+
requiresCLI = false;
|
|
15
|
+
outputFormats = ['plantuml'];
|
|
16
|
+
async generate(model, options) {
|
|
17
|
+
try {
|
|
18
|
+
const includeAggregates = options?.includeAggregates ?? false;
|
|
19
|
+
const plantuml = generateContextMapDiagram(model, includeAggregates);
|
|
20
|
+
const output = {
|
|
21
|
+
type: 'content',
|
|
22
|
+
content: plantuml,
|
|
23
|
+
format: 'plantuml',
|
|
24
|
+
description: 'Context map diagram in PlantUML format',
|
|
25
|
+
};
|
|
26
|
+
return createSuccessResult([output]);
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
return createErrorResult('INTERNAL_ERROR', error instanceof Error ? error.message : 'Unknown error generating context map diagram');
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* PlantUML Aggregate Generator
|
|
35
|
+
* Generates PlantUML syntax for aggregate class diagrams
|
|
36
|
+
*/
|
|
37
|
+
export class PlantUMLAggregateGenerator {
|
|
38
|
+
name = 'plantuml-aggregate';
|
|
39
|
+
description = 'Generate PlantUML class diagram for a specific aggregate';
|
|
40
|
+
requiresCLI = false;
|
|
41
|
+
outputFormats = ['plantuml'];
|
|
42
|
+
async generate(model, options) {
|
|
43
|
+
if (!options?.contextName) {
|
|
44
|
+
return createErrorResult('INTERNAL_ERROR', 'contextName is required', 'Provide the name of the bounded context containing the aggregate');
|
|
45
|
+
}
|
|
46
|
+
if (!options?.aggregateName) {
|
|
47
|
+
return createErrorResult('INTERNAL_ERROR', 'aggregateName is required', 'Provide the name of the aggregate to generate the diagram for');
|
|
48
|
+
}
|
|
49
|
+
try {
|
|
50
|
+
// Find the bounded context
|
|
51
|
+
const bc = model.boundedContexts.find((c) => c.name === options.contextName);
|
|
52
|
+
if (!bc) {
|
|
53
|
+
return createErrorResult('INTERNAL_ERROR', `Bounded context '${options.contextName}' not found`);
|
|
54
|
+
}
|
|
55
|
+
// Find the aggregate
|
|
56
|
+
let aggregate = bc.aggregates.find((a) => a.name === options.aggregateName);
|
|
57
|
+
// Also check modules
|
|
58
|
+
if (!aggregate) {
|
|
59
|
+
for (const mod of bc.modules) {
|
|
60
|
+
const found = mod.aggregates.find((a) => a.name === options.aggregateName);
|
|
61
|
+
if (found) {
|
|
62
|
+
aggregate = found;
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (!aggregate) {
|
|
68
|
+
return createErrorResult('INTERNAL_ERROR', `Aggregate '${options.aggregateName}' not found in context '${options.contextName}'`);
|
|
69
|
+
}
|
|
70
|
+
const plantuml = generateAggregateDiagram(aggregate);
|
|
71
|
+
const output = {
|
|
72
|
+
type: 'content',
|
|
73
|
+
content: plantuml,
|
|
74
|
+
format: 'plantuml',
|
|
75
|
+
description: `Class diagram for aggregate '${options.aggregateName}'`,
|
|
76
|
+
};
|
|
77
|
+
return createSuccessResult([output]);
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
return createErrorResult('INTERNAL_ERROR', error instanceof Error ? error.message : 'Unknown error generating aggregate diagram');
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* PlantUML Full Model Generator
|
|
86
|
+
* Generates PlantUML syntax for the complete domain model
|
|
87
|
+
*/
|
|
88
|
+
export class PlantUMLFullModelGenerator {
|
|
89
|
+
name = 'plantuml-full-model';
|
|
90
|
+
description = 'Generate PlantUML diagram of the complete domain model';
|
|
91
|
+
requiresCLI = false;
|
|
92
|
+
outputFormats = ['plantuml'];
|
|
93
|
+
async generate(model, options) {
|
|
94
|
+
try {
|
|
95
|
+
const plantuml = generateFullModelDiagram(model);
|
|
96
|
+
const output = {
|
|
97
|
+
type: 'content',
|
|
98
|
+
content: plantuml,
|
|
99
|
+
format: 'plantuml',
|
|
100
|
+
description: 'Full domain model diagram in PlantUML format',
|
|
101
|
+
};
|
|
102
|
+
return createSuccessResult([output]);
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
return createErrorResult('INTERNAL_ERROR', error instanceof Error ? error.message : 'Unknown error generating full model diagram');
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Create all PlantUML generators
|
|
111
|
+
*/
|
|
112
|
+
export function createPlantUMLGenerators() {
|
|
113
|
+
return [
|
|
114
|
+
new PlantUMLContextMapGenerator(),
|
|
115
|
+
new PlantUMLAggregateGenerator(),
|
|
116
|
+
new PlantUMLFullModelGenerator(),
|
|
117
|
+
];
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=plantuml-adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plantuml-adapter.js","sourceRoot":"","sources":["../../../src/generators/builtin/plantuml-adapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EACL,yBAAyB,EACzB,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,gBAAgB,CAAC;AAoBxB;;;GAGG;AACH,MAAM,OAAO,2BAA2B;IACtC,IAAI,GAAG,sBAAsB,CAAC;IAC9B,WAAW,GAAG,kFAAkF,CAAC;IACjG,WAAW,GAAG,KAAK,CAAC;IACpB,aAAa,GAAG,CAAC,UAAU,CAAC,CAAC;IAE7B,KAAK,CAAC,QAAQ,CAAC,KAAe,EAAE,OAAmC;QACjE,IAAI,CAAC;YACH,MAAM,iBAAiB,GAAG,OAAO,EAAE,iB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,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,0BAA0B;IACrC,IAAI,GAAG,qBAAqB,CAAC;IAC7B,WAAW,GAAG,wDAAwD,CAAC;IACvE,WAAW,GAAG,KAAK,CAAC;IACpB,aAAa,GAAG,CAAC,UAAU,CAAC,CAAC;IAE7B,KAAK,CAAC,QAAQ,CAAC,KAAe,EAAE,OAA0B;QACxD,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,wBAAwB,CAAC,KAAK,CAAC,CAAC;YAEjD,MAAM,MAAM,GAAoB;gBAC9B,IAAI,EAAE,SAAS;gBACf,OAAO,EAAE,QAAQ;gBACjB,MAAM,EAAE,UAAU;gBAClB,WAAW,EAAE,8CAA8C;aAC5D,CAAC;YAEF,OAAO,mBAAmB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;QACvC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,iBAAiB,CACtB,gBAAgB,EAChB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,6CAA6C,CACvF,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,wBAAwB;IACtC,OAAO;QACL,IAAI,2BAA2B,EAAE;QACjC,IAAI,0BAA0B,EAAE;QAChC,IAAI,0BAA0B,EAAE;KACjC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI Configuration
|
|
3
|
+
* Manages paths, versions, and settings for the Context Mapper CLI
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Default CLI version to use
|
|
7
|
+
*/
|
|
8
|
+
export declare const DEFAULT_CLI_VERSION = "6.12.0";
|
|
9
|
+
/**
|
|
10
|
+
* Maven Central base URL for CLI downloads
|
|
11
|
+
*/
|
|
12
|
+
export declare const MAVEN_BASE_URL = "https://repo1.maven.org/maven2/org/contextmapper/context-mapper-cli";
|
|
13
|
+
/**
|
|
14
|
+
* Minimum required Java version
|
|
15
|
+
*/
|
|
16
|
+
export declare const MIN_JAVA_VERSION = 17;
|
|
17
|
+
/**
|
|
18
|
+
* Default timeout for CLI operations (5 minutes)
|
|
19
|
+
*/
|
|
20
|
+
export declare const DEFAULT_CLI_TIMEOUT: number;
|
|
21
|
+
/**
|
|
22
|
+
* CLI Configuration interface
|
|
23
|
+
*/
|
|
24
|
+
export interface CLIConfig {
|
|
25
|
+
/** Directory where CLI is installed */
|
|
26
|
+
cliDir: string;
|
|
27
|
+
/** CLI version to use */
|
|
28
|
+
version: string;
|
|
29
|
+
/** Path to java executable (or null to auto-detect) */
|
|
30
|
+
javaHome: string | null;
|
|
31
|
+
/** Default output directory for generated files */
|
|
32
|
+
outputDir: string;
|
|
33
|
+
/** Default timeout for CLI operations in milliseconds */
|
|
34
|
+
timeout: number;
|
|
35
|
+
/** Directory containing bundled templates */
|
|
36
|
+
templatesDir: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Get the default CLI installation directory
|
|
40
|
+
*/
|
|
41
|
+
export declare function getDefaultCLIDir(): string;
|
|
42
|
+
/**
|
|
43
|
+
* Get the default output directory
|
|
44
|
+
*/
|
|
45
|
+
export declare function getDefaultOutputDir(): string;
|
|
46
|
+
/**
|
|
47
|
+
* Get the bundled templates directory
|
|
48
|
+
*/
|
|
49
|
+
export declare function getTemplatesDir(): string;
|
|
50
|
+
/**
|
|
51
|
+
* Get the current CLI configuration
|
|
52
|
+
*/
|
|
53
|
+
export declare function getCLIConfig(): CLIConfig;
|
|
54
|
+
/**
|
|
55
|
+
* Update CLI configuration
|
|
56
|
+
* @param updates Partial configuration to merge
|
|
57
|
+
*/
|
|
58
|
+
export declare function setCLIConfig(updates: Partial<CLIConfig>): CLIConfig;
|
|
59
|
+
/**
|
|
60
|
+
* Reset CLI configuration to defaults
|
|
61
|
+
*/
|
|
62
|
+
export declare function resetCLIConfig(): CLIConfig;
|
|
63
|
+
/**
|
|
64
|
+
* Get the directory for a specific CLI version
|
|
65
|
+
*/
|
|
66
|
+
export declare function getCLIVersionDir(version?: string): string;
|
|
67
|
+
/**
|
|
68
|
+
* Get the CLI executable path
|
|
69
|
+
*/
|
|
70
|
+
export declare function getCLIExecutablePath(version?: string): string;
|
|
71
|
+
/**
|
|
72
|
+
* Get the Java executable path
|
|
73
|
+
*/
|
|
74
|
+
export declare function getJavaExecutablePath(): string;
|
|
75
|
+
/**
|
|
76
|
+
* Get download URL for CLI archive
|
|
77
|
+
* @param version CLI version
|
|
78
|
+
*/
|
|
79
|
+
export declare function getCLIDownloadUrl(version?: string): string;
|
|
80
|
+
/**
|
|
81
|
+
* Get the current platform type
|
|
82
|
+
*/
|
|
83
|
+
export declare function getPlatformType(): 'windows' | 'unix';
|
|
84
|
+
/**
|
|
85
|
+
* Check if we're running on Windows
|
|
86
|
+
*/
|
|
87
|
+
export declare function isWindows(): boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Configuration for bundled template lookup
|
|
90
|
+
*/
|
|
91
|
+
export interface BundledTemplateInfo {
|
|
92
|
+
name: string;
|
|
93
|
+
path: string;
|
|
94
|
+
description: string;
|
|
95
|
+
outputExtension: string;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Get information about bundled templates
|
|
99
|
+
*/
|
|
100
|
+
export declare function getBundledTemplates(): BundledTemplateInfo[];
|
|
101
|
+
/**
|
|
102
|
+
* Get a bundled template by name
|
|
103
|
+
*/
|
|
104
|
+
export declare function getBundledTemplate(name: string): BundledTemplateInfo | undefined;
|
|
105
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/generators/cli/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAWH;;GAEG;AACH,eAAO,MAAM,mBAAmB,WAAW,CAAC;AAE5C;;GAEG;AACH,eAAO,MAAM,cAAc,wEAAwE,CAAC;A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E,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,mBAAmB,EAAE,CA4B3D;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,mBAAmB,GAAG,SAAS,CAEhF"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI Configuration
|
|
3
|
+
* Manages paths, versions, and settings for the Context Mapper CLI
|
|
4
|
+
*/
|
|
5
|
+
import { homedir, platform } from 'os';
|
|
6
|
+
import { join, dirname } from 'path';
|
|
7
|
+
import { fileURLToPath } from 'url';
|
|
8
|
+
// Get package root directory
|
|
9
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
10
|
+
const __dirname = dirname(__filename);
|
|
11
|
+
const PACKAGE_ROOT = join(__dirname, '..', '..', '..');
|
|
12
|
+
/**
|
|
13
|
+
* Default CLI version to use
|
|
14
|
+
*/
|
|
15
|
+
export const DEFAULT_CLI_VERSION = '6.12.0';
|
|
16
|
+
/**
|
|
17
|
+
* Maven Central base URL for CLI downloads
|
|
18
|
+
*/
|
|
19
|
+
export const MAVEN_BASE_URL = 'https://repo1.maven.org/maven2/org/contextmapper/context-mapper-cli';
|
|
20
|
+
/**
|
|
21
|
+
* Minimum required Java version
|
|
22
|
+
*/
|
|
23
|
+
export const MIN_JAVA_VERSION = 17;
|
|
24
|
+
/**
|
|
25
|
+
* Default timeout for CLI operations (5 minutes)
|
|
26
|
+
*/
|
|
27
|
+
export const DEFAULT_CLI_TIMEOUT = 5 * 60 * 1000;
|
|
28
|
+
/**
|
|
29
|
+
* Get the default CLI installation directory
|
|
30
|
+
*/
|
|
31
|
+
export function getDefaultCLIDir() {
|
|
32
|
+
return join(homedir(), '.context-mapper-mcp', 'cli');
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Get the default output directory
|
|
36
|
+
*/
|
|
37
|
+
export function getDefaultOutputDir() {
|
|
38
|
+
return join(process.cwd(), 'generated');
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Get the bundled templates directory
|
|
42
|
+
*/
|
|
43
|
+
export function getTemplatesDir() {
|
|
44
|
+
return join(PACKAGE_ROOT, 'src', 'templates');
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Current CLI configuration (singleton)
|
|
48
|
+
*/
|
|
49
|
+
let currentConfig = {
|
|
50
|
+
cliDir: getDefaultCLIDir(),
|
|
51
|
+
version: DEFAULT_CLI_VERSION,
|
|
52
|
+
javaHome: process.env.JAVA_HOME || null,
|
|
53
|
+
outputDir: getDefaultOutputDir(),
|
|
54
|
+
timeout: DEFAULT_CLI_TIMEOUT,
|
|
55
|
+
templatesDir: getTemplatesDir(),
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Get the current CLI configuration
|
|
59
|
+
*/
|
|
60
|
+
export function getCLIConfig() {
|
|
61
|
+
return { ...currentConfig };
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Update CLI configuration
|
|
65
|
+
* @param updates Partial configuration to merge
|
|
66
|
+
*/
|
|
67
|
+
export function setCLIConfig(updates) {
|
|
68
|
+
currentConfig = { ...currentConfig, ...updates };
|
|
69
|
+
return getCLIConfig();
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Reset CLI configuration to defaults
|
|
73
|
+
*/
|
|
74
|
+
export function resetCLIConfig() {
|
|
75
|
+
currentConfig = {
|
|
76
|
+
cliDir: getDefaultCLIDir(),
|
|
77
|
+
version: DEFAULT_CLI_VERSION,
|
|
78
|
+
javaHome: process.env.JAVA_HOME || null,
|
|
79
|
+
outputDir: getDefaultOutputDir(),
|
|
80
|
+
timeout: DEFAULT_CLI_TIMEOUT,
|
|
81
|
+
templatesDir: getTemplatesDir(),
|
|
82
|
+
};
|
|
83
|
+
return getCLIConfig();
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Get the directory for a specific CLI version
|
|
87
|
+
*/
|
|
88
|
+
export function getCLIVersionDir(version = currentConfig.version) {
|
|
89
|
+
return join(currentConfig.cliDir, version);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Get the CLI executable path
|
|
93
|
+
*/
|
|
94
|
+
export function getCLIExecutablePath(version = currentConfig.version) {
|
|
95
|
+
const versionDir = getCLIVersionDir(version);
|
|
96
|
+
const executable = platform() === 'win32' ? 'cm.bat' : 'cm';
|
|
97
|
+
return join(versionDir, 'bin', executable);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Get the Java executable path
|
|
101
|
+
*/
|
|
102
|
+
export function getJavaExecutablePath() {
|
|
103
|
+
if (currentConfig.javaHome) {
|
|
104
|
+
const executable = platform() === 'win32' ? 'java.exe' : 'java';
|
|
105
|
+
return join(currentConfig.javaHome, 'bin', executable);
|
|
106
|
+
}
|
|
107
|
+
// Fall back to PATH
|
|
108
|
+
return 'java';
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Get download URL for CLI archive
|
|
112
|
+
* @param version CLI version
|
|
113
|
+
*/
|
|
114
|
+
export function getCLIDownloadUrl(version = currentConfig.version) {
|
|
115
|
+
const extension = platform() === 'win32' ? 'zip' : 'tar';
|
|
116
|
+
return `${MAVEN_BASE_URL}/${version}/context-mapper-cli-${version}.${extension}`;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Get the current platform type
|
|
120
|
+
*/
|
|
121
|
+
export function getPlatformType() {
|
|
122
|
+
return platform() === 'win32' ? 'windows' : 'unix';
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Check if we're running on Windows
|
|
126
|
+
*/
|
|
127
|
+
export function isWindows() {
|
|
128
|
+
return platform() === 'win32';
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Get information about bundled templates
|
|
132
|
+
*/
|
|
133
|
+
export function getBundledTemplates() {
|
|
134
|
+
const templatesDir = currentConfig.templatesDir;
|
|
135
|
+
return [
|
|
136
|
+
{
|
|
137
|
+
name: 'glossary',
|
|
138
|
+
path: join(templatesDir, 'GlossaryTemplate.md.ftl'),
|
|
139
|
+
description: 'Ubiquitous language glossary',
|
|
140
|
+
outputExtension: 'md',
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
name: 'jhipster-microservices',
|
|
144
|
+
path: join(templatesDir, 'JHipster-Microservices.jdl.ftl'),
|
|
145
|
+
description: 'JHipster microservices architecture',
|
|
146
|
+
outputExtension: 'jdl',
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
name: 'jhipster-monolith',
|
|
150
|
+
path: join(templatesDir, 'JHipster-Monolith.jdl.ftl'),
|
|
151
|
+
description: 'JHipster monolithic application',
|
|
152
|
+
outputExtension: 'jdl',
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
name: 'full-report',
|
|
156
|
+
path: join(templatesDir, 'FullReportTemplate.md.ftl'),
|
|
157
|
+
description: 'Comprehensive domain documentation',
|
|
158
|
+
outputExtension: 'md',
|
|
159
|
+
},
|
|
160
|
+
];
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Get a bundled template by name
|
|
164
|
+
*/
|
|
165
|
+
export function getBundledTemplate(name) {
|
|
166
|
+
return getBundledTemplates().find(t => t.name === name);
|
|
167
|
+
}
|
|
168
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/generators/cli/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,6BAA6B;AAC7B,M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kB,CAAC,IAAY;IAC7C,OAAO,mBAAmB,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;AAC1D,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context Map CLI Generator
|
|
3
|
+
* Generates Context Map graphics (PNG/SVG) using the Context Mapper CLI
|
|
4
|
+
*/
|
|
5
|
+
import type { CMLModel } from '../../model/types.js';
|
|
6
|
+
import type { IGenerator, GeneratorResult, ContextMapGeneratorOptions } from '../interfaces.js';
|
|
7
|
+
/**
|
|
8
|
+
* Context Map Image Generator
|
|
9
|
+
* Uses CLI to generate PNG or SVG context map visualizations
|
|
10
|
+
*/
|
|
11
|
+
export declare class ContextMapImageGenerator implements IGenerator {
|
|
12
|
+
name: string;
|
|
13
|
+
description: string;
|
|
14
|
+
requiresCLI: boolean;
|
|
15
|
+
outputFormats: string[];
|
|
16
|
+
generate(model: CMLModel, options?: ContextMapGeneratorOptions): Promise<GeneratorResult>;
|
|
17
|
+
/**
|
|
18
|
+
* Find generated files in the output directory
|
|
19
|
+
*/
|
|
20
|
+
private findGeneratedFiles;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Create the Context Map image generator
|
|
24
|
+
*/
|
|
25
|
+
export declare function createContextMapImageGenerator(): IGenerator;
|
|
26
|
+
//# sourceMappingURL=context-map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-map.d.ts","sourceRoot":"","sources":["../../../src/generators/cli/context-map.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EACV,UAAU,EACV,eAAe,EACf,0BAA0B,EAE3B,MAAM,kBAAkB,CAAC;AAc1B;;;GAGG;AACH,qBAAa,wBAAyB,YAAW,UAAU;IACzD,IAAI,SAAuB;IAC3B,WAAW,SAA2E;IACtF,WAAW,UAAQ;IACnB,aAAa,WAAkB;IAEzB,QAAQ,CACZ,KAAK,EAAE,QAAQ,EACf,OAAO,CAAC,EAAE,0BAA0B,GACnC,OAAO,CAAC,eAAe,CAAC;IA4G3B;;OAEG;YACW,kBAAkB;CAyBjC;AAED;;GAEG;AACH,wBAAgB,8BAA8B,IAAI,UAAU,CAE3D"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context Map CLI Generator
|
|
3
|
+
* Generates Context Map graphics (PNG/SVG) using the Context Mapper CLI
|
|
4
|
+
*/
|
|
5
|
+
import { readdir, stat } from 'fs/promises';
|
|
6
|
+
import { join, basename } from 'path';
|
|
7
|
+
import { createSuccessResult, createErrorResult, cliNotFoundError, javaNotFoundError, javaVersionError, executionTimeoutError, } from '../interfaces.js';
|
|
8
|
+
import { serializeCML } from '../../model/writer.js';
|
|
9
|
+
import { withTempFiles } from '../../utils/temp-files.js';
|
|
10
|
+
import { getCLIExecutor, getCLIStatus } from './executor.js';
|
|
11
|
+
import { getCLIConfig } from './config.js';
|
|
12
|
+
/**
|
|
13
|
+
* Context Map Image Generator
|
|
14
|
+
* Uses CLI to generate PNG or SVG context map visualizations
|
|
15
|
+
*/
|
|
16
|
+
export class ContextMapImageGenerator {
|
|
17
|
+
name = 'context-map-image';
|
|
18
|
+
description = 'Generate Context Map visualization (PNG/SVG) using Context Mapper CLI';
|
|
19
|
+
requiresCLI = true;
|
|
20
|
+
outputFormats = ['png', 'svg'];
|
|
21
|
+
async generate(model, options) {
|
|
22
|
+
// Check prerequisites
|
|
23
|
+
const status = await getCLIStatus();
|
|
24
|
+
if (!status.javaAvailable) {
|
|
25
|
+
return javaNotFoundError();
|
|
26
|
+
}
|
|
27
|
+
if (!status.javaCompatible) {
|
|
28
|
+
return javaVersionError(status.javaVersion || 'unknown');
|
|
29
|
+
}
|
|
30
|
+
if (!status.cliInstalled) {
|
|
31
|
+
return cliNotFoundError();
|
|
32
|
+
}
|
|
33
|
+
// Use temp files with automatic cleanup
|
|
34
|
+
return withTempFiles(async (tempContext) => {
|
|
35
|
+
try {
|
|
36
|
+
// Serialize model to CML
|
|
37
|
+
const cmlContent = serializeCML(model);
|
|
38
|
+
const tempDir = await tempContext.createDir();
|
|
39
|
+
const cmlPath = await tempContext.createCMLFile(cmlContent, tempDir);
|
|
40
|
+
// Determine output directory
|
|
41
|
+
const config = getCLIConfig();
|
|
42
|
+
const outputDir = options?.outputDir ?? config.outputDir;
|
|
43
|
+
// Build extra arguments
|
|
44
|
+
const extraArgs = [];
|
|
45
|
+
// Format option
|
|
46
|
+
const format = options?.format ?? 'png';
|
|
47
|
+
// Context Map generator always outputs to png/svg based on format arg
|
|
48
|
+
if (format === 'svg') {
|
|
49
|
+
extraArgs.push('--outputFormat', 'svg');
|
|
50
|
+
}
|
|
51
|
+
// Width/height options
|
|
52
|
+
if (options?.width) {
|
|
53
|
+
extraArgs.push('--width', options.width.toString());
|
|
54
|
+
}
|
|
55
|
+
if (options?.height) {
|
|
56
|
+
extraArgs.push('--height', options.height.toString());
|
|
57
|
+
}
|
|
58
|
+
if (options?.fixWidth) {
|
|
59
|
+
extraArgs.push('--fix-width');
|
|
60
|
+
}
|
|
61
|
+
if (options?.fixHeight) {
|
|
62
|
+
extraArgs.push('--fix-height');
|
|
63
|
+
}
|
|
64
|
+
// Execute CLI
|
|
65
|
+
const executor = getCLIExecutor();
|
|
66
|
+
const result = await executor.generate(cmlPath, 'context-map', outputDir, extraArgs, { timeout: options?.timeout });
|
|
67
|
+
if (result.timedOut) {
|
|
68
|
+
return executionTimeoutError(options?.timeout ?? config.timeout);
|
|
69
|
+
}
|
|
70
|
+
if (!result.success) {
|
|
71
|
+
return createErrorResult('EXECUTION_FAILED', result.error || 'CLI execution failed', 'Check the CML model for errors using cml_validate_model', result.stderr);
|
|
72
|
+
}
|
|
73
|
+
// Find generated files
|
|
74
|
+
const generatedFiles = await this.findGeneratedFiles(outputDir, format);
|
|
75
|
+
if (generatedFiles.length === 0) {
|
|
76
|
+
return createErrorResult('OUTPUT_NOT_FOUND', 'No output files were generated', 'Ensure the model has a context map defined');
|
|
77
|
+
}
|
|
78
|
+
const outputs = generatedFiles.map((filePath) => ({
|
|
79
|
+
type: 'file',
|
|
80
|
+
path: filePath,
|
|
81
|
+
format,
|
|
82
|
+
description: `Context Map image: ${basename(filePath)}`,
|
|
83
|
+
}));
|
|
84
|
+
// Include any warnings from stderr
|
|
85
|
+
const warnings = result.stderr
|
|
86
|
+
? result.stderr.split('\n').filter((line) => line.trim().length > 0)
|
|
87
|
+
: undefined;
|
|
88
|
+
return createSuccessResult(outputs, warnings);
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
return createErrorResult('INTERNAL_ERROR', error instanceof Error ? error.message : 'Unknown error during generation');
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Find generated files in the output directory
|
|
97
|
+
*/
|
|
98
|
+
async findGeneratedFiles(outputDir, format) {
|
|
99
|
+
const files = [];
|
|
100
|
+
try {
|
|
101
|
+
const entries = await readdir(outputDir);
|
|
102
|
+
for (const entry of entries) {
|
|
103
|
+
if (entry.endsWith(`.${format}`)) {
|
|
104
|
+
const entryPath = join(outputDir, entry);
|
|
105
|
+
const entryStat = await stat(entryPath);
|
|
106
|
+
if (entryStat.isFile()) {
|
|
107
|
+
files.push(entryPath);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
// Directory may not exist
|
|
114
|
+
}
|
|
115
|
+
return files;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Create the Context Map image generator
|
|
120
|
+
*/
|
|
121
|
+
export function createContextMapImageGenerator() {
|
|
122
|
+
return new ContextMapImageGenerator();
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=context-map.js.map
|
|
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