1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const tslib_1 = require("tslib");
|
4 | const color_1 = tslib_1.__importDefault(require("@heroku-cli/color"));
|
5 | const cli_ux_1 = tslib_1.__importDefault(require("cli-ux"));
|
6 | const lodash_sortby_1 = tslib_1.__importDefault(require("lodash.sortby"));
|
7 | const ownership_1 = require("./ownership");
|
8 | async function renderPipeline(heroku, pipeline, pipelineApps, { withOwners, showOwnerWarning } = { withOwners: false, showOwnerWarning: false }) {
|
9 | cli_ux_1.default.styledHeader(pipeline.name);
|
10 | let owner;
|
11 | if (pipeline.owner) {
|
12 | owner = await ownership_1.getOwner(heroku, pipelineApps, pipeline);
|
13 | cli_ux_1.default.log(`owner: ${owner}`);
|
14 | }
|
15 | cli_ux_1.default.log('');
|
16 | const columns = {
|
17 | name: {
|
18 | header: 'app name',
|
19 | get(row) {
|
20 | return color_1.default.app(row.name || '');
|
21 | },
|
22 | },
|
23 | 'coupling.stage': {
|
24 | header: 'stage',
|
25 | get(row) {
|
26 | return row.coupling.stage;
|
27 | },
|
28 | },
|
29 | };
|
30 | if (withOwners) {
|
31 | columns['owner.email'] = {
|
32 | header: 'owner',
|
33 | get(row) {
|
34 | const email = row.owner && row.owner.email;
|
35 | if (email) {
|
36 | return email.endsWith('@herokumanager.com') ? `${row.split('@')[0]} (team)` : email;
|
37 | }
|
38 | },
|
39 | };
|
40 | }
|
41 | const developmentApps = lodash_sortby_1.default(pipelineApps.filter(app => app.coupling.stage === 'development'), ['name']);
|
42 | const reviewApps = lodash_sortby_1.default(pipelineApps.filter(app => app.coupling.stage === 'review'), ['name']);
|
43 | const stagingApps = lodash_sortby_1.default(pipelineApps.filter(app => app.coupling.stage === 'staging'), ['name']);
|
44 | const productionApps = lodash_sortby_1.default(pipelineApps.filter(app => app.coupling.stage === 'production'), ['name']);
|
45 | const apps = developmentApps.concat(reviewApps).concat(stagingApps).concat(productionApps);
|
46 | cli_ux_1.default.table(apps, columns);
|
47 | if (showOwnerWarning && pipeline.owner) {
|
48 | ownership_1.warnMixedOwnership(pipelineApps, pipeline, owner);
|
49 | }
|
50 | }
|
51 | exports.default = renderPipeline;
|