heroku-cli-util
Set of helpful CLI utilities
Installation
npm install heroku-cli-util --save
Action
let cli = ; cliaction'restarting dynos' ; // restarting dynos... done
Prompt
let cli = ;let email = cliprompt'email' {};console;
cli.prompt options
cliprompt'email' mask: true // mask input field after submitting hide: true // mask characters while entering;
Confirm App
Supports the same async styles as prompt()
. Errors if not confirmed.
Basic
let cli = ; cli; // ! WARNING: Destructive Action// ! This command will affect the app appname// ! To proceed, type appname or re-run this command with --confirm appname > appname
Custom message
let cli = ; cli; // ! foo// ! To proceed, type appname or re-run this command with --confirm appname > appname
Note that you will still need to define a confirm
flag for your command.
Errors
let cli = ;cli;// ! App not found
Warnings
let cli = ;cli;// ! App not found
Dates
let cli = ;let d = ;console;// 2001-01-01T08:00:00.000Z
Hush
Use hush for verbose logging when HEROKU_DEBUG=1
.
let cli = ;cli;// only prints if HEROKU_DEBUG is set
Debug
Pretty print an object.
let cli = ;cli;// { foo: [ 1, 2, 3 ] }
Stylized output
Pretty print a header, hash, and JSON
let cli = ;cli;cli;cli;
Produces
=== MyApp
Collaborators: user1@example.com
user1@example.com
Name: myapp
{
"name": "myapp"
}
Table
cli;
Produces:
app Dyno Count language
────────── ────────── ────────
first-app 3 ruby
second-app 2 node
Linewrap
Used to indent output with wrapping around words:
cli;// Outputs://// this// text is// longer// than 10// characters`);
Useful with process.stdout.columns || 80
.
Open Web Browser
cli;
HTTP calls
heroku-cli-util
includes an instance of got that will correctly use HTTP proxies.
let cli = ;let rsp = cli;
Mocking
Mock stdout and stderr by using cli.log()
and cli.error()
.
let cli = ;cli; // prints 'message 1'cli;cli; // prints nothingclistdoutshould;
Command
Used for initializing a plugin command.
give you an auth'ed instance of heroku-client
and cleanly handle API exceptions.
It expects you to return a promise chain. This is usually done with co.
let cli = ;let co = ;moduleexportscommands = topic: 'apps' command: 'info' needsAuth: true needsApp: true run: cli ;
With options:
let cli = ;let co = ;moduleexportscommands = topic: 'apps' command: 'info' needsAuth: true needsApp: true run: cli ;
If the command has a two_factor
API error, it will ask the user for a 2fa code and retry.
If you set preauth: true
it will preauth against the current app instead of just setting the header on an app. (This is necessary if you need to do more than 1 API call that will require 2fa)
Tests
npm installnpm test
License
ISC