-
Notifications
You must be signed in to change notification settings - Fork 228
/
Copy pathindex.ts
46 lines (40 loc) · 1.48 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
import {Command, flags as cmdFlags} from '@heroku-cli/command'
import {ux} from '@oclif/core'
import color from '@heroku-cli/color'
import * as Heroku from '@heroku-cli/schema'
import * as shellescape from 'shell-escape'
import {getPipeline} from '../../../lib/ci/pipelines'
import {getPipelineConfigVars} from '../../../lib/api'
export default class CiConfig extends Command {
static description = 'display CI config vars'
static examples = [
`$ heroku ci:config --app murmuring-headland-14719 --json
`,
]
static flags = {
app: cmdFlags.app(),
remote: cmdFlags.remote(),
shell: cmdFlags.boolean({char: 's', description: 'output config vars in shell format'}),
json: cmdFlags.boolean({description: 'output config vars in json format'}),
pipeline: cmdFlags.pipeline({exactlyOne: ['pipeline', 'app']}),
}
async run() {
const {flags} = await this.parse(CiConfig)
const pipeline = await getPipeline(flags, this.heroku)
const {body: config} = await getPipelineConfigVars(this.heroku, pipeline.id)
if (flags.shell) {
Object.keys(config).forEach(key => {
ux.log(`${key}=${shellescape([config[key]])}`)
})
} else if (flags.json) {
ux.styledJSON(config)
} else {
ux.styledHeader(`${pipeline.name} test config vars`)
const formattedConfig: Heroku.Pipeline = {}
Object.keys(config).forEach(key => {
formattedConfig[color.green(key)] = config[key]
})
ux.styledObject(formattedConfig)
}
}
}