From ab2a7648cd02383b73156e091875819483f7918a Mon Sep 17 00:00:00 2001 From: Leonardo Situmorang Date: Thu, 22 Nov 2018 04:17:20 +0000 Subject: [PATCH 1/4] CLI application now accept path option --- command.js | 4 ++++ index.js | 3 +++ lib/lifecycles/bump.js | 9 ++++++--- lib/lifecycles/changelog.js | 3 ++- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/command.js b/command.js index 095f9650c..35625e7db 100755 --- a/command.js +++ b/command.js @@ -77,6 +77,10 @@ module.exports = require('yargs') default: defaults.gitTagFallback, describe: `fallback to git tags for version, if no meta-information file is found (e.g., package.json)` }) + .option('path', { + type: 'string', + describe: 'Only populate commits made under this path', + }) .check((argv) => { if (typeof argv.scripts !== 'object' || Array.isArray(argv.scripts)) { throw Error('scripts must be an object') diff --git a/index.js b/index.js index d8432b03c..0cb7ba3e3 100755 --- a/index.js +++ b/index.js @@ -34,11 +34,14 @@ module.exports = function standardVersion (argv) { newVersion = version }) .then(() => { + console.info("standard-version", args); return bump(args, newVersion) }) .then((_newVersion) => { // if bump runs, it calculaes the new version that we // should release at. + console.info("standard-version newVersion:", _newVersion); + console.info("standard-version args before changelog():", args); if (_newVersion) newVersion = _newVersion return changelog(args, newVersion) }) diff --git a/lib/lifecycles/bump.js b/lib/lifecycles/bump.js index 7fa0857b8..ad88b4f70 100644 --- a/lib/lifecycles/bump.js +++ b/lib/lifecycles/bump.js @@ -24,7 +24,7 @@ function Bump (args, version) { .then(runLifecycleScript.bind(this, args, 'prebump')) .then((stdout) => { if (stdout && stdout.trim().length) args.releaseAs = stdout.trim() - return bumpVersion(args.releaseAs) + return bumpVersion(args.releaseAs, args) }) .then((release) => { if (!args.firstRelease) { @@ -125,7 +125,7 @@ function getTypePriority (type) { return TypeList.indexOf(type) } -function bumpVersion (releaseAs, callback) { +function bumpVersion (releaseAs, args) { return new Promise((resolve, reject) => { if (releaseAs) { return resolve({ @@ -133,8 +133,11 @@ function bumpVersion (releaseAs, callback) { }) } else { conventionalRecommendedBump({ - preset: 'angular' + debug: args.verbose && console.info.bind(console), + preset: 'angular', + path: args.path, }, function (err, release) { + console.info("BUMP", release); if (err) return reject(err) else return resolve(release) }) diff --git a/lib/lifecycles/changelog.js b/lib/lifecycles/changelog.js index 084914d11..8984b0088 100644 --- a/lib/lifecycles/changelog.js +++ b/lib/lifecycles/changelog.js @@ -30,9 +30,10 @@ function outputChangelog (args, newVersion) { var context if (args.dryRun) context = { version: newVersion } var changelogStream = conventionalChangelog({ + debug: args.verbose && console.info.bind(console, "standard-version"), preset: 'angular', tagPrefix: args.tagPrefix - }, context, { merges: null }) + }, context, { merges: null, path: args.path }) .on('error', function (err) { return reject(err) }) From 70b2d46ae2554e7db4e7fc7a68ca0c6bd8a8dc2f Mon Sep 17 00:00:00 2001 From: Leonardo Situmorang Date: Thu, 22 Nov 2018 04:51:15 +0000 Subject: [PATCH 2/4] Minor adjustments --- command.js | 2 +- index.js | 3 --- lib/lifecycles/bump.js | 3 +-- lib/lifecycles/changelog.js | 2 +- 4 files changed, 3 insertions(+), 7 deletions(-) diff --git a/command.js b/command.js index 35625e7db..65a6af3dd 100755 --- a/command.js +++ b/command.js @@ -79,7 +79,7 @@ module.exports = require('yargs') }) .option('path', { type: 'string', - describe: 'Only populate commits made under this path', + describe: 'Only populate commits made under this path' }) .check((argv) => { if (typeof argv.scripts !== 'object' || Array.isArray(argv.scripts)) { diff --git a/index.js b/index.js index 0cb7ba3e3..d8432b03c 100755 --- a/index.js +++ b/index.js @@ -34,14 +34,11 @@ module.exports = function standardVersion (argv) { newVersion = version }) .then(() => { - console.info("standard-version", args); return bump(args, newVersion) }) .then((_newVersion) => { // if bump runs, it calculaes the new version that we // should release at. - console.info("standard-version newVersion:", _newVersion); - console.info("standard-version args before changelog():", args); if (_newVersion) newVersion = _newVersion return changelog(args, newVersion) }) diff --git a/lib/lifecycles/bump.js b/lib/lifecycles/bump.js index ad88b4f70..d6e5c58b1 100644 --- a/lib/lifecycles/bump.js +++ b/lib/lifecycles/bump.js @@ -135,9 +135,8 @@ function bumpVersion (releaseAs, args) { conventionalRecommendedBump({ debug: args.verbose && console.info.bind(console), preset: 'angular', - path: args.path, + path: args.path }, function (err, release) { - console.info("BUMP", release); if (err) return reject(err) else return resolve(release) }) diff --git a/lib/lifecycles/changelog.js b/lib/lifecycles/changelog.js index 8984b0088..c1530fde7 100644 --- a/lib/lifecycles/changelog.js +++ b/lib/lifecycles/changelog.js @@ -30,7 +30,7 @@ function outputChangelog (args, newVersion) { var context if (args.dryRun) context = { version: newVersion } var changelogStream = conventionalChangelog({ - debug: args.verbose && console.info.bind(console, "standard-version"), + debug: args.verbose && console.info.bind(console, 'conventional-changelog'), preset: 'angular', tagPrefix: args.tagPrefix }, context, { merges: null, path: args.path }) From 42feb4ace6bb837db46c7fbe11f3ab636d14f867 Mon Sep 17 00:00:00 2001 From: Leonardo Situmorang Date: Thu, 22 Nov 2018 04:57:22 +0000 Subject: [PATCH 3/4] Minor adjustment --- lib/lifecycles/bump.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/lifecycles/bump.js b/lib/lifecycles/bump.js index d6e5c58b1..38a0d7f10 100644 --- a/lib/lifecycles/bump.js +++ b/lib/lifecycles/bump.js @@ -133,7 +133,7 @@ function bumpVersion (releaseAs, args) { }) } else { conventionalRecommendedBump({ - debug: args.verbose && console.info.bind(console), + debug: args.verbose && console.info.bind(console, 'conventional-recommended-bump'), preset: 'angular', path: args.path }, function (err, release) { From 948ba8664c65faf37722047aecfd52a0de843ba0 Mon Sep 17 00:00:00 2001 From: Leonardo Situmorang Date: Thu, 22 Nov 2018 10:22:39 +0000 Subject: [PATCH 4/4] Add preset option to the cli application --- command.js | 5 +++++ defaults.json | 3 ++- lib/lifecycles/bump.js | 2 +- lib/lifecycles/changelog.js | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/command.js b/command.js index 65a6af3dd..3406cd00c 100755 --- a/command.js +++ b/command.js @@ -81,6 +81,11 @@ module.exports = require('yargs') type: 'string', describe: 'Only populate commits made under this path' }) + .option('preset', { + type: 'string', + default: defaults.preset, + describe: 'Commit message guideline preset (default: angular)' + }) .check((argv) => { if (typeof argv.scripts !== 'object' || Array.isArray(argv.scripts)) { throw Error('scripts must be an object') diff --git a/defaults.json b/defaults.json index b70e54697..17035be47 100644 --- a/defaults.json +++ b/defaults.json @@ -10,5 +10,6 @@ "scripts": {}, "skip": {}, "dryRun": false, - "gitTagFallback": true + "gitTagFallback": true, + "preset": "angular" } diff --git a/lib/lifecycles/bump.js b/lib/lifecycles/bump.js index 38a0d7f10..162a312e9 100644 --- a/lib/lifecycles/bump.js +++ b/lib/lifecycles/bump.js @@ -134,7 +134,7 @@ function bumpVersion (releaseAs, args) { } else { conventionalRecommendedBump({ debug: args.verbose && console.info.bind(console, 'conventional-recommended-bump'), - preset: 'angular', + preset: args.preset || 'angular', path: args.path }, function (err, release) { if (err) return reject(err) diff --git a/lib/lifecycles/changelog.js b/lib/lifecycles/changelog.js index c1530fde7..fb2e0f9f3 100644 --- a/lib/lifecycles/changelog.js +++ b/lib/lifecycles/changelog.js @@ -31,7 +31,7 @@ function outputChangelog (args, newVersion) { if (args.dryRun) context = { version: newVersion } var changelogStream = conventionalChangelog({ debug: args.verbose && console.info.bind(console, 'conventional-changelog'), - preset: 'angular', + preset: args.preset || 'angular', tagPrefix: args.tagPrefix }, context, { merges: null, path: args.path }) .on('error', function (err) {