UNPKG

1.92 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const command_1 = require("@oclif/command");
4const colors = require("colors/safe");
5const fs = require("fs");
6const locator_1 = require("./utils/locator");
7const setup_config_1 = require("./utils/setup-config");
8const devPortal_1 = require("./utils/devPortal");
9class default_1 extends command_1.default {
10 constructor() {
11 super(...arguments);
12 this.silent = false;
13 }
14 get locator() {
15 return new locator_1.default(this.bearerConfig);
16 }
17 get colors() {
18 return colors;
19 }
20 get integrationAuthConfig() {
21 return require(this.locator.authConfigPath);
22 }
23 get hasViews() {
24 return fs.existsSync(this.locator.srcViewsDir);
25 }
26 success(message) {
27 this.log(this.colors.green(message));
28 }
29 log(_message, ..._args) {
30 if (!this.silent) {
31 // @ts-ignore
32 super.log.apply(this, arguments);
33 }
34 }
35 warn(_input) {
36 if (!this.silent) {
37 // @ts-ignore
38 super.warn.apply(this, arguments);
39 }
40 }
41 get devPortalClient() {
42 return devPortal_1.devPortalClient(this);
43 }
44 get isIntegrationLocation() {
45 return fs.existsSync(this.locator.authConfigPath);
46 }
47 // protected logLevel: any
48 async init() {
49 const { flags } = this.parse(this.constructor);
50 const path = flags.path || undefined;
51 const { constants, config } = setup_config_1.default(path);
52 this.bearerConfig = config;
53 this.constants = constants;
54 this.silent = flags.silent;
55 }
56}
57default_1.flags = {
58 help: command_1.flags.help({ char: 'h' }),
59 path: command_1.flags.string({}),
60 silent: command_1.flags.boolean({})
61 // logLevel: flags.string({ options: ['error', 'warn', 'info', 'debug'], default: 'info' })
62};
63exports.default = default_1;