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