@expressots/cli 1.7.1 → 1.8.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 (72) hide show
  1. package/README.md +8 -0
  2. package/bin/@types/config.d.ts +39 -39
  3. package/bin/@types/config.js +2 -2
  4. package/bin/@types/index.d.ts +1 -1
  5. package/bin/@types/index.js +17 -17
  6. package/bin/app.container.d.ts +1 -1
  7. package/bin/app.container.js +8 -8
  8. package/bin/cli.d.ts +2 -2
  9. package/bin/cli.js +38 -38
  10. package/bin/commands/__tests__/project.commands.spec.d.ts +1 -0
  11. package/bin/commands/__tests__/project.commands.spec.js +8 -0
  12. package/bin/commands/project.commands.d.ts +8 -8
  13. package/bin/commands/project.commands.js +137 -136
  14. package/bin/generate/cli.d.ts +4 -4
  15. package/bin/generate/cli.js +66 -66
  16. package/bin/generate/form.d.ts +20 -20
  17. package/bin/generate/form.js +30 -30
  18. package/bin/generate/index.d.ts +1 -1
  19. package/bin/generate/index.js +17 -17
  20. package/bin/generate/utils/command-utils.d.ts +123 -123
  21. package/bin/generate/utils/command-utils.js +314 -310
  22. package/bin/generate/utils/nonopininated-cmd.d.ts +9 -9
  23. package/bin/generate/utils/nonopininated-cmd.js +248 -248
  24. package/bin/generate/utils/opinionated-cmd.d.ts +11 -11
  25. package/bin/generate/utils/opinionated-cmd.js +481 -480
  26. package/bin/help/cli.d.ts +4 -4
  27. package/bin/help/cli.js +15 -15
  28. package/bin/help/form.d.ts +2 -2
  29. package/bin/help/form.js +28 -28
  30. package/bin/help/index.d.ts +1 -1
  31. package/bin/help/index.js +17 -2
  32. package/bin/index.d.ts +6 -4
  33. package/bin/index.js +22 -20
  34. package/bin/info/cli.d.ts +4 -4
  35. package/bin/info/cli.js +15 -15
  36. package/bin/info/form.d.ts +2 -2
  37. package/bin/info/form.js +36 -36
  38. package/bin/info/index.d.ts +1 -1
  39. package/bin/info/index.js +17 -17
  40. package/bin/new/cli.d.ts +4 -4
  41. package/bin/new/cli.js +65 -51
  42. package/bin/new/form.d.ts +2 -2
  43. package/bin/new/form.js +238 -213
  44. package/bin/new/index.d.ts +1 -1
  45. package/bin/new/index.js +17 -17
  46. package/bin/providers/cli.d.ts +4 -4
  47. package/bin/providers/cli.js +43 -38
  48. package/bin/providers/external/external.provider.d.ts +2 -0
  49. package/bin/providers/external/external.provider.js +49 -0
  50. package/bin/providers/index.d.ts +1 -1
  51. package/bin/providers/index.js +17 -17
  52. package/bin/providers/prisma/prisma.provider.d.ts +2 -2
  53. package/bin/providers/prisma/prisma.provider.js +272 -270
  54. package/bin/types.d.ts +1 -1
  55. package/bin/types.js +17 -17
  56. package/bin/utils/add-controller-to-module.d.ts +1 -1
  57. package/bin/utils/add-controller-to-module.js +46 -46
  58. package/bin/utils/add-module-to-container.d.ts +3 -3
  59. package/bin/utils/add-module-to-container.js +129 -129
  60. package/bin/utils/center-text.d.ts +2 -2
  61. package/bin/utils/center-text.js +10 -10
  62. package/bin/utils/cli-ui.d.ts +3 -3
  63. package/bin/utils/cli-ui.js +19 -19
  64. package/bin/utils/compiler.d.ts +15 -15
  65. package/bin/utils/compiler.js +93 -93
  66. package/bin/utils/find-folder.d.ts +5 -5
  67. package/bin/utils/find-folder.js +37 -37
  68. package/bin/utils/index.d.ts +1 -1
  69. package/bin/utils/index.js +17 -17
  70. package/bin/utils/verify-file-exists.d.ts +2 -2
  71. package/bin/utils/verify-file-exists.js +30 -30
  72. package/package.json +35 -31
@@ -1,248 +1,248 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.nonOpinionatedProcess = void 0;
4
- const boost_ts_1 = require("@expressots/boost-ts");
5
- const cli_ui_1 = require("../../utils/cli-ui");
6
- const command_utils_1 = require("./command-utils");
7
- /**
8
- * Process the non-opinionated command
9
- * @param schematic - The schematic
10
- * @param target - The target
11
- * @param method - The method
12
- * @param expressoConfig - The expresso config
13
- */
14
- async function nonOpinionatedProcess(schematic, target, method, expressoConfig) {
15
- let f = await (0, command_utils_1.validateAndPrepareFile)({
16
- schematic,
17
- target,
18
- method,
19
- expressoConfig,
20
- });
21
- switch (schematic) {
22
- case "service":
23
- f = await (0, command_utils_1.validateAndPrepareFile)({
24
- schematic: "controller",
25
- target,
26
- method,
27
- expressoConfig,
28
- });
29
- await generateController(f.outputPath, f.className, f.path, method, f.file, f.schematic);
30
- await (0, cli_ui_1.printGenerateSuccess)(f.schematic, f.file);
31
- f = await (0, command_utils_1.validateAndPrepareFile)({
32
- schematic: "usecase",
33
- target,
34
- method,
35
- expressoConfig,
36
- });
37
- await generateUseCase(f.outputPath, f.className, f.moduleName, f.path, f.fileName, f.schematic, "../templates/nonopinionated/usecase.tpl");
38
- await (0, cli_ui_1.printGenerateSuccess)(f.schematic, f.file);
39
- f = await (0, command_utils_1.validateAndPrepareFile)({
40
- schematic: "dto",
41
- target,
42
- method,
43
- expressoConfig,
44
- });
45
- await generateDTO(f.outputPath, f.className, f.moduleName, f.path, f.schematic);
46
- await (0, cli_ui_1.printGenerateSuccess)(f.schematic, f.file);
47
- f = await (0, command_utils_1.validateAndPrepareFile)({
48
- schematic: "module",
49
- target,
50
- method,
51
- expressoConfig,
52
- });
53
- await generateModule(f.outputPath, f.className, f.moduleName, f.path, f.schematic);
54
- await (0, cli_ui_1.printGenerateSuccess)(f.schematic, f.file);
55
- break;
56
- case "usecase":
57
- await generateUseCase(f.outputPath, f.className, f.moduleName, f.path, f.fileName, f.schematic);
58
- await (0, cli_ui_1.printGenerateSuccess)(f.schematic, f.file);
59
- break;
60
- case "controller":
61
- await generateController(f.outputPath, f.className, f.path, method, f.file, f.schematic);
62
- await (0, cli_ui_1.printGenerateSuccess)(f.schematic, f.file);
63
- break;
64
- case "dto":
65
- await generateDTO(f.outputPath, f.className, f.moduleName, f.path, f.schematic);
66
- await (0, cli_ui_1.printGenerateSuccess)(f.schematic, f.file);
67
- break;
68
- case "provider":
69
- await generateProvider(f.outputPath, f.className, f.moduleName, f.path, f.schematic);
70
- await (0, cli_ui_1.printGenerateSuccess)(f.schematic, f.file);
71
- break;
72
- case "entity":
73
- await generateEntity(f.outputPath, f.className, f.moduleName, f.path, f.schematic);
74
- await (0, cli_ui_1.printGenerateSuccess)(f.schematic, f.file);
75
- break;
76
- case "middleware":
77
- await generateMiddleware(f.outputPath, f.className, f.moduleName, f.path, f.schematic);
78
- await (0, cli_ui_1.printGenerateSuccess)(f.schematic, f.file);
79
- break;
80
- case "module":
81
- await generateModule(f.outputPath, f.className, f.moduleName, f.path, f.schematic);
82
- await (0, cli_ui_1.printGenerateSuccess)(f.schematic, f.file);
83
- break;
84
- }
85
- return f.file;
86
- }
87
- exports.nonOpinionatedProcess = nonOpinionatedProcess;
88
- /* Generate Resource */
89
- /**
90
- * Generate a use case
91
- * @param outputPath - The output path
92
- * @param className - The class name
93
- * @param moduleName - The module name
94
- * @param path - The path
95
- * @param template - The template
96
- */
97
- async function generateUseCase(outputPath, className, moduleName, path, fileName, schematic, template) {
98
- (0, command_utils_1.writeTemplate)({
99
- outputPath,
100
- template: {
101
- path: template
102
- ? template
103
- : "../templates/nonopinionated/usecase.tpl",
104
- data: {
105
- className,
106
- moduleName,
107
- path,
108
- fileName,
109
- schematic: (0, boost_ts_1.anyCaseToPascalCase)(schematic),
110
- },
111
- },
112
- });
113
- }
114
- /**
115
- * Generate a controller
116
- * @param outputPath - The output path
117
- * @param className - The class name
118
- * @param path - The path
119
- * @param method - The method
120
- * @param file - The file
121
- */
122
- async function generateController(outputPath, className, path, method, file, schematic) {
123
- const templateBasedMethod = "../templates/nonopinionated/controller.tpl";
124
- (0, command_utils_1.writeTemplate)({
125
- outputPath,
126
- template: {
127
- path: templateBasedMethod,
128
- data: {
129
- className,
130
- fileName: (0, command_utils_1.getFileNameWithoutExtension)(file),
131
- useCase: (0, boost_ts_1.anyCaseToCamelCase)(className),
132
- route: className
133
- ? className.toLowerCase()
134
- : path.replace(/\/$/, ""),
135
- construct: (0, boost_ts_1.anyCaseToKebabCase)(className),
136
- method: (0, command_utils_1.getHttpMethod)(method),
137
- schematic: (0, boost_ts_1.anyCaseToPascalCase)(schematic),
138
- },
139
- },
140
- });
141
- }
142
- /**
143
- * Generate a DTO
144
- * @param outputPath - The output path
145
- * @param className - The class name
146
- * @param moduleName - The module name
147
- * @param path - The path
148
- */
149
- async function generateDTO(outputPath, className, moduleName, path, schematic) {
150
- (0, command_utils_1.writeTemplate)({
151
- outputPath,
152
- template: {
153
- path: "../templates/nonopinionated/dto.tpl",
154
- data: {
155
- className,
156
- moduleName,
157
- path,
158
- schematic: (0, boost_ts_1.anyCaseToPascalCase)(schematic),
159
- },
160
- },
161
- });
162
- }
163
- /**
164
- * Generate a provider
165
- * @param outputPath - The output path
166
- * @param className - The class name
167
- * @param moduleName - The module name
168
- * @param path - The path
169
- */
170
- async function generateProvider(outputPath, className, moduleName, path, schematic) {
171
- (0, command_utils_1.writeTemplate)({
172
- outputPath,
173
- template: {
174
- path: "../templates/nonopinionated/provider.tpl",
175
- data: {
176
- className,
177
- moduleName,
178
- path,
179
- schematic: (0, boost_ts_1.anyCaseToPascalCase)(schematic),
180
- },
181
- },
182
- });
183
- }
184
- /**
185
- * Generate an entity
186
- * @param outputPath - The output path
187
- * @param className - The class name
188
- * @param moduleName - The module name
189
- * @param path - The path
190
- */
191
- async function generateEntity(outputPath, className, moduleName, path, schematic) {
192
- (0, command_utils_1.writeTemplate)({
193
- outputPath,
194
- template: {
195
- path: "../templates/nonopinionated/entity.tpl",
196
- data: {
197
- className,
198
- moduleName,
199
- path,
200
- schematic: (0, boost_ts_1.anyCaseToPascalCase)(schematic),
201
- },
202
- },
203
- });
204
- }
205
- /**
206
- * Generate a middleware
207
- * @param outputPath - The output path
208
- * @param className - The class name
209
- * @param moduleName - The module name
210
- * @param path - The path
211
- */
212
- async function generateMiddleware(outputPath, className, moduleName, path, schematic) {
213
- (0, command_utils_1.writeTemplate)({
214
- outputPath,
215
- template: {
216
- path: "../templates/nonopinionated/middleware.tpl",
217
- data: {
218
- className,
219
- moduleName,
220
- path,
221
- schematic: (0, boost_ts_1.anyCaseToPascalCase)(schematic),
222
- },
223
- },
224
- });
225
- }
226
- /**
227
- * Generate a module
228
- * @param outputPath - The output path
229
- * @param className - The class name
230
- * @param moduleName - The module name
231
- * @param path - The path
232
- */
233
- async function generateModule(outputPath, className, moduleName, path, schematic) {
234
- (0, command_utils_1.writeTemplate)({
235
- outputPath,
236
- template: {
237
- path: "../templates/nonopinionated/module.tpl",
238
- data: {
239
- className,
240
- moduleName: className
241
- ? (0, boost_ts_1.anyCaseToPascalCase)(className)
242
- : (0, boost_ts_1.anyCaseToPascalCase)(moduleName),
243
- path,
244
- schematic: (0, boost_ts_1.anyCaseToPascalCase)(schematic),
245
- },
246
- },
247
- });
248
- }
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.nonOpinionatedProcess = void 0;
4
+ const boost_ts_1 = require("@expressots/boost-ts");
5
+ const cli_ui_1 = require("../../utils/cli-ui");
6
+ const command_utils_1 = require("./command-utils");
7
+ /**
8
+ * Process the non-opinionated command
9
+ * @param schematic - The schematic
10
+ * @param target - The target
11
+ * @param method - The method
12
+ * @param expressoConfig - The expresso config
13
+ */
14
+ async function nonOpinionatedProcess(schematic, target, method, expressoConfig) {
15
+ let f = await (0, command_utils_1.validateAndPrepareFile)({
16
+ schematic,
17
+ target,
18
+ method,
19
+ expressoConfig,
20
+ });
21
+ switch (schematic) {
22
+ case "service":
23
+ f = await (0, command_utils_1.validateAndPrepareFile)({
24
+ schematic: "controller",
25
+ target,
26
+ method,
27
+ expressoConfig,
28
+ });
29
+ await generateController(f.outputPath, f.className, f.path, method, f.file, f.schematic);
30
+ await (0, cli_ui_1.printGenerateSuccess)(f.schematic, f.file);
31
+ f = await (0, command_utils_1.validateAndPrepareFile)({
32
+ schematic: "usecase",
33
+ target,
34
+ method,
35
+ expressoConfig,
36
+ });
37
+ await generateUseCase(f.outputPath, f.className, f.moduleName, f.path, f.fileName, f.schematic, "../templates/nonopinionated/usecase.tpl");
38
+ await (0, cli_ui_1.printGenerateSuccess)(f.schematic, f.file);
39
+ f = await (0, command_utils_1.validateAndPrepareFile)({
40
+ schematic: "dto",
41
+ target,
42
+ method,
43
+ expressoConfig,
44
+ });
45
+ await generateDTO(f.outputPath, f.className, f.moduleName, f.path, f.schematic);
46
+ await (0, cli_ui_1.printGenerateSuccess)(f.schematic, f.file);
47
+ f = await (0, command_utils_1.validateAndPrepareFile)({
48
+ schematic: "module",
49
+ target,
50
+ method,
51
+ expressoConfig,
52
+ });
53
+ await generateModule(f.outputPath, f.className, f.moduleName, f.path, f.schematic);
54
+ await (0, cli_ui_1.printGenerateSuccess)(f.schematic, f.file);
55
+ break;
56
+ case "usecase":
57
+ await generateUseCase(f.outputPath, f.className, f.moduleName, f.path, f.fileName, f.schematic);
58
+ await (0, cli_ui_1.printGenerateSuccess)(f.schematic, f.file);
59
+ break;
60
+ case "controller":
61
+ await generateController(f.outputPath, f.className, f.path, method, f.file, f.schematic);
62
+ await (0, cli_ui_1.printGenerateSuccess)(f.schematic, f.file);
63
+ break;
64
+ case "dto":
65
+ await generateDTO(f.outputPath, f.className, f.moduleName, f.path, f.schematic);
66
+ await (0, cli_ui_1.printGenerateSuccess)(f.schematic, f.file);
67
+ break;
68
+ case "provider":
69
+ await generateProvider(f.outputPath, f.className, f.moduleName, f.path, f.schematic);
70
+ await (0, cli_ui_1.printGenerateSuccess)(f.schematic, f.file);
71
+ break;
72
+ case "entity":
73
+ await generateEntity(f.outputPath, f.className, f.moduleName, f.path, f.schematic);
74
+ await (0, cli_ui_1.printGenerateSuccess)(f.schematic, f.file);
75
+ break;
76
+ case "middleware":
77
+ await generateMiddleware(f.outputPath, f.className, f.moduleName, f.path, f.schematic);
78
+ await (0, cli_ui_1.printGenerateSuccess)(f.schematic, f.file);
79
+ break;
80
+ case "module":
81
+ await generateModule(f.outputPath, f.className, f.moduleName, f.path, f.schematic);
82
+ await (0, cli_ui_1.printGenerateSuccess)(f.schematic, f.file);
83
+ break;
84
+ }
85
+ return f.file;
86
+ }
87
+ exports.nonOpinionatedProcess = nonOpinionatedProcess;
88
+ /* Generate Resource */
89
+ /**
90
+ * Generate a use case
91
+ * @param outputPath - The output path
92
+ * @param className - The class name
93
+ * @param moduleName - The module name
94
+ * @param path - The path
95
+ * @param template - The template
96
+ */
97
+ async function generateUseCase(outputPath, className, moduleName, path, fileName, schematic, template) {
98
+ (0, command_utils_1.writeTemplate)({
99
+ outputPath,
100
+ template: {
101
+ path: template
102
+ ? template
103
+ : "../templates/nonopinionated/usecase.tpl",
104
+ data: {
105
+ className,
106
+ moduleName,
107
+ path,
108
+ fileName,
109
+ schematic: (0, boost_ts_1.anyCaseToPascalCase)(schematic),
110
+ },
111
+ },
112
+ });
113
+ }
114
+ /**
115
+ * Generate a controller
116
+ * @param outputPath - The output path
117
+ * @param className - The class name
118
+ * @param path - The path
119
+ * @param method - The method
120
+ * @param file - The file
121
+ */
122
+ async function generateController(outputPath, className, path, method, file, schematic) {
123
+ const templateBasedMethod = "../templates/nonopinionated/controller.tpl";
124
+ (0, command_utils_1.writeTemplate)({
125
+ outputPath,
126
+ template: {
127
+ path: templateBasedMethod,
128
+ data: {
129
+ className,
130
+ fileName: (0, command_utils_1.getFileNameWithoutExtension)(file),
131
+ useCase: (0, boost_ts_1.anyCaseToCamelCase)(className),
132
+ route: className
133
+ ? className.toLowerCase()
134
+ : path.replace(/\/$/, ""),
135
+ construct: (0, boost_ts_1.anyCaseToKebabCase)(className),
136
+ method: (0, command_utils_1.getHttpMethod)(method),
137
+ schematic: (0, boost_ts_1.anyCaseToPascalCase)(schematic),
138
+ },
139
+ },
140
+ });
141
+ }
142
+ /**
143
+ * Generate a DTO
144
+ * @param outputPath - The output path
145
+ * @param className - The class name
146
+ * @param moduleName - The module name
147
+ * @param path - The path
148
+ */
149
+ async function generateDTO(outputPath, className, moduleName, path, schematic) {
150
+ (0, command_utils_1.writeTemplate)({
151
+ outputPath,
152
+ template: {
153
+ path: "../templates/nonopinionated/dto.tpl",
154
+ data: {
155
+ className,
156
+ moduleName,
157
+ path,
158
+ schematic: (0, boost_ts_1.anyCaseToPascalCase)(schematic),
159
+ },
160
+ },
161
+ });
162
+ }
163
+ /**
164
+ * Generate a provider
165
+ * @param outputPath - The output path
166
+ * @param className - The class name
167
+ * @param moduleName - The module name
168
+ * @param path - The path
169
+ */
170
+ async function generateProvider(outputPath, className, moduleName, path, schematic) {
171
+ (0, command_utils_1.writeTemplate)({
172
+ outputPath,
173
+ template: {
174
+ path: "../templates/nonopinionated/provider.tpl",
175
+ data: {
176
+ className,
177
+ moduleName,
178
+ path,
179
+ schematic: (0, boost_ts_1.anyCaseToPascalCase)(schematic),
180
+ },
181
+ },
182
+ });
183
+ }
184
+ /**
185
+ * Generate an entity
186
+ * @param outputPath - The output path
187
+ * @param className - The class name
188
+ * @param moduleName - The module name
189
+ * @param path - The path
190
+ */
191
+ async function generateEntity(outputPath, className, moduleName, path, schematic) {
192
+ (0, command_utils_1.writeTemplate)({
193
+ outputPath,
194
+ template: {
195
+ path: "../templates/nonopinionated/entity.tpl",
196
+ data: {
197
+ className,
198
+ moduleName,
199
+ path,
200
+ schematic: (0, boost_ts_1.anyCaseToPascalCase)(schematic),
201
+ },
202
+ },
203
+ });
204
+ }
205
+ /**
206
+ * Generate a middleware
207
+ * @param outputPath - The output path
208
+ * @param className - The class name
209
+ * @param moduleName - The module name
210
+ * @param path - The path
211
+ */
212
+ async function generateMiddleware(outputPath, className, moduleName, path, schematic) {
213
+ (0, command_utils_1.writeTemplate)({
214
+ outputPath,
215
+ template: {
216
+ path: "../templates/nonopinionated/middleware.tpl",
217
+ data: {
218
+ className,
219
+ moduleName,
220
+ path,
221
+ schematic: (0, boost_ts_1.anyCaseToPascalCase)(schematic),
222
+ },
223
+ },
224
+ });
225
+ }
226
+ /**
227
+ * Generate a module
228
+ * @param outputPath - The output path
229
+ * @param className - The class name
230
+ * @param moduleName - The module name
231
+ * @param path - The path
232
+ */
233
+ async function generateModule(outputPath, className, moduleName, path, schematic) {
234
+ (0, command_utils_1.writeTemplate)({
235
+ outputPath,
236
+ template: {
237
+ path: "../templates/nonopinionated/module.tpl",
238
+ data: {
239
+ className,
240
+ moduleName: className
241
+ ? (0, boost_ts_1.anyCaseToPascalCase)(className)
242
+ : (0, boost_ts_1.anyCaseToPascalCase)(moduleName),
243
+ path,
244
+ schematic: (0, boost_ts_1.anyCaseToPascalCase)(schematic),
245
+ },
246
+ },
247
+ });
248
+ }
@@ -1,11 +1,11 @@
1
- import { ExpressoConfig } from "../../@types";
2
- /**
3
- * Process commands for opinionated service scaffolding
4
- * @param schematic - Resource to scaffold
5
- * @param target - Target path
6
- * @param method - HTTP method
7
- * @param expressoConfig - Expresso configuration [expressots.config.ts]
8
- * @param pathStyle - Path command style [sugar, nested, single]
9
- * @returns
10
- */
11
- export declare function opinionatedProcess(schematic: string, target: string, method: string, expressoConfig: ExpressoConfig, pathStyle: string): Promise<string>;
1
+ import { ExpressoConfig } from "../../@types";
2
+ /**
3
+ * Process commands for opinionated service scaffolding
4
+ * @param schematic - Resource to scaffold
5
+ * @param target - Target path
6
+ * @param method - HTTP method
7
+ * @param expressoConfig - Expresso configuration [expressots.config.ts]
8
+ * @param pathStyle - Path command style [sugar, nested, single]
9
+ * @returns
10
+ */
11
+ export declare function opinionatedProcess(schematic: string, target: string, method: string, expressoConfig: ExpressoConfig, pathStyle: string): Promise<string>;