1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const color_1 = require("@heroku-cli/color");
|
4 | const command_1 = require("@heroku-cli/command");
|
5 | const cli_ux_1 = require("cli-ux");
|
6 | const _ = require("lodash");
|
7 | class Regions extends command_1.Command {
|
8 | async run() {
|
9 | const { flags } = this.parse(Regions);
|
10 | let { body: regions } = await this.heroku.get('/regions');
|
11 | if (flags.private) {
|
12 | regions = regions.filter((region) => region.private_capable);
|
13 | }
|
14 | else if (flags.common) {
|
15 | regions = regions.filter((region) => !region.private_capable);
|
16 | }
|
17 | regions = _.sortBy(regions, ['private_capable', 'name']);
|
18 | if (flags.json) {
|
19 | cli_ux_1.cli.styledJSON(regions);
|
20 | }
|
21 | else {
|
22 | cli_ux_1.cli.table(regions, {
|
23 | columns: [
|
24 | { key: 'name', label: 'ID', format: (n) => color_1.default.green(n) },
|
25 | { key: 'description', label: 'Location' },
|
26 | { key: 'private_capable', label: 'Runtime', format: (c) => c ? 'Private Spaces' : 'Common Runtime' }
|
27 | ]
|
28 | });
|
29 | }
|
30 | }
|
31 | }
|
32 | Regions.topic = 'regions';
|
33 | Regions.description = 'list available regions for deployment';
|
34 | Regions.flags = {
|
35 | json: command_1.flags.boolean({ description: 'output in json format' }),
|
36 | private: command_1.flags.boolean({ description: 'show regions for private spaces' }),
|
37 | common: command_1.flags.boolean({ description: 'show regions for common runtime' })
|
38 | };
|
39 | exports.default = Regions;
|