Comparing version 2.9.16 to 2.9.17
@@ -267,2 +267,7 @@ const util = require('util'); | ||
/** | ||
* Format markdown-style tags surrounding text in a string to ASCII color tags | ||
* \*\*blue\*\* \~\~yellow\~\~ !!red!! ##gray## ^^green^^ | ||
* @param {string} strs String to format | ||
*/ | ||
function markdown(strs) { | ||
@@ -269,0 +274,0 @@ if (process.env.AKA_NO_COLORS) { |
{ | ||
"name": "akkeris", | ||
"version": "2.9.16", | ||
"version": "2.9.17", | ||
"description": "Akkeris CLI", | ||
@@ -5,0 +5,0 @@ "main": "aka.js", |
@@ -207,7 +207,12 @@ "use strict" | ||
function format_attached_addons(addon) { | ||
return `**+ ${addon.app.name === addon.addon.app.name ? addon.addon.id : (addon.id + ' ^^attached^^' )} ${addon.name}** | ||
function format_attached_addons(appkit, addon) { | ||
const md = (s) => appkit.terminal.markdown(s); | ||
const ital = (s) => appkit.terminal.italic(s); | ||
const owner = addon.app.name === addon.addon.app.name; | ||
return md(`**+ ${owner ? addon.addon.id : addon.id} (${addon.name})** ${!owner && '🔗'} | ||
***Plan:*** ${addon.addon.plan.name} | ||
***Primary:*** ${addon.primary} | ||
***State:*** ${addon.state || 'provisioned'}\n`; | ||
***State:*** ${addon.state || 'provisioned'} | ||
${!owner && ital(`^^Attached From^^ ${it(addon.addon.app.name)}`)}\n`); | ||
} | ||
@@ -234,19 +239,22 @@ | ||
function list_all_addons(appkit, args) { | ||
appkit.api.get('/apps/' + args.app + '/addon-attachments', (err, attachments) => { | ||
if(err) { | ||
return appkit.terminal.error(err) | ||
} | ||
appkit.api.get('/apps/' + args.app + '/addons', (err, addons) => { | ||
if(err) { | ||
return appkit.terminal.error(err); | ||
} | ||
if(addons.length === 0 && attachments.length === 0) { | ||
console.log(appkit.terminal.markdown('###===### No addons (attached or owned) were found.')); | ||
} else { | ||
if(addons.length > 0) console.log(addons.map(format_addons).map(appkit.terminal.markdown).join('\n')); | ||
if(attachments.length > 0) console.log(attachments.map(format_attached_addons).map(appkit.terminal.markdown).join('\n')); | ||
} | ||
}) | ||
}); | ||
async function list_all_addons(appkit, args) { | ||
let addons, attachments; | ||
try { | ||
addons = await appkit.api.get(`/apps/${args.app}/addons`); | ||
attachments = await appkit.api.get(`/apps/${args.app}/addon-attachments`); | ||
} catch (err) { | ||
return appkit.terminal.error(err) | ||
} | ||
if(addons.length === 0 && attachments.length === 0) { | ||
console.log(appkit.terminal.markdown('###===### No addons (attached or owned) were found.')); | ||
return; | ||
} | ||
if(addons.length > 0) { | ||
console.log(addons.map(format_addons).map(appkit.terminal.markdown).join('\n')); | ||
} | ||
if(attachments.length > 0) { | ||
console.log(attachments.map(format_attached_addons.bind(null, appkit)).join('\n')); | ||
} | ||
} | ||
@@ -253,0 +261,0 @@ |
@@ -167,32 +167,42 @@ "use strict" | ||
function info(appkit, args) { | ||
async function info(appkit, args) { | ||
assert.ok(args.app && args.app !== '', 'An application name was not provided.'); | ||
appkit.api.get('/apps/' + args.app, function(err, app) { | ||
if (err){ | ||
try { | ||
const app = await appkit.api.get('/apps/' + args.app); | ||
const pipeline = await appkit.api.get('/apps/' + args.app + '/pipeline-couplings'); | ||
const ui = require('cliui')(); | ||
const md = (s) => appkit.terminal.markdown(s); | ||
const bld = (s) => md(appkit.terminal.bold(s)); | ||
const ital = (s) => md(appkit.terminal.italic(s)); | ||
const label = (s) => ({text: md(`**${s}**`), width:20}); | ||
const shortLabel = (s) => ({text: md(`**${s}**`), width:10}); | ||
ui.div(); | ||
ui.div(bld(`###===### **⬢ ${app.name}** ${app.preview ? '- ^^preview^^' : ''} ###===###`)); | ||
ui.div(label(`ID:`), app.id) | ||
ui.div(label(`Description:`), app.description) | ||
ui.div(label(`Organization:`), app.organization.name) | ||
ui.div(label(`Region:`), app.region.name) | ||
ui.div(label(`Current Image:`), app.image) | ||
ui.div(label(`Git:`), `${app.git_url}${app.git_branch ? ('#' + app.git_branch) : ''}`) | ||
ui.div(label(`Service ENV:`), `${app.simple_name.toUpperCase()}_SERVICE_HOST, ${app.simple_name.toUpperCase()}_SERVICE_PORT`) | ||
ui.div(label(`Pipeline:`), pipeline ? pipeline.pipeline.name + ' - ' + pipeline.stage : '') | ||
ui.div(label(`Last Released:`), app.released_at ? new Date(app.released_at).toLocaleString() : 'Never') | ||
ui.div(label(`URL:`), app.web_url) | ||
ui.div(); | ||
ui.div(('Additional Commands')); | ||
ui.div(shortLabel('Addons:'), ital(`aka addons -a ${app.name}`)) | ||
ui.div(shortLabel('Config:'), ital(`aka config -a ${app.name}`)) | ||
ui.div(shortLabel('Dynos:'), ital(`aka ps -a ${app.name}`)) | ||
ui.div(shortLabel('Logs:'), ital(`aka logs -a ${app.name}`)) | ||
ui.div(shortLabel('Metrics:'), ital(`aka metrics -a ${app.name}`)) | ||
console.log(ui.toString()) | ||
} catch (err) { | ||
return appkit.terminal.print(err); | ||
} | ||
appkit.api.get('/apps/' + args.app + '/addons', function(err, addons) { | ||
appkit.api.get('/apps/' + args.app + '/addon-attachments', function(err, attachments) { | ||
appkit.api.get('/apps/' + args.app + '/pipeline-couplings', function(err, pipeline) { | ||
appkit.api.get('/apps/' + args.app + '/formation', function(err, dynos) { | ||
console.log(appkit.terminal.markdown(`###===### **⬢ ${app.name}** ${app.preview ? '- ^^preview^^' : ''} | ||
**ID:**\t\t${app.id} | ||
**Description:**\t\t${app.description} | ||
**Addons:**\t${addons ? addons.map((x) => { return '\t' + x.name; }).join('\n\t\t') : ''} | ||
**Attached Addons:**\t${attachments ? attachments.map((x) => { return '\t' + x.name; }).join('\n\t\t') : ''} | ||
**Dynos:**\t${dynos ? dynos.map((x) => { return '\t' + x.type + ': ' + x.quantity}).join('\n\t\t') : ''} | ||
**Pipeline:**\t\t${pipeline ? pipeline.pipeline.name + ' - ' + pipeline.stage : ''} | ||
**Git:**\t\t\t${app.git_url}${app.git_branch ? ('#' + app.git_branch) : ''} | ||
**Last Released:**\t${app.released_at ? new Date(app.released_at).toLocaleString() : 'Never'} | ||
**Slug:**\t\t\t${app.image} | ||
**Owner:**\t\t${app.organization.name} | ||
**Region:**\t\t${app.region.name} | ||
**Service ENV:**\t\t${app.simple_name.toUpperCase() + '_SERVICE_HOST'}, ${app.simple_name.toUpperCase() + '_SERVICE_PORT'} | ||
**URL:**\t\t\t${app.web_url}`)); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
} | ||
} | ||
@@ -199,0 +209,0 @@ function destroy(appkit, args) { |
@@ -48,5 +48,9 @@ "use strict" | ||
} | ||
assert.ok(args.URL && args.URL !== '', 'The url for the drain was not found.'); | ||
assert.ok(args.URL.startsWith("syslog://") || args.URL.startsWith("syslog+tls://") || args.URL.startsWith("syslog+udp://") || args.URL.startsWith("http://") || args.URL.startsWith("https://"), | ||
'The specified log drain did not have a http, https, syslog, syslog+tls, or syslog+udp scheme. Invalid URL.'); | ||
try { | ||
assert.ok(args.URL && args.URL !== '', 'The url for the drain was not found.'); | ||
assert.ok(args.URL.startsWith("syslog://") || args.URL.startsWith("syslog+tls://") || args.URL.startsWith("syslog+udp://") || args.URL.startsWith("http://") || args.URL.startsWith("https://"), | ||
'The specified log drain did not have a http, https, syslog, syslog+tls, or syslog+udp scheme. Invalid URL.'); | ||
} catch (e) { | ||
return appkit.terminal.error(e); | ||
} | ||
let payload = {url:args.URL}; | ||
@@ -53,0 +57,0 @@ |
@@ -7,15 +7,20 @@ "use strict" | ||
function format_release(appkit, release) { | ||
let state = ''; | ||
if(release.state === 'pending') { | ||
let state = ' ~~●~~ '; | ||
if(release.status === 'succeeded') { | ||
if(release.state === 'pending') { | ||
state = ' ~~●~~ '; | ||
} else if(release.state === 'failure') { | ||
state = ' !!✕!! '; | ||
} else if(release.state === 'error') { | ||
state = ' !!⚠!! '; | ||
} else { | ||
state = ' ^^^✓^^^ '; | ||
} | ||
} else if (release.status === 'pending' || release.status === 'queued') { | ||
state = ' ~~●~~ '; | ||
} | ||
if(release.state === 'failure') { | ||
state = ' !!✕!! '; | ||
} | ||
if(release.state === 'error') { | ||
} else if(release.status === 'failed') { | ||
state = ' !!⚠!! '; | ||
} else { | ||
state = ` ###●### `; | ||
} | ||
if(release.state === 'success') { | ||
state = ' ^^^✓^^^ '; | ||
} | ||
if(release.build) { | ||
@@ -22,0 +27,0 @@ let info = [ |
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
249115
6545