From 513bc14f2d8f3d69f085fdd1f5fc6fcba1a96d04 Mon Sep 17 00:00:00 2001 From: JasonCust Date: Sat, 2 Jun 2018 10:48:47 -0400 Subject: [PATCH 01/15] test(package): ensure a version can be provided --- test/package.test.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/package.test.js b/test/package.test.js index f9ae814..e7c92af 100644 --- a/test/package.test.js +++ b/test/package.test.js @@ -141,6 +141,15 @@ describe('package', function () { }); }); + it('return the version value if version is provided', function () { + var options = { version: '1.0.0' }; + + return Package.calculateNewVersion(options) + .then(function (version) { + Expect(version).to.eql('1.0.0'); + }); + }); + it('leaves the version untouched if none of three options is true', function () { return Package.calculateNewVersion() .then(function (version) { From 6793a4b30665f6640e0a4528c0184024bf73e77a Mon Sep 17 00:00:00 2001 From: JasonCust Date: Sat, 2 Jun 2018 10:50:02 -0400 Subject: [PATCH 02/15] feat(cli, package): provide option to provide external version value (#35) --- lib/cli.js | 1 + lib/index.js | 1 + lib/package.js | 6 ++++++ 3 files changed, 8 insertions(+) diff --git a/lib/cli.js b/lib/cli.js index cbb4216..0b3deb9 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -14,6 +14,7 @@ module.exports = CLI .option('-p, --patch', 'create a patch changelog') .option('-m, --minor', 'create a minor changelog') .option('-M, --major', 'create a major changelog') + .option('-v, --version', 'specify the version to use (e.g. v1.2.3)') .option('-t, --tag ', 'generate from specific tag or range (e.g. v1.2.3 or v1.2.3..v1.2.4)') .option('-x, --exclude ', 'exclude selected commit types (comma separated)', list) .option('-f, --file [file]', 'file to write to, defaults to ./CHANGELOG.md, use - for stdout', './CHANGELOG.md') diff --git a/lib/index.js b/lib/index.js index e799a4b..4d12578 100644 --- a/lib/index.js +++ b/lib/index.js @@ -12,6 +12,7 @@ var Writer = require('./writer'); * @param {Boolean} options.patch - whether it should be a patch changelog * @param {Boolean} options.minor - whether it should be a minor changelog * @param {Boolean} options.major - whether it should be a major changelog + * @param {String} [options.version] - the version * @param {String} options.repoUrl - repo URL that will be used when linking commits * @param {Array} options.exclude - exclude listed commit types (e.g. ['chore', 'style', 'refactor']) * @returns {Promise} the \n separated changelog string diff --git a/lib/package.js b/lib/package.js index da3e6d1..ec78601 100644 --- a/lib/package.js +++ b/lib/package.js @@ -46,10 +46,16 @@ exports.extractRepoUrl = function () { * @param {Boolean} options.patch - whether it should be a patch version * @param {Boolean} options.minor - whether it should be a minor version * @param {Boolean} options.major - whether it should be a major version + * @param {String} [options.version] - the version * @returns {Promise} - new version */ exports.calculateNewVersion = function (options) { options = options || {}; + + if (options.version) { + return Promise.resolve(options.version); + } + return exports.getUserPackage() .then(function (userPackage) { if (!userPackage.version) { From d1d16a1d957e0d3184adbca03e7ce13525e5063a Mon Sep 17 00:00:00 2001 From: JasonCust Date: Sat, 2 Jun 2018 10:50:24 -0400 Subject: [PATCH 03/15] docs(README): include documentation for version option --- README.md | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 3f4ae80..f269705 100644 --- a/README.md +++ b/README.md @@ -58,15 +58,16 @@ $ changelog -h Options: - -h, --help output usage information - -V, --version output the version number - -p, --patch create a patch changelog - -m, --minor create a minor changelog - -M, --major create a major changelog - -t, --tag generate from specific tag or range (e.g. v1.2.3 or v1.2.3..v1.2.4) - -x, --exclude exclude selected commit types (comma separated) - -f, --file [file] file to write to, defaults to ./CHANGELOG.md, use - for stdout - -u, --repo-url [url] specify the repo URL for commit links, defaults to checking the package.json + -h, --help output usage information + -V, --version output the version number + -p, --patch create a patch changelog + -m, --minor create a minor changelog + -M, --major create a major changelog + -v, --version the version value (e.g. v1.2.3) + -t, --tag generate from specific tag or range (e.g. v1.2.3 or v1.2.3..v1.2.4) + -x, --exclude exclude selected commit types (comma separated) + -f, --file [file] file to write to, defaults to ./CHANGELOG.md, use - for stdout + -u, --repo-url [url] specify the repo URL for commit links, defaults to checking the package.json ``` @@ -92,6 +93,12 @@ The way that I would recommend using this module would be the way it's being use "release:patch": "changelog -p && git add CHANGELOG.md && git commit -m 'updated CHANGELOG.md' && npm version patch && git push origin && git push origin --tags", ``` +To use a specific version rather than a generated value, you can use `-v VERSION` or `--version VERSION` rather than the major, minor or patch argument switches. For example, using npm's version `scripts` object in your `package.json` the previous `release` scripts could be condensed to: + +```json +"postversion": "npm version [major|minor|patch] 'bumping version' && changelog -v $npm_package_version && git add CHANGELOG.md && git commit -m 'updated CHANGELOG.md' && git push origin && git push origin --tags" +``` + ## Testing To run the test suite, just clone the repository and run the following: From b886eb964b8f87d3c16c27f376b0d41326fb0e84 Mon Sep 17 00:00:00 2001 From: JasonCust Date: Sat, 2 Jun 2018 10:59:26 -0400 Subject: [PATCH 04/15] docs(README): fix example code --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f269705..3fc7b11 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ The way that I would recommend using this module would be the way it's being use To use a specific version rather than a generated value, you can use `-v VERSION` or `--version VERSION` rather than the major, minor or patch argument switches. For example, using npm's version `scripts` object in your `package.json` the previous `release` scripts could be condensed to: ```json -"postversion": "npm version [major|minor|patch] 'bumping version' && changelog -v $npm_package_version && git add CHANGELOG.md && git commit -m 'updated CHANGELOG.md' && git push origin && git push origin --tags" +"postversion": "changelog -v $npm_package_version && git add CHANGELOG.md && git commit -m 'updated CHANGELOG.md' && git push origin && git push origin --tags" ``` ## Testing From 47ce079c55c049b5817cfda834e9ecf0030a612d Mon Sep 17 00:00:00 2001 From: JasonCust Date: Sat, 2 Jun 2018 11:14:14 -0400 Subject: [PATCH 05/15] test(package): test for semver vs version --- test/package.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/package.test.js b/test/package.test.js index e7c92af..94e1ff0 100644 --- a/test/package.test.js +++ b/test/package.test.js @@ -141,8 +141,8 @@ describe('package', function () { }); }); - it('return the version value if version is provided', function () { - var options = { version: '1.0.0' }; + it('return the version value if semver is provided', function () { + var options = { semver: '1.0.0' }; return Package.calculateNewVersion(options) .then(function (version) { From d2706227c501dc4d508797901f37e3ebaba16a52 Mon Sep 17 00:00:00 2001 From: JasonCust Date: Sat, 2 Jun 2018 11:14:39 -0400 Subject: [PATCH 06/15] fix(cli, package): use semver instead of version --- lib/cli.js | 2 +- lib/index.js | 2 +- lib/package.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/cli.js b/lib/cli.js index 0b3deb9..447cea7 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -14,7 +14,7 @@ module.exports = CLI .option('-p, --patch', 'create a patch changelog') .option('-m, --minor', 'create a minor changelog') .option('-M, --major', 'create a major changelog') - .option('-v, --version', 'specify the version to use (e.g. v1.2.3)') + .option('-s, --semver', 'specify the version to use (e.g. v1.2.3)') .option('-t, --tag ', 'generate from specific tag or range (e.g. v1.2.3 or v1.2.3..v1.2.4)') .option('-x, --exclude ', 'exclude selected commit types (comma separated)', list) .option('-f, --file [file]', 'file to write to, defaults to ./CHANGELOG.md, use - for stdout', './CHANGELOG.md') diff --git a/lib/index.js b/lib/index.js index 4d12578..0325d61 100644 --- a/lib/index.js +++ b/lib/index.js @@ -12,7 +12,7 @@ var Writer = require('./writer'); * @param {Boolean} options.patch - whether it should be a patch changelog * @param {Boolean} options.minor - whether it should be a minor changelog * @param {Boolean} options.major - whether it should be a major changelog - * @param {String} [options.version] - the version + * @param {String} [options.semver] - the semver version * @param {String} options.repoUrl - repo URL that will be used when linking commits * @param {Array} options.exclude - exclude listed commit types (e.g. ['chore', 'style', 'refactor']) * @returns {Promise} the \n separated changelog string diff --git a/lib/package.js b/lib/package.js index ec78601..50b1b4c 100644 --- a/lib/package.js +++ b/lib/package.js @@ -46,7 +46,7 @@ exports.extractRepoUrl = function () { * @param {Boolean} options.patch - whether it should be a patch version * @param {Boolean} options.minor - whether it should be a minor version * @param {Boolean} options.major - whether it should be a major version - * @param {String} [options.version] - the version + * @param {String} [options.semver] - the semver version * @returns {Promise} - new version */ exports.calculateNewVersion = function (options) { From 014c043014af0b7904384a71e2328eda3cb6e416 Mon Sep 17 00:00:00 2001 From: JasonCust Date: Sat, 2 Jun 2018 11:15:29 -0400 Subject: [PATCH 07/15] docs(README): update docs to use semver rather than version --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3fc7b11..6e2c329 100644 --- a/README.md +++ b/README.md @@ -93,10 +93,10 @@ The way that I would recommend using this module would be the way it's being use "release:patch": "changelog -p && git add CHANGELOG.md && git commit -m 'updated CHANGELOG.md' && npm version patch && git push origin && git push origin --tags", ``` -To use a specific version rather than a generated value, you can use `-v VERSION` or `--version VERSION` rather than the major, minor or patch argument switches. For example, using npm's version `scripts` object in your `package.json` the previous `release` scripts could be condensed to: +To use a specific version rather than a generated value, you can use `-s VERSION` or `--semver VERSION` rather than the major, minor or patch argument switches. For example, using npm's version `scripts` object in your `package.json` the previous `release` scripts could be condensed to: ```json -"postversion": "changelog -v $npm_package_version && git add CHANGELOG.md && git commit -m 'updated CHANGELOG.md' && git push origin && git push origin --tags" +"postversion": "changelog -s $npm_package_version && git add CHANGELOG.md && git commit -m 'updated CHANGELOG.md' && git push origin && git push origin --tags" ``` ## Testing From f91df4520d74269ece3b975d5618c91dd9d0c773 Mon Sep 17 00:00:00 2001 From: JasonCust Date: Sat, 2 Jun 2018 11:16:30 -0400 Subject: [PATCH 08/15] fix(package): use Bluebird for node v0.10 --- lib/package.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/package.js b/lib/package.js index 50b1b4c..dc95547 100644 --- a/lib/package.js +++ b/lib/package.js @@ -1,5 +1,7 @@ 'use strict'; +var Bluebird = require('bluebird'); + var File = require('./file'); var ParseGitHubUrl = require('github-url-from-git'); @@ -53,7 +55,7 @@ exports.calculateNewVersion = function (options) { options = options || {}; if (options.version) { - return Promise.resolve(options.version); + return Bluebird.resolve(options.version); } return exports.getUserPackage() From 866bb1015ae23e26d530dbf6e3b0f4da3ca14342 Mon Sep 17 00:00:00 2001 From: JasonCust Date: Sat, 2 Jun 2018 11:17:38 -0400 Subject: [PATCH 09/15] fix(package): use semver option --- lib/package.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/package.js b/lib/package.js index dc95547..5d4abd1 100644 --- a/lib/package.js +++ b/lib/package.js @@ -54,8 +54,8 @@ exports.extractRepoUrl = function () { exports.calculateNewVersion = function (options) { options = options || {}; - if (options.version) { - return Bluebird.resolve(options.version); + if (options.semver) { + return Bluebird.resolve(options.semver); } return exports.getUserPackage() From fa39d1a1775dfc3b47bc0b41739cbcee06aa1476 Mon Sep 17 00:00:00 2001 From: JasonCust Date: Sat, 2 Jun 2018 11:23:55 -0400 Subject: [PATCH 10/15] docs(README): update options documenation for semver --- README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 6e2c329..db70c1b 100644 --- a/README.md +++ b/README.md @@ -58,16 +58,16 @@ $ changelog -h Options: - -h, --help output usage information - -V, --version output the version number - -p, --patch create a patch changelog - -m, --minor create a minor changelog - -M, --major create a major changelog - -v, --version the version value (e.g. v1.2.3) - -t, --tag generate from specific tag or range (e.g. v1.2.3 or v1.2.3..v1.2.4) - -x, --exclude exclude selected commit types (comma separated) - -f, --file [file] file to write to, defaults to ./CHANGELOG.md, use - for stdout - -u, --repo-url [url] specify the repo URL for commit links, defaults to checking the package.json + -h, --help output usage information + -V, --version output the version number + -p, --patch create a patch changelog + -m, --minor create a minor changelog + -M, --major create a major changelog + -s, --semver the version value (e.g. v1.2.3) + -t, --tag generate from specific tag or range (e.g. v1.2.3 or v1.2.3..v1.2.4) + -x, --exclude exclude selected commit types (comma separated) + -f, --file [file] file to write to, defaults to ./CHANGELOG.md, use - for stdout + -u, --repo-url [url] specify the repo URL for commit links, defaults to checking the package.json ``` From 700c9d26cd4afa898c12ce086d4b059016f2b5c4 Mon Sep 17 00:00:00 2001 From: JasonCust Date: Sat, 2 Jun 2018 11:36:13 -0400 Subject: [PATCH 11/15] docs(README): use correct format for value option --- README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index db70c1b..85eda48 100644 --- a/README.md +++ b/README.md @@ -58,16 +58,16 @@ $ changelog -h Options: - -h, --help output usage information - -V, --version output the version number - -p, --patch create a patch changelog - -m, --minor create a minor changelog - -M, --major create a major changelog - -s, --semver the version value (e.g. v1.2.3) - -t, --tag generate from specific tag or range (e.g. v1.2.3 or v1.2.3..v1.2.4) - -x, --exclude exclude selected commit types (comma separated) - -f, --file [file] file to write to, defaults to ./CHANGELOG.md, use - for stdout - -u, --repo-url [url] specify the repo URL for commit links, defaults to checking the package.json + -h, --help output usage information + -V, --version output the version number + -p, --patch create a patch changelog + -m, --minor create a minor changelog + -M, --major create a major changelog + -s, --semver [value] the version value (e.g. v1.2.3) + -t, --tag generate from specific tag or range (e.g. v1.2.3 or v1.2.3..v1.2.4) + -x, --exclude exclude selected commit types (comma separated) + -f, --file [file] file to write to, defaults to ./CHANGELOG.md, use - for stdout + -u, --repo-url [url] specify the repo URL for commit links, defaults to checking the package.json ``` From 57a8c25f1b46e1dd0d8bb4117fa0fbad444afd9b Mon Sep 17 00:00:00 2001 From: JasonCust Date: Sat, 2 Jun 2018 11:36:35 -0400 Subject: [PATCH 12/15] fix(cli): use correct format value option --- lib/cli.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cli.js b/lib/cli.js index 447cea7..cbb9a3f 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -14,7 +14,7 @@ module.exports = CLI .option('-p, --patch', 'create a patch changelog') .option('-m, --minor', 'create a minor changelog') .option('-M, --major', 'create a major changelog') - .option('-s, --semver', 'specify the version to use (e.g. v1.2.3)') + .option('-s, --semver [value]', 'specify the version to use (e.g. v1.2.3)') .option('-t, --tag ', 'generate from specific tag or range (e.g. v1.2.3 or v1.2.3..v1.2.4)') .option('-x, --exclude ', 'exclude selected commit types (comma separated)', list) .option('-f, --file [file]', 'file to write to, defaults to ./CHANGELOG.md, use - for stdout', './CHANGELOG.md') From 5aff4fe640e2fe6cd361ed7807e96a30684041a4 Mon Sep 17 00:00:00 2001 From: JasonCust Date: Sat, 2 Jun 2018 14:20:37 -0400 Subject: [PATCH 13/15] docs(README): show `version` script for inclusion of changes in changelog in example code --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 85eda48..0c6d13f 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ The way that I would recommend using this module would be the way it's being use To use a specific version rather than a generated value, you can use `-s VERSION` or `--semver VERSION` rather than the major, minor or patch argument switches. For example, using npm's version `scripts` object in your `package.json` the previous `release` scripts could be condensed to: ```json -"postversion": "changelog -s $npm_package_version && git add CHANGELOG.md && git commit -m 'updated CHANGELOG.md' && git push origin && git push origin --tags" +"version": "changelog -s $npm_package_version && git add CHANGELOG.md && git commit -m 'updated CHANGELOG.md' && git push origin && git push origin --tags" ``` ## Testing From 69e14a666b078be9185b68ab54524dd639e4d4de Mon Sep 17 00:00:00 2001 From: JasonCust Date: Sun, 3 Jun 2018 16:12:15 -0400 Subject: [PATCH 14/15] style(package): move declaration for eslint compliance --- lib/package.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/package.js b/lib/package.js index 5d4abd1..8a62222 100644 --- a/lib/package.js +++ b/lib/package.js @@ -1,9 +1,8 @@ 'use strict'; -var Bluebird = require('bluebird'); - var File = require('./file'); var ParseGitHubUrl = require('github-url-from-git'); +var Bluebird = require('bluebird'); /** * Get the package.json object located in the current directory. From b3e5fe9bb608b872b15c1f9fd7663ea9415b577b Mon Sep 17 00:00:00 2001 From: JasonCust Date: Sun, 3 Jun 2018 16:13:16 -0400 Subject: [PATCH 15/15] docs(README): split example command for commiting after version commit occurs --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0c6d13f..f19902b 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,8 @@ The way that I would recommend using this module would be the way it's being use To use a specific version rather than a generated value, you can use `-s VERSION` or `--semver VERSION` rather than the major, minor or patch argument switches. For example, using npm's version `scripts` object in your `package.json` the previous `release` scripts could be condensed to: ```json -"version": "changelog -s $npm_package_version && git add CHANGELOG.md && git commit -m 'updated CHANGELOG.md' && git push origin && git push origin --tags" +"version": "changelog -s $npm_package_version && git add CHANGELOG.md && git commit -m 'updated CHANGELOG.md" +"postversion": "git push origin && git push origin --tags" ``` ## Testing