UNPKG

13.6 kBMarkdownView Raw
1# generate-license [![NPM version](https://img.shields.io/npm/v/generate-license.svg?style=flat)](https://www.npmjs.com/package/generate-license) [![NPM downloads](https://img.shields.io/npm/dm/generate-license.svg?style=flat)](https://npmjs.org/package/generate-license) [![Build Status](https://img.shields.io/travis/generate/generate-license.svg?style=flat)](https://travis-ci.org/generate/generate-license)
2
3> Generate a license file for a GitHub project.
4
5![generate-license demo](https://raw.githubusercontent.com/generate/generate-license/master/demo.gif)
6
7## Table of Contents
8
9- [What is "Generate"?](#what-is-generate)
10- [Command line usage](#command-line-usage)
11 * [Install](#install)
12 * [Run](#run)
13 * [Help](#help)
14 * [Running tasks](#running-tasks)
15- [Available tasks](#available-tasks)
16- [API usage](#api-usage)
17 * [Install locally](#install-locally)
18 * [Use as a plugin](#use-as-a-plugin)
19 * [Register as a generator](#register-as-a-generator)
20- [Customization](#customization)
21 * [Destination directory](#destination-directory)
22 * [Overriding templates](#overriding-templates)
23- [About](#about)
24 * [Related projects](#related-projects)
25 * [Contributing](#contributing)
26 * [Running tests](#running-tests)
27 * [Author](#author)
28 * [License](#license)
29
30_(TOC generated by [verb](https://github.com/verbose/verb) using [markdown-toc](https://github.com/jonschlinkert/markdown-toc))_
31
32## What is "Generate"?
33
34Generate is a command line tool and developer framework for scaffolding out new GitHub projects using [generators](https://github.com/generate/generate/blob/master/docs/generators.md) and [tasks](https://github.com/generate/generate/blob/master/docs/tasks.md). Answers to prompts and the user's environment can be used to determine the templates, directories, files and contents to build. Support for [gulp](http://gulpjs.com), [base](https://github.com/node-base/base) and [assemble](https://github.com/assemble/assemble) plugins, and much more.
35
36For more information about Generate:
37
38* Visit the [generate project](https://github.com/generate/generate)
39* Visit the [generate documentation](https://github.com/generate/generate/blob/master/docs/)
40* Find [generators on npm](https://www.npmjs.com/browse/keyword/generate-generator) (help us [author generators](https://github.com/generate/generate/blob/master/docs/micro-generators.md))
41
42## Command line usage
43
44### Install
45
46**Installing the CLI**
47
48To run the `license` generator from the command line, you'll need to install [generate](https://github.com/generate/generate) globally first. You can do that now with the following command:
49
50```sh
51$ npm install --global generate
52```
53
54This adds the `gen` command to your system path, allowing it to be run from any directory.
55
56**Install generate-license**
57
58You may now install this module with the following command:
59
60```sh
61$ npm install --global generate-license
62```
63
64### Run
65
66You should now be able to run `generate-license` with the following command:
67
68```sh
69$ gen license
70```
71
72**What will happen?**
73
74Running `$ gen license` will run the generator's [default task](#default), which will:
75
761. prompt you to choose a license to generate
772. prompt you for any information that's missing, if applicable (like author name, etc.)
783. render the necessary template(s) using your answers
794. write [the resulting files](#available-tasks) to the current working directory
80
81**What you should see in the terminal**
82
83If completed successfully, you should see both `starting` and `finished` events in the terminal, like the following:
84
85```sh
86[00:44:21] starting ...
87...
88[00:44:22] finished ✔
89```
90
91If you do not see one or both of those events, please [let us know about it](../../issues).
92
93### Help
94
95To see a general help menu and available commands for Generate's CLI, run:
96
97```sh
98$ gen help
99```
100
101### Running tasks
102
103Tasks on `generate-license` are run by passing the name of the task to run after the generator name, delimited by a comma:
104
105```sh
106$ gen license:foo
107 ^ ^
108generator task
109```
110
111**Example**
112
113The following will run generator `foo`, task `bar`:
114
115```sh
116$ gen foo:bar
117```
118
119**Default task**
120
121When a task name is not explicitly passed on the command line, Generate's CLI will run the [default](#default) task.
122
123## Available tasks
124
125### [agpl-3.0](generator.js#L27)
126
127Generate a GNU Affero General Public License v3.0 `LICENSE` file in the current working directory.
128
129**Example**
130
131```sh
132$ gen license:agpl-3.0
133$ gen license:agpl-3.0 --dest ./docs
134$ gen dest license:agpl-3.0
135```
136
137### [apache-2.0](generator.js#L44)
138
139Generate an Apache License 2.0 `LICENSE` file in the current working directory.
140
141**Example**
142
143```sh
144$ gen license:apache-2.0
145$ gen license:apache-2.0 --dest ./docs
146$ gen dest license:apache-2.0
147```
148
149### [artistic-2.0](generator.js#L61)
150
151Generate an Artistic License 2.0 `LICENSE` file in the current working directory.
152
153**Example**
154
155```sh
156$ gen license:artistic-2.0
157$ gen license:artistic-2.0 --dest ./docs
158$ gen dest license:artistic-2.0
159```
160
161### [bsd-2-clause](generator.js#L78)
162
163Generate a BSD 2-clause "Simplified" License `LICENSE` file in the current working directory.
164
165**Example**
166
167```sh
168$ gen license:bsd-2-clause
169$ gen license:bsd-2-clause --dest ./docs
170$ gen dest license:bsd-2-clause
171```
172
173### [bsd-3-clause](generator.js#L95)
174
175Generate a BSD 3-clause "New" or "Revised" License `LICENSE` file in the current working directory.
176
177**Example**
178
179```sh
180$ gen license:bsd-3-clause
181$ gen license:bsd-3-clause --dest ./docs
182$ gen dest license:bsd-3-clause
183```
184
185### [cc0-1.0](generator.js#L112)
186
187Generate a Creative Commons Zero v1.0 Universal `LICENSE` file in the current working directory.
188
189**Example**
190
191```sh
192$ gen license:cc0-1.0
193$ gen license:cc0-1.0 --dest ./docs
194$ gen dest license:cc0-1.0
195```
196
197### [epl-1.0](generator.js#L129)
198
199Generate an Eclipse Public License 1.0 `LICENSE` file in the current working directory.
200
201**Example**
202
203```sh
204$ gen license:epl-1.0
205$ gen license:epl-1.0 --dest ./docs
206$ gen dest license:epl-1.0
207```
208
209### [gpl-2.0](generator.js#L146)
210
211Generate a GNU General Public License v2.0 `LICENSE` file in the current working directory.
212
213**Example**
214
215```sh
216$ gen license:gpl-2.0
217$ gen license:gpl-2.0 --dest ./docs
218$ gen dest license:gpl-2.0
219```
220
221### [gpl-3.0](generator.js#L163)
222
223Generate a GNU General Public License v3.0 `LICENSE` file in the current working directory.
224
225**Example**
226
227```sh
228$ gen license:gpl-3.0
229$ gen license:gpl-3.0 --dest ./docs
230$ gen dest license:gpl-3.0
231```
232
233### [isc](generator.js#L180)
234
235Generate a ISC License `LICENSE` file in the current working directory.
236
237**Example**
238
239```sh
240$ gen license:isc
241$ gen license:isc --dest ./docs
242$ gen dest license:isc
243```
244
245### [lgpl-2.1](generator.js#L197)
246
247Generate a GNU Lesser General Public License v2.1 `LICENSE` file in the current working directory.
248
249**Example**
250
251```sh
252$ gen license:lgpl-2.1
253$ gen license:lgpl-2.1 --dest ./docs
254$ gen dest license:lgpl-2.1
255```
256
257### [lgpl-3.0](generator.js#L217)
258
259Generate a GNU Lesser General Public License v3.0 `LICENSE.lesser` file in the current working directory.
260
261This will also generate a GNU General Public License v3.0 `LICENSE`
262file in the current working directory.
263
264**Example**
265
266```sh
267$ gen license:lgpl-3.0
268$ gen license:lgpl-3.0 --dest ./docs
269$ gen dest license:lgpl-3.0
270```
271
272### [mit](generator.js#L234)
273
274Generate a MIT License `LICENSE` file in the current working directory.
275
276**Example**
277
278```sh
279$ gen license:mit
280$ gen license:mit --dest ./docs
281$ gen dest license:mit
282```
283
284### [mpl-2.0](generator.js#L251)
285
286Generate a Mozilla Public License 2.0 `LICENSE` file in the current working directory.
287
288**Example**
289
290```sh
291$ gen license:mpl-2.0
292$ gen license:mpl-2.0 --dest ./docs
293$ gen dest license:mpl-2.0
294```
295
296### [unlicense](generator.js#L268)
297
298Generate a The Unlicense `UNLICENSE` file in the current working directory.
299
300**Example**
301
302```sh
303$ gen license:unlicense
304$ gen license:unlicense --dest ./docs
305$ gen dest license:unlicense
306```
307
308### [license](generator.js#L290)
309
310Prompts the user to choose the template to use for generating a `LICENSE` file in the current working directory. This task is also aliased as `choose-license` to provide a semantic name for API usage (e.g. `app.generate('choose-license', cb)`).
311
312**Example**
313
314```sh
315$ gen license
316$ gen license --dest ./docs
317$ gen dest license
318# or
319$ gen license:choose
320$ gen license:choose --dest ./docs
321$ gen dest license:choose
322```
323
324### [default](generator.js#L331)
325
326Alias for the [license](#license) task, to allow this generator to be run with the following command:
327
328**Example**
329
330```sh
331$ gen license
332```
333
334Visit Generate's [documentation for tasks](https://github.com/generate/generate/blob/master/docs/tasks.md).
335
336## API usage
337
338Use `generate-license` as a [plugin](https://github.com/generate/generate/blob/master/docs/plugins.md) in your own [generator](https://github.com/generate/generate/blob/master/docs/generators.md).
339
340### Install locally
341
342Install with [npm](https://www.npmjs.com/):
343
344```sh
345$ npm install --save generate-license
346```
347
348### Use as a plugin
349
350When used as a plugin, tasks from `generate-license` are added to your generator's instance.
351
352```js
353module.exports = function(app) {
354 app.use(require('generate-license'));
355 // do generator stuff
356};
357```
358
359**Running tasks**
360
361You can now run any tasks from `generate-license` as if they were part of your own generator.
362
363```js
364module.exports = function(app) {
365 app.use(require('generate-license'));
366
367 app.task('foo', function(cb) {
368 // do task stuff
369 cb();
370 });
371
372 // run the `mit` task from `generate-license`
373 app.task('default', ['foo', 'mit']);
374};
375```
376
377### Register as a generator
378
379When registered as a generator, tasks from `generate-license` are added to the "namespace" you give to the generator.
380
381```js
382module.exports = function(app) {
383 app.register('foo', require('generate-license'));
384 // generate
385};
386```
387
388**Running tasks**
389
390Pass the names of one or more tasks to run to the `.generate` method, prefixed with the namespace of the sub-generator (`foo`, in our example):
391
392**Examples**
393
394Run the [mit](#mit) task from `generate-license`:
395
396```js
397module.exports = function(app) {
398 app.register('foo', require('generate-license'));
399
400 app.generate('foo:mit', function(err) {
401 if (err) console.log(err);
402 });
403};
404```
405
406Wrap the call to `.generate` in a task, so it can be called on demand:
407
408```js
409module.exports = function(app) {
410 app.register('foo', require('generate-license'));
411
412 app.task('mit-license', function(cb) {
413 app.generate('foo:mit', cb);
414 });
415};
416```
417
418**More information**
419
420Visit the [generator docs](https://github.com/generate/generate/blob/master/docs/generators.md) to learn more about creating, installing, using and publishing generators.
421
422## Customization
423
424### Destination directory
425
426To customize the destination directory, install [generate-dest](https://github.com/generate/generate-dest) globally, then in the command line prefix `dest` before any other generator names.
427
428For example, the following will prompt you for the destination path to use, then pass the result to `generate-license`:
429
430```sh
431$ gen dest license
432```
433
434### Overriding templates
435
436You can override a template by adding a template of the same name to the `templates` directory in user home.
437
438For example, to override the `foo.tmpl` template, add a template at the following path `~/generate/templates/foo.tmpl`, where `~/` is the user-home directory that `os.homedir()` resolves to on your system.
439
440## About
441
442### Related projects
443
444* [generate-eslint](https://www.npmjs.com/package/generate-eslint): Generate a `.eslintrc.json` or `.eslintignore` file as part of a larger build workflow. This generator… [more](https://github.com/generate/generate-eslint) | [homepage](https://github.com/generate/generate-eslint "Generate a `.eslintrc.json` or `.eslintignore` file as part of a larger build workflow. This generator can be used as a sub-generator or plugin inside other generators.")
445* [generate-install](https://www.npmjs.com/package/generate-install): Generator that automatically detects the dependencies or devDependencies to install based on the templates or… [more](https://github.com/generate/generate-install) | [homepage](https://github.com/generate/generate-install "Generator that automatically detects the dependencies or devDependencies to install based on the templates or includes that are dynamically used by your generator. This can be used as a sub-generator or plugin in your own generator.")
446* [generate-package](https://www.npmjs.com/package/generate-package): Generate a package.json from a pre-defined or user-defined template. This generator can be used from… [more](https://github.com/generate/generate-package) | [homepage](https://github.com/generate/generate-package "Generate a package.json from a pre-defined or user-defined template. This generator can be used from the command line when globally installed, or as a plugin or sub-generator in your own generator.")
447
448### Contributing
449
450Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
451
452### Running tests
453
454Install dev dependencies:
455
456```sh
457$ npm install -d && npm test
458```
459
460### Author
461
462**Jon Schlinkert**
463
464* [github/jonschlinkert](https://github.com/jonschlinkert)
465* [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
466
467### License
468
469Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert).
470Released under the [MIT license](https://github.com/generate/generate-license/blob/master/LICENSE).
471
472***
473
474_This file was generated by [verb](https://github.com/verbose/verb), v0.9.0, on July 15, 2016._
\No newline at end of file