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

cli-step

v1.0.2

Published

Module to create yarn like steps for your cli app

Downloads

12,910

Readme

Cli steps ⛹

This module makes it super simple to show animated steps on the terminal and also track the time spent to perform those steps.

Highly inspired by yarn

Some bragging 🤘🏻

Below is the output of couple of examples of what you can do with cli-step.

Yarn style output

Publish to npm

Usage ✍️

Grab it from npm.

npm i cli-step

# yarn
yarn add cli-step
const Steps = require('cli-step')

const totalNumberOfSteps = 4
const steps = new Steps(totalNumberOfSteps)

const step1 = steps
    .advance('Resolving packages', 'mag')
    .start()

// perform your task
step1.stop()

const step2 = steps
    .advance('Fetching packages', 'truck')
    .start()

// peform next task
step2.stop()

Note 🗒️

Cli steps doesn't gives you any functionality on how to perform certain actions, it's just a module to show animated steps of the tasks you are executing.

So think of it as the UI layer for your command line app.

Why? 🤷‍♂️

  1. To produce consistent output
  2. Everyone loves emoji's
  3. Record time taken to perform all the steps.

API 👇🏻

Here's the list of methods you can call to tweak the output.

advance(text, emoji, helpLabel)

  • text ( String ) [required] The text to be printed on the terminal. It is required
  • emoji (String) [optional] Emoji to be printed just before the text. The emoji name must one of the available emojis from this list
  • helpLabel (String) [optional] The help label to be printed in DIM color. For example showing the command used to execute the task
const steps = new Steps(4)
const stepInstance = steps.advance(text, emoji, helpLabel)

startRecording

Optionally, you can start recording the time which can later be used to know the time taken to execute all the tasks. Used in yarn example

const steps = new Steps(4)
steps.startRecording()

// perform all tasks

const nanoSeconds = steps.stopRecording()

stopRecording

Used to stop recording the time. The return value is the time spent between startRecording and stopRecording in nano seconds.

A single step ☝️

Everytime you call advance it returns an instance of the step class, which can be used to tweak the output, complete a step and so on.

const step1 = steps.advance('Linting...', null, 'npm run lint')

step1.start() // start the animation

try {
 // perform task
 
 step1.success('Successfully linted', 'white_check_mark')
} catch (error) {
  step1.error('Unable to lint', 'x')
}

start

The start method starts the animation for a given step.

step.start()

success(text, emoji)

  • text ( String ) [optional] Optionally change the text on step completion
  • emoji (String) [optional] Optionally change the emoji on step completion
step1.complete()

// or change text
step1.complete('Success')

// or change text and emoji
step1.complete('Success', 'white_check_mark')

error(text, emoji)

  • text ( String ) [optional] Optionally change the text on error
  • emoji (String) [optional] Optionally change the emoji on error
step1.error()

// or change text
step1.error('Ohh no!')

// or change text and emoji
step1.error('Ohh no!', 'x')

stop()

Same as error and complete but instead doesn't accept any params and just stops the animation.

update(text)

  • text ( String ) [required] Update the step text during animation.
step1.start()

// after a while
step1.update('Changing the text')

Spinner 🤸‍♂️

The cli-spinner module is used to show the loading icon. You can tweak the behaviour by accessing the spinner property on the step instance.

const Steps = require('cli-step')
const steps = new Steps(1)

const step = steps.advance('Eating banana', 'banana')

// update the spinner string
step.spinner.setSpinnerString(10)

// start animation
step.start()

Props 🎉

The module is possible because of