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