8
8
* @see https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/git-raw-commits
9
9
*/
10
10
11
+ import {
12
+ Type ,
13
+ parserPreset ,
14
+ type Commit
15
+ } from '@flex-development/commitlint-config'
11
16
import pathe from '@flex-development/pathe'
12
17
import { CompareResult , isNIL } from '@flex-development/tutils'
13
18
import addStream from 'add-stream'
@@ -17,7 +22,7 @@ import type {
17
22
CommitGroup ,
18
23
GeneratedContext
19
24
} from 'conventional-changelog-writer'
20
- import type { Commit , ICommit } from 'conventional-commits-parser'
25
+ import type { ICommit } from 'conventional-commits-parser'
21
26
import dateformat from 'dateformat'
22
27
import type mri from 'mri'
23
28
import {
@@ -136,7 +141,8 @@ sade('changelog', true)
136
141
*
137
142
* @const {Readable} changelog
138
143
*/
139
- const changelog : Readable = conventionalChangelog (
144
+ // @ts -expect-error type definitions are incorrect
145
+ const changelog : Readable = conventionalChangelog < Commit > (
140
146
{
141
147
append : false ,
142
148
debug : debug ? console . debug . bind ( console ) : undefined ,
@@ -147,24 +153,23 @@ sade('changelog', true)
147
153
? ! ! outputUnreleased . trim ( )
148
154
: false ,
149
155
pkg : { path : pathe . resolve ( 'package.json' ) } ,
150
- // @ts -expect-error ts(2322)
151
156
preset : {
152
157
header : '' ,
153
- name : 'conventionalcommits' ,
158
+ name : parserPreset . name ,
154
159
releaseCommitMessageFormat : 'release: {{currentTag}}' ,
155
160
types : [
156
- { section : ':package: Build' , type : 'build' } ,
157
- { section : ':house_with_garden: Housekeeping' , type : 'chore' } ,
158
- { section : ':robot: Continuous Integration' , type : 'ci' } ,
159
- { section : ':pencil: Documentation' , type : 'docs' } ,
160
- { section : ':sparkles: Features' , type : 'feat' } ,
161
- { section : ':bug: Fixes' , type : 'fix' } ,
162
- { section : ':fire: Performance Improvements' , type : 'perf' } ,
163
- { section : ':zap : Refactors' , type : 'refactor' } ,
164
- { section : ':rewind : Reverts' , type : 'revert' } ,
165
- { hidden : true , type : 'style' } ,
166
- { section : ':white_check_mark: Testing' , type : 'test' } ,
167
- { hidden : true , type : 'wip' }
161
+ { section : ':package: Build' , type : Type . BUILD } ,
162
+ { section : ':house_with_garden: Housekeeping' , type : Type . CHORE } ,
163
+ { section : ':robot: Continuous Integration' , type : Type . CI } ,
164
+ { section : ':pencil: Documentation' , type : Type . DOCS } ,
165
+ { section : ':sparkles: Features' , type : Type . FEAT } ,
166
+ { section : ':bug: Fixes' , type : Type . FIX } ,
167
+ { section : ':fire: Performance Improvements' , type : Type . PERF } ,
168
+ { section : ':mechanical_arm : Refactors' , type : Type . REFACTOR } ,
169
+ { section : ':wastebasket : Reverts' , type : Type . REVERT } ,
170
+ { hidden : true , type : Type . STYLE } ,
171
+ { section : ':white_check_mark: Testing' , type : Type . TEST } ,
172
+ { hidden : true , type : Type . WIP }
168
173
]
169
174
} ,
170
175
releaseCount,
@@ -183,25 +188,23 @@ sade('changelog', true)
183
188
transform ( commit : Commit , apply : Options . Transform . Callback ) : void {
184
189
return void apply ( null , {
185
190
...commit ,
186
- committerDate : dateformat (
187
- commit . committerDate ! ,
188
- 'yyyy-mm-dd' ,
189
- true
190
- ) ,
191
+ committerDate : dateformat ( commit . committerDate , 'yyyy-mm-dd' , true ) ,
191
192
mentions : commit . mentions . filter ( m => m !== 'flexdevelopment' ) ,
192
193
// @ts -expect-error ts(2322)
193
194
raw : commit ,
194
195
references : commit . references . filter ( ref => ref . action !== null ) ,
195
- shortHash : commit . hash ! . slice ( 0 , 7 ) ,
196
196
version : commit . gitTags ? vgx . exec ( commit . gitTags ) ?. [ 1 ] : undefined
197
197
} )
198
- }
198
+ } ,
199
+ warn : parserPreset . parserOpts . warn
199
200
} ,
200
201
{ } ,
201
- { } ,
202
202
{
203
- issuePrefixesCaseSensitive : true
203
+ debug : debug ? parserPreset . parserOpts . warn : undefined ,
204
+ format :
205
+ '%B%n-hash-%n%H%n-shortHash-%n%h%n-gitTags-%n%d%n-committerDate-%n%ci%n'
204
206
} ,
207
+ parserPreset . parserOpts ,
205
208
{
206
209
/**
207
210
* Sorts commit groups in descending order by group title.
@@ -299,8 +302,8 @@ sade('changelog', true)
299
302
300
303
// try setting previous tag based on current tag
301
304
if ( gitSemverTags . includes ( currentTag ?? '' ) ) {
302
- const { version } = key
303
- previousTag = gitSemverTags [ gitSemverTags . indexOf ( version ! ) + 1 ]
305
+ const { version = '' } = key
306
+ previousTag = gitSemverTags [ gitSemverTags . indexOf ( version ) + 1 ]
304
307
if ( ! previousTag ) previousTag = last_commit ?. hash ?? undefined
305
308
}
306
309
} else {
0 commit comments