conventional-recommended-bump
Advanced tools
+59
-4
@@ -6,2 +6,4 @@ 'use strict'; | ||
| var gitRawCommits = require('git-raw-commits'); | ||
| var modifyValues = require('modify-values'); | ||
| var isSubset = require('is-subset'); | ||
| var objectAssign = require('object-assign'); | ||
@@ -11,2 +13,43 @@ | ||
| function filterCommits(commits) { | ||
| var ret = []; | ||
| var ignores = []; | ||
| commits.forEach(function(commit) { | ||
| if (commit.revert) { | ||
| ignores.push(commit.revert); | ||
| } else { | ||
| ret.push(commit); | ||
| } | ||
| }); | ||
| ret = ret.filter(function(commit) { | ||
| var ignoreThis = false; | ||
| commit = modifyValues(commit, function(val) { | ||
| if (typeof val === 'string') { | ||
| return val.trim(); | ||
| } | ||
| return val; | ||
| }); | ||
| ignores.some(function(ignore) { | ||
| ignore = modifyValues(ignore, function(val) { | ||
| if (typeof val === 'string') { | ||
| return val.trim(); | ||
| } | ||
| return val.trim(); | ||
| }); | ||
| ignoreThis = isSubset(commit, ignore); | ||
| return ignoreThis; | ||
| }); | ||
| return !ignoreThis; | ||
| }); | ||
| return ret; | ||
| } | ||
| function conventionalRecommendedBump(options, parserOpts, cb) { | ||
@@ -16,5 +59,7 @@ var preset; | ||
| if (typeof options === 'function') { | ||
| cb = options; | ||
| } else if (typeof parserOpts === 'function') { | ||
| if (typeof options !== 'object') { | ||
| throw new TypeError('options must be an object'); | ||
| } | ||
| if (typeof parserOpts === 'function') { | ||
| cb = parserOpts; | ||
@@ -26,2 +71,3 @@ } else { | ||
| options = objectAssign({ | ||
| ignoreReverted: true, | ||
| warn: function() {} | ||
@@ -52,2 +98,3 @@ }, options); | ||
| gitRawCommits({ | ||
| format: '%B%n-hash-%n%H', | ||
| from: tag | ||
@@ -57,3 +104,11 @@ }) | ||
| .pipe(concat(function(data) { | ||
| var level = whatBump(data); | ||
| var commits; | ||
| if (options.ignoreReverted) { | ||
| commits = filterCommits(data); | ||
| } else { | ||
| commits = data; | ||
| } | ||
| var level = whatBump(commits); | ||
| var releaseAs = VERSIONS[level]; | ||
@@ -60,0 +115,0 @@ |
+5
-3
| { | ||
| "name": "conventional-recommended-bump", | ||
| "version": "0.0.1", | ||
| "version": "0.0.2", | ||
| "description": "Get a recommended version bump based on conventional commits", | ||
@@ -21,6 +21,8 @@ "homepage": "https://github.com/stevemao/conventional-recommended-bump", | ||
| "concat-stream": "^1.4.10", | ||
| "conventional-commits-parser": "0.0.17", | ||
| "conventional-commits-parser": "0.0.18", | ||
| "git-latest-semver-tag": "0.0.0", | ||
| "git-raw-commits": "0.0.7", | ||
| "git-raw-commits": "0.0.8", | ||
| "is-subset": "^0.1.1", | ||
| "meow": "^3.3.0", | ||
| "modify-values": "^1.0.0", | ||
| "object-assign": "^3.0.0" | ||
@@ -27,0 +29,0 @@ }, |
@@ -24,3 +24,5 @@ var presetOpts = { | ||
| ], | ||
| noteKeywords: 'BREAKING CHANGE' | ||
| noteKeywords: 'BREAKING CHANGE', | ||
| revertPattern: /^revert:\s([\s\S]*?)\s*This reverts commit (\w*)\./, | ||
| revertCorrespondence: ['header', 'hash'] | ||
| } | ||
@@ -27,0 +29,0 @@ }; |
+8
-1
@@ -24,2 +24,3 @@ # [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url] [![Coverage Status][coverall-image]][coverall-url] | ||
| console.log(releaseAs); | ||
| //=> 'major' | ||
| }); | ||
@@ -55,6 +56,12 @@ }); | ||
| ### conventionalRecommendedBump([options, [parserOpts]], [callback]) | ||
| ### conventionalRecommendedBump(options, [parserOpts], [callback]) | ||
| #### options | ||
| ##### ignoreReverted | ||
| Type: `boolean` Default: `true` | ||
| If true, reverted commits will be ignored. | ||
| ##### preset | ||
@@ -61,0 +68,0 @@ |
+30
-9
@@ -10,2 +10,6 @@ 'use strict'; | ||
| describe('angular', function() { | ||
| var opts = { | ||
| preset: 'angular' | ||
| }; | ||
| before(function() { | ||
@@ -27,5 +31,3 @@ shell.cd('angular'); | ||
| it('should release as minor', function(done) { | ||
| conventionalRecommendedBump({ | ||
| preset: 'angular' | ||
| }, function(err, releaseAs) { | ||
| conventionalRecommendedBump(opts, function(err, releaseAs) { | ||
| equal(releaseAs, 'minor'); | ||
@@ -37,5 +39,3 @@ done(); | ||
| it('should merge parserOpts', function(done) { | ||
| conventionalRecommendedBump({ | ||
| preset: 'angular' | ||
| }, { | ||
| conventionalRecommendedBump(opts, { | ||
| headerPattern: /^(\w*)\: (.*)$/, | ||
@@ -52,5 +52,3 @@ }, function(err, releaseAs) { | ||
| child.exec('git add --all && git commit -m"feat(): amazing new module\n\nBREAKING CHANGE: Not backward compatible."', function() { | ||
| conventionalRecommendedBump({ | ||
| preset: 'angular' | ||
| }, function(err, releaseAs) { | ||
| conventionalRecommendedBump(opts, function(err, releaseAs) { | ||
| equal(releaseAs, 'major'); | ||
@@ -61,3 +59,26 @@ done(); | ||
| }); | ||
| it('should ignore a reverted commit', function(done) { | ||
| writeFileSync('test5', ''); | ||
| child.exec('git rev-parse HEAD', function(err, hash) { | ||
| // fix this until https://github.com/arturadib/shelljs/issues/175 is solved | ||
| child.exec('git add --all && git commit -m"revert: feat(): amazing new module\n\nThis reverts commit ' + hash.trim() + '."', function() { | ||
| conventionalRecommendedBump(opts, function(err, releaseAs) { | ||
| equal(releaseAs, 'minor'); | ||
| done(); | ||
| }); | ||
| }); | ||
| }); | ||
| }); | ||
| it('should not ignore a reverted commit', function(done) { | ||
| conventionalRecommendedBump({ | ||
| preset: 'angular', | ||
| ignoreReverted: false | ||
| }, function(err, releaseAs) { | ||
| equal(releaseAs, 'major'); | ||
| done(); | ||
| }); | ||
| }); | ||
| }); | ||
| }); |
+1
-0
@@ -8,2 +8,3 @@ var shell = require('shelljs'); | ||
| shell.mkdir('test'); | ||
| shell.mkdir('angular'); |
+24
-4
| 'use strict'; | ||
| var equal = require('assert').strictEqual; | ||
| var assert = require('assert'); | ||
| var conventionalRecommendedBump = require('../'); | ||
| var equal = assert.strictEqual; | ||
| var fs = require('fs'); | ||
| var shell = require('shelljs'); | ||
| describe('conventional-recommended-bump', function() { | ||
| it('should return `null` if no `whatBump` is found', function(done) { | ||
| conventionalRecommendedBump(function(err, releaseAs) { | ||
| before(function() { | ||
| shell.cd('test'); | ||
| shell.exec('git init'); | ||
| fs.writeFileSync('test1', ''); | ||
| shell.exec('git add --all && git commit -m"First commit"'); | ||
| }); | ||
| after(function() { | ||
| shell.cd('../'); | ||
| }); | ||
| it('should return `""` if no `whatBump` is found', function(done) { | ||
| conventionalRecommendedBump({}, function(err, releaseAs) { | ||
| equal(releaseAs, ''); | ||
@@ -25,5 +39,11 @@ done(); | ||
| it('should not error if callback is missing', function() { | ||
| conventionalRecommendedBump(); | ||
| conventionalRecommendedBump({}); | ||
| }); | ||
| it('should error if `options` is missing', function() { | ||
| assert.throws(function() { | ||
| conventionalRecommendedBump(function() {}); | ||
| }, 'options must be an object'); | ||
| }); | ||
| it('should error if no preset found', function(done) { | ||
@@ -30,0 +50,0 @@ conventionalRecommendedBump({ |
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
14596
22.41%304
36.32%122
6.09%8
33.33%3
50%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
Updated