1 | const cli = require('heroku-cli-util')
|
2 | const co = require('co')
|
3 | const shellescape = require('shell-escape')
|
4 | const api = require('../../lib/heroku-api')
|
5 |
|
6 | function* run (context, heroku) {
|
7 | const coupling = yield api.pipelineCoupling(heroku, context.app)
|
8 | const config = yield api.configVars(heroku, coupling.pipeline.id)
|
9 |
|
10 | if (context.flags.shell) {
|
11 | Object.keys(config).forEach((key) => {
|
12 | cli.log(`${key}=${shellescape([config[key]])}`)
|
13 | })
|
14 | } else if (context.flags.json) {
|
15 | cli.styledJSON(config)
|
16 | } else {
|
17 | cli.styledHeader(`${coupling.pipeline.name} test config vars`)
|
18 | cli.styledObject(Object.keys(config).reduce((memo, key) => {
|
19 | memo[cli.color.green(key)] = config[key]
|
20 | return memo
|
21 | }, {}))
|
22 | }
|
23 | }
|
24 |
|
25 | module.exports = {
|
26 | topic: 'ci',
|
27 | command: 'config',
|
28 | needsApp: true,
|
29 | needsAuth: true,
|
30 | description: 'display CI config vars',
|
31 | flags: [
|
32 | {name: 'shell', char: 's', description: 'output config vars in shell format'},
|
33 | {name: 'json', description: 'output config vars in json format'}
|
34 | ],
|
35 | run: cli.command(co.wrap(run))
|
36 | }
|