generate

Project generator, for node.js.

generate

Project generator, for node.js.

This is a working application, but it's not ready to use. If you're curious about what we're building, feel free to ask questions or pitch in and help us make a better generator system for node.js.

(Table of contents generated by [verb])

The goal of this project is to offer an alternative to Yeoman that is:

  • easier to use, and easier to author generators
  • faster and lighter
  • should be composable and modular, allowing you to reuse logic across generators for things like:
    • tasks
    • plugins
    • middleware
    • loaders
    • templates
    • helpers
    • data
  • [x] resolving global generators
  • [x] loading global generators
  • [x] path handling for generators
  • [x] path handling for templates
  • [x] template processing
  • [x] data loading (for templates)
  • [x] path handling for cwd
  • [ ] prompts
  • [ ] collision management

Generate

Create a generate generator.

var app = require('generate');

.src

Glob patterns or filepaths to source files.

  • 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
app.src('*.js')

Example usage

app.task('web-app', function() {
  app.src('templates/*')
    app.dest(process.cwd())
});

.templates

Glob patterns or filepaths to templates stored in the ./templates directory of a generator.

  • 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
app.templates('*.js')

Example usage

app.task('web-app', function() {
  app.templates('templates/*')
    app.dest(process.cwd())
});

.dest

Specify a destination for processed files.

  • dest {String|Function}: File path or rename function.
  • options {Object}: Options or locals to merge into the context and/or pass to dest plugins
app.dest('dist', {ext: '.xml'})

Example usage

app.task('sitemap', function() {
  app.src('templates/*')
    app.dest('dist', {ext: '.xml'})
});

.task

Define a generator.

  • name {String}
  • fn {Function}
app.task('docs', function() {
  app.src('*.js').pipe(app.dest('.'));
});

.gettask

Get the name of the currently running task. This is primarily used inside plugins.

  • returns {String} task: The currently running task.
app.gettask();

.transform

Transforms functions are used to exted the Generate object and are run immediately upon init and are used to extend or modify anything on the this object.

  • name {String}: The name of the transform to add.
  • fn {Function}: The actual transform function.
  • returns {Object}: Returns Generate for chaining.
app.transform('foo', function(app) {
  app.cache.foo = app.cache.foo || {};
});

.watch

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

  • glob {String|Array}: Filepaths or glob patterns.
  • fn {Function}: Task(s) to watch.
app.task('watch', function() {
  app.watch('docs/*.md', ['docs']);
});

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

Jon Schlinkert

Copyright (c) 2015 Jon Schlinkert
Released under the MIT license


This file was generated by verb-cli on April 08, 2015.