1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const command_1 = require("@heroku-cli/command");
|
4 | const cli_ux_1 = require("cli-ux");
|
5 | const true_myth_1 = require("true-myth");
|
6 | const buildpack_registry_1 = require("@heroku/buildpack-registry");
|
7 | class Versions extends command_1.Command {
|
8 | async run() {
|
9 | let { args } = this.parse(Versions);
|
10 | let registry;
|
11 | let herokuAuth = this.heroku.auth || '';
|
12 | if (herokuAuth === '') {
|
13 | this.error('You need to be logged in to run this command.');
|
14 | }
|
15 | registry = new buildpack_registry_1.BuildpackRegistry();
|
16 | true_myth_1.Result.match({
|
17 | Ok: _ => { },
|
18 | Err: err => {
|
19 | this.error(`Could not find the buildpack.\n${err}`);
|
20 | },
|
21 | }, buildpack_registry_1.BuildpackRegistry.isValidBuildpackSlug(args.buildpack));
|
22 | let result = await registry.listVersions(args.buildpack);
|
23 | true_myth_1.Result.match({
|
24 | Ok: versions => {
|
25 | cli_ux_1.cli.table(versions.sort((a, b) => {
|
26 | return a.release > b.release ? -1 : 1;
|
27 | }), {
|
28 | columns: [
|
29 | { key: 'release', label: 'Version' },
|
30 | { key: 'created_at', label: 'Released At' },
|
31 | { key: 'status', label: 'Status' }
|
32 | ]
|
33 | });
|
34 | },
|
35 | Err: err => {
|
36 | if (err.status === 404) {
|
37 | this.error(`Could not find '${args.buildpack}'`);
|
38 | }
|
39 | else {
|
40 | this.error(`Problem fetching versions, ${err.status}: ${err.description}`);
|
41 | }
|
42 | }
|
43 | }, result);
|
44 | }
|
45 | }
|
46 | Versions.description = 'list versions of a buildpack';
|
47 | Versions.args = [
|
48 | {
|
49 | name: 'buildpack',
|
50 | required: true,
|
51 | description: 'namespace/name of the buildpack'
|
52 | }
|
53 | ];
|
54 | exports.default = Versions;
|