UNPKG

1.82 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const base_command_1 = require("../../base-command");
4class IntegrationsList extends base_command_1.default {
5 async run() {
6 try {
7 const { data } = await this.devPortalClient.request({
8 query: QUERY
9 });
10 if (data.data) {
11 const { integrations } = data.data;
12 const max = integrations.reduce((acc, inte) => {
13 acc.name = Math.max(inte.name.length, acc.name);
14 acc.state = Math.max((inte.latestActivity || { state: '' }).state.length, acc.state);
15 return acc;
16 }, { name: 0, state: 0 });
17 this.log('');
18 const headers = [
19 {
20 name: this.colors.bold('Name'.padEnd(max.name)),
21 latestActivity: { state: this.colors.bold('Status'.padEnd(max.state)) }
22 }
23 ];
24 headers.concat(integrations).forEach(inte => {
25 this.log('| %s | %s |', inte.name.padEnd(max.name), (inte.latestActivity || { state: '' }).state.padEnd(max.state));
26 });
27 }
28 else {
29 this.error('Unable to fetch integration list');
30 }
31 }
32 catch (e) {
33 this.error(e);
34 }
35 }
36}
37IntegrationsList.description = 'list deployed integrations';
38IntegrationsList.flags = Object.assign({}, base_command_1.default.flags);
39IntegrationsList.args = [];
40exports.default = IntegrationsList;
41const QUERY = `
42query CLIListIntegrations {
43 integrations(includeGloballyAvailable: false) {
44 deprecated_uuid: uuid
45 uuid: uuidv2
46 name
47 latestActivity {
48 state
49 }
50 }
51}
52`;