88 * @see https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/git-raw-commits
99 */
1010
11+ import {
12+ Type ,
13+ parserPreset ,
14+ type Commit
15+ } from '@flex-development/commitlint-config'
1116import pathe from '@flex-development/pathe'
1217import { CompareResult , isNIL } from '@flex-development/tutils'
1318import addStream from 'add-stream'
@@ -17,7 +22,7 @@ import type {
1722 CommitGroup ,
1823 GeneratedContext
1924} from 'conventional-changelog-writer'
20- import type { Commit , ICommit } from 'conventional-commits-parser'
25+ import type { ICommit } from 'conventional-commits-parser'
2126import dateformat from 'dateformat'
2227import type mri from 'mri'
2328import {
@@ -136,7 +141,8 @@ sade('changelog', true)
136141 *
137142 * @const {Readable} changelog
138143 */
139- const changelog : Readable = conventionalChangelog (
144+ // @ts -expect-error type definitions are incorrect
145+ const changelog : Readable = conventionalChangelog < Commit > (
140146 {
141147 append : false ,
142148 debug : debug ? console . debug . bind ( console ) : undefined ,
@@ -147,24 +153,23 @@ sade('changelog', true)
147153 ? ! ! outputUnreleased . trim ( )
148154 : false ,
149155 pkg : { path : pathe . resolve ( 'package.json' ) } ,
150- // @ts -expect-error ts(2322)
151156 preset : {
152157 header : '' ,
153- name : 'conventionalcommits' ,
158+ name : parserPreset . name ,
154159 releaseCommitMessageFormat : 'release: {{currentTag}}' ,
155160 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 }
168173 ]
169174 } ,
170175 releaseCount,
@@ -183,25 +188,23 @@ sade('changelog', true)
183188 transform ( commit : Commit , apply : Options . Transform . Callback ) : void {
184189 return void apply ( null , {
185190 ...commit ,
186- committerDate : dateformat (
187- commit . committerDate ! ,
188- 'yyyy-mm-dd' ,
189- true
190- ) ,
191+ committerDate : dateformat ( commit . committerDate , 'yyyy-mm-dd' , true ) ,
191192 mentions : commit . mentions . filter ( m => m !== 'flexdevelopment' ) ,
192193 // @ts -expect-error ts(2322)
193194 raw : commit ,
194195 references : commit . references . filter ( ref => ref . action !== null ) ,
195- shortHash : commit . hash ! . slice ( 0 , 7 ) ,
196196 version : commit . gitTags ? vgx . exec ( commit . gitTags ) ?. [ 1 ] : undefined
197197 } )
198- }
198+ } ,
199+ warn : parserPreset . parserOpts . warn
199200 } ,
200201 { } ,
201- { } ,
202202 {
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'
204206 } ,
207+ parserPreset . parserOpts ,
205208 {
206209 /**
207210 * Sorts commit groups in descending order by group title.
@@ -299,8 +302,8 @@ sade('changelog', true)
299302
300303 // try setting previous tag based on current tag
301304 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 ]
304307 if ( ! previousTag ) previousTag = last_commit ?. hash ?? undefined
305308 }
306309 } else {
0 commit comments