conventional-commits-parser 4.0.0 → 5.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} +33 -33
- package/lib/parser.js +16 -16
- package/package.json +7 -10
package/{cli.js → cli.mjs}
RENAMED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const split = require('split2')
|
|
11
|
-
|
|
12
|
-
const filePaths = []
|
|
13
|
-
let separator = '\n\n\n'
|
|
2
|
+
import fs from 'fs'
|
|
3
|
+
import readline from 'readline'
|
|
4
|
+
import { Transform } from 'stream'
|
|
5
|
+
import isTextPath from 'is-text-path'
|
|
6
|
+
import JSONStream from 'JSONStream'
|
|
7
|
+
import split from 'split2'
|
|
8
|
+
import meow from 'meow'
|
|
9
|
+
import conventionalCommitsParser from './index.js'
|
|
14
10
|
|
|
15
11
|
const cli = meow(`
|
|
16
12
|
Practice writing commit messages or parse messages from files.
|
|
@@ -41,48 +37,52 @@ const cli = meow(`
|
|
|
41
37
|
--revert-correspondence Comma separated fields used to define what the commit reverts
|
|
42
38
|
-v, --verbose Verbose output
|
|
43
39
|
`, {
|
|
40
|
+
importMeta: import.meta,
|
|
44
41
|
flags: {
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
headerPattern: {
|
|
43
|
+
shortFlag: 'p',
|
|
47
44
|
type: 'string'
|
|
48
45
|
},
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
headerCorrespondence: {
|
|
47
|
+
shortFlag: 'c',
|
|
51
48
|
type: 'string'
|
|
52
49
|
},
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
referenceActions: {
|
|
51
|
+
shortFlag: 'r',
|
|
55
52
|
type: 'string'
|
|
56
53
|
},
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
issuePrefixes: {
|
|
55
|
+
shortFlag: 'i',
|
|
59
56
|
type: 'string'
|
|
60
57
|
},
|
|
61
|
-
|
|
58
|
+
issuePrefixesCaseSensitive: {
|
|
62
59
|
type: 'boolean'
|
|
63
60
|
},
|
|
64
|
-
|
|
65
|
-
|
|
61
|
+
noteKeywords: {
|
|
62
|
+
shortFlag: 'n',
|
|
66
63
|
type: 'string'
|
|
67
64
|
},
|
|
68
|
-
|
|
69
|
-
|
|
65
|
+
fieldPattern: {
|
|
66
|
+
shortFlag: 'f',
|
|
70
67
|
type: 'string'
|
|
71
68
|
},
|
|
72
|
-
|
|
69
|
+
revertPattern: {
|
|
73
70
|
type: 'string'
|
|
74
71
|
},
|
|
75
|
-
|
|
72
|
+
revertCorrespondence: {
|
|
76
73
|
type: 'string'
|
|
77
74
|
},
|
|
78
75
|
verbose: {
|
|
79
|
-
|
|
76
|
+
shortFlag: 'v',
|
|
80
77
|
type: 'boolean'
|
|
81
78
|
}
|
|
82
79
|
}
|
|
83
80
|
})
|
|
84
81
|
|
|
85
|
-
|
|
82
|
+
const filePaths = []
|
|
83
|
+
let separator = '\n\n\n'
|
|
84
|
+
|
|
85
|
+
cli.input.forEach((arg) => {
|
|
86
86
|
if (isTextPath(arg)) {
|
|
87
87
|
filePaths.push(arg)
|
|
88
88
|
} else {
|
|
@@ -100,7 +100,7 @@ if (options.verbose) {
|
|
|
100
100
|
function processFile (fileIndex) {
|
|
101
101
|
const filePath = filePaths[fileIndex]
|
|
102
102
|
fs.createReadStream(filePath)
|
|
103
|
-
.on('error',
|
|
103
|
+
.on('error', (err) => {
|
|
104
104
|
console.warn('Failed to read file ' + filePath + '\n' + err)
|
|
105
105
|
if (++fileIndex < length) {
|
|
106
106
|
processFile(fileIndex)
|
|
@@ -109,7 +109,7 @@ function processFile (fileIndex) {
|
|
|
109
109
|
.pipe(split(separator))
|
|
110
110
|
.pipe(conventionalCommitsParser(options))
|
|
111
111
|
.pipe(JSONStream.stringify())
|
|
112
|
-
.on('end',
|
|
112
|
+
.on('end', () => {
|
|
113
113
|
if (++fileIndex < length) {
|
|
114
114
|
processFile(fileIndex)
|
|
115
115
|
}
|
|
@@ -146,7 +146,7 @@ if (process.stdin.isTTY) {
|
|
|
146
146
|
)
|
|
147
147
|
.pipe(process.stdout)
|
|
148
148
|
|
|
149
|
-
rl.on('line',
|
|
149
|
+
rl.on('line', (line) => {
|
|
150
150
|
commit += line + '\n'
|
|
151
151
|
if (commit.indexOf(separator) === -1) {
|
|
152
152
|
return
|
|
@@ -161,7 +161,7 @@ if (process.stdin.isTTY) {
|
|
|
161
161
|
process.stdin
|
|
162
162
|
.pipe(split(separator))
|
|
163
163
|
.pipe(conventionalCommitsParser(options))
|
|
164
|
-
.on('error',
|
|
164
|
+
.on('error', (err) => {
|
|
165
165
|
console.error(err.toString())
|
|
166
166
|
process.exit(1)
|
|
167
167
|
})
|
package/lib/parser.js
CHANGED
|
@@ -66,8 +66,8 @@ function getReferences (input, regex) {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
const reference = {
|
|
69
|
-
action
|
|
70
|
-
owner
|
|
69
|
+
action,
|
|
70
|
+
owner,
|
|
71
71
|
repository: repository || null,
|
|
72
72
|
issue: referenceMatch[3],
|
|
73
73
|
raw: referenceMatch[0],
|
|
@@ -132,14 +132,14 @@ function parser (raw, options, regex) {
|
|
|
132
132
|
|
|
133
133
|
if (lines.length === 0) {
|
|
134
134
|
return {
|
|
135
|
-
body
|
|
136
|
-
footer
|
|
137
|
-
header
|
|
138
|
-
mentions
|
|
139
|
-
merge
|
|
140
|
-
notes
|
|
141
|
-
references
|
|
142
|
-
revert
|
|
135
|
+
body,
|
|
136
|
+
footer,
|
|
137
|
+
header,
|
|
138
|
+
mentions,
|
|
139
|
+
merge,
|
|
140
|
+
notes,
|
|
141
|
+
references,
|
|
142
|
+
revert,
|
|
143
143
|
scope: null,
|
|
144
144
|
subject: null,
|
|
145
145
|
type: null
|
|
@@ -299,14 +299,14 @@ function parser (raw, options, regex) {
|
|
|
299
299
|
const msg = {
|
|
300
300
|
...headerParts,
|
|
301
301
|
...mergeParts,
|
|
302
|
-
merge
|
|
303
|
-
header
|
|
302
|
+
merge,
|
|
303
|
+
header,
|
|
304
304
|
body: body ? trimOffNewlines(body) : null,
|
|
305
305
|
footer: footer ? trimOffNewlines(footer) : null,
|
|
306
|
-
notes
|
|
307
|
-
references
|
|
308
|
-
mentions
|
|
309
|
-
revert
|
|
306
|
+
notes,
|
|
307
|
+
references,
|
|
308
|
+
mentions,
|
|
309
|
+
revert,
|
|
310
310
|
...otherFields
|
|
311
311
|
}
|
|
312
312
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "conventional-commits-parser",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "Parse raw conventional commits",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/conventional-changelog/conventional-changelog/issues"
|
|
@@ -17,11 +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.
|
|
24
|
+
"cli.mjs",
|
|
25
25
|
"lib"
|
|
26
26
|
],
|
|
27
27
|
"keywords": [
|
|
@@ -34,17 +34,14 @@
|
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"JSONStream": "^1.3.5",
|
|
37
|
-
"is-text-path": "^
|
|
38
|
-
"meow": "^
|
|
39
|
-
"split2": "^
|
|
37
|
+
"is-text-path": "^2.0.0",
|
|
38
|
+
"meow": "^12.0.1",
|
|
39
|
+
"split2": "^4.0.0"
|
|
40
40
|
},
|
|
41
41
|
"bin": {
|
|
42
|
-
"conventional-commits-parser": "cli.
|
|
42
|
+
"conventional-commits-parser": "cli.mjs"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"forceable-tty": "^0.1.0"
|
|
46
|
-
},
|
|
47
|
-
"scripts": {
|
|
48
|
-
"test-windows": "echo 'make work on windows'"
|
|
49
46
|
}
|
|
50
47
|
}
|