@@ -14,6 +14,7 @@ import {
1414 getProcessSubject ,
1515 getMaxSubjectLength ,
1616 handleScopes ,
17+ handleCustomTemplate ,
1718 buildCommit ,
1819 log
1920} from "./until" ;
@@ -45,11 +46,17 @@ export const generateOptions = (clConfig: any): CommitizenGitOptions => {
4546 scopes : pkgConfig . scopes ?? clPromptConfig . scopes ?? defaultConfig . scopes ,
4647 scopeOverrides : pkgConfig . scopeOverrides ?? clPromptConfig . scopeOverrides ?? defaultConfig . scopeOverrides ,
4748 allowCustomScopes : pkgConfig . allowCustomScopes ?? clPromptConfig . allowCustomScopes ?? defaultConfig . allowCustomScopes ,
49+ customScopesAlign : pkgConfig . customScopesAlign ?? clPromptConfig . customScopesAlign ?? defaultConfig . customScopesAlign ,
50+ customScopesAlias : pkgConfig . customScopesAlias ?? clPromptConfig . customScopesAlias ?? defaultConfig . customScopesAlias ,
51+ emptyScopesAlias : pkgConfig . emptyScopesAlias ?? clPromptConfig . emptyScopesAlias ?? defaultConfig . emptyScopesAlias ,
4852 upperCaseSubject : pkgConfig . upperCaseSubject ?? clPromptConfig . upperCaseSubject ?? defaultConfig . upperCaseSubject ,
4953 allowBreakingChanges : pkgConfig . allowBreakingChanges ?? clPromptConfig . allowBreakingChanges ?? defaultConfig . allowBreakingChanges ,
5054 breaklineChar : pkgConfig . breaklineChar ?? clPromptConfig . breaklineChar ?? defaultConfig . breaklineChar ,
5155 skipQuestions : pkgConfig . skipQuestions ?? clPromptConfig . skipQuestions ?? defaultConfig . skipQuestions ,
5256 issuePrefixs : pkgConfig . issuePrefixs ?? clPromptConfig . issuePrefixs ?? defaultConfig . issuePrefixs ,
57+ customIssuePrefixsAlign : pkgConfig . customIssuePrefixsAlign ?? clPromptConfig . customIssuePrefixsAlign ?? defaultConfig . customIssuePrefixsAlign ,
58+ emptyIssuePrefixsAlias : pkgConfig . emptyIssuePrefixsAlias ?? clPromptConfig . emptyIssuePrefixsAlias ?? defaultConfig . emptyIssuePrefixsAlias ,
59+ customIssuePrefixsAlias : pkgConfig . customIssuePrefixsAlias ?? clPromptConfig . customIssuePrefixsAlias ?? defaultConfig . customIssuePrefixsAlias ,
5360 confirmColorize : pkgConfig . confirmColorize ?? clPromptConfig . confirmColorize ?? defaultConfig . confirmColorize ,
5461 maxHeaderLength : CZ_MAN_HEADER_LENGTH ? parseInt ( CZ_MAN_HEADER_LENGTH ) : getMaxLength ( clConfig ?. rules ?. [ "header-max-length" ] ) ,
5562 maxSubjectLength : CZ_MAN_SUBJECT_LENGTH ? parseInt ( CZ_MAN_SUBJECT_LENGTH ) : getMaxLength ( clConfig ?. rules ?. [ "subject-max-length" ] ) ,
@@ -81,17 +88,17 @@ export const generateQuestions = (options: CommitizenGitOptions, cz: any) => {
8188 source : ( answer : Answers , input : string ) => {
8289 let scopes : Option [ ] = [ ] ;
8390 if ( options . scopeOverrides && answer . type && options . scopeOverrides [ answer . type ] ) {
84- scopes = scopes . concat ( handleScopes ( options . scopeOverrides [ answer . type ] ) ) ;
91+ scopes = handleScopes ( options . scopeOverrides [ answer . type ] ) ;
8592 } else if ( Array . isArray ( options . scopes ) ) {
86- scopes = scopes . concat ( handleScopes ( options . scopes ) ) ;
87- }
88- if ( options . allowCustomScopes || scopes . length === 0 ) {
89- scopes = scopes . concat ( [
90- new cz . Separator ( "" ) ,
91- { value : false , name : "empty" } ,
92- { value : "custom" , name : "custom" }
93- ] ) ;
93+ scopes = handleScopes ( options . scopes ) ;
9494 }
95+ scopes = handleCustomTemplate (
96+ scopes ,
97+ cz ,
98+ options . customScopesAlign ,
99+ options . emptyScopesAlias ,
100+ options . customScopesAlias
101+ ) ;
95102 return scopes ?. filter ( ( item ) => ( input ? item . name ?. includes ( input ) : true ) ) || true ;
96103 }
97104 } ,
@@ -101,7 +108,7 @@ export const generateQuestions = (options: CommitizenGitOptions, cz: any) => {
101108 message : options . messages ?. customScope ,
102109 default : options . defaultScope || undefined ,
103110 when ( answers : Answers ) {
104- return answers . scope === "custom " ;
111+ return answers . scope === "___CUSTOM___ " ;
105112 }
106113 } ,
107114 {
@@ -186,14 +193,13 @@ export const generateQuestions = (options: CommitizenGitOptions, cz: any) => {
186193 name : "footerPrefix" ,
187194 message : options . messages ?. footerPrefixsSelect ,
188195 source : ( _ : Answers , input : string ) => {
189- let issues : Array < { name : string ; value : string } > = [
190- { name : "skip" , value : false } ,
191- { name : "custom" , value : "custom" } ,
192- new cz . Separator ( "" )
193- ] ;
194- if ( Array . isArray ( options . issuePrefixs ) ) {
195- issues = issues . concat ( options . issuePrefixs ) ;
196- }
196+ const issues = handleCustomTemplate (
197+ options . issuePrefixs as Option [ ] ,
198+ cz ,
199+ options . customIssuePrefixsAlign ,
200+ options . emptyIssuePrefixsAlias ,
201+ options . customIssuePrefixsAlias
202+ )
197203 return issues ?. filter ( ( item ) => ( input ? item . name ?. includes ( input ) : true ) ) || true ;
198204 }
199205 } ,
@@ -203,7 +209,7 @@ export const generateQuestions = (options: CommitizenGitOptions, cz: any) => {
203209 message : options . messages ?. customFooterPrefixs ,
204210 default : options . defaultIssues || undefined ,
205211 when ( answers : Answers ) {
206- return answers . footerPrefix === "custom " ;
212+ return answers . footerPrefix === "___CUSTOM___ " ;
207213 }
208214 } ,
209215 {
@@ -227,7 +233,9 @@ export const generateQuestions = (options: CommitizenGitOptions, cz: any) => {
227233 const SEP = options . confirmColorize
228234 ? "\u001B[1;90m###--------------------------------------------------------###\u001B[0m"
229235 : "###--------------------------------------------------------###" ;
230- console . info ( `\n${ SEP } \n${ buildCommit ( answers , options , options . confirmColorize ) } \n${ SEP } \n` ) ;
236+ console . info (
237+ `\n${ SEP } \n${ buildCommit ( answers , options , options . confirmColorize ) } \n${ SEP } \n`
238+ ) ;
231239 return options . messages ?. confirmCommit ;
232240 }
233241 }
0 commit comments