提交 | 用户 | age
|
9c26ee
|
1 |
const fs = require('fs'); |
Z |
2 |
const path = require('path'); |
|
3 |
const { execSync } = require('child_process'); |
|
4 |
|
|
5 |
const scopes = fs |
|
6 |
.readdirSync(path.resolve(__dirname, 'src'), { withFileTypes: true }) |
|
7 |
.filter((dirent) => dirent.isDirectory()) |
|
8 |
.map((dirent) => dirent.name.replace(/s$/, '')); |
|
9 |
|
|
10 |
// precomputed scope |
|
11 |
const scopeComplete = execSync('git status --porcelain || true') |
|
12 |
.toString() |
|
13 |
.trim() |
|
14 |
.split('\n') |
|
15 |
.find((r) => ~r.indexOf('M src')) |
|
16 |
?.replace(/(\/)/g, '%%') |
|
17 |
?.match(/src%%((\w|-)*)/)?.[1] |
|
18 |
?.replace(/s$/, ''); |
|
19 |
|
|
20 |
/** @type {import('cz-git').UserConfig} */ |
2f6253
|
21 |
module.exports = { |
陈 |
22 |
ignores: [(commit) => commit.includes('init')], |
|
23 |
extends: ['@commitlint/config-conventional'], |
|
24 |
rules: { |
|
25 |
'body-leading-blank': [2, 'always'], |
|
26 |
'footer-leading-blank': [1, 'always'], |
|
27 |
'header-max-length': [2, 'always', 108], |
|
28 |
'subject-empty': [2, 'never'], |
|
29 |
'type-empty': [2, 'never'], |
ed40b3
|
30 |
'subject-case': [0], |
2f6253
|
31 |
'type-enum': [ |
陈 |
32 |
2, |
|
33 |
'always', |
|
34 |
[ |
|
35 |
'feat', |
|
36 |
'fix', |
|
37 |
'perf', |
|
38 |
'style', |
|
39 |
'docs', |
|
40 |
'test', |
|
41 |
'refactor', |
|
42 |
'build', |
|
43 |
'ci', |
|
44 |
'chore', |
|
45 |
'revert', |
|
46 |
'wip', |
|
47 |
'workflow', |
ad3688
|
48 |
'types', |
e09068
|
49 |
'release', |
2f6253
|
50 |
], |
陈 |
51 |
], |
|
52 |
}, |
9c26ee
|
53 |
prompt: { |
895dab
|
54 |
/** @use `pnpm commit :f` */ |
9c26ee
|
55 |
alias: { |
Z |
56 |
f: 'docs: fix typos', |
|
57 |
r: 'docs: update README', |
|
58 |
s: 'style: update code format', |
|
59 |
b: 'build: bump dependencies', |
|
60 |
c: 'chore: update config', |
|
61 |
}, |
|
62 |
customScopesAlign: !scopeComplete ? 'top' : 'bottom', |
|
63 |
defaultScope: scopeComplete, |
|
64 |
scopes: [...scopes, 'mock'], |
|
65 |
allowEmptyIssuePrefixs: false, |
|
66 |
allowCustomIssuePrefixs: false, |
|
67 |
|
|
68 |
// English |
|
69 |
typesAppend: [ |
|
70 |
{ value: 'wip', name: 'wip: work in process' }, |
|
71 |
{ value: 'workflow', name: 'workflow: workflow improvements' }, |
|
72 |
{ value: 'types', name: 'types: type definition file changes' }, |
|
73 |
], |
|
74 |
|
|
75 |
// 中英文对照版 |
|
76 |
// messages: { |
|
77 |
// type: '选择你要提交的类型 :', |
|
78 |
// scope: '选择一个提交范围 (可选):', |
|
79 |
// customScope: '请输入自定义的提交范围 :', |
|
80 |
// subject: '填写简短精炼的变更描述 :\n', |
|
81 |
// body: '填写更加详细的变更描述 (可选)。使用 "|" 换行 :\n', |
|
82 |
// breaking: '列举非兼容性重大的变更 (可选)。使用 "|" 换行 :\n', |
|
83 |
// footerPrefixsSelect: '选择关联issue前缀 (可选):', |
|
84 |
// customFooterPrefixs: '输入自定义issue前缀 :', |
|
85 |
// footer: '列举关联issue (可选) 例如: #31, #I3244 :\n', |
|
86 |
// confirmCommit: '是否提交或修改commit ?', |
|
87 |
// }, |
|
88 |
// types: [ |
|
89 |
// { value: 'feat', name: 'feat: 新增功能' }, |
|
90 |
// { value: 'fix', name: 'fix: 修复缺陷' }, |
|
91 |
// { value: 'docs', name: 'docs: 文档变更' }, |
|
92 |
// { value: 'style', name: 'style: 代码格式' }, |
|
93 |
// { value: 'refactor', name: 'refactor: 代码重构' }, |
|
94 |
// { value: 'perf', name: 'perf: 性能优化' }, |
|
95 |
// { value: 'test', name: 'test: 添加疏漏测试或已有测试改动' }, |
|
96 |
// { value: 'build', name: 'build: 构建流程、外部依赖变更 (如升级 npm 包、修改打包配置等)' }, |
|
97 |
// { value: 'ci', name: 'ci: 修改 CI 配置、脚本' }, |
|
98 |
// { value: 'revert', name: 'revert: 回滚 commit' }, |
|
99 |
// { value: 'chore', name: 'chore: 对构建过程或辅助工具和库的更改 (不影响源文件、测试用例)' }, |
|
100 |
// { value: 'wip', name: 'wip: 正在开发中' }, |
|
101 |
// { value: 'workflow', name: 'workflow: 工作流程改进' }, |
|
102 |
// { value: 'types', name: 'types: 类型定义文件修改' }, |
|
103 |
// ], |
|
104 |
// emptyScopesAlias: 'empty: 不填写', |
|
105 |
// customScopesAlias: 'custom: 自定义', |
|
106 |
}, |
2f6253
|
107 |
}; |