This repository has been archived by the owner on Feb 5, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(init): extracting code from https://github.com/ajoslin/conventio…
- Loading branch information
0 parents
commit 79a8c6b
Showing
13 changed files
with
387 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"preset": "google", | ||
"maximumLineLength": null, | ||
"excludeFiles": ["node_modules/**"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"boss": true, | ||
"curly": true, | ||
"eqeqeq": true, | ||
"eqnull": true, | ||
"immed": true, | ||
"latedef": true, | ||
"mocha" : true, | ||
"newcap": true, | ||
"noarg": true, | ||
"node": true, | ||
"sub": true, | ||
"undef": true, | ||
"unused": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
language: node_js | ||
node_js: | ||
- '5' | ||
- '4' | ||
- '3' | ||
- '2' | ||
- '1' | ||
- '0.12' | ||
- '0.10' | ||
before_script: | ||
- git config --global user.name 'Travis-CI' | ||
- git config --global user.email 'dummy@example.org' | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
#### Examples | ||
|
||
Appears under "Features" header, pencil subheader: | ||
|
||
``` | ||
feat(pencil): add 'graphiteWidth' option | ||
``` | ||
|
||
Appears under "Bug Fixes" header, graphite subheader, with a link to issue #28: | ||
|
||
``` | ||
fix(graphite): stop graphite breaking when width < 0.1 | ||
Closes #28 | ||
``` | ||
|
||
Appears under "Performance Improvements" header, and under "Breaking Changes" with the breaking change explanation: | ||
|
||
``` | ||
perf(pencil): remove graphiteWidth option | ||
BREAKING CHANGE: The graphiteWidth option has been removed. The default graphite width of 10mm is always used for performance reason. | ||
``` | ||
|
||
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. | ||
|
||
``` | ||
revert: feat(pencil): add 'graphiteWidth' option | ||
This reverts commit 667ecc1654a317a13331b17617d973392f415f02. | ||
``` | ||
|
||
### Commit Message Format | ||
|
||
A commit message consists of a **header**, **body** and **footer**. The header has a **type**, **scope** and **subject**: | ||
|
||
``` | ||
<type>(<scope>): <subject> | ||
<BLANK LINE> | ||
<body> | ||
<BLANK LINE> | ||
<footer> | ||
``` | ||
|
||
The **header** is mandatory and the **scope** of the header is optional. | ||
|
||
Any line of the commit message cannot be longer 100 characters! This allows the message to be easier | ||
to read on GitHub as well as in various git tools. | ||
|
||
### Revert | ||
|
||
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. | ||
|
||
### Type | ||
|
||
If the prefix is `feat`, `fix` or `perf`, it will always appear in the changelog. | ||
|
||
Other prefixes are up to your discretion. Suggested prefixes are `docs`, `chore`, `style`, `refactor`, and `test` for non-changelog related tasks. | ||
|
||
### Scope | ||
|
||
The scope could be anything specifying place of the commit change. For example `$location`, | ||
`$browser`, `$compile`, `$rootScope`, `ngHref`, `ngClick`, `ngView`, etc... | ||
|
||
### Subject | ||
|
||
The subject contains succinct description of the change: | ||
|
||
* use the imperative, present tense: "change" not "changed" nor "changes" | ||
* don't capitalize first letter | ||
* no dot (.) at the end | ||
|
||
### Body | ||
|
||
Just as in the **subject**, use the imperative, present tense: "change" not "changed" nor "changes". | ||
The body should include the motivation for the change and contrast this with previous behavior. | ||
|
||
### Footer | ||
|
||
The footer should contain any information about **Breaking Changes** and is also the place to | ||
reference GitHub issues that this commit **Closes**. | ||
|
||
**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. | ||
|
||
A detailed explanation can be found in this [document][commit-message-format]. | ||
|
||
Based on https://github.com/angular/angular.js/blob/master/CONTRIBUTING.md#commit | ||
|
||
[commit-message-format]: https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
'use strict'; | ||
var compareFunc = require('compare-func'); | ||
var Q = require('q'); | ||
var readFile = Q.denodeify(require('fs').readFile); | ||
var resolve = require('path').resolve; | ||
var semver = require('semver'); | ||
var _ = require('lodash'); | ||
|
||
function presetOpts() { | ||
var parserOpts = { | ||
headerPattern: /^(\w*)(?:\((.*)\))?\: (.*)$/, | ||
headerCorrespondence: [ | ||
'type', | ||
'scope', | ||
'subject' | ||
], | ||
noteKeywords: 'BREAKING CHANGE', | ||
revertPattern: /^revert:\s([\s\S]*?)\s*This reverts commit (\w*)\./, | ||
revertCorrespondence: ['header', 'hash'] | ||
}; | ||
|
||
var writerOpts = { | ||
transform: function(commit) { | ||
if (commit.type === 'feat') { | ||
commit.type = 'Features'; | ||
} else if (commit.type === 'fix') { | ||
commit.type = 'Bug Fixes'; | ||
} else if (commit.type === 'perf') { | ||
commit.type = 'Performance Improvements'; | ||
} else if (commit.type === 'revert') { | ||
commit.type = 'Reverts'; | ||
} else { | ||
return; | ||
} | ||
|
||
if (commit.scope === '*') { | ||
commit.scope = ''; | ||
} | ||
|
||
if (typeof commit.hash === 'string') { | ||
commit.hash = commit.hash.substring(0, 7); | ||
} | ||
|
||
if (typeof commit.subject === 'string') { | ||
commit.subject = commit.subject.substring(0, 80); | ||
} | ||
|
||
_.map(commit.notes, function(note) { | ||
if (note.title === 'BREAKING CHANGE') { | ||
note.title = 'BREAKING CHANGES'; | ||
} | ||
|
||
return note; | ||
}); | ||
|
||
return commit; | ||
}, | ||
groupBy: 'type', | ||
commitGroupsSort: 'title', | ||
commitsSort: ['scope', 'subject'], | ||
noteGroupsSort: 'title', | ||
notesSort: compareFunc, | ||
generateOn: function(commit) { | ||
return semver.valid(commit.version); | ||
} | ||
}; | ||
|
||
return Q.all([ | ||
readFile(resolve(__dirname, 'templates/template.hbs'), 'utf-8'), | ||
readFile(resolve(__dirname, 'templates/header.hbs'), 'utf-8'), | ||
readFile(resolve(__dirname, 'templates/commit.hbs'), 'utf-8'), | ||
readFile(resolve(__dirname, 'templates/footer.hbs'), 'utf-8') | ||
]) | ||
.spread(function(template, header, commit, footer) { | ||
writerOpts.mainTemplate = template; | ||
writerOpts.headerPartial = header; | ||
writerOpts.commitPartial = commit; | ||
writerOpts.footerPartial = footer; | ||
|
||
return { | ||
parserOpts: parserOpts, | ||
writerOpts: writerOpts | ||
}; | ||
}); | ||
} | ||
|
||
module.exports = presetOpts; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"name": "conventional-changelog-angular", | ||
"version": "0.0.0", | ||
"description": "conventional-changelog angular preset", | ||
"main": "index.js", | ||
"scripts": { | ||
"coverage": "istanbul cover _mocha -- -R spec && rm -rf ./coverage", | ||
"lint": "jshint *.js --exclude node_modules && jscs *.js", | ||
"test": "mocha && npm run-script lint" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/stevemao/conventional-changelog-angular.git" | ||
}, | ||
"keywords": [ | ||
"conventional-changelog", | ||
"angular", | ||
"preset" | ||
], | ||
"author": "Steve Mao", | ||
"license": "ISC", | ||
"bugs": { | ||
"url": "https://github.com/stevemao/conventional-changelog-angular/issues" | ||
}, | ||
"homepage": "https://github.com/stevemao/conventional-changelog-angular#readme", | ||
"devDependencies": { | ||
"chai": "^3.4.1", | ||
"conventional-changelog-core": "0.0.1", | ||
"coveralls": "^2.11.6", | ||
"git-dummy-commit": "^1.1.1", | ||
"jscs": "^2.7.0", | ||
"jshint": "^2.9.1-rc2", | ||
"mocha": "*", | ||
"shelljs": "^0.5.3", | ||
"through2": "^2.0.0" | ||
}, | ||
"dependencies": { | ||
"compare-func": "^1.3.1", | ||
"lodash": "^3.10.1", | ||
"q": "^1.4.1", | ||
"semver": "^5.1.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url] [![Coverage Status][coveralls-image]][coveralls-url] | ||
|
||
> [conventional-changelog](https://github.com/ajoslin/conventional-changelog) angular preset | ||
|
||
See [conventional](convention.md) | ||
|
||
|
||
[npm-image]: https://badge.fury.io/js/conventional-changelog-angular.svg | ||
[npm-url]: https://npmjs.org/package/conventional-changelog-angular | ||
[travis-image]: https://travis-ci.org/stevemao/conventional-changelog-angular.svg?branch=master | ||
[travis-url]: https://travis-ci.org/stevemao/conventional-changelog-angular | ||
[daviddm-image]: https://david-dm.org/stevemao/conventional-changelog-angular.svg?theme=shields.io | ||
[daviddm-url]: https://david-dm.org/stevemao/conventional-changelog-angular | ||
[coveralls-image]: https://coveralls.io/repos/stevemao/conventional-changelog-angular/badge.svg | ||
[coveralls-url]: https://coveralls.io/r/stevemao/conventional-changelog-angular |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
*{{#if scope}} **{{scope}}:**{{/if}} {{#if subject}}{{subject}}{{else}}{{header}}{{/if}} | ||
|
||
{{~!-- 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}} | ||
|
||
{{~!-- 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}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{{#if noteGroups}} | ||
{{#each noteGroups}} | ||
|
||
### {{title}} | ||
|
||
{{#each notes}} | ||
* {{#if commit.scope}}{{commit.scope}}: {{/if}}{{text}} | ||
{{/each}} | ||
{{/each}} | ||
|
||
{{/if}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<a name="{{version}}"></a> | ||
{{#if isPatch}}##{{else}}#{{/if}} {{#if @root.linkCompare}}[{{version}}]({{@root.host}}/{{#if @root.owner}}{{@root.owner}}/{{/if}}{{@root.repository}}/compare/{{previousTag}}...{{currentTag}}){{else}}{{version}}{{/if}}{{#if title}} "{{title}}"{{/if}}{{#if date}} ({{date}}){{/if}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{{> header}} | ||
|
||
{{#each commitGroups}} | ||
|
||
{{#if title}} | ||
### {{title}} | ||
|
||
{{/if}} | ||
{{#each commits}} | ||
{{> commit root=@root}} | ||
{{/each}} | ||
{{/each}} | ||
|
||
{{> footer}} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
'use strict'; | ||
var child = require('child_process'); | ||
var conventionalChangelogCore = require('conventional-changelog-core'); | ||
var expect = require('chai').expect; | ||
var gitDummyCommit = require('git-dummy-commit'); | ||
var shell = require('shelljs'); | ||
var through = require('through2'); | ||
var preset = require('./')(); | ||
|
||
describe('angular preset', function() { | ||
before(function(done) { | ||
shell.config.silent = true; | ||
shell.rm('-rf', 'tmp'); | ||
shell.mkdir('tmp'); | ||
shell.cd('tmp'); | ||
shell.mkdir('git-templates'); | ||
shell.exec('git init --template=./git-templates'); | ||
|
||
gitDummyCommit('chore: first commit'); | ||
// fix this until https://github.com/arturadib/shelljs/issues/175 is solved | ||
child.exec('git commit -m"feat: amazing new module\n\nBREAKING CHANGE: Not backward compatible." --allow-empty', function() { | ||
gitDummyCommit(['fix(compile): avoid a bug', 'BREAKING CHANGE: The Change is huge.']); | ||
gitDummyCommit('perf(ngOptions): make it faster'); | ||
gitDummyCommit('revert(ngOptions): make it faster'); | ||
gitDummyCommit('fix(*): oops'); | ||
|
||
done(); | ||
}); | ||
}); | ||
|
||
it('should work if there is no semver tag', function(done) { | ||
conventionalChangelogCore({ | ||
config: preset | ||
}) | ||
.pipe(through(function(chunk) { | ||
chunk = chunk.toString(); | ||
|
||
expect(chunk).to.include('amazing new module'); | ||
expect(chunk).to.include('avoid a bug'); | ||
expect(chunk).to.include('make it faster'); | ||
expect(chunk).to.include('Not backward compatible.'); | ||
expect(chunk).to.include('compile: The Change is huge.'); | ||
expect(chunk).to.include('Features'); | ||
expect(chunk).to.include('Bug Fixes'); | ||
expect(chunk).to.include('Performance Improvements'); | ||
expect(chunk).to.include('Reverts'); | ||
expect(chunk).to.include('BREAKING CHANGES'); | ||
|
||
expect(chunk).to.not.include('first commit'); | ||
expect(chunk).to.not.include('feat'); | ||
expect(chunk).to.not.include('fix'); | ||
expect(chunk).to.not.include('perf'); | ||
expect(chunk).to.not.include('revert'); | ||
expect(chunk).to.not.include('***:**'); | ||
expect(chunk).to.not.include(': Not backward compatible.'); | ||
|
||
done(); | ||
})); | ||
}); | ||
|
||
it('should work if there is a semver tag', function(done) { | ||
var i = 0; | ||
|
||
shell.exec('git tag v1.0.0'); | ||
gitDummyCommit('feat: some more features'); | ||
|
||
conventionalChangelogCore({ | ||
config: preset | ||
}) | ||
.pipe(through(function(chunk, enc, cb) { | ||
chunk = chunk.toString(); | ||
|
||
expect(chunk).to.include('some more features'); | ||
expect(chunk).to.not.include('BREAKING'); | ||
|
||
i++; | ||
cb(); | ||
}, function() { | ||
expect(i).to.equal(1); | ||
done(); | ||
})); | ||
}); | ||
}); |