UNPKG

1.09 kBJavaScriptView Raw
1'use strict'
2
3let cli = require('heroku-cli-util')
4let formatDate = require('./format_date.js')
5let _ = require('lodash')
6
7module.exports = function (certs, domains) {
8 let mapped = certs.filter(function (f) { return f.ssl_cert }).map(function (f) {
9 return {
10 name: f.name,
11 cname: f.cname,
12 expires_at: f.ssl_cert.expires_at,
13 ca_signed: f.ssl_cert['ca_signed?'],
14 type: f._meta.type,
15 common_names: f.ssl_cert.cert_domains.join(', ')
16 }
17 })
18
19 let columns = [
20 {label: 'Name', key: 'name'}
21 ]
22
23 if (_.find(mapped, (row) => row.cname)) {
24 columns = columns.concat([{label: 'Endpoint', key: 'cname', format: function (f) { return f || '(Not applicable for SNI)' }}])
25 }
26
27 columns = columns.concat([
28 {label: 'Common Name(s)', key: 'common_names'},
29 {label: 'Expires', key: 'expires_at', format: function (f) { return f ? formatDate(f) : '' }},
30 {label: 'Trusted', key: 'ca_signed', format: function (f) { return f === undefined ? '' : (f ? 'True' : 'False') }},
31 {label: 'Type', key: 'type'}
32 ])
33
34 cli.table(mapped, { columns })
35}