composer

Boilerplate for creating a node.js application based on Template, vinyl and orchestrator. This consists of the core, generalized components of assemble, verb and generate.

composer

Boilerplate for creating a node.js application based on Template, vinyl and orchestrator. This consists of the core, generalized components of assemble, verb and generate.

This has the core components of [verb] and [assemble], and [generate]. You can use it to build your own application too. It comes with a fully-functional CLI and API for running tasks, plugins, routes and middleware, including the following:

  • tasks/plugins: gulp-style tasks and support for vinyl plugins (gulp, verb, assemble). Session caching is also used to allow context to be passed from one task to another.
  • engines: ability to render templates from any template engine.
  • middleware: for priming the file object with default properties, like data
  • routes: for running the default middleware at specific points in the plugin pipeline

The goal with this project is to generalize the core functionality used a

(Table of contents generated by [verb])

Fork or clone the repo from GitHub:

$ git clone https://github.com/jonschlinkert/composer.git
var app = require('composer');

Since this library uses orchestrator and vinyl, tasks have the same API as [gulp]:

app.task('default', function() {
  app.src('vendor/*.js')
    .pipe(app.src('dist'));
});

Tasks with plugins

var one = require('plugin-one');
var two = require('plugin-two');
 
app.task('default', function() {
  app.src('vendor/*.js')
    .pipe(one())
    .pipe(two())
    .pipe(app.src('dist'));
});

CLI for persisting and getting values that can be used across projects

Set

Set a value:

$ app --set foo=bar
#=> {foo: 'bar'} 
 
$ app --set baz
#=> {baz: true} 

Get

Get a value:

$ app --get foo
#=> bar 
 
$ app --get baz
#=> true 

.plugin

Register a plugin by name

Params

  • name {String}
  • fn {Function}

.pipeline

Create a plugin pipeline from an array of plugins.

Params

  • plugins {Array}: Each plugin is a function that returns a stream, or the name of a registered plugin.
  • options {Object}
  • returns {Stream}

.src

Glob patterns or filepaths to source files.

Params

  • glob {String|Array}: Glob patterns or file paths to source files.
  • options {Object}: Options or locals to merge into the context and/or pass to src plugins

Example

app.src('*.js')

.dest

Specify a destination for processed files.

Params

  • dest {String|Function}: File path or rename function.
  • options {Object}: Options or locals to pass to dest plugins

Example

app.dest('dist', {ext: '.xml'})

.copy

Copy a glob of files to the specified dest.

Params

  • glob {String|Array}
  • dest {String|Function}
  • returns {Stream}: Stream, to continue processing if necessary.

Example

app.copy('assets/**', 'dist');

.task

Define a task.

Params

  • name {String}
  • fn {Function}

Example

app.task('docs', function() {
  app.src(['foo.js', 'bar/*.js'])
    .pipe(app.dest('./'));
});

.getTask

Get the name of the current task-session. This is used in plugins to lookup data or views created in a task.

  • returns {String} task: The name of the currently running task.

Example

var id = app.getTask();
var views = app.views[id];

.getCollection

Get a view collection by its singular-form name.

  • returns {String} name: Singular name of the collection to get

Example

var collection = app.getCollection('page');
// gets the `pages` collection 
//=> {a: {}, b: {}, ...} 

.getFile

Get a file from the current session.

  • returns {Object} file: Vinyl file object. Must have an id property.

Example

var file = app.getFile(file);

.pushToStream

Get a template from the current session, convert it to a vinyl file, and push it into the stream.

Params

  • stream {Stream}: Vinyl stream
  • id {String}: Get the session id using app.getTask()

Example

app.pushToStream(file);

.taskFiles

taskFiles is a session-context-specific getter that returns the collection of files from the currently running task.

  • returns {Object}: Get the files from the currently running task.

Example

var taskFiles = app.taskFiles;

.watch

Re-run the specified task(s) when a file changes.

Params

  • glob {String|Array}: Filepaths or glob patterns.
  • fn {Function}: Task(s) to watch.

Example

app.task('watch', function() {
  app.watch('docs/*.md', ['docs']);
});
  • assemble: Static site generator for Grunt.js, Yeoman and Node.js. Used by Zurb Foundation, Zurb Ink, H5BP/Effeckt,… more
  • generate: Project generator, for node.js.
  • template: Render templates using any engine. Supports, layouts, pages, partials and custom template types. Use template… more
  • verb: Documentation generator for GitHub projects. Extremely powerful, easy to use, can generate anything from API… more

Install dev dependencies:

$ npm i -d && npm test

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue

Jon Schlinkert


This file was generated by verb-cli on May 26, 2015.