├── CHANGELOG.md ├── README.md ├── bin └── cli.js ├── lib ├── changelog.js ├── cli.js ├── options.js ├── release-changelog.js └── util.js └── package.json /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ### 0.6.1 (2014-06-25) 2 | 3 | 4 | #### Bug Fixes 5 | 6 | * **changelog:** 7 | * wrong arguments ([d21a9faa](https://github.com/azu/release-changelog/commit/d21a9faa66e6f7a19884271562e6e0a140c2034a)) 8 | * wrong option position ([b26d026d](https://github.com/azu/release-changelog/commit/b26d026d413bb17d505c2e1c27d087871b6e8a51)) 9 | 10 | 11 | #### Features 12 | 13 | * **changelog:** 14 | * debug option as ConventialOption ([888ff419](https://github.com/azu/release-changelog/commit/888ff419698e9e11bfd4a9e2771b9d3e9689f340)) 15 | * add ^docs for grep ([c88ce137](https://github.com/azu/release-changelog/commit/c88ce1375bd7853c0dad8c5b23d482c9bdbe1ec8)) 16 | 17 | 18 | ## 0.6.0 (2014-06-25) 19 | 20 | 21 | #### Bug Fixes 22 | 23 | * **changelog:** fix passing version ([6f9e2529](https://github.com/azu/release-changelog/commit/6f9e252942ffe1a6cb784615aca44a85a0dd5660)) 24 | 25 | 26 | ### 0.5.5 (2014-06-25) 27 | 28 | 29 | #### Features 30 | 31 | * **changelog:** add cli option ([ed08b725](https://github.com/azu/release-changelog/commit/ed08b725b603f5e433ece2f0b5825b3b5d13b9e6)) 32 | 33 | 34 | ### 0.5.4 (2014-06-15) 35 | 36 | 37 | #### Bug Fixes 38 | 39 | * **changelog:** strip last slash of homepage url ([81344e33](https://github.com/azu/release-changelog//commit/81344e3341fe1f93d809cfc527047069199afc45)) 40 | 41 | 42 | ### 0.5.3 (2014-06-15) 43 | 44 | 45 | #### Bug Fixes 46 | 47 | * **changelog:** 48 | * missing package.json ([4fa9a2f9](https://github.com/azu/release-changelog//commit/4fa9a2f9adf30eca38b71e2ba0041101d8c219de)) 49 | * remove unnecessity assert ([af7abaaa](https://github.com/azu/release-changelog//commit/af7abaaa7abe10d64bbf4367c18a5bd3ddbef14f)) 50 | * **release-changelog:** 51 | * resolve module ([a2940a33](https://github.com/azu/release-changelog//commit/a2940a33694f8847b0489c5f8100ca858da443f1)) 52 | * fix release version ([6c600752](https://github.com/azu/release-changelog//commit/6c600752a3fbd076ddcc0678c74eb04758f783d5)) 53 | 54 | 55 | ### 0.5.1 (2014-06-15) 56 | 57 | 58 | ## 0.5.0 (2014-06-15) 59 | 60 | 61 | #### Features 62 | 63 | * **changelog:** silent log ([1b35a938](https://github.com/azu/release-changelog//commit/1b35a9386d91bcd4d2c1b5964842ec188bb9fcec)) 64 | 65 | 66 | ## 0.4.0 (2014-06-15) 67 | 68 | 69 | #### バグ修正 70 | 71 | * **execute:** add first line ([e288aa05](https://github.com/azu/release-changelog//commit/e288aa050cd656fff577b99c3507fc85175937cc)) 72 | 73 | 74 | #### 新しい機能 75 | 76 | * **changelog:** add changelog as promise ([8dbe122e](https://github.com/azu/release-changelog//commit/8dbe122e0b86b145afef358ce4ee12c08f6d6293)) 77 | * **cli:** 78 | * add cli options parser ([b6504e74](https://github.com/azu/release-changelog//commit/b6504e745cddf01ba555d733ce9e2d34bf325b69)) 79 | * add cli file ([3c39ce4e](https://github.com/azu/release-changelog//commit/3c39ce4e9e034efd8a2ba6fd644f3b529c93ac5c)) 80 | * **release-changelog:** simple implement execute ([4007893c](https://github.com/azu/release-changelog//commit/4007893cdb069314f4baf834a458faaa6aec7d95)) 81 | 82 | 83 | ## 0.3.0 (2014-06-15) 84 | 85 | 86 | #### 新しい機能 87 | 88 | * **changelog:** add changelog as promise ([8dbe122e](https://github.com/azu/release-changelog//commit/8dbe122e0b86b145afef358ce4ee12c08f6d6293)) 89 | * **cli:** 90 | * add cli options parser ([b6504e74](https://github.com/azu/release-changelog//commit/b6504e745cddf01ba555d733ce9e2d34bf325b69)) 91 | * add cli file ([3c39ce4e](https://github.com/azu/release-changelog//commit/3c39ce4e9e034efd8a2ba6fd644f3b529c93ac5c)) 92 | * **release-changelog:** simple implement execute ([4007893c](https://github.com/azu/release-changelog//commit/4007893cdb069314f4baf834a458faaa6aec7d95)) 93 | 94 | 95 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # release-changelog 2 | 3 | **Easy** to use [conventional-changelog](https://github.com/conventional-changelog/conventional-changelog "conventional-changelog") and [release-it](https://github.com/webpro/release-it "release-it"). 4 | 5 | This CLI Work two things. 6 | 7 | * Generate a changelog from git metadata, using the AngularJS commit conventions - [conventional-changelog](https://github.com/conventional-changelog/conventional-changelog "conventional-changelog") 8 | * Interactive release for Git and npm - [release-it](https://github.com/webpro/release-it "release-it") 9 | 10 | ## Installation 11 | 12 | ```sh 13 | npm install -g release-changelog 14 | ``` 15 | 16 | ## Usage 17 | 18 | **Must** 19 | 20 | * You have to set `homepage` field to `package.json` 21 | * [Git Commit Guidelines](https://github.com/conventional-changelog/conventional-changelog-angular/blob/master/convention.md "Git Commit Guidelines") 22 | 23 | 24 | This CLI work the same way as [release-it](https://github.com/webpro/release-it#configuration "webpro/release-it"). 25 | 26 | ``` sh 27 | release-changelog [version] [options] 28 | ``` 29 | 30 | ## Contributing 31 | 32 | 1. Fork it! 33 | 2. Create your feature branch: `git checkout -b my-new-feature` 34 | 3. Commit your changes: `git commit -am 'Add some feature'` 35 | 4. Push to the branch: `git push origin my-new-feature` 36 | 5. Submit a pull request :D 37 | 38 | ## License 39 | 40 | MIT 41 | -------------------------------------------------------------------------------- /bin/cli.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var args = [].slice.call(process.argv, 2); 4 | require("../lib/cli")(args).then(function () { 5 | process.exit(0); 6 | }, function (error) { 7 | console.error(error); 8 | process.exit(1); 9 | }); -------------------------------------------------------------------------------- /lib/changelog.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var fs = require("fs"); 3 | var path = require("path"); 4 | var Promise = require("bluebird"); 5 | var conventional = require('conventional-changelog'); 6 | var CHANGELOG_FILE = path.resolve(process.cwd(), 'CHANGELOG.md'); 7 | var PACKAGE_FILE = path.resolve(process.cwd(), 'package.json'); 8 | function stripTrailingSlash(string) { 9 | return string.replace(/\/+$/, ""); 10 | } 11 | function getConventialOptions(cliOption) { 12 | var homepage = require(PACKAGE_FILE).homepage; 13 | if (!homepage) { 14 | return reject(new Error("Not found `homepage` filed in package.json")); 15 | } 16 | var object = { 17 | repository: stripTrailingSlash(homepage), 18 | file: CHANGELOG_FILE, 19 | version: cliOption.releaseVersion, 20 | grep: '^feat|^fix|^write|^docs|BREAKING' 21 | }; 22 | if (cliOption["debug"]) { 23 | object.log = console.log.bind(console); 24 | } else { 25 | object.log = function () { 26 | } 27 | } 28 | return object 29 | } 30 | function writeChangeLogPromise(cliOption) { 31 | if (cliOption["dry-run"]) { 32 | return Promise.resolve("dry-run"); 33 | } 34 | return new Promise(function (resolve, reject) { 35 | conventional(getConventialOptions(cliOption), function (error, log) { 36 | // write file 37 | fs.writeFile(CHANGELOG_FILE, log, function (error, result) { 38 | if (error) { 39 | reject(error); 40 | } else { 41 | resolve(result); 42 | } 43 | }); 44 | }); 45 | }); 46 | } 47 | function getCurrentChangeLogPromise(cliOption) { 48 | return new Promise(function (resolve, reject) { 49 | var options = getConventialOptions(cliOption); 50 | options.file = "";// prev...current only 51 | conventional(options, function (error, log) { 52 | if (error) { 53 | reject(error); 54 | } else { 55 | if (cliOption["debug"]) { 56 | console.log(log); 57 | } 58 | resolve(log); 59 | } 60 | }); 61 | }); 62 | } 63 | module.exports.writeChangeLogPromise = writeChangeLogPromise; 64 | module.exports.getCurrentChangeLogPromise = getCurrentChangeLogPromise; -------------------------------------------------------------------------------- /lib/cli.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var releaseChangelog = require("./release-changelog"); 3 | var cliOptions = require("./options"); 4 | module.exports = function (args) { 5 | var options = cliOptions.parse(args); 6 | return releaseChangelog.execute(options); 7 | }; -------------------------------------------------------------------------------- /lib/options.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var optimist = require('optimist'), 3 | pkg = require('../package.json'), 4 | version = pkg.version; 5 | 6 | optimist.usage('Release Changelog! v' + version + '\n\n' + 7 | 'Usage: $0 [options]\n\n' + 8 | 'Use e.g. "$0 minor" directly as shorthand for "$0 --increment=minor".'); 9 | 10 | optimist.alias('c', 'config'); 11 | optimist.describe('c', 'Path to local configuration options [default: ".release.json"]'); 12 | 13 | optimist.boolean('d'); 14 | optimist.alias('d', 'dry-run'); 15 | optimist.describe('d', 'Do not touch or write anything, but show the commands and interactivity'); 16 | 17 | optimist.boolean('e'); 18 | optimist.alias('e', 'debug'); 19 | optimist.describe('e', 'Output exceptions'); 20 | 21 | optimist.boolean('f'); 22 | optimist.alias('f', 'force'); 23 | optimist.describe('f', 'Force tagging with Git'); 24 | 25 | optimist.boolean('h'); 26 | optimist.alias('h', 'help'); 27 | optimist.describe('h', 'Print help'); 28 | 29 | optimist.alias('i', 'increment'); 30 | optimist.describe('i', 'Incrementing "major", "minor", or "patch" version; or specify version [default: "patch"]'); 31 | 32 | optimist.boolean('n'); 33 | optimist.alias('n', 'non-interactive'); 34 | optimist.describe('n', 'No interaction (assume default answers to questions)'); 35 | 36 | optimist.boolean('p'); 37 | optimist.alias('p', 'publish'); 38 | optimist.describe('p', 'Publish to npm (only in --non-interactive mode)'); 39 | 40 | optimist.boolean('v'); 41 | optimist.alias('v', 'version'); 42 | optimist.describe('v', 'Print version number'); 43 | 44 | optimist.boolean('V'); 45 | optimist.alias('V', 'verbose'); 46 | optimist.describe('V', 'Verbose output'); 47 | 48 | module.exports = { 49 | version: function () { 50 | console.log('v' + version); 51 | }, 52 | help: function () { 53 | console.log(optimist.help()); 54 | 55 | }, 56 | parse: function (argv) { 57 | var options = optimist.parse(argv); 58 | if (options._[0] && !options.increment) { 59 | options.increment = options.i = options._[0]; 60 | } 61 | return options; 62 | } 63 | }; 64 | -------------------------------------------------------------------------------- /lib/release-changelog.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var releaseIt = require("release-it"); 3 | var Promise = require("bluebird"); 4 | var changelog = require("./changelog"); 5 | var path = require("path"); 6 | var util = require("./util"); 7 | var PACKAGE_FILE = path.resolve(process.cwd(), 'package.json'); 8 | function getCurrentVersion() { 9 | return require(PACKAGE_FILE).version; 10 | } 11 | function execute(option) { 12 | var releaseVersion = util.increment(getCurrentVersion(), option.increment); 13 | var changeLogOption = { 14 | "debug": option["debug"], 15 | "dry-run": option['dry-run'], 16 | "releaseVersion": releaseVersion 17 | }; 18 | return Promise.all([ 19 | changelog.getCurrentChangeLogPromise(changeLogOption), changelog.writeChangeLogPromise(changeLogOption) 20 | ]).then(function (results) { 21 | var changelog = results[0]; 22 | option.tagAnnotation = "Release %s\n" + changelog; 23 | return releaseIt.execute(option); 24 | }); 25 | } 26 | module.exports.execute = execute; -------------------------------------------------------------------------------- /lib/util.js: -------------------------------------------------------------------------------- 1 | var semver = require("semver"); 2 | function increment(version, increment) { 3 | increment = increment || 'patch'; 4 | if (['major', 'minor', 'patch'].indexOf(increment) === -1) { 5 | return increment; 6 | } else { 7 | return semver.inc(version, increment); 8 | } 9 | } 10 | 11 | module.exports = { 12 | increment: increment 13 | }; 14 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "release-changelog", 3 | "description": "release it + conventional-changelog cli", 4 | "version": "0.6.1", 5 | "homepage": "https://github.com/azu/release-changelog/", 6 | "repository": { 7 | "type": "git", 8 | "url": "https://github.com/azu/release-changelog.git" 9 | }, 10 | "bin": "./bin/cli.js", 11 | "main": "./lib/release-changelog.js", 12 | "scripts": { 13 | "test": "mocha test/*.js" 14 | }, 15 | "directories": { 16 | "test": "test/" 17 | }, 18 | "author": "azu", 19 | "license": "MIT", 20 | "bugs": { 21 | "url": "https://github.com/azu/release-changelog/issues" 22 | }, 23 | "dependencies": { 24 | "bluebird": "^2.1.1", 25 | "conventional-changelog": "https://github.com/azu/conventional-changelog/archive/promises-book.tar.gz", 26 | "optimist": "^0.6.1", 27 | "release-it": "0.0.6", 28 | "semver": "^2.3.0" 29 | } 30 | } --------------------------------------------------------------------------------