UNPKG

2.01 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 // @ts-ignore
30 debug(...args) {
31 super.debug.apply(this, args);
32 }
33 log(_message, ..._args) {
34 if (!this.silent) {
35 // @ts-ignore
36 super.log.apply(this, arguments);
37 }
38 }
39 warn(_input) {
40 if (!this.silent) {
41 // @ts-ignore
42 super.warn.apply(this, arguments);
43 }
44 }
45 get devPortalClient() {
46 return devPortal_1.devPortalClient(this);
47 }
48 get isIntegrationLocation() {
49 return fs.existsSync(this.locator.authConfigPath);
50 }
51 // protected logLevel: any
52 async init() {
53 const { flags } = this.parse(this.constructor);
54 const path = flags.path || undefined;
55 const { constants, config } = setup_config_1.default(path);
56 this.bearerConfig = config;
57 this.constants = constants;
58 this.silent = flags.silent;
59 }
60}
61default_1.flags = {
62 help: command_1.flags.help({ char: 'h' }),
63 path: command_1.flags.string({}),
64 silent: command_1.flags.boolean({})
65 // logLevel: flags.string({ options: ['error', 'warn', 'info', 'debug'], default: 'info' })
66};
67exports.default = default_1;