Generate a node.js project, with everything you need to begin writing code and easily publish the project to npm.
TOC(TOC generated by verb using markdown-toc)
What is generate?Generate is a new, open source developer framework for rapidly initializing and scaffolding out new code projects, offering an intuitive CLI, and a powerful and expressive API that makes it easy and enjoyable to use.
Visit the getting started guide or the generate project and documentation to learn more.
CLIInstalling the CLI
To run the node
generator from the command line, you'll need to install generate globally first. You can that now with the following command:
This adds the gen
command to your system path, allowing it to be run from any directory. Visit the generate project and documentation to learn more.
Run the node
generator from the command line
Once both generate and generate-node
are installed globally, you can run the generator with the following command:
Run the node
generator from the command line:
You can use generate-node as a sub-generator{docs/sub-generators}. See the generate docs for more details.
app.register('foo', require('generate-node'));
This adds the namespace foo
to
Extend your generator with the features and settings of this generator.
Example
Tasks mitapp.use(require('generate-node'));
Â
app.task('default', ['files']);
Generate a MIT
license file. Runs the default
task from generate-license.
Example
gitInitialize a git repository, and add files and first commit. Runs the default
task from generate-git.
Example
mochaGenerate a mocha unit test file. Runs the default
task from generate-mocha.
Example
npmInstall the latest dependencies
and devDependencies
in package.json.
Example
tasksAsks you to choose which tasks to run.
Example
promptPrompt the user and pass answers to rendering engine to use as context in templates. Specify questions to ask with the --ask
flag. See common-questions for the complete list of available built-in questions.
Example
prompt-mocha$ gen node:prompt
$ gen node:prompt --ask=author
$ gen node:prompt --ask=author.name
Asks if you'd like to generate mocha unit tests. Runs the default
task from generate-mocha.
Example
prompt-git$ gen node:prompt-mocha
Asks if you'd like to initialize a git repository (also does git add
and first commit). If true the first-commit task is run.
Example
prompt-npmAsks if you'd like install the latest devDependencies
in package.json. If true, the npm task is run.
Example
choicesAsks if you want to save your choices from user prompts and automatically use them without asking again the next time the generator is run. If you change your mind, just run gen node:choices
and you'll be prompted again.
Example
post-generateAsks if you want to use the same "post-generate" choices next time this generator is run. If you change your mind, just run gen node:choices
and you'll be prompted again.
If false
, the prompt-mocha, prompt-npm, and prompt-git tasks will be run after files are generated then next time the generator is run. If true
, the mocha, npm, and git tasks will be run (and you will not be prompted) after files are generated then next time the generator is run.
Example
project$ gen node:post-generate
Generate a complete a node.js project, with all of the necessary files included.
(Note that this task does not initialize a git repository, generate mocha unit tests or install npm dependencies. If you want these things you can either run the default task, or run the tasks individually.)
Example
defaultGenerate a complete node.js project, then optionally install npm dependecies, mocha unit tests, and initialize a git repository.
Example
API$ gen node
$ gen node:default
To use this generator as a node.js module, as a plugin or sub-generator, you must first install the generator locally.
InstallInstall with npm:
Usage$ npm install generate-node
Then use in your project:
var node = require('generate-node');
Use as a plugin
In your generate project:
var generate = require('generate');
var app = generate();
Â
app.use(node);
Use as a generator plugin
In your generate generator:
module.exports = function(app) {
  app.use(node);
};
Use as a sub-generator
In your generate generator:
Docs CLImodule.exports = function(app) {
 Â
  app.register('foo', require('generate-node'));
};
Installing the CLI
To run the node
generator from the command line, you'll need to install generate globally first. You can do that now with the following command:
This adds the gen
command to your system path, allowing it to be run from any directory.
Help
Get general help and a menu of available commands:
Running the node
generator
Once both generate and generate-node
are installed globally, you can run the generator with the following command:
If completed successfully, you should see both starting
and finished
events in the terminal, like the following:
[00:44:21] starting ...
...
[00:44:22] finished â
If you do not see one or both of those events, please let us know about it.
APIThis updater can also be used as a node.js library in your own updater. To do so you must first install generate-node locally.
Install
Install with npm:
$ npm install --save generate-node
Use as a plugin in your generator
Use as a plugin if you want to extend your own generator with the features, settings and tasks of generate-node, as if they were created on your generator.
In your generator.js
:
module.exports = function(app) {
  app.use(require('generate-node'));
Â
 Â
  app.task('default', ['node']);
};
Use as a sub-generator
Use as a sub-generator if you want expose the features, settings and tasks from generate-node on a namespace in your generator.
In your generator.js
:
module.exports = function(app) {
 Â
  app.register('foo', require('generate-node'));
Â
  app.task('minify', function(cb) {
   Â
    cb();
  });
Â
 Â
 Â
  app.task('default', function(cb) {
    app.generate(['foo:default', 'minify'], cb);
  });
};
Tasks from generate-node
will be available on the foo
namespace from the API and the command line. Continuing with the previous code example, to run the default
task on generate-node
, you would run gen foo:default
(or just gen foo
if foo
does not conflict with an existing task on your generator).
To learn more about namespaces and sub-generators, and how they work, visit the getting started guide.
Related projectsYou might also be interested in these projects:
This document was generated by verb-readme-generator (a verb generator), please don't edit directly. Any changes to the readme must be made in .verb.md. See Building Docs.
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue. Or visit the verb-readme-generator project to submit bug reports or pull requests for the readme layout template.
Building docsGenerate readme and API documentation with verb:
Running tests$ npm install -g verb verb-readme-generator && verb
Install dev dependencies:
Author$ npm install -d && npm test
Jon Schlinkert
LicenseCopyright © 2016, Jon Schlinkert. Released under the MIT license.
This file was generated by verb, v0.9.0, on June 15, 2016.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4