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

terminal-task-runner

v1.6.0

Published

Task-runner is a node UI framework for task execution. Developer can only focus on the task logic.

Downloads

17

Readme

terminal-task-runner

NPM version

Terminal task execution system

Terminal-task-runner is a node UI framework for task execution. Developer can only focus on the task logic. Framework will generate the terminal menu for you.

terminal-task-runner is now used by sero-cli, modou-terminal-controller, fe-interview

High-level overview

terminal-task-runner is runner system with a lovely terminal UI. Which also provide some cool features to ease the way of implementing tasks.

Installation

npm install terminal-task-runner --save

Usage

var TaskRunner = require('terminal-task-runner');

TaskRunner.createMenu({
    title: 'This is Header',
    subtitle: 'here is subTitle'
});

By doing above, you've created a very simple terminal menu as following:

How to write your own task

Welcome to play with the example as your skeleton.

API

TaskRunner.createMenu(options)

options

Type: Object

Options to pass to createMenu

options.title

Type: String Default: =====================

The title displayed on the top of the terminal ui.

options.subtitle

Type: String Default: --------------------

The subtitle displayed below the title.

options.helpTxt

Type: String Default: HELP

The text will be displayed if you have set helpFile.

options.exitTxt

Type: String Default: EXIT

The text will be displayed at the bottom of the terminal UI.

options.width

Type: number Default: 100

menu width in columns.

options.x

Type: number Default: 3

top-left corner x offset.

options.y

Type: number Default: 2

top-left corner y offset.

options.taskDir

Type: String

The location of where the tasks placed.

options.taskList

Type: array Optional: true

The the list of task folders. If not specified, task-runner will go through all the folders under taskDir.

options.helpFile

Type: String

The location of where the help file placed. A help file should be written in colors-tmpl style.

options.version

Type: String Default: ''

The version will be displayed at the right of the title.

options.preferenceName

Type: String

The preference file name will be used to store the information. For example: .sero

How to play with PreferenceMgr

options.onFinish

Type: Function

This Function gets called once a task is executed successfully with two parameters id and name

options.onError

Type: Function

This Function gets called once a task is failed with three parameters id, name and error

TaskRunner.Base

Your own task should extend from it.

var Task = TaskRunner.Base.extend({
    id: 'helloTask',
    name: 'This is only a hello world task',
    priority: 1,
    run: function(cons) {
        //Task has to be asynchronous, otherwise, you won't receive the finish/error event
        setTimeout(function() {
            logger.warn('hello, world!!');
            cons();
        });
    }
});

TaskRunner.logger

Print stuff to the terminal instead of the original console.

var logger = TaskRunner.logger;

logger.info('information');          //print in white
logger.success('congratulation');    //print in green
logger.warn('warning');              //print in yellow
logger.error('error');               //print in red

TaskRunner.shell(commands, variables, displayCmdItself)

commands

Type: Array

Commands to pass to new Shell

command

Type: String

The command you'd like to execute. A command can contains variable which will be replaced later before executed by Shell, the varible syntax should apply lodash

variables

Type: Object

The object used to replace the variable in command by using lodash's template engine.

displayCmdItself

Type: Boolean

This option used to determine whether to display the command itself

var Shell = TaskRunner.shell;

new Shell(['ls -l *<%= suffix %>'], {
                suffix: '.js'
    }, true).start().then(function() {
        cons();
    }, function(err) {
        cons(err);
});

TaskRunner.Q

Q as default promise implementation is recommended.

LICENSE

MIT License