conventional-recommended-bump 7.0.1 → 9.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/{cli.js → cli.mjs} +38 -37
- package/index.js +61 -79
- package/package.json +11 -16
- package/preset-resolver.js +0 -19
package/README.md
CHANGED
|
@@ -38,11 +38,11 @@ npm install conventional-recommended-bump
|
|
|
38
38
|
```javascript
|
|
39
39
|
const conventionalRecommendedBump = require(`conventional-recommended-bump`);
|
|
40
40
|
|
|
41
|
-
conventionalRecommendedBump({
|
|
41
|
+
const recommendation = await conventionalRecommendedBump({
|
|
42
42
|
preset: `angular`
|
|
43
|
-
}, (error, recommendation) => {
|
|
44
|
-
console.log(recommendation.releaseType); // 'major'
|
|
45
43
|
});
|
|
44
|
+
|
|
45
|
+
console.log(recommendation.releaseType); // 'major'
|
|
46
46
|
```
|
|
47
47
|
|
|
48
48
|
```bash
|
package/{cli.js → cli.mjs}
RENAMED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { resolve } from 'path'
|
|
3
|
+
import { pathToFileURL } from 'url'
|
|
4
|
+
import meow from 'meow'
|
|
5
|
+
import conventionalRecommendedBump from './index.js'
|
|
2
6
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const conventionalRecommendedBump = require('./')
|
|
7
|
-
const path = require('path')
|
|
7
|
+
function relativeResolve (filePath) {
|
|
8
|
+
return pathToFileURL(resolve(process.cwd(), filePath))
|
|
9
|
+
}
|
|
8
10
|
|
|
9
11
|
const cli = meow(`
|
|
10
12
|
Usage
|
|
@@ -28,39 +30,43 @@ const cli = meow(`
|
|
|
28
30
|
--commit-path Recommend a bump scoped to a specific directory
|
|
29
31
|
--skip-unstable If given, unstable tags will be skipped, e.g., x.x.x-alpha.1, x.x.x-rc.2
|
|
30
32
|
`, {
|
|
33
|
+
importMeta: import.meta,
|
|
31
34
|
flags: {
|
|
32
35
|
preset: {
|
|
33
|
-
|
|
36
|
+
shortFlag: 'p'
|
|
34
37
|
},
|
|
35
38
|
config: {
|
|
36
|
-
|
|
39
|
+
shortFlag: 'g'
|
|
37
40
|
},
|
|
38
|
-
|
|
39
|
-
|
|
41
|
+
headerPattern: {
|
|
42
|
+
shortFlag: 'h'
|
|
40
43
|
},
|
|
41
|
-
|
|
42
|
-
|
|
44
|
+
headerCorrespondence: {
|
|
45
|
+
shortFlag: 'c'
|
|
43
46
|
},
|
|
44
|
-
|
|
45
|
-
|
|
47
|
+
referenceActions: {
|
|
48
|
+
shortFlag: 'r'
|
|
46
49
|
},
|
|
47
|
-
|
|
48
|
-
|
|
50
|
+
issuePrefixes: {
|
|
51
|
+
shortFlag: 'i'
|
|
49
52
|
},
|
|
50
|
-
|
|
51
|
-
|
|
53
|
+
noteKeywords: {
|
|
54
|
+
shortFlag: 'n'
|
|
52
55
|
},
|
|
53
|
-
|
|
54
|
-
|
|
56
|
+
fieldPattern: {
|
|
57
|
+
shortFlag: 'f'
|
|
55
58
|
},
|
|
56
59
|
verbose: {
|
|
57
|
-
|
|
60
|
+
shortFlag: 'v'
|
|
61
|
+
},
|
|
62
|
+
lernaPackage: {
|
|
63
|
+
shortFlag: 'l'
|
|
58
64
|
},
|
|
59
|
-
|
|
60
|
-
|
|
65
|
+
tagPrefix: {
|
|
66
|
+
shortFlag: 't'
|
|
61
67
|
},
|
|
62
|
-
|
|
63
|
-
|
|
68
|
+
skipUnstable: {
|
|
69
|
+
type: 'boolean'
|
|
64
70
|
}
|
|
65
71
|
}
|
|
66
72
|
})
|
|
@@ -79,7 +85,7 @@ if (preset) {
|
|
|
79
85
|
options.preset = preset
|
|
80
86
|
delete flags.preset
|
|
81
87
|
} else if (config) {
|
|
82
|
-
options.config =
|
|
88
|
+
options.config = (await import(relativeResolve(config))).default
|
|
83
89
|
delete flags.config
|
|
84
90
|
}
|
|
85
91
|
|
|
@@ -87,17 +93,12 @@ if (flags.verbose) {
|
|
|
87
93
|
options.warn = console.warn.bind(console)
|
|
88
94
|
}
|
|
89
95
|
|
|
90
|
-
conventionalRecommendedBump(options, flags
|
|
91
|
-
if (err) {
|
|
92
|
-
console.error(err.toString())
|
|
93
|
-
process.exit(1)
|
|
94
|
-
}
|
|
96
|
+
const data = await conventionalRecommendedBump(options, flags)
|
|
95
97
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
98
|
+
if (data.releaseType) {
|
|
99
|
+
console.log(data.releaseType)
|
|
100
|
+
}
|
|
99
101
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
})
|
|
102
|
+
if (flags.verbose && data.reason) {
|
|
103
|
+
console.log(`Reason: ${data.reason}`)
|
|
104
|
+
}
|
package/index.js
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
'use strict'
|
|
2
|
-
const concat = require('concat-stream')
|
|
3
2
|
const conventionalCommitsFilter = require('conventional-commits-filter')
|
|
4
3
|
const conventionalCommitsParser = require('conventional-commits-parser')
|
|
5
|
-
const
|
|
4
|
+
const { loadPreset } = require('conventional-changelog-preset-loader')
|
|
6
5
|
const gitSemverTags = require('git-semver-tags')
|
|
7
6
|
const gitRawCommits = require('git-raw-commits')
|
|
8
|
-
const presetResolver = require('./preset-resolver')
|
|
9
7
|
|
|
10
8
|
const VERSIONS = ['major', 'minor', 'patch']
|
|
11
9
|
|
|
12
|
-
|
|
10
|
+
function noop () {}
|
|
13
11
|
|
|
14
|
-
function conventionalRecommendedBump (optionsArgument, parserOptsArgument
|
|
12
|
+
async function conventionalRecommendedBump (optionsArgument, parserOptsArgument) {
|
|
15
13
|
if (typeof optionsArgument !== 'object') {
|
|
16
14
|
throw new Error('The \'options\' argument must be an object.')
|
|
17
15
|
}
|
|
@@ -21,84 +19,68 @@ function conventionalRecommendedBump (optionsArgument, parserOptsArgument, cbArg
|
|
|
21
19
|
gitRawCommitsOpts: {}
|
|
22
20
|
}, optionsArgument)
|
|
23
21
|
|
|
24
|
-
|
|
22
|
+
let config = options.config || {}
|
|
23
|
+
if (options.preset) {
|
|
24
|
+
config = await loadPreset(options.preset)
|
|
25
|
+
}
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
const whatBump = options.whatBump ||
|
|
28
|
+
((config.recommendedBumpOpts && config.recommendedBumpOpts.whatBump)
|
|
29
|
+
? config.recommendedBumpOpts.whatBump
|
|
30
|
+
: noop)
|
|
31
|
+
|
|
32
|
+
if (typeof whatBump !== 'function') {
|
|
33
|
+
throw Error('whatBump must be a function')
|
|
28
34
|
}
|
|
29
35
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
36
|
+
// TODO: For now we defer to `config.recommendedBumpOpts.parserOpts` if it exists, as our initial refactor
|
|
37
|
+
// efforts created a `parserOpts` object under the `recommendedBumpOpts` object in each preset package.
|
|
38
|
+
// In the future we want to merge differences found in `recommendedBumpOpts.parserOpts` into the top-level
|
|
39
|
+
// `parserOpts` object and remove `recommendedBumpOpts.parserOpts` from each preset package if it exists.
|
|
40
|
+
const parserOpts = Object.assign({},
|
|
41
|
+
config.recommendedBumpOpts && config.recommendedBumpOpts.parserOpts
|
|
42
|
+
? config.recommendedBumpOpts.parserOpts
|
|
43
|
+
: config.parserOpts,
|
|
44
|
+
parserOptsArgument)
|
|
45
|
+
|
|
46
|
+
const warn = typeof parserOpts.warn === 'function' ? parserOpts.warn : noop
|
|
47
|
+
const tags = await gitSemverTags({
|
|
48
|
+
lernaTags: !!options.lernaPackage,
|
|
49
|
+
package: options.lernaPackage,
|
|
50
|
+
tagPrefix: options.tagPrefix,
|
|
51
|
+
skipUnstable: options.skipUnstable,
|
|
52
|
+
cwd: options.cwd
|
|
53
|
+
})
|
|
54
|
+
const commitsStream = gitRawCommits({
|
|
55
|
+
format: '%B%n-hash-%n%H',
|
|
56
|
+
from: tags[0] || '',
|
|
57
|
+
path: options.path,
|
|
58
|
+
...options.gitRawCommitsOpts
|
|
59
|
+
}, {
|
|
60
|
+
cwd: options.cwd
|
|
61
|
+
})
|
|
62
|
+
.pipe(conventionalCommitsParser(parserOpts))
|
|
63
|
+
let commits = []
|
|
64
|
+
|
|
65
|
+
for await (const commit of commitsStream) {
|
|
66
|
+
commits.push(commit)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
commits = options.ignoreReverted ? conventionalCommitsFilter(commits) : commits
|
|
70
|
+
|
|
71
|
+
if (!commits || !commits.length) {
|
|
72
|
+
warn('No commits since last release')
|
|
42
73
|
}
|
|
43
74
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
// TODO: For now we defer to `config.recommendedBumpOpts.parserOpts` if it exists, as our initial refactor
|
|
55
|
-
// efforts created a `parserOpts` object under the `recommendedBumpOpts` object in each preset package.
|
|
56
|
-
// In the future we want to merge differences found in `recommendedBumpOpts.parserOpts` into the top-level
|
|
57
|
-
// `parserOpts` object and remove `recommendedBumpOpts.parserOpts` from each preset package if it exists.
|
|
58
|
-
const parserOpts = Object.assign({},
|
|
59
|
-
config.recommendedBumpOpts && config.recommendedBumpOpts.parserOpts
|
|
60
|
-
? config.recommendedBumpOpts.parserOpts
|
|
61
|
-
: config.parserOpts,
|
|
62
|
-
parserOptsArgument)
|
|
63
|
-
|
|
64
|
-
const warn = typeof parserOpts.warn === 'function' ? parserOpts.warn : noop
|
|
65
|
-
|
|
66
|
-
gitSemverTags({
|
|
67
|
-
lernaTags: !!options.lernaPackage,
|
|
68
|
-
package: options.lernaPackage,
|
|
69
|
-
tagPrefix: options.tagPrefix,
|
|
70
|
-
skipUnstable: options.skipUnstable
|
|
71
|
-
}, (err, tags) => {
|
|
72
|
-
if (err) {
|
|
73
|
-
return cb(err)
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
gitRawCommits({
|
|
77
|
-
format: '%B%n-hash-%n%H',
|
|
78
|
-
from: tags[0] || '',
|
|
79
|
-
path: options.path,
|
|
80
|
-
...options.gitRawCommitsOpts
|
|
81
|
-
})
|
|
82
|
-
.pipe(conventionalCommitsParser(parserOpts))
|
|
83
|
-
.pipe(concat(data => {
|
|
84
|
-
const commits = options.ignoreReverted ? conventionalCommitsFilter(data) : data
|
|
85
|
-
|
|
86
|
-
if (!commits || !commits.length) {
|
|
87
|
-
warn('No commits since last release')
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
let result = whatBump(commits, options)
|
|
91
|
-
|
|
92
|
-
if (result && result.level != null) {
|
|
93
|
-
result.releaseType = VERSIONS[result.level]
|
|
94
|
-
} else if (result == null) {
|
|
95
|
-
result = {}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
cb(null, result)
|
|
99
|
-
}))
|
|
100
|
-
})
|
|
101
|
-
}).catch(err => cb(err))
|
|
75
|
+
let result = whatBump(commits, options)
|
|
76
|
+
|
|
77
|
+
if (result && result.level != null) {
|
|
78
|
+
result.releaseType = VERSIONS[result.level]
|
|
79
|
+
} else if (result == null) {
|
|
80
|
+
result = {}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return result
|
|
102
84
|
}
|
|
103
85
|
|
|
104
|
-
|
|
86
|
+
module.exports = conventionalRecommendedBump
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "conventional-recommended-bump",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0",
|
|
4
4
|
"description": "Get a recommended version bump based on conventional commits",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/conventional-changelog/conventional-changelog/issues"
|
|
@@ -17,12 +17,11 @@
|
|
|
17
17
|
},
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"engines": {
|
|
20
|
-
"node": ">=
|
|
20
|
+
"node": ">=16"
|
|
21
21
|
},
|
|
22
22
|
"files": [
|
|
23
23
|
"index.js",
|
|
24
|
-
"cli.
|
|
25
|
-
"preset-resolver.js"
|
|
24
|
+
"cli.mjs"
|
|
26
25
|
],
|
|
27
26
|
"keywords": [
|
|
28
27
|
"conventional-recommended-bump",
|
|
@@ -31,19 +30,15 @@
|
|
|
31
30
|
"bump"
|
|
32
31
|
],
|
|
33
32
|
"dependencies": {
|
|
34
|
-
"
|
|
35
|
-
"conventional-changelog-preset-loader": "^
|
|
36
|
-
"conventional-commits-filter": "^
|
|
37
|
-
"conventional-commits-parser": "^
|
|
38
|
-
"git-raw-commits": "^
|
|
39
|
-
"git-semver-tags": "^
|
|
40
|
-
"meow": "^8.1.2"
|
|
33
|
+
"meow": "^12.0.1",
|
|
34
|
+
"conventional-changelog-preset-loader": "^4.1.0",
|
|
35
|
+
"conventional-commits-filter": "^4.0.0",
|
|
36
|
+
"conventional-commits-parser": "^5.0.0",
|
|
37
|
+
"git-raw-commits": "^4.0.0",
|
|
38
|
+
"git-semver-tags": "^7.0.0"
|
|
41
39
|
},
|
|
42
|
-
"bin": "cli.
|
|
40
|
+
"bin": "cli.mjs",
|
|
43
41
|
"devDependencies": {
|
|
44
|
-
"conventional-changelog-conventionalcommits": "^
|
|
45
|
-
},
|
|
46
|
-
"scripts": {
|
|
47
|
-
"test-windows": "mocha --timeout 30000 ./test/preset-resolver.spec.js"
|
|
42
|
+
"conventional-changelog-conventionalcommits": "^7.0.2"
|
|
48
43
|
}
|
|
49
44
|
}
|
package/preset-resolver.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const { promisify } = require('util')
|
|
4
|
-
|
|
5
|
-
module.exports = presetResolver
|
|
6
|
-
|
|
7
|
-
async function presetResolver (presetPackage) {
|
|
8
|
-
// handle traditional node-style callbacks
|
|
9
|
-
if (typeof presetPackage === 'function') {
|
|
10
|
-
return await promisify(presetPackage)()
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// handle object literal or Promise instance
|
|
14
|
-
if (typeof presetPackage === 'object') {
|
|
15
|
-
return await presetPackage
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
throw new Error('preset package must be a promise, function, or object')
|
|
19
|
-
}
|