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

@polite/cli

v0.0.1

Published

---- A polite and semantic command line utility powered by middleware. Written for and tested on node v8.9.1+ with support for Babel.

Downloads

3

Readme

@polite/cli


A polite and semantic command line utility powered by middleware.
Written for and tested on node v8.9.1+ with support for Babel.


How does it work?

Polite uses the please command to provide a flexible and easy-to-use command line platform for your application. Polite scans the working directory for one of the following files:

  • polite.js
  • polite.config.js
  • polite.babel.js
  • polite.{process.env.NODE_ENV}.js

You can define procedures and middleware in your configuration file, and polite provides useful help text and common libraries to aid you.


Command Line Options

  • --babel
    • Enables babel-register & babel-polyfill

Configuration Options

  • procedures   object
    • A hashmap keyed by procedure name and containing procedure objects
  • middleware   array
    • An array of middleware methods to be executed before any procedures
  • postMiddleware   array
    • An array of middleware methods to be executed after any procedures
  • babel   bool
    • Enables babel-register & babel-polyfill

Procedure Object Specification

A procedure object should contain the following keys:

  • name   string
    • a string name to be used for help text
  • description   string
    • descriptive text for use in the "help" command
  • run   fn(ctx, next)
    • a middleware method to be executed for this procedure

Example Configuration

module.exports = {
  procedures: {
    test: {
      name: "test",
      description: "Descriptive text for use in the 'help' command",
      run: async (ctx, next) => {
        console.log("Test:", ctx.hasTestMiddleware); // Test: true
        await next();
      }
    },
    test2: {
      name: "test2",
      description:
        "This method does not await next, so 'All done!' will not be logged",
      run: async (ctx, next) => {
        console.log("Test2:", ctx.hasTestMiddleware); // Test2: true
        ctx.inputLoop = true; // Begins an infinite input loop until the user requests an "exit"
        // Since this method does not 'await next()' the postMiddleware will not execute
      }
    }
  },
  middleware: [
    // These methods will be added to the stack _before_ procedure execution
    async (ctx, next) => {
      ctx.hasTestMiddleware = true;
      await next();
    }
  ],
  postMiddleware: [
    // These methods will be added to the stack _after_ procedure execution
    async (ctx, next) => {
      console.log("All done!");
    }
  ]
};

Example Usage

> please test
Test: true
All done!
> please test2
Test2: true
All done!