1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const command_1 = require("@oclif/command");
|
4 | const Case = require("case");
|
5 | const cli_ux_1 = require("cli-ux");
|
6 | const colors = require("colors/safe");
|
7 | const copy = require("copy-template-dir");
|
8 | const inquirer = require("inquirer");
|
9 | const fs = require("fs");
|
10 | const locator_1 = require("./utils/locator");
|
11 | const setup_config_1 = require("./utils/setup-config");
|
12 | const devPortal_1 = require("./utils/devPortal");
|
13 | class default_1 extends command_1.default {
|
14 | constructor() {
|
15 | super(...arguments);
|
16 | this.silent = false;
|
17 | }
|
18 | get locator() {
|
19 | return new locator_1.default(this.bearerConfig);
|
20 | }
|
21 | get inquirer() {
|
22 | return inquirer;
|
23 | }
|
24 | get copy() {
|
25 | return copy;
|
26 | }
|
27 | get case() {
|
28 | return Case;
|
29 | }
|
30 |
|
31 | get ux() {
|
32 | return cli_ux_1.default;
|
33 | }
|
34 | get colors() {
|
35 | return colors;
|
36 | }
|
37 | get integrationAuthConfig() {
|
38 | return require(this.locator.authConfigPath);
|
39 | }
|
40 | get hasViews() {
|
41 | return fs.existsSync(this.locator.srcViewsDir);
|
42 | }
|
43 | success(message) {
|
44 | this.log(this.colors.green(message));
|
45 | }
|
46 | log(_message, ..._args) {
|
47 | if (!this.silent) {
|
48 |
|
49 | super.log.apply(this, arguments);
|
50 | }
|
51 | }
|
52 | warn(_input) {
|
53 | if (!this.silent) {
|
54 |
|
55 | super.warn.apply(this, arguments);
|
56 | }
|
57 | }
|
58 | get devPortalClient() {
|
59 | return devPortal_1.devPortalClient(this);
|
60 | }
|
61 |
|
62 | async init() {
|
63 | const { flags } = this.parse(this.constructor);
|
64 | const path = flags.path || undefined;
|
65 | const { constants, config } = setup_config_1.default(path);
|
66 | this.bearerConfig = config;
|
67 | this.constants = constants;
|
68 | this.silent = flags.silent;
|
69 | }
|
70 | |
71 |
|
72 |
|
73 | async askForString(phrase, options = {}) {
|
74 | const { response } = await this.inquirer.prompt([
|
75 | Object.assign({ message: `${phrase}:`, name: 'response' }, options)
|
76 | ]);
|
77 | return response;
|
78 | }
|
79 | }
|
80 | default_1.flags = {
|
81 | help: command_1.flags.help({ char: 'h' }),
|
82 | path: command_1.flags.string({}),
|
83 | silent: command_1.flags.boolean({})
|
84 |
|
85 | };
|
86 | exports.default = default_1;
|