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-minion

v1.0.0

Published

[![travis_ci](https://img.shields.io/travis/marspa/gulp-minion.svg)]() [![coveralls](https://img.shields.io/coveralls/marspa/gulp-minion.svg)]() [![npm](https://img.shields.io/npm/v/gulp-minion.svg)]() [![npm](https://img.shields.io/npm/l/gulp-minion.svg)

Downloads

6

Readme

travis_ci coveralls npm npm

gulp-minion

What is gulp-minion?

gulp-minion is a tool that allows you to easily construct and orchestrate gulp.js tasks. In particular, gulp-minion allows you to

Sample Usage

import { exec } from 'child_process';
import { GulpMinion, iocContainer, Task, TaskFactory, TaskRunner } from 'gulp-minion';

// retrieve the objects from IoC container
const gulpMinion: GulpMinion = iocContainer.get(GulpMinion);
const taskFactory: TaskFactory = iocContainer.get(TaskFactory);
const taskRunner: TaskRunner = iocContainer.get(TaskRunner);

// define the interface and instances of Git repositories
interface GitRepository {
  url: string;
  branch: string;
}

const gitRepositories: GitRepository[] = [
  {
    "url": "https://github.com/gulpjs/gulp.git",
    "branch": "master"
  },
  {
    "url": "https://github.com/kelektiv/node-uuid.git",
    "branch": "master"
  },
  {
    "url": "https://github.com/isaacs/rimraf.git",
    "branch": "master"
  }
];

// define the single Git tasks as plain functions
const clone = (gitRepository: GitRepository): Promise<void> => {
  exec('git clone ' + gitRepository.url);
  return Promise.resolve();
};

const checkout = (gitRepository: GitRepository): Promise<void> => {
  exec('git checkout ' + gitRepository.branch);
  return Promise.resolve();
};

// create Task objects from the Git repository instances
const cloneTasks: Task<GitRepository>[] = gitRepositories.map((gitRepository: GitRepository) => {
  return taskFactory.getTask(clone, gitRepository);
});

const checkoutTasks: Task<GitRepository>[] = gitRepositories.map((gitRepository: GitRepository) => {
  return taskFactory.getTask(checkout, gitRepository);
});

// create Gulp tasks from the Task objects
const cloneGulpTask: string = gulpMinion.constructParallelGulpTasks('clone', cloneTasks);
const checkoutGulpTask: string = gulpMinion.constructParallelGulpTasks('checkout', checkoutTasks);

// orchestrate several tasks
const updateGulpTask: string = gulpMinion.constructSequentialGulpTask('update', [cloneGulpTask, checkoutGulpTask]);

// execute the update Task
taskRunner.execute(updateGulpTask);

Documentation

The gulp-minion package consists of the following classes:

Task

A generic DTO that describes a task. A task has the following properties:

  • A unique id.
  • A function fn that has an optional input parameter and returns a Promise<void> object.
  • An optional parameter for the function fn. To generate a Task object, you can use the TaskFactory.

TaskFactory

A factory class to produce Task objects.

getTask(fn: (parameter: T) => Promise, parameter: T, name: string = uuid()): Task;

Generate a Task object by passing a function with precisely one input parameter and the corresponding input parameter. If no id is passed, an random UUID is generated.

getTaskWithoutParameter(fn: () => Promise, name: string = uuid()): Task;

Generate a Task object by passing a function without input parameters. If no id is passed, an random UUID is generated.

GulpMinion

A generator of gulp.js tasks.

constructParallelGulpTasks(name: string, tasks: Task[], concurrencyLimit: number = Number.MAX_SAFE_INTEGER): string;

Construct a gulp.js task that executes the given tasks in parallel. The passed name is the name of the generated gulp.js task. You can optionally use concurrencyLimit to restrict the number of tasks to be executed. E.g., if concurrencyLimit is set to 3 and you pass 7 tasks, the tasks 1 to 3 are executed in parallel, as soon as those are finished, the tasks 4 to 6 are executed in parallel, and after that, the 7th task is executed.

constructSequentialGulpTask(name: string, taskNames: string[]): string;

Construct a gulp.js task that executes the given tasks one after another. The passed name is the name of the generated gulp.js task.

TaskRunner

A gulp.js task runner.

execute(task: string): Promise;

Execute the gulp.js task with name task.

Configuration

To ease the setup of the objects, we follow the inversion of control (IoC) principle. Every object can be retrieved using a provided IoC container as in the following example:

/// import the IoC container and the classes of objects that should be setup
import { GulpMinion, iocContainer } from 'gulp-minion';

// retrieve the objects from IoC container
const gulpMinion: GulpMinion = iocContainer.get(GulpMinion);