UNPKG

6.44 kBMarkdownView Raw
1# Yoeman Generator for Node projects [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-url]][daviddm-image]
2
3A basic module template, that includes handy git hooks, a release script, es{6,2015} support via babel, and auto-changelog generation.
4
5Here's what you get:
6
7* auto-creates a `package.json`
8* auto-creates and keeps your `.npmignore` file up-to-date
9* auto-creates a `CONTRIBUTING.md`
10* auto-creates a `LICENSE`
11* auto-creates a `README.md` with a template that you can fill in
12* auto-creates a `.travis.yml` for easy CI
13* tests are auto-setup in `tape`, and it uses `smokestack` so you can do browser tests too.
14* auto-runs tests and linters before a `git push`, to ensure you can never push bad code
15* auto-runs the Node Security Project advisory list against installed node modules before a `git push` to make sure your project is always secure
16* adds a release script to automate the headache of releasing a new version. It auto-generates a changelog, runs the tests, bumps the version, pushes to github, and publishes to npm.
17
18<!-- START doctoc generated TOC please keep comment here to allow auto update -->
19<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
20**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*
21
22 - [Install](#install)
23 - [Usage](#usage)
24 - [What Everything Does](#what-everything-does)
25 - [`.babelrc`](#babelrc)
26 - [`.editorconfig`](#editorconfig)
27 - [`.gitignore`](#gitignore)
28 - [`.eslintrc`](#eslintrc)
29 - [`.npmignore`](#npmignore)
30 - [`.npmrc`](#npmrc)
31 - [`.travis.yml`](#travisyml)
32 - [`README.md`](#readmemd)
33 - [`LICENSE`](#license)
34 - [`CHANGELOG.md`](#changelogmd)
35 - [`CONTRIBUTING.md`](#contributingmd)
36 - [`package.json`](#packagejson)
37 - [`index.js`](#indexjs)
38 - [`test/test.js`](#testtestjs)
39 - [`bin/<module name>`](#binmodule-name)
40 - [Developing](#developing)
41 - [Tests](#tests)
42 - [Requirements](#requirements)
43- [License](#license)
44
45<!-- END doctoc generated TOC please keep comment here to allow auto update -->
46
47
48## Install
49`npm install -g generator-iojs yo`
50
51## Usage
52```sh
53yo iojs
54```
55
56## What Everything Does
57### `.babelrc`
58As long as you haven't turned off es6 (and why would you!?), this file is created to configure Babel, the es6 compiler. By default, it includes a [closure-elimination](https://github.com/codemix/babel-plugin-closure-elimination) plugin. This makes the compiled code faster!
59
60### `.editorconfig`
61[The Editor Config standard](http://editorconfig.org/) enforces very basic white space rules in files.
62
63### `.gitignore`
64Ever accidentally commit `.DS_Store` to git? There are a bunch of defaults here that you almost certainly don't want to commit.
65
66### `.eslintrc`
67Linters are good! They save you from making silly mistakes. This is a fairly opinionated linter setup, but it catches you from many silly errors. The linter will be run before every commit and before every release.
68
69### `.npmignore`
70What you commit to git and what you publish to npm don't need to be the same thing. Just like you wouldn't commit compiled files to git, you don't want to send unnecessary files to npm. When others `npm install` your module, they don't need all your tests or source files. These defaults strip out everything but what people really need when they install your module. It's kept up-to-date semi-automatically with [dmn](https://www.npmjs.com/package/dmn).
71
72### `.npmrc`
73Local configuration for npm commands. Most of the time, when you're installing modules, you want to save them to `package.json`. This changes the default behavior of `npm install` to always be `npm install --save`. `--save-dev` overrides this and works as normal.
74
75### `.travis.yml`
76Tests are good. Automatically testing is even better. [travis](https://travis-ci.org/) is free for open source modules and is a good choice for a CI server. This file is configured to automatically test your code against node 0.10, 0.12, and iojs latest. It puts you into the faster build environment on travis.
77
78### `README.md`
79Without docs, no one (including you, 3 months from now) will be able to figure out how to use this thing you've built! This readme provides a decent structure for a readme. It includes a table of contents that is automatically updated when deploying a new version.
80
81### `LICENSE`
82[You should have a license](https://help.github.com/articles/open-source-licensing/)
83
84### `CHANGELOG.md`
85Changelogs are really important for open source projects, but they're a pain to maintain. This changelog will automatically get updated (but give you a chance to edit it) every time you run `npm run release`.
86
87### `CONTRIBUTING.md`
88A file for github! This will show a banner above the new issue and new PR screens. This file has a set of general rules.
89
90### `package.json`
91So much magic! This sets up your node module with good defaults, and installs a bunch of dev dependencies to make magic! There are many included scripts to make dev life easier. `npm run release` and `npm run tdd` are some favorites.
92
93### `index.js`
94Just dummy content for your new node module.
95
96### `test/test.js`
97Just a dummy test file.
98
99### `bin/<module name>`
100If you specified this module as a CLI module, this file gets created for you. It should be a light-weight wrapper around `index.js` so that you can use the module both from the CLI and programatically.
101
102## Developing
103To publish, run `npm run release -- [{patch,minor,major}]`
104
105_NOTE: you might need to `sudo ln -s /usr/local/bin/node /usr/bin/node` to ensure node is in your path for the git hooks to work_
106
107## Tests
108Tests are in [tape](https://github.com/substack/tape). They can be run with `npm test`.
109
110Tests can be run in a loop with `npm run tdd`
111
112### Requirements
113* **npm > 2.0.0** So that passing args to a npm script will work. `npm i -g npm`
114* **git > 1.8.3** So that `git push --follow-tags` will work. `brew install git`
115
116# License
117Artistic 2.0 © [Joey Baker](https://byjoeybaker.com)
118
119[npm-url]: https://npmjs.org/package/generator-iojs
120[npm-image]: https://badge.fury.io/js/generator-iojs.svg
121[travis-url]: https://travis-ci.org/joeybaker/generator-iojs
122[travis-image]: https://travis-ci.org/joeybaker/generator-iojs.svg?branch=master
123[daviddm-url]: https://david-dm.org/joeybaker/generator-iojs.svg?theme=shields.io
124[daviddm-image]: https://david-dm.org/joeybaker/generator-iojs
125