Skip to content

Commit 867eb87

Browse files
authored
feat(cz-git,czg): add scopesSearchValue boolean option field #83 (#85)
* feat(cz-git): add `scopesSearchValue` boolean option field default scope list fuzzy search types `name` key of list. if choose `true` will search `value` key of list. @use If have long description of scope. can use it to enhanced search. @default: `false` BREAKING CHANGE: rename option `typesSearchValueKey` to `typesSearchValue` * Already processed for normal compatibility
1 parent febeba9 commit 867eb87

9 files changed

Lines changed: 48 additions & 21 deletions

File tree

‎.commitlintrc.cjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ module.exports = {
3838
'table:docs': 'docs: update project using table' + coAuthoredBy,
3939
},
4040
themeColorCode: '38;5;043',
41-
issuePrefixs: [
41+
issuePrefixes: [
4242
{ value: 'link', name: 'link: Work in processing to ISSUES' },
4343
{ value: 'closed', name: 'closed: ISSUES has been processed' },
4444
],

‎docs/.vitepress/config/en.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ export const enConfig: LocaleSpecificConfig<DefaultTheme.Config> = {
4040
head: [
4141
['meta', { name: 'twitter:description', content: descriptionEN }],
4242
['meta', { name: 'twitter:image', content: ogImg }],
43-
['meta', { name: 'og:description', content: descriptionEN }],
44-
['meta', { name: 'og:url', content: site }],
45-
['meta', { name: 'og:locale', content: 'en_US' }],
46-
['meta', { name: 'og:image', content: ogImg }],
43+
['meta', { property: 'og:description', content: descriptionEN }],
44+
['meta', { property: 'og:url', content: site }],
45+
['meta', { property: 'og:locale', content: 'en_US' }],
46+
['meta', { property: 'og:image', content: ogImg }],
4747
],
4848
}

‎docs/.vitepress/config/share.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export const shareConfig = defineConfig({
5151
['meta', { name: 'twitter:creator', content: '@zhengqbbb' }],
5252
['meta', { name: 'twitter:site', content: '@zhengqbbb' }],
5353
['meta', { name: 'twitter:card', content: 'summary_large_image' }],
54-
['meta', { name: 'og:type', content: 'article' }],
54+
['meta', { property: 'og:type', content: 'article' }],
5555
['meta', { name: 'application-name', content: name }],
5656
['meta', { name: 'apple-mobile-web-app-title', content: name }],
5757
['meta', { name: 'apple-mobile-web-app-status-bar-style', content: 'default' }],

‎docs/.vitepress/config/zh.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ export const zhConfig: LocaleSpecificConfig<DefaultTheme.Config> = {
4242
head: [
4343
['meta', { name: 'twitter:description', content: descriptionCN }],
4444
['meta', { name: 'twitter:image', content: ogImgCN }],
45-
['meta', { name: 'og:description', content: descriptionCN }],
46-
['meta', { name: 'og:url', content: siteCN }],
47-
['meta', { name: 'og:locale', content: 'zh_CN' }],
48-
['meta', { name: 'og:image', content: ogImgCN }],
45+
['meta', { property: 'og:description', content: descriptionCN }],
46+
['meta', { property: 'og:url', content: siteCN }],
47+
['meta', { property: 'og:locale', content: 'zh_CN' }],
48+
['meta', { property: 'og:image', content: ogImgCN }],
4949
],
5050
}

‎docs/config/show.md‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,18 @@ Try running command to **enable output emoji mode in the current session**
9494
}
9595
```
9696

97-
## typesSearchValueKey
97+
## typesSearchValue
9898

9999
- **description** : Default types list fuzzy search `value` key. Set `false` will search `name` key.
100100
- **type** : `boolean`
101101
- **default** : `true`
102102

103+
## scopesSearchValue
104+
105+
- **description** : Default `scopes` list fuzzy search `name` key. Set `true` will search `value` key.
106+
- **type** : `boolean`
107+
- **default** : `false`
108+
103109
## customScopesAlign
104110

105111
- **description** : Set the **location** of empty option (empty) and custom option (custom) in **selection range**

‎docs/zh/config/show.md‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,18 @@ export ___X_CMD_THEME_COLOR_CODE="38;5;043"
9696
}
9797
```
9898

99-
## typesSearchValueKey
99+
## typesSearchValue
100100

101-
- **描述** : 默认 `types` 列表的模糊搜索针对 `value` 字段。设置为 `false` 后针对 `name` 字段
101+
- **描述** : 默认 `types` 类别列表的模糊搜索针对列表 `value` 字段。设置为 `false` 后针对列表 `name` 字段
102102
- **类型** : `boolean`
103103
- **默认** : `true`
104104

105+
## scopesSearchValue
106+
107+
- **描述** : 默认 `scopes` 范围列表的模糊搜索针对列表 `name` 字段。设置为 `true` 后针对列表 `value` 字段
108+
- **类型** : `boolean`
109+
- **默认** : `false`
110+
105111
## customScopesAlign
106112

107113
- **描述** : 设置 **选择范围** 中 为空选项(empty) 和 自定义选项(custom) 的 **位置**

‎packages/cz-git/src/generator/option.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@ export const generateOptions = (config: UserConfig): CommitizenGitOptions => {
2525
themeColorCode: ___X_CMD_THEME_COLOR_CODE || promptConfig.themeColorCode || defaultConfig.themeColorCode,
2626
types: promptConfig.types ?? defaultConfig.types,
2727
typesAppend: promptConfig.typesAppend ?? defaultConfig.typesAppend,
28-
typesSearchValueKey: promptConfig.typesSearchValueKey ?? defaultConfig.typesSearchValueKey,
28+
typesSearchValue: promptConfig.typesSearchValueKey ?? promptConfig.typesSearchValue ?? defaultConfig.typesSearchValue,
2929
useEmoji: Boolean(emoji === '1') || promptConfig.useEmoji || defaultConfig.useEmoji,
3030
emojiAlign: promptConfig.emojiAlign || defaultConfig.emojiAlign,
3131
scopes: promptConfig.scopes ?? getEnumList(config?.rules?.['scope-enum'] as any),
32+
scopesSearchValue: promptConfig.scopesSearchValue ?? defaultConfig.scopesSearchValue,
3233
scopeOverrides: promptConfig.scopeOverrides ?? defaultConfig.scopeOverrides,
3334
scopeFilters: promptConfig.scopeFilters ?? defaultConfig.scopeFilters,
3435
enableMultipleScopes: Boolean(checkbox === '1') || promptConfig.enableMultipleScopes || defaultConfig.enableMultipleScopes,

‎packages/cz-git/src/generator/question.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export const generateQuestions = (options: CommitizenGitOptions, cz: any) => {
3939
options.types?.concat(options.typesAppend || []) || [],
4040
options.defaultType,
4141
)
42-
const searchTarget = options.typesSearchValueKey
42+
const searchTarget = options.typesSearchValue
4343
? 'value'
4444
: 'name'
4545
return fuzzyFilter(input, typeSource, searchTarget)
@@ -67,7 +67,10 @@ export const generateQuestions = (options: CommitizenGitOptions, cz: any) => {
6767
options.defaultScope as string,
6868
options.scopeFilters,
6969
)
70-
return fuzzyFilter(input, scopeSource)
70+
const searchTarget = options.scopesSearchValue
71+
? 'value'
72+
: 'name'
73+
return fuzzyFilter(input, scopeSource, searchTarget)
7174
},
7275
validate: (input: string | Array<string>) => {
7376
if (options.allowEmptyScopes)

‎packages/cz-git/src/shared/types/options.ts‎

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,13 @@ export interface CommitizenGitOptions {
188188
typesAppend?: TypesOption[]
189189

190190
/**
191-
* @description: default types list fuzzy search types `value` options.
192-
* if choose `false` will search `name` options
191+
* @description: default types list fuzzy search types `value` key of list.
192+
* if choose `false` will search `name` key of list
193193
* @use Using emoji unicode as `value` and that can't be searched
194194
* @default: true
195195
*/
196+
typesSearchValue?: boolean
197+
/** @deprecated Please use `typesSearchValue` field instead. */
196198
typesSearchValueKey?: boolean
197199

198200
/**
@@ -214,6 +216,14 @@ export interface CommitizenGitOptions {
214216
*/
215217
scopes?: ScopesType
216218

219+
/**
220+
* @description: default scope list fuzzy search types `name` key of list.
221+
* if choose `true` will search `value` key of list.
222+
* @use If have long description of scope. can use it to enhanced search.
223+
* @default: false
224+
*/
225+
scopesSearchValue?: boolean
226+
217227
/**
218228
* @description: Provides an overriding select of prompt to select module scopes under specific type
219229
* @note use this option should set `scopes` option to realize distinguish
@@ -490,11 +500,14 @@ export const defaultConfig = Object.freeze({
490500
{ value: 'revert', name: 'revert: Reverts a previous commit', emoji: ':rewind:' },
491501
],
492502
typesAppend: [],
493-
typesSearchValueKey: true,
503+
typesSearchValue: true,
494504
themeColorCode: '',
495505
useEmoji: false,
496506
emojiAlign: 'center',
497507
scopes: [],
508+
scopesSearchValue: false,
509+
scopeOverrides: undefined,
510+
scopeFilters: ['.DS_Store'],
498511
enableMultipleScopes: false,
499512
scopeEnumSeparator: ',',
500513
allowCustomScopes: true,
@@ -519,8 +532,6 @@ export const defaultConfig = Object.freeze({
519532
maxSubjectLength: Infinity,
520533
isIgnoreCheckMaxSubjectLength: false,
521534
minSubjectLength: 0,
522-
scopeOverrides: undefined,
523-
scopeFilters: ['.DS_Store'],
524535
defaultType: '',
525536
defaultScope: '',
526537
defaultBody: '',

0 commit comments

Comments
 (0)