conventional-commits-parser 3.0.7 → 3.2.1
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/CHANGELOG.md +52 -0
- package/README.md +12 -0
- package/cli.js +51 -34
- package/index.js +8 -8
- package/lib/parser.js +54 -53
- package/lib/regex.js +16 -9
- package/package.json +8 -6
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,58 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [3.2.0](https://github.com/conventional-changelog/conventional-changelog/compare/conventional-commits-parser@3.1.0...conventional-commits-parser@3.2.0) (2020-11-05)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* ignore gpg lines ([#685](https://github.com/conventional-changelog/conventional-changelog/issues/685)) ([f8fcbc2](https://github.com/conventional-changelog/conventional-changelog/commit/f8fcbc2e8b0834c29178ace6382b438a020ad828))
|
|
12
|
+
* **deps:** update dependency through2 to v4 ([#657](https://github.com/conventional-changelog/conventional-changelog/issues/657)) ([7ae618c](https://github.com/conventional-changelog/conventional-changelog/commit/7ae618c81491841e5b1d796d3933aac0c54bc312))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* allows notes pattern to be customized ([#586](https://github.com/conventional-changelog/conventional-changelog/issues/586)) ([9c00f32](https://github.com/conventional-changelog/conventional-changelog/commit/9c00f3242d916be1774a618d943f908f8d9699a6))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
# [3.1.0](https://github.com/conventional-changelog/conventional-changelog/compare/conventional-commits-parser@3.0.8...conventional-commits-parser@3.1.0) (2020-05-08)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Bug Fixes
|
|
27
|
+
|
|
28
|
+
* **deps:** update yargs-parser to move off a flagged-vulnerable version. ([#635](https://github.com/conventional-changelog/conventional-changelog/issues/635)) ([aafc0f0](https://github.com/conventional-changelog/conventional-changelog/commit/aafc0f00412c3e4b23b8418300e5a570a48fe24d))
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Features
|
|
32
|
+
|
|
33
|
+
* **conventional-commits-parser:** add issuePrefixesCaseSensitive parser option ([#580](https://github.com/conventional-changelog/conventional-changelog/issues/580)) ([526b282](https://github.com/conventional-changelog/conventional-changelog/commit/526b28214d12c55158eb2e4d44408378587ceb97))
|
|
34
|
+
* support slash in headerPattern default options ([93a547d](https://github.com/conventional-changelog/conventional-changelog/commit/93a547d742634d8676f499cfa2a274bc3792d020))
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
### [3.2.1](https://www.github.com/conventional-changelog/conventional-changelog/compare/conventional-commits-parser@3.2.0...v3.2.1) (2021-02-15)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
### Bug Fixes
|
|
44
|
+
|
|
45
|
+
* handle missing header in merge commit ([#757](https://www.github.com/conventional-changelog/conventional-changelog/issues/757)) ([d189d3e](https://www.github.com/conventional-changelog/conventional-changelog/commit/d189d3e45b82e7141115ce8eccd95c8cf2d7db77))
|
|
46
|
+
|
|
47
|
+
## [3.0.8](https://github.com/conventional-changelog/conventional-changelog/compare/conventional-commits-parser@3.0.7...conventional-commits-parser@3.0.8) (2019-11-14)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
### Bug Fixes
|
|
51
|
+
|
|
52
|
+
* add types for cli flags ([#551](https://github.com/conventional-changelog/conventional-changelog/issues/551)) ([bf1d64a](https://github.com/conventional-changelog/conventional-changelog/commit/bf1d64aeaf8f262d4b2beec02d2aebb78df7343b))
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
6
58
|
## [3.0.7](https://github.com/conventional-changelog/conventional-changelog/compare/conventional-commits-parser@3.0.6...conventional-commits-parser@3.0.7) (2019-11-07)
|
|
7
59
|
|
|
8
60
|
|
package/README.md
CHANGED
|
@@ -193,12 +193,24 @@ Type: `array` of `string` or `string` Default: `['#']`
|
|
|
193
193
|
|
|
194
194
|
The prefixes of an issue. EG: In `gh-123` `gh-` is the prefix.
|
|
195
195
|
|
|
196
|
+
##### issuePrefixesCaseSensitive
|
|
197
|
+
|
|
198
|
+
Type: `boolean` Default: false
|
|
199
|
+
|
|
200
|
+
Used to define if `issuePrefixes` should be considered case sensitive.
|
|
201
|
+
|
|
196
202
|
##### noteKeywords
|
|
197
203
|
|
|
198
204
|
Type: `array` of `string` or `string` Default: `['BREAKING CHANGE']`
|
|
199
205
|
|
|
200
206
|
Keywords for important notes. This value is case **insensitive**. If it's a `string` it will be converted to an `array` separated by a comma.
|
|
201
207
|
|
|
208
|
+
##### notesPattern
|
|
209
|
+
|
|
210
|
+
Type: `function` Default: `noteKeywordsSelection => ^[\\s|*]*(' + noteKeywordsSelection + ')[:\\s]+(.*)` where `noteKeywordsSelection` is `join(noteKeywords, '|')`
|
|
211
|
+
|
|
212
|
+
A function that takes `noteKeywordsSelection` and returns a `RegExp` to be matched against the notes.
|
|
213
|
+
|
|
202
214
|
##### fieldPattern
|
|
203
215
|
|
|
204
216
|
Type: `regex` or `string` Default: `/^-(.*?)-$/`
|
package/cli.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict'
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
const conventionalCommitsParser = require('./')
|
|
4
|
+
const forEach = require('lodash').forEach
|
|
5
|
+
const fs = require('fs')
|
|
6
|
+
const isTextPath = require('is-text-path')
|
|
7
|
+
const JSONStream = require('JSONStream')
|
|
8
|
+
const meow = require('meow')
|
|
9
|
+
const readline = require('readline')
|
|
10
|
+
const split = require('split2')
|
|
11
|
+
const through = require('through2')
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
const filePaths = []
|
|
14
|
+
let separator = '\n\n\n'
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
const cli = meow(`
|
|
17
17
|
Practice writing commit messages or parse messages from files.
|
|
18
18
|
If used without specifying a text file path, you will enter an interactive shell.
|
|
19
19
|
Otherwise the commit messages in the files are parsed and printed
|
|
@@ -31,37 +31,54 @@ var cli = meow(`
|
|
|
31
31
|
conventional-commits-parser log2.txt '===' >> parsed.txt
|
|
32
32
|
|
|
33
33
|
Options
|
|
34
|
-
-p, --header-pattern
|
|
35
|
-
-c, --header-correspondence
|
|
36
|
-
-r, --reference-actions
|
|
37
|
-
-i, --issue-prefixes
|
|
38
|
-
|
|
39
|
-
-
|
|
40
|
-
--
|
|
41
|
-
--revert-
|
|
42
|
-
-
|
|
34
|
+
-p, --header-pattern Regex to match header pattern
|
|
35
|
+
-c, --header-correspondence Comma separated parts used to define what capturing group of 'headerPattern' captures what
|
|
36
|
+
-r, --reference-actions Comma separated keywords that used to reference issues
|
|
37
|
+
-i, --issue-prefixes Comma separated prefixes of an issue
|
|
38
|
+
--issue-prefixes-case-sensitive Treat issue prefixes as case sensitive
|
|
39
|
+
-n, --note-keywords Comma separated keywords for important notes
|
|
40
|
+
-f, --field-pattern Regex to match other fields
|
|
41
|
+
--revert-pattern Regex to match revert pattern
|
|
42
|
+
--revert-correspondence Comma separated fields used to define what the commit reverts
|
|
43
|
+
-v, --verbose Verbose output
|
|
43
44
|
`, {
|
|
44
45
|
flags: {
|
|
45
46
|
'header-pattern': {
|
|
46
|
-
alias:
|
|
47
|
+
alias: 'p',
|
|
48
|
+
type: 'string'
|
|
47
49
|
},
|
|
48
50
|
'header-correspondence': {
|
|
49
|
-
alias:
|
|
51
|
+
alias: 'c',
|
|
52
|
+
type: 'string'
|
|
50
53
|
},
|
|
51
54
|
'reference-actions': {
|
|
52
|
-
alias:
|
|
55
|
+
alias: 'r',
|
|
56
|
+
type: 'string'
|
|
53
57
|
},
|
|
54
58
|
'issue-prefixes': {
|
|
55
|
-
alias:
|
|
59
|
+
alias: 'i',
|
|
60
|
+
type: 'string'
|
|
61
|
+
},
|
|
62
|
+
'issue-prefixes-case-sensitive': {
|
|
63
|
+
type: 'boolean'
|
|
56
64
|
},
|
|
57
65
|
'note-keywords': {
|
|
58
|
-
alias:
|
|
66
|
+
alias: 'n',
|
|
67
|
+
type: 'string'
|
|
59
68
|
},
|
|
60
69
|
'field-pattern': {
|
|
61
|
-
alias:
|
|
70
|
+
alias: 'f',
|
|
71
|
+
type: 'string'
|
|
72
|
+
},
|
|
73
|
+
'revert-pattern': {
|
|
74
|
+
type: 'string'
|
|
75
|
+
},
|
|
76
|
+
'revert-correspondence': {
|
|
77
|
+
type: 'string'
|
|
62
78
|
},
|
|
63
79
|
verbose: {
|
|
64
|
-
alias:
|
|
80
|
+
alias: 'v',
|
|
81
|
+
type: 'boolean'
|
|
65
82
|
}
|
|
66
83
|
}
|
|
67
84
|
})
|
|
@@ -74,15 +91,15 @@ forEach(cli.input, function (arg) {
|
|
|
74
91
|
}
|
|
75
92
|
})
|
|
76
93
|
|
|
77
|
-
|
|
78
|
-
|
|
94
|
+
const length = filePaths.length
|
|
95
|
+
const options = cli.flags
|
|
79
96
|
|
|
80
97
|
if (options.verbose) {
|
|
81
98
|
options.warn = console.log.bind(console)
|
|
82
99
|
}
|
|
83
100
|
|
|
84
101
|
function processFile (fileIndex) {
|
|
85
|
-
|
|
102
|
+
const filePath = filePaths[fileIndex]
|
|
86
103
|
fs.createReadStream(filePath)
|
|
87
104
|
.on('error', function (err) {
|
|
88
105
|
console.warn('Failed to read file ' + filePath + '\n' + err)
|
|
@@ -105,9 +122,9 @@ if (process.stdin.isTTY) {
|
|
|
105
122
|
if (length > 0) {
|
|
106
123
|
processFile(0)
|
|
107
124
|
} else {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
125
|
+
let commit = ''
|
|
126
|
+
const stream = through()
|
|
127
|
+
const rl = readline.createInterface({
|
|
111
128
|
input: process.stdin,
|
|
112
129
|
output: process.stdout,
|
|
113
130
|
terminal: true
|
package/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
const parser = require('./lib/parser')
|
|
4
|
+
const regex = require('./lib/regex')
|
|
5
|
+
const through = require('through2')
|
|
6
|
+
const _ = require('lodash')
|
|
7
7
|
|
|
8
8
|
function assignOpts (options) {
|
|
9
9
|
options = _.extend({
|
|
10
|
-
headerPattern: /^(\w*)(?:\(([\w
|
|
10
|
+
headerPattern: /^(\w*)(?:\(([\w$.\-*/ ]*)\))?: (.*)$/,
|
|
11
11
|
headerCorrespondence: ['type', 'scope', 'subject'],
|
|
12
12
|
referenceActions: [
|
|
13
13
|
'close',
|
|
@@ -71,10 +71,10 @@ function assignOpts (options) {
|
|
|
71
71
|
|
|
72
72
|
function conventionalCommitsParser (options) {
|
|
73
73
|
options = assignOpts(options)
|
|
74
|
-
|
|
74
|
+
const reg = regex(options)
|
|
75
75
|
|
|
76
76
|
return through.obj(function (data, enc, cb) {
|
|
77
|
-
|
|
77
|
+
let commit
|
|
78
78
|
|
|
79
79
|
try {
|
|
80
80
|
commit = parser(data.toString(), options, reg)
|
|
@@ -92,7 +92,7 @@ function conventionalCommitsParser (options) {
|
|
|
92
92
|
|
|
93
93
|
function sync (commit, options) {
|
|
94
94
|
options = assignOpts(options)
|
|
95
|
-
|
|
95
|
+
const reg = regex(options)
|
|
96
96
|
|
|
97
97
|
return parser(commit, options, reg)
|
|
98
98
|
}
|
package/lib/parser.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict'
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
const trimOffNewlines = require('trim-off-newlines')
|
|
3
|
+
const _ = require('lodash')
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
const CATCH_ALL = /()(.+)/gi
|
|
6
|
+
const SCISSOR = '# ------------------------ >8 ------------------------'
|
|
7
7
|
|
|
8
8
|
function append (src, line) {
|
|
9
9
|
if (src) {
|
|
@@ -22,7 +22,7 @@ function getCommentFilter (char) {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
function truncateToScissor (lines) {
|
|
25
|
-
|
|
25
|
+
const scissorIndex = lines.indexOf(SCISSOR)
|
|
26
26
|
|
|
27
27
|
if (scissorIndex === -1) {
|
|
28
28
|
return lines
|
|
@@ -32,29 +32,29 @@ function truncateToScissor (lines) {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
function getReferences (input, regex) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
const references = []
|
|
36
|
+
let referenceSentences
|
|
37
|
+
let referenceMatch
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
const reApplicable = input.match(regex.references) !== null
|
|
40
40
|
? regex.references
|
|
41
41
|
: CATCH_ALL
|
|
42
42
|
|
|
43
43
|
while ((referenceSentences = reApplicable.exec(input))) {
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
const action = referenceSentences[1] || null
|
|
45
|
+
const sentence = referenceSentences[2]
|
|
46
46
|
|
|
47
47
|
while ((referenceMatch = regex.referenceParts.exec(sentence))) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
let owner = null
|
|
49
|
+
let repository = referenceMatch[1] || ''
|
|
50
|
+
const ownerRepo = repository.split('/')
|
|
51
51
|
|
|
52
52
|
if (ownerRepo.length > 1) {
|
|
53
53
|
owner = ownerRepo.shift()
|
|
54
54
|
repository = ownerRepo.join('/')
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
const reference = {
|
|
58
58
|
action: action,
|
|
59
59
|
owner: owner,
|
|
60
60
|
repository: repository || null,
|
|
@@ -87,39 +87,37 @@ function parser (raw, options, regex) {
|
|
|
87
87
|
throw new TypeError('Expected regex')
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
var revertMatch
|
|
95
|
-
var otherFields = {}
|
|
96
|
-
var commentFilter = typeof options.commentChar === 'string'
|
|
90
|
+
let currentProcessedField
|
|
91
|
+
let mentionsMatch
|
|
92
|
+
const otherFields = {}
|
|
93
|
+
const commentFilter = typeof options.commentChar === 'string'
|
|
97
94
|
? getCommentFilter(options.commentChar)
|
|
98
95
|
: passTrough
|
|
96
|
+
const gpgFilter = line => !line.match(/^\s*gpg:/)
|
|
99
97
|
|
|
100
|
-
|
|
101
|
-
|
|
98
|
+
const rawLines = trimOffNewlines(raw).split(/\r?\n/)
|
|
99
|
+
const lines = truncateToScissor(rawLines).filter(commentFilter).filter(gpgFilter)
|
|
102
100
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
101
|
+
let continueNote = false
|
|
102
|
+
let isBody = true
|
|
103
|
+
const headerCorrespondence = _.map(options.headerCorrespondence, function (part) {
|
|
106
104
|
return part.trim()
|
|
107
105
|
})
|
|
108
|
-
|
|
106
|
+
const revertCorrespondence = _.map(options.revertCorrespondence, function (field) {
|
|
109
107
|
return field.trim()
|
|
110
108
|
})
|
|
111
|
-
|
|
109
|
+
const mergeCorrespondence = _.map(options.mergeCorrespondence, function (field) {
|
|
112
110
|
return field.trim()
|
|
113
111
|
})
|
|
114
112
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
113
|
+
let body = null
|
|
114
|
+
let footer = null
|
|
115
|
+
let header = null
|
|
116
|
+
const mentions = []
|
|
117
|
+
let merge = null
|
|
118
|
+
const notes = []
|
|
119
|
+
const references = []
|
|
120
|
+
let revert = null
|
|
123
121
|
|
|
124
122
|
if (lines.length === 0) {
|
|
125
123
|
return {
|
|
@@ -139,22 +137,25 @@ function parser (raw, options, regex) {
|
|
|
139
137
|
|
|
140
138
|
// msg parts
|
|
141
139
|
merge = lines.shift()
|
|
142
|
-
|
|
143
|
-
|
|
140
|
+
const mergeParts = {}
|
|
141
|
+
const headerParts = {}
|
|
144
142
|
body = ''
|
|
145
143
|
footer = ''
|
|
146
144
|
|
|
147
|
-
mergeMatch = merge.match(options.mergePattern)
|
|
145
|
+
const mergeMatch = merge.match(options.mergePattern)
|
|
148
146
|
if (mergeMatch && options.mergePattern) {
|
|
149
147
|
merge = mergeMatch[0]
|
|
150
148
|
|
|
151
149
|
header = lines.shift()
|
|
152
|
-
while (!header.trim()) {
|
|
150
|
+
while (header !== undefined && !header.trim()) {
|
|
153
151
|
header = lines.shift()
|
|
154
152
|
}
|
|
153
|
+
if (!header) {
|
|
154
|
+
header = ''
|
|
155
|
+
}
|
|
155
156
|
|
|
156
157
|
_.forEach(mergeCorrespondence, function (partName, index) {
|
|
157
|
-
|
|
158
|
+
const partValue = mergeMatch[index + 1] || null
|
|
158
159
|
mergeParts[partName] = partValue
|
|
159
160
|
})
|
|
160
161
|
} else {
|
|
@@ -166,10 +167,10 @@ function parser (raw, options, regex) {
|
|
|
166
167
|
})
|
|
167
168
|
}
|
|
168
169
|
|
|
169
|
-
headerMatch = header.match(options.headerPattern)
|
|
170
|
+
const headerMatch = header.match(options.headerPattern)
|
|
170
171
|
if (headerMatch) {
|
|
171
172
|
_.forEach(headerCorrespondence, function (partName, index) {
|
|
172
|
-
|
|
173
|
+
const partValue = headerMatch[index + 1] || null
|
|
173
174
|
headerParts[partName] = partValue
|
|
174
175
|
})
|
|
175
176
|
} else {
|
|
@@ -186,7 +187,7 @@ function parser (raw, options, regex) {
|
|
|
186
187
|
// body or footer
|
|
187
188
|
_.forEach(lines, function (line) {
|
|
188
189
|
if (options.fieldPattern) {
|
|
189
|
-
|
|
190
|
+
const fieldMatch = options.fieldPattern.exec(line)
|
|
190
191
|
|
|
191
192
|
if (fieldMatch) {
|
|
192
193
|
currentProcessedField = fieldMatch[1]
|
|
@@ -201,16 +202,16 @@ function parser (raw, options, regex) {
|
|
|
201
202
|
}
|
|
202
203
|
}
|
|
203
204
|
|
|
204
|
-
|
|
205
|
+
let referenceMatched
|
|
205
206
|
|
|
206
207
|
// this is a new important note
|
|
207
|
-
|
|
208
|
+
const notesMatch = line.match(regex.notes)
|
|
208
209
|
if (notesMatch) {
|
|
209
210
|
continueNote = true
|
|
210
211
|
isBody = false
|
|
211
212
|
footer = append(footer, line)
|
|
212
213
|
|
|
213
|
-
|
|
214
|
+
const note = {
|
|
214
215
|
title: notesMatch[1],
|
|
215
216
|
text: notesMatch[2]
|
|
216
217
|
}
|
|
@@ -220,7 +221,7 @@ function parser (raw, options, regex) {
|
|
|
220
221
|
return
|
|
221
222
|
}
|
|
222
223
|
|
|
223
|
-
|
|
224
|
+
const lineReferences = getReferences(line, {
|
|
224
225
|
references: regex.references,
|
|
225
226
|
referenceParts: regex.referenceParts
|
|
226
227
|
})
|
|
@@ -254,7 +255,7 @@ function parser (raw, options, regex) {
|
|
|
254
255
|
})
|
|
255
256
|
|
|
256
257
|
if (options.breakingHeaderPattern && notes.length === 0) {
|
|
257
|
-
|
|
258
|
+
const breakingHeader = header.match(options.breakingHeaderPattern)
|
|
258
259
|
if (breakingHeader) {
|
|
259
260
|
const noteText = breakingHeader[3] // the description of the change.
|
|
260
261
|
notes.push({
|
|
@@ -269,11 +270,11 @@ function parser (raw, options, regex) {
|
|
|
269
270
|
}
|
|
270
271
|
|
|
271
272
|
// does this commit revert any other commit?
|
|
272
|
-
revertMatch = raw.match(options.revertPattern)
|
|
273
|
+
const revertMatch = raw.match(options.revertPattern)
|
|
273
274
|
if (revertMatch) {
|
|
274
275
|
revert = {}
|
|
275
276
|
_.forEach(revertCorrespondence, function (partName, index) {
|
|
276
|
-
|
|
277
|
+
const partValue = revertMatch[index + 1] || null
|
|
277
278
|
revert[partName] = partValue
|
|
278
279
|
})
|
|
279
280
|
} else {
|
|
@@ -286,7 +287,7 @@ function parser (raw, options, regex) {
|
|
|
286
287
|
return note
|
|
287
288
|
})
|
|
288
289
|
|
|
289
|
-
|
|
290
|
+
const msg = _.merge(headerParts, mergeParts, {
|
|
290
291
|
merge: merge,
|
|
291
292
|
header: header,
|
|
292
293
|
body: body ? trimOffNewlines(body) : null,
|
package/lib/regex.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const reNomatch = /(?!.*)/
|
|
4
4
|
|
|
5
5
|
function join (array, joiner) {
|
|
6
6
|
return array
|
|
@@ -13,20 +13,27 @@ function join (array, joiner) {
|
|
|
13
13
|
.join(joiner)
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
function getNotesRegex (noteKeywords) {
|
|
16
|
+
function getNotesRegex (noteKeywords, notesPattern) {
|
|
17
17
|
if (!noteKeywords) {
|
|
18
18
|
return reNomatch
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
const noteKeywordsSelection = join(noteKeywords, '|')
|
|
22
|
+
|
|
23
|
+
if (!notesPattern) {
|
|
24
|
+
return new RegExp('^[\\s|*]*(' + noteKeywordsSelection + ')[:\\s]+(.*)', 'i')
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return notesPattern(noteKeywordsSelection)
|
|
22
28
|
}
|
|
23
29
|
|
|
24
|
-
function getReferencePartsRegex (issuePrefixes) {
|
|
30
|
+
function getReferencePartsRegex (issuePrefixes, issuePrefixesCaseSensitive) {
|
|
25
31
|
if (!issuePrefixes) {
|
|
26
32
|
return reNomatch
|
|
27
33
|
}
|
|
28
34
|
|
|
29
|
-
|
|
35
|
+
const flags = issuePrefixesCaseSensitive ? 'g' : 'gi'
|
|
36
|
+
return new RegExp('(?:.*?)??\\s*([\\w-\\.\\/]*?)??(' + join(issuePrefixes, '|') + ')([\\w-]*\\d+)', flags)
|
|
30
37
|
}
|
|
31
38
|
|
|
32
39
|
function getReferencesRegex (referenceActions) {
|
|
@@ -35,15 +42,15 @@ function getReferencesRegex (referenceActions) {
|
|
|
35
42
|
return /()(.+)/gi
|
|
36
43
|
}
|
|
37
44
|
|
|
38
|
-
|
|
45
|
+
const joinedKeywords = join(referenceActions, '|')
|
|
39
46
|
return new RegExp('(' + joinedKeywords + ')(?:\\s+(.*?))(?=(?:' + joinedKeywords + ')|$)', 'gi')
|
|
40
47
|
}
|
|
41
48
|
|
|
42
49
|
module.exports = function (options) {
|
|
43
50
|
options = options || {}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
51
|
+
const reNotes = getNotesRegex(options.noteKeywords, options.notesPattern)
|
|
52
|
+
const reReferenceParts = getReferencePartsRegex(options.issuePrefixes, options.issuePrefixesCaseSensitive)
|
|
53
|
+
const reReferences = getReferencesRegex(options.referenceActions)
|
|
47
54
|
|
|
48
55
|
return {
|
|
49
56
|
notes: reNotes,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "conventional-commits-parser",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.1",
|
|
4
4
|
"description": "Parse raw conventional commits",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/conventional-changelog/conventional-changelog/issues"
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"engines": {
|
|
20
|
-
"node": ">=
|
|
20
|
+
"node": ">=10"
|
|
21
21
|
},
|
|
22
22
|
"files": [
|
|
23
23
|
"index.js",
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
"JSONStream": "^1.0.4",
|
|
37
37
|
"is-text-path": "^1.0.1",
|
|
38
38
|
"lodash": "^4.17.15",
|
|
39
|
-
"meow": "^
|
|
40
|
-
"split2": "^
|
|
41
|
-
"through2": "^
|
|
39
|
+
"meow": "^8.0.0",
|
|
40
|
+
"split2": "^3.0.0",
|
|
41
|
+
"through2": "^4.0.0",
|
|
42
42
|
"trim-off-newlines": "^1.0.0"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
@@ -47,5 +47,7 @@
|
|
|
47
47
|
"bin": {
|
|
48
48
|
"conventional-commits-parser": "cli.js"
|
|
49
49
|
},
|
|
50
|
-
"
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"forceable-tty": "^0.1.0"
|
|
52
|
+
}
|
|
51
53
|
}
|