@gravito/scaffold 3.2.0 → 4.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/README.md +30 -6
- package/dist/index.cjs +491 -87
- package/dist/index.d.ts +240 -3
- package/dist/index.js +491 -87
- package/package.json +5 -2
- package/dist/index.d.cts +0 -686
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gravito/scaffold",
|
|
3
|
-
"
|
|
3
|
+
"sideEffects": false,
|
|
4
|
+
"version": "4.1.0",
|
|
4
5
|
"description": "Project scaffolding engine for Gravito - Generate enterprise-grade architecture templates",
|
|
5
6
|
"type": "module",
|
|
6
7
|
"main": "dist/index.js",
|
|
@@ -15,6 +16,7 @@
|
|
|
15
16
|
},
|
|
16
17
|
"scripts": {
|
|
17
18
|
"build": "bun run build.ts",
|
|
19
|
+
"build:dts": "bun run build.ts --dts-only",
|
|
18
20
|
"dev": "bun run --watch src/index.ts",
|
|
19
21
|
"test": "bun test --timeout=10000",
|
|
20
22
|
"typecheck": "bun tsc -p tsconfig.json --noEmit --skipLibCheck",
|
|
@@ -35,12 +37,13 @@
|
|
|
35
37
|
"handlebars": "^4.7.8"
|
|
36
38
|
},
|
|
37
39
|
"devDependencies": {
|
|
40
|
+
"@gravito/core": "workspace:*",
|
|
38
41
|
"tsup": "^8.5.1",
|
|
39
42
|
"typescript": "^5.9.3",
|
|
40
43
|
"bun-types": "latest"
|
|
41
44
|
},
|
|
42
45
|
"peerDependencies": {
|
|
43
|
-
"@gravito/core": "^
|
|
46
|
+
"@gravito/core": "^2.0.0"
|
|
44
47
|
},
|
|
45
48
|
"author": "Carl Lee <carllee0520@gmail.com>",
|
|
46
49
|
"license": "MIT",
|
package/dist/index.d.cts
DELETED
|
@@ -1,686 +0,0 @@
|
|
|
1
|
-
import Handlebars from 'handlebars';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Supported project profiles defining the set of included orbits and default drivers.
|
|
5
|
-
*
|
|
6
|
-
* @public
|
|
7
|
-
* @since 3.0.0
|
|
8
|
-
*/
|
|
9
|
-
type ProfileType = 'core' | 'scale' | 'enterprise';
|
|
10
|
-
/**
|
|
11
|
-
* Resolved configuration for a project profile.
|
|
12
|
-
*
|
|
13
|
-
* @public
|
|
14
|
-
* @since 3.0.0
|
|
15
|
-
*/
|
|
16
|
-
interface ProfileConfig {
|
|
17
|
-
/** Map of default service drivers. */
|
|
18
|
-
drivers: {
|
|
19
|
-
database: string;
|
|
20
|
-
cache: string;
|
|
21
|
-
queue: string;
|
|
22
|
-
storage: string;
|
|
23
|
-
session: string;
|
|
24
|
-
};
|
|
25
|
-
/** List of enabled features and orbits. */
|
|
26
|
-
features: string[];
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* ProfileResolver manages the resolution of project profiles and feature add-ons.
|
|
30
|
-
*
|
|
31
|
-
* It maps high-level profiles (Core, Scale, Enterprise) to specific sets of
|
|
32
|
-
* service drivers and orbits, and handles the conditional inclusion of
|
|
33
|
-
* additional features.
|
|
34
|
-
*
|
|
35
|
-
* @public
|
|
36
|
-
* @since 3.0.0
|
|
37
|
-
*/
|
|
38
|
-
declare class ProfileResolver {
|
|
39
|
-
private static readonly DEFAULTS;
|
|
40
|
-
resolve(profile?: ProfileType, withFeatures?: string[]): ProfileConfig;
|
|
41
|
-
private applyFeature;
|
|
42
|
-
/**
|
|
43
|
-
* Validator for profile names
|
|
44
|
-
*/
|
|
45
|
-
isValidProfile(profile: string): profile is ProfileType;
|
|
46
|
-
/**
|
|
47
|
-
* Validator for feature names
|
|
48
|
-
*/
|
|
49
|
-
isValidFeature(feature: string): boolean;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* package.json 結構
|
|
54
|
-
*/
|
|
55
|
-
interface PackageJson {
|
|
56
|
-
name?: string;
|
|
57
|
-
version?: string;
|
|
58
|
-
dependencies?: Record<string, string>;
|
|
59
|
-
devDependencies?: Record<string, string>;
|
|
60
|
-
[key: string]: unknown;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* 驗證結果
|
|
64
|
-
*/
|
|
65
|
-
interface ValidationResult {
|
|
66
|
-
/** 是否通過驗證 */
|
|
67
|
-
valid: boolean;
|
|
68
|
-
/** 錯誤訊息列表 (阻塞性問題) */
|
|
69
|
-
errors: string[];
|
|
70
|
-
/** 警告訊息列表 (非阻塞性問題) */
|
|
71
|
-
warnings: string[];
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* 依賴驗證器
|
|
75
|
-
*
|
|
76
|
-
* 負責驗證 Profile 配置的依賴完整性,包括:
|
|
77
|
-
* - Driver 必需的 packages
|
|
78
|
-
* - Feature 之間的衝突
|
|
79
|
-
* - Feature 的依賴關係
|
|
80
|
-
*
|
|
81
|
-
* @example
|
|
82
|
-
* ```typescript
|
|
83
|
-
* const validator = new DependencyValidator()
|
|
84
|
-
* const result = validator.validate(profileConfig, packageJson)
|
|
85
|
-
*
|
|
86
|
-
* if (!result.valid) {
|
|
87
|
-
* console.error('依賴驗證失敗:', result.errors)
|
|
88
|
-
* }
|
|
89
|
-
* ```
|
|
90
|
-
*
|
|
91
|
-
* @since 3.1.0
|
|
92
|
-
* @public
|
|
93
|
-
*/
|
|
94
|
-
declare class DependencyValidator {
|
|
95
|
-
/**
|
|
96
|
-
* Driver 到 Package 的映射規則
|
|
97
|
-
*/
|
|
98
|
-
private static readonly DRIVER_DEPENDENCIES;
|
|
99
|
-
/**
|
|
100
|
-
* Feature 衝突規則
|
|
101
|
-
*/
|
|
102
|
-
private static readonly CONFLICTS;
|
|
103
|
-
/**
|
|
104
|
-
* Feature 依賴映射
|
|
105
|
-
*/
|
|
106
|
-
private static readonly FEATURE_DEPENDENCIES;
|
|
107
|
-
/**
|
|
108
|
-
* 驗證 Profile 配置
|
|
109
|
-
*
|
|
110
|
-
* @param config - Profile 配置
|
|
111
|
-
* @param packageJson - 專案的 package.json 內容
|
|
112
|
-
* @returns 驗證結果
|
|
113
|
-
*/
|
|
114
|
-
validate(config: ProfileConfig, packageJson: PackageJson): ValidationResult;
|
|
115
|
-
/**
|
|
116
|
-
* 驗證 driver 依賴
|
|
117
|
-
*/
|
|
118
|
-
private validateDriverDependencies;
|
|
119
|
-
/**
|
|
120
|
-
* 驗證 feature 衝突
|
|
121
|
-
*/
|
|
122
|
-
private validateFeatureConflicts;
|
|
123
|
-
/**
|
|
124
|
-
* 驗證 feature 依賴
|
|
125
|
-
*/
|
|
126
|
-
private validateFeatureDependencies;
|
|
127
|
-
/**
|
|
128
|
-
* 檢查 package.json 是否包含指定 package
|
|
129
|
-
*/
|
|
130
|
-
private hasPackage;
|
|
131
|
-
/**
|
|
132
|
-
* 建議安裝缺失的依賴
|
|
133
|
-
*
|
|
134
|
-
* @param result - 驗證結果
|
|
135
|
-
* @returns 安裝命令建議
|
|
136
|
-
*/
|
|
137
|
-
static suggestInstallCommand(result: ValidationResult): string | null;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Represents the results of an environment detection scan.
|
|
142
|
-
*
|
|
143
|
-
* @public
|
|
144
|
-
* @since 3.0.0
|
|
145
|
-
*/
|
|
146
|
-
interface DetectedEnvironment {
|
|
147
|
-
/** The detected cloud or hosting platform. */
|
|
148
|
-
platform: 'aws' | 'gcp' | 'azure' | 'k8s' | 'vercel' | 'netlify' | 'unknown';
|
|
149
|
-
/** The project profile most suitable for this environment. */
|
|
150
|
-
suggestedProfile: ProfileType;
|
|
151
|
-
/** The degree of certainty in the detection. */
|
|
152
|
-
confidence: 'high' | 'medium' | 'low';
|
|
153
|
-
/** The reason or heuristic used for the detection. */
|
|
154
|
-
reason: string;
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* EnvironmentDetector inspects environment variables to identify the hosting platform.
|
|
158
|
-
*
|
|
159
|
-
* It uses these heuristics to suggest the most appropriate project profile
|
|
160
|
-
* (Core, Scale, or Enterprise) for the current environment.
|
|
161
|
-
*
|
|
162
|
-
* @public
|
|
163
|
-
* @since 3.0.0
|
|
164
|
-
*/
|
|
165
|
-
declare class EnvironmentDetector {
|
|
166
|
-
detect(): DetectedEnvironment;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* FileMerger handles the intelligent merging of file contents during scaffolding.
|
|
171
|
-
*
|
|
172
|
-
* It understands different file formats (JSON, ENV) and applies appropriate
|
|
173
|
-
* merging strategies instead of simple overwriting.
|
|
174
|
-
*
|
|
175
|
-
* @public
|
|
176
|
-
* @since 3.0.0
|
|
177
|
-
*/
|
|
178
|
-
declare class FileMerger {
|
|
179
|
-
/**
|
|
180
|
-
* Merge content of two files based on their type.
|
|
181
|
-
*/
|
|
182
|
-
merge(fileName: string, baseContent: string, overlayContent: string): string;
|
|
183
|
-
private mergeJson;
|
|
184
|
-
private mergeEnv;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* Architecture patterns supported by the scaffolding engine.
|
|
189
|
-
*
|
|
190
|
-
* @public
|
|
191
|
-
* @since 3.0.0
|
|
192
|
-
*/
|
|
193
|
-
type ArchitectureType = 'enterprise-mvc' | 'clean' | 'ddd' | 'satellite' | 'action-domain' | 'standalone-engine';
|
|
194
|
-
/**
|
|
195
|
-
* Configuration options for creating a new project via Scaffold.
|
|
196
|
-
*
|
|
197
|
-
* @public
|
|
198
|
-
* @since 3.0.0
|
|
199
|
-
*/
|
|
200
|
-
interface ScaffoldOptions {
|
|
201
|
-
/** The name of the new project (e.g., 'my-api'). */
|
|
202
|
-
name: string;
|
|
203
|
-
/** Absolute path where the project files should be generated. */
|
|
204
|
-
targetDir: string;
|
|
205
|
-
/** The primary architectural pattern to apply. */
|
|
206
|
-
architecture: ArchitectureType;
|
|
207
|
-
/** Preferred package manager for dependency installation. @default 'bun' */
|
|
208
|
-
packageManager?: 'bun' | 'npm' | 'yarn' | 'pnpm';
|
|
209
|
-
/** Whether to run `git init` in the target directory. @default true */
|
|
210
|
-
initGit?: boolean;
|
|
211
|
-
/** Whether to automatically run `install` after file generation. @default true */
|
|
212
|
-
installDeps?: boolean;
|
|
213
|
-
/** If true, includes the Spectrum observability dashboard in the scaffolded app. */
|
|
214
|
-
withSpectrum?: boolean;
|
|
215
|
-
/** Internal flag for official Gravito satellite projects. */
|
|
216
|
-
isInternal?: boolean;
|
|
217
|
-
/** Selected project profile determining the set of included orbits/packages. */
|
|
218
|
-
profile?: 'core' | 'scale' | 'enterprise';
|
|
219
|
-
/** List of additional feature orbits to include (e.g., 'redis', 'queue', 'otel'). */
|
|
220
|
-
features?: string[];
|
|
221
|
-
/** Additional template variables to be used during file generation. */
|
|
222
|
-
context?: Record<string, unknown>;
|
|
223
|
-
}
|
|
224
|
-
/**
|
|
225
|
-
* The outcome of a scaffolding operation.
|
|
226
|
-
*
|
|
227
|
-
* @public
|
|
228
|
-
* @since 3.0.0
|
|
229
|
-
*/
|
|
230
|
-
interface ScaffoldResult {
|
|
231
|
-
/** True if the operation completed without fatal errors. */
|
|
232
|
-
success: boolean;
|
|
233
|
-
/** The absolute path where the project was created. */
|
|
234
|
-
targetDir: string;
|
|
235
|
-
/** List of relative file paths that were successfully generated. */
|
|
236
|
-
filesCreated: string[];
|
|
237
|
-
/** Any non-fatal error messages encountered during generation. */
|
|
238
|
-
errors?: string[];
|
|
239
|
-
}
|
|
240
|
-
/**
|
|
241
|
-
* Represents a node in the project file structure blueprint.
|
|
242
|
-
*
|
|
243
|
-
* Used to define the skeleton of a new project before generation.
|
|
244
|
-
*
|
|
245
|
-
* @public
|
|
246
|
-
* @since 3.0.0
|
|
247
|
-
*/
|
|
248
|
-
interface DirectoryNode {
|
|
249
|
-
/** The type of node (file vs folder). */
|
|
250
|
-
type: 'file' | 'directory';
|
|
251
|
-
/** The name of the file or directory. */
|
|
252
|
-
name: string;
|
|
253
|
-
/** Literal string content if this is a file node. */
|
|
254
|
-
content?: string;
|
|
255
|
-
/** The name or path of a template to use for this file's content. */
|
|
256
|
-
template?: string;
|
|
257
|
-
/** Nested nodes if this is a directory. */
|
|
258
|
-
children?: DirectoryNode[];
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
declare class TemplateManager {
|
|
262
|
-
private stubGenerator;
|
|
263
|
-
constructor(templatesDir: string);
|
|
264
|
-
render(template: string, context: Record<string, unknown>): string;
|
|
265
|
-
applyOverlay(sourceDir: string, targetDir: string, context: Record<string, unknown>, fileMerger: FileMerger, log?: (msg: string) => void): Promise<string[]>;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
/**
|
|
269
|
-
* BaseGenerator - Abstract base class for architecture generators.
|
|
270
|
-
*/
|
|
271
|
-
|
|
272
|
-
interface GeneratorContext {
|
|
273
|
-
name: string;
|
|
274
|
-
namePascalCase: string;
|
|
275
|
-
nameCamelCase: string;
|
|
276
|
-
nameSnakeCase: string;
|
|
277
|
-
nameKebabCase: string;
|
|
278
|
-
targetDir: string;
|
|
279
|
-
architecture: ArchitectureType;
|
|
280
|
-
packageManager: 'bun' | 'npm' | 'yarn' | 'pnpm';
|
|
281
|
-
year: string;
|
|
282
|
-
date: string;
|
|
283
|
-
[key: string]: unknown;
|
|
284
|
-
}
|
|
285
|
-
interface GeneratorConfig {
|
|
286
|
-
templatesDir: string;
|
|
287
|
-
verbose?: boolean;
|
|
288
|
-
}
|
|
289
|
-
declare abstract class BaseGenerator {
|
|
290
|
-
protected config: GeneratorConfig;
|
|
291
|
-
protected templateManager: TemplateManager;
|
|
292
|
-
protected fileMerger: FileMerger;
|
|
293
|
-
protected filesCreated: string[];
|
|
294
|
-
constructor(config: GeneratorConfig);
|
|
295
|
-
abstract get architectureType(): ArchitectureType;
|
|
296
|
-
abstract get displayName(): string;
|
|
297
|
-
abstract get description(): string;
|
|
298
|
-
abstract getDirectoryStructure(context: GeneratorContext): DirectoryNode[];
|
|
299
|
-
generate(context: GeneratorContext): Promise<string[]>;
|
|
300
|
-
protected createStructure(basePath: string, nodes: DirectoryNode[], context: GeneratorContext): Promise<void>;
|
|
301
|
-
protected generateCommonFiles(context: GeneratorContext): Promise<void>;
|
|
302
|
-
protected generateFileFromTemplate(tplDir: string, tplName: string, targetName: string, context: GeneratorContext): Promise<void>;
|
|
303
|
-
protected generateSkills(context: GeneratorContext): Promise<void>;
|
|
304
|
-
protected applyOverlays(context: GeneratorContext): Promise<void>;
|
|
305
|
-
protected applyFeatureOverlays(context: GeneratorContext): Promise<void>;
|
|
306
|
-
protected copyOverlayDirectory(sourceDir: string, context: GeneratorContext): Promise<void>;
|
|
307
|
-
protected writeFile(basePath: string, relativePath: string, content: string): Promise<void>;
|
|
308
|
-
protected generatePackageJson(context: GeneratorContext): string;
|
|
309
|
-
protected abstract generateArchitectureDoc(context: GeneratorContext): string;
|
|
310
|
-
protected generateCheckScripts(context: GeneratorContext): Promise<void>;
|
|
311
|
-
protected log(message: string): void;
|
|
312
|
-
static createContext(name: string, targetDir: string, architecture: ArchitectureType, packageManager?: 'bun' | 'npm' | 'yarn' | 'pnpm', extra?: Record<string, unknown>): GeneratorContext;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
/**
|
|
316
|
-
* CleanArchitectureGenerator - Clean Architecture Generator
|
|
317
|
-
*
|
|
318
|
-
* Generates a structure following Uncle Bob's Clean Architecture:
|
|
319
|
-
* - Domain: Entities, Value Objects, Interfaces (pure business logic)
|
|
320
|
-
* - Application: Use Cases, DTOs
|
|
321
|
-
* - Infrastructure: Database, External Services
|
|
322
|
-
* - Interface: HTTP Controllers, Presenters
|
|
323
|
-
*/
|
|
324
|
-
|
|
325
|
-
/**
|
|
326
|
-
* CleanArchitectureGenerator implements Uncle Bob's Clean Architecture pattern.
|
|
327
|
-
*
|
|
328
|
-
* It generates a strictly layered structure including Domain, Application,
|
|
329
|
-
* Infrastructure, and Interface layers, ensuring business logic is isolated
|
|
330
|
-
* from framework and external dependencies.
|
|
331
|
-
*
|
|
332
|
-
* @public
|
|
333
|
-
* @since 3.0.0
|
|
334
|
-
*/
|
|
335
|
-
declare class CleanArchitectureGenerator extends BaseGenerator {
|
|
336
|
-
get architectureType(): "clean";
|
|
337
|
-
get displayName(): string;
|
|
338
|
-
get description(): string;
|
|
339
|
-
getDirectoryStructure(context: GeneratorContext): DirectoryNode[];
|
|
340
|
-
private generateAppConfig;
|
|
341
|
-
private generateDatabaseConfig;
|
|
342
|
-
private generateAuthConfig;
|
|
343
|
-
private generateCacheConfig;
|
|
344
|
-
private generateLoggingConfig;
|
|
345
|
-
private generateUserEntity;
|
|
346
|
-
private generateEmailValueObject;
|
|
347
|
-
private generateUserRepositoryInterface;
|
|
348
|
-
private generateCreateUserUseCase;
|
|
349
|
-
private generateGetUserUseCase;
|
|
350
|
-
private generateUserDTO;
|
|
351
|
-
private generateMailServiceInterface;
|
|
352
|
-
private generateUserRepository;
|
|
353
|
-
private generateMailService;
|
|
354
|
-
private generateAppServiceProvider;
|
|
355
|
-
private generateRepositoryServiceProvider;
|
|
356
|
-
private generateProvidersIndex;
|
|
357
|
-
private generateMiddlewareProvider;
|
|
358
|
-
private generateRouteProvider;
|
|
359
|
-
private generateUserController;
|
|
360
|
-
private generateApiRoutes;
|
|
361
|
-
private generateUserPresenter;
|
|
362
|
-
private generateBootstrap;
|
|
363
|
-
protected generateArchitectureDoc(context: GeneratorContext): string;
|
|
364
|
-
protected generatePackageJson(context: GeneratorContext): string;
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
/**
|
|
368
|
-
* DddGenerator - Domain-Driven Design Architecture Generator
|
|
369
|
-
*
|
|
370
|
-
* Generates a DDD structure with:
|
|
371
|
-
* - Bounded Contexts (e.g., Ordering, Catalog, Identity)
|
|
372
|
-
* - Shared Kernel for cross-context concerns
|
|
373
|
-
* - Each context has Domain, Application, Infrastructure, UserInterface layers
|
|
374
|
-
*/
|
|
375
|
-
|
|
376
|
-
/**
|
|
377
|
-
* DddGenerator implements the full Domain-Driven Design (DDD) architectural pattern.
|
|
378
|
-
*
|
|
379
|
-
* It generates a sophisticated structure including Bounded Contexts, Aggregates,
|
|
380
|
-
* Value Objects, Domain Events, and a Shared Kernel. It is ideal for complex
|
|
381
|
-
* enterprise applications with rich business logic.
|
|
382
|
-
*
|
|
383
|
-
* @public
|
|
384
|
-
* @since 3.0.0
|
|
385
|
-
*/
|
|
386
|
-
declare class DddGenerator extends BaseGenerator {
|
|
387
|
-
private moduleGenerator;
|
|
388
|
-
private sharedKernelGenerator;
|
|
389
|
-
private bootstrapGenerator;
|
|
390
|
-
constructor(config: GeneratorConfig);
|
|
391
|
-
get architectureType(): "ddd";
|
|
392
|
-
get displayName(): string;
|
|
393
|
-
get description(): string;
|
|
394
|
-
getDirectoryStructure(context: GeneratorContext): DirectoryNode[];
|
|
395
|
-
/**
|
|
396
|
-
* Override package.json for DDD architecture (uses main.ts instead of bootstrap.ts)
|
|
397
|
-
*/
|
|
398
|
-
protected generatePackageJson(context: GeneratorContext): string;
|
|
399
|
-
protected generateArchitectureDoc(context: GeneratorContext): string;
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
/**
|
|
403
|
-
* EnterpriseMvcGenerator - Enterprise MVC Architecture Generator
|
|
404
|
-
*
|
|
405
|
-
* Generates a Laravel-inspired MVC structure with:
|
|
406
|
-
* - Controllers for HTTP handling
|
|
407
|
-
* - Services for business logic
|
|
408
|
-
* - Repositories for data persistence
|
|
409
|
-
* - Http/Kernel for middleware management
|
|
410
|
-
*/
|
|
411
|
-
|
|
412
|
-
/**
|
|
413
|
-
* EnterpriseMvcGenerator implements a Laravel-inspired MVC architectural pattern.
|
|
414
|
-
*
|
|
415
|
-
* It generates a pragmatic, robust structure with Controllers, Services,
|
|
416
|
-
* Repositories, and Service Providers. It is the recommended architecture
|
|
417
|
-
* for most web applications and APIs.
|
|
418
|
-
*
|
|
419
|
-
* @public
|
|
420
|
-
* @since 3.0.0
|
|
421
|
-
*/
|
|
422
|
-
declare class EnterpriseMvcGenerator extends BaseGenerator {
|
|
423
|
-
get architectureType(): "enterprise-mvc";
|
|
424
|
-
get displayName(): string;
|
|
425
|
-
get description(): string;
|
|
426
|
-
getDirectoryStructure(context: GeneratorContext): DirectoryNode[];
|
|
427
|
-
private generateAppConfig;
|
|
428
|
-
private generateDatabaseConfig;
|
|
429
|
-
private generateAuthConfig;
|
|
430
|
-
private generateCacheConfig;
|
|
431
|
-
private generateLoggingConfig;
|
|
432
|
-
private generateHttpKernel;
|
|
433
|
-
private generateBaseController;
|
|
434
|
-
private generateHomeController;
|
|
435
|
-
private generateAuthMiddleware;
|
|
436
|
-
private generateAppServiceProvider;
|
|
437
|
-
private generateProvidersIndex;
|
|
438
|
-
private generateDatabaseProvider;
|
|
439
|
-
private generateMiddlewareProvider;
|
|
440
|
-
private generateRouteProvider;
|
|
441
|
-
private generateExceptionHandler;
|
|
442
|
-
private generateBootstrap;
|
|
443
|
-
private generateRoutes;
|
|
444
|
-
protected generateArchitectureDoc(context: GeneratorContext): string;
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
/**
|
|
448
|
-
* SatelliteGenerator - Scaffolds Gravito Satellites (Plugins)
|
|
449
|
-
*
|
|
450
|
-
* Implements DDD + Clean Architecture for plugins with built-in
|
|
451
|
-
* Dogfooding support (pre-configured with Gravito modules).
|
|
452
|
-
*/
|
|
453
|
-
|
|
454
|
-
/**
|
|
455
|
-
* SatelliteGenerator scaffolds modular plug-and-play extensions for Gravito.
|
|
456
|
-
*
|
|
457
|
-
* It follows a strict DDD and Clean Architecture pattern to ensure that
|
|
458
|
-
* satellites remain decoupled from the core framework and other satellites.
|
|
459
|
-
*
|
|
460
|
-
* @public
|
|
461
|
-
* @since 3.0.0
|
|
462
|
-
*/
|
|
463
|
-
declare class SatelliteGenerator extends BaseGenerator {
|
|
464
|
-
get architectureType(): "satellite";
|
|
465
|
-
get displayName(): string;
|
|
466
|
-
get description(): string;
|
|
467
|
-
getDirectoryStructure(context: GeneratorContext): DirectoryNode[];
|
|
468
|
-
private generateEntity;
|
|
469
|
-
private generateRepositoryInterface;
|
|
470
|
-
private generateUseCase;
|
|
471
|
-
private generateAtlasRepository;
|
|
472
|
-
private generateEntryPoint;
|
|
473
|
-
private generateManifest;
|
|
474
|
-
protected generatePackageJson(context: GeneratorContext): string;
|
|
475
|
-
protected generateArchitectureDoc(context: GeneratorContext): string;
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
/**
|
|
479
|
-
* StubGenerator - Abstract template processor for generating code files.
|
|
480
|
-
*
|
|
481
|
-
* Provides a flexible system for processing stub templates with Handlebars,
|
|
482
|
-
* enabling extensible code generation for any file type.
|
|
483
|
-
*
|
|
484
|
-
* @example
|
|
485
|
-
* ```typescript
|
|
486
|
-
* const generator = new StubGenerator({
|
|
487
|
-
* stubsDir: './stubs',
|
|
488
|
-
* outputDir: './src',
|
|
489
|
-
* });
|
|
490
|
-
*
|
|
491
|
-
* await generator.generate('controller.stub', 'Controllers/UserController.ts', {
|
|
492
|
-
* name: 'User',
|
|
493
|
-
* namespace: 'App\\Controllers',
|
|
494
|
-
* });
|
|
495
|
-
* ```
|
|
496
|
-
*/
|
|
497
|
-
|
|
498
|
-
/**
|
|
499
|
-
* Variables passed to stub templates during processing.
|
|
500
|
-
*
|
|
501
|
-
* @public
|
|
502
|
-
* @since 3.0.0
|
|
503
|
-
*/
|
|
504
|
-
interface StubVariables {
|
|
505
|
-
[key: string]: unknown;
|
|
506
|
-
}
|
|
507
|
-
/**
|
|
508
|
-
* Configuration for the `StubGenerator`.
|
|
509
|
-
*
|
|
510
|
-
* @public
|
|
511
|
-
* @since 3.0.0
|
|
512
|
-
*/
|
|
513
|
-
interface StubConfig {
|
|
514
|
-
/** Directory containing the raw stub templates. */
|
|
515
|
-
stubsDir: string;
|
|
516
|
-
/** Root directory for all generated files. */
|
|
517
|
-
outputDir: string;
|
|
518
|
-
/** Default variables available to all templates. */
|
|
519
|
-
defaultVariables?: StubVariables;
|
|
520
|
-
/** Optional custom Handlebars helper implementations. */
|
|
521
|
-
helpers?: Record<string, Handlebars.HelperDelegate>;
|
|
522
|
-
}
|
|
523
|
-
/**
|
|
524
|
-
* StubGenerator processes template stubs using the Handlebars engine.
|
|
525
|
-
*
|
|
526
|
-
* It provides a rich set of built-in helpers for string manipulation
|
|
527
|
-
* (camelCase, PascalCase, etc.) and handles file reading and writing.
|
|
528
|
-
*
|
|
529
|
-
* @public
|
|
530
|
-
* @since 3.0.0
|
|
531
|
-
*/
|
|
532
|
-
declare class StubGenerator {
|
|
533
|
-
private config;
|
|
534
|
-
private handlebars;
|
|
535
|
-
constructor(config: StubConfig);
|
|
536
|
-
/**
|
|
537
|
-
* Register built-in Handlebars helpers.
|
|
538
|
-
*/
|
|
539
|
-
private registerBuiltinHelpers;
|
|
540
|
-
/**
|
|
541
|
-
* Generate a file from a stub template.
|
|
542
|
-
*
|
|
543
|
-
* @param stubName - Name of the stub file (relative to stubsDir)
|
|
544
|
-
* @param outputPath - Output path (relative to outputDir)
|
|
545
|
-
* @param variables - Template variables
|
|
546
|
-
* @returns Path to the generated file
|
|
547
|
-
*/
|
|
548
|
-
generate(stubName: string, outputPath: string, variables?: StubVariables): Promise<string>;
|
|
549
|
-
/**
|
|
550
|
-
* Generate multiple files from a stub template.
|
|
551
|
-
*
|
|
552
|
-
* @param stubName - Name of the stub file
|
|
553
|
-
* @param outputs - Array of [outputPath, variables] tuples
|
|
554
|
-
* @returns Array of generated file paths
|
|
555
|
-
*/
|
|
556
|
-
generateMany(stubName: string, outputs: [string, StubVariables][]): Promise<string[]>;
|
|
557
|
-
/**
|
|
558
|
-
* Render a template string directly.
|
|
559
|
-
*
|
|
560
|
-
* @param template - Template string
|
|
561
|
-
* @param variables - Template variables
|
|
562
|
-
* @returns Rendered content
|
|
563
|
-
*/
|
|
564
|
-
render(template: string, variables?: StubVariables): string;
|
|
565
|
-
/**
|
|
566
|
-
* Register a custom Handlebars helper.
|
|
567
|
-
*
|
|
568
|
-
* @param name - Helper name
|
|
569
|
-
* @param helper - Helper function
|
|
570
|
-
*/
|
|
571
|
-
registerHelper(name: string, helper: Handlebars.HelperDelegate): void;
|
|
572
|
-
/**
|
|
573
|
-
* Register a Handlebars partial.
|
|
574
|
-
*
|
|
575
|
-
* @param name - Partial name
|
|
576
|
-
* @param partial - Partial template string
|
|
577
|
-
*/
|
|
578
|
-
registerPartial(name: string, partial: string): void;
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
/**
|
|
582
|
-
* Represents the structure of a `gravito.lock.json` file.
|
|
583
|
-
*
|
|
584
|
-
* @public
|
|
585
|
-
* @since 3.0.0
|
|
586
|
-
*/
|
|
587
|
-
interface LockFile {
|
|
588
|
-
/** Information about the selected project profile. */
|
|
589
|
-
profile: {
|
|
590
|
-
name: ProfileType;
|
|
591
|
-
version: string;
|
|
592
|
-
};
|
|
593
|
-
/** List of enabled features and orbits. */
|
|
594
|
-
features: string[];
|
|
595
|
-
/** Selected default drivers for various services. */
|
|
596
|
-
drivers: {
|
|
597
|
-
database: string;
|
|
598
|
-
cache: string;
|
|
599
|
-
queue: string;
|
|
600
|
-
storage: string;
|
|
601
|
-
session: string;
|
|
602
|
-
};
|
|
603
|
-
/** Metadata about the template used for generation. */
|
|
604
|
-
manifest: {
|
|
605
|
-
template: string;
|
|
606
|
-
version: string;
|
|
607
|
-
};
|
|
608
|
-
/** ISO timestamp when the project was scaffolded. */
|
|
609
|
-
createdAt: string;
|
|
610
|
-
}
|
|
611
|
-
/**
|
|
612
|
-
* LockGenerator creates the `gravito.lock.json` file during scaffolding.
|
|
613
|
-
*
|
|
614
|
-
* This file records the architectural choices and feature set of the project,
|
|
615
|
-
* allowing the CLI to perform consistent upgrades and feature injections later.
|
|
616
|
-
*
|
|
617
|
-
* @public
|
|
618
|
-
* @since 3.0.0
|
|
619
|
-
*/
|
|
620
|
-
declare class LockGenerator {
|
|
621
|
-
generate(profileName: ProfileType, config: ProfileConfig, templateName?: string, templateVersion?: string): string;
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
/**
|
|
625
|
-
* Scaffold is the primary engine for generating Gravito project structures.
|
|
626
|
-
*
|
|
627
|
-
* It orchestrates dynamic template generation, architecture patterns,
|
|
628
|
-
* profile resolution, and environment setup.
|
|
629
|
-
*
|
|
630
|
-
* @example
|
|
631
|
-
* ```typescript
|
|
632
|
-
* const engine = new Scaffold();
|
|
633
|
-
* const result = await engine.create({
|
|
634
|
-
* name: 'new-app',
|
|
635
|
-
* targetDir: '/path/to/app',
|
|
636
|
-
* architecture: 'enterprise-mvc'
|
|
637
|
-
* });
|
|
638
|
-
* ```
|
|
639
|
-
*
|
|
640
|
-
* @public
|
|
641
|
-
* @since 3.0.0
|
|
642
|
-
*/
|
|
643
|
-
declare class Scaffold {
|
|
644
|
-
private templatesDir;
|
|
645
|
-
private verbose;
|
|
646
|
-
constructor(options?: {
|
|
647
|
-
templatesDir?: string;
|
|
648
|
-
verbose?: boolean;
|
|
649
|
-
});
|
|
650
|
-
/**
|
|
651
|
-
* Returns a list of all architectural patterns supported by the engine,
|
|
652
|
-
* along with human-readable names and descriptions.
|
|
653
|
-
*
|
|
654
|
-
* @returns {Array<{type: ArchitectureType, name: string, description: string}>}
|
|
655
|
-
*/
|
|
656
|
-
getArchitectureTypes(): Array<{
|
|
657
|
-
type: ArchitectureType;
|
|
658
|
-
name: string;
|
|
659
|
-
description: string;
|
|
660
|
-
}>;
|
|
661
|
-
/**
|
|
662
|
-
* Orchestrates the complete project generation lifecycle.
|
|
663
|
-
* This includes directory creation, file layout, profile resolution,
|
|
664
|
-
* dependency mapping, and optional post-install hooks.
|
|
665
|
-
*
|
|
666
|
-
* @param {ScaffoldOptions} options - Detailed configuration for the new project.
|
|
667
|
-
* @returns {Promise<ScaffoldResult>}
|
|
668
|
-
*/
|
|
669
|
-
create(options: ScaffoldOptions): Promise<ScaffoldResult>;
|
|
670
|
-
/**
|
|
671
|
-
* Create a generator for the specified architecture.
|
|
672
|
-
*/
|
|
673
|
-
private createGenerator;
|
|
674
|
-
/**
|
|
675
|
-
* Generate a single module (for DDD bounded context).
|
|
676
|
-
*/
|
|
677
|
-
generateModule(_targetDir: string, _moduleName: string, _options?: {
|
|
678
|
-
architecture?: ArchitectureType;
|
|
679
|
-
}): Promise<ScaffoldResult>;
|
|
680
|
-
/**
|
|
681
|
-
* Generate a service provider.
|
|
682
|
-
*/
|
|
683
|
-
generateProvider(_targetDir: string, _providerName: string): Promise<ScaffoldResult>;
|
|
684
|
-
}
|
|
685
|
-
|
|
686
|
-
export { type ArchitectureType, BaseGenerator, CleanArchitectureGenerator, DddGenerator, DependencyValidator, type DetectedEnvironment, EnterpriseMvcGenerator, EnvironmentDetector, FileMerger, type GeneratorConfig, type GeneratorContext, type LockFile, LockGenerator, type PackageJson, type ProfileConfig, ProfileResolver, type ProfileType, SatelliteGenerator, Scaffold, type ScaffoldOptions, type StubConfig, StubGenerator, type StubVariables, type ValidationResult };
|