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

kpo

v0.28.0

Published

A task runner that goes where npm scripts won't, for the true capo

Downloads

1,383

Readme

kpo

Version Types License

A task runner that goes where npm scripts won't, for the true capo.

Install

Run npm install -g kpo for a global install.

Table of Contents

Usage

kpo can be used programmatically or with its CLI.

Tasks (see definition) are plain synchronous or asynchronous functions that take a Context as an argument.

Tasks can be used in an exclusively programmatic manner or with kpo's CLI. The CLI expects a kpo.tasks.js file exporting a a Task.Record as a default.

Contexts are used by tasks to determine things such as the current working directory, environment variables, cancellation state, logging level, or stdio streams. In that sense, tasks, at least those created with kpo's creation functions, are independent of the process current state and can be cancelled. A task's context can in turn be manipulated to be different only for certain tasks, even within a group of serial or parallel tasks.

Programmatic Usage

  • Tasks
    • Creation
      • create: a task creation helper.
      • context: manipulates the context of a task.
    • Aggregate
      • series: runs a group of tasks in series.
      • parallel: runs a group of tasks in parallel.
      • combine: selects a task of group of tasks from a nested tasks record to run in series.
    • Exception
      • raises: raises an error.
      • catches: catches an error in a task and optionally run an alternate task.
      • finalize: executes a task after another regardless of whether the first task errored.
    • Filesystem
      • mkdir: creates a directory.
      • write: writes a file.
      • edit: edits a file.
      • copy: copies files or directories.
      • move: moves files or directories.
      • remove: removes files or directories.
      • watch: watches for changes and runs a task for change events.
    • Process
      • exec: spawns a process.
    • Schedule
      • sleep: stops execution for a given time.
      • repeat: repeats a task for a number of times.
      • timeout: sets a timeout for a task.
    • Stdio
      • log: prints a message with a given logging level.
      • print: prints a message.
      • clear: clears the stdout.
      • silence: suppresses the stdio for a task.
      • announce: logs a task route before execution and/or upon success.
      • interactive: marks a task as interactive to error or run an alternate task on non-interactive environments.
      • progress: shows a spinner while the task is in progress.
      • prompt: prompts for a user response.
      • confirm: executes a task in response to user confirmation or rejection.
      • select: executes a task in response to user selection.
    • Reflection
      • lift: lifts tasks on a record to a package.json file.
      • list: prints all available tasks on a task record.
  • Utils
    • run: runs a task.
    • style: styles a string.
    • fetch: fetches a file with a tasks record as a default export.
    • recreate: maps all tasks in a tasks record.
    • isCI: indicates whether a context environment variables indicate it's running in a CI.
    • isCancelled: resolves with the current cancellation state for a context.
    • isInteractive: indicates whether a context is that of an interactive environment.
    • isLevelActive: indicates whether a logging level is enabled for a context.

CLI Usage

Common options

These are common options for all kpo subcommands. They must always be passed before any subcommand or scope.

Usage:
  $ kpo [options] [command]

Options:
  -f, --file <path>       Configuration file
  -d, --dir <path>        Project directory
  -e, --env <value>       Environment variables
  --level <value>         Logging level
  --prefix                Prefix tasks output with their route
  -h, --help              Show help
  -v, --version           Show version number

Commands:
  :run          Runs tasks (default)
  :watch        Watch paths and run tasks on change events
  :list         List available tasks
  :lift         Lift tasks to package

Examples:
  $ kpo foo bar baz
  $ kpo -e NODE_ENV=development -e BABEL_ENV=node :run foo

kpo :run

Runs tasks.

kpo :run doesn't take additional options, other than the common options.

Note that the :run command can be omitted. When no command is passed, kpo will assume you're passing it tasks to run. Hence, kpo :run foo bar and kpo foo bar are equivalent.

kpo :watch

Watch a path and run tasks on change events

Usage:
  $ kpo :watch [options] -- [args]

Options:
  -g, --glob              Parse globs in paths
  -p, --prime             Runs the task once when ready to wait for changes
  -f, --fail              Finalizes the watch effort if a given task fails
  -c, --clear             Clear stdout before tasks execution
  -i, --include <value>   Paths to include
  -e, --exclude <value>   Paths to exclude
  -s, --symlinks          Follow symlinks
  --parallel              Don't cancel running tasks
  --debounce <number>     Avoid rapid task restarts (ms)
  --depth <number>        Limit subdirectories to traverse
  --poll <number>         Use polling for every ms interval
  -h, --help              Show help

Examples:
  $ kpo :watch -i ./src foo bar baz
  $ kpo :watch -i ./src -i ./test foo
  $ kpo -e NODE_ENV=development :watch -i ./src bar

kpo :list

List available tasks

Usage:
  $ kpo :list [options]

Options:
  --defaults      List default tasks and subtasks by their own
  -h, --help      Show help

kpo :lift

Lift tasks to a package.json

Usage:
  $ kpo :lift [options]

Options:
  --purge             Purge all non-kpo scripts
  --defaults          Lift default tasks and subtasks by their own
  --mode <value>      Lift mode of operation (confirm, fix, dry, audit)
  -h, --help          Show help