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

productionline

v1.3.13

Published

An extendable class for creating common build pipelines.

Downloads

64

Readme

productionline Build Status Greenkeeper badge

npm install productionline --save-dev

An extendable build pipeline class, based on a "queue and run" strategy.

Demo

While gulp and grunt are mature tools with a large ecosystem, some build processes simply don't warrant the complexity. Plus, as awesome as streams are, it's typically easier for most developers think of build processes in sequential steps than stream manipulations. Furthermore, a global executable doesn't have to be a requirement for a build pipeline when Node/npm itself is a) suitable for the task and b) already installed. We prefer to configure npm scripts, executed as npm run build. This module provides an extendable JS Class, serving as a baseline for running any kind of build pipeline.

Examples

See the examples, and feel free to submit PR's with new examples.

Basic Use

The source code is well documented with several feature methods.

The following would go in a file called build.js.

const ProductionLine = require('productionline')
const builder = new ProductionLine({
  commands: {
    default: function (cmd) {
      console.log('No command specified!')
    },

    '--buildme': function (cmd) {
      console.log('Running Build Process:')

      // The following are not explicitly necessary since the source,
      // assets, and destination are all being set to their defaults.
      // However; the code is written so you can supply your own
      // folder structure.
      builder.source = path.resolve('./src')
      builder.assets = path.resolve('./assets') // Relative to source!
      builder.destination = path.resolve('./dist')

      // Queue the built-in make process.
      builder.addTask('My Build Task', function (next) {
        // Do something
        next()
      })
    }
  }
})

builder.run()

In the package.json file, add an npm command like:

{
  "scripts": {
    "test": "...",
    "build": "node build.js --buildme"
  }
}

The entire process can then be run using npm run build.

Extending the Production Line

This is the most anticipated use case, since most build processes are unique in some manner.

Basic ES 2016 class extension is the easiest way to create a custom build tool. The builder queues tasks using an internal shortbus instance, accessible via this.tasks. Once all tasks are queued, the build process can be run.

 const ProductionLine = require('productionline')

 class CustomBuilder extends ProductionLine {
   constructor {
     super()
   }

   // These tasks run before any others.
   before () {
     this.tasks.add('Custom Preprocessing Step', next => { ... })
   }

   // These tasks run after all others.
   after () {
     this.tasks.add('Custom Postprocessing Step', next => { ... })
   }

   make () {
     this.addStep('Custom step', (next) => {
       // Do something
       // ...

       // When complete, run the next queued task.
       next()
     })
   }

   makeDebuggableVersion () {
     this.tasks.add('Custom Step 1', next => {
        someAsynchrnousOperation(() => {
          next()
        })
     })
     this.tasks.add('Custom Step 2', next => { ... })
     this.tasks.add('Custom Step 3', next => { ... })
   }
 }

 const builder = new CustomBuilder({
   commands: {
     '--make': () => {
       console.log('Running Build Process:')

       // Queue the built-in make process.
       builder.make()
       builder.run() // This executes all of the queued tasks.
     },

     '--debug': () => {
       console.log('Running Building Process:')

       // Queue the custom debug process.
       builder.makeDebuggableVersion()
       builder.run() // This executes all of the queued tasks.
     },

     default: () => console.log('No command specified!')

   }
 })

Live Builds

During development, it's often useful to monitor source code and rebuild whenever a file changes. To support this, productionline contains a watch task, which will remain running and respond to file system changes.

For example:

builder.watch((action, filepath) => {
  builder.run()

  builder.watch((action, filepath) => {
    if (action === 'create') {
      console.log('New file created, rerun the build.')
      builder.run()
    }
  })
})

Extensions