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

gulp-workflow

v1.1.5

Published

A simple, opinionated tool to managing your Gulp workflow

Downloads

21

Readme

workflow

A simple, opinionated tool to manage your Gulp workflow

Workflow is here to help with standardising Gulp setups across multiple projects. It surfaces the main workflow tasks in a clean and concise manner making it simple for people to compile those applications.

Setup

Your gulpfile.js should only contain the main tasks that you should be run by yourself, contributors or CI environments. These are called tasks. These tasks can then run a series of other tasks or subtasks. Subtasks are more granular tasks that do one simple thing. The subtasks you pass to a given task are run through run-sequence allowing you to run them in series or parallel.

workflow has it's own ideas about where tasks should live.

+-- gulp
|   +-- config
|   |   +-- gulp.conf.js
|   +-- eslint.js
|   +-- build-js.js
|   +-- build-css.js
+-- package.json
+-- gulpfile.js

The config folder is where you can store configurations needed for your tasks, i.e. webpack.conf.js. If a gulp.conf.js file is present, then workflow will pick that up and pass it back to your tasks.

// gulpfile.js

// Import `workflow` into your `gulpfile`
const gulp = require('gulp');
const workflow = require('gulp-workflow');

// Load `workflow`, passing it your projects instance of `gulp`
workflow
    .load(gulp)
    .task('lint', 'Run all linters.', ['eslint'])
    .task('build', 'Build the application.', ['clean', ['build:js', 'build:css']])
    .task('ci', 'Lint, test and build the application.', ['lint', 'build', 'test'])
    .task('test', 'Run unit tests.', ['test:unit', 'test:e2e']);
// gulp/lint.js

// Subtasks are passed four arguments.
// The `$` is an object of available gulp plugins via gulp-load-plugins
// The config is whatever is in the `gulp.conf.js` file merged with any arguments
module.exports = (workflow, gulp, $, config) => {
    workflow.subtask('eslint', () =>
        gulp.src('**/*.js')
            .pipe($.eslint())
            .pipe($.eslint.format())
            .pipe($.if(config.env.ci, $.eslint.failAfterError()))
    );
};

Usage

Configuration

As mentioned before, you can create an optional gulp.conf.js file in the config folder. This file needs to export a plain object.

// gulp.conf.js

module.exports = {
    name: "Project Name",
    appDir: "./some/path"
};

Arguments

You may want to pass arguments to your tasks, i.e. gulp build --release. Any arguments will be merged with the configuration object and passed back to each task.

// gulp.conf.js

module.exports = {
    name: "Project Name",
    appDir: "./some/path",
    args: {
        release: true
    }
};

Running tasks

It's no different than using gulp.

gulp lint    // Will run the lint task
gulp build   // Will run the build task

You get a help task for free. It will display a list of the available tasks. Only the tasks will be displayed, keeping the subtasks hidden.

Usage
  gulp [TASK] [OPTIONS...]

Available tasks
  build  Build the application.
  ci     Lint, test and build the application.
  help   Display this help text.
  lint   Run all linters.
  test   Run unit tests.

Running subtasks

Again, they're just ordinary gulp tasks so you can run them individually, i.e. gulp eslint

API

load(gulp)

Requires an instance of gulp. Loads the subtasks present in the gulp folder.

task(name, description, [tasks], args || [options])

Takes a name, description, array of tasks to run when called and an object containing any arguments that can be passed. The array of tasks is passed to run-sequence so can support their syntax.

Alternatively, you can pass it an object of options which use the same arguments as keys.

subtask(name, dependencies, func)

Takes a name, any dependencies and array of tasks to run when called. This functions in exactly the same way as a normal gulp task.

Debugging

To make sure your tasks are being loaded correctly, you can run any gulp command with a debug flag

gulp lint --debug

License

MIT © Ben Holland