How to use the @heroku-cli/command.flags.pipeline function in @heroku-cli/command

To help you get started, we’ve selected a few @heroku-cli/command examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github heroku / cli / packages / ci / src / commands / ci / run.ts View on Github external
import * as Kolkrabbi from '../../interfaces/kolkrabbi'
import * as git from '../../utils/git'
import {getPipeline} from '../../utils/pipelines'
import {createSourceBlob} from '../../utils/source'
import {displayAndExit} from '../../utils/test-run'
export default class CiRun extends Command {
  static description = 'run tests against current directory'

  static examples = [
    `$ heroku ci:run --app murmuring-headland-14719
`,
  ]

  static flags = {
    app: flags.string({char: 'a', description: 'app name'}),
    pipeline: flags.pipeline({required: false})
  }

  async run() {
    const {flags} = this.parse(CiRun)
    const pipeline = await getPipeline(flags, this)
    const commit = await git.readCommit('HEAD')

    cli.action.start('Preparing source')
    const sourceBlobUrl = await createSourceBlob(commit.ref, this)
    cli.action.stop()

    cli.action.start('Starting test run')
    const {body: pipelineRepository} = await this.heroku.get(`https://kolkrabbi.heroku.com/pipelines/${pipeline.id}/repository`)
    const organization = pipelineRepository.organization && pipelineRepository.organization.name
    const {body: testRun} = await this.heroku.post('/test-runs', {body: {
      commit_branch: commit.branch,
github heroku / cli / packages / webhooks / src / commands / webhooks / deliveries / index.ts View on Github external
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, {
      headers: {
        Range: `seq ..; order=desc,max=${max}`
      },
github heroku / cli / packages / pipelines / src / commands / pipelines / transfer.ts View on Github external
static examples = [
    '$ heroku pipelines:transfer admin@example.com -p my-pipeline',
    '$ heroku pipelines:transfer admin-team -p my-pipeline',
  ]

  static args = [
    {
      name: 'owner',
      description: 'the owner to transfer the pipeline to',
      required: true,
    },
  ]

  static flags = {
    pipeline: flags.pipeline({required: true}),
    confirm: flags.string({char: 'c'}),
  }

  async run() {
    const {args, flags} = this.parse(PipelinesTransfer)
    const pipeline = await disambiguate(this.heroku, flags.pipeline)
    const newOwner = await getOwner(this.heroku, args.owner)
    const apps = await listPipelineApps(this.heroku, pipeline.id!)
    const displayType = newOwner.type === 'user' ? 'account' : newOwner.type
    let confirmName = flags.confirm

    if (!confirmName) {
      await renderPipeline(this.heroku, pipeline, apps)
      cli.log('')
      cli.warn(`This will transfer ${color.pipeline(pipeline.name!)} and all of the listed apps to the ${args.owner} ${displayType}`)
      cli.warn(`to proceed, type ${color.red(pipeline.name!)} or re-run this command with ${color.red('--confirm')} ${pipeline.name}`)
github heroku / cli / packages / ci / src / commands / ci / index.ts View on Github external
import {getPipeline} from '../../utils/pipelines'
import {renderList} from '../../utils/test-run'

export default class CiIndex extends Command {
  static description = 'display the most recent CI runs for the given pipeline'

  static examples = [
    `$ heroku ci --app murmuring-headland-14719
`,
  ]

  static flags = {
    app: flags.string({char: 'a', description: 'app name'}),
    watch: flags.boolean({description: 'keep running and watch for new and update tests', required: false}),
    pipeline: flags.pipeline({required: false}),
    json: flags.boolean({description: 'output in json format', required: false})
  }

  async run() {
    const {flags} = this.parse(CiIndex)
    const pipeline = await getPipeline(flags, this)
    const {body: testRuns} = await this.heroku.get(`/pipelines/${pipeline.id}/test-runs`)

    await renderList(this, testRuns, pipeline, flags.watch, flags.json)
  }
}
github heroku / cli / packages / ci / src / commands / ci / last.ts View on Github external
import {getPipeline} from '../../utils/pipelines'
import {displayTestRunInfo} from '../../utils/test-run'

export default class CiLast extends Command {
  static description = 'looks for the most recent run and returns the output of that run'

  static examples = [
    `$ heroku ci:last --pipeline=my-pipeline --node 100
`,
  ]

  static flags = {
    app: flags.string({char: 'a', description: 'app name'}),
    node: flags.string({description: 'the node number to show its setup and output', required: false}),
    pipeline: flags.pipeline({required: false})
  }

  async run() {
    const {flags} = this.parse(CiLast)
    const pipeline = await getPipeline(flags, this)
    const headers = {Range: 'number ..; order=desc,max=1'}
    const {body: latestTestRuns} = await this.heroku.get(`/pipelines/${pipeline.id}/test-runs`, {headers})

    if (latestTestRuns.length === 0) {
      return cli.warn('No Heroku CI runs found for the specified app and/or pipeline.')
    }

    const {body: testRun} = await this.heroku.get(`/pipelines/${pipeline.id}/test-runs/${latestTestRuns[0].number}`)
    const {body: testNodes} = await this.heroku.get(`/test-runs/${testRun.id}/test-nodes`)

    await displayTestRunInfo(this, testRun, testNodes, flags.node)
github heroku / cli / packages / webhooks / src / commands / webhooks / update.ts View on Github external
import {flags} from '@heroku-cli/command'
import {cli} from 'cli-ux'

import BaseCommand from '../base'

export default class WebhooksUpdate extends BaseCommand {
  static description = 'updates a webhook in an app'

  static examples = [
    '$ heroku webhooks:update 99999999-9999-9999-9999-999999999999 -i dyno -l notify -s 09928c40bf1b191b645174a19f7053d16a180da37332e719ef0998f4c0a2 -u https://example.com/hooks',
  ]

  static flags = {
    app: flags.app(),
    remote: flags.remote(),
    pipeline: flags.pipeline({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}),
  }

  static args = [
    {name: 'id', required: true},
  ]

  async run() {
    const {flags, args} = this.parse(WebhooksUpdate)
    const {path, display} = this.webhookType(flags)

    cli.action.start(`Updating webhook ${args.id} for ${display}`)
github heroku / cli / packages / webhooks / src / commands / webhooks / events / info.ts View on Github external
import {flags} from '@heroku-cli/command'
import {cli} from 'cli-ux'

import BaseCommand from '../../base'

export default class Info extends BaseCommand {
  static description = 'info for a webhook event on an app'

  static examples = [
    '$ heroku webhooks:events:info 99999999-9999-9999-9999-999999999999',
  ]

  static flags = {
    app: flags.app(),
    remote: flags.remote(),
    pipeline: flags.pipeline({char: 'p', description: 'pipeline on which to list', hidden: true}),
  }

  static args = [
    {name: 'id', required: true},
  ]

  async run() {
    const {flags, args} = this.parse(Info)
    const {path} = this.webhookType(flags)

    cli.warn('heroku webhooks:event:info is deprecated, please use heroku webhooks:deliveries:info')

    const {body: webhookEvent} = await this.webhooksClient.get(`${path}/webhook-events/${args.id}`)

    const obj = {
      payload: JSON.stringify(webhookEvent.payload, null, 2),
github heroku / cli / packages / webhooks / src / commands / webhooks / events / index.ts View on Github external
import {flags} from '@heroku-cli/command'
import {cli} from 'cli-ux'

import BaseCommand from '../../base'

export default class EventsIndex extends BaseCommand {
  static description = 'list webhook events on an app'

  static examples = [
    '$ heroku webhooks:events',
  ]

  static flags = {
    app: flags.app(),
    remote: flags.remote(),
    pipeline: flags.pipeline({char: 'p', description: 'pipeline on which to list', hidden: true}),
  }

  async run() {
    const {flags} = this.parse(EventsIndex)
    const {path, display} = this.webhookType(flags)

    cli.warn('heroku webhooks:event is deprecated, please use heroku webhooks:deliveries')

    const {body: events} = await this.webhooksClient.get(`${path}/webhook-events`)

    if (events.length === 0) {
      this.log(`${display} has no events`)
    } else {
      events.sort((a: any, b: any) => Date.parse(a.created_at) - Date.parse(b.created_at))

      cli.table(events, {
github heroku / cli / packages / pipelines / src / commands / reviewapps / disable.ts View on Github external
import KolkrabbiAPI from '../../kolkrabbi-api'

export default class ReviewappsDisable extends Command {
  static description = 'disable review apps and/or settings on an existing pipeline'

  static examples = [
    '$ heroku reviewapps:disable -p my-pipeline -a my-app --no-autodeploy'
  ]

  static flags = {
    app: flags.app({
      description: 'parent app used by review apps',
    }),
    remote: flags.remote(),
    pipeline: flags.pipeline({
      required: true,
    }),
    autodeploy: flags.boolean({
      description: 'disable autodeployments',
      hidden: true
    }),
    autodestroy: flags.boolean({
      description: 'disable automatically destroying review apps',
      hidden: true
    }),
    'wait-for-ci': flags.boolean({
      description: 'disable wait for CI',
      hidden: true
    }),
    'no-autodeploy': flags.boolean({
      description: 'disable autodeployments',
github heroku / cli / packages / pipelines-v5 / commands / review_apps / enable.js View on Github external
const KolkrabbiAPI = require('../../lib/kolkrabbi-api')

module.exports = {
  topic: 'reviewapps',
  command: 'enable',
  description: 'enable review apps and/or settings on an existing pipeline',
  examples: `$ heroku reviewapps:enable -p mypipeline --a myapp --autodeploy --autodestroy
Enabling review apps ...
Enabling auto deployment ...
Enabling auto destroy ...
Configuring pipeline... done`,
  needsApp: false,
  needsAuth: true,
  args: [],
  flags: [
    flags.pipeline({ name: 'pipeline', required: true, hasValue: true }),
    {
      name: 'app',
      char: 'a',
      description: 'parent app used by review apps',
      hasValue: true,
      required: true
    },
    {
      name: 'remote',
      char: 'r',
      description: 'git remote of parent app used by review apps',
      hasValue: true,
      required: false
    },
    {
      name: 'autodeploy',