heroku-cli-addons
Advanced tools
Comparing version 1.1.4 to 1.1.5
@@ -7,2 +7,4 @@ 'use strict' | ||
function * run (context, heroku) { | ||
const util = require('../../lib/util') | ||
let app = context.app | ||
@@ -27,8 +29,4 @@ let addon = yield heroku.get(`/addons/${encodeURIComponent(context.args.addon_name)}`) | ||
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)) | ||
}) | ||
let attachment = yield util.trapConfirmationRequired(context, (confirm) => createAttachment(app, context.flags.as, confirm)) | ||
yield cli.action( | ||
@@ -35,0 +33,0 @@ `Setting ${cli.color.attachment(attachment.name)} config vars and restarting ${cli.color.app(app)}`, |
@@ -48,20 +48,23 @@ 'use strict' | ||
let {app, flags, args} = context | ||
let {name, as, confirm} = flags | ||
let {name, as} = flags | ||
let plan = {name: args[0]} | ||
let config = parseConfig(args.slice(1)) | ||
let addon | ||
function createAddon (app, config, name, confirm, plan, as) { | ||
return cli.action(`Creating ${plan.name} on ${cli.color.app(app)}`, | ||
heroku.post(`/apps/${app}/addons`, { | ||
body: { config, name, confirm, plan, attachment: {name: as} }, | ||
headers: { | ||
'accept-expansion': 'plan', | ||
'x-heroku-legacy-provider-messages': 'true' | ||
} | ||
}).then(function (addon) { | ||
cli.action.done(cli.color.green(util.formatPrice(addon.plan.price))) | ||
return addon | ||
}) | ||
) | ||
} | ||
yield cli.action(`Creating ${plan.name} on ${cli.color.app(app)}`, co(function * () { | ||
addon = yield heroku.post(`/apps/${app}/addons`, { | ||
body: { config, name, confirm, plan, attachment: {name: as} }, | ||
headers: { | ||
'accept-expansion': 'plan', | ||
'x-heroku-legacy-provider-messages': 'true' | ||
} | ||
}) | ||
let addon = yield util.trapConfirmationRequired(context, (confirm) => (createAddon(app, config, name, confirm, plan, as))) | ||
cli.action.done(cli.color.green(util.formatPrice(addon.plan.price))) | ||
})) | ||
if (addon.provision_message) { cli.log(addon.provision_message) } | ||
@@ -68,0 +71,0 @@ |
@@ -51,3 +51,13 @@ 'use strict' | ||
return state | ||
}, | ||
trapConfirmationRequired: function * (context, fn) { | ||
return yield fn(context.flags.confirm) | ||
.catch((err) => { | ||
if (!err.body || err.body.id !== 'confirmation_required') throw err | ||
return cli.confirmApp(context.app, context.flags.confirm, err.body.message) | ||
.then(() => fn(context.app)) | ||
}) | ||
} | ||
} |
{ | ||
"name": "heroku-cli-addons", | ||
"description": "`heroku addons:*` commands", | ||
"version": "1.1.4", | ||
"version": "1.1.5", | ||
"author": "Bo Jeanes @bjeanes", | ||
@@ -6,0 +6,0 @@ "bugs": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
42138
1042