conventional-recommended-bump 7.0.1 → 8.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/{cli.js → cli.mjs} +32 -26
- package/index.js +42 -43
- package/package.json +11 -15
- package/preset-resolver.js +0 -19
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,7 +93,7 @@ if (flags.verbose) {
|
|
|
87
93
|
options.warn = console.warn.bind(console)
|
|
88
94
|
}
|
|
89
95
|
|
|
90
|
-
conventionalRecommendedBump(options, flags,
|
|
96
|
+
conventionalRecommendedBump(options, flags, (err, data) => {
|
|
91
97
|
if (err) {
|
|
92
98
|
console.error(err.toString())
|
|
93
99
|
process.exit(1)
|
package/index.js
CHANGED
|
@@ -2,16 +2,15 @@
|
|
|
2
2
|
const concat = require('concat-stream')
|
|
3
3
|
const conventionalCommitsFilter = require('conventional-commits-filter')
|
|
4
4
|
const conventionalCommitsParser = require('conventional-commits-parser')
|
|
5
|
-
const
|
|
5
|
+
const { loadPreset } = require('conventional-changelog-preset-loader')
|
|
6
6
|
const gitSemverTags = require('git-semver-tags')
|
|
7
7
|
const gitRawCommits = require('git-raw-commits')
|
|
8
|
-
const presetResolver = require('./preset-resolver')
|
|
9
8
|
|
|
10
9
|
const VERSIONS = ['major', 'minor', 'patch']
|
|
11
10
|
|
|
12
|
-
module.exports =
|
|
11
|
+
module.exports = conventionalRecommendedBumpLegacy
|
|
13
12
|
|
|
14
|
-
function conventionalRecommendedBump (optionsArgument, parserOptsArgument
|
|
13
|
+
async function conventionalRecommendedBump (optionsArgument, parserOptsArgument) {
|
|
15
14
|
if (typeof optionsArgument !== 'object') {
|
|
16
15
|
throw new Error('The \'options\' argument must be an object.')
|
|
17
16
|
}
|
|
@@ -21,56 +20,42 @@ function conventionalRecommendedBump (optionsArgument, parserOptsArgument, cbArg
|
|
|
21
20
|
gitRawCommitsOpts: {}
|
|
22
21
|
}, optionsArgument)
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (typeof cb !== 'function') {
|
|
27
|
-
throw new Error('You must provide a callback function.')
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
let presetPackage = options.config || {}
|
|
23
|
+
let config = options.config || {}
|
|
31
24
|
if (options.preset) {
|
|
32
|
-
|
|
33
|
-
presetPackage = conventionalChangelogPresetLoader(options.preset)
|
|
34
|
-
} catch (err) {
|
|
35
|
-
if (err.message === 'does not exist') {
|
|
36
|
-
const preset = typeof options.preset === 'object' ? options.preset.name : options.preset
|
|
37
|
-
return cb(new Error(`Unable to load the "${preset}" preset package. Please make sure it's installed.`))
|
|
38
|
-
} else {
|
|
39
|
-
return cb(err)
|
|
40
|
-
}
|
|
41
|
-
}
|
|
25
|
+
config = await loadPreset(options.preset)
|
|
42
26
|
}
|
|
43
27
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
: noop)
|
|
28
|
+
const whatBump = options.whatBump ||
|
|
29
|
+
((config.recommendedBumpOpts && config.recommendedBumpOpts.whatBump)
|
|
30
|
+
? config.recommendedBumpOpts.whatBump
|
|
31
|
+
: noop)
|
|
49
32
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
33
|
+
if (typeof whatBump !== 'function') {
|
|
34
|
+
throw Error('whatBump must be a function')
|
|
35
|
+
}
|
|
53
36
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
37
|
+
// TODO: For now we defer to `config.recommendedBumpOpts.parserOpts` if it exists, as our initial refactor
|
|
38
|
+
// efforts created a `parserOpts` object under the `recommendedBumpOpts` object in each preset package.
|
|
39
|
+
// In the future we want to merge differences found in `recommendedBumpOpts.parserOpts` into the top-level
|
|
40
|
+
// `parserOpts` object and remove `recommendedBumpOpts.parserOpts` from each preset package if it exists.
|
|
41
|
+
const parserOpts = Object.assign({},
|
|
42
|
+
config.recommendedBumpOpts && config.recommendedBumpOpts.parserOpts
|
|
43
|
+
? config.recommendedBumpOpts.parserOpts
|
|
44
|
+
: config.parserOpts,
|
|
45
|
+
parserOptsArgument)
|
|
63
46
|
|
|
64
|
-
|
|
47
|
+
const warn = typeof parserOpts.warn === 'function' ? parserOpts.warn : noop
|
|
65
48
|
|
|
49
|
+
return await new Promise((resolve, reject) => {
|
|
66
50
|
gitSemverTags({
|
|
67
51
|
lernaTags: !!options.lernaPackage,
|
|
68
52
|
package: options.lernaPackage,
|
|
69
53
|
tagPrefix: options.tagPrefix,
|
|
70
|
-
skipUnstable: options.skipUnstable
|
|
54
|
+
skipUnstable: options.skipUnstable,
|
|
55
|
+
cwd: options.cwd
|
|
71
56
|
}, (err, tags) => {
|
|
72
57
|
if (err) {
|
|
73
|
-
return
|
|
58
|
+
return reject(err)
|
|
74
59
|
}
|
|
75
60
|
|
|
76
61
|
gitRawCommits({
|
|
@@ -78,6 +63,8 @@ function conventionalRecommendedBump (optionsArgument, parserOptsArgument, cbArg
|
|
|
78
63
|
from: tags[0] || '',
|
|
79
64
|
path: options.path,
|
|
80
65
|
...options.gitRawCommitsOpts
|
|
66
|
+
}, {
|
|
67
|
+
cwd: options.cwd
|
|
81
68
|
})
|
|
82
69
|
.pipe(conventionalCommitsParser(parserOpts))
|
|
83
70
|
.pipe(concat(data => {
|
|
@@ -95,10 +82,22 @@ function conventionalRecommendedBump (optionsArgument, parserOptsArgument, cbArg
|
|
|
95
82
|
result = {}
|
|
96
83
|
}
|
|
97
84
|
|
|
98
|
-
|
|
85
|
+
resolve(result)
|
|
99
86
|
}))
|
|
100
87
|
})
|
|
101
|
-
})
|
|
88
|
+
})
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function conventionalRecommendedBumpLegacy (optionsArgument, parserOptsArgument, cbArgument) {
|
|
92
|
+
const cb = typeof parserOptsArgument === 'function' ? parserOptsArgument : cbArgument
|
|
93
|
+
|
|
94
|
+
if (typeof cb !== 'function') {
|
|
95
|
+
throw new Error('You must provide a callback function.')
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
conventionalRecommendedBump(optionsArgument, parserOptsArgument)
|
|
99
|
+
.then((result) => cb(null, result))
|
|
100
|
+
.catch((err) => cb(err))
|
|
102
101
|
}
|
|
103
102
|
|
|
104
103
|
function noop () {}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "conventional-recommended-bump",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.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",
|
|
@@ -32,18 +31,15 @@
|
|
|
32
31
|
],
|
|
33
32
|
"dependencies": {
|
|
34
33
|
"concat-stream": "^2.0.0",
|
|
35
|
-
"
|
|
36
|
-
"conventional-
|
|
37
|
-
"conventional-commits-
|
|
38
|
-
"
|
|
39
|
-
"git-
|
|
40
|
-
"
|
|
34
|
+
"meow": "^12.0.1",
|
|
35
|
+
"conventional-changelog-preset-loader": "^4.0.0",
|
|
36
|
+
"conventional-commits-filter": "^4.0.0",
|
|
37
|
+
"conventional-commits-parser": "^5.0.0",
|
|
38
|
+
"git-raw-commits": "^4.0.0",
|
|
39
|
+
"git-semver-tags": "^6.0.0"
|
|
41
40
|
},
|
|
42
|
-
"bin": "cli.
|
|
41
|
+
"bin": "cli.mjs",
|
|
43
42
|
"devDependencies": {
|
|
44
|
-
"conventional-changelog-conventionalcommits": "^
|
|
45
|
-
},
|
|
46
|
-
"scripts": {
|
|
47
|
-
"test-windows": "mocha --timeout 30000 ./test/preset-resolver.spec.js"
|
|
43
|
+
"conventional-changelog-conventionalcommits": "^7.0.0"
|
|
48
44
|
}
|
|
49
45
|
}
|
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
|
-
}
|