UNPKG

2.28 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const tslib_1 = require("tslib");
4const command_1 = require("@oclif/command");
5const child_process_1 = require("child_process");
6const base_command_1 = require("../../base-command");
7const decorators_1 = require("../../utils/decorators");
8const cdnHost = 'cdn-host';
9class PackViews extends base_command_1.default {
10 async run() {
11 const { flags } = this.parse(PackViews);
12 const config = this.constants;
13 const env = Object.assign({}, process.env, { BEARER_INTEGRATION_ID: this.bearerConfig.BUID, BEARER_INTEGRATION_HOST: config.IntegrationServiceHost, BEARER_AUTHORIZATION_HOST: config.IntegrationServiceHost, CDN_HOST: flags[cdnHost] });
14 try {
15 const buildDestination = await this.buildStencil(env);
16 this.success(`Packed views : ${buildDestination}`);
17 }
18 catch (e) {
19 this.error(e);
20 }
21 }
22 async buildStencil(env) {
23 return new Promise((resolve, reject) => {
24 const build = child_process_1.spawn('yarn', ['stencil', 'build'], { env, cwd: this.locator.buildViewsDir });
25 build.stdout.on('data', data => {
26 this.debug(`build integration => stdout: ${data}`);
27 });
28 build.stderr.on('data', data => {
29 this.debug(`build integration => stderr: ${data}`);
30 });
31 build.on('close', code => {
32 if (code === 0) {
33 resolve(this.locator.buildViewsDir);
34 }
35 else {
36 reject(new Error("Can't build integration views. please check logs"));
37 }
38 });
39 });
40 }
41}
42PackViews.description = 'Pack integration views';
43PackViews.hidden = true;
44PackViews.flags = Object.assign({}, base_command_1.default.flags, { [cdnHost]: command_1.flags.string({
45 required: true,
46 description: 'Host url where views are uploade to (ex: https:static.bearer.sh/123456/attach-pull/dist/78901/'
47 }) });
48tslib_1.__decorate([
49 decorators_1.skipIfNoViews(),
50 decorators_1.RequireIntegrationFolder(),
51 decorators_1.RequireLinkedIntegration()
52], PackViews.prototype, "run", null);
53exports.default = PackViews;