Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (secret) {
cli.styledHeader('Webhooks Signing Secret')
cli.log(secret)
}
}
}
Add.description = 'add a webhook to an app'
Add.examples = [
'$ heroku webhooks:add -i api:dyno -l notify -u https://example.com/hooks'
]
Add.flags = {
app: flags.app(),
remote: flags.remote(),
pipeline: flags.string({ char: 'p', description: 'pipeline on which to list', hidden: true }),
include: flags.string({ char: 'i', description: 'comma delimited event types your server will receive ', required: true }),
level: flags.string({ char: 'l', description: 'notify does not retry, sync will retry until successful or timeout', required: true }),
secret: flags.string({ char: 's', description: 'value to sign delivery with in Heroku-Webhook-Hmac-SHA256 header' }),
authorization: flags.string({ char: 't', description: 'authoriation header to send with webhooks' }),
url: flags.string({ char: 'u', description: 'URL for receiver', required: true })
}
module.exports = Add
export default class DomainsIndex extends Command {
static description = 'list domains for an app'
static examples = [
`$ heroku domains
=== example Heroku Domain
example.herokuapp.com
=== example Custom Domains
Domain Name DNS Record Type DNS Target
www.example.com CNAME www.example.herokudns.com
`, "$ heroku domains --filter 'Domain Name=www.example.com'"]
static flags = {
help: flags.help({char: 'h'}),
app: flags.app({required: true}),
remote: flags.remote(),
json: flags.boolean({description: 'output in json format', char: 'j'}),
...cli.table.flags({except: 'no-truncate'})
}
async run() {
const {flags} = this.parse(DomainsIndex)
const {body: domains} = await this.heroku.get>(`/apps/${flags.app}/domains`)
const herokuDomain = domains.find(domain => domain.kind === 'heroku')
const customDomains = domains.filter(domain => domain.kind === 'custom')
if (flags.json) {
cli.styledJSON(domains)
} else {
cli.styledHeader(`${flags.app} Heroku Domain`)
cli.log(herokuDomain && herokuDomain.hostname)
import {Command, flags as Flags} from '@heroku-cli/command'
import {cli} from 'cli-ux'
import {BuildpackCommand} from '../../buildpacks'
export default class Remove extends Command {
static description = 'remove a buildpack set on the app'
static flags = {
app: Flags.app({required: true}),
remote: Flags.remote(),
index: Flags.integer({
description: 'the 1-based index of the URL to remove from the list of URLs',
char: 'i',
}),
}
static args = [
{
name: 'buildpack',
description: 'namespace/name of the buildpack',
},
]
async run() {
const {args, flags} = this.parse(Remove)
import logDisplayer from '../lib/log-displayer'
export default class Logs extends Command {
static description = `display recent log output
disable colors with --no-color, HEROKU_LOGS_COLOR=0, or HEROKU_COLOR=0`
static examples = [
'$ heroku logs --app=my-app',
'$ heroku logs --num=50',
'$ heroku logs --dyno=web --app=my-app',
'$ heroku logs --app=my-app --tail'
]
static flags = {
app: flags.app({required: true}),
remote: flags.remote(),
num: flags.integer({char: 'n', description: 'number of lines to display'}),
ps: flags.string({char: 'p', description: 'hidden alias for dyno', hidden: true}),
dyno: flags.string({
char: 'd',
description: 'only show output from this dyno type (such as "web" or "worker")',
completion: ProcessTypeCompletion
}),
source: flags.string({char: 's', description: 'only show output from this source (such as "app" or "heroku")'}),
tail: flags.boolean({char: 't', description: 'continually stream logs'}),
'force-colors': flags.boolean({description: 'force use of colors (even on non-tty output)'})
}
async run() {
let {flags} = this.parse(Logs)
import {Command, flags} from '@heroku-cli/command'
import * as Heroku from '@heroku-cli/schema'
import {cli} from 'cli-ux'
const METRICS_HOST = 'api.metrics.heroku.com'
export default class Disable extends Command {
static description = 'disable web dyno autoscaling'
static flags = {
app: flags.app({required: true}),
remote: flags.remote(),
}
async run() {
const {flags} = this.parse(Disable)
cli.action.start('Disabling dyno autoscaling')
const appResponse = await this.heroku.get(`/apps/${flags.app}`)
const app = appResponse.body
const monitorsResponse = await this.heroku.get(`/apps/${app.id}/formation/web/monitors`, {
hostname: METRICS_HOST
})
const monitors = monitorsResponse.body
const scaleMonitor = monitors.find((m: any) => m.action_type === 'scale')
if (!scaleMonitor) throw new Error(`${flags.app} does not have autoscale enabled`)
import {flags} from '@heroku-cli/command'
import {cli} from 'cli-ux'
import BaseCommand from '../../base'
export default class Deliveries extends BaseCommand {
static description = 'list webhook deliveries on an app'
static examples = [
'$ heroku webhooks:deliveries'
]
static flags = {
app: flags.app(),
remote: flags.remote(),
status: flags.string({char: 's', description: 'filter deliveries by status'}),
pipeline: flags.pipeline({char: 'p', description: 'pipeline on which to list', hidden: true})
}
async run() {
const {flags} = this.parse(Deliveries)
let {path, display} = this.webhookType(flags)
const max = 1000
path = `${path}/webhook-deliveries`
if (flags.status) {
path += `?eq[status]=${encodeURIComponent(flags.status)}`
}
const {body: deliveries} = await this.webhooksClient.get(path, {
import {Command, flags} from '@heroku-cli/command'
import {cli} from 'cli-ux'
import {Dyno, Release} from '@heroku-cli/schema'
export default class Wait extends Command {
static description = 'wait for all dynos to be running latest version after a release'
static flags = {
app: flags.app({required: true}),
remote: flags.remote(),
type: flags.string({
char: 't',
description: 'wait for one specific dyno type',
}),
'wait-interval': flags.integer({
char: 'w',
description: 'how frequently to poll in seconds (to avoid hitting Heroku API rate limits)',
parse: input => {
const w = parseInt(input, 10)
if (w < 10) {
cli.error('wait-interval must be at least 10', {exit: 1})
}
return w
},
default: 10,
import {createCoupling} from '../../api'
import disambiguate from '../../disambiguate'
import infer from '../../infer'
import {inferrableStageNames as stageNames} from '../../stages'
export default class PipelinesAdd extends Command {
static description = `add this app to a pipeline
The app and pipeline names must be specified.
The stage of the app will be guessed based on its name if not specified.`
static examples = [
'$ heroku pipelines:add my-pipeline -a my-app -s production',
]
static flags = {
app: flags.app({required: true}),
remote: flags.remote(),
stage: flags.string({
char: 's',
description: 'stage of first app in pipeline',
completion: StageCompletion,
}),
}
static args = [{
name: 'pipeline',
description: 'name of pipeline',
required: true,
}]
async run() {
const {args, flags} = this.parse(PipelinesAdd)
import {Command, flags} from '@heroku-cli/command'
import * as Heroku from '@heroku-cli/schema'
import cli from 'cli-ux'
import KolkrabbiAPI from '../../kolkrabbi-api'
export default class ReviewappsEnable extends Command {
static description = 'enable review apps and/or settings on an existing pipeline'
static examples = [
'$ heroku reviewapps:enable -p my-pipeline -a my-app --autodeploy --autodestroy',
]
static flags = {
app: flags.app({
description: 'parent app used by review apps',
}),
remote: flags.remote(),
pipeline: flags.string({
char: 'p',
description: 'name of pipeline',
required: true,
}),
autodeploy: flags.boolean({
description: 'autodeploy the review app',
}),
autodestroy: flags.boolean({
description: 'autodestroy the review app',
}),
'wait-for-ci': flags.boolean({
description: 'wait for CI to pass before deploying',
export default class ConfigEdit extends Command {
static description = `interactively edit config vars
This command opens the app config in a text editor set by $VISUAL or $EDITOR.
Any variables added/removed/changed will be updated on the app after saving and closing the file.`
static examples = [
`# edit with vim
$ EDITOR="vim" heroku config:edit`,
`# edit with emacs
$ EDITOR="emacs" heroku config:edit`,
`# edit with pico
$ EDITOR="pico" heroku config:edit`,
`# edit with atom editor
$ VISUAL="atom --wait" heroku config:edit`,
]
static flags = {
app: flags.app({required: true}),
remote: flags.remote(),
}
static args = [
{name: 'key', optional: true, description: 'edit a single key'},
]
app!: string
async run() {
const {flags: {app}, args: {key}} = this.parse(ConfigEdit)
this.app = app
cli.action.start('Fetching config')
const original = await this.fetchLatestConfig()
cli.action.stop()
let newConfig = {...original}