@expressots/cli 1.7.1 → 1.8.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 +8 -0
- package/bin/@types/config.d.ts +39 -39
- package/bin/@types/config.js +2 -2
- package/bin/@types/index.d.ts +1 -1
- package/bin/@types/index.js +17 -17
- package/bin/app.container.d.ts +1 -1
- package/bin/app.container.js +8 -8
- package/bin/cli.d.ts +2 -2
- package/bin/cli.js +38 -38
- package/bin/commands/__tests__/project.commands.spec.d.ts +1 -0
- package/bin/commands/__tests__/project.commands.spec.js +8 -0
- package/bin/commands/project.commands.d.ts +8 -8
- package/bin/commands/project.commands.js +137 -136
- package/bin/generate/cli.d.ts +4 -4
- package/bin/generate/cli.js +66 -66
- package/bin/generate/form.d.ts +20 -20
- package/bin/generate/form.js +30 -30
- package/bin/generate/index.d.ts +1 -1
- package/bin/generate/index.js +17 -17
- package/bin/generate/utils/command-utils.d.ts +123 -123
- package/bin/generate/utils/command-utils.js +314 -310
- package/bin/generate/utils/nonopininated-cmd.d.ts +9 -9
- package/bin/generate/utils/nonopininated-cmd.js +248 -248
- package/bin/generate/utils/opinionated-cmd.d.ts +11 -11
- package/bin/generate/utils/opinionated-cmd.js +481 -480
- package/bin/help/cli.d.ts +4 -4
- package/bin/help/cli.js +15 -15
- package/bin/help/form.d.ts +2 -2
- package/bin/help/form.js +28 -28
- package/bin/help/index.d.ts +1 -1
- package/bin/help/index.js +17 -2
- package/bin/index.d.ts +6 -4
- package/bin/index.js +22 -20
- package/bin/info/cli.d.ts +4 -4
- package/bin/info/cli.js +15 -15
- package/bin/info/form.d.ts +2 -2
- package/bin/info/form.js +36 -36
- package/bin/info/index.d.ts +1 -1
- package/bin/info/index.js +17 -17
- package/bin/new/cli.d.ts +4 -4
- package/bin/new/cli.js +51 -51
- package/bin/new/form.d.ts +2 -2
- package/bin/new/form.js +235 -213
- package/bin/new/index.d.ts +1 -1
- package/bin/new/index.js +17 -17
- package/bin/providers/cli.d.ts +4 -4
- package/bin/providers/cli.js +43 -38
- package/bin/providers/external/external.provider.d.ts +2 -0
- package/bin/providers/external/external.provider.js +49 -0
- package/bin/providers/index.d.ts +1 -1
- package/bin/providers/index.js +17 -17
- package/bin/providers/prisma/prisma.provider.d.ts +2 -2
- package/bin/providers/prisma/prisma.provider.js +272 -270
- package/bin/types.d.ts +1 -1
- package/bin/types.js +17 -17
- package/bin/utils/add-controller-to-module.d.ts +1 -1
- package/bin/utils/add-controller-to-module.js +46 -46
- package/bin/utils/add-module-to-container.d.ts +3 -3
- package/bin/utils/add-module-to-container.js +129 -129
- package/bin/utils/center-text.d.ts +2 -2
- package/bin/utils/center-text.js +10 -10
- package/bin/utils/cli-ui.d.ts +3 -3
- package/bin/utils/cli-ui.js +19 -19
- package/bin/utils/compiler.d.ts +15 -15
- package/bin/utils/compiler.js +93 -93
- package/bin/utils/find-folder.d.ts +5 -5
- package/bin/utils/find-folder.js +37 -37
- package/bin/utils/index.d.ts +1 -1
- package/bin/utils/index.js +17 -17
- package/bin/utils/verify-file-exists.d.ts +2 -2
- package/bin/utils/verify-file-exists.js +30 -30
- package/package.json +31 -28
|
@@ -1,480 +1,481 @@
|
|
|
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
|
-
|
|
91
|
-
|
|
92
|
-
await (
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
await (
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
await (
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
await (
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
await (
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
await (
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
await (
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
*
|
|
126
|
-
* @param
|
|
127
|
-
* @param
|
|
128
|
-
* @param
|
|
129
|
-
* @param
|
|
130
|
-
* @param
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
*
|
|
174
|
-
* @param
|
|
175
|
-
* @param
|
|
176
|
-
* @param
|
|
177
|
-
* @param
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
*
|
|
218
|
-
* @param
|
|
219
|
-
* @param
|
|
220
|
-
* @param
|
|
221
|
-
* @param
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
*
|
|
240
|
-
* @param
|
|
241
|
-
* @param
|
|
242
|
-
* @param
|
|
243
|
-
* @param
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
*
|
|
265
|
-
* @param
|
|
266
|
-
* @param
|
|
267
|
-
* @param
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
*
|
|
285
|
-
* @param
|
|
286
|
-
* @param
|
|
287
|
-
* @param
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
*
|
|
305
|
-
* @param
|
|
306
|
-
* @param
|
|
307
|
-
* @param
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
*
|
|
325
|
-
* @param
|
|
326
|
-
* @param
|
|
327
|
-
* @param
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
*
|
|
345
|
-
* @param
|
|
346
|
-
* @param
|
|
347
|
-
* @param
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
const
|
|
352
|
-
|
|
353
|
-
.
|
|
354
|
-
|
|
355
|
-
const
|
|
356
|
-
const
|
|
357
|
-
|
|
358
|
-
.
|
|
359
|
-
.
|
|
360
|
-
.replace(
|
|
361
|
-
.replace(
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
.
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
*
|
|
385
|
-
* @param
|
|
386
|
-
* @param
|
|
387
|
-
* @param
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
const
|
|
392
|
-
const
|
|
393
|
-
const
|
|
394
|
-
const
|
|
395
|
-
|
|
396
|
-
.
|
|
397
|
-
.
|
|
398
|
-
.replace(
|
|
399
|
-
.replace(
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
.
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
*
|
|
423
|
-
* @param
|
|
424
|
-
* @param
|
|
425
|
-
* @param
|
|
426
|
-
* @
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
const
|
|
431
|
-
|
|
432
|
-
.
|
|
433
|
-
|
|
434
|
-
const
|
|
435
|
-
const
|
|
436
|
-
|
|
437
|
-
.
|
|
438
|
-
.
|
|
439
|
-
.replace(
|
|
440
|
-
.replace(
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
.
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
*
|
|
464
|
-
* @param
|
|
465
|
-
* @param
|
|
466
|
-
* @param
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
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
|
+
}
|
|
91
|
+
case "usecase":
|
|
92
|
+
await generateUseCase(f.outputPath, f.className, f.moduleName, f.path, f.fileName);
|
|
93
|
+
await (0, cli_ui_1.printGenerateSuccess)(schematic, f.file);
|
|
94
|
+
break;
|
|
95
|
+
case "controller":
|
|
96
|
+
await generateController(f.outputPath, f.className, f.path, method, f.file);
|
|
97
|
+
await (0, cli_ui_1.printGenerateSuccess)(schematic, f.file);
|
|
98
|
+
break;
|
|
99
|
+
case "dto":
|
|
100
|
+
await generateDTO(f.outputPath, f.className, f.moduleName, f.path);
|
|
101
|
+
await (0, cli_ui_1.printGenerateSuccess)(schematic, f.file);
|
|
102
|
+
break;
|
|
103
|
+
case "provider":
|
|
104
|
+
await generateProvider(f.outputPath, f.className, f.moduleName, f.path);
|
|
105
|
+
await (0, cli_ui_1.printGenerateSuccess)(schematic, f.file);
|
|
106
|
+
break;
|
|
107
|
+
case "entity":
|
|
108
|
+
await generateEntity(f.outputPath, f.className, f.moduleName, f.path);
|
|
109
|
+
await (0, cli_ui_1.printGenerateSuccess)(schematic, f.file);
|
|
110
|
+
break;
|
|
111
|
+
case "middleware":
|
|
112
|
+
await generateMiddleware(f.outputPath, f.className, f.moduleName, f.path);
|
|
113
|
+
await (0, cli_ui_1.printGenerateSuccess)(schematic, f.file);
|
|
114
|
+
break;
|
|
115
|
+
case "module":
|
|
116
|
+
await generateModule(f.outputPath, f.className, f.moduleName, f.path);
|
|
117
|
+
await (0, cli_ui_1.printGenerateSuccess)(schematic, f.file);
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
return f.file;
|
|
121
|
+
}
|
|
122
|
+
exports.opinionatedProcess = opinionatedProcess;
|
|
123
|
+
/* Generate Resource */
|
|
124
|
+
/**
|
|
125
|
+
* Generate a controller service
|
|
126
|
+
* @param outputPath - The output path
|
|
127
|
+
* @param className - The class name
|
|
128
|
+
* @param moduleName - The module name
|
|
129
|
+
* @param path - The path
|
|
130
|
+
* @param method - The method
|
|
131
|
+
* @param file - The file
|
|
132
|
+
*/
|
|
133
|
+
async function generateControllerService(outputPath, className, path, method, file) {
|
|
134
|
+
let templateBasedMethod = "";
|
|
135
|
+
switch (method) {
|
|
136
|
+
case "put":
|
|
137
|
+
templateBasedMethod =
|
|
138
|
+
"../templates/opinionated/controller-service-put.tpl";
|
|
139
|
+
break;
|
|
140
|
+
case "patch":
|
|
141
|
+
templateBasedMethod =
|
|
142
|
+
"../templates/opinionated/controller-service-patch.tpl";
|
|
143
|
+
break;
|
|
144
|
+
case "post":
|
|
145
|
+
templateBasedMethod =
|
|
146
|
+
"../templates/opinionated/controller-service-post.tpl";
|
|
147
|
+
break;
|
|
148
|
+
case "delete":
|
|
149
|
+
templateBasedMethod =
|
|
150
|
+
"../templates/opinionated/controller-service-delete.tpl";
|
|
151
|
+
break;
|
|
152
|
+
default:
|
|
153
|
+
templateBasedMethod =
|
|
154
|
+
"../templates/opinionated/controller-service-get.tpl";
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
(0, command_utils_1.writeTemplate)({
|
|
158
|
+
outputPath,
|
|
159
|
+
template: {
|
|
160
|
+
path: templateBasedMethod,
|
|
161
|
+
data: {
|
|
162
|
+
className,
|
|
163
|
+
fileName: (0, command_utils_1.getFileNameWithoutExtension)(file),
|
|
164
|
+
useCase: (0, boost_ts_1.anyCaseToCamelCase)(className),
|
|
165
|
+
route: path.replace(/\/$/, ""),
|
|
166
|
+
construct: (0, boost_ts_1.anyCaseToKebabCase)(className),
|
|
167
|
+
method: (0, command_utils_1.getHttpMethod)(method),
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Generate a use case
|
|
174
|
+
* @param outputPath - The output path
|
|
175
|
+
* @param className - The class name
|
|
176
|
+
* @param moduleName - The module name
|
|
177
|
+
* @param path - The path
|
|
178
|
+
* @param template - The template
|
|
179
|
+
*/
|
|
180
|
+
async function generateUseCaseService(outputPath, className, method, moduleName, path, fileName) {
|
|
181
|
+
let templateBasedMethod = "";
|
|
182
|
+
switch (method) {
|
|
183
|
+
case "put":
|
|
184
|
+
templateBasedMethod =
|
|
185
|
+
"../templates/opinionated/usecase-service.tpl";
|
|
186
|
+
break;
|
|
187
|
+
case "patch":
|
|
188
|
+
templateBasedMethod =
|
|
189
|
+
"../templates/opinionated/usecase-service.tpl";
|
|
190
|
+
break;
|
|
191
|
+
case "post":
|
|
192
|
+
templateBasedMethod =
|
|
193
|
+
"../templates/opinionated/usecase-service.tpl";
|
|
194
|
+
break;
|
|
195
|
+
case "delete":
|
|
196
|
+
templateBasedMethod =
|
|
197
|
+
"../templates/opinionated/usecase-service-delete.tpl";
|
|
198
|
+
break;
|
|
199
|
+
default:
|
|
200
|
+
templateBasedMethod = "../templates/opinionated/usecase.tpl";
|
|
201
|
+
break;
|
|
202
|
+
}
|
|
203
|
+
(0, command_utils_1.writeTemplate)({
|
|
204
|
+
outputPath,
|
|
205
|
+
template: {
|
|
206
|
+
path: templateBasedMethod,
|
|
207
|
+
data: {
|
|
208
|
+
className,
|
|
209
|
+
moduleName,
|
|
210
|
+
path,
|
|
211
|
+
fileName,
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Generate a use case
|
|
218
|
+
* @param outputPath - The output path
|
|
219
|
+
* @param className - The class name
|
|
220
|
+
* @param moduleName - The module name
|
|
221
|
+
* @param path - The path
|
|
222
|
+
* @param fileName - The file name
|
|
223
|
+
*/
|
|
224
|
+
async function generateUseCase(outputPath, className, moduleName, path, fileName) {
|
|
225
|
+
(0, command_utils_1.writeTemplate)({
|
|
226
|
+
outputPath,
|
|
227
|
+
template: {
|
|
228
|
+
path: "../templates/opinionated/usecase.tpl",
|
|
229
|
+
data: {
|
|
230
|
+
className,
|
|
231
|
+
moduleName,
|
|
232
|
+
path,
|
|
233
|
+
fileName,
|
|
234
|
+
},
|
|
235
|
+
},
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Generate a controller
|
|
240
|
+
* @param outputPath - The output path
|
|
241
|
+
* @param className - The class name
|
|
242
|
+
* @param path - The path
|
|
243
|
+
* @param method - The method
|
|
244
|
+
* @param file - The file
|
|
245
|
+
*/
|
|
246
|
+
async function generateController(outputPath, className, path, method, file) {
|
|
247
|
+
const templateBasedMethod = "../templates/opinionated/controller-service.tpl";
|
|
248
|
+
(0, command_utils_1.writeTemplate)({
|
|
249
|
+
outputPath,
|
|
250
|
+
template: {
|
|
251
|
+
path: templateBasedMethod,
|
|
252
|
+
data: {
|
|
253
|
+
className,
|
|
254
|
+
fileName: (0, command_utils_1.getFileNameWithoutExtension)(file),
|
|
255
|
+
useCase: (0, boost_ts_1.anyCaseToCamelCase)(className),
|
|
256
|
+
route: path.replace(/\/$/, ""),
|
|
257
|
+
construct: (0, boost_ts_1.anyCaseToKebabCase)(className),
|
|
258
|
+
method: (0, command_utils_1.getHttpMethod)(method),
|
|
259
|
+
},
|
|
260
|
+
},
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Generate a DTO
|
|
265
|
+
* @param outputPath - The output path
|
|
266
|
+
* @param className - The class name
|
|
267
|
+
* @param moduleName - The module name
|
|
268
|
+
* @param path - The path
|
|
269
|
+
*/
|
|
270
|
+
async function generateDTO(outputPath, className, moduleName, path) {
|
|
271
|
+
(0, command_utils_1.writeTemplate)({
|
|
272
|
+
outputPath,
|
|
273
|
+
template: {
|
|
274
|
+
path: "../templates/opinionated/dto.tpl",
|
|
275
|
+
data: {
|
|
276
|
+
className,
|
|
277
|
+
moduleName,
|
|
278
|
+
path,
|
|
279
|
+
},
|
|
280
|
+
},
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Generate a provider
|
|
285
|
+
* @param outputPath - The output path
|
|
286
|
+
* @param className - The class name
|
|
287
|
+
* @param moduleName - The module name
|
|
288
|
+
* @param path - The path
|
|
289
|
+
*/
|
|
290
|
+
async function generateProvider(outputPath, className, moduleName, path) {
|
|
291
|
+
(0, command_utils_1.writeTemplate)({
|
|
292
|
+
outputPath,
|
|
293
|
+
template: {
|
|
294
|
+
path: "../templates/opinionated/provider.tpl",
|
|
295
|
+
data: {
|
|
296
|
+
className,
|
|
297
|
+
moduleName,
|
|
298
|
+
path,
|
|
299
|
+
},
|
|
300
|
+
},
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Generate an entity
|
|
305
|
+
* @param outputPath - The output path
|
|
306
|
+
* @param className - The class name
|
|
307
|
+
* @param moduleName - The module name
|
|
308
|
+
* @param path - The path
|
|
309
|
+
*/
|
|
310
|
+
async function generateEntity(outputPath, className, moduleName, path) {
|
|
311
|
+
(0, command_utils_1.writeTemplate)({
|
|
312
|
+
outputPath,
|
|
313
|
+
template: {
|
|
314
|
+
path: "../templates/opinionated/entity.tpl",
|
|
315
|
+
data: {
|
|
316
|
+
className,
|
|
317
|
+
moduleName,
|
|
318
|
+
path,
|
|
319
|
+
},
|
|
320
|
+
},
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Generate a middleware
|
|
325
|
+
* @param outputPath - The output path
|
|
326
|
+
* @param className - The class name
|
|
327
|
+
* @param moduleName - The module name
|
|
328
|
+
* @param path - The path
|
|
329
|
+
*/
|
|
330
|
+
async function generateMiddleware(outputPath, className, moduleName, path) {
|
|
331
|
+
(0, command_utils_1.writeTemplate)({
|
|
332
|
+
outputPath,
|
|
333
|
+
template: {
|
|
334
|
+
path: "../templates/opinionated/middleware.tpl",
|
|
335
|
+
data: {
|
|
336
|
+
className,
|
|
337
|
+
moduleName,
|
|
338
|
+
path,
|
|
339
|
+
},
|
|
340
|
+
},
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Generate a module for service scaffolding with sugar path
|
|
345
|
+
* @param outputPath - The output path
|
|
346
|
+
* @param className - The class name
|
|
347
|
+
* @param moduleName - The module name
|
|
348
|
+
* @param path - The path
|
|
349
|
+
*/
|
|
350
|
+
async function generateModuleServiceSugarPath(outputPathController, className, moduleName, path, file, folderToScaffold) {
|
|
351
|
+
const newModuleFile = await (0, command_utils_1.extractFirstWord)(file);
|
|
352
|
+
const newModulePath = nodePath
|
|
353
|
+
.join(folderToScaffold, path, "..")
|
|
354
|
+
.normalize();
|
|
355
|
+
const newModuleName = `${newModuleFile}.module.ts`;
|
|
356
|
+
const newModuleOutputPath = `${newModulePath}/${newModuleName}`.replace("\\", "/");
|
|
357
|
+
const controllerToModule = nodePath
|
|
358
|
+
.relative(newModuleOutputPath, outputPathController)
|
|
359
|
+
.normalize()
|
|
360
|
+
.replace(/\.ts$/, "")
|
|
361
|
+
.replace(/\\/g, "/")
|
|
362
|
+
.replace(/\.\./g, ".");
|
|
363
|
+
const controllerFullPath = nodePath
|
|
364
|
+
.join(folderToScaffold, path, "..", newModuleName)
|
|
365
|
+
.normalize();
|
|
366
|
+
if (fs_1.default.existsSync(newModuleOutputPath)) {
|
|
367
|
+
await (0, add_controller_to_module_1.addControllerToModule)(controllerFullPath, `${className}Controller`, controllerToModule);
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
(0, command_utils_1.writeTemplate)({
|
|
371
|
+
outputPath: newModuleOutputPath,
|
|
372
|
+
template: {
|
|
373
|
+
path: "../templates/opinionated/module-service.tpl",
|
|
374
|
+
data: {
|
|
375
|
+
className,
|
|
376
|
+
moduleName: (0, boost_ts_1.anyCaseToPascalCase)(moduleName),
|
|
377
|
+
path: controllerToModule,
|
|
378
|
+
},
|
|
379
|
+
},
|
|
380
|
+
});
|
|
381
|
+
await (0, add_module_to_container_1.addModuleToContainer)((0, boost_ts_1.anyCaseToPascalCase)(moduleName), `${moduleName}/${file.replace(".ts", "")}`, path);
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Generate a module for service scaffolding with single path
|
|
385
|
+
* @param outputPath - The output path
|
|
386
|
+
* @param className - The class name
|
|
387
|
+
* @param moduleName - The module name
|
|
388
|
+
* @param path - The path
|
|
389
|
+
*/
|
|
390
|
+
async function generateModuleServiceSinglePath(outputPathController, className, moduleName, path, file, folderToScaffold) {
|
|
391
|
+
const newModuleFile = await (0, command_utils_1.extractFirstWord)(file);
|
|
392
|
+
const newModulePath = nodePath.join(folderToScaffold, path).normalize();
|
|
393
|
+
const newModuleName = `${newModuleFile}.module.ts`;
|
|
394
|
+
const newModuleOutputPath = `${newModulePath}/${newModuleName}`.replace("\\", "/");
|
|
395
|
+
const controllerToModule = nodePath
|
|
396
|
+
.relative(newModuleOutputPath, outputPathController)
|
|
397
|
+
.normalize()
|
|
398
|
+
.replace(/\.ts$/, "")
|
|
399
|
+
.replace(/\\/g, "/")
|
|
400
|
+
.replace(/\.\./g, ".");
|
|
401
|
+
const controllerFullPath = nodePath
|
|
402
|
+
.join(folderToScaffold, path, "..", newModuleName)
|
|
403
|
+
.normalize();
|
|
404
|
+
if (fs_1.default.existsSync(newModuleOutputPath)) {
|
|
405
|
+
await (0, add_controller_to_module_1.addControllerToModule)(controllerFullPath, `${className}Controller`, controllerToModule);
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
(0, command_utils_1.writeTemplate)({
|
|
409
|
+
outputPath: newModuleOutputPath,
|
|
410
|
+
template: {
|
|
411
|
+
path: "../templates/opinionated/module-service.tpl",
|
|
412
|
+
data: {
|
|
413
|
+
className,
|
|
414
|
+
moduleName: (0, boost_ts_1.anyCaseToPascalCase)(moduleName),
|
|
415
|
+
path: controllerToModule,
|
|
416
|
+
},
|
|
417
|
+
},
|
|
418
|
+
});
|
|
419
|
+
await (0, add_module_to_container_1.addModuleToContainer)((0, boost_ts_1.anyCaseToPascalCase)(moduleName), `${moduleName}/${file.replace(".ts", "")}`, path);
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* Generate a module for service scaffolding with nested path
|
|
423
|
+
* @param outputPathController
|
|
424
|
+
* @param className
|
|
425
|
+
* @param path
|
|
426
|
+
* @param folderToScaffold
|
|
427
|
+
* @returns
|
|
428
|
+
*/
|
|
429
|
+
async function generateModuleServiceNestedPath(outputPathController, className, path, folderToScaffold) {
|
|
430
|
+
const moduleFileName = nodePath.basename(path, "/");
|
|
431
|
+
const newModulePath = nodePath
|
|
432
|
+
.join(folderToScaffold, path, "..")
|
|
433
|
+
.normalize();
|
|
434
|
+
const newModuleName = `${moduleFileName}.module.ts`;
|
|
435
|
+
const newModuleOutputPath = `${newModulePath}/${newModuleName}`.replace("\\", "/");
|
|
436
|
+
const controllerToModule = nodePath
|
|
437
|
+
.relative(newModuleOutputPath, outputPathController)
|
|
438
|
+
.normalize()
|
|
439
|
+
.replace(/\.ts$/, "")
|
|
440
|
+
.replace(/\\/g, "/")
|
|
441
|
+
.replace(/\.\./g, ".");
|
|
442
|
+
const controllerFullPath = nodePath
|
|
443
|
+
.join(folderToScaffold, path, "..", newModuleName)
|
|
444
|
+
.normalize();
|
|
445
|
+
if (fs_1.default.existsSync(newModuleOutputPath)) {
|
|
446
|
+
await (0, add_controller_to_module_1.addControllerToModule)(controllerFullPath, `${className}Controller`, controllerToModule);
|
|
447
|
+
return;
|
|
448
|
+
}
|
|
449
|
+
(0, command_utils_1.writeTemplate)({
|
|
450
|
+
outputPath: newModuleOutputPath,
|
|
451
|
+
template: {
|
|
452
|
+
path: "../templates/opinionated/module-service.tpl",
|
|
453
|
+
data: {
|
|
454
|
+
className,
|
|
455
|
+
moduleName: (0, boost_ts_1.anyCaseToPascalCase)(moduleFileName),
|
|
456
|
+
path: controllerToModule,
|
|
457
|
+
},
|
|
458
|
+
},
|
|
459
|
+
});
|
|
460
|
+
await (0, add_module_to_container_1.addModuleToContainerNestedPath)((0, boost_ts_1.anyCaseToPascalCase)(moduleFileName), path);
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* Generate a module
|
|
464
|
+
* @param outputPath - The output path
|
|
465
|
+
* @param className - The class name
|
|
466
|
+
* @param moduleName - The module name
|
|
467
|
+
* @param path - The path
|
|
468
|
+
*/
|
|
469
|
+
async function generateModule(outputPath, className, moduleName, path) {
|
|
470
|
+
(0, command_utils_1.writeTemplate)({
|
|
471
|
+
outputPath,
|
|
472
|
+
template: {
|
|
473
|
+
path: "../templates/opinionated/module.tpl",
|
|
474
|
+
data: {
|
|
475
|
+
className,
|
|
476
|
+
moduleName: (0, boost_ts_1.anyCaseToPascalCase)(moduleName),
|
|
477
|
+
path,
|
|
478
|
+
},
|
|
479
|
+
},
|
|
480
|
+
});
|
|
481
|
+
}
|