nest-hex 0.2.0 → 0.2.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/README.md +183 -4
- package/dist/src/cli/bin.js +2630 -0
- package/dist/src/cli/commands/index.d.ts +23 -0
- package/dist/src/cli/commands/index.js +2595 -0
- package/dist/src/cli/config/defaults.d.ts +74 -0
- package/dist/src/cli/config/defaults.js +76 -0
- package/dist/src/cli/config/define-config.d.ts +74 -0
- package/dist/src/cli/config/define-config.js +62 -0
- package/dist/src/cli/config/loader.d.ts +74 -0
- package/dist/src/cli/config/loader.js +106 -0
- package/dist/src/cli/config/validator.d.ts +81 -0
- package/dist/src/cli/config/validator.js +108 -0
- package/dist/src/cli/generators/adapter.generator.d.ts +235 -0
- package/dist/src/cli/generators/adapter.generator.js +377 -0
- package/dist/src/cli/generators/base.generator.d.ts +190 -0
- package/dist/src/cli/generators/base.generator.js +312 -0
- package/dist/src/cli/generators/index.d.ts +264 -0
- package/dist/src/cli/generators/index.js +467 -0
- package/dist/src/cli/generators/port.generator.d.ts +211 -0
- package/dist/src/cli/generators/port.generator.js +364 -0
- package/dist/src/cli/generators/service.generator.d.ts +208 -0
- package/dist/src/cli/generators/service.generator.js +340 -0
- package/dist/src/cli/index.d.ts +74 -0
- package/dist/src/cli/index.js +69 -0
- package/dist/src/cli/types/config.types.d.ts +73 -0
- package/dist/src/cli/types/config.types.js +56 -0
- package/dist/src/cli/types/generator.types.d.ts +46 -0
- package/dist/src/cli/types/generator.types.js +56 -0
- package/dist/src/cli/types/index.d.ts +121 -0
- package/dist/src/cli/types/index.js +56 -0
- package/dist/src/cli/types/template.types.d.ts +28 -0
- package/dist/src/cli/types/template.types.js +56 -0
- package/dist/src/cli/ui/components/index.d.ts +97 -0
- package/dist/src/cli/ui/components/index.js +1493 -0
- package/dist/src/cli/utils/file-writer.d.ts +17 -0
- package/dist/src/cli/utils/file-writer.js +100 -0
- package/dist/src/cli/utils/linter-detector.d.ts +12 -0
- package/dist/src/cli/utils/linter-detector.js +128 -0
- package/dist/src/cli/utils/linter-runner.d.ts +17 -0
- package/dist/src/cli/utils/linter-runner.js +101 -0
- package/dist/src/cli/utils/name-transformer.d.ts +18 -0
- package/dist/src/cli/utils/name-transformer.js +90 -0
- package/dist/src/cli/utils/path-resolver.d.ts +5 -0
- package/dist/src/cli/utils/path-resolver.js +78 -0
- package/dist/src/cli/utils/port-scanner.d.ts +93 -0
- package/dist/src/cli/utils/port-scanner.js +104 -0
- package/dist/src/cli/utils/template-renderer.d.ts +30 -0
- package/dist/src/cli/utils/template-renderer.js +95 -0
- package/dist/{index.js → src/index.js} +14 -0
- package/package.json +10 -10
- /package/dist/{index.d.ts → src/index.d.ts} +0 -0
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration types for nest-hex CLI
|
|
3
|
+
*/
|
|
4
|
+
interface NestHexConfig {
|
|
5
|
+
/**
|
|
6
|
+
* Output directory configuration
|
|
7
|
+
*/
|
|
8
|
+
output?: {
|
|
9
|
+
/**
|
|
10
|
+
* Directory for generated ports
|
|
11
|
+
* @default 'src/ports'
|
|
12
|
+
*/
|
|
13
|
+
portsDir?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Directory for generated adapters
|
|
16
|
+
* @default 'src/adapters'
|
|
17
|
+
*/
|
|
18
|
+
adaptersDir?: string;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Naming conventions
|
|
22
|
+
*/
|
|
23
|
+
naming?: {
|
|
24
|
+
/**
|
|
25
|
+
* Suffix for port tokens
|
|
26
|
+
* @default 'PORT'
|
|
27
|
+
*/
|
|
28
|
+
portSuffix?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Suffix for adapter classes
|
|
31
|
+
* @default 'Adapter'
|
|
32
|
+
*/
|
|
33
|
+
adapterSuffix?: string;
|
|
34
|
+
/**
|
|
35
|
+
* File naming case
|
|
36
|
+
* @default 'kebab'
|
|
37
|
+
*/
|
|
38
|
+
fileCase?: "kebab" | "camel" | "pascal";
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Code style preferences
|
|
42
|
+
*/
|
|
43
|
+
style?: {
|
|
44
|
+
/**
|
|
45
|
+
* Indentation style
|
|
46
|
+
* @default 'tab'
|
|
47
|
+
*/
|
|
48
|
+
indent?: "tab" | 2 | 4;
|
|
49
|
+
/**
|
|
50
|
+
* Quote style
|
|
51
|
+
* @default 'single'
|
|
52
|
+
*/
|
|
53
|
+
quotes?: "single" | "double";
|
|
54
|
+
/**
|
|
55
|
+
* Use semicolons
|
|
56
|
+
* @default true
|
|
57
|
+
*/
|
|
58
|
+
semicolons?: boolean;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Custom template paths
|
|
62
|
+
*/
|
|
63
|
+
templates?: {
|
|
64
|
+
portModule?: string;
|
|
65
|
+
portToken?: string;
|
|
66
|
+
portInterface?: string;
|
|
67
|
+
portService?: string;
|
|
68
|
+
adapterModule?: string;
|
|
69
|
+
adapterService?: string;
|
|
70
|
+
adapterTypes?: string;
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Generator types for CLI
|
|
75
|
+
*/
|
|
76
|
+
interface GeneratorOptions {
|
|
77
|
+
name: string;
|
|
78
|
+
outputPath?: string;
|
|
79
|
+
includeModule?: boolean;
|
|
80
|
+
includeService?: boolean;
|
|
81
|
+
registrationType?: "sync" | "async";
|
|
82
|
+
generateExample?: boolean;
|
|
83
|
+
dryRun?: boolean;
|
|
84
|
+
}
|
|
85
|
+
interface GeneratorContext extends Record<string, unknown> {
|
|
86
|
+
original: string;
|
|
87
|
+
kebab: string;
|
|
88
|
+
camel: string;
|
|
89
|
+
pascal: string;
|
|
90
|
+
snake: string;
|
|
91
|
+
screamingSnake: string;
|
|
92
|
+
nameKebab: string;
|
|
93
|
+
nameCamel: string;
|
|
94
|
+
namePascal: string;
|
|
95
|
+
nameSnake: string;
|
|
96
|
+
nameScreamingSnake: string;
|
|
97
|
+
portSuffix: string;
|
|
98
|
+
adapterSuffix: string;
|
|
99
|
+
fileCase: "kebab" | "camel" | "pascal";
|
|
100
|
+
indent: "tab" | number;
|
|
101
|
+
quotes: "single" | "double";
|
|
102
|
+
semicolons: boolean;
|
|
103
|
+
includeModule: boolean;
|
|
104
|
+
includeService: boolean;
|
|
105
|
+
registrationType: "sync" | "async";
|
|
106
|
+
generateExample: boolean;
|
|
107
|
+
coreImportPath: string;
|
|
108
|
+
}
|
|
109
|
+
interface FileToGenerate {
|
|
110
|
+
path: string;
|
|
111
|
+
content: string;
|
|
112
|
+
}
|
|
113
|
+
interface GeneratorResult {
|
|
114
|
+
files: string[];
|
|
115
|
+
success: boolean;
|
|
116
|
+
message?: string;
|
|
117
|
+
}
|
|
118
|
+
interface NameVariations {
|
|
119
|
+
original: string;
|
|
120
|
+
kebab: string;
|
|
121
|
+
camel: string;
|
|
122
|
+
pascal: string;
|
|
123
|
+
snake: string;
|
|
124
|
+
screamingSnake: string;
|
|
125
|
+
}
|
|
126
|
+
declare function generateNameVariations(name: string): NameVariations;
|
|
127
|
+
/**
|
|
128
|
+
* Abstract base class for all generators.
|
|
129
|
+
*
|
|
130
|
+
* Provides common functionality like:
|
|
131
|
+
* - Template rendering
|
|
132
|
+
* - File writing
|
|
133
|
+
* - Name transformations
|
|
134
|
+
* - Path resolution
|
|
135
|
+
*/
|
|
136
|
+
declare abstract class BaseGenerator {
|
|
137
|
+
protected readonly config: NestHexConfig;
|
|
138
|
+
constructor(config: NestHexConfig);
|
|
139
|
+
/**
|
|
140
|
+
* Render a template with the given context.
|
|
141
|
+
*
|
|
142
|
+
* @param templatePath - Path to the Handlebars template file
|
|
143
|
+
* @param context - Template context
|
|
144
|
+
* @returns Rendered template content
|
|
145
|
+
*/
|
|
146
|
+
protected renderTemplate(templatePath: string, context: GeneratorContext): Promise<string>;
|
|
147
|
+
/**
|
|
148
|
+
* Write a file to disk.
|
|
149
|
+
*
|
|
150
|
+
* @param filePath - Destination file path
|
|
151
|
+
* @param content - File content
|
|
152
|
+
* @param dryRun - If true, don't actually write the file
|
|
153
|
+
* @returns WriteResult indicating success and conflict status
|
|
154
|
+
*/
|
|
155
|
+
protected writeFile(filePath: string, content: string, dryRun?: boolean): Promise<import("../utils/file-writer").WriteResult>;
|
|
156
|
+
/**
|
|
157
|
+
* Generate all name variations for a given name.
|
|
158
|
+
*
|
|
159
|
+
* @param name - Original name
|
|
160
|
+
* @returns Object with all name case variations
|
|
161
|
+
*/
|
|
162
|
+
protected getNameVariations(name: string): ReturnType<typeof generateNameVariations>;
|
|
163
|
+
/**
|
|
164
|
+
* Resolve a path relative to the project root.
|
|
165
|
+
*
|
|
166
|
+
* @param relativePath - Relative path
|
|
167
|
+
* @returns Absolute path
|
|
168
|
+
*/
|
|
169
|
+
protected resolvePath(relativePath: string): string;
|
|
170
|
+
/**
|
|
171
|
+
* Get the template directory for a specific generator type.
|
|
172
|
+
*
|
|
173
|
+
* @param type - Generator type (port, adapter, service)
|
|
174
|
+
* @returns Absolute path to template directory
|
|
175
|
+
*/
|
|
176
|
+
protected getTemplateDir(type: "port" | "adapter" | "service" | "examples"): string;
|
|
177
|
+
/**
|
|
178
|
+
* Create a template context from generator options.
|
|
179
|
+
*
|
|
180
|
+
* @param options - Generator options
|
|
181
|
+
* @param additionalContext - Additional context to merge
|
|
182
|
+
* @returns Complete template context
|
|
183
|
+
*/
|
|
184
|
+
protected createTemplateContext(options: GeneratorOptions, additionalContext?: Record<string, unknown>): GeneratorContext;
|
|
185
|
+
/**
|
|
186
|
+
* Generate files from a list of file specifications.
|
|
187
|
+
*
|
|
188
|
+
* @param files - Array of files to generate
|
|
189
|
+
* @param dryRun - If true, don't actually write files
|
|
190
|
+
* @returns Array of successfully generated file paths
|
|
191
|
+
* @throws Error if any files fail to write
|
|
192
|
+
*/
|
|
193
|
+
protected generateFiles(files: FileToGenerate[], dryRun?: boolean): Promise<string[]>;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Additional options for adapter generation.
|
|
197
|
+
*/
|
|
198
|
+
interface AdapterGeneratorOptions extends GeneratorOptions {
|
|
199
|
+
/**
|
|
200
|
+
* Name of the port this adapter implements.
|
|
201
|
+
* Used to generate correct imports and token references.
|
|
202
|
+
*/
|
|
203
|
+
portName?: string;
|
|
204
|
+
/**
|
|
205
|
+
* Path to the port interface file (for imports).
|
|
206
|
+
* If not provided, assumes standard structure.
|
|
207
|
+
*/
|
|
208
|
+
portPath?: string;
|
|
209
|
+
/**
|
|
210
|
+
* Port token name (e.g., "OBJECT_STORAGE_PORT").
|
|
211
|
+
* Used in the @Port decorator.
|
|
212
|
+
*/
|
|
213
|
+
portTokenName?: string;
|
|
214
|
+
/**
|
|
215
|
+
* Technology or service being adapted (e.g., "AWS S3", "HTTP API").
|
|
216
|
+
* Used in documentation comments.
|
|
217
|
+
*/
|
|
218
|
+
technology?: string;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Generator for creating adapter files.
|
|
222
|
+
*
|
|
223
|
+
* Generates:
|
|
224
|
+
* - Adapter class (extends Adapter base class with @Port decorator)
|
|
225
|
+
* - Service implementation (implements the port interface)
|
|
226
|
+
* - Types file (adapter configuration options)
|
|
227
|
+
* - Index file (barrel exports)
|
|
228
|
+
*/
|
|
229
|
+
declare class AdapterGenerator extends BaseGenerator {
|
|
230
|
+
/**
|
|
231
|
+
* Generate all adapter files.
|
|
232
|
+
*/
|
|
233
|
+
generate(options: AdapterGeneratorOptions): Promise<GeneratorResult>;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Generator for creating port files.
|
|
237
|
+
*
|
|
238
|
+
* Generates:
|
|
239
|
+
* - Port interface (domain contract)
|
|
240
|
+
* - Port token (dependency injection token)
|
|
241
|
+
* - Port service (optional - domain service using the port)
|
|
242
|
+
* - Port module (optional - feature module wrapper)
|
|
243
|
+
* - Index file (barrel exports)
|
|
244
|
+
*/
|
|
245
|
+
declare class PortGenerator extends BaseGenerator {
|
|
246
|
+
/**
|
|
247
|
+
* Generate all port files.
|
|
248
|
+
*/
|
|
249
|
+
generate(options: GeneratorOptions): Promise<GeneratorResult>;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Generator for creating standalone services.
|
|
253
|
+
*
|
|
254
|
+
* Generates:
|
|
255
|
+
* - Injectable service that uses @InjectPort to inject an existing port
|
|
256
|
+
* - Can be created with or without port injection scaffolding
|
|
257
|
+
*/
|
|
258
|
+
declare class ServiceGenerator extends BaseGenerator {
|
|
259
|
+
/**
|
|
260
|
+
* Generate service file.
|
|
261
|
+
*/
|
|
262
|
+
generate(options: GeneratorOptions): Promise<GeneratorResult>;
|
|
263
|
+
}
|
|
264
|
+
export { ServiceGenerator, PortGenerator, BaseGenerator, AdapterGeneratorOptions, AdapterGenerator };
|