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

auto-builder

v1.1.36

Published

Auto Builder ===========

Downloads

44

Readme

Auto Builder

Auto Builder is an implementation of GNU make. Instead of the configuration being found inside a makefile, it uses a javascript object which describes the dependency graph. This makes it easy to dynamically generate the configuration in your build script.

Installation

npm install auto-builder

Usage

The library itself exports a single factory function. This factory is used to create a runner which can then be used to generate a series of targets:

    const autoBuilder = require( "auto-builder" );

    const buildCfg = { ... }; 
    var runner = autoBuilder( buildCfg );

    Promise.resolve()
        // generate target x
        .then( () => runner( [ "target_x" ] ) )
        // generate targets z and y
        .then( () => runner( [ "target_z", "target_y" ] ) );

The runner will only re-generate targets with dependencies that have modified dates later than that of the target. This prevents redundant regeneration.

Targets will be built with maximum parallelism - using the dependency graph specified by the configuration. The meat of this work is offloaded to the orchestrator library.

Configuration

The Auto Builder configuration is an object mapping target to: recipe and dependencies.

The target is the name of some file that needs to be generated. The dependencies are the names of the files required for the generation and the recipe is a function that performs the actual regeneration.

The recipe function should be a nullary function that returns a promise which resolves upon completion. If the recipe doesn't create the target file, an empty file will be created by the library.

Heres a toy example:

{
    // no actual *work* is done here - just collect all dependencies 
    "dist/build" : {
        dependencies : [ "dist/index.js" ],
    },

    // compile the javascript into es7
    "dist/index.js.es7" : {
        dependencies : [ "index.js" ],
        recipe : () => compileToES7( "index.js", "dist/index.js.es7" )
    },

    // minify the compiled javascript and save it at the target location
    "dist/index.js" : {
        dependencies : [ "dist/index.js.es7" ],
        recipe : () => minify( "dist/index.js.es7", "dist/index.js" )
    },
    
    // clear the directory. Need to add a dummy dependency as otherwise will only clean once..
    "dist/clean" : {
        dependencies : [ "dist/.clean" ],
        recipe : () => fsPromise.clearDir( "dist" )
    },

    // dummy clean dependency - ensures clean can be run multiple times
    "dist/.clean" : {
    },

}

To perform a clean and then a build, you would do:

    Promise.resolve()
        .then( () => runner( [ "dist/clean" ] ) )
        .then( () => runner( [ "dist/build" ] ) );