├── .travis.yml ├── lib ├── util.js ├── file.js ├── log.js ├── config.js ├── git.js └── generate.js ├── .jsbeautifyrc ├── .gitignore ├── package.json ├── .clgtrc ├── LICENSE ├── index.js ├── CHANGELOG.md ├── README.md ├── test ├── git.js └── generate.js └── .eslintrc /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | 3 | node_js: 4 | - "4" 5 | 6 | install: 7 | - npm install 8 | 9 | script: 10 | - npm test 11 | 12 | after_success: 13 | - npm run coveralls 14 | -------------------------------------------------------------------------------- /lib/util.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | var _ = require('lodash'); 5 | 6 | 7 | exports.groupByMulti = function(obj, values) { 8 | 9 | if (!values.length) { 10 | return obj; 11 | } 12 | var byFirst = _.groupBy(obj, values[0]), 13 | rest = values.slice(1); 14 | 15 | _.forOwn(byFirst, function(value, prop) { 16 | byFirst[prop] = exports.groupByMulti(byFirst[prop], rest); 17 | }); 18 | return byFirst; 19 | }; 20 | 21 | 22 | exports.capitalize = function(str) { 23 | 24 | return str.charAt(0).toUpperCase() + str.slice(1); 25 | }; 26 | -------------------------------------------------------------------------------- /.jsbeautifyrc: -------------------------------------------------------------------------------- 1 | { 2 | "js": { 3 | "indent_size": 2, 4 | "indent_char": " ", 5 | "indent_level": 0, 6 | "indent_with_tabs": false, 7 | "preserve_newlines": true, 8 | "space_in_paren": false, 9 | "space_after_anon_function": false, 10 | "space_before_conditional": true, 11 | "brace_style": "none", 12 | "break_chained_methods": false, 13 | "keep_array_indentation": true, 14 | "keep_function_indentation": true, 15 | "eval_code": false, 16 | "unescape_strings": false, 17 | "wrap_line_length": 120, 18 | "end_with_newline": true, 19 | "end_with_comma": false, 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | 6 | # Runtime data 7 | pids 8 | *.pid 9 | *.seed 10 | 11 | # Directory for instrumented libs generated by jscoverage/JSCover 12 | lib-cov 13 | 14 | # Coverage directory used by tools like istanbul 15 | coverage 16 | 17 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 18 | .grunt 19 | 20 | # node-waf configuration 21 | .lock-wscript 22 | 23 | # Compiled binary addons (http://nodejs.org/api/addons.html) 24 | build/Release 25 | 26 | # Dependency directory 27 | node_modules 28 | 29 | # Optional npm cache directory 30 | .npm 31 | 32 | # Optional REPL history 33 | .node_repl_history 34 | -------------------------------------------------------------------------------- /lib/file.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | var fs = require('fs'); 5 | var format = require('util').format; 6 | 7 | 8 | function File(path) { 9 | 10 | this.path = path; 11 | fs.writeFileSync(path, ''); 12 | } 13 | 14 | 15 | File.prototype.format = function() { 16 | 17 | return format.apply(this, arguments); 18 | }; 19 | 20 | 21 | File.prototype.writeln = function() { 22 | 23 | this.write('\n'); 24 | return this; 25 | }; 26 | 27 | 28 | File.prototype.write = function() { 29 | 30 | fs.appendFileSync(this.path, this.format.apply(this, arguments)); 31 | return this; 32 | }; 33 | 34 | 35 | File.prototype.end = function() { 36 | 37 | // do nothing, this just for compatibility api 38 | }; 39 | 40 | 41 | module.exports = File; 42 | -------------------------------------------------------------------------------- /lib/log.js: -------------------------------------------------------------------------------- 1 | /* eslint no-process-env: "off" */ 2 | /* eslint no-console: "off" */ 3 | 'use strict'; 4 | 5 | 6 | var colors = require('colors'); 7 | var themes = { 8 | info: 'blue', 9 | success: 'green', 10 | error: 'red', 11 | debug: 'cyan', 12 | warn: 'yellow' 13 | }; 14 | colors.setTheme(themes); 15 | 16 | 17 | function log() { 18 | 19 | var args = Array.prototype.slice.call(arguments); 20 | var type = 'info'; 21 | 22 | if (args.length >= 2) { 23 | type = args[0]; 24 | if (themes[type]) { 25 | args.splice(0, 1); 26 | } else { 27 | type = 'info'; 28 | } 29 | } 30 | 31 | if (process.env.NODE_ENV !== 'test') { 32 | console.log(colors[type].apply(null, args)); 33 | } 34 | } 35 | 36 | 37 | module.exports = log; 38 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "clgt", 3 | "author": "Toan Pham Cong", 4 | "license": "MIT", 5 | "version": "1.0.4", 6 | "description": "A tool generate git changelog file.", 7 | "main": "index.js", 8 | "scripts": { 9 | "test": "lab -L -C -c -t 90", 10 | "coveralls": "lab -r lcov | ./node_modules/.bin/coveralls" 11 | }, 12 | "repository": { 13 | "type": "git", 14 | "url": "https://github.com/toancong/clgt" 15 | }, 16 | "keywords": [ 17 | "git", 18 | "change", 19 | "log" 20 | ], 21 | "dependencies": { 22 | "async": "^1.5.0", 23 | "colors": "^1.1.0", 24 | "commander": "^2.8.0", 25 | "lodash": "^4.12.0", 26 | "marked": "^0.3.5", 27 | "nconf": "^0.8.4" 28 | }, 29 | "devDependencies": { 30 | "code": "^3.0.0", 31 | "coveralls": "^2.11.9", 32 | "lab": "^10.6.1", 33 | "sinon": "^1.12.0" 34 | }, 35 | "bin": { 36 | "clgt": "index.js" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /.clgtrc: -------------------------------------------------------------------------------- 1 | { 2 | "file": "CHANGELOG.md", 3 | "name": "Change Log GiT", 4 | "description": "A tool generate git changelog file", 5 | "url": "https://github.com/toancong/clgt/commit", 6 | "types": [ 7 | { 8 | "title": "Bug Fixes", 9 | "pattern": "^fix|^bug" 10 | }, 11 | { 12 | "title": "Features", 13 | "pattern": "^feat" 14 | }, 15 | { 16 | "title": "Documentation", 17 | "pattern": "^docs" 18 | }, 19 | { 20 | "title": "Breaking changes", 21 | "pattern": "BREAKING" 22 | }, 23 | { 24 | "title": "Refactor", 25 | "pattern": "^refactor" 26 | }, 27 | { 28 | "title": "Style", 29 | "pattern": "^style" 30 | }, 31 | { 32 | "title": "Test", 33 | "pattern": "^test" 34 | } 35 | ], 36 | "ignore": ".*ignore me.*|.*CHANGELOG.md.*|.*ignoreme.*|^chore|^release|^revert|^Merge pull request", 37 | "report": "none" 38 | } 39 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 toancong 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | (function() { 4 | var _ = require('lodash'); 5 | var cmdOptions = require('./lib/config').cmdOptions; 6 | var generator = require('./lib/generate'); 7 | var nconf = require('nconf'); 8 | var log = require('./lib/log'); 9 | var fs = require('fs'); 10 | var marked = require('marked'); 11 | var File = require('./lib/file'); 12 | 13 | if (!module.parent) { 14 | var file = _.cloneDeep(nconf.file('.clgtrc').stores.file.store); 15 | if (file.url) { 16 | cmdOptions.u.default = file.url; 17 | } 18 | var args = nconf.argv(cmdOptions, 19 | 'Change Log GiT\nA tool generate changelog file.\nUsage: clgt