UNPKG

1.81 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const tslib_1 = require("tslib");
4const color_1 = tslib_1.__importDefault(require("@heroku-cli/color"));
5const cli_ux_1 = tslib_1.__importDefault(require("cli-ux"));
6const api_1 = require("./api");
7function 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}
20exports.warnMixedOwnership = warnMixedOwnership;
21function 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 // If pipeline owner doesn't own any application and type is user (unlikely)
32 // We return the uuid as default
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}
40exports.getOwner = getOwner;