Skip to content
This repository was archived by the owner on Feb 5, 2018. It is now read-only.

Commit 79a8c6b

Browse files
committed
0 parents  commit 79a8c6b

File tree

13 files changed

+387
-0
lines changed

13 files changed

+387
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
tmp

.jscsrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"preset": "google",
3+
"maximumLineLength": null,
4+
"excludeFiles": ["node_modules/**"]
5+
}

.jshintrc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"boss": true,
3+
"curly": true,
4+
"eqeqeq": true,
5+
"eqnull": true,
6+
"immed": true,
7+
"latedef": true,
8+
"mocha" : true,
9+
"newcap": true,
10+
"noarg": true,
11+
"node": true,
12+
"sub": true,
13+
"undef": true,
14+
"unused": true
15+
}

.travis.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
language: node_js
2+
node_js:
3+
- '5'
4+
- '4'
5+
- '3'
6+
- '2'
7+
- '1'
8+
- '0.12'
9+
- '0.10'
10+
before_script:
11+
- git config --global user.name 'Travis-CI'
12+
- git config --global user.email '[email protected]'
13+
after_script: NODE_ENV=test istanbul cover ./node_modules/mocha/bin/_mocha -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage

convention.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#### Examples
2+
3+
Appears under "Features" header, pencil subheader:
4+
5+
```
6+
feat(pencil): add 'graphiteWidth' option
7+
```
8+
9+
Appears under "Bug Fixes" header, graphite subheader, with a link to issue #28:
10+
11+
```
12+
fix(graphite): stop graphite breaking when width < 0.1
13+
14+
Closes #28
15+
```
16+
17+
Appears under "Performance Improvements" header, and under "Breaking Changes" with the breaking change explanation:
18+
19+
```
20+
perf(pencil): remove graphiteWidth option
21+
22+
BREAKING CHANGE: The graphiteWidth option has been removed. The default graphite width of 10mm is always used for performance reason.
23+
```
24+
25+
The following commit and commit `667ecc1` do not appear in the changelog if they are under the same release. If not, the revert commit appears under the "Reverts" header.
26+
27+
```
28+
revert: feat(pencil): add 'graphiteWidth' option
29+
30+
This reverts commit 667ecc1654a317a13331b17617d973392f415f02.
31+
```
32+
33+
### Commit Message Format
34+
35+
A commit message consists of a **header**, **body** and **footer**. The header has a **type**, **scope** and **subject**:
36+
37+
```
38+
<type>(<scope>): <subject>
39+
<BLANK LINE>
40+
<body>
41+
<BLANK LINE>
42+
<footer>
43+
```
44+
45+
The **header** is mandatory and the **scope** of the header is optional.
46+
47+
Any line of the commit message cannot be longer 100 characters! This allows the message to be easier
48+
to read on GitHub as well as in various git tools.
49+
50+
### Revert
51+
52+
If the commit reverts a previous commit, it should begin with `revert: `, followed by the header of the reverted commit. In the body it should say: `This reverts commit <hash>.`, where the hash is the SHA of the commit being reverted.
53+
54+
### Type
55+
56+
If the prefix is `feat`, `fix` or `perf`, it will always appear in the changelog.
57+
58+
Other prefixes are up to your discretion. Suggested prefixes are `docs`, `chore`, `style`, `refactor`, and `test` for non-changelog related tasks.
59+
60+
### Scope
61+
62+
The scope could be anything specifying place of the commit change. For example `$location`,
63+
`$browser`, `$compile`, `$rootScope`, `ngHref`, `ngClick`, `ngView`, etc...
64+
65+
### Subject
66+
67+
The subject contains succinct description of the change:
68+
69+
* use the imperative, present tense: "change" not "changed" nor "changes"
70+
* don't capitalize first letter
71+
* no dot (.) at the end
72+
73+
### Body
74+
75+
Just as in the **subject**, use the imperative, present tense: "change" not "changed" nor "changes".
76+
The body should include the motivation for the change and contrast this with previous behavior.
77+
78+
### Footer
79+
80+
The footer should contain any information about **Breaking Changes** and is also the place to
81+
reference GitHub issues that this commit **Closes**.
82+
83+
**Breaking Changes** should start with the word `BREAKING CHANGE:` with a space or two newlines. The rest of the commit message is then used for this.
84+
85+
A detailed explanation can be found in this [document][commit-message-format].
86+
87+
Based on https://github.com/angular/angular.js/blob/master/CONTRIBUTING.md#commit
88+
89+
[commit-message-format]: https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit#

index.js

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
'use strict';
2+
var compareFunc = require('compare-func');
3+
var Q = require('q');
4+
var readFile = Q.denodeify(require('fs').readFile);
5+
var resolve = require('path').resolve;
6+
var semver = require('semver');
7+
var _ = require('lodash');
8+
9+
function presetOpts() {
10+
var parserOpts = {
11+
headerPattern: /^(\w*)(?:\((.*)\))?\: (.*)$/,
12+
headerCorrespondence: [
13+
'type',
14+
'scope',
15+
'subject'
16+
],
17+
noteKeywords: 'BREAKING CHANGE',
18+
revertPattern: /^revert:\s([\s\S]*?)\s*This reverts commit (\w*)\./,
19+
revertCorrespondence: ['header', 'hash']
20+
};
21+
22+
var writerOpts = {
23+
transform: function(commit) {
24+
if (commit.type === 'feat') {
25+
commit.type = 'Features';
26+
} else if (commit.type === 'fix') {
27+
commit.type = 'Bug Fixes';
28+
} else if (commit.type === 'perf') {
29+
commit.type = 'Performance Improvements';
30+
} else if (commit.type === 'revert') {
31+
commit.type = 'Reverts';
32+
} else {
33+
return;
34+
}
35+
36+
if (commit.scope === '*') {
37+
commit.scope = '';
38+
}
39+
40+
if (typeof commit.hash === 'string') {
41+
commit.hash = commit.hash.substring(0, 7);
42+
}
43+
44+
if (typeof commit.subject === 'string') {
45+
commit.subject = commit.subject.substring(0, 80);
46+
}
47+
48+
_.map(commit.notes, function(note) {
49+
if (note.title === 'BREAKING CHANGE') {
50+
note.title = 'BREAKING CHANGES';
51+
}
52+
53+
return note;
54+
});
55+
56+
return commit;
57+
},
58+
groupBy: 'type',
59+
commitGroupsSort: 'title',
60+
commitsSort: ['scope', 'subject'],
61+
noteGroupsSort: 'title',
62+
notesSort: compareFunc,
63+
generateOn: function(commit) {
64+
return semver.valid(commit.version);
65+
}
66+
};
67+
68+
return Q.all([
69+
readFile(resolve(__dirname, 'templates/template.hbs'), 'utf-8'),
70+
readFile(resolve(__dirname, 'templates/header.hbs'), 'utf-8'),
71+
readFile(resolve(__dirname, 'templates/commit.hbs'), 'utf-8'),
72+
readFile(resolve(__dirname, 'templates/footer.hbs'), 'utf-8')
73+
])
74+
.spread(function(template, header, commit, footer) {
75+
writerOpts.mainTemplate = template;
76+
writerOpts.headerPartial = header;
77+
writerOpts.commitPartial = commit;
78+
writerOpts.footerPartial = footer;
79+
80+
return {
81+
parserOpts: parserOpts,
82+
writerOpts: writerOpts
83+
};
84+
});
85+
}
86+
87+
module.exports = presetOpts;

package.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"name": "conventional-changelog-angular",
3+
"version": "0.0.0",
4+
"description": "conventional-changelog angular preset",
5+
"main": "index.js",
6+
"scripts": {
7+
"coverage": "istanbul cover _mocha -- -R spec && rm -rf ./coverage",
8+
"lint": "jshint *.js --exclude node_modules && jscs *.js",
9+
"test": "mocha && npm run-script lint"
10+
},
11+
"repository": {
12+
"type": "git",
13+
"url": "git+https://github.com/stevemao/conventional-changelog-angular.git"
14+
},
15+
"keywords": [
16+
"conventional-changelog",
17+
"angular",
18+
"preset"
19+
],
20+
"author": "Steve Mao",
21+
"license": "ISC",
22+
"bugs": {
23+
"url": "https://github.com/stevemao/conventional-changelog-angular/issues"
24+
},
25+
"homepage": "https://github.com/stevemao/conventional-changelog-angular#readme",
26+
"devDependencies": {
27+
"chai": "^3.4.1",
28+
"conventional-changelog-core": "0.0.1",
29+
"coveralls": "^2.11.6",
30+
"git-dummy-commit": "^1.1.1",
31+
"jscs": "^2.7.0",
32+
"jshint": "^2.9.1-rc2",
33+
"mocha": "*",
34+
"shelljs": "^0.5.3",
35+
"through2": "^2.0.0"
36+
},
37+
"dependencies": {
38+
"compare-func": "^1.3.1",
39+
"lodash": "^3.10.1",
40+
"q": "^1.4.1",
41+
"semver": "^5.1.0"
42+
}
43+
}

readme.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url] [![Coverage Status][coveralls-image]][coveralls-url]
2+
3+
> [conventional-changelog](https://github.com/ajoslin/conventional-changelog) angular preset
4+
5+
6+
See [conventional](convention.md)
7+
8+
9+
[npm-image]: https://badge.fury.io/js/conventional-changelog-angular.svg
10+
[npm-url]: https://npmjs.org/package/conventional-changelog-angular
11+
[travis-image]: https://travis-ci.org/stevemao/conventional-changelog-angular.svg?branch=master
12+
[travis-url]: https://travis-ci.org/stevemao/conventional-changelog-angular
13+
[daviddm-image]: https://david-dm.org/stevemao/conventional-changelog-angular.svg?theme=shields.io
14+
[daviddm-url]: https://david-dm.org/stevemao/conventional-changelog-angular
15+
[coveralls-image]: https://coveralls.io/repos/stevemao/conventional-changelog-angular/badge.svg
16+
[coveralls-url]: https://coveralls.io/r/stevemao/conventional-changelog-angular

templates/commit.hbs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*{{#if scope}} **{{scope}}:**{{/if}} {{#if subject}}{{subject}}{{else}}{{header}}{{/if}}
2+
3+
{{~!-- commit hash --}} {{#if @root.linkReferences}}([{{hash}}]({{#if @root.host}}{{@root.host}}/{{/if}}{{#if @root.owner}}{{@root.owner}}/{{/if}}{{@root.repository}}/{{@root.commit}}/{{hash}})){{else}}{{hash~}}{{/if}}
4+
5+
{{~!-- commit references --}}{{#if references}}, closes{{~#each references}} {{#if @root.linkReferences}}[{{#if this.owner}}{{this.owner}}/{{/if}}{{this.repository}}#{{this.issue}}]({{#if @root.host}}{{@root.host}}/{{/if}}{{#if this.repository}}{{#if this.owner}}{{this.owner}}/{{/if}}{{this.repository}}{{else}}{{#if @root.owner}}{{@root.owner}}/{{/if}}{{@root.repository}}{{/if}}/{{@root.issue}}/{{this.issue}}){{else}}{{#if this.owner}}{{this.owner}}/{{/if}}{{this.repository}}#{{this.issue}}{{/if}}{{/each}}{{/if}}

templates/footer.hbs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{{#if noteGroups}}
2+
{{#each noteGroups}}
3+
4+
### {{title}}
5+
6+
{{#each notes}}
7+
* {{#if commit.scope}}{{commit.scope}}: {{/if}}{{text}}
8+
{{/each}}
9+
{{/each}}
10+
11+
{{/if}}

0 commit comments

Comments
 (0)