@expressots/cli 3.0.0 → 4.0.0-preview.3
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 +41 -95
- package/bin/cicd/cli.d.ts +6 -0
- package/bin/cicd/cli.js +128 -0
- package/bin/cicd/form.d.ts +29 -0
- package/bin/cicd/form.js +346 -0
- package/bin/cicd/generators/azure-devops.d.ts +2 -0
- package/bin/cicd/generators/azure-devops.js +370 -0
- package/bin/cicd/generators/bitbucket.d.ts +2 -0
- package/bin/cicd/generators/bitbucket.js +217 -0
- package/bin/cicd/generators/circleci.d.ts +2 -0
- package/bin/cicd/generators/circleci.js +274 -0
- package/bin/cicd/generators/github-actions.d.ts +14 -0
- package/bin/cicd/generators/github-actions.js +426 -0
- package/bin/cicd/generators/gitlab-ci.d.ts +2 -0
- package/bin/cicd/generators/gitlab-ci.js +237 -0
- package/bin/cicd/generators/index.d.ts +6 -0
- package/bin/cicd/generators/index.js +15 -0
- package/bin/cicd/generators/jenkins.d.ts +2 -0
- package/bin/cicd/generators/jenkins.js +248 -0
- package/bin/cicd/generators/template-loader.d.ts +17 -0
- package/bin/cicd/generators/template-loader.js +128 -0
- package/bin/cicd/index.d.ts +1 -0
- package/bin/cicd/index.js +5 -0
- package/bin/cli.d.ts +1 -5
- package/bin/cli.js +72 -7
- package/bin/commands/project.commands.d.ts +19 -6
- package/bin/commands/project.commands.js +602 -66
- package/bin/config/index.d.ts +5 -0
- package/bin/config/index.js +10 -0
- package/bin/config/manager.d.ts +98 -0
- package/bin/config/manager.js +222 -0
- package/bin/containerize/analyzers/bootstrap-analyzer.d.ts +46 -0
- package/bin/containerize/analyzers/bootstrap-analyzer.js +187 -0
- package/bin/containerize/analyzers/project-analyzer.d.ts +20 -0
- package/bin/containerize/analyzers/project-analyzer.js +150 -0
- package/bin/containerize/cli.d.ts +4 -0
- package/bin/containerize/cli.js +113 -0
- package/bin/containerize/form.d.ts +15 -0
- package/bin/containerize/form.js +152 -0
- package/bin/containerize/generators/ci-generator.d.ts +31 -0
- package/bin/containerize/generators/ci-generator.js +940 -0
- package/bin/containerize/generators/docker-compose-generator.d.ts +8 -0
- package/bin/containerize/generators/docker-compose-generator.js +187 -0
- package/bin/containerize/generators/dockerfile-generator.d.ts +8 -0
- package/bin/containerize/generators/dockerfile-generator.js +657 -0
- package/bin/containerize/generators/kubernetes-generator.d.ts +8 -0
- package/bin/containerize/generators/kubernetes-generator.js +134 -0
- package/bin/containerize/generators/template-loader.d.ts +36 -0
- package/bin/containerize/generators/template-loader.js +129 -0
- package/bin/containerize/index.d.ts +4 -0
- package/bin/containerize/index.js +13 -0
- package/bin/containerize/presets/preset-registry.d.ts +20 -0
- package/bin/containerize/presets/preset-registry.js +102 -0
- package/bin/costs/cli.d.ts +5 -0
- package/bin/costs/cli.js +185 -0
- package/bin/costs/form.d.ts +44 -0
- package/bin/costs/form.js +412 -0
- package/bin/costs/index.d.ts +4 -0
- package/bin/costs/index.js +25 -0
- package/bin/costs/pricing-manager.d.ts +84 -0
- package/bin/costs/pricing-manager.js +342 -0
- package/bin/costs/providers/index.d.ts +32 -0
- package/bin/costs/providers/index.js +153 -0
- package/bin/costs/sources/api-source.d.ts +10 -0
- package/bin/costs/sources/api-source.js +32 -0
- package/bin/costs/sources/index.d.ts +6 -0
- package/bin/costs/sources/index.js +15 -0
- package/bin/costs/sources/local-json-source.d.ts +23 -0
- package/bin/costs/sources/local-json-source.js +59 -0
- package/bin/costs/sources/remote-json-source.d.ts +11 -0
- package/bin/costs/sources/remote-json-source.js +53 -0
- package/bin/costs/types.d.ts +53 -0
- package/bin/costs/types.js +5 -0
- package/bin/dev/cli.d.ts +4 -0
- package/bin/dev/cli.js +136 -0
- package/bin/dev/form.d.ts +36 -0
- package/bin/dev/form.js +254 -0
- package/bin/dev/index.d.ts +1 -0
- package/bin/dev/index.js +5 -0
- package/bin/generate/cli.d.ts +1 -1
- package/bin/generate/cli.js +29 -2
- package/bin/generate/form.d.ts +5 -1
- package/bin/generate/form.js +3 -3
- package/bin/generate/templates/nonopinionated/config.tpl +12 -0
- package/bin/generate/templates/nonopinionated/event.tpl +10 -0
- package/bin/generate/templates/nonopinionated/guard.tpl +18 -0
- package/bin/generate/templates/nonopinionated/handler.tpl +12 -0
- package/bin/generate/templates/nonopinionated/interceptor.tpl +27 -0
- package/bin/generate/templates/opinionated/config.tpl +47 -0
- package/bin/generate/templates/opinionated/entity.tpl +1 -8
- package/bin/generate/templates/opinionated/event.tpl +15 -0
- package/bin/generate/templates/opinionated/guard.tpl +41 -0
- package/bin/generate/templates/opinionated/handler.tpl +23 -0
- package/bin/generate/templates/opinionated/interceptor.tpl +50 -0
- package/bin/generate/utils/command-utils.d.ts +20 -5
- package/bin/generate/utils/command-utils.js +145 -48
- package/bin/generate/utils/nonopininated-cmd.d.ts +10 -1
- package/bin/generate/utils/nonopininated-cmd.js +100 -1
- package/bin/generate/utils/opinionated-cmd.d.ts +10 -1
- package/bin/generate/utils/opinionated-cmd.js +128 -16
- package/bin/generate/utils/string-utils.d.ts +6 -0
- package/bin/generate/utils/string-utils.js +13 -1
- package/bin/help/cli.d.ts +1 -1
- package/bin/help/command-help-registry.d.ts +23 -0
- package/bin/help/command-help-registry.js +303 -0
- package/bin/help/command-help.d.ts +36 -0
- package/bin/help/command-help.js +56 -0
- package/bin/help/form.js +127 -22
- package/bin/help/main-help.d.ts +8 -0
- package/bin/help/main-help.js +126 -0
- package/bin/help/render.d.ts +32 -0
- package/bin/help/render.js +46 -0
- package/bin/info/cli.d.ts +1 -1
- package/bin/info/form.d.ts +1 -1
- package/bin/info/form.js +11 -11
- package/bin/migrate/analyzers/platform-detector.d.ts +14 -0
- package/bin/migrate/analyzers/platform-detector.js +116 -0
- package/bin/migrate/cli.d.ts +6 -0
- package/bin/migrate/cli.js +98 -0
- package/bin/migrate/form.d.ts +25 -0
- package/bin/migrate/form.js +348 -0
- package/bin/migrate/generators/compose-to-k8s.d.ts +2 -0
- package/bin/migrate/generators/compose-to-k8s.js +324 -0
- package/bin/migrate/generators/compose-to-railway.d.ts +2 -0
- package/bin/migrate/generators/compose-to-railway.js +138 -0
- package/bin/migrate/generators/compose-to-render.d.ts +2 -0
- package/bin/migrate/generators/compose-to-render.js +148 -0
- package/bin/migrate/generators/generic-migration.d.ts +9 -0
- package/bin/migrate/generators/generic-migration.js +221 -0
- package/bin/migrate/generators/heroku-to-fly.d.ts +2 -0
- package/bin/migrate/generators/heroku-to-fly.js +291 -0
- package/bin/migrate/generators/heroku-to-railway.d.ts +2 -0
- package/bin/migrate/generators/heroku-to-railway.js +283 -0
- package/bin/migrate/generators/heroku-to-render.d.ts +2 -0
- package/bin/migrate/generators/heroku-to-render.js +148 -0
- package/bin/migrate/generators/index.d.ts +7 -0
- package/bin/migrate/generators/index.js +17 -0
- package/bin/migrate/generators/template-loader.d.ts +21 -0
- package/bin/migrate/generators/template-loader.js +59 -0
- package/bin/migrate/index.d.ts +1 -0
- package/bin/migrate/index.js +5 -0
- package/bin/new/cli.d.ts +5 -1
- package/bin/new/cli.js +77 -14
- package/bin/new/form.d.ts +27 -4
- package/bin/new/form.js +605 -75
- package/bin/profile/analyzers/dockerfile-analyzer.d.ts +27 -0
- package/bin/profile/analyzers/dockerfile-analyzer.js +122 -0
- package/bin/profile/analyzers/image-analyzer.d.ts +19 -0
- package/bin/profile/analyzers/image-analyzer.js +85 -0
- package/bin/profile/cli.d.ts +4 -0
- package/bin/profile/cli.js +94 -0
- package/bin/profile/form.d.ts +56 -0
- package/bin/profile/form.js +401 -0
- package/bin/profile/index.d.ts +1 -0
- package/bin/profile/index.js +5 -0
- package/bin/profile/optimizers/index.d.ts +19 -0
- package/bin/profile/optimizers/index.js +137 -0
- package/bin/providers/add/form.d.ts +1 -1
- package/bin/providers/add/form.js +27 -6
- package/bin/providers/create/form.js +53 -3
- package/bin/scripts/form.js +27 -5
- package/bin/studio/cli.d.ts +15 -0
- package/bin/studio/cli.js +172 -0
- package/bin/studio/index.d.ts +5 -0
- package/bin/studio/index.js +9 -0
- package/bin/templates/cache.d.ts +54 -0
- package/bin/templates/cache.js +180 -0
- package/bin/templates/cli.d.ts +8 -0
- package/bin/templates/cli.js +294 -0
- package/bin/templates/fetcher.d.ts +49 -0
- package/bin/templates/fetcher.js +208 -0
- package/bin/templates/index.d.ts +11 -0
- package/bin/templates/index.js +37 -0
- package/bin/templates/manager.d.ts +116 -0
- package/bin/templates/manager.js +323 -0
- package/bin/templates/renderer.d.ts +49 -0
- package/bin/templates/renderer.js +204 -0
- package/bin/templates/types.d.ts +51 -0
- package/bin/templates/types.js +5 -0
- package/bin/utils/add-module-to-container.d.ts +14 -3
- package/bin/utils/add-module-to-container.js +327 -98
- package/bin/utils/cli-ui.d.ts +49 -3
- package/bin/utils/cli-ui.js +133 -13
- package/bin/utils/index.d.ts +4 -0
- package/bin/utils/index.js +4 -0
- package/bin/utils/input-validation.d.ts +50 -0
- package/bin/utils/input-validation.js +143 -0
- package/bin/utils/package-manager-commands.d.ts +24 -0
- package/bin/utils/package-manager-commands.js +50 -0
- package/bin/utils/safe-spawn.d.ts +35 -0
- package/bin/utils/safe-spawn.js +51 -0
- package/bin/utils/update-tsconfig-paths.d.ts +35 -0
- package/bin/utils/update-tsconfig-paths.js +326 -0
- package/package.json +165 -156
|
@@ -10,8 +10,9 @@ const command_utils_1 = require("./command-utils");
|
|
|
10
10
|
* @param target - The target
|
|
11
11
|
* @param method - The method
|
|
12
12
|
* @param expressoConfig - The expresso config
|
|
13
|
+
* @param v4Options - Additional options for v4.0 schematics
|
|
13
14
|
*/
|
|
14
|
-
async function nonOpinionatedProcess(schematic, target, method, expressoConfig) {
|
|
15
|
+
async function nonOpinionatedProcess(schematic, target, method, expressoConfig, v4Options = {}) {
|
|
15
16
|
let f = await (0, command_utils_1.validateAndPrepareFile)({
|
|
16
17
|
schematic,
|
|
17
18
|
target,
|
|
@@ -81,6 +82,27 @@ async function nonOpinionatedProcess(schematic, target, method, expressoConfig)
|
|
|
81
82
|
await generateModule(f.outputPath, f.className, f.moduleName, f.path, f.schematic);
|
|
82
83
|
await (0, cli_ui_1.printGenerateSuccess)(f.schematic, f.file);
|
|
83
84
|
break;
|
|
85
|
+
// NEW v4.0 schematics
|
|
86
|
+
case "interceptor":
|
|
87
|
+
await generateInterceptor(f.outputPath, f.className, v4Options.priority ?? 10);
|
|
88
|
+
await (0, cli_ui_1.printGenerateSuccess)("interceptor", f.file);
|
|
89
|
+
break;
|
|
90
|
+
case "event":
|
|
91
|
+
await generateEvent(f.outputPath, f.className);
|
|
92
|
+
await (0, cli_ui_1.printGenerateSuccess)("event", f.file);
|
|
93
|
+
break;
|
|
94
|
+
case "handler":
|
|
95
|
+
await generateHandler(f.outputPath, f.className, v4Options.event ?? "MyEvent", v4Options.priority ?? 10);
|
|
96
|
+
await (0, cli_ui_1.printGenerateSuccess)("handler", f.file);
|
|
97
|
+
break;
|
|
98
|
+
case "guard":
|
|
99
|
+
await generateGuard(f.outputPath, f.className);
|
|
100
|
+
await (0, cli_ui_1.printGenerateSuccess)("guard", f.file);
|
|
101
|
+
break;
|
|
102
|
+
case "config":
|
|
103
|
+
await generateConfig(f.outputPath, f.className, f.moduleName);
|
|
104
|
+
await (0, cli_ui_1.printGenerateSuccess)("config", f.file);
|
|
105
|
+
break;
|
|
84
106
|
}
|
|
85
107
|
return f.file;
|
|
86
108
|
}
|
|
@@ -248,3 +270,80 @@ async function generateModule(outputPath, className, moduleName, path, schematic
|
|
|
248
270
|
},
|
|
249
271
|
});
|
|
250
272
|
}
|
|
273
|
+
// NEW v4.0 Schematic Generators
|
|
274
|
+
/**
|
|
275
|
+
* Generate an interceptor
|
|
276
|
+
*/
|
|
277
|
+
async function generateInterceptor(outputPath, className, priority) {
|
|
278
|
+
(0, command_utils_1.writeTemplate)({
|
|
279
|
+
outputPath,
|
|
280
|
+
template: {
|
|
281
|
+
path: "../templates/nonopinionated/interceptor.tpl",
|
|
282
|
+
data: {
|
|
283
|
+
className: (0, string_utils_1.anyCaseToPascalCase)(className),
|
|
284
|
+
priority: priority.toString(),
|
|
285
|
+
},
|
|
286
|
+
},
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Generate an event
|
|
291
|
+
*/
|
|
292
|
+
async function generateEvent(outputPath, className) {
|
|
293
|
+
(0, command_utils_1.writeTemplate)({
|
|
294
|
+
outputPath,
|
|
295
|
+
template: {
|
|
296
|
+
path: "../templates/nonopinionated/event.tpl",
|
|
297
|
+
data: {
|
|
298
|
+
className: (0, string_utils_1.anyCaseToPascalCase)(className),
|
|
299
|
+
},
|
|
300
|
+
},
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Generate an event handler
|
|
305
|
+
*/
|
|
306
|
+
async function generateHandler(outputPath, className, eventName, priority) {
|
|
307
|
+
(0, command_utils_1.writeTemplate)({
|
|
308
|
+
outputPath,
|
|
309
|
+
template: {
|
|
310
|
+
path: "../templates/nonopinionated/handler.tpl",
|
|
311
|
+
data: {
|
|
312
|
+
className: (0, string_utils_1.anyCaseToPascalCase)(className),
|
|
313
|
+
eventName: (0, string_utils_1.anyCaseToPascalCase)(eventName),
|
|
314
|
+
eventPath: `./${(0, string_utils_1.anyCaseToKebabCase)(eventName)}.event`,
|
|
315
|
+
priority: priority.toString(),
|
|
316
|
+
},
|
|
317
|
+
},
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Generate a guard
|
|
322
|
+
*/
|
|
323
|
+
async function generateGuard(outputPath, className) {
|
|
324
|
+
(0, command_utils_1.writeTemplate)({
|
|
325
|
+
outputPath,
|
|
326
|
+
template: {
|
|
327
|
+
path: "../templates/nonopinionated/guard.tpl",
|
|
328
|
+
data: {
|
|
329
|
+
className: (0, string_utils_1.anyCaseToPascalCase)(className),
|
|
330
|
+
},
|
|
331
|
+
},
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Generate a config module
|
|
336
|
+
*/
|
|
337
|
+
async function generateConfig(outputPath, className, moduleName) {
|
|
338
|
+
(0, command_utils_1.writeTemplate)({
|
|
339
|
+
outputPath,
|
|
340
|
+
template: {
|
|
341
|
+
path: "../templates/nonopinionated/config.tpl",
|
|
342
|
+
data: {
|
|
343
|
+
className: (0, string_utils_1.anyCaseToPascalCase)(className),
|
|
344
|
+
moduleName: (0, string_utils_1.anyCaseToCamelCase)(moduleName || className),
|
|
345
|
+
envPrefix: (0, string_utils_1.anyCaseToUpperSnakeCase)(className),
|
|
346
|
+
},
|
|
347
|
+
},
|
|
348
|
+
});
|
|
349
|
+
}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { ExpressoConfig } from "@expressots/shared";
|
|
2
|
+
/**
|
|
3
|
+
* Additional options for v4.0 schematics
|
|
4
|
+
*/
|
|
5
|
+
type V4Options = {
|
|
6
|
+
event?: string;
|
|
7
|
+
priority?: number;
|
|
8
|
+
};
|
|
2
9
|
/**
|
|
3
10
|
* Process commands for opinionated service scaffolding
|
|
4
11
|
* @param schematic - Resource to scaffold
|
|
@@ -6,6 +13,8 @@ import { ExpressoConfig } from "@expressots/shared";
|
|
|
6
13
|
* @param method - HTTP method
|
|
7
14
|
* @param expressoConfig - Expresso configuration [expressots.config.ts]
|
|
8
15
|
* @param pathStyle - Path command style [sugar, nested, single]
|
|
16
|
+
* @param v4Options - Additional options for v4.0 schematics
|
|
9
17
|
* @returns
|
|
10
18
|
*/
|
|
11
|
-
export declare function opinionatedProcess(schematic: string, target: string, method: string, expressoConfig: ExpressoConfig, pathStyle: string): Promise<string>;
|
|
19
|
+
export declare function opinionatedProcess(schematic: string, target: string, method: string, expressoConfig: ExpressoConfig, pathStyle: string, v4Options?: V4Options): Promise<string>;
|
|
20
|
+
export {};
|
|
@@ -41,9 +41,10 @@ const add_module_to_container_1 = require("../../utils/add-module-to-container")
|
|
|
41
41
|
* @param method - HTTP method
|
|
42
42
|
* @param expressoConfig - Expresso configuration [expressots.config.ts]
|
|
43
43
|
* @param pathStyle - Path command style [sugar, nested, single]
|
|
44
|
+
* @param v4Options - Additional options for v4.0 schematics
|
|
44
45
|
* @returns
|
|
45
46
|
*/
|
|
46
|
-
async function opinionatedProcess(schematic, target, method, expressoConfig, pathStyle) {
|
|
47
|
+
async function opinionatedProcess(schematic, target, method, expressoConfig, pathStyle, v4Options = {}) {
|
|
47
48
|
const f = await (0, command_utils_1.validateAndPrepareFile)({
|
|
48
49
|
schematic,
|
|
49
50
|
target,
|
|
@@ -73,19 +74,20 @@ async function opinionatedProcess(schematic, target, method, expressoConfig, pat
|
|
|
73
74
|
method,
|
|
74
75
|
expressoConfig,
|
|
75
76
|
});
|
|
77
|
+
let moduleFile = m.file;
|
|
76
78
|
if (pathStyle === "sugar" /* PathStyle.Sugar */) {
|
|
77
|
-
await generateModuleServiceSugarPath(f.outputPath, m.className, m.moduleName, m.path, m.
|
|
79
|
+
moduleFile = await generateModuleServiceSugarPath(f.outputPath, m.className, m.moduleName, m.path, m.folderToScaffold);
|
|
78
80
|
}
|
|
79
81
|
else if (pathStyle === "nested" /* PathStyle.Nested */) {
|
|
80
|
-
await generateModuleServiceNestedPath(f.outputPath, m.className, m.path, m.folderToScaffold);
|
|
82
|
+
moduleFile = await generateModuleServiceNestedPath(f.outputPath, m.className, m.path, m.folderToScaffold);
|
|
81
83
|
}
|
|
82
84
|
else if (pathStyle === "single" /* PathStyle.Single */) {
|
|
83
|
-
await generateModuleServiceSinglePath(f.outputPath, m.className, m.moduleName, m.path, m.file, m.folderToScaffold);
|
|
85
|
+
moduleFile = await generateModuleServiceSinglePath(f.outputPath, m.className, m.moduleName, m.path, m.file, m.folderToScaffold);
|
|
84
86
|
}
|
|
85
87
|
await (0, cli_ui_1.printGenerateSuccess)("controller", f.file);
|
|
86
88
|
await (0, cli_ui_1.printGenerateSuccess)("usecase", f.file);
|
|
87
89
|
await (0, cli_ui_1.printGenerateSuccess)("dto", f.file);
|
|
88
|
-
await (0, cli_ui_1.printGenerateSuccess)("module",
|
|
90
|
+
await (0, cli_ui_1.printGenerateSuccess)("module", moduleFile);
|
|
89
91
|
break;
|
|
90
92
|
}
|
|
91
93
|
case "usecase":
|
|
@@ -116,6 +118,27 @@ async function opinionatedProcess(schematic, target, method, expressoConfig, pat
|
|
|
116
118
|
await generateModule(f.outputPath, f.className, f.moduleName, f.path);
|
|
117
119
|
await (0, cli_ui_1.printGenerateSuccess)(schematic, f.file);
|
|
118
120
|
break;
|
|
121
|
+
// NEW v4.0 schematics
|
|
122
|
+
case "interceptor":
|
|
123
|
+
await generateInterceptor(f.outputPath, f.className, v4Options.priority ?? 10);
|
|
124
|
+
await (0, cli_ui_1.printGenerateSuccess)("interceptor", f.file);
|
|
125
|
+
break;
|
|
126
|
+
case "event":
|
|
127
|
+
await generateEvent(f.outputPath, f.className);
|
|
128
|
+
await (0, cli_ui_1.printGenerateSuccess)("event", f.file);
|
|
129
|
+
break;
|
|
130
|
+
case "handler":
|
|
131
|
+
await generateHandler(f.outputPath, f.className, v4Options.event ?? "MyEvent", v4Options.priority ?? 10);
|
|
132
|
+
await (0, cli_ui_1.printGenerateSuccess)("handler", f.file);
|
|
133
|
+
break;
|
|
134
|
+
case "guard":
|
|
135
|
+
await generateGuard(f.outputPath, f.className);
|
|
136
|
+
await (0, cli_ui_1.printGenerateSuccess)("guard", f.file);
|
|
137
|
+
break;
|
|
138
|
+
case "config":
|
|
139
|
+
await generateConfig(f.outputPath, f.className, f.moduleName);
|
|
140
|
+
await (0, cli_ui_1.printGenerateSuccess)("config", f.file);
|
|
141
|
+
break;
|
|
119
142
|
}
|
|
120
143
|
return f.file;
|
|
121
144
|
}
|
|
@@ -347,13 +370,16 @@ async function generateMiddleware(outputPath, className, moduleName, path) {
|
|
|
347
370
|
* @param moduleName - The module name
|
|
348
371
|
* @param path - The path
|
|
349
372
|
*/
|
|
350
|
-
async function generateModuleServiceSugarPath(outputPathController, className, moduleName, path,
|
|
351
|
-
|
|
373
|
+
async function generateModuleServiceSugarPath(outputPathController, className, moduleName, path, folderToScaffold) {
|
|
374
|
+
// The module file is named after the feature (first word), e.g. `user`, and
|
|
375
|
+
// lives at the feature root (`useCases/user/user.module.ts`), grouping all of
|
|
376
|
+
// the feature's use-cases. `moduleName` already carries the feature word.
|
|
377
|
+
const newModuleFile = await (0, command_utils_1.getNameWithScaffoldPattern)(moduleName);
|
|
352
378
|
const newModulePath = nodePath
|
|
353
379
|
.join(folderToScaffold, path, "..")
|
|
354
380
|
.normalize();
|
|
355
381
|
const newModuleName = `${newModuleFile}.module.ts`;
|
|
356
|
-
const newModuleOutputPath = `${newModulePath}/${newModuleName}`.replace(
|
|
382
|
+
const newModuleOutputPath = `${newModulePath}/${newModuleName}`.replace(/\\/g, "/");
|
|
357
383
|
const controllerToModule = nodePath
|
|
358
384
|
.relative(newModuleOutputPath, outputPathController)
|
|
359
385
|
.normalize()
|
|
@@ -365,7 +391,7 @@ async function generateModuleServiceSugarPath(outputPathController, className, m
|
|
|
365
391
|
.normalize();
|
|
366
392
|
if (fs_1.default.existsSync(newModuleOutputPath)) {
|
|
367
393
|
await (0, add_controller_to_module_1.addControllerToModule)(controllerFullPath, `${className}Controller`, controllerToModule);
|
|
368
|
-
return;
|
|
394
|
+
return newModuleName;
|
|
369
395
|
}
|
|
370
396
|
(0, command_utils_1.writeTemplate)({
|
|
371
397
|
outputPath: newModuleOutputPath,
|
|
@@ -378,7 +404,10 @@ async function generateModuleServiceSugarPath(outputPathController, className, m
|
|
|
378
404
|
},
|
|
379
405
|
},
|
|
380
406
|
});
|
|
381
|
-
|
|
407
|
+
// Extract folder name from folderToScaffold (e.g., "src/useCases" -> "useCases")
|
|
408
|
+
const folderName = nodePath.basename(folderToScaffold);
|
|
409
|
+
await (0, add_module_to_container_1.addModuleToContainerByPath)(`${(0, string_utils_1.anyCaseToPascalCase)(moduleName)}Module`, newModuleOutputPath, folderToScaffold, folderName);
|
|
410
|
+
return newModuleName;
|
|
382
411
|
}
|
|
383
412
|
/**
|
|
384
413
|
* Generate a module for service scaffolding with single path
|
|
@@ -391,7 +420,7 @@ async function generateModuleServiceSinglePath(outputPathController, className,
|
|
|
391
420
|
const newModuleFile = await (0, command_utils_1.extractFirstWord)(file);
|
|
392
421
|
const newModulePath = nodePath.join(folderToScaffold, path).normalize();
|
|
393
422
|
const newModuleName = `${newModuleFile}.module.ts`;
|
|
394
|
-
const newModuleOutputPath = `${newModulePath}/${newModuleName}`.replace(
|
|
423
|
+
const newModuleOutputPath = `${newModulePath}/${newModuleName}`.replace(/\\/g, "/");
|
|
395
424
|
const controllerToModule = nodePath
|
|
396
425
|
.relative(newModuleOutputPath, outputPathController)
|
|
397
426
|
.normalize()
|
|
@@ -403,7 +432,7 @@ async function generateModuleServiceSinglePath(outputPathController, className,
|
|
|
403
432
|
.normalize();
|
|
404
433
|
if (fs_1.default.existsSync(newModuleOutputPath)) {
|
|
405
434
|
await (0, add_controller_to_module_1.addControllerToModule)(controllerFullPath, `${className}Controller`, controllerToModule);
|
|
406
|
-
return;
|
|
435
|
+
return newModuleName;
|
|
407
436
|
}
|
|
408
437
|
(0, command_utils_1.writeTemplate)({
|
|
409
438
|
outputPath: newModuleOutputPath,
|
|
@@ -416,7 +445,10 @@ async function generateModuleServiceSinglePath(outputPathController, className,
|
|
|
416
445
|
},
|
|
417
446
|
},
|
|
418
447
|
});
|
|
419
|
-
|
|
448
|
+
// Extract folder name from folderToScaffold (e.g., "src/useCases" -> "useCases")
|
|
449
|
+
const folderName = nodePath.basename(folderToScaffold);
|
|
450
|
+
await (0, add_module_to_container_1.addModuleToContainerByPath)(`${(0, string_utils_1.anyCaseToPascalCase)(moduleName)}Module`, newModuleOutputPath, folderToScaffold, folderName);
|
|
451
|
+
return newModuleName;
|
|
420
452
|
}
|
|
421
453
|
/**
|
|
422
454
|
* Generate a module for service scaffolding with nested path
|
|
@@ -432,7 +464,7 @@ async function generateModuleServiceNestedPath(outputPathController, className,
|
|
|
432
464
|
.join(folderToScaffold, path, "..")
|
|
433
465
|
.normalize();
|
|
434
466
|
const newModuleName = `${moduleFileName}.module.ts`;
|
|
435
|
-
const newModuleOutputPath = `${newModulePath}/${newModuleName}`.replace(
|
|
467
|
+
const newModuleOutputPath = `${newModulePath}/${newModuleName}`.replace(/\\/g, "/");
|
|
436
468
|
const controllerToModule = nodePath
|
|
437
469
|
.relative(newModuleOutputPath, outputPathController)
|
|
438
470
|
.normalize()
|
|
@@ -444,7 +476,7 @@ async function generateModuleServiceNestedPath(outputPathController, className,
|
|
|
444
476
|
.normalize();
|
|
445
477
|
if (fs_1.default.existsSync(newModuleOutputPath)) {
|
|
446
478
|
await (0, add_controller_to_module_1.addControllerToModule)(controllerFullPath, `${className}Controller`, controllerToModule);
|
|
447
|
-
return;
|
|
479
|
+
return newModuleName;
|
|
448
480
|
}
|
|
449
481
|
(0, command_utils_1.writeTemplate)({
|
|
450
482
|
outputPath: newModuleOutputPath,
|
|
@@ -457,7 +489,10 @@ async function generateModuleServiceNestedPath(outputPathController, className,
|
|
|
457
489
|
},
|
|
458
490
|
},
|
|
459
491
|
});
|
|
460
|
-
|
|
492
|
+
// Extract folder name from folderToScaffold (e.g., "src/useCases" -> "useCases")
|
|
493
|
+
const folderName = nodePath.basename(folderToScaffold);
|
|
494
|
+
await (0, add_module_to_container_1.addModuleToContainerByPath)(`${(0, string_utils_1.anyCaseToPascalCase)(moduleFileName)}Module`, newModuleOutputPath, folderToScaffold, folderName);
|
|
495
|
+
return newModuleName;
|
|
461
496
|
}
|
|
462
497
|
/**
|
|
463
498
|
* Generate a module
|
|
@@ -479,3 +514,80 @@ async function generateModule(outputPath, className, moduleName, path) {
|
|
|
479
514
|
},
|
|
480
515
|
});
|
|
481
516
|
}
|
|
517
|
+
// NEW v4.0 Schematic Generators
|
|
518
|
+
/**
|
|
519
|
+
* Generate an interceptor
|
|
520
|
+
*/
|
|
521
|
+
async function generateInterceptor(outputPath, className, priority) {
|
|
522
|
+
(0, command_utils_1.writeTemplate)({
|
|
523
|
+
outputPath,
|
|
524
|
+
template: {
|
|
525
|
+
path: "../templates/opinionated/interceptor.tpl",
|
|
526
|
+
data: {
|
|
527
|
+
className: (0, string_utils_1.anyCaseToPascalCase)(className),
|
|
528
|
+
priority: priority.toString(),
|
|
529
|
+
},
|
|
530
|
+
},
|
|
531
|
+
});
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* Generate an event
|
|
535
|
+
*/
|
|
536
|
+
async function generateEvent(outputPath, className) {
|
|
537
|
+
(0, command_utils_1.writeTemplate)({
|
|
538
|
+
outputPath,
|
|
539
|
+
template: {
|
|
540
|
+
path: "../templates/opinionated/event.tpl",
|
|
541
|
+
data: {
|
|
542
|
+
className: (0, string_utils_1.anyCaseToPascalCase)(className),
|
|
543
|
+
},
|
|
544
|
+
},
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
/**
|
|
548
|
+
* Generate an event handler
|
|
549
|
+
*/
|
|
550
|
+
async function generateHandler(outputPath, className, eventName, priority) {
|
|
551
|
+
(0, command_utils_1.writeTemplate)({
|
|
552
|
+
outputPath,
|
|
553
|
+
template: {
|
|
554
|
+
path: "../templates/opinionated/handler.tpl",
|
|
555
|
+
data: {
|
|
556
|
+
className: (0, string_utils_1.anyCaseToPascalCase)(className),
|
|
557
|
+
eventName: (0, string_utils_1.anyCaseToPascalCase)(eventName),
|
|
558
|
+
eventPath: `@events/${(0, string_utils_1.anyCaseToKebabCase)(eventName)}.event`,
|
|
559
|
+
priority: priority.toString(),
|
|
560
|
+
},
|
|
561
|
+
},
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* Generate a guard
|
|
566
|
+
*/
|
|
567
|
+
async function generateGuard(outputPath, className) {
|
|
568
|
+
(0, command_utils_1.writeTemplate)({
|
|
569
|
+
outputPath,
|
|
570
|
+
template: {
|
|
571
|
+
path: "../templates/opinionated/guard.tpl",
|
|
572
|
+
data: {
|
|
573
|
+
className: (0, string_utils_1.anyCaseToPascalCase)(className),
|
|
574
|
+
},
|
|
575
|
+
},
|
|
576
|
+
});
|
|
577
|
+
}
|
|
578
|
+
/**
|
|
579
|
+
* Generate a config module
|
|
580
|
+
*/
|
|
581
|
+
async function generateConfig(outputPath, className, moduleName) {
|
|
582
|
+
(0, command_utils_1.writeTemplate)({
|
|
583
|
+
outputPath,
|
|
584
|
+
template: {
|
|
585
|
+
path: "../templates/opinionated/config.tpl",
|
|
586
|
+
data: {
|
|
587
|
+
className: (0, string_utils_1.anyCaseToPascalCase)(className),
|
|
588
|
+
moduleName: (0, string_utils_1.anyCaseToCamelCase)(moduleName || className),
|
|
589
|
+
envPrefix: (0, string_utils_1.anyCaseToUpperSnakeCase)(className),
|
|
590
|
+
},
|
|
591
|
+
},
|
|
592
|
+
});
|
|
593
|
+
}
|
|
@@ -34,3 +34,9 @@ export declare function anyCaseToUpperCase(str: string): string;
|
|
|
34
34
|
* @returns The converted string in lower case.
|
|
35
35
|
*/
|
|
36
36
|
export declare function anyCaseToLowerCase(str: string): string;
|
|
37
|
+
/**
|
|
38
|
+
* Converts a string from any case (camelCase, PascalCase, kebab-case, snake_case) to UPPER_SNAKE_CASE.
|
|
39
|
+
* @param str - The input string to be converted.
|
|
40
|
+
* @returns The converted string in UPPER_SNAKE_CASE.
|
|
41
|
+
*/
|
|
42
|
+
export declare function anyCaseToUpperSnakeCase(str: string): string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.anyCaseToLowerCase = exports.anyCaseToUpperCase = exports.anyCaseToSnakeCase = exports.anyCaseToPascalCase = exports.anyCaseToKebabCase = exports.anyCaseToCamelCase = void 0;
|
|
3
|
+
exports.anyCaseToUpperSnakeCase = exports.anyCaseToLowerCase = exports.anyCaseToUpperCase = exports.anyCaseToSnakeCase = exports.anyCaseToPascalCase = exports.anyCaseToKebabCase = exports.anyCaseToCamelCase = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Converts a string from any case (camelCase, PascalCase, kebab-case, snake_case) to camelCase.
|
|
6
6
|
* @param str - The input string to be converted.
|
|
@@ -69,3 +69,15 @@ function anyCaseToLowerCase(str) {
|
|
|
69
69
|
.toLowerCase();
|
|
70
70
|
}
|
|
71
71
|
exports.anyCaseToLowerCase = anyCaseToLowerCase;
|
|
72
|
+
/**
|
|
73
|
+
* Converts a string from any case (camelCase, PascalCase, kebab-case, snake_case) to UPPER_SNAKE_CASE.
|
|
74
|
+
* @param str - The input string to be converted.
|
|
75
|
+
* @returns The converted string in UPPER_SNAKE_CASE.
|
|
76
|
+
*/
|
|
77
|
+
function anyCaseToUpperSnakeCase(str) {
|
|
78
|
+
return str
|
|
79
|
+
.replace(/([a-z0-9])([A-Z])/g, "$1_$2")
|
|
80
|
+
.replace(/[-]+/g, "_")
|
|
81
|
+
.toUpperCase();
|
|
82
|
+
}
|
|
83
|
+
exports.anyCaseToUpperSnakeCase = anyCaseToUpperSnakeCase;
|
package/bin/help/cli.d.ts
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type CommandHelpSpec } from "./command-help";
|
|
2
|
+
/**
|
|
3
|
+
* Structured help specs for the subcommands whose option-heavy `--help` would
|
|
4
|
+
* otherwise render as yargs' sprawling default table. Keeping them here lets
|
|
5
|
+
* the central interceptor in `cli.ts` render a refined, grouped screen that
|
|
6
|
+
* matches the rest of the CLI without touching each command's yargs builder.
|
|
7
|
+
*
|
|
8
|
+
* NOTE: these mirror the option definitions in each command's `cli.ts`. When
|
|
9
|
+
* an option/choice/default changes there, update the matching entry here.
|
|
10
|
+
*/
|
|
11
|
+
declare const SPECS: CommandHelpSpec[];
|
|
12
|
+
/**
|
|
13
|
+
* Resolve a command token (name or alias) to its help spec, if any.
|
|
14
|
+
*/
|
|
15
|
+
export declare function resolveCommandHelpSpec(token: string): CommandHelpSpec | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Detect a `<command> --help` / `<command> -h` invocation and, if the command
|
|
18
|
+
* has a registered spec, render the refined help screen.
|
|
19
|
+
*
|
|
20
|
+
* @returns `true` when custom help was printed (caller should exit), else `false`.
|
|
21
|
+
*/
|
|
22
|
+
export declare function tryPrintCommandHelp(args: string[], version?: string): boolean;
|
|
23
|
+
export { SPECS as COMMAND_HELP_SPECS };
|