Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const rmKey = (cacheKey: string) => fs.remove(path.join(completionsDir, cacheKey))
if (type === 'app') return rmKey('app')
if (type === 'addon' && app) return rmKey(`${app}_addons`)
if (type === 'config' && app) return rmKey(`${app}_config_vars`)
if (logInOut) return rm()
const update = async (completion: any, cacheKey: string) => {
const cachePath = path.join(completionsDir, cacheKey)
const options = await completion.options({config: this.config})
await updateCache(cachePath, options)
}
// if user is not logged in, exit
try {
const heroku = new APIClient(this.config)
if (!heroku.auth) return
await heroku.get('/account', {retryAuth: false})
} catch (err) {
this.debug(err.message)
return
}
cli.action.start('Updating completions')
await rm()
await acCreate.run([], this.config)
try {
await update(AppCompletion, 'app')
await update(PipelineCompletion, 'pipeline')
await update(SpaceCompletion, 'space')
await update(TeamCompletion, 'team')
protected constructor(argv: string[], config: IConfig) {
super(argv, config)
const client = new APIClient(this.config, {})
client.defaults.headers = {
...this.heroku.defaults.headers,
Accept: 'application/vnd.heroku+json; version=3.webhooks',
authorization: `Basic ${Buffer.from(':' + this.heroku.auth).toString('base64')}`
}
this.webhooksClient = client
}
options: async (ctx: any) => {
const heroku = new APIClient(ctx.config)
if (ctx.flags && ctx.flags.app) {
let {body: configs} = await heroku.get(`/apps/${ctx.flags.app}/config-vars`, {retryAuth: false})
return Object.keys(configs)
}
return []
},
}