Exemple #1
0
function * run (context, heroku) {
  const name = context.args['org/name']
  checkname(name)

  const d = context.flags['buildpack-dir'] || process.cwd()
  validateBuildpack(d)

  let headers = {}

  if (name.startsWith('heroku/')) {
    let secondFactor = yield cli.prompt('Two-factor code', {mask: true})
    headers['Heroku-Two-Factor-Code'] = secondFactor
  }

  yield cli.action(`Publishing ${name} buildkit`, {success: false}, co(function * () {
    const tmpdir = tmp.dirSync().name
    const tgz = path.join(tmpdir, 'buildpack.tgz')
    yield execa.shell(`cd ${d} && tar czf ${tgz} --exclude=.git .`)
    let form = new FormData()
    form.append('buildpack', fs.createReadStream(tgz))
    const response = yield submitForm(form, headers, {
      path: `/buildpacks/${name}`,
      method: 'POST',
      auth: yield http.auth(context, heroku),
      host: http.host
    })
    cli.action.done(`v${response.revision}`)
  }))
}
Exemple #2
0
  run: cli.command(co.wrap(function* (context, heroku) {
    const pipeline = yield disambiguate(heroku, context.flags.pipeline)
    const newOwner = yield getOwner(heroku, context.args.owner)
    const apps = yield api.listPipelineApps(heroku, pipeline.id)
    const displayType = { team: 'team', user: '******' }[newOwner.type]
    let confirmName = context.flags.confirm

    if (!confirmName) {
      yield renderPipeline(heroku, pipeline, apps)
      cli.log('')
      cli.warn(`This will transfer ${cli.color.pipeline(pipeline.name)} and all of the listed apps to the ${context.args.owner} ${displayType}`)
      cli.warn(`to proceed, type ${cli.color.red(pipeline.name)} or re-run this command with ${cli.color.red('--confirm')} ${pipeline.name}`)
      confirmName = yield cli.prompt('', {})
    }

    if (confirmName !== pipeline.name) {
      cli.warn(`Confirmation did not match ${cli.color.red(pipeline.name)}. Aborted.`)
      return
    }

    const promise = heroku.request({
      method: 'POST',
      path: '/pipeline-transfers',
      body: { pipeline: { id: pipeline.id }, new_owner: newOwner },
      headers: {'Accept': 'application/vnd.heroku+json; version=3.pipelines'}
    })

    yield cli.action(
      `Transferring ${cli.color.pipeline(pipeline.name)} pipeline to the ${context.args.owner} ${displayType}`,
      promise
    )
  }))
Exemple #3
0
function * run (context, heroku) {
  if (requiresPrompt(context)) {
    context.flags.owner = yield cli.prompt('Owner of this certificate')
    context.flags.country = yield cli.prompt('Country of owner (two-letter ISO code)')
    context.flags.area = yield cli.prompt('State/province/etc. of owner')
    context.flags.city = yield cli.prompt('City of owner')
  }

  let subject = getSubject(context)

  let domain = context.args.domain
  let keysize = context.flags.keysize || 2048
  let keyfile = `${domain}.key`

  let certs = yield endpoints(context.app, heroku)

  var command = getCommand(certs, domain)

  if (context.flags.selfsigned) {
    let crtfile = `${domain}.crt`

    yield openssl.spawn(['req', '-new', '-newkey', `rsa:${keysize}`, '-nodes', '-keyout', keyfile, '-out', crtfile, '-subj', subject, '-x509'])

    cli.console.error('Your key and self-signed certificate have been generated.')
    cli.console.error('Next, run:')
    cli.console.error(`$ heroku certs:${command} ${crtfile} ${keyfile}`)
  } else {
    let csrfile = `${domain}.csr`

    yield openssl.spawn(['req', '-new', '-newkey', `rsa:${keysize}`, '-nodes', '-keyout', keyfile, '-out', csrfile, '-subj', subject])

    cli.console.error('Your key and certificate signing request have been generated.')
    cli.console.error(`Submit the CSR in '${csrfile}' to your preferred certificate authority.`)
    cli.console.error("When you've received your certificate, run:")
    cli.console.error(`$ heroku certs:${command} CERTFILE ${keyfile}`)
  }
}
function* destroyTemp(context, heroku) {
  let deletableApps = yield cli.action('finding temp apps', co(findDeletableApps));
  if (!deletableApps.length) {
    cli.warn('No temp apps found');
    return;
  }

  listApps(deletableApps);
  let confirm = yield cli.prompt(`\nDestroy these ${ deletableApps.length } apps? (y/n)`);
  if (confirm.toLowerCase() === 'y' || confirm.toLowerCase === 'yes') {
    let coDestroyApp = co.wrap(destroyApp);
    yield cli.action('destroying apps', Promise.all(deletableApps.map(coDestroyApp)));
  }

  function* findDeletableApps() {
    let account = yield heroku.account().info();
    let apps = yield heroku.apps().list();
    let myApps = apps.filter(appOwnedBy(account));
    let tempApps = myApps.filter(appHasTempName);
    let coAppWithCollabs = co.wrap(appWithCollabs);
    let tempAppsWithCollabs = yield Promise.all(tempApps.map(coAppWithCollabs));
    let deletableApps = tempAppsWithCollabs.filter(appHasOneOwner);

    return deletableApps;
  }

  function listApps(apps) {
    let appNames = apps.map((a) => a.name);
    console.log();
    appNames.forEach((name, i) => { console.log(`${ i+1 }. ${ name }`); });
  }

  function* appWithCollabs(app) {
    let collabs = yield heroku.apps(app.name).collaborators().list();
    let collabEmails = collabs.map((c) => c.user.email);
    return assign(cloneDeep(app), { collaborators: collabEmails });
  }

  function* destroyApp(app) {
    return yield heroku.apps(app.name).delete();
  }
}