Socket
Socket
Sign inDemoInstall

heroku-cli-util

Package Overview
Dependencies
Maintainers
2
Versions
155
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

heroku-cli-util - npm Package Compare versions

Comparing version 5.0.2 to 5.1.0

1

index.js

@@ -6,2 +6,3 @@ 'use strict';

exports.hush = console.hush;
exports.log = console.log.bind(console);

@@ -8,0 +9,0 @@ exports.formatDate = require('./lib/date').formatDate;

@@ -26,2 +26,3 @@ 'use strict';

function setupHttpProxy() {
cli.hush(`proxy set to ${httpsProxy}`);
let proxy = url.parse(httpsProxy);

@@ -28,0 +29,0 @@ process.env.HEROKU_HTTP_PROXY_HOST = proxy.hostname;

@@ -20,2 +20,8 @@ 'use strict';

function hush () {
if (process.env.HEROKU_DEBUG) {
console.log.apply(null, arguments);
}
}
/**

@@ -55,2 +61,3 @@ * log is a wrapper for console.error() but can be mocked

exports.hush = hush;
exports.log = log;

@@ -57,0 +64,0 @@ exports.error = error;

2

package.json
{
"name": "heroku-cli-util",
"version": "5.0.2",
"version": "5.1.0",
"description": "Set of helpful CLI utilities",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -19,5 +19,5 @@ # heroku-cli-util

```js
let h = require('heroku-cli-util');
let cli = require('heroku-cli-util');
let promise = heroku.apps(appname).info();
let app = yield h.action('getting apps', promise);
let app = yield cli.action('getting apps', promise);
console.log(`app name: ${app.name}`);

@@ -34,4 +34,4 @@

```js
var h = require('heroku-cli-util');
h.prompt('email', {}, function (_, email) {
let cli = require('heroku-cli-util');
cli.prompt('email', {}, function (_, email) {
console.log(`your email is: ${email}`);

@@ -44,4 +44,4 @@ });

```js
var h = require('heroku-cli-util');
h.prompt('email', {}).then(function (email) {
let cli = require('heroku-cli-util');
cli.prompt('email', {}).then(function (email) {
console.log(`your email is: ${email}`);

@@ -51,14 +51,18 @@ });

Generator style (must be wrapped in h.command() or co block)
Generator style (must be wrapped in cli.command() or co block)
```js
var h = require('heroku-cli-util');
var email = yield h.prompt('email', {});
let cli = require('heroku-cli-util');
let email = yield cli.prompt('email', {});
console.log(`your email is: ${email}`);
```
**Options**
**cli.prompt options**
`mask: true`: mask input field after submitting.
`hide: true`: mask characters while entering.
```js
cli.prompt('email', {
mask: true, // mask input field after submitting
hide: true // mask characters while entering
});
```

@@ -72,4 +76,4 @@ ## Confirm App

```js
var h = require('heroku-cli-util');
yield h.confirmApp('appname', context.flags.confirm);
let cli = require('heroku-cli-util');
yield cli.confirmApp('appname', context.flags.confirm);

@@ -86,4 +90,4 @@ // ! WARNING: Destructive Action

```js
var h = require('heroku-cli-util');
yield h.confirmApp('appname', context.flags.confirm, 'foo');
let cli = require('heroku-cli-util');
yield cli.confirmApp('appname', context.flags.confirm, 'foo');

@@ -99,4 +103,4 @@ // ! foo

```js
var h = require('heroku-cli-util');
h.error("App not found");
let cli = require('heroku-cli-util');
cli.error("App not found");
// ! App not found

@@ -108,4 +112,4 @@ ```

```js
var h = require('heroku-cli-util');
h.warn("App not found");
let cli = require('heroku-cli-util');
cli.warn("App not found");
// ! App not found

@@ -117,8 +121,40 @@ ```

```js
var h = require('heroku-cli-util');
var d = new Date();
console.log(h.formatDate(d));
let cli = require('heroku-cli-util');
let d = new Date();
console.log(cli.formatDate(d));
// 2001-01-01T08:00:00.000Z
```
## Hush
Use hush for verbose logging when `HEROKU_DEBUG=1`.
```js
let cli = require('heroku-cli-util');
cli.hush('foo');
// only prints if HEROKU_DEBUG is set
```
## Debug
Pretty print an object.
```js
let cli = require('heroku-cli-util');
cli.debug({foo: [1,2,3]});
// { foo: [ 1, 2, 3 ] }
```
## Mocking
Mock stdout and stderr by using `cli.log()` and `cli.error()`.
```js
let cli = require('heroku-cli-util');
cli.log('message 1'); // prints 'message 1'
cli.mockConsole();
cli.log('message 2'); // prints nothing
cli.stdout.should.eq('message 2\n');
```
## Command

@@ -129,6 +165,7 @@

It uses `co` so you can `yield` promises.
It expects you to return a promise chain. This is usually done with [co](https://github.com/tj/co).
```js
let h = require('heroku-cli-util');
let cli = require('heroku-cli-util');
let co = require('co');
module.exports.commands = [

@@ -140,5 +177,7 @@ {

needsApp: true,
run: h.command(function* (context, heroku) {
let app = yield heroku.apps(context.app).info();
console.dir(app);
run: cli.command(function (context, heroku) {
return co(function* () {
let app = yield heroku.apps(context.app).info();
console.dir(app);
});
})

@@ -152,3 +191,4 @@ }

```js
let h = require('heroku-cli-util');
let cli = require('heroku-cli-util');
let co = require('co');
module.exports.commands = [

@@ -160,7 +200,11 @@ {

needsApp: true,
run: h.command({preauth: true},
function* (context, heroku) {
let app = yield heroku.apps(context.app).info();
console.dir(app);
})
run: cli.command(
{preauth: true},
function (context, heroku) {
return co(function* () {
let app = yield heroku.apps(context.app).info();
console.dir(app);
});
}
)
}

@@ -167,0 +211,0 @@ ];

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc