Package Exports
- generate
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (generate) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
generate

Fast, composable, highly pluggable project generator with a user-friendly and expressive API.
You might also be interested in base.
TOC
- Install
- What is generate?
- CLI
- Quickstart
- More info
- Related projects
- Contributing
- Building docs
- Running tests
- Author
- License
(TOC generated by verb using markdown-toc)
Install
Install globally with npm
$ npm install -g generateWhat is generate?
Generate is a new, open source developer framework for rapidly initializing and scaffolding out new code projects. Generate's offers a powerful and expressive API that makes it easy and enjoyable to author generators, and an intuitive CLI that helps you stay productive.
Example
This example shows two generators working together seamlessly.

Want to know more?
You can use generate from the command line, or as a node.js library as a part of your own application.
- Jump to feature highlights
- Visit the getting started guide
Continue on, and start generating!
CLI
Installing the CLI
To run generate from the command line, you'll need to install it globally first. You can do that now with the following command:
$ npm i -g generateThis adds the gen command to your system path, allowing it to be run from any directory.
You should now be able to use the gen command to execute code in a local generator.js file, or to execute globally installed generators by their aliases.
Quickstart
The following intro only skims the surface of what generate has to offer. For a more in-depth introduction, we highly recommend visiting the getting started guide.
Create a generator
Add a generator.js to the current working directory with the following code:
module.exports = function(app) {
console.log('success!');
};Run a generator
Enter the following command:
genIf successful, you should see success! in the terminal.
Create a task
Now, add a task to your generator.
module.exports = function(app) {
app.task('default', function(cb) {
console.log('success!');
cb();
});
};Now, in the command line, run:
$ gen
# then try
$ gen defaultWhen a local generator.js exists, the gen command is aliased to automatically run the default task if one exists. But you can also run the task with gen default.
Run a task
Let's try adding more tasks to your generator:
module.exports = function(app) {
app.task('default', function(cb) {
console.log('default > success!');
cb();
});
app.task('foo', function(cb) {
console.log('foo > success!');
cb();
});
app.task('bar', function(cb) {
console.log('bar > success!');
cb();
});
};Now, in the command line, run:
$ gen
# then try
$ gen foo
# then try
$ gen foo barRun task dependencies
Now update your code to the following:
module.exports = function(app) {
app.task('default', ['foo', 'bar']);
app.task('foo', function(cb) {
console.log('foo > success!');
cb();
});
app.task('bar', function(cb) {
console.log('bar > success!');
cb();
});
};And run:
$ genYou're now a master at running tasks with generate! You can do anything with generate tasks that you can do with gulp tasks (we use and support gulp libraries after all!).
Next steps
But generate does much more than this. For a more in-depth introduction, we highly recommend visiting the getting started guide.
More info
Feature highlights
Generate offers an elegant and robust suite of methods, carefully organized to help you accomplish common activities in less time, including:
- unparalleled flow control: through the use of generators, sub-generators and tasks
- templates, scaffolds and boilerplates: generate a single file, initialize an entire project, or provide ad-hoc "components" throughout the duration of a project using any combination of templates, scaffolds and boilerplates.
- any engine: use any template engine to render templates, including handlebars, lodash, swig and pug
- prompts: asks you for data when it can't find what it needs, and it's easy to customize prompts for any data you want.
- data: gathers data from the user's environment to populate "hints" in user prompts and render templates
- streams: interact with the file system, with full support for gulp and assemble plugins
- smart plugins: Generate is built on base, so any "smart" plugin can be used
- stores: persist configuration settings, global defaults, project-specific defaults, answers to prompts, and so on.
Visit the getting started guide to learn more.
FAQ
What's an alias, and what do they do?
Generate tries to find globally installed generators using an "alias" first, falling back on the generator's full name if not found by its alias.
A generator's alias is created by stripping the substring generate- from the full name of generator. Thus, when publishing a generator the naming convention generate-foo should be used (where foo is the alias, and generate-foo is the full name).
Note that no dots may be used in published generator names. Aside from that, any characters considered valid by npm are fine.
Related projects
Generate shares a common architecture and plugin ecosystem with the following libraries:
- assemble: Assemble is a powerful, extendable and easy to use static site generator for node.js. Used… more | homepage
- base: base is the foundation for creating modular, unit testable and highly pluggable node.js applications, starting… more | homepage
- update: Easily keep anything in your project up-to-date by installing the updaters you want to use… more | homepage
- verb: Documentation generator for GitHub projects. Verb is extremely powerful, easy to use, and is used… more | homepage
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Building docs
Generate readme and API documentation with verb:
$ npm install verb && npm run docsOr, if verb is installed globally:
$ verbRunning tests
Install dev dependencies:
$ npm install -d && npm testAuthor
Jon Schlinkert
License
Copyright © 2016, Jon Schlinkert. Released under the MIT license.
This file was generated by verb, v0.9.0, on May 30, 2016.