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

mmake

v0.3.0

Published

Simple, flexible, zero-dependency, filesystem-based build tool

Downloads

4

Readme

mmake - modern make

mmake takes the best ideas from make and pulls them into the 21st century. mmake does away with the archaic syntax and hacky workarounds required for modern Makefile-based workflows.

| make | mmake | | ------------------------------------- | --------------------------------------------------- | | ❌ dummy files | ✅ directory targets and prerequisites | | ❌ PHONY targets | ✅ register commands like any other target | | ❌ terse, limited syntax | ✅ familiar RegExp and callback functions | | ❌ magic | ✅ explicit and discoverable | | ❌ no rebuild on source file deletion | ✅ rebuild on source file deletion (future release) | | ❌ println debugging | ✅ advanced observability tools (future release) |

Installation

npm install --save-dev mmake # or yarn add --dev mmake

Usage

Define and invoke build rules

Here is an example rule that writes the md5 checksum of a JSON file to a sibling text file.

import { invoke, register } from 'mmake';

register(
  /*
   * The first argument is a RegExp that will match the intended target.
   * Capture groups are allowed and can be used to calculate prerequisites.
   */
  /^hash-(foo|bar)\.txt$/,
  /*
   * The second argument is a callback function that takes the RegExp matches
   * array (if applicable) from the target and should return a list of string
   * prerequisites. Optionally asynchronous.
   */
  async ([_, fooOrBar]) => [`${fooOrBar}.json`],
  /*
   * The third argument is an asynchronous function that will run if the target
   * is non-existent or older than any prerequisites. It is passed the string
   * target as its first argument, and the array of string prerequisites as its
   * second argument.
   */
  async (targetPath, [sourcePath]) => {
    /*
     * If targetPath is hash-foo.txt, then sourcePath will be foo.json.
     * (Otherwise: hash-bar.txt and bar.json, respectively.)
     */
    const hash = await calculateHash(sourcePath);
    await writeFile(targetPath, hash);
  },
);

/*
 * After registering the rules, targets can be built using the invoke method.
 */
await invoke('hash-foo.txt');

Directories can be used as targets or prerequisites, too. In the case of a directory target, mmake will recurse the directory to find the oldest file's timestamp, which will be used to determine whether or not the recipe needs to be run (and for directory prerequisites: the newest file).

Any JavaScript can be run as part of a target's recipe. The recipe doesn't have to create the target file, either; this can be useful for executing commands that should always run each time they are requested (like PHONY targets in a traditional Makefile).

Build targets using a command-line interface

A simple CLI can be fashioned by making the rule script executable and passing command-line arguments to invoke():

#!/usr/bin/env node
import { invoke, register } from 'mmake';

register(...);
register(...);
register(...);

for (const requisite of process.argv.slice(2)) {
  await invoke(requisite);
}