UNPKG

4.17 kBMarkdownView Raw
1# chg [![Build Status](https://secure.travis-ci.org/heff/chg.png?branch=master)](http://travis-ci.org/heff/chg)
2
3unfancy release history tracking
4
5[blog post](http://blog.heff.me/post/75189221194/introducing-chg-a-simple-changelog-cli-lib)
6
7functions:
8
9- `init` - create a CHANGELOG.md file
10- `add` - add new changes to the changelog under a 'HEAD (Unreleased)' heading
11- `release` - move all unreleased changes under a new release version
12
13`chg` can be useful when built into a release/deploy script or paired with a pull request merging script like [pulley](https://github.com/jeresig/pulley).
14
15It **does not** try to automatically generate changes from git commits or github pull requests, though you could build that on top of the `chg` functions.
16
17### Example
18
19```markdown
20CHANGELOG
21=========
22
23## HEAD (Unreleased)
24* Removed crusty semantic html, javascript app ftw
25
26--------------------
27
28## 2.0.0 (2007-3-13)
29* Removed horrible tables, semantic html ftw
30* Switched background to vertical gradient
31* Added dropshadows to EVERYTHING
32
33## 1.1.1 (2002-08-16)
34* Added a dot.gif to 3,000 table cells to fix layout issues
35
36## 1.1.0 (2002-05-17)
37* Removed horrible Flash, table layout ftw
38* Switched background to horizontal gray lines
39
40## 1.0.1 (2000-07-01)
41* Duplicated all Flash content in HTML so Yahoo can see it
42
43## 1.0.0 (2000-04-14)
44* Removed horrible frames, Flash ftw
45* Switched background to fast moving clouds like 2advanced V3
46
47## 0.1.0 (1997-01-26)
48* Added a "GIF" of a construction worker. ha ha ha
49* Navigation frame ftw
50* Added repeating tanbark background to look more professional
51
52```
53
54## Using globally
55
56```bash
57# install
58[sudo] npm install -g chg
59
60# create CHANGELOG.md
61chg init
62
63# add a change
64chg add 'My first change'
65
66# create a release
67chg release '0.0.1'
68```
69
70## Using as a node module
71
72shell
73```shell
74# install
75npm install chg --save
76```
77
78javascript
79```js
80var chg = require('chg');
81
82// create CHANGELOG.md
83chg.init({}, callback);
84
85// add a change
86chg.add('My first change', {}, callback);
87
88// create a release
89chg.release('0.0.1', {}, callback);
90
91// each command can take a callback, but each also returns synchronously
92var changeData = chg.release('3.0.0', {});
93// changeData = { title: '0.0.1', changes: '* Removed crusty semantic html, javascript app ftw', changeLog: '/* entire changelog */' }
94
95chg.find('1.1.1');
96// => { title: '## 1.1.1 (2002-08-16)', changes: ['* Added a dot.gif to 3,000 table cells to fix layout issues'], changesRaw: '* Added a dot.gif to 3,000 table cells to fix layout issues' }
97```
98
99## Using as a grunt plugin
100
101shell
102```shell
103# install
104npm install chg --save-dev
105```
106
107Gruntfile.js
108```js
109grunt.loadNpmTasks('chg');
110```
111
112shell
113```shell
114# create CHANGELOG.md
115grunt chg-init
116
117# add a change
118grunt chg-add
119
120# create a release
121grunt chg-release
122```
123
124## Using as a npm script (requires npm v2.13.0 or higher)
125
126```json
127"scripts": {
128 "version": "chg release -y && git add -A CHANGELOG.md"
129}
130```
131
132**The `-y` flag will use the current version in `package.json`**
133
134## Functions
135
136### init()
137Creates a CHANGELOG.md file in the current directory.
138
139```bash
140chg init
141```
142
143```markdown
144CHANGELOG
145=========
146
147## HEAD (Unreleased)
148* _(none)_
149
150--------------------
151```
152
153### add(line:String)
154Add a line to the change log. The first argument is the line to add.
155
156```bash
157chg add "My new change!"
158```
159
160```markdown
161CHANGELOG
162=========
163
164## HEAD (Unreleased)
165* My new change!
166
167--------------------
168```
169
170### release(version:String)
171Add a line to the change log. The first argument is the version to be used as the release version.
172
173```bash
174chg release "v0.1.0"
175```
176
177```markdown
178CHANGELOG
179=========
180
181## HEAD (Unreleased)
182* _(none)_
183
184--------------------
185
186## 0.1.0 (2014-01-31)
187* My new change!
188```
189
190### find(version:String)
191Finds a release given a version.
192
193### delete()
194Delete the current changelog
195
196## Release History
197See [CHANGELOG.md](CHANGELOG.md) :scream_cat:
198
199## License
200Copyright (c) 2014 heff. Licensed under the Apache license.