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

graphtask

v0.0.1-0

Published

Graphtask is graph based task runner for complex task orchestration scenarios. It is written in Typescript and available as a commonjs or esm.

Downloads

4

Readme

Graphtask

Graphtask is graph based task runner for complex task orchestration scenarios. It is written in Typescript and available as a commonjs or esm.

Installation

Use the package manager npm to install graph task.

npm install -g graphtask

// or, as a project dependency
npm install graphtask --save-dev

Usage

Graphtask exposes a global function task(), this function is used to build a graph of tasks. The return value of task() can then be used as an input to other tasks, to form a graph. The tool uses a pool of web-workers to process tasks as efficiently as possible.

When the graph is run a task will be executed only if at least one of its inputs has succeeded (or if it has no inputs).

Writing task definitions (flows and actions).

Graphtask requires two files an NAME.flow.js and NAME.actions.js, these files define what is to be done and how it is to be done.

The flow file

The flow file describes what to do. It defines the tasks and their connections to other tasks. The following example defines four nodes. The input field defines connections between the nodes. The params field allows arbitrary data to be passed to each.

const actions = require('./tasks.actions');

const first = task({
  name: 'Wait for some time',   // The title of the task
  action: actions.wait,         // The action to run, must return a promise
  params: { some: 'input' }     // Some arbitrary data to pass in as arguments
});

const error = task({
  name: 'Fail because of error',
  action: actions.errorer,
  input: { 'first': first },    // A labeled input, the result of "first" will be passed in via the argument first
  params: { other: 'data' }
});

task({
  name: 'I dont run because all inputs failed',
  action: actions.wait,
  input: [error]
})

task({
  name: 'I run because some inputs succeeded',
  action: actions.wait,
  input: [error, first],
  params: { some: 'other input' },
})

This example produces the following graph:

simple graph

The actions file

The actions file defines how to do the tasks. These must be named functions that return a Promise.

const { wait } = require('../utils');

module.exports = {
  wait,

  async errorer() {
    throw new Error('BANNNG');
  }
};

CLI

graphtask ./tasks_folder      # Run tasks in folder
graphtask ./tasks_folder -p   # Generate a task plan (dont execute task actions)
graphtask ./tasks_folder -o ./results   # Write the output of the run in .json, .log & .dot format to the ./results folder

graphtask --help          # Display command help

Examples

See ./examples sub-folders

e.g.

./lib/cjs/cli/index.js ./examples/simple -o /tmp
./lib/cjs/cli/index.js ./examples/complex -o /tmp

-- TODO

Tests

-- TODO

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT