npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

generate-node

v0.1.7

Published

Generate a node.js project, with everything you need to begin writing code and easily publish the project to npm.

Downloads

11

Readme

generate-node NPM version NPM downloads Build Status

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.

CLI

Installing 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:

$ npm i -g generate

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:

$ gen node

Usage as a sub-generator

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

Usage as a plugin

Extend your generator with the features and settings of this generator.

Example

app.use(require('generate-node'));

// use any task from `generate-node`!
app.task('default', ['files']);

Tasks

mit

Generate a MIT license file. Runs the default task from generate-license.

Example

$ gen node:mit

git

Initialize a git repository, and add files and first commit. Runs the default task from generate-git.

Example

$ gen node:git

mocha

Generate a mocha unit test file. Runs the default task from generate-mocha.

Example

$ gen node:mocha

npm

Install the latest dependencies and devDependencies in package.json.

Example

$ gen node:npm

tasks

Asks you to choose which tasks to run.

Example

$ gen node:tasks

prompt

Prompt 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

$ gen node:prompt
# ask all `author` questions
$ gen node:prompt --ask=author
# ask `author.name`
$ gen node:prompt --ask=author.name

prompt-mocha

Asks if you'd like to generate mocha unit tests. Runs the default task from generate-mocha.

Example

$ gen node:prompt-mocha

prompt-git

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

$ gen node:prompt-git

prompt-npm

Asks if you'd like install the latest devDependencies in package.json. If true, the npm task is run.

Example

$ gen node:prompt-npm

choices

Asks 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

$ gen node:choices

post-generate

Asks 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

$ gen node:post-generate

project

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

$ gen node:project

default

Generate a complete node.js project, then optionally install npm dependecies, mocha unit tests, and initialize a git repository.

Example

$ gen node
# or
$ gen node:default

API

To use this generator as a node.js module, as a plugin or sub-generator, you must first install the generator locally.

Install

Install with npm:

$ npm install generate-node

Usage

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:

module.exports = function(app) {
  // name the sub-generator whatever you want
  app.register('foo', require('generate-node'));
};

Docs

CLI

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:

$ npm i -g generate

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:

$ gen help

Running the node generator

Once both generate and generate-node are installed globally, you can run the generator with the following command:

$ gen node

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.

API

This 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'));

  // specify any tasks from generate-node. Example:
  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) {
  // register the generate-node generator (as a sub-generator with an arbitrary name)
  app.register('foo', require('generate-node'));

  app.task('minify', function(cb) {
    // minify some stuff
    cb();
  });

  // run the "default" task on generate-node (aliased as `foo`), 
  // then run the `minify` task defined in our generator
  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 projects

You might also be interested in these projects:

Contributing

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 docs

Generate readme and API documentation with verb:

$ npm install -g verb verb-readme-generator && verb

Running tests

Install dev dependencies:

$ npm install -d && npm test

Author

Jon Schlinkert

License

Copyright © 2016, Jon Schlinkert. Released under the MIT license.


This file was generated by verb, v0.9.0, on June 15, 2016.