-
Notifications
You must be signed in to change notification settings - Fork 228
/
Copy pathindex.ts
52 lines (42 loc) · 1.41 KB
/
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import {flags} from '@heroku-cli/command'
import {ux} from '@oclif/core'
import BaseCommand from '../../../lib/webhooks/base'
export default class EventsIndex extends BaseCommand {
static description = 'list webhook events on an app'
static examples = [
'$ heroku webhooks:events',
]
static flags = {
app: flags.app(),
remote: flags.remote(),
pipeline: flags.pipeline({char: 'p', description: 'pipeline on which to list', hidden: true}),
}
async run() {
const {flags} = await this.parse(EventsIndex)
const {path, display} = this.webhookType(flags)
ux.warn('heroku webhooks:event is deprecated, please use heroku webhooks:deliveries')
const {body: events}: {body: any} = await this.webhooksClient.get(`${path}/webhook-events`)
if (events.length === 0) {
this.log(`${display} has no events`)
} else {
events.sort((a: any, b: any) => Date.parse(a.created_at) - Date.parse(b.created_at))
const printLine: typeof this.log = (...args) => this.log(...args)
ux.table(events, {
id: {
header: 'Event ID',
},
resource: {
get: (w: any) => w.payload.resource,
},
action: {
get: (w: any) => w.payload.action,
},
published_at: {
header: 'Published At', get: (w: any) => w.payload.published_at,
},
}, {
'no-header': false, printLine,
})
}
}
}