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 | get ux() {
|
31 | return cli_ux_1.default;
|
32 | }
|
33 | get colors() {
|
34 | return colors;
|
35 | }
|
36 | get integrationAuthConfig() {
|
37 | return require(this.locator.authConfigPath);
|
38 | }
|
39 | get hasViews() {
|
40 | return fs.existsSync(this.locator.srcViewsDir);
|
41 | }
|
42 | success(message) {
|
43 | this.log(this.colors.green(message));
|
44 | }
|
45 | log(_message, ..._args) {
|
46 | if (!this.silent) {
|
47 |
|
48 | super.log.apply(this, arguments);
|
49 | }
|
50 | }
|
51 | warn(_input) {
|
52 | if (!this.silent) {
|
53 |
|
54 | super.warn.apply(this, arguments);
|
55 | }
|
56 | }
|
57 | get devPortalClient() {
|
58 | return devPortal_1.devPortalClient(this);
|
59 | }
|
60 | get isIntegrationLocation() {
|
61 | return fs.existsSync(this.locator.authConfigPath);
|
62 | }
|
63 |
|
64 | async init() {
|
65 | const { flags } = this.parse(this.constructor);
|
66 | const path = flags.path || undefined;
|
67 | const { constants, config } = setup_config_1.default(path);
|
68 | this.bearerConfig = config;
|
69 | this.constants = constants;
|
70 | this.silent = flags.silent;
|
71 | }
|
72 | |
73 |
|
74 |
|
75 | async askForString(phrase, options = {}) {
|
76 | const { response } = await this.inquirer.prompt([
|
77 | Object.assign({ message: `${phrase}:`, name: 'response' }, options)
|
78 | ]);
|
79 | return response;
|
80 | }
|
81 | async askForPassword(phrase, options = {}) {
|
82 | return this.askForString(phrase, Object.assign({}, options, { type: 'password' }));
|
83 | }
|
84 | }
|
85 | default_1.flags = {
|
86 | help: command_1.flags.help({ char: 'h' }),
|
87 | path: command_1.flags.string({}),
|
88 | silent: command_1.flags.boolean({})
|
89 |
|
90 | };
|
91 | exports.default = default_1;
|