UNPKG

1.59 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");
8const inquirer = require("inquirer");
9class GenerateIndex extends base_command_1.default {
10 async run() {
11 const { flags } = this.parse(GenerateIndex);
12 const pathParams = flags.path ? ['--path', flags.path] : [];
13 const type = this.hasViews ? await this.askForType() : 1 /* Function */;
14 switch (type) {
15 case 1 /* Function */: {
16 return function_1.default.run([...pathParams]);
17 }
18 case 0 /* Component */: {
19 return component_1.default.run([...pathParams]);
20 }
21 }
22 }
23 async askForType() {
24 const { type } = await inquirer.prompt([
25 {
26 message: 'What would you like to generate:',
27 type: 'list',
28 name: 'type',
29 choices: [{ value: 1 /* Function */, name: 'Function' }, { value: 0 /* Component */, name: 'Component' }]
30 }
31 ]);
32 return type;
33 }
34}
35GenerateIndex.description = 'generate function';
36GenerateIndex.aliases = ['g'];
37GenerateIndex.flags = Object.assign({}, base_command_1.default.flags);
38GenerateIndex.args = [];
39tslib_1.__decorate([
40 decorators_1.RequireIntegrationFolder()
41], GenerateIndex.prototype, "run", null);
42exports.default = GenerateIndex;