1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const tslib_1 = require("tslib");
|
4 | const base_command_1 = require("../../base-command");
|
5 | const decorators_1 = require("../../utils/decorators");
|
6 | const component_1 = require("./component");
|
7 | const function_1 = require("./function");
|
8 | class GenerateIndex extends base_command_1.default {
|
9 | async run() {
|
10 | const { flags } = this.parse(GenerateIndex);
|
11 | const pathParams = flags.path ? ['--path', flags.path] : [];
|
12 | const type = await this.askForType();
|
13 | switch (type) {
|
14 | case 1 : {
|
15 | return function_1.default.run([...pathParams]);
|
16 | }
|
17 | case 0 : {
|
18 | return component_1.default.run([...pathParams]);
|
19 | }
|
20 | }
|
21 | }
|
22 | async askForType() {
|
23 | const { type } = await this.inquirer.prompt([
|
24 | {
|
25 | message: 'What would you like to generate:',
|
26 | type: 'list',
|
27 | name: 'type',
|
28 | choices: [{ value: 1 , name: 'Function' }, { value: 0 , name: 'Component' }]
|
29 | }
|
30 | ]);
|
31 | return type;
|
32 | }
|
33 | }
|
34 | GenerateIndex.description = 'Generate Function or Component';
|
35 | GenerateIndex.aliases = ['g'];
|
36 | GenerateIndex.flags = Object.assign({}, base_command_1.default.flags);
|
37 | GenerateIndex.args = [];
|
38 | tslib_1.__decorate([
|
39 | decorators_1.RequireIntegrationFolder()
|
40 | ], GenerateIndex.prototype, "run", null);
|
41 | exports.default = GenerateIndex;
|