-
Notifications
You must be signed in to change notification settings - Fork 228
/
Copy pathindex.ts
26 lines (23 loc) · 949 Bytes
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import color from '@heroku-cli/color'
import {Command, flags} from '@heroku-cli/command'
import {ux} from '@oclif/core'
import displayTable from '../../lib/certs/display_table'
import {SniEndpoint} from '../../lib/types/sni_endpoint'
export default class Index extends Command {
static topic = 'certs';
static description = 'list SSL certificates for an app';
static flags = {
app: flags.app({required: true}),
remote: flags.remote(),
};
public async run(): Promise<void> {
const {flags} = await this.parse(Index)
const {body: certs} = await this.heroku.get<SniEndpoint[]>(`/apps/${flags.app}/sni-endpoints`)
if (certs.length === 0) {
ux.log(`${color.magenta(flags.app)} has no SSL certificates.\nUse ${color.cmd('heroku certs:add CRT KEY')} to add one.`)
} else {
const sortedCerts = certs.sort((a, b) => a.name > b.name ? 1 : (b.name > a.name ? -1 : 0))
displayTable(sortedCerts)
}
}
}