Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Commit

Permalink
standardify
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff Dickey committed Apr 21, 2016
1 parent 828b660 commit 513861b
Show file tree
Hide file tree
Showing 32 changed files with 1,383 additions and 1,411 deletions.
1 change: 0 additions & 1 deletion .jshintignore

This file was deleted.

41 changes: 0 additions & 41 deletions .jshintrc

This file was deleted.

44 changes: 22 additions & 22 deletions commands/addons/attach.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
'use strict';
'use strict'

let cli = require('heroku-cli-util');
let co = require('co');
let cli = require('heroku-cli-util')
let co = require('co')

function* run (context, heroku) {
let app = context.app;
let addon = yield heroku.get(`/addons/${context.args.addon_name}`);
function * run (context, heroku) {
let app = context.app
let addon = yield heroku.get(`/addons/${context.args.addon_name}`)

function createAttachment(app, as, confirm) {
function createAttachment (app, as, confirm) {
return cli.action(
`Attaching ${cli.color.addon(addon.name)}${as ? ' as ' + cli.color.attachment(as) : ''} to ${cli.color.app(app)}`,
heroku.request({
path: '/addon-attachments',
method: 'POST',
body: {
name: as,
app: {name: app},
name: as,
app: {name: app},
addon: {name: addon.name},
confirm,
confirm
}
})
);
)
}

let attachment = yield createAttachment(app, context.flags.as, context.flags.confirm)
.catch(err => {
if (!err.body || err.body.id !== 'confirmation_required') throw err;
return cli.confirmApp(app, context.flags.confirm, err.body.message)
.then(() => createAttachment(app, context.flags.as, app));
});
.catch((err) => {
if (!err.body || err.body.id !== 'confirmation_required') throw err
return cli.confirmApp(app, context.flags.confirm, err.body.message)
.then(() => createAttachment(app, context.flags.as, app))
})
let releases = yield cli.action(
`Setting ${cli.color.attachment(attachment.name)} config vars and restarting ${cli.color.app(app)}`,
{success: false},
heroku.request({
path: `/apps/${app}/releases`,
partial: true,
headers: { 'Range': `version ..; max=1, order=desc` },
headers: { 'Range': 'version ..; max=1, order=desc' }
})
);
cli.console.error(`done, v${releases[0].version}`);
)
cli.console.error(`done, v${releases[0].version}`)
}

module.exports = {
Expand All @@ -48,9 +48,9 @@ module.exports = {
needsAuth: true,
needsApp: true,
flags: [
{name: 'as', description: 'name for add-on attachment', hasValue: true},
{name: 'confirm', description: 'overwrite existing add-on attachment with same name', hasValue: true},
{name: 'as', description: 'name for add-on attachment', hasValue: true},
{name: 'confirm', description: 'overwrite existing add-on attachment with same name', hasValue: true}
],
args: [{name: 'addon_name'}],
run: cli.command({preauth: true}, co.wrap(run))
};
}
24 changes: 12 additions & 12 deletions commands/addons/detach.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
'use strict';
'use strict'

let cli = require('heroku-cli-util');
let co = require('co');
let cli = require('heroku-cli-util')
let co = require('co')

function* run (context, heroku) {
let app = context.app;
let attachment = yield heroku.get(`/apps/${app}/addon-attachments/${context.args.attachment_name}`);
function * run (context, heroku) {
let app = context.app
let attachment = yield heroku.get(`/apps/${app}/addon-attachments/${context.args.attachment_name}`)

yield cli.action(
`Detaching ${cli.color.attachment(attachment.name)} to ${cli.color.addon(attachment.addon.name)} from ${cli.color.app(app)}`,
heroku.request({
path: `/addon-attachments/${attachment.id}`,
method: 'DELETE',
method: 'DELETE'
})
);
)

let releases = yield cli.action(
`Unsetting ${cli.color.attachment(attachment.name)} config vars and restarting ${cli.color.app(app)}`,
{success: false},
heroku.request({
path: `/apps/${app}/releases`,
partial: true,
headers: { 'Range': `version ..; max=1, order=desc` },
headers: { 'Range': 'version ..; max=1, order=desc' }
})
);
cli.console.error(`done, v${releases[0].version}`);
)
cli.console.error(`done, v${releases[0].version}`)
}

module.exports = {
Expand All @@ -35,4 +35,4 @@ module.exports = {
needsApp: true,
args: [{name: 'attachment_name'}],
run: cli.command({preauth: true}, co.wrap(run))
};
}
42 changes: 21 additions & 21 deletions commands/addons/docs.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
'use strict';
'use strict'

let cli = require('heroku-cli-util');
let co = require('co');
let resolve = require('../../lib/resolve');
let cli = require('heroku-cli-util')
let co = require('co')
let resolve = require('../../lib/resolve')

function* run (context, heroku) {
let id = context.args.addon.split(':')[0];
let addon = yield heroku.get(`/addon-services/${encodeURIComponent(id)}`).catch(() => null);
if (!addon) addon = (yield resolve.addon(heroku, context.app, id)).addon_service;
let url = `https://devcenter.heroku.com/articles/${addon.name}`;
function * run (context, heroku) {
let id = context.args.addon.split(':')[0]
let addon = yield heroku.get(`/addon-services/${encodeURIComponent(id)}`).catch(() => null)
if (!addon) addon = (yield resolve.addon(heroku, context.app, id)).addon_service
let url = `https://devcenter.heroku.com/articles/${addon.name}`

if (context.flags['show-url']) {
cli.log(url);
cli.log(url)
} else {
cli.log(`Opening ${cli.color.cyan(url)}...`);
yield cli.open(url);
cli.log(`Opening ${cli.color.cyan(url)}...`)
yield cli.open(url)
}
}

module.exports = {
topic: 'addons',
command: 'docs',
wantsApp: true,
needsAuth: true,
args: [{name: 'addon'}],
flags: [{name: 'show-url', description: 'show URL, do not open browser'}],
run: cli.command({preauth: true}, co.wrap(run)),
description: `open an add-on's Dev Center documentation in your browser`
};
topic: 'addons',
command: 'docs',
wantsApp: true,
needsAuth: true,
args: [{name: 'addon'}],
flags: [{name: 'show-url', description: 'show URL, do not open browser'}],
run: cli.command({preauth: true}, co.wrap(run)),
description: "open an add-on's Dev Center documentation in your browser"
}

0 comments on commit 513861b

Please sign in to comment.