heroku-cli-addons
Advanced tools
Comparing version 1.2.9 to 1.2.10
@@ -28,3 +28,3 @@ 'use strict' | ||
let attachment = yield util.trapConfirmationRequired(context, (confirm) => createAttachment(app, context.flags.as, confirm)) | ||
let attachment = yield util.trapConfirmationRequired(context.app, context.flags.confirm, (confirm) => createAttachment(app, context.flags.as, confirm)) | ||
@@ -31,0 +31,0 @@ yield cli.action( |
@@ -5,3 +5,2 @@ 'use strict' | ||
const co = require('co') | ||
let waitForAddonProvisioning = require('../../lib/addons_wait') | ||
@@ -35,55 +34,11 @@ function parseConfig (args) { | ||
function formatConfigVarsMessage (addon) { | ||
let configVars = (addon.config_vars || []) | ||
if (configVars.length > 0) { | ||
configVars = configVars.map(c => cli.color.configVar(c)).join(', ') | ||
return `Created ${cli.color.addon(addon.name)} as ${configVars}` | ||
} else { | ||
return `Created ${cli.color.addon(addon.name)}` | ||
} | ||
} | ||
function * run (context, heroku) { | ||
const util = require('../../lib/util') | ||
let createAddon = require('../../lib/create_addon') | ||
let {app, flags, args} = context | ||
let {name, as} = flags | ||
let plan = {name: args[0]} | ||
let config = parseConfig(args.slice(1)) | ||
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 | ||
}) | ||
) | ||
} | ||
let addon = yield createAddon(heroku, app, args[0], context.flags.confirm, context.flags.wait, {config, name, as}) | ||
let addon = yield util.trapConfirmationRequired(context, (confirm) => (createAddon(app, config, name, confirm, plan, as))) | ||
if (addon.provision_message) { cli.log(addon.provision_message) } | ||
if (addon.state === 'provisioning') { | ||
if (context.flags.wait) { | ||
cli.log(`Waiting for ${cli.color.addon(addon.name)}...`) | ||
addon = yield waitForAddonProvisioning(context, heroku, addon, 5) | ||
cli.log(formatConfigVarsMessage(addon)) | ||
} else { | ||
cli.log(`${cli.color.addon(addon.name)} is being created in the background. The app will restart when complete...`) | ||
cli.log(`Use ${cli.color.cmd('heroku addons:info ' + addon.name)} to check creation progress`) | ||
} | ||
} else if (addon.state === 'deprovisioned') { | ||
throw new Error(`The add-on was unable to be created, with status ${addon.state}`) | ||
} else { | ||
cli.log(formatConfigVarsMessage(addon)) | ||
} | ||
cli.log(`Use ${cli.color.cmd('heroku addons:docs ' + addon.addon_service.name)} to view documentation`) | ||
@@ -90,0 +45,0 @@ } |
@@ -26,3 +26,3 @@ 'use strict' | ||
for (let addon of addons) { | ||
addon = yield waitForAddonProvisioning(ctx, api, addon, interval) | ||
addon = yield waitForAddonProvisioning(api, addon, interval) | ||
@@ -29,0 +29,0 @@ let configVars = (addon.config_vars || []) |
@@ -27,1 +27,2 @@ 'use strict' | ||
exports.resolve = require('./lib/resolve') | ||
exports.createAddon = require('./lib/create_addon') |
@@ -6,3 +6,3 @@ 'use strict' | ||
module.exports = function * (context, api, addon, interval) { | ||
module.exports = function * (api, addon, interval) { | ||
const wait = require('co-wait') | ||
@@ -9,0 +9,0 @@ const app = addon.app.name |
@@ -41,8 +41,8 @@ 'use strict' | ||
trapConfirmationRequired: function * (context, fn) { | ||
return yield fn(context.flags.confirm) | ||
trapConfirmationRequired: function * (app, confirm, fn) { | ||
return yield fn(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)) | ||
return cli.confirmApp(app, confirm, err.body.message) | ||
.then(() => fn(app)) | ||
}) | ||
@@ -49,0 +49,0 @@ }, |
{ | ||
"name": "heroku-cli-addons", | ||
"description": "`heroku addons:*` commands", | ||
"version": "1.2.9", | ||
"version": "1.2.10", | ||
"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
125746
25
1195