@icebreakers/commitlint-config 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +67 -0
- package/dist/index.cjs +166 -332
- package/dist/index.d.cts +25 -57
- package/dist/index.d.ts +25 -57
- package/dist/index.mjs +167 -333
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# @icebreakers/commitlint-config
|
|
2
|
+
|
|
3
|
+
`@icebreakers/commitlint-config` 是一个基于 `@commitlint/config-conventional` 的可配置 preset。我们在保留社区标准的基础上,提供了一套函数式 API,方便团队按需扩展类型、Scope、Subject 等规则,并同步更新 commit prompt 元数据。
|
|
4
|
+
|
|
5
|
+
## 快速开始
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add -D @icebreakers/commitlint-config
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
### 使用默认配置
|
|
12
|
+
|
|
13
|
+
`commitlint.config.ts`
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { icebreaker } from '@icebreakers/commitlint-config'
|
|
17
|
+
|
|
18
|
+
export default icebreaker()
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### 自定义选项
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
import { icebreaker, RuleConfigSeverity } from '@icebreakers/commitlint-config'
|
|
25
|
+
|
|
26
|
+
export default icebreaker({
|
|
27
|
+
types: {
|
|
28
|
+
definitions: [
|
|
29
|
+
{
|
|
30
|
+
value: 'deps',
|
|
31
|
+
title: 'Dependencies',
|
|
32
|
+
description: '依赖升级',
|
|
33
|
+
emoji: '📦',
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
scopes: {
|
|
38
|
+
values: ['core', 'docs'],
|
|
39
|
+
required: true,
|
|
40
|
+
},
|
|
41
|
+
subject: {
|
|
42
|
+
forbidden: ['sentence-case', 'start-case'],
|
|
43
|
+
caseSeverity: RuleConfigSeverity.Warning,
|
|
44
|
+
},
|
|
45
|
+
header: {
|
|
46
|
+
maxLength: 100,
|
|
47
|
+
},
|
|
48
|
+
})
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## 导出的工具
|
|
52
|
+
|
|
53
|
+
- `icebreaker(options?)`: 推荐使用的工厂函数,合并默认规则与自定义规则。
|
|
54
|
+
- `createIcebreakerCommitlintConfig(options?)`: 与 `icebreaker` 等效的底层函数,便于需要显式命名的场景。
|
|
55
|
+
- `RuleConfigSeverity`: Enum,用于声明 commitlint 规则的严重级别。
|
|
56
|
+
- `CommitTypesOptions`、`CommitScopeOptions`、`CommitSubjectOptions`、`CommitHeaderOptions`: 细粒度配置类型。
|
|
57
|
+
- `CommitlintUserConfig`: 对应 commitlint 的最终配置类型。
|
|
58
|
+
|
|
59
|
+
## 测试
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
pnpm --filter @icebreakers/commitlint-config test
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## 许可证
|
|
66
|
+
|
|
67
|
+
MIT License。
|
package/dist/index.cjs
CHANGED
|
@@ -1,112 +1,23 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/
|
|
2
|
-
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/builders.ts
|
|
2
|
+
var _configconventional = require('@commitlint/config-conventional'); var _configconventional2 = _interopRequireDefault(_configconventional);
|
|
3
3
|
|
|
4
|
+
// src/types.ts
|
|
4
5
|
var _types = require('@commitlint/types');
|
|
5
6
|
|
|
6
|
-
// src/constants.ts
|
|
7
|
-
var DEFAULT_PARSER_PRESET = "conventional-changelog-conventionalcommits";
|
|
8
|
-
var DEFAULT_HEADER_MAX_LENGTH = 100;
|
|
9
|
-
var DEFAULT_BODY_MAX_LINE_LENGTH = 100;
|
|
10
|
-
var DEFAULT_FOOTER_MAX_LINE_LENGTH = 100;
|
|
11
|
-
var DEFAULT_FULL_STOP = ".";
|
|
12
|
-
var DEFAULT_SUBJECT_FORBIDDEN_CASES = [
|
|
13
|
-
"sentence-case",
|
|
14
|
-
"start-case",
|
|
15
|
-
"pascal-case",
|
|
16
|
-
"upper-case"
|
|
17
|
-
];
|
|
18
|
-
var DEFAULT_COMMIT_TYPES = [
|
|
19
|
-
{
|
|
20
|
-
value: "build",
|
|
21
|
-
title: "Builds",
|
|
22
|
-
description: "Changes that affect the build system or external dependencies (example scopes: pnpm, webpack, docker)",
|
|
23
|
-
emoji: "\u{1F6E0}"
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
value: "chore",
|
|
27
|
-
title: "Chores",
|
|
28
|
-
description: "Other changes that don't modify src or test files",
|
|
29
|
-
emoji: "\u267B\uFE0F"
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
value: "ci",
|
|
33
|
-
title: "Continuous Integrations",
|
|
34
|
-
description: "Changes to our CI configuration files and scripts (example scopes: GitHub Actions, Travis, Circle)",
|
|
35
|
-
emoji: "\u2699\uFE0F"
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
value: "docs",
|
|
39
|
-
title: "Documentation",
|
|
40
|
-
description: "Documentation only changes",
|
|
41
|
-
emoji: "\u{1F4DA}"
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
value: "feat",
|
|
45
|
-
title: "Features",
|
|
46
|
-
description: "A new feature",
|
|
47
|
-
emoji: "\u2728"
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
value: "fix",
|
|
51
|
-
title: "Bug Fixes",
|
|
52
|
-
description: "A bug fix",
|
|
53
|
-
emoji: "\u{1F41B}"
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
value: "perf",
|
|
57
|
-
title: "Performance Improvements",
|
|
58
|
-
description: "A code change that improves performance",
|
|
59
|
-
emoji: "\u{1F680}"
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
value: "refactor",
|
|
63
|
-
title: "Code Refactoring",
|
|
64
|
-
description: "A code change that neither fixes a bug nor adds a feature",
|
|
65
|
-
emoji: "\u{1F4E6}"
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
value: "revert",
|
|
69
|
-
title: "Reverts",
|
|
70
|
-
description: "Reverts a previous commit",
|
|
71
|
-
emoji: "\u{1F5D1}"
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
value: "style",
|
|
75
|
-
title: "Styles",
|
|
76
|
-
description: "Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)",
|
|
77
|
-
emoji: "\u{1F48E}"
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
value: "test",
|
|
81
|
-
title: "Tests",
|
|
82
|
-
description: "Adding missing tests or correcting existing tests",
|
|
83
|
-
emoji: "\u{1F6A8}"
|
|
84
|
-
}
|
|
85
|
-
];
|
|
86
|
-
var DEFAULT_TYPES = DEFAULT_COMMIT_TYPES.map((type) => type.value);
|
|
87
|
-
var DEFAULT_PROMPT_SCOPE_DESCRIPTION = "What is the scope of this change (e.g. component or file name)";
|
|
88
|
-
var DEFAULT_PROMPT_TYPE_DESCRIPTION = "Select the type of change that you're committing";
|
|
89
|
-
var DEFAULT_PROMPT_SUBJECT_DESCRIPTION = "Write a short, imperative tense description of the change";
|
|
90
|
-
var DEFAULT_PROMPT_BODY_DESCRIPTION = "Provide a longer description of the change";
|
|
91
|
-
var DEFAULT_PROMPT_IS_BREAKING_DESCRIPTION = "Are there any breaking changes?";
|
|
92
|
-
var DEFAULT_PROMPT_BREAKING_BODY_DESCRIPTION = "A BREAKING CHANGE commit requires a body. Please enter a longer description of the commit itself";
|
|
93
|
-
var DEFAULT_PROMPT_BREAKING_DESCRIPTION = "Describe the breaking changes";
|
|
94
|
-
var DEFAULT_PROMPT_IS_ISSUE_AFFECTED_DESCRIPTION = "Does this change affect any open issues?";
|
|
95
|
-
var DEFAULT_PROMPT_ISSUES_BODY_DESCRIPTION = "If issues are closed, the commit requires a body. Please enter a longer description of the commit itself";
|
|
96
|
-
var DEFAULT_PROMPT_ISSUES_DESCRIPTION = 'Add issue references (e.g. "fix #123", "re #123".)';
|
|
97
|
-
var DEFAULT_EXTENDS = ["@commitlint/config-conventional"];
|
|
98
|
-
|
|
99
7
|
// src/utils.ts
|
|
100
|
-
function
|
|
8
|
+
function asArray(value) {
|
|
101
9
|
if (value === void 0) {
|
|
102
10
|
return [];
|
|
103
11
|
}
|
|
104
12
|
return Array.isArray(value) ? value : [value];
|
|
105
13
|
}
|
|
106
|
-
function
|
|
14
|
+
function mergeUnique(values) {
|
|
107
15
|
const seen = /* @__PURE__ */ new Set();
|
|
108
16
|
const result = [];
|
|
109
17
|
for (const value of values) {
|
|
18
|
+
if (value === void 0 || value === null) {
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
110
21
|
if (!seen.has(value)) {
|
|
111
22
|
seen.add(value);
|
|
112
23
|
result.push(value);
|
|
@@ -114,266 +25,196 @@ function unique(values) {
|
|
|
114
25
|
}
|
|
115
26
|
return result;
|
|
116
27
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
28
|
+
|
|
29
|
+
// src/builders.ts
|
|
30
|
+
function resolveBaseTypeRule() {
|
|
31
|
+
const rule = _optionalChain([_configconventional2.default, 'access', _ => _.rules, 'optionalAccess', _2 => _2["type-enum"]]);
|
|
32
|
+
if (Array.isArray(rule)) {
|
|
33
|
+
const severity = _nullishCoalesce(rule[0], () => ( _types.RuleConfigSeverity.Error));
|
|
34
|
+
const condition = _nullishCoalesce(rule[1], () => ( "always"));
|
|
35
|
+
const values = _nullishCoalesce(rule[2], () => ( []));
|
|
36
|
+
return {
|
|
37
|
+
severity,
|
|
38
|
+
condition,
|
|
39
|
+
values: [...values]
|
|
40
|
+
};
|
|
41
|
+
}
|
|
121
42
|
return {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
43
|
+
severity: _types.RuleConfigSeverity.Error,
|
|
44
|
+
condition: "always",
|
|
45
|
+
values: []
|
|
125
46
|
};
|
|
126
47
|
}
|
|
127
|
-
function
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
map.set(definition.value, definition);
|
|
131
|
-
}
|
|
132
|
-
for (const definition of overrides) {
|
|
133
|
-
map.set(definition.value, definition);
|
|
48
|
+
function buildTypesConfig(options) {
|
|
49
|
+
if (!options) {
|
|
50
|
+
return {};
|
|
134
51
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
);
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
52
|
+
const baseRule = resolveBaseTypeRule();
|
|
53
|
+
const additional = mergeUnique([
|
|
54
|
+
...baseRule.values,
|
|
55
|
+
...mergeUnique(_nullishCoalesce(options.add, () => ( []))),
|
|
56
|
+
...mergeUnique((_nullishCoalesce(options.definitions, () => ( []))).map((definition) => definition.value))
|
|
57
|
+
]);
|
|
58
|
+
let rule;
|
|
59
|
+
if (additional.length > 0) {
|
|
60
|
+
rule = [
|
|
61
|
+
_nullishCoalesce(options.severity, () => ( baseRule.severity)),
|
|
62
|
+
_nullishCoalesce(options.condition, () => ( baseRule.condition)),
|
|
63
|
+
additional
|
|
64
|
+
];
|
|
65
|
+
}
|
|
66
|
+
if (!_optionalChain([options, 'access', _3 => _3.definitions, 'optionalAccess', _4 => _4.length])) {
|
|
67
|
+
return { rule };
|
|
68
|
+
}
|
|
69
|
+
const basePromptType = _optionalChain([_configconventional2.default, 'access', _5 => _5.prompt, 'optionalAccess', _6 => _6.questions, 'optionalAccess', _7 => _7.type]);
|
|
70
|
+
const mergedEnum = {
|
|
71
|
+
..._nullishCoalesce(_optionalChain([basePromptType, 'optionalAccess', _8 => _8.enum]), () => ( {}))
|
|
72
|
+
};
|
|
73
|
+
for (const definition of options.definitions) {
|
|
74
|
+
const { value, title, description, emoji } = definition;
|
|
75
|
+
mergedEnum[value] = {
|
|
76
|
+
..._nullishCoalesce(mergedEnum[value], () => ( {})),
|
|
77
|
+
title,
|
|
78
|
+
description,
|
|
79
|
+
emoji
|
|
80
|
+
};
|
|
145
81
|
}
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
continue;
|
|
155
|
-
}
|
|
156
|
-
if (Array.isArray(value)) {
|
|
157
|
-
output[key] = [...value];
|
|
158
|
-
continue;
|
|
82
|
+
const prompt = {
|
|
83
|
+
..._nullishCoalesce(_configconventional2.default.prompt, () => ( {})),
|
|
84
|
+
questions: {
|
|
85
|
+
..._nullishCoalesce(_optionalChain([_configconventional2.default, 'access', _9 => _9.prompt, 'optionalAccess', _10 => _10.questions]), () => ( {})),
|
|
86
|
+
type: {
|
|
87
|
+
..._nullishCoalesce(basePromptType, () => ( {})),
|
|
88
|
+
enum: mergedEnum
|
|
89
|
+
}
|
|
159
90
|
}
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
return output;
|
|
163
|
-
}
|
|
164
|
-
function removeUndefined(value) {
|
|
165
|
-
const entries = Object.entries(value).filter(([, item]) => item !== void 0);
|
|
166
|
-
return Object.fromEntries(entries);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
// src/config.ts
|
|
170
|
-
function resolveExtends(entries) {
|
|
171
|
-
if (!entries) {
|
|
172
|
-
return [...DEFAULT_EXTENDS];
|
|
173
|
-
}
|
|
174
|
-
const values = toArray(entries);
|
|
175
|
-
return unique([...DEFAULT_EXTENDS, ...values]);
|
|
91
|
+
};
|
|
92
|
+
return { rule, prompt };
|
|
176
93
|
}
|
|
177
|
-
function
|
|
178
|
-
let severity = _types.RuleConfigSeverity.Error;
|
|
179
|
-
let condition = "always";
|
|
180
|
-
let overrides = [];
|
|
181
|
-
let values;
|
|
94
|
+
function buildScopeRules(options) {
|
|
182
95
|
if (!options) {
|
|
183
|
-
|
|
184
|
-
} else if (Array.isArray(options)) {
|
|
185
|
-
values = unique(options);
|
|
186
|
-
} else {
|
|
187
|
-
severity = _nullishCoalesce(options.severity, () => ( severity));
|
|
188
|
-
condition = _nullishCoalesce(options.condition, () => ( condition));
|
|
189
|
-
overrides = _nullishCoalesce(options.definitions, () => ( []));
|
|
190
|
-
const base = options.values ? toArray(options.values) : DEFAULT_TYPES;
|
|
191
|
-
const additions = options.add ? toArray(options.add) : [];
|
|
192
|
-
values = unique([...base, ...additions]);
|
|
96
|
+
return {};
|
|
193
97
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
98
|
+
const rules = {};
|
|
99
|
+
const severity = _nullishCoalesce(options.severity, () => ( _types.RuleConfigSeverity.Error));
|
|
100
|
+
const scopeValues = mergeUnique(asArray(options.values));
|
|
101
|
+
if (scopeValues.length > 0) {
|
|
102
|
+
rules["scope-enum"] = [severity, "always", scopeValues];
|
|
103
|
+
}
|
|
104
|
+
if (options.required !== void 0) {
|
|
105
|
+
if (options.required) {
|
|
106
|
+
rules["scope-empty"] = [severity, "never"];
|
|
107
|
+
} else {
|
|
108
|
+
rules["scope-empty"] = [_types.RuleConfigSeverity.Disabled];
|
|
109
|
+
}
|
|
199
110
|
}
|
|
200
|
-
const
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
);
|
|
204
|
-
return {
|
|
205
|
-
definitions,
|
|
206
|
-
rule: [severity, condition, values]
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
function asCaseArray(value) {
|
|
210
|
-
if (!value) {
|
|
211
|
-
return [];
|
|
111
|
+
const scopeCases = mergeUnique(asArray(options.case));
|
|
112
|
+
if (scopeCases.length > 0) {
|
|
113
|
+
rules["scope-case"] = [severity, "always", scopeCases];
|
|
212
114
|
}
|
|
213
|
-
return
|
|
115
|
+
return rules;
|
|
214
116
|
}
|
|
215
|
-
function
|
|
117
|
+
function buildSubjectRules(options) {
|
|
216
118
|
if (!options) {
|
|
217
119
|
return {};
|
|
218
120
|
}
|
|
219
121
|
const rules = {};
|
|
220
|
-
const
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
122
|
+
const forbiddenCases = mergeUnique(asArray(options.forbidden));
|
|
123
|
+
if (forbiddenCases.length > 0) {
|
|
124
|
+
rules["subject-case"] = [
|
|
125
|
+
_nullishCoalesce(options.caseSeverity, () => ( _types.RuleConfigSeverity.Error)),
|
|
126
|
+
_nullishCoalesce(options.caseCondition, () => ( "never")),
|
|
127
|
+
forbiddenCases
|
|
128
|
+
];
|
|
129
|
+
}
|
|
130
|
+
if (options.allowEmpty !== void 0) {
|
|
131
|
+
if (options.allowEmpty) {
|
|
132
|
+
rules["subject-empty"] = [_types.RuleConfigSeverity.Disabled];
|
|
133
|
+
} else {
|
|
134
|
+
rules["subject-empty"] = [
|
|
135
|
+
_nullishCoalesce(options.allowEmptySeverity, () => ( _types.RuleConfigSeverity.Error)),
|
|
136
|
+
"never"
|
|
137
|
+
];
|
|
138
|
+
}
|
|
233
139
|
}
|
|
234
|
-
if (
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
140
|
+
if (options.fullStop !== void 0) {
|
|
141
|
+
if (options.fullStop) {
|
|
142
|
+
rules["subject-full-stop"] = [
|
|
143
|
+
_nullishCoalesce(options.fullStopSeverity, () => ( _types.RuleConfigSeverity.Error)),
|
|
144
|
+
"always",
|
|
145
|
+
_nullishCoalesce(options.fullStopCharacter, () => ( "."))
|
|
146
|
+
];
|
|
147
|
+
} else {
|
|
148
|
+
rules["subject-full-stop"] = [_types.RuleConfigSeverity.Disabled];
|
|
239
149
|
}
|
|
240
150
|
}
|
|
241
151
|
return rules;
|
|
242
152
|
}
|
|
243
|
-
function
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
const subjectCases = forbiddenCases.length > 0 ? forbiddenCases : DEFAULT_SUBJECT_FORBIDDEN_CASES;
|
|
247
|
-
const caseSeverity = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _2 => _2.caseSeverity]), () => ( _types.RuleConfigSeverity.Error));
|
|
248
|
-
rules["subject-case"] = [caseSeverity, "never", subjectCases];
|
|
249
|
-
if (_optionalChain([options, 'optionalAccess', _3 => _3.allowEmpty])) {
|
|
250
|
-
rules["subject-empty"] = [_types.RuleConfigSeverity.Disabled];
|
|
251
|
-
} else {
|
|
252
|
-
const emptySeverity = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _4 => _4.emptySeverity]), () => ( _types.RuleConfigSeverity.Error));
|
|
253
|
-
rules["subject-empty"] = [emptySeverity, "never"];
|
|
153
|
+
function buildHeaderRules(options) {
|
|
154
|
+
if (!options) {
|
|
155
|
+
return {};
|
|
254
156
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
rules["subject-full-stop"] = [fullStopSeverity, "never", fullStop];
|
|
157
|
+
const rules = {};
|
|
158
|
+
const severity = _nullishCoalesce(options.severity, () => ( _types.RuleConfigSeverity.Error));
|
|
159
|
+
const condition = _nullishCoalesce(options.condition, () => ( "always"));
|
|
160
|
+
if (options.maxLength !== void 0) {
|
|
161
|
+
rules["header-max-length"] = [severity, condition, options.maxLength];
|
|
261
162
|
}
|
|
262
163
|
return rules;
|
|
263
164
|
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
"footer-max-line-length": [
|
|
281
|
-
_types.RuleConfigSeverity.Error,
|
|
282
|
-
"always",
|
|
283
|
-
DEFAULT_FOOTER_MAX_LINE_LENGTH
|
|
284
|
-
],
|
|
285
|
-
"header-trim": [_types.RuleConfigSeverity.Error, "always"],
|
|
286
|
-
"type-case": [_types.RuleConfigSeverity.Error, "always", "lower-case"],
|
|
287
|
-
"type-empty": [_types.RuleConfigSeverity.Error, "never"]
|
|
288
|
-
};
|
|
289
|
-
}
|
|
290
|
-
function buildTypeEnum(definitions) {
|
|
291
|
-
return definitions.reduce(
|
|
292
|
-
(accumulator, definition) => {
|
|
293
|
-
accumulator[definition.value] = {
|
|
294
|
-
description: definition.description,
|
|
295
|
-
title: definition.title,
|
|
296
|
-
emoji: definition.emoji
|
|
297
|
-
};
|
|
298
|
-
return accumulator;
|
|
299
|
-
},
|
|
300
|
-
{}
|
|
301
|
-
);
|
|
302
|
-
}
|
|
303
|
-
function createBasePrompt(definitions) {
|
|
165
|
+
|
|
166
|
+
// src/constants.ts
|
|
167
|
+
var DEFAULT_EXTENDS = ["@commitlint/config-conventional"];
|
|
168
|
+
var DEFAULT_PARSER_PRESET = "conventional-changelog-conventionalcommits";
|
|
169
|
+
|
|
170
|
+
// src/prompt.ts
|
|
171
|
+
function mergePrompts(base, override) {
|
|
172
|
+
if (!base && !override) {
|
|
173
|
+
return void 0;
|
|
174
|
+
}
|
|
175
|
+
if (!base) {
|
|
176
|
+
return override;
|
|
177
|
+
}
|
|
178
|
+
if (!override) {
|
|
179
|
+
return base;
|
|
180
|
+
}
|
|
304
181
|
return {
|
|
182
|
+
...base,
|
|
183
|
+
...override,
|
|
305
184
|
questions: {
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
enum: buildTypeEnum(definitions)
|
|
309
|
-
},
|
|
310
|
-
scope: {
|
|
311
|
-
description: DEFAULT_PROMPT_SCOPE_DESCRIPTION
|
|
312
|
-
},
|
|
313
|
-
subject: {
|
|
314
|
-
description: DEFAULT_PROMPT_SUBJECT_DESCRIPTION
|
|
315
|
-
},
|
|
316
|
-
body: {
|
|
317
|
-
description: DEFAULT_PROMPT_BODY_DESCRIPTION
|
|
318
|
-
},
|
|
319
|
-
isBreaking: {
|
|
320
|
-
description: DEFAULT_PROMPT_IS_BREAKING_DESCRIPTION
|
|
321
|
-
},
|
|
322
|
-
breakingBody: {
|
|
323
|
-
description: DEFAULT_PROMPT_BREAKING_BODY_DESCRIPTION
|
|
324
|
-
},
|
|
325
|
-
breaking: {
|
|
326
|
-
description: DEFAULT_PROMPT_BREAKING_DESCRIPTION
|
|
327
|
-
},
|
|
328
|
-
isIssueAffected: {
|
|
329
|
-
description: DEFAULT_PROMPT_IS_ISSUE_AFFECTED_DESCRIPTION
|
|
330
|
-
},
|
|
331
|
-
issuesBody: {
|
|
332
|
-
description: DEFAULT_PROMPT_ISSUES_BODY_DESCRIPTION
|
|
333
|
-
},
|
|
334
|
-
issues: {
|
|
335
|
-
description: DEFAULT_PROMPT_ISSUES_DESCRIPTION
|
|
336
|
-
}
|
|
185
|
+
..._nullishCoalesce(base.questions, () => ( {})),
|
|
186
|
+
..._nullishCoalesce(override.questions, () => ( {}))
|
|
337
187
|
}
|
|
338
188
|
};
|
|
339
189
|
}
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
return mergeDeep(base, overrides);
|
|
343
|
-
}
|
|
190
|
+
|
|
191
|
+
// src/index.ts
|
|
344
192
|
function createIcebreakerCommitlintConfig(options = {}) {
|
|
345
|
-
const
|
|
346
|
-
const
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
const baseRules = createBaseRules();
|
|
193
|
+
const { types, scopes, subject, header } = options;
|
|
194
|
+
const extendsList = mergeUnique([
|
|
195
|
+
...DEFAULT_EXTENDS,
|
|
196
|
+
...mergeUnique(_nullishCoalesce(options.extends, () => ( [])))
|
|
197
|
+
]);
|
|
351
198
|
const rules = {
|
|
352
|
-
...
|
|
353
|
-
|
|
354
|
-
...
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
199
|
+
...buildScopeRules(scopes),
|
|
200
|
+
...buildSubjectRules(subject),
|
|
201
|
+
...buildHeaderRules(header)
|
|
202
|
+
};
|
|
203
|
+
const typesConfig = buildTypesConfig(types);
|
|
204
|
+
if (typesConfig.rule) {
|
|
205
|
+
rules["type-enum"] = typesConfig.rule;
|
|
206
|
+
}
|
|
207
|
+
const mergedRules = {
|
|
208
|
+
...rules,
|
|
209
|
+
..._nullishCoalesce(options.rules, () => ( {}))
|
|
210
|
+
};
|
|
211
|
+
const prompt = mergePrompts(typesConfig.prompt, options.prompt);
|
|
212
|
+
return {
|
|
213
|
+
extends: extendsList,
|
|
214
|
+
parserPreset: DEFAULT_PARSER_PRESET,
|
|
215
|
+
...Object.keys(mergedRules).length > 0 ? { rules: mergedRules } : {},
|
|
216
|
+
...prompt ? { prompt } : {}
|
|
358
217
|
};
|
|
359
|
-
const prompt = resolvePrompt(typeSettings.definitions, options.prompt);
|
|
360
|
-
return removeUndefined({
|
|
361
|
-
extends: extendsField,
|
|
362
|
-
formatter: options.formatter,
|
|
363
|
-
parserPreset: _nullishCoalesce(options.parserPreset, () => ( DEFAULT_PARSER_PRESET)),
|
|
364
|
-
rules,
|
|
365
|
-
ignores: options.ignores,
|
|
366
|
-
defaultIgnores: options.defaultIgnores,
|
|
367
|
-
plugins: options.plugins,
|
|
368
|
-
helpUrl: options.helpUrl,
|
|
369
|
-
prompt
|
|
370
|
-
});
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
// src/index.ts
|
|
374
|
-
|
|
375
|
-
function createCommitlintConfig(options) {
|
|
376
|
-
return createIcebreakerCommitlintConfig(options);
|
|
377
218
|
}
|
|
378
219
|
function icebreaker(options) {
|
|
379
220
|
return createIcebreakerCommitlintConfig(options);
|
|
@@ -382,11 +223,4 @@ function icebreaker(options) {
|
|
|
382
223
|
|
|
383
224
|
|
|
384
225
|
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
exports.DEFAULT_COMMIT_TYPES = DEFAULT_COMMIT_TYPES; exports.DEFAULT_EXTENDS = DEFAULT_EXTENDS; exports.DEFAULT_SUBJECT_FORBIDDEN_CASES = DEFAULT_SUBJECT_FORBIDDEN_CASES; exports.DEFAULT_TYPES = DEFAULT_TYPES; exports.RuleConfigCondition = _types.RuleConfigCondition; exports.RuleConfigSeverity = _types.RuleConfigSeverity; exports.TargetCaseType = _types.TargetCaseType; exports.createCommitlintConfig = createCommitlintConfig; exports.createIcebreakerCommitlintConfig = createIcebreakerCommitlintConfig; exports.icebreaker = icebreaker;
|
|
226
|
+
exports.RuleConfigSeverity = _types.RuleConfigSeverity; exports.createIcebreakerCommitlintConfig = createIcebreakerCommitlintConfig; exports.icebreaker = icebreaker;
|