UNPKG

1.54 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const tslib_1 = require("tslib");
4const base_command_1 = require("../../base-command");
5const decorators_1 = require("../../utils/decorators");
6const component_1 = require("./component");
7const function_1 = require("./function");
8class 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 /* Function */: {
15 return function_1.default.run([...pathParams]);
16 }
17 case 0 /* Component */: {
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 /* Function */, name: 'Function' }, { value: 0 /* Component */, name: 'Component' }]
29 }
30 ]);
31 return type;
32 }
33}
34GenerateIndex.description = 'Generate Function or Component';
35GenerateIndex.aliases = ['g'];
36GenerateIndex.flags = Object.assign({}, base_command_1.default.flags);
37GenerateIndex.args = [];
38tslib_1.__decorate([
39 decorators_1.RequireIntegrationFolder()
40], GenerateIndex.prototype, "run", null);
41exports.default = GenerateIndex;