@expressots/cli 1.6.0 → 1.7.1

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.
Files changed (54) hide show
  1. package/bin/@types/config.d.ts +9 -0
  2. package/bin/app.container.js +4 -5
  3. package/bin/cli.d.ts +1 -1
  4. package/bin/cli.js +2 -2
  5. package/bin/generate/cli.js +2 -2
  6. package/bin/generate/form.d.ts +13 -0
  7. package/bin/generate/form.js +17 -377
  8. package/bin/generate/templates/nonopinionated/controller.tpl +4 -0
  9. package/bin/generate/templates/nonopinionated/dto.tpl +3 -0
  10. package/bin/generate/templates/nonopinionated/entity.tpl +4 -0
  11. package/bin/generate/templates/nonopinionated/middleware.tpl +10 -0
  12. package/bin/generate/templates/nonopinionated/module.tpl +4 -0
  13. package/bin/generate/templates/nonopinionated/provider.tpl +4 -0
  14. package/bin/generate/templates/nonopinionated/usecase.tpl +4 -0
  15. package/bin/generate/templates/{controller-service-delete.tpl → opinionated/controller-service-delete.tpl} +2 -2
  16. package/bin/generate/templates/{controller-service.tpl → opinionated/controller-service-get.tpl} +2 -2
  17. package/bin/generate/templates/{controller-service-patch.tpl → opinionated/controller-service-patch.tpl} +2 -2
  18. package/bin/generate/templates/{controller-service-post.tpl → opinionated/controller-service-post.tpl} +2 -2
  19. package/bin/generate/templates/{controller-service-put.tpl → opinionated/controller-service-put.tpl} +2 -2
  20. package/bin/generate/templates/{entity.tpl → opinionated/entity.tpl} +2 -2
  21. package/bin/generate/templates/opinionated/usecase-service-delete.tpl +8 -0
  22. package/bin/generate/utils/command-utils.d.ts +123 -0
  23. package/bin/generate/utils/command-utils.js +310 -0
  24. package/bin/generate/utils/nonopininated-cmd.d.ts +9 -0
  25. package/bin/generate/utils/nonopininated-cmd.js +248 -0
  26. package/bin/generate/utils/opinionated-cmd.d.ts +11 -0
  27. package/bin/generate/utils/opinionated-cmd.js +480 -0
  28. package/bin/help/cli.d.ts +4 -0
  29. package/bin/help/cli.js +15 -0
  30. package/bin/help/form.d.ts +2 -0
  31. package/bin/help/form.js +28 -0
  32. package/bin/help/index.d.ts +1 -0
  33. package/bin/help/index.js +2 -0
  34. package/bin/info/form.d.ts +1 -1
  35. package/bin/info/form.js +8 -11
  36. package/bin/new/form.js +1 -0
  37. package/bin/utils/add-controller-to-module.d.ts +1 -2
  38. package/bin/utils/add-module-to-container.d.ts +2 -1
  39. package/bin/utils/add-module-to-container.js +37 -4
  40. package/bin/utils/cli-ui.d.ts +2 -0
  41. package/bin/utils/cli-ui.js +10 -2
  42. package/bin/utils/verify-file-exists.d.ts +1 -1
  43. package/bin/utils/verify-file-exists.js +6 -4
  44. package/package.json +4 -1
  45. package/bin/generate/templates/dto-op.tpl +0 -7
  46. package/bin/generate/templates/usecase-post.tpl +0 -9
  47. /package/bin/generate/templates/{controller.tpl → opinionated/controller-service.tpl} +0 -0
  48. /package/bin/generate/templates/{dto.tpl → opinionated/dto.tpl} +0 -0
  49. /package/bin/generate/templates/{middleware.tpl → opinionated/middleware.tpl} +0 -0
  50. /package/bin/generate/templates/{module.tpl → opinionated/module-service.tpl} +0 -0
  51. /package/bin/generate/templates/{module-default.tpl → opinionated/module.tpl} +0 -0
  52. /package/bin/generate/templates/{provider.tpl → opinionated/provider.tpl} +0 -0
  53. /package/bin/generate/templates/{usecase-op.tpl → opinionated/usecase-service.tpl} +0 -0
  54. /package/bin/generate/templates/{usecase.tpl → opinionated/usecase.tpl} +0 -0
@@ -0,0 +1,480 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.opinionatedProcess = void 0;
30
+ const boost_ts_1 = require("@expressots/boost-ts");
31
+ const nodePath = __importStar(require("node:path"));
32
+ const fs_1 = __importDefault(require("fs"));
33
+ const cli_ui_1 = require("../../utils/cli-ui");
34
+ const command_utils_1 = require("./command-utils");
35
+ const add_controller_to_module_1 = require("../../utils/add-controller-to-module");
36
+ const add_module_to_container_1 = require("../../utils/add-module-to-container");
37
+ /**
38
+ * Process commands for opinionated service scaffolding
39
+ * @param schematic - Resource to scaffold
40
+ * @param target - Target path
41
+ * @param method - HTTP method
42
+ * @param expressoConfig - Expresso configuration [expressots.config.ts]
43
+ * @param pathStyle - Path command style [sugar, nested, single]
44
+ * @returns
45
+ */
46
+ async function opinionatedProcess(schematic, target, method, expressoConfig, pathStyle) {
47
+ const f = await (0, command_utils_1.validateAndPrepareFile)({
48
+ schematic,
49
+ target,
50
+ method,
51
+ expressoConfig,
52
+ });
53
+ switch (schematic) {
54
+ case "service":
55
+ await generateControllerService(f.outputPath, f.className, f.path, method, f.file);
56
+ const u = await (0, command_utils_1.validateAndPrepareFile)({
57
+ schematic: "usecase",
58
+ target,
59
+ method,
60
+ expressoConfig,
61
+ });
62
+ await generateUseCaseService(u.outputPath, u.className, method, u.moduleName, u.path, u.fileName);
63
+ const d = await (0, command_utils_1.validateAndPrepareFile)({
64
+ schematic: "dto",
65
+ target,
66
+ method,
67
+ expressoConfig,
68
+ });
69
+ await generateDTO(d.outputPath, d.className, d.moduleName, d.path);
70
+ const m = await (0, command_utils_1.validateAndPrepareFile)({
71
+ schematic: "module",
72
+ target,
73
+ method,
74
+ expressoConfig,
75
+ });
76
+ if (pathStyle === "sugar" /* PathStyle.Sugar */) {
77
+ await generateModuleServiceSugarPath(f.outputPath, m.className, m.moduleName, m.path, m.file, m.folderToScaffold);
78
+ }
79
+ else if (pathStyle === "nested" /* PathStyle.Nested */) {
80
+ await generateModuleServiceNestedPath(f.outputPath, m.className, m.path, m.folderToScaffold);
81
+ }
82
+ else if (pathStyle === "single" /* PathStyle.Single */) {
83
+ await generateModuleServiceSinglePath(f.outputPath, m.className, m.moduleName, m.path, m.file, m.folderToScaffold);
84
+ }
85
+ await (0, cli_ui_1.printGenerateSuccess)("controller", f.file);
86
+ await (0, cli_ui_1.printGenerateSuccess)("usecase", f.file);
87
+ await (0, cli_ui_1.printGenerateSuccess)("dto", f.file);
88
+ await (0, cli_ui_1.printGenerateSuccess)("module", f.file);
89
+ break;
90
+ case "usecase":
91
+ await generateUseCase(f.outputPath, f.className, f.moduleName, f.path, f.fileName);
92
+ await (0, cli_ui_1.printGenerateSuccess)(schematic, f.file);
93
+ break;
94
+ case "controller":
95
+ await generateController(f.outputPath, f.className, f.path, method, f.file);
96
+ await (0, cli_ui_1.printGenerateSuccess)(schematic, f.file);
97
+ break;
98
+ case "dto":
99
+ await generateDTO(f.outputPath, f.className, f.moduleName, f.path);
100
+ await (0, cli_ui_1.printGenerateSuccess)(schematic, f.file);
101
+ break;
102
+ case "provider":
103
+ await generateProvider(f.outputPath, f.className, f.moduleName, f.path);
104
+ await (0, cli_ui_1.printGenerateSuccess)(schematic, f.file);
105
+ break;
106
+ case "entity":
107
+ await generateEntity(f.outputPath, f.className, f.moduleName, f.path);
108
+ await (0, cli_ui_1.printGenerateSuccess)(schematic, f.file);
109
+ break;
110
+ case "middleware":
111
+ await generateMiddleware(f.outputPath, f.className, f.moduleName, f.path);
112
+ await (0, cli_ui_1.printGenerateSuccess)(schematic, f.file);
113
+ break;
114
+ case "module":
115
+ await generateModule(f.outputPath, f.className, f.moduleName, f.path);
116
+ await (0, cli_ui_1.printGenerateSuccess)(schematic, f.file);
117
+ break;
118
+ }
119
+ return f.file;
120
+ }
121
+ exports.opinionatedProcess = opinionatedProcess;
122
+ /* Generate Resource */
123
+ /**
124
+ * Generate a controller service
125
+ * @param outputPath - The output path
126
+ * @param className - The class name
127
+ * @param moduleName - The module name
128
+ * @param path - The path
129
+ * @param method - The method
130
+ * @param file - The file
131
+ */
132
+ async function generateControllerService(outputPath, className, path, method, file) {
133
+ let templateBasedMethod = "";
134
+ switch (method) {
135
+ case "put":
136
+ templateBasedMethod =
137
+ "../templates/opinionated/controller-service-put.tpl";
138
+ break;
139
+ case "patch":
140
+ templateBasedMethod =
141
+ "../templates/opinionated/controller-service-patch.tpl";
142
+ break;
143
+ case "post":
144
+ templateBasedMethod =
145
+ "../templates/opinionated/controller-service-post.tpl";
146
+ break;
147
+ case "delete":
148
+ templateBasedMethod =
149
+ "../templates/opinionated/controller-service-delete.tpl";
150
+ break;
151
+ default:
152
+ templateBasedMethod =
153
+ "../templates/opinionated/controller-service-get.tpl";
154
+ break;
155
+ }
156
+ (0, command_utils_1.writeTemplate)({
157
+ outputPath,
158
+ template: {
159
+ path: templateBasedMethod,
160
+ data: {
161
+ className,
162
+ fileName: (0, command_utils_1.getFileNameWithoutExtension)(file),
163
+ useCase: (0, boost_ts_1.anyCaseToCamelCase)(className),
164
+ route: path.replace(/\/$/, ""),
165
+ construct: (0, boost_ts_1.anyCaseToKebabCase)(className),
166
+ method: (0, command_utils_1.getHttpMethod)(method),
167
+ },
168
+ },
169
+ });
170
+ }
171
+ /**
172
+ * Generate a use case
173
+ * @param outputPath - The output path
174
+ * @param className - The class name
175
+ * @param moduleName - The module name
176
+ * @param path - The path
177
+ * @param template - The template
178
+ */
179
+ async function generateUseCaseService(outputPath, className, method, moduleName, path, fileName) {
180
+ let templateBasedMethod = "";
181
+ switch (method) {
182
+ case "put":
183
+ templateBasedMethod =
184
+ "../templates/opinionated/usecase-service.tpl";
185
+ break;
186
+ case "patch":
187
+ templateBasedMethod =
188
+ "../templates/opinionated/usecase-service.tpl";
189
+ break;
190
+ case "post":
191
+ templateBasedMethod =
192
+ "../templates/opinionated/usecase-service.tpl";
193
+ break;
194
+ case "delete":
195
+ templateBasedMethod =
196
+ "../templates/opinionated/usecase-service-delete.tpl";
197
+ break;
198
+ default:
199
+ templateBasedMethod = "../templates/opinionated/usecase.tpl";
200
+ break;
201
+ }
202
+ (0, command_utils_1.writeTemplate)({
203
+ outputPath,
204
+ template: {
205
+ path: templateBasedMethod,
206
+ data: {
207
+ className,
208
+ moduleName,
209
+ path,
210
+ fileName,
211
+ },
212
+ },
213
+ });
214
+ }
215
+ /**
216
+ * Generate a use case
217
+ * @param outputPath - The output path
218
+ * @param className - The class name
219
+ * @param moduleName - The module name
220
+ * @param path - The path
221
+ * @param fileName - The file name
222
+ */
223
+ async function generateUseCase(outputPath, className, moduleName, path, fileName) {
224
+ (0, command_utils_1.writeTemplate)({
225
+ outputPath,
226
+ template: {
227
+ path: "../templates/opinionated/usecase.tpl",
228
+ data: {
229
+ className,
230
+ moduleName,
231
+ path,
232
+ fileName,
233
+ },
234
+ },
235
+ });
236
+ }
237
+ /**
238
+ * Generate a controller
239
+ * @param outputPath - The output path
240
+ * @param className - The class name
241
+ * @param path - The path
242
+ * @param method - The method
243
+ * @param file - The file
244
+ */
245
+ async function generateController(outputPath, className, path, method, file) {
246
+ const templateBasedMethod = "../templates/opinionated/controller-service.tpl";
247
+ (0, command_utils_1.writeTemplate)({
248
+ outputPath,
249
+ template: {
250
+ path: templateBasedMethod,
251
+ data: {
252
+ className,
253
+ fileName: (0, command_utils_1.getFileNameWithoutExtension)(file),
254
+ useCase: (0, boost_ts_1.anyCaseToCamelCase)(className),
255
+ route: path.replace(/\/$/, ""),
256
+ construct: (0, boost_ts_1.anyCaseToKebabCase)(className),
257
+ method: (0, command_utils_1.getHttpMethod)(method),
258
+ },
259
+ },
260
+ });
261
+ }
262
+ /**
263
+ * Generate a DTO
264
+ * @param outputPath - The output path
265
+ * @param className - The class name
266
+ * @param moduleName - The module name
267
+ * @param path - The path
268
+ */
269
+ async function generateDTO(outputPath, className, moduleName, path) {
270
+ (0, command_utils_1.writeTemplate)({
271
+ outputPath,
272
+ template: {
273
+ path: "../templates/opinionated/dto.tpl",
274
+ data: {
275
+ className,
276
+ moduleName,
277
+ path,
278
+ },
279
+ },
280
+ });
281
+ }
282
+ /**
283
+ * Generate a provider
284
+ * @param outputPath - The output path
285
+ * @param className - The class name
286
+ * @param moduleName - The module name
287
+ * @param path - The path
288
+ */
289
+ async function generateProvider(outputPath, className, moduleName, path) {
290
+ (0, command_utils_1.writeTemplate)({
291
+ outputPath,
292
+ template: {
293
+ path: "../templates/opinionated/provider.tpl",
294
+ data: {
295
+ className,
296
+ moduleName,
297
+ path,
298
+ },
299
+ },
300
+ });
301
+ }
302
+ /**
303
+ * Generate an entity
304
+ * @param outputPath - The output path
305
+ * @param className - The class name
306
+ * @param moduleName - The module name
307
+ * @param path - The path
308
+ */
309
+ async function generateEntity(outputPath, className, moduleName, path) {
310
+ (0, command_utils_1.writeTemplate)({
311
+ outputPath,
312
+ template: {
313
+ path: "../templates/opinionated/entity.tpl",
314
+ data: {
315
+ className,
316
+ moduleName,
317
+ path,
318
+ },
319
+ },
320
+ });
321
+ }
322
+ /**
323
+ * Generate a middleware
324
+ * @param outputPath - The output path
325
+ * @param className - The class name
326
+ * @param moduleName - The module name
327
+ * @param path - The path
328
+ */
329
+ async function generateMiddleware(outputPath, className, moduleName, path) {
330
+ (0, command_utils_1.writeTemplate)({
331
+ outputPath,
332
+ template: {
333
+ path: "../templates/opinionated/middleware.tpl",
334
+ data: {
335
+ className,
336
+ moduleName,
337
+ path,
338
+ },
339
+ },
340
+ });
341
+ }
342
+ /**
343
+ * Generate a module for service scaffolding with sugar path
344
+ * @param outputPath - The output path
345
+ * @param className - The class name
346
+ * @param moduleName - The module name
347
+ * @param path - The path
348
+ */
349
+ async function generateModuleServiceSugarPath(outputPathController, className, moduleName, path, file, folderToScaffold) {
350
+ const newModuleFile = await (0, command_utils_1.extractFirstWord)(file);
351
+ const newModulePath = nodePath
352
+ .join(folderToScaffold, path, "..")
353
+ .normalize();
354
+ const newModuleName = `${newModuleFile}.module.ts`;
355
+ const newModuleOutputPath = `${newModulePath}/${newModuleName}`.replace("\\", "/");
356
+ const controllerToModule = nodePath
357
+ .relative(newModuleOutputPath, outputPathController)
358
+ .normalize()
359
+ .replace(/\.ts$/, "")
360
+ .replace(/\\/g, "/")
361
+ .replace(/\.\./g, ".");
362
+ const controllerFullPath = nodePath
363
+ .join(folderToScaffold, path, "..", newModuleName)
364
+ .normalize();
365
+ if (fs_1.default.existsSync(newModuleOutputPath)) {
366
+ await (0, add_controller_to_module_1.addControllerToModule)(controllerFullPath, `${className}Controller`, controllerToModule);
367
+ return;
368
+ }
369
+ (0, command_utils_1.writeTemplate)({
370
+ outputPath: newModuleOutputPath,
371
+ template: {
372
+ path: "../templates/opinionated/module-service.tpl",
373
+ data: {
374
+ className,
375
+ moduleName: (0, boost_ts_1.anyCaseToPascalCase)(moduleName),
376
+ path: controllerToModule,
377
+ },
378
+ },
379
+ });
380
+ await (0, add_module_to_container_1.addModuleToContainer)((0, boost_ts_1.anyCaseToPascalCase)(moduleName), `${moduleName}/${file.replace(".ts", "")}`, path);
381
+ }
382
+ /**
383
+ * Generate a module for service scaffolding with single path
384
+ * @param outputPath - The output path
385
+ * @param className - The class name
386
+ * @param moduleName - The module name
387
+ * @param path - The path
388
+ */
389
+ async function generateModuleServiceSinglePath(outputPathController, className, moduleName, path, file, folderToScaffold) {
390
+ const newModuleFile = await (0, command_utils_1.extractFirstWord)(file);
391
+ const newModulePath = nodePath.join(folderToScaffold, path).normalize();
392
+ const newModuleName = `${newModuleFile}.module.ts`;
393
+ const newModuleOutputPath = `${newModulePath}/${newModuleName}`.replace("\\", "/");
394
+ const controllerToModule = nodePath
395
+ .relative(newModuleOutputPath, outputPathController)
396
+ .normalize()
397
+ .replace(/\.ts$/, "")
398
+ .replace(/\\/g, "/")
399
+ .replace(/\.\./g, ".");
400
+ const controllerFullPath = nodePath
401
+ .join(folderToScaffold, path, "..", newModuleName)
402
+ .normalize();
403
+ if (fs_1.default.existsSync(newModuleOutputPath)) {
404
+ await (0, add_controller_to_module_1.addControllerToModule)(controllerFullPath, `${className}Controller`, controllerToModule);
405
+ return;
406
+ }
407
+ (0, command_utils_1.writeTemplate)({
408
+ outputPath: newModuleOutputPath,
409
+ template: {
410
+ path: "../templates/opinionated/module-service.tpl",
411
+ data: {
412
+ className,
413
+ moduleName: (0, boost_ts_1.anyCaseToPascalCase)(moduleName),
414
+ path: controllerToModule,
415
+ },
416
+ },
417
+ });
418
+ await (0, add_module_to_container_1.addModuleToContainer)((0, boost_ts_1.anyCaseToPascalCase)(moduleName), `${moduleName}/${file.replace(".ts", "")}`, path);
419
+ }
420
+ /**
421
+ * Generate a module for service scaffolding with nested path
422
+ * @param outputPathController
423
+ * @param className
424
+ * @param path
425
+ * @param folderToScaffold
426
+ * @returns
427
+ */
428
+ async function generateModuleServiceNestedPath(outputPathController, className, path, folderToScaffold) {
429
+ const moduleFileName = nodePath.basename(path, "/");
430
+ const newModulePath = nodePath
431
+ .join(folderToScaffold, path, "..")
432
+ .normalize();
433
+ const newModuleName = `${moduleFileName}.module.ts`;
434
+ const newModuleOutputPath = `${newModulePath}/${newModuleName}`.replace("\\", "/");
435
+ const controllerToModule = nodePath
436
+ .relative(newModuleOutputPath, outputPathController)
437
+ .normalize()
438
+ .replace(/\.ts$/, "")
439
+ .replace(/\\/g, "/")
440
+ .replace(/\.\./g, ".");
441
+ const controllerFullPath = nodePath
442
+ .join(folderToScaffold, path, "..", newModuleName)
443
+ .normalize();
444
+ if (fs_1.default.existsSync(newModuleOutputPath)) {
445
+ await (0, add_controller_to_module_1.addControllerToModule)(controllerFullPath, `${className}Controller`, controllerToModule);
446
+ return;
447
+ }
448
+ (0, command_utils_1.writeTemplate)({
449
+ outputPath: newModuleOutputPath,
450
+ template: {
451
+ path: "../templates/opinionated/module-service.tpl",
452
+ data: {
453
+ className,
454
+ moduleName: (0, boost_ts_1.anyCaseToPascalCase)(moduleFileName),
455
+ path: controllerToModule,
456
+ },
457
+ },
458
+ });
459
+ await (0, add_module_to_container_1.addModuleToContainerNestedPath)((0, boost_ts_1.anyCaseToPascalCase)(moduleFileName), path);
460
+ }
461
+ /**
462
+ * Generate a module
463
+ * @param outputPath - The output path
464
+ * @param className - The class name
465
+ * @param moduleName - The module name
466
+ * @param path - The path
467
+ */
468
+ async function generateModule(outputPath, className, moduleName, path) {
469
+ (0, command_utils_1.writeTemplate)({
470
+ outputPath,
471
+ template: {
472
+ path: "../templates/opinionated/module.tpl",
473
+ data: {
474
+ className,
475
+ moduleName: (0, boost_ts_1.anyCaseToPascalCase)(moduleName),
476
+ path,
477
+ },
478
+ },
479
+ });
480
+ }
@@ -0,0 +1,4 @@
1
+ import { CommandModule } from "yargs";
2
+ type CommandModuleArgs = {};
3
+ declare const helpCommand: () => CommandModule<CommandModuleArgs, any>;
4
+ export { helpCommand };
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.helpCommand = void 0;
4
+ const form_1 = require("./form");
5
+ const helpCommand = () => {
6
+ return {
7
+ command: "resources",
8
+ describe: "Resource list",
9
+ aliases: ["r"],
10
+ handler: async () => {
11
+ await (0, form_1.helpForm)();
12
+ },
13
+ };
14
+ };
15
+ exports.helpCommand = helpCommand;
@@ -0,0 +1,2 @@
1
+ declare const helpForm: () => Promise<void>;
2
+ export { helpForm };
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.helpForm = void 0;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ const cli_table3_1 = __importDefault(require("cli-table3"));
9
+ const helpForm = async () => {
10
+ const table = new cli_table3_1.default({
11
+ head: [
12
+ chalk_1.default.green("Name"),
13
+ chalk_1.default.green("Alias"),
14
+ chalk_1.default.green("Description"),
15
+ ],
16
+ colWidths: [15, 10, 60],
17
+ });
18
+ table.push(["new project", "new", "Generate a new project"], ["info", "i", "Provides project information"], ["resources", "r", "Displays cli commands and resources"], ["help", "h", "Show command help"], [
19
+ "service",
20
+ "g s",
21
+ "Generate a service [controller, usecase, dto, module]",
22
+ ], ["controller", "g c", "Generate a controller"], ["usecase", "g u", "Generate a usecase"], ["dto", "g d", "Generate a dto"], ["entity", "g e", "Generate an entity"], ["provider", "g p", "Generate a provider"], ["module", "g mo", "Generate a module"], ["middleware", "g mi", "Generate a middleware"]);
23
+ console.log(chalk_1.default.bold.white("ExpressoTS:", `${chalk_1.default.green("Resources List")}`));
24
+ console.log(chalk_1.default.whiteBright(table.toString()));
25
+ console.log(chalk_1.default.bold.white(`📝 More info: ${chalk_1.default.green("https://doc.expresso-ts.com/docs/category/cli")}`));
26
+ console.log("\n");
27
+ };
28
+ exports.helpForm = helpForm;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +1,2 @@
1
- declare const infoForm: () => Promise<void>;
1
+ declare const infoForm: () => void;
2
2
  export { infoForm };
package/bin/info/form.js CHANGED
@@ -8,7 +8,6 @@ const chalk_1 = __importDefault(require("chalk"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const fs_1 = __importDefault(require("fs"));
10
10
  const os_1 = __importDefault(require("os"));
11
- const cli_1 = require("../cli");
12
11
  const cli_ui_1 = require("../utils/cli-ui");
13
12
  function getInfosFromPackage() {
14
13
  try {
@@ -19,21 +18,19 @@ function getInfosFromPackage() {
19
18
  const fileContents = fs_1.default.readFileSync(packageJsonPath, "utf-8");
20
19
  const packageJson = JSON.parse(fileContents);
21
20
  console.log(chalk_1.default.green("ExpressoTS Project:"));
22
- console.log(chalk_1.default.bold(`\tName: ${packageJson.name}`));
23
- console.log(chalk_1.default.bold(`\tDescription: ${packageJson.description}`));
24
- console.log(chalk_1.default.bold(`\tVersion: ${packageJson.version}`));
25
- console.log(chalk_1.default.bold(`\tAuthor: ${packageJson.author}`));
21
+ console.log(chalk_1.default.white(`\tName: ${packageJson.name}`));
22
+ console.log(chalk_1.default.white(`\tDescription: ${packageJson.description}`));
23
+ console.log(chalk_1.default.white(`\tVersion: ${packageJson.version}`));
24
+ console.log(chalk_1.default.white(`\tAuthor: ${packageJson.author}`));
26
25
  }
27
26
  catch (error) {
28
27
  (0, cli_ui_1.printError)("No project information available.", "package.json not found!");
29
28
  }
30
29
  }
31
- const infoForm = async () => {
32
- console.log(chalk_1.default.green("System informations:"));
33
- console.log(chalk_1.default.bold(`\tOS Version: ${os_1.default.version()}`));
34
- console.log(chalk_1.default.bold(`\tNodeJS version: ${process.version}`));
35
- console.log(chalk_1.default.green("CLI Version:"));
36
- console.log(chalk_1.default.bold(`\tCurrent version: v${cli_1.CLI_VERSION}`));
30
+ const infoForm = () => {
37
31
  getInfosFromPackage();
32
+ console.log(chalk_1.default.green("System information:"));
33
+ console.log(chalk_1.default.white(`\tOS Version: ${os_1.default.version()}`));
34
+ console.log(chalk_1.default.white(`\tNodeJS version: ${process.version}`));
38
35
  };
39
36
  exports.infoForm = infoForm;
package/bin/new/form.js CHANGED
@@ -166,6 +166,7 @@ const projectForm = async (projectName, args) => {
166
166
  await emitter.clone(answer.name);
167
167
  }
168
168
  catch (err) {
169
+ console.log("\n");
169
170
  (0, cli_ui_1.printError)("Project already exists or Folder is not empty", answer.name);
170
171
  process.exit(1);
171
172
  }
@@ -1,2 +1 @@
1
- declare function addControllerToModule(filePath: string, controllerName: string, controllerPath: string): Promise<void>;
2
- export { addControllerToModule };
1
+ export declare function addControllerToModule(filePath: string, controllerName: string, controllerPath: string): Promise<void>;
@@ -1,2 +1,3 @@
1
1
  declare function addModuleToContainer(name: string, modulePath?: string, path?: string): Promise<void>;
2
- export { addModuleToContainer };
2
+ declare function addModuleToContainerNestedPath(name: string, path?: string): Promise<void>;
3
+ export { addModuleToContainer, addModuleToContainerNestedPath };
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.addModuleToContainer = void 0;
6
+ exports.addModuleToContainerNestedPath = exports.addModuleToContainer = void 0;
7
7
  const chalk_1 = __importDefault(require("chalk"));
8
8
  const glob_1 = require("glob");
9
9
  const node_fs_1 = __importDefault(require("node:fs"));
@@ -67,14 +67,14 @@ async function addModuleToContainer(name, modulePath, path) {
67
67
  const modulePathRegex = /^[^/]=$/;
68
68
  if (!modulePathRegex.test(modulePath)) {
69
69
  if (path.split("/").length > 1) {
70
- newImport = `import { ${moduleName}Module } from "${usecaseDir}${modulePath}/${name}.module";`;
70
+ newImport = `import { ${moduleName}Module } from "${usecaseDir}${name.toLowerCase()}/${name.toLowerCase()}.module";`;
71
71
  }
72
72
  else {
73
- newImport = `import { ${moduleName}Module } from "${usecaseDir}${name}.module";`;
73
+ newImport = `import { ${moduleName}Module } from "${usecaseDir}${name.toLowerCase()}.module";`;
74
74
  }
75
75
  }
76
76
  else {
77
- newImport = `import { ${moduleName}Module } from "${usecaseDir}${name}/${name}.module";`;
77
+ newImport = `import { ${moduleName}Module } from "${usecaseDir}${name}/${name.toLowerCase()}.module";`;
78
78
  }
79
79
  if (containerData.imports.includes(newImport) &&
80
80
  containerData.modules.includes(`${moduleName}Module`)) {
@@ -94,3 +94,36 @@ async function addModuleToContainer(name, modulePath, path) {
94
94
  await node_fs_1.default.promises.writeFile(containerData.path, newFileContent, "utf8");
95
95
  }
96
96
  exports.addModuleToContainer = addModuleToContainer;
97
+ async function addModuleToContainerNestedPath(name, path) {
98
+ const containerData = await validateAppContainer();
99
+ const moduleName = (name[0].toUpperCase() + name.slice(1)).trimStart();
100
+ const { opinionated } = await compiler_1.default.loadConfig();
101
+ let usecaseDir;
102
+ if (opinionated) {
103
+ usecaseDir = `@useCases/`;
104
+ }
105
+ else {
106
+ usecaseDir = `./`;
107
+ }
108
+ if (path.endsWith("/")) {
109
+ path = path.slice(0, -1);
110
+ }
111
+ const newImport = `import { ${moduleName}Module } from "${usecaseDir}${path}.module";`;
112
+ if (containerData.imports.includes(newImport) &&
113
+ containerData.modules.includes(`${moduleName}Module`)) {
114
+ return;
115
+ }
116
+ containerData.imports.push(newImport);
117
+ containerData.modules.push(`${moduleName}Module`);
118
+ const newModule = containerData.modules.join(", ");
119
+ const newModuleDeclaration = `.create([${newModule}]`;
120
+ const newFileContent = [
121
+ ...containerData.imports,
122
+ ...containerData.notImports,
123
+ ]
124
+ .join("\n")
125
+ .replace(containerData.regex, newModuleDeclaration);
126
+ console.log(" ", chalk_1.default.greenBright(`[container]`.padEnd(14)), chalk_1.default.bold.white(`${moduleName}Module added to ${APP_CONTAINER}! ✔️`));
127
+ await node_fs_1.default.promises.writeFile(containerData.path, newFileContent, "utf8");
128
+ }
129
+ exports.addModuleToContainerNestedPath = addModuleToContainerNestedPath;
@@ -1 +1,3 @@
1
1
  export declare function printError(message: string, component: string): void;
2
+ export declare function printGenerateError(schematic: string, file: string): Promise<void>;
3
+ export declare function printGenerateSuccess(schematic: string, file: string): Promise<void>;