UNPKG

6.21 kBMarkdownView Raw
1
2# autod
3
4[![NPM version][npm-image]][npm-url]
5[![David deps][david-image]][david-url]
6[![node version][node-image]][node-url]
7[![Gittip][gittip-image]][gittip-url]
8
9[npm-image]: https://img.shields.io/npm/v/autod.svg?style=flat-square
10[npm-url]: https://npmjs.org/package/autod
11[david-image]: https://img.shields.io/david/node-modules/autod.svg?style=flat-square
12[david-url]: https://david-dm.org/node-modules/autod
13[node-image]: https://img.shields.io/badge/node.js-%3E=_0.10-green.svg?style=flat-square
14[node-url]: http://nodejs.org/download/
15[gittip-image]: https://img.shields.io/gittip/dead-horse.svg?style=flat-square
16[gittip-url]: https://www.gittip.com/dead-horse/
17
18Auto generate dependencies and devDependencies by parse the project file.
19`autod` will parse all the js files in `path`, and get the latest dependencies version from [registry.npmjs.org](https://registry.npmjs.org) or other registries by `-r`.
20
21## install
22
23```bash
24$ npm install -g autod
25```
26
27## usage
28
29```bash
30$ bin/autod -h
31
32 Usage: autod [options]
33
34 Options:
35
36 -h, --help output usage information
37 -V, --version output the version number
38 -p, --path [root path] the root path to be parse
39 -t, --test <test/benchmark/example directory paths> modules in these paths will be tread as devDependencies
40 -e, --exclude <exclude directory path> exclude parse directory, split by `,`
41 -r, --registry <remote registry> get latest version from which registry
42 -f, --prefix [version prefix] version prefix, can be `~` or `^`
43 -F, --devprefix [dev dependencies version prefix] develop dependencies version prefix, can be `~` or `^`
44 -w, --write write dependencies into package.json
45 -i, --ignore ignore errors, display the dependencies or write the dependencies.
46 -m, --map display all the dependencies require by which file
47 -d, --dep <dependently modules> modules that not require in source file, but you need them as dependencies
48 -D, --devdep <dev dependently modules> modules that not require in source file, but you need them in as devDependencies
49 -k, --keep <dependently modules> modules that you want to keep version in package.json file
50 -s, --semver <dependencies@version> auto update these modules within the specified semver
51```
52
53* Autod will parse all the js files in `path`, and you can exclude folder by `-e, --exclude`.
54* All the modules in test folder (can be alter by `-t, --text`) will parsed as devDependencies.
55* If you set `-w, --write`, `autod` will write the dependencies into package.json file. `dependencies` will replace `dependencies` in package.json, and `devDependencies` will merge with `devDependencies` in package.json, then write into package file.
56* `-f, --prefix` will add prefix to each dependencies' version.
57* `-F, --devprefix` will add prefix to each dev dependencies' version.
58* `-i, --ignore` will display or wrtie the dependencies even some error happened.
59* `-d --dep` will add modules to dependencies even not require by any file.
60* `-D --devdep` will add modules to devDependencies even not require by any file.
61* `-k --keep` will keep the modules' version in package.json not change by autod.
62* `-s, --semver` will update these modules within the specified semver.
63* `-n, --notransform` disable transfrom es next, don't support es6 modules.
64
65a simple example of autod:
66
67```
68autod -w --prefix="~" -d connect -D mocha,should -k express -s connect@2
69```
70
71## Maintains your dependencies in Makefile
72
73add a command in your Makefile
74
75```sh
76autod:
77 @./node_modules/.bin/autod -w
78 @npm install
79
80```
81
82then run `make autod`, it will find all the dependencies and devDependencies in your project,
83add / remove dependencies, and bump the versions.
84
85check out some examples:
86
87 - [cnpmjs.org](https://github.com/cnpm/cnpmjs.org/blob/master/Makefile#L95)
88 - [koa-generic-session](https://github.com/koajs/generic-session/blob/master/Makefile#L40)
89
90## es6 modules support
91
92All files will compiled by `babel` with `babel-preset-react`, `babel-preset-es2015`, `babel-preset-stage-0`.
93
94## Plugin support
95
96You can write a plugin for autod to decide how to parse dependencies.
97
98- Write a plugin, and publish it to NPM.
99
100```js
101module.exports = function (filepath, content) {
102 // find the dependencies
103 return []; // return dependencies
104};
105```
106
107- Use plugin:
108
109install plugin from NPM, then use it with `autod`:
110
111```
112autod -P pluginName
113```
114
115## Config support
116
117You can put all the options in `${cwd}/.autod.conf.js`, when you run `autod`, it will load this file as input options. It can be both a `js` file or a `json` file.
118
119```js
120module.exports = {
121 write: true,
122 prefix: '~',
123 devprefix: '^',
124 dep: [
125 'bluebird'
126 ],
127 semver: [
128 'koa-router@4',
129 'koa-compose@2'
130 ],
131};
132```
133
134## License
135
136(The MIT License)
137
138Copyright (c) 2013~2015 dead_horse <dead_horse@qq.com>;
139
140Permission is hereby granted, free of charge, to any person obtaining
141a copy of this software and associated documentation files (the
142'Software'), to deal in the Software without restriction, including
143without limitation the rights to use, copy, modify, merge, publish,
144distribute, sublicense, and/or sell copies of the Software, and to
145permit persons to whom the Software is furnished to do so, subject to
146the following conditions:
147
148The above copyright notice and this permission notice shall be
149included in all copies or substantial portions of the Software.
150
151THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
152EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
153MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
154IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
155CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
156TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
157SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.