npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@heroku/heroku-cli-util

v8.0.15

Published

Set of helpful CLI utilities

Downloads

22,408

Maintainers

srishtigautamsrishtigautamaklimaiteaklimaitejsullivandigsjsullivandigsjulianduque-sfdcjulianduque-sfdccwallsfcwallsfmsaminenimsaminenijeffrey.estradajeffrey.estradadlira-sfdlira-sfntonollierntonollierdaebumleedaebumleetetsuya_tetsuya_mttrmttrelearyelearysalesforce-releasessalesforce-releasesbhawnaherokubhawnaherokurevativelagadarevativelagadadboston528dboston528anujpandey001anujpandey001sripad.kulkarnisripad.kulkarnibemory-herokubemory-herokuchetankd10chetankd10rafaydinrafaydinkbaird-sfkbaird-sfkscareykscareycbaxtersfcbaxtersfryoneyamaryoneyamaadirasanamadirasanammengxiao.zhaomengxiao.zhaonrisaronrisarocmarcojoscmarcojosadirksmeieradirksmeiermgates-salesforcemgates-salesforceademusoyoademusoyoelzoonaelzoonachristopher.josechristopher.josejondaniel-sfdcjondaniel-sfdcdhagberg-sfdhagberg-sfbencdentonbencdentonlsangalang2023lsangalang2023marcelsfdcmarcelsfdcccaseyccaseyjoeybrown90sfjoeybrown90sfsuppadasuppadadiana.doherty.sfdcdiana.doherty.sfdcryanbrainardryanbrainardrsoerensenrsoerensenjasoncummings-herokujasoncummings-herokusconklinsconklinbrock-salesforcebrock-salesforcetkoh-sfdctkoh-sfdcgnettergnettercoreypurcell_salesforcecoreypurcell_salesforceswapnilghoseswapnilghosestessema-sfcstessema-sfcjmonrealjmonrealbrittany.jonesbrittany.jonesnnaidu9nnaidu9rstiltonsfrstiltonsfnilamuthunilamuthusghaffarsghaffarcdwort-sfdccdwort-sfdcagatpareekagatpareekaaronromeosfdcaaronromeosfdckpremkumarkpremkumarrchandarchanda7ftz7ftzxx-sfdc-npmxx-sfdc-npmcv88cv88ekozilforceekozilforceumarsfdcumarsfdcbeanieboibeanieboindavidson-sfndavidson-sfmingzhi-liu1258mingzhi-liu1258angelcampbellangelcampbellmandeepsfmandeepsfyann_ckyann_ckdasofieidasofieirajashri-gurusamyrajashri-gurusamysudarshanhiraysudarshanhirayalex_herokualex_herokusbosio_sfsbosio_sfsarahoh2468sarahoh2468justinwilaby-sfjustinwilaby-sfcmcclung-npm-salesforce.comcmcclung-npm-salesforce.comtlowrimoretlowrimorejonnymacjonnymacvish_herokuvish_herokuharish.457harish.457paulaprado18paulaprado18ptemporiniptemporinitcareysmith-sfdctcareysmith-sfdcrobinson.mrobinson.mgrundy.ggrundy.gdkabanov1dkabanov1cgfuhcgfuhrdagg-herordagg-herok80bowmank80bowmansheax0rsheax0rdpark.herokudpark.herokuafraidknotafraidknotdaniel.brightdaniel.brightjdowningjdowningabhinavkoulabhinavkouljoshwlewis-sfdcjoshwlewis-sfdcviniljainviniljaineblackeblackk.plentyk.plentyapadalaapadalajhili!16jhili!16lsorstokkelsorstokkercrossrcrosskdreyerorenkdreyerorendhammer25dhammer25tenharmsel_sftenharmsel_sfdougmcinnes-sfdcdougmcinnes-sfdchillzbot2000hillzbot2000chap-herokuchap-herokumichellejhlimmichellejhlimmbuschherokumbuschherokureidmixreidmixbeckychenbeckychensmrutisamantasmrutisamantaapoorvasrivapoorvasrivsfalansfalanp.shreyap.shreyasai_harshitha_neelasai_harshitha_neelanlanattanlanattavammundravammundradreichenbergdreichenbergkamakshinagarkamakshinagarvlazukavlazukamarsmarsheroku-front-endheroku-front-endrichatiwaririchatiwariwchrisjohnsonwchrisjohnsonthe7okathe7okasimonebonettisfitasimonebonettisfitalucaszhoulucaszhoupsalimpsalimnrenkenrenketaylor.jonestaylor.jonesangelayoungangelayoungmble-sfdc-2mble-sfdc-2ktsforcektsforcehkiihkiikerry-bennettkerry-bennettpranamsharmapranamsharmasfjonnpmsfjonnpmcory.steelecory.steelegkomminenigkomminenikmichalskiskmichalskissmukusmukuykatzykatzdgallegossfdcdgallegossfdcdzuelke-sfdcdzuelke-sfdcrishabh.wasonrishabh.wasonsarassassinsarassassinarajaarajav.anandv.anandlmckenzielmckenziejordaneekeyjordaneekeyjmccartiejmccartiedaigo-herokudaigo-herokumimenmimenjheikesjheikesjwadsworthsfjwadsworthsfsaikrishna0202saikrishna0202pfuentepfuentemontes_herokumontes_herokubleongbleongpaguilarpaguilarjoanneyeungjoanneyeungsbaner18sbaner18zli-sfzli-sflalitreddylalitreddypbommapbommamarcusblankenshipmarcusblankenshipsruthichsruthichmgomes-herokumgomes-herokujesse.brown-sfjesse.brown-sftij005tij005tholschuh-salesforcetholschuh-salesforcetholmes-sfdctholmes-sfdcannajohnson-sfannajohnson-sfvjohnevjohne

Keywords

Readme

Heroku CLI Utilities

GitHub Actions CI npm version License

Set of helpful CLI utilities

Installation

npm install heroku-cli-util --save

Action

let cli = require('heroku-cli-util');
await cli.action('restarting dynos', async function() {
  let app = await heroku.get(`/apps/${context.app}`);
  await heroku.request({method: 'DELETE', path: `/apps/${app.name}/dynos`});
});

// restarting dynos... done

Prompt

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

cli.prompt options

cli.prompt('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 = require('heroku-cli-util');
await cli.confirmApp('appname', context.flags.confirm);

// !     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 = require('heroku-cli-util');
await cli.confirmApp('appname', context.flags.confirm, 'foo');

// !     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 = require('heroku-cli-util');
cli.error("App not found");
// !    App not found

Warnings

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

Dates

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.

let cli = require('heroku-cli-util');
cli.hush('foo');
// only prints if HEROKU_DEBUG is set

Debug

Pretty print an object.

let cli = require('heroku-cli-util');
cli.debug({foo: [1,2,3]});
// { foo: [ 1, 2, 3 ] }

Stylized output

Pretty print a header, hash, and JSON

let cli = require('heroku-cli-util');
cli.styledHeader("MyApp");
cli.styledHash({name: "myapp", collaborators: ["[email protected]", "[email protected]"]});
cli.styledJSON({name: "myapp"});

Produces

=== MyApp
Collaborators: [email protected]
               [email protected]
Name:          myapp

{
  "name": "myapp"
}

Table

cli.table([
  {app: 'first-app',  language: 'ruby', dyno_count: 3},
  {app: 'second-app', language: 'node', dyno_count: 2},
], {
  columns: [
    {key: 'app'},
    {key: 'dyno_count', label: 'Dyno Count'},
    {key: 'language', format: language => cli.color.red(language)},
  ]
});

Produces:

app         Dyno Count  language
──────────  ──────────  ────────
first-app   3           ruby
second-app  2           node

Linewrap

Used to indent output with wrapping around words:

cli.log(cli.linewrap(2, 10, 'this is text is longer than 10 characters'));
// Outputs:
//
// this
// text is
//  longer
//  than 10
//  characters`);

Useful with process.stdout.columns || 80.

Open Web Browser

await cli.open('https://github.com');

HTTP calls

heroku-cli-util includes an instance of got that will correctly use HTTP proxies.

let cli = require('heroku-cli-util');
let rsp = await cli.got('https://google.com');

Mocking

Mock stdout and stderr by using cli.log() and cli.error().

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

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 = require('heroku-cli-util');
let co  = require('co');
module.exports.commands = [
  {
    topic: 'apps',
    command: 'info',
    needsAuth: true,
    needsApp: true,
    run: cli.command(async function (context, heroku) {
      let app = await heroku.get(`/apps/${context.app}`);
      console.dir(app);
    })
  }
];

With options:

let cli = require('heroku-cli-util');
let co  = require('co');
module.exports.commands = [
  {
    topic: 'apps',
    command: 'info',
    needsAuth: true,
    needsApp: true,
    run: cli.command(
      {preauth: true},
      async function (context, heroku) {
        let app = await heroku.get(`/apps/${context.app}`);
        console.dir(app);
      }
    )
  }
];

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 install
npm test

License

ISC