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

@jamesblanksby/toolkit

v0.0.12

Published

> A customizable task automation tool.

Downloads

4

Readme

🧰 Toolkit

A customizable task automation tool.

Getting Started

Install

$ npm install @jamesblanksby/toolkit

Usage

import Toolkit from 'toolkit';

// Initialise Toolkit
const toolkit = new Toolkit();

// Load task config file
await toolkit.load('/path/to/config.js');

// Run provided tasks
const tasks = [
    'task1',
    'task2',
    ...
];
await toolkit.run(tasks);

API

Toolkit

load(config)

Load a configuration file by the provided path and initalise a set of tasks based on the functions found in the loaded module.

Parameters:

  • config (String): The path to the configuration file.

run(tasks...)

Execute a list of tasks based on their names provided in the tasks parameter.

Parameters:

  • tasks (Array of Strings): An array containing the names of tasks to be executed.

hasFlag(name)

Check whether a specific flag is present in the set of flags stored within the instance.

Parameters:

  • name (String): The name of the flag to check.

getFlag(name)

This method retrieves the value associated with a specific flag from the set of flags stored within the instance.

Parameters:

  • name (String): The name of the flag to retrieve.

getTasks()

Retrieve a map of tasks stored within the instance.

parallel(tasks...)

Executes a set of tasks simultaneously.

Parameters:

  • ...tasks (Tasks): A set of tasks to be executed in simultaneously.

series(tasks...)

Execute a series of tasks sequentially.

Parameters:

  • ...tasks (Tasks): A set of tasks to be executed sequentially.

src(patterns, [options])

Creates a Files object based on file patterns.

Parameters:

  • patterns (String or Array of Strings): File glob patterns to match files.
  • options (Object): Additional options for file globbing and matching.

watch(pattern, tasks)

Watch files from a pattern and trigger a set of tasks in parallel whenever a change event is detected.

Parameters:

  • pattern (String): The file glob pattern to watch for changes.
  • tasks (Tasks): A set of tasks to be executed when a change is detected.

Files

pipe(hander, args...)

Create a new instance of a Files object by applying a handler function to the current instance.

Parameters:

  • handler (Function): The handler function to be applied to the current instance.
  • ...args (Any): Additional arguments to be passed to the handler function.

dest(files, [directory])

Write files to a directory (or the same path if not provided).

Parameters:

  • files (Files Object): Files to be written.
  • directory (String, optional): The destination directory to write the files. If not provided, files will be written to their original paths.

rm(files)

Removes files and recursively removes empty parent directories.

Parameters:

  • files (Files Object): Files to be removed.

rename(files, target)

Renames files based on the provided target path or a custom function.

Parameters:

  • files (Files Object): An async generator yielding instances of files to be renamed.
  • target (String or Function): The target path or a function to generate the new path for each file.

File

read()

Reads the content of the file and returns a new instance of MemoryFile with the same path and the read buffer.

CLI

Usage

$ npm toolkit [tasks] [options]

[!NOTE] This package ships with a default set of tasks, covering a range of common use cases. You can manually specify a different configuration file using the --config option.

Options

  • --help, -h: Show help and exit.
  • --config: Manually set the path of the config file.
  • --tasks, -t: Print the tasks from the loaded config and exit.
  • --quiet: Minimize logging.
  • --silent: Suppress all non-essential logging.

Examples

# Show help
$ npm toolkit --help

# Run default tasks
$ npm toolkit

# Run specific tasks
$ npm toolkit task1 task2

# Set a custom config file path
$ npm toolkit --config /path/to/config.js

# Print tasks from the loaded config
$ npm toolkit --tasks