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 api_1 = require("./api");
|
7 | function warnMixedOwnership(pipelineApps, pipeline, owner) {
|
8 | const hasMixedOwnership = pipelineApps.some(app => {
|
9 | return (app.owner && app.owner.id) !== pipeline.owner.id;
|
10 | });
|
11 | if (hasMixedOwnership) {
|
12 | cli_ux_1.default.log();
|
13 | let message = `Some apps in this pipeline do not belong to ${color_1.default.cmd(owner)}.`;
|
14 | message += '\n\nAll apps in a pipeline must have the same owner as the pipeline owner.';
|
15 | message += '\nTransfer these apps or change the pipeline owner in pipeline settings.';
|
16 | message += `\nSee ${color_1.default.cyan('https://devcenter.heroku.com/articles/pipeline-ownership-transition')} for more info.`;
|
17 | cli_ux_1.default.warn(message);
|
18 | }
|
19 | }
|
20 | exports.warnMixedOwnership = warnMixedOwnership;
|
21 | function getOwner(heroku, apps, pipeline) {
|
22 | let owner;
|
23 | let ownerPromise;
|
24 | if (pipeline.owner.type === 'team') {
|
25 | ownerPromise = api_1.getTeam(heroku, pipeline.owner.id).then(response => response.body);
|
26 | }
|
27 | else {
|
28 | const app = apps.find(app => {
|
29 | return app.owner ? app.owner.id === pipeline.owner.id : false;
|
30 | });
|
31 |
|
32 |
|
33 | owner = app ? app.owner && app.owner.email : pipeline.owner.id;
|
34 | ownerPromise = Promise.resolve(owner);
|
35 | }
|
36 | return ownerPromise.then(owner => {
|
37 | return owner.name ? `${owner.name} (team)` : owner;
|
38 | });
|
39 | }
|
40 | exports.getOwner = getOwner;
|