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

tempaw-build

v1.0.3

Published

Gulp wrapper for quick and easy project build

Downloads

5

Readme

Tempaw Build

Simple Gulp add-on for easy project building.

Usage

Simple step-by-step guide:

  • Create the gulpfile.js file in the project’s root directory.
  • Import the tempaw-build module.
  • Export the result of calling the task function with necessary parameters.
  • Run the file via the console (gulp)

For example:

const { action, task } = require( 'tempaw-build' );

module.exports.build = task([
	action.clean({ src: 'dist' }),
	action.copy({ src: [ 'dev/**/*.scss', 'dev/**/*.pug' ], dest: 'tmp' }),
	action.del({ src: 'tmp/**/*', marker: 'DIST' }),
	action.sass({ src: 'tmp/**/!(_)*.scss', dest: 'dist' }),
	action.pug({ src: 'tmp/components/page/!(_)*.pug', dest: 'dist' }),
	action.copy({ src: [ 'dev/**/*.js', 'dev/**/*.ico' ], dest: 'dist' }),
	action.minifyimg({ src: [ 'dev/**/*.jpg', 'dev/**/*.png' ], dest: 'dist' }),
	action.clean({ src: 'tmp' })
]);

API

set()

Creates an array of executable functions out of the action sequence for further transfer to gulp.series or gulp.parallel.

executableSet = set( actions );

| parameter | type | required | description | |:---:|:---:|:---:|---| | actions | Array | yes | An array of the action set | | executableSet | Array | | Executable set of functions |

task()

Creates a gulp-task out of the action sequence. Afterward, it can be inserted into another task or exported.

series = task( actions );

| parameter | type | required | description | |:---:|:---:|:---:|---| | actions | Array | yes | An array of the action set | | series | function | | Task series |

action.copy()

File copying.

actionObject = action.copy( options );

| parameter | type | required | description | |:---:|:---:|:---:|---| | actionObject | object | | Created action object for further execution | | options | object | yes | Action parameters | | options.name | string | no | Name of the action displayed in the console during execution | | options.cb | function | no | Executable callback (must be synchronous), does not accept parameters | | options.opts | object | no | gulp.src parameters | | options.fname | string|object|function | no | gulp-rename parameters | | options.src | string|Array | yes | glob file selection for copying | | options.dest | string|Array | yes | destination path |

action.clean()

File deletion.

actionObject = action.clean( options );

| parameter | type | required | description | |:---:|:---:|:---:|---| | actionObject | object | | Created action object for further execution | | options | object | yes | Action parameters | | options.name | string | no | Name of the action displayed in the console during execution | | options.cb | function | no | Executable callback (must be synchronous), does not accept parameters | | options.src | string|Array | yes | glob file selection for deletion |

action.minifyimg()

Image minifying.

actionObject = action.minifyimg( options );

| parameter | type | required | description | |:---:|:---:|:---:|---| | actionObject | object | | Created action object for further execution | | options | object | yes | Action parameters | | options.name | string | no | Name of the action displayed in the console during execution | | options.cb | function | no | Executable callback (must be synchronous), does not accept parameters | | options.opts | object | no | gulp.src parameters | | options.fname | string|object|function | no | gulp-rename parameters | | options.src | string|Array | yes | glob image file selection for minifying | | options.dest | string|Array | no | Destination path (if not specified, source files will be overwritten) | | options.cache | boolean | no | Using cache during minifying (the result is cached and used repeatedly to save time) |

action.del()

Deleting a part of the file using markers.

actionObject = action.del( options );

| parameter | type | required | description | |:---:|:---:|:---:|---| | actionObject | object | | Created action object for further execution | | options | object | yes | Action parameters | | options.name | string | no | Name of the action displayed in the console during execution | | options.cb | function | no | Executable callback (must be synchronous), does not accept parameters | | options.opts | object | no | gulp.src parameters | | options.fname | string|object|function | no | gulp-rename parameters | | options.src | string|Array | yes | glob file selection | | options.dest | string|Array | no | Destination path (if not specified, source files will be overwritten) | | options.marker | string | yes | Marker name (digits, letters, uppercase, and underscore are acceptable) |

action.pug()

Compiling Pug files.

actionObject = action.pug( options );

| parameter | type | required | description | |:---:|:---:|:---:|---| | actionObject | object | | Created action object for further execution | | options | object | yes | Action parameters | | options.name | string | no | Name of the action displayed in the console during execution | | options.cb | function | no | Executable callback (must be synchronous), does not accept parameters | | options.opts | object | no | gulp.src parameters | | options.fname | string|object|function | no | gulp-rename parameters | | options.pug | object | no | pug compiler parameters | | options.src | string|Array | yes | glob file selection for compiling | | options.dest | string|Array | yes | Destination path | | options.debug | boolean | no | Shows the compiled file in the console |

action.sass()

Compiling Sass files.

actionObject = action.sass( options );

| parameter | type | required | description | |:---:|:---:|:---:|---| | actionObject | object | | Created action object for further execution | | options | object | yes | Action parameters | | options.name | string | no | Name of the action displayed in the console during execution | | options.cb | function | no | Executable callback (must be synchronous), does not accept parameters | | options.opts | object | no | gulp.src parameters | | options.fname | string|object|function | no | gulp-rename parameters | | options.sass | object | no | sass compiler parameters | | options.src | string|Array | yes | glob file selection for compiling | | options.dest | string|Array | yes | Destination path | | options.debug | boolean | no | Shows the compiled file in the console |

action.transform()

Transforming the file selection content.

actionObject = action.transform( options );

| parameter | type | required | description | |:---:|:---:|:---:|---| | actionObject | object | | Created action object for further execution | | options | object | yes | Action parameters | | options.name | string | no | Name of the action displayed in the console during execution | | options.opts | object | no | gulp.src parameters | | options.fname | string|object|function | no | gulp-rename parameters | | options.src | string|Array | yes | glob file selection for processing | | options.dest | string|Array | no | Destination path (if not specified, source files will be overwritten) | | options.cb | function | yes | Transformation callback, gets the file content (contents & file), must return a string |

action.json()

Modifying the content of a JSON-file as an object.

actionObject = action.json( options );

| parameter | type | required | description | |:---:|:---:|:---:|---| | actionObject | object | | Created action object for further execution | | options | object | yes | Action parameters | | options.name | string | no | Name of the action displayed in the console during execution | | options.opts | object | no | gulp.src parameters | | options.fname | string|object|function | no | gulp-rename parameters | | options.src | string|Array | yes | glob file selection for processing | | options.dest | string|Array | no | Destination path (if not specified, source files will be overwritten) | | options.cb | function | yes | Transformation callback, gets an object, must return an object |

action.zip()

Packing the file selection into a zip archive.

actionObject = action.zip( options );

| parameter | type | required | description | |:---:|:---:|:---:|---| | actionObject | object | | Created action object for further execution | | options | object | yes | Action parameters | | options.name | string | no | Name of the action displayed in the console during execution | | options.cb | function | no | Executable callback (must be synchronous), does not accept parameters | | options.opts | object | no | gulp.src parameters | | options.zip | object | no | gulp-zip parameters | | options.fname | string | yes | Name of the zip archive | | options.src | string|Array | yes | glob file selection for processing | | options.dest | string|Array | no | Destination path, if not specified, then the archive will be created in the project’s root folder |

Custom action

A conditional action is a function of a gulp task or a simple object with the execute parameter that represents a gulp task, too.

Examples:

let action = function ( end ) {
  console.log( 'Hello world' );
  end();
};

let actionObject = {
  execute: function ( end ) {
    console.log( 'Hello world' );
    end();
  }
};

let actionObject = {
  execute: function () {
    return src( 'src/*.js' )
      .pipe( dest( 'output/' ) );
  }
};

To shorten the routine actions, a function that returns an action object can be used, for example:

/**
 * File copying
 * @param {object} data - object with parameters
 * @param {string|Array.<string>} data.src - glob file selection for copying
 * @param {string} data.dest - destination path
 * @return {object}
 */
let myCopy = function ( obj ) {
  // Checking for required parameters
  if ( !obj || !obj.src || !obj.dest ) throw Error( 'Required parameter of myCopy not specified (src, dest)' );

  // Gulp task for file copying with the received parameters obj.src and obj.dest
  obj.execute = function () {
    return src( obj.src ).pipe( dest( obj.dest ) );
  }

  // Changing the task name
  obj.execute.displayName = 'My Simple Copy';

  // Returning the action object
  return obj;
};

Now, a new action can be used:

const { action, task } = require( 'tempaw-build' );

module.exports.build = task([
	action.clean({ src: 'dist' }),
	myCopy({ src: [ 'dev/**/*.scss', 'dev/**/*.pug' ], dest: 'tmp' }),
	action.del({ src: 'tmp/**/*', marker: 'DIST' }),
	action.sass({ src: 'tmp/**/!(_)*.scss', dest: 'dist' }),
	action.pug({ src: 'tmp/components/page/!(_)*.pug', dest: 'dist' }),
	myCopy({ src: [ 'dev/**/*.js', 'dev/**/*.ico' ], dest: 'dist' }),
	action.minifyimg({ src: [ 'dev/**/*.jpg', 'dev/**/*.png' ], dest: 'dist' }),
	action.clean({ src: 'tmp' })
]);