|
3 | 3 | * ------------------------------------- |
4 | 4 | * |
5 | 5 | */ |
6 | | -import { writeTemplate } from './lib/template'; |
7 | | -import { askFileName, buildFilePath, existsFile, parseName, updateTargets } from './lib/utils'; |
| 6 | +import { AbstractMakeCommand } from './AbstractMakeCommand'; |
8 | 7 |
|
9 | 8 |
|
10 | | -export class MakeControllerCommand { |
| 9 | +export class MakeControllerCommand extends AbstractMakeCommand { |
11 | 10 |
|
12 | 11 | static command = 'make:controller'; |
13 | 12 | static description = 'Generate new controller'; |
14 | | - static type = 'Controller'; |
15 | | - static suffix = 'Controller'; |
16 | | - static template = 'controller.hbs'; |
17 | | - static target = 'api/controllers'; |
18 | 13 |
|
19 | | - static async action(): Promise<void> { |
20 | | - try { |
21 | | - const command = new MakeControllerCommand(); |
22 | | - await command.run(); |
23 | | - } catch (e) { |
24 | | - process.exit(1); |
25 | | - } |
26 | | - } |
27 | | - |
28 | | - public async run(): Promise<void> { |
29 | | - const context = await askFileName(MakeControllerCommand.type, MakeControllerCommand.suffix); |
30 | | - const filePath = buildFilePath(MakeControllerCommand.target, context.name); |
31 | | - await existsFile(filePath, true); |
32 | | - await writeTemplate(MakeControllerCommand.template, filePath, { |
33 | | - name: parseName(context.name, MakeControllerCommand.suffix), |
34 | | - deepness: context.deepness |
35 | | - }); |
36 | | - await updateTargets(); |
37 | | - process.exit(0); |
38 | | - } |
| 14 | + public type = 'Controller'; |
| 15 | + public suffix = 'Controller'; |
| 16 | + public template = 'controller.hbs'; |
| 17 | + public target = 'api/controllers'; |
39 | 18 |
|
40 | 19 | } |
0 commit comments