fuller

Build everything with right tool

npm install fuller
18 downloads in the last week
22 downloads in the last month

Fuller

Build everything with right tool

Richard Buckminster "Bucky" Fuller was an American systems theorist, architect, engineer, author, designer, inventor, and futurist

Install

npm install fuller -g

Usage

fuller [-w] [-z] [-v] [--src] [--dst] [--taskName] [--toolSetName]
--watch, -w     Watch source directory for changes
--src           Relative path to directory with source files
--dst           Relative path to directory for compiled files
--dev, -z       Developer version (usually this means no minifing and compressions, but depends from plugin)
--verbose, -v   Verbose mode
--taskName      Run task from plan
--toolSetName   Run toolSet from plan

Plan

So Mr. Fuller needs a plan to build something. All plans looks like this:

plan = {
    defaults,
    tasks,
    tools: {
        toolName: toolPlan
    }
}

If you don't need tool's plan tools section can be a simple array.

plan = {
    defaults,
    tasks,
    tools: ["toolName1", "toolName2"]
}

At start fuller trying to find plan.js file in current directory. So global plan is a simple module:

var defaults = {
    src: "./src",
    dst: "./",
    dev: true
};

var js = {
    "out/script.js": [
        "src1.js",
        "src2.js"
    ]
};

var less = {
        "out.css": "src.less"
};

var tasks = {
    //look for further explanation in the text below
}

module.exports = {
    defaults: defaults,
    tasks: tasks,
    tools : {
        concat: {
            tasks: js, 
            defaults: {
                src: defaults.src + "/js"
            },
            tools: ['common-js', 'uglify']
        },
        less: {tasks: less},
    }
};

In global plan you can make named tool sets. And run single tool set from command line. For example:

module.exports = {
    defaults: defaults,
    tasks: tasks,

    "static": {
        defaults: {
            dst: defaults.dst + "static"
        },
        tools : {
            concat: {
                tasks: js, 
                defaults: {
                    src: defaults.src + "/js"
                },
                tools: ['common-js', 'uglify']
            },
            less: {tasks: less},
        },
    }
};

if you didn't make tool set, it's means "default" tool set. And it will be run on fuller start.

Tools

This is about right tools. But what is a Tool? Tool is a plugin, that building something according to plan.

What's interesting tools can use another tools...

plan: {
    tools: {
        tool1: {
            tools: {
                tool2: etc;
            }
        }
    }
}

;)

You should include tools' packages in your project's package.json

Tools API

Needs to be written. But you can check fuller's tools.

Defaults

You can specify defaults option in global section, or in tool's part of the plan.

File tools

Also fuller has special purpose file tools. You can load in your plugin with a fuller.getTool('files').

  • concat(path, arrayFileNames, [prependString], [appendString]) — concatenates files with base path and strings for appeding and prepending to result.
  • treeToArray(srcPath, files) — converts path and array of files to array of full paths to files
  • writeForce(pathFile, data, cb) — writes file, but if destination directory not exist creates it.
  • addDependence(deps, master, slave) — adds depenencies to deps object
  • mkdirp — make path
  • watchFiles(root, arrayFileNames, cb) — adds watchers and run cb on files changes.

Global tasks

You can specify your own tasks in plan:

tasks = {
    start: function(fuller, defaults) {
        fuller.build();             //builds everything
        fuller.run('bin/cmd start') //run cmd
    }
}

and then just run it fuller --start

Don't forget about verbose mode here if you needed.

The fuller var in your task function is a pointer to global fuller object.

  • fuller.plan — your plan
  • fuller.build() — builds everything.
  • fuller.watch() — watch for changes in all tools.
  • fuller.run(cmd) — run cmd
  • fuller.verbose.log(str) — print str to console if fuller in verbose mode
  • fuller.getTool('toolName') — return tool instance

Bonus, you can specify dev task. It'll be run before all others tasks when you'll use -z(--dev) key.

npm loves you