Skip to content

Commit

Permalink
feat(output): added logo in printHeader
Browse files Browse the repository at this point in the history
  • Loading branch information
rafinskipg committed Jun 4, 2015
1 parent f15a0c4 commit 6b48945
Show file tree
Hide file tree
Showing 11 changed files with 93 additions and 92 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ before_script:
after_script:
- istanbul cover node_modules/.bin/_mocha -- -R dot
- codeclimate < ./coverage/lcov.info
- grunt
13 changes: 8 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
<img width="300px" src="https://github.com/rafinskipg/git-changelog/raw/master/images/git-changelog-logo.png" />

__Git changelog__

_Git changelog is a utility tool for generating changelogs. It is free and opensource. :)_

# (2015-06-05)



---
<a name="">Version </a>
<img width="300px" src="http://upload.wikimedia.org/wikipedia/commons/4/4a/Logo_2013_Google.png" />
__null my name__
_a project by Google Corp_
# v (2015-06-04)

## Bug Fixes

Expand Down
30 changes: 27 additions & 3 deletions EXTENDEDCHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
<a name="">Git changelog extended</a>
# (2015-04-21)
<img width="300px" src="https://github.com/rafinskipg/git-changelog/raw/master/images/git-changelog-logo.png" />

__Git changelog extended__

_Git changelog is a utility tool for generating changelogs. It is free and opensource. :)_

# (2015-06-05)



---

## Bug Fixes

- Stream didn't close properly
([99f228cf](https://github.com/rafinskipg/git-changelog/commit/99f228cfa5cb26c46ef9e3b00171a5e3d38fd844))
- Github commit url
([c186f2d8](https://github.com/rafinskipg/git-changelog/commit/c186f2d877e7907305953610bcaaef331406178a))
- **checkPath:** add missing require('path')
([e5dab826](https://github.com/rafinskipg/git-changelog/commit/e5dab826062bd22dd37c8c3d3c24a4d9b4701f6d))
- **generate:** create path to file if it does not already exist
([62f6210f](https://github.com/rafinskipg/git-changelog/commit/62f6210f6895bcf5f9984b26948178b1a93cbc9e))
- **git_changelog_generate:** pass tag if it exists to gitReadLog
Expand Down Expand Up @@ -47,11 +59,14 @@
- **docs:**
- Angular document commits
- Added docs
- **lib:** simplify methods and refactor into separate files
- **writeChangelog:** method now returns a promise


## Chore

- a couple of spelling corrections [ci skip]
- minor edits to README
- fixing lint errors
- added chai-as-promise to handle methods that return promises
- updated travis config
Expand Down Expand Up @@ -79,14 +94,23 @@
- added node.js `0.12` to travis-ci config
- Updated readme
- package json version 1.1.3
- **lint:** fixing jshint errors
- **images:**
- add logo in JPEG format
- add logo in PNG format
- **lint:**
- add missing semicolon
- fix indentation
- have jshint ignore false positives
- fixing jshint errors
- **package:** Package json version
- **task:** cleanup unused requires


## Documentation

- added documentation for explaining the commit message
- Added docs
- **README:** add logo
- **readme:** Final readme Fixes #1 Closes #1


Expand Down
10 changes: 8 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,27 @@ module.exports = function(grunt) {
git_changelog: {
minimal: {
options: {
app_name : 'Git changelog'
app_name : 'Git changelog',
logo : 'https://github.com/rafinskipg/git-changelog/raw/master/images/git-changelog-logo.png',
intro : 'Git changelog is a utility tool for generating changelogs. It is free and opensource. :)'
}
},
tag1: {
options: {
app_name : 'Since tag 1 changelog',
file: 'output/tag1.md',
logo : 'https://github.com/rafinskipg/git-changelog/raw/master/images/git-changelog-logo.png',
version : 'squeezy potatoe',
tag: 'v0.0.1',
debug: true
}
},
extended: {
options: {
repo_url: 'https://github.com/rafinskipg/git-changelog',
app_name : 'Git changelog extended',
logo : 'https://github.com/rafinskipg/git-changelog/raw/master/images/git-changelog-logo.png',
intro : 'Git changelog is a utility tool for generating changelogs. It is free and opensource. :)',
repo_url: 'https://github.com/rafinskipg/git-changelog',
tag: false,
debug: true,
file : 'EXTENDEDCHANGELOG.md',
Expand Down
17 changes: 10 additions & 7 deletions output/tag1.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
<a name="">Version 0.2.0</a>
<img width="300px" src="https://github.com/rafinskipg/git-changelog/raw/master/images/git-changelog-logo.png" />

<img width="300px" src="http://upload.wikimedia.org/wikipedia/commons/4/4a/Logo_2013_Google.png" />
__Since tag 1 changelog__

__Git changelog__
# squeezy potatoe (2015-06-05)

_a project by Google Corp_


# v0.2.0 (2015-04-21)

---

## Bug Fixes

- Stream didn't close properly
([99f228cf](https://github.com/rafinskipg/git-changelog/commit/99f228cfa5cb26c46ef9e3b00171a5e3d38fd844))
- Github commit url
([c186f2d8](https://github.com/rafinskipg/git-changelog/commit/c186f2d877e7907305953610bcaaef331406178a))
- **checkPath:** add missing require('path')
([e5dab826](https://github.com/rafinskipg/git-changelog/commit/e5dab826062bd22dd37c8c3d3c24a4d9b4701f6d))
- **generate:** create path to file if it does not already exist
([62f6210f](https://github.com/rafinskipg/git-changelog/commit/62f6210f6895bcf5f9984b26948178b1a93cbc9e))
- **git_changelog_generate:** pass tag if it exists to gitReadLog
Expand Down Expand Up @@ -49,9 +51,10 @@ _a project by Google Corp_

- added documentation for explaining the commit message
- Added docs
- **README:** add logo
- **readme:** Final readme Fixes #1 Closes #1



---
<sub><sup>*Generated with [git-changelog](https://github.com/rafinskipg/git-changelog). If you have any problem or suggestion, create an issue.* :) **Thanks** </sub></sup>
<sub><sup>*Generated with [git-changelog](https://github.com/rafinskipg/git-changelog). If you have any problem or suggestion, create an issue.* :) **Thanks** </sub></sup>
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
},
"scripts": {
"pre-test": "grunt",
"post-test": "grunt",
"test": "mocha -R spec test/**/*.spec.js",
"coverage": "istanbul cover node_modules/.bin/_mocha -- -R dot"
},
Expand Down
4 changes: 4 additions & 0 deletions tasks/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ if (process.argv.join('').indexOf('/grunt') === -1) {
.option('-f, --file [file]', 'File [file]')
.option('-r, --repo_url [url]', 'Repo url [url]')
.option('-l, --logo [logo]', 'Logo path [logo]')
.option('-i, --intro [intro]', 'intro text [intro]')
.option('-t, --tag [tag]', 'Since tag [tag]')
.option('-g, --grep [grep]', 'Grep commits for [grep]')
.option('-d, --debug', 'Debugger')
Expand Down Expand Up @@ -50,6 +51,9 @@ if (process.argv.join('').indexOf('/grunt') === -1) {
if (program.logo){
options.logo = program.logo;
}
if (program.intro){
options.intro = program.intro;
}

if (program.url){
options.repo_url = program.url;
Expand Down
1 change: 1 addition & 0 deletions tasks/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module.exports = {
grep_commits: '^fix|^feat|^docs|BREAKING',
tag: null,
logo : null,
intro : null,
debug: false,
sections: [
{
Expand Down
2 changes: 2 additions & 0 deletions tasks/lib/init-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ function initOptions(params) {
this.options = _.defaults(params, defaults);
this.options.msg = '';
this.message('name', this.options.app_name);
this.message('intro', this.options.intro);
this.message('file', this.options.file);
this.message('logo', this.options.logo);
this.message('grep_commits', this.options.grep_commits);
this.message('debug', this.options.debug);
this.message('version', this.options.version);
Expand Down
24 changes: 17 additions & 7 deletions tasks/lib/print-header.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,28 @@

var debug = require('debug')('changelog:printHeader');
var format = require('util').format;
var tpl =
'<a name="">Version %s</a>\n\n'+
'<img width="300px" src="http://upload.wikimedia.org/wikipedia/commons/4/4a/Logo_2013_Google.png" />\n\n'+
'__%s %s__\n\n' +
'_a project by Google Corp_\n\n' +
'# v%s (%s)\n\n';

//Templates
var logoTemplate = '<img width="300px" src="%s" />\n\n';
var titleTemplate = '__%s__\n\n';
var subtitleTemplate = '_%s_\n\n';
var versionTemplate = '# %s %s (%s)\n\n';

function printHeader(stream, options, date) {

debug('printing header');
if(options.logo){
stream.write(format(logoTemplate, options.logo));
}

stream.write(format(titleTemplate, options.app_name));

if(options.intro){
stream.write(format(subtitleTemplate, options.intro));
}

stream.write(format(versionTemplate, options.version || '', options.versionName || '', date));
stream.write('\n\n---\n');
stream.write(format(tpl, options.version, options.logo, options.app_name, options.version, date));
}

module.exports = printHeader;
82 changes: 14 additions & 68 deletions test/git_changelog_generate.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ describe('git_changelog_generate.js', function() {
expect(changelog.options.msg).to.contain('logo: test');
});

it('should store "intro" if passed as an option', function() {
changelog.initOptions({ intro: 'test' });
expect(changelog.options.intro).to.equal('test');
expect(changelog.options.msg).to.contain('intro: test');
});

it('should store "grep_commits" if passed as an option', function() {
changelog.initOptions({ grep_commits: 'test' });
expect(changelog.options.grep_commits).to.equal('test');
Expand Down Expand Up @@ -422,6 +428,7 @@ describe('git_changelog_generate.js', function() {
sinon.stub(changelog, 'organizeCommits');
sinon.stub(changelog, 'printSalute');
sinon.stub(changelog, 'printSection');
sinon.stub(changelog, 'printHeader');

changelog.initOptions({ app_name: 'app', version: 'version' });
changelog.writeChangelog(this.stream, this.commits).then(function() {
Expand All @@ -432,6 +439,7 @@ describe('git_changelog_generate.js', function() {
after(function() {
changelog.organizeCommits.restore();
changelog.printSection.restore();
changelog.printHeader.restore();
changelog.printSalute.restore();
});

Expand All @@ -441,8 +449,8 @@ describe('git_changelog_generate.js', function() {
});

it('should write the header to the stream', function() {
expect(this.stream.write).to.have.been.calledOnce;
expect(this.stream.write).to.have.been.calledWithMatch(/^<a name=/);
expect(changelog.printHeader).to.have.been.calledOnce;
expect(changelog.printSalute).to.have.been.calledWith(this.stream);
});

it('should print 7 sections', function() {
Expand Down Expand Up @@ -489,6 +497,7 @@ describe('git_changelog_generate.js', function() {
});
sinon.stub(changelog, 'printSalute');
sinon.stub(changelog, 'printSection');
sinon.stub(changelog, 'printHeader');

changelog.initOptions({ app_name: 'app', version: 'version' });
changelog.writeChangelog(this.stream, this.commits).then(function() {
Expand All @@ -500,6 +509,7 @@ describe('git_changelog_generate.js', function() {
changelog.organizeCommits.restore();
changelog.printSection.restore();
changelog.printSalute.restore();
changelog.printHeader.restore();
});

it('should organize commits', function() {
Expand All @@ -508,8 +518,8 @@ describe('git_changelog_generate.js', function() {
});

it('should write the header to the stream', function() {
expect(this.stream.write).to.have.been.calledOnce;
expect(this.stream.write).to.have.been.calledWithMatch(/^<a name=/);
expect(changelog.printHeader).to.have.been.calledOnce;
expect(changelog.printHeader).to.have.been.calledWith(this.stream, changelog.options);
});

it('should print 8 sections', function() {
Expand Down Expand Up @@ -538,70 +548,6 @@ describe('git_changelog_generate.js', function() {

});

describe('with logo', function() {

before(function(done) {
this.stream = {
write: sinon.stub(),
end : function(){

},
on: sinon.spy(function(event, callback) {
callback();
})
};
this.commits = require('./fixtures/commits.js').withoutBreaking;

sinon.stub(changelog, 'organizeCommits');
sinon.stub(changelog, 'printSalute');
sinon.stub(changelog, 'printSection');

changelog.initOptions({ app_name: 'app', version: 'version' });
changelog.writeChangelog(this.stream, this.commits).then(function() {
done();
});
});

after(function() {
changelog.organizeCommits.restore();
changelog.printSection.restore();
changelog.printSalute.restore();
});

it('should organize commits', function() {
expect(changelog.organizeCommits).to.have.been.calledOnce;
expect(changelog.organizeCommits).to.have.been.calledWith(this.commits);
});

it('should write the header to the stream', function() {
expect(this.stream.write).to.have.been.calledOnce;
expect(this.stream.write).to.have.been.calledWithMatch(/^<a name=/);
});

it('should print 7 sections', function() {
var sections = [
'Bug Fixes',
'Features',
'Refactor',
'Style',
'Test',
'Chore',
'Documentation'
];

expect(changelog.printSection.callCount).to.equal(7);
sections.forEach(function(section, index) {
var call = changelog.printSection.getCall(index);
expect(call.args).to.include(section);
});
});

it('should print salute', function() {
expect(changelog.printSalute).to.have.been.calledOnce;
expect(changelog.printSalute).to.have.been.calledWith(this.stream);
});
});

});

describe('.organizeCommits()', function() {
Expand Down

0 comments on commit 6b48945

Please sign in to comment.