@@ -8,27 +8,15 @@ import { commitizenConfigLoader } from "@cz-git/loader";
88import type { Config , CommitizenGitOptions , UserConfig } from "../shared" ;
99import {
1010 defaultConfig ,
11- getMaxLength ,
12- getMinLength ,
1311 enumRuleIsActive ,
1412 emptyRuleIsActive ,
13+ getCommandHaveArgs ,
1514 getEnumList ,
16- getValueByCallBack
15+ getValueByCallBack ,
16+ getMaxLength ,
17+ getMinLength
1718} from "../shared" ;
1819
19- /**
20- * @description : Compatibility support for cz-conventional-changelog
21- */
22- const {
23- CZ_SCOPE ,
24- CZ_SUBJECT ,
25- CZ_BODY ,
26- CZ_ISSUES ,
27- CZ_MAN_HEADER_LENGTH ,
28- CZ_MAN_SUBJECT_LENGTH ,
29- CZ_MIN_SUBJECT_LENGTH
30- } = process . env ;
31-
3220const pkgConfig : Config = commitizenConfigLoader ( ) ?? { } ;
3321
3422/* eslint-disable prettier/prettier */
@@ -39,15 +27,17 @@ export const generateOptions = (clConfig: UserConfig): CommitizenGitOptions => {
3927 clPromptConfig ,
4028 [ "defaultScope" , "defaultSubject" , "defaultBody" , "defaultFooterPrefix" , "defaultIssues" ]
4129 )
30+ const CZ_EMOJI = getCommandHaveArgs ( "emoji" ) ;
31+ const CZ_CHECKBOX = getCommandHaveArgs ( "checkbox" ) ;
4232
4333 return {
4434 messages : pkgConfig . messages ?? clPromptConfig . messages ?? defaultConfig . messages ,
4535 types : pkgConfig . types ?? clPromptConfig . types ?? defaultConfig . types ,
4636 typesAppend : pkgConfig . typesAppend ?? clPromptConfig . typesAppend ?? defaultConfig . typesAppend ,
47- useEmoji : pkgConfig . useEmoji ?? clPromptConfig . useEmoji ?? defaultConfig . useEmoji ,
37+ useEmoji : CZ_EMOJI ?? pkgConfig . useEmoji ?? clPromptConfig . useEmoji ?? defaultConfig . useEmoji ,
4838 scopes : pkgConfig . scopes ?? clPromptConfig . scopes ?? getEnumList ( clConfig ?. rules ?. [ "scope-enum" ] as any ) ,
4939 scopeOverrides : pkgConfig . scopeOverrides ?? clPromptConfig . scopeOverrides ?? defaultConfig . scopeOverrides ,
50- enableMultipleScopes : pkgConfig . enableMultipleScopes ?? clPromptConfig . enableMultipleScopes ?? defaultConfig . enableMultipleScopes ,
40+ enableMultipleScopes : CZ_CHECKBOX ?? pkgConfig . enableMultipleScopes ?? clPromptConfig . enableMultipleScopes ?? defaultConfig . enableMultipleScopes ,
5141 scopeEnumSeparator : pkgConfig . scopeEnumSeparator ?? clPromptConfig . scopeEnumSeparator ?? defaultConfig . scopeEnumSeparator ,
5242 allowCustomScopes : pkgConfig . allowCustomScopes ?? clPromptConfig . allowCustomScopes ?? ! enumRuleIsActive ( clConfig ?. rules ?. [ "scope-enum" ] as any ) ,
5343 allowEmptyScopes : pkgConfig . allowEmptyScopes ?? clPromptConfig . allowEmptyScopes ?? ! emptyRuleIsActive ( clConfig ?. rules ?. [ "scope-empty" ] as any ) ,
@@ -68,19 +58,13 @@ export const generateOptions = (clConfig: UserConfig): CommitizenGitOptions => {
6858 allowCustomIssuePrefixs : pkgConfig . allowCustomIssuePrefixs ?? clPromptConfig . allowCustomIssuePrefixs ?? defaultConfig . allowCustomIssuePrefixs ,
6959 allowEmptyIssuePrefixs : pkgConfig . allowEmptyIssuePrefixs ?? clPromptConfig . allowEmptyIssuePrefixs ?? defaultConfig . allowEmptyIssuePrefixs ,
7060 confirmColorize : pkgConfig . confirmColorize ?? clPromptConfig . confirmColorize ?? defaultConfig . confirmColorize ,
71- maxHeaderLength : CZ_MAN_HEADER_LENGTH
72- ? parseInt ( CZ_MAN_HEADER_LENGTH )
73- : clPromptConfig . maxHeaderLength ?? getMaxLength ( clConfig ?. rules ?. [ "header-max-length" ] as any ) ,
74- maxSubjectLength : CZ_MAN_SUBJECT_LENGTH
75- ? parseInt ( CZ_MAN_SUBJECT_LENGTH )
76- : clPromptConfig . maxSubjectLength ?? getMaxLength ( clConfig ?. rules ?. [ "subject-max-length" ] as any ) ,
77- minSubjectLength : CZ_MIN_SUBJECT_LENGTH
78- ? parseInt ( CZ_MIN_SUBJECT_LENGTH )
79- : clPromptConfig . minSubjectLength ?? getMinLength ( clConfig ?. rules ?. [ "subject-min-length" ] as any ) ,
80- defaultScope : CZ_SCOPE ?? clPromptConfig . defaultScope ?? defaultConfig . defaultScope ,
81- defaultSubject : CZ_SUBJECT ?? clPromptConfig . defaultSubject ?? defaultConfig . defaultSubject ,
82- defaultBody : CZ_BODY ?? clPromptConfig . defaultBody ?? defaultConfig . defaultBody ,
61+ maxHeaderLength : clPromptConfig . maxHeaderLength ?? getMaxLength ( clConfig ?. rules ?. [ "header-max-length" ] as any ) ,
62+ maxSubjectLength : clPromptConfig . maxSubjectLength ?? getMaxLength ( clConfig ?. rules ?. [ "subject-max-length" ] as any ) ,
63+ minSubjectLength : clPromptConfig . minSubjectLength ?? getMinLength ( clConfig ?. rules ?. [ "subject-min-length" ] as any ) ,
64+ defaultScope : clPromptConfig . defaultScope ?? defaultConfig . defaultScope ,
65+ defaultSubject : clPromptConfig . defaultSubject ?? defaultConfig . defaultSubject ,
66+ defaultBody : clPromptConfig . defaultBody ?? defaultConfig . defaultBody ,
8367 defaultFooterPrefix : clPromptConfig . defaultFooterPrefix ?? defaultConfig . defaultFooterPrefix ,
84- defaultIssues : CZ_ISSUES ?? clPromptConfig . defaultIssues ?? defaultConfig . defaultIssues
68+ defaultIssues : clPromptConfig . defaultIssues ?? defaultConfig . defaultIssues
8569 }
8670}
0 commit comments