heroku-cli-addons
Advanced tools
Comparing version 1.1.6 to 1.1.7
@@ -5,2 +5,3 @@ 'use strict' | ||
const co = require('co') | ||
let waitForAddonProvisioning = require('../../lib/addons_wait') | ||
@@ -17,2 +18,3 @@ function parseConfig (args) { | ||
val = val.join('=') | ||
if (val === 'true') { val = true } | ||
config[key] = val | ||
@@ -34,2 +36,13 @@ } else { | ||
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) { | ||
@@ -60,9 +73,19 @@ const util = require('../../lib/util') | ||
if (addon.config_vars.length) { | ||
let configVars = addon.config_vars.map(c => cli.color.configVar(c)).join(', ') | ||
cli.log(`Created ${cli.color.addon(addon.name)} as ${configVars}`) | ||
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(`Created ${cli.color.addon(addon.name)}`) | ||
cli.log(formatConfigVarsMessage(addon)) | ||
} | ||
if (addon.provision_message) cli.log(addon.provision_message) | ||
cli.log(`Use ${cli.color.cmd('heroku addons:docs ' + addon.addon_service.name)} to view documentation`) | ||
@@ -81,3 +104,4 @@ } | ||
{name: 'as', description: 'name for the initial add-on attachment', hasValue: true}, | ||
{name: 'confirm', description: 'overwrite existing config vars or existing add-on attachments', hasValue: true} | ||
{name: 'confirm', description: 'overwrite existing config vars or existing add-on attachments', hasValue: true}, | ||
{name: 'wait', description: 'watch add-on creation status and exit when complete'} | ||
], | ||
@@ -84,0 +108,0 @@ run: cli.command({preauth: true}, co.wrap(run)) |
@@ -11,2 +11,3 @@ 'use strict' | ||
const formatPrice = util.formatPrice | ||
const formatState = util.formatState | ||
const printf = require('printf') | ||
@@ -125,2 +126,19 @@ | ||
} | ||
}, | ||
{ | ||
key: 'state', | ||
label: 'State', | ||
format: function (state) { | ||
switch (state) { | ||
case 'provisioned': | ||
state = 'created' | ||
break | ||
case 'provisioning': | ||
state = 'creating' | ||
break | ||
case 'deprovisioned': | ||
state = 'errored' | ||
} | ||
return state | ||
} | ||
}] | ||
@@ -209,2 +227,6 @@ }) | ||
} | ||
}, { | ||
label: 'State', | ||
key: 'state', | ||
format: formatState | ||
}], | ||
@@ -211,0 +233,0 @@ |
@@ -7,2 +7,3 @@ 'use strict' | ||
let formatPrice = require('../../lib/util').formatPrice | ||
let formatState = require('../../lib/util').formatState | ||
let style = require('../../lib/util').style | ||
@@ -31,3 +32,4 @@ | ||
'Owning app': style('app', addon.app.name), | ||
'Installed at': (new Date(addon.created_at)).toString() | ||
'Installed at': (new Date(addon.created_at)).toString(), | ||
'State': formatState(addon.state) | ||
}) | ||
@@ -34,0 +36,0 @@ }) |
@@ -22,5 +22,6 @@ 'use strict' | ||
require('./commands/addons/services'), | ||
require('./commands/addons/upgrade') | ||
require('./commands/addons/upgrade'), | ||
require('./commands/addons/wait') | ||
]) | ||
exports.resolve = require('./lib/resolve') |
@@ -43,3 +43,20 @@ 'use strict' | ||
}) | ||
}, | ||
formatState: function (state) { | ||
switch (state) { | ||
case 'provisioned': | ||
state = 'created' | ||
break | ||
case 'provisioning': | ||
state = 'creating' | ||
break | ||
case 'deprovisioned': | ||
state = 'errored' | ||
break | ||
default: | ||
state = '' | ||
} | ||
return state | ||
} | ||
} |
{ | ||
"name": "heroku-cli-addons", | ||
"description": "`heroku addons:*` commands", | ||
"version": "1.1.6", | ||
"version": "1.1.7", | ||
"author": "Bo Jeanes @bjeanes", | ||
@@ -11,2 +11,3 @@ "bugs": { | ||
"co": "4.6.0", | ||
"co-wait": "0.0.0", | ||
"heroku-cli-util": "6.0.15", | ||
@@ -13,0 +14,0 @@ "lodash.flatten": "4.3.0", |
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
40954
23
1014
12
+ Addedco-wait@0.0.0
+ Addedco-wait@0.0.0(transitive)