UNPKG

2.6 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 integrationId = 'integration-id';
9const integrationUuid = 'integration-uuid';
10const cdnHost = 'cdn-host';
11class PackViews extends base_command_1.default {
12 async run() {
13 const { flags } = this.parse(PackViews);
14 const config = this.constants;
15 const env = Object.assign({}, process.env, { BEARER_INTEGRATION_ID: flags[integrationUuid], BEARER_INTEGRATION_TAG_NAME: flags[integrationId], BEARER_INTEGRATION_HOST: config.IntegrationServiceHost, BEARER_AUTHORIZATION_HOST: config.IntegrationServiceHost, CDN_HOST: flags[cdnHost] });
16 try {
17 const buildDestination = await this.buildStencil(env);
18 this.success(`Packed views : ${buildDestination}`);
19 }
20 catch (e) {
21 this.error(e);
22 }
23 }
24 async buildStencil(env) {
25 return new Promise((resolve, reject) => {
26 const build = child_process_1.spawn('yarn', ['stencil', 'build'], { env, cwd: this.locator.buildViewsDir });
27 build.stdout.on('data', data => {
28 this.debug(`build integration => stdout: ${data}`);
29 });
30 build.stderr.on('data', data => {
31 this.debug(`build integration => stderr: ${data}`);
32 });
33 build.on('close', code => {
34 if (code === 0) {
35 resolve();
36 }
37 else {
38 reject(new Error("Can't build integration views. please check logs"));
39 }
40 });
41 });
42 }
43}
44PackViews.description = 'Pack integration views';
45PackViews.hidden = true;
46PackViews.flags = Object.assign({}, base_command_1.default.flags, { [integrationUuid]: command_1.flags.string({
47 required: true,
48 description: 'Integration unique identifier'
49 }), [integrationId]: command_1.flags.string({
50 required: true,
51 description: 'stencil integration namespace'
52 }), [cdnHost]: command_1.flags.string({
53 required: true,
54 description: 'Host url where views are uploade to (ex: https:static.bearer.sh/123456/attach-pull/dist/78901/'
55 }) });
56tslib_1.__decorate([
57 decorators_1.skipIfNoViews(),
58 decorators_1.RequireIntegrationFolder()
59], PackViews.prototype, "run", null);
60exports.default = PackViews;