@icebreakers/commitlint-config 1.2.10 → 1.2.12
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/dist/index.cjs +184 -217
- package/dist/index.d.cts +38 -37
- package/dist/index.d.ts +38 -37
- package/dist/index.js +178 -0
- package/package.json +15 -8
- package/dist/index.mjs +0 -237
package/dist/index.cjs
CHANGED
|
@@ -1,237 +1,204 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
|
+
get: ((k) => from[k]).bind(null, key),
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
20
|
+
value: mod,
|
|
21
|
+
enumerable: true
|
|
22
|
+
}) : target, mod));
|
|
23
|
+
//#endregion
|
|
24
|
+
let _commitlint_config_conventional = require("@commitlint/config-conventional");
|
|
25
|
+
_commitlint_config_conventional = __toESM(_commitlint_config_conventional);
|
|
26
|
+
let _commitlint_types = require("@commitlint/types");
|
|
27
|
+
//#region src/utils.ts
|
|
11
28
|
function asArray(value) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
return Array.isArray(value) ? value : [value];
|
|
29
|
+
if (value === void 0) return [];
|
|
30
|
+
return Array.isArray(value) ? value : [value];
|
|
16
31
|
}
|
|
17
32
|
function mergeUnique(values) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
return result;
|
|
33
|
+
const seen = /* @__PURE__ */ new Set();
|
|
34
|
+
const result = [];
|
|
35
|
+
for (const value of values) {
|
|
36
|
+
if (value === void 0 || value === null) continue;
|
|
37
|
+
if (!seen.has(value)) {
|
|
38
|
+
seen.add(value);
|
|
39
|
+
result.push(value);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return result;
|
|
30
43
|
}
|
|
31
|
-
|
|
32
|
-
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/builders.ts
|
|
33
46
|
function resolveBaseTypeRule() {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return {
|
|
46
|
-
severity: _types.RuleConfigSeverity.Error,
|
|
47
|
-
condition: "always",
|
|
48
|
-
values: []
|
|
49
|
-
};
|
|
47
|
+
const rule = _commitlint_config_conventional.default.rules?.["type-enum"];
|
|
48
|
+
if (Array.isArray(rule)) return {
|
|
49
|
+
severity: rule[0] ?? _commitlint_types.RuleConfigSeverity.Error,
|
|
50
|
+
condition: rule[1] ?? "always",
|
|
51
|
+
values: [...rule[2] ?? []]
|
|
52
|
+
};
|
|
53
|
+
return {
|
|
54
|
+
severity: _commitlint_types.RuleConfigSeverity.Error,
|
|
55
|
+
condition: "always",
|
|
56
|
+
values: []
|
|
57
|
+
};
|
|
50
58
|
}
|
|
51
59
|
function buildTypesConfig(options) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
enum: mergedEnum
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
return {
|
|
96
|
-
...rule ? { rule } : {},
|
|
97
|
-
prompt
|
|
98
|
-
};
|
|
60
|
+
if (!options) return {};
|
|
61
|
+
const baseRule = resolveBaseTypeRule();
|
|
62
|
+
const additional = mergeUnique([
|
|
63
|
+
...baseRule.values,
|
|
64
|
+
...mergeUnique(options.add ?? []),
|
|
65
|
+
...mergeUnique((options.definitions ?? []).map((definition) => definition.value))
|
|
66
|
+
]);
|
|
67
|
+
let rule;
|
|
68
|
+
if (additional.length > 0) rule = [
|
|
69
|
+
options.severity ?? baseRule.severity,
|
|
70
|
+
options.condition ?? baseRule.condition,
|
|
71
|
+
additional
|
|
72
|
+
];
|
|
73
|
+
if (!options.definitions?.length) return rule ? { rule } : {};
|
|
74
|
+
const basePromptType = _commitlint_config_conventional.default.prompt?.questions?.type;
|
|
75
|
+
const mergedEnum = { ...basePromptType?.enum ?? {} };
|
|
76
|
+
for (const definition of options.definitions) {
|
|
77
|
+
const { value, title, description, emoji } = definition;
|
|
78
|
+
mergedEnum[value] = {
|
|
79
|
+
...mergedEnum[value] ?? {},
|
|
80
|
+
...title !== void 0 ? { title } : {},
|
|
81
|
+
...description !== void 0 ? { description } : {},
|
|
82
|
+
...emoji !== void 0 ? { emoji } : {}
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
const prompt = {
|
|
86
|
+
..._commitlint_config_conventional.default.prompt ?? {},
|
|
87
|
+
questions: {
|
|
88
|
+
..._commitlint_config_conventional.default.prompt?.questions ?? {},
|
|
89
|
+
type: {
|
|
90
|
+
...basePromptType ?? {},
|
|
91
|
+
enum: mergedEnum
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
return {
|
|
96
|
+
...rule ? { rule } : {},
|
|
97
|
+
prompt
|
|
98
|
+
};
|
|
99
99
|
}
|
|
100
100
|
function buildScopeRules(options) {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
rules["scope-case"] = [severity, "always", scopeCases];
|
|
120
|
-
}
|
|
121
|
-
return rules;
|
|
101
|
+
if (!options) return {};
|
|
102
|
+
const rules = {};
|
|
103
|
+
const severity = options.severity ?? _commitlint_types.RuleConfigSeverity.Error;
|
|
104
|
+
const scopeValues = mergeUnique(asArray(options.values));
|
|
105
|
+
if (scopeValues.length > 0) rules["scope-enum"] = [
|
|
106
|
+
severity,
|
|
107
|
+
"always",
|
|
108
|
+
scopeValues
|
|
109
|
+
];
|
|
110
|
+
if (options.required !== void 0) if (options.required) rules["scope-empty"] = [severity, "never"];
|
|
111
|
+
else rules["scope-empty"] = [_commitlint_types.RuleConfigSeverity.Disabled];
|
|
112
|
+
const scopeCases = mergeUnique(asArray(options.case));
|
|
113
|
+
if (scopeCases.length > 0) rules["scope-case"] = [
|
|
114
|
+
severity,
|
|
115
|
+
"always",
|
|
116
|
+
scopeCases
|
|
117
|
+
];
|
|
118
|
+
return rules;
|
|
122
119
|
}
|
|
123
120
|
function buildSubjectRules(options) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
_nullishCoalesce(options.allowEmptySeverity, () => ( _types.RuleConfigSeverity.Error)),
|
|
142
|
-
"never"
|
|
143
|
-
];
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
if (options.fullStop !== void 0) {
|
|
147
|
-
if (options.fullStop) {
|
|
148
|
-
rules["subject-full-stop"] = [
|
|
149
|
-
_nullishCoalesce(options.fullStopSeverity, () => ( _types.RuleConfigSeverity.Error)),
|
|
150
|
-
"always",
|
|
151
|
-
_nullishCoalesce(options.fullStopCharacter, () => ( "."))
|
|
152
|
-
];
|
|
153
|
-
} else {
|
|
154
|
-
rules["subject-full-stop"] = [_types.RuleConfigSeverity.Disabled];
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
return rules;
|
|
121
|
+
if (!options) return {};
|
|
122
|
+
const rules = {};
|
|
123
|
+
const forbiddenCases = mergeUnique(asArray(options.forbidden));
|
|
124
|
+
if (forbiddenCases.length > 0) rules["subject-case"] = [
|
|
125
|
+
options.caseSeverity ?? _commitlint_types.RuleConfigSeverity.Error,
|
|
126
|
+
options.caseCondition ?? "never",
|
|
127
|
+
forbiddenCases
|
|
128
|
+
];
|
|
129
|
+
if (options.allowEmpty !== void 0) if (options.allowEmpty) rules["subject-empty"] = [_commitlint_types.RuleConfigSeverity.Disabled];
|
|
130
|
+
else rules["subject-empty"] = [options.allowEmptySeverity ?? _commitlint_types.RuleConfigSeverity.Error, "never"];
|
|
131
|
+
if (options.fullStop !== void 0) if (options.fullStop) rules["subject-full-stop"] = [
|
|
132
|
+
options.fullStopSeverity ?? _commitlint_types.RuleConfigSeverity.Error,
|
|
133
|
+
"always",
|
|
134
|
+
options.fullStopCharacter ?? "."
|
|
135
|
+
];
|
|
136
|
+
else rules["subject-full-stop"] = [_commitlint_types.RuleConfigSeverity.Disabled];
|
|
137
|
+
return rules;
|
|
158
138
|
}
|
|
159
139
|
function buildHeaderRules(options) {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
140
|
+
if (!options) return {};
|
|
141
|
+
const rules = {};
|
|
142
|
+
const severity = options.severity ?? _commitlint_types.RuleConfigSeverity.Error;
|
|
143
|
+
const condition = options.condition ?? "always";
|
|
144
|
+
if (options.maxLength !== void 0) rules["header-max-length"] = [
|
|
145
|
+
severity,
|
|
146
|
+
condition,
|
|
147
|
+
options.maxLength
|
|
148
|
+
];
|
|
149
|
+
return rules;
|
|
170
150
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
// src/prompt.ts
|
|
151
|
+
//#endregion
|
|
152
|
+
//#region src/constants.ts
|
|
153
|
+
const DEFAULT_EXTENDS = [];
|
|
154
|
+
//#endregion
|
|
155
|
+
//#region src/prompt.ts
|
|
177
156
|
function mergePrompts(base, override) {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
...override,
|
|
190
|
-
questions: {
|
|
191
|
-
..._nullishCoalesce(base.questions, () => ( {})),
|
|
192
|
-
..._nullishCoalesce(override.questions, () => ( {}))
|
|
193
|
-
}
|
|
194
|
-
};
|
|
157
|
+
if (!base && !override) return;
|
|
158
|
+
if (!base) return override;
|
|
159
|
+
if (!override) return base;
|
|
160
|
+
return {
|
|
161
|
+
...base,
|
|
162
|
+
...override,
|
|
163
|
+
questions: {
|
|
164
|
+
...base.questions ?? {},
|
|
165
|
+
...override.questions ?? {}
|
|
166
|
+
}
|
|
167
|
+
};
|
|
195
168
|
}
|
|
196
|
-
|
|
197
|
-
|
|
169
|
+
//#endregion
|
|
170
|
+
//#region src/index.ts
|
|
198
171
|
function createIcebreakerCommitlintConfig(options = {}) {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
...extendsList.length > 0 ? { extends: extendsList } : {},
|
|
225
|
-
parserPreset: _nullishCoalesce(_configconventional2.default.parserPreset, () => ( DEFAULT_PARSER_PRESET)),
|
|
226
|
-
...Object.keys(mergedRules).length > 0 ? { rules: mergedRules } : {},
|
|
227
|
-
...prompt ? { prompt } : {}
|
|
228
|
-
};
|
|
172
|
+
const { types, scopes, subject, header } = options;
|
|
173
|
+
const extendsList = mergeUnique([
|
|
174
|
+
...DEFAULT_EXTENDS,
|
|
175
|
+
...asArray(_commitlint_config_conventional.default.extends),
|
|
176
|
+
...asArray(options.extends)
|
|
177
|
+
]);
|
|
178
|
+
const rules = {
|
|
179
|
+
..._commitlint_config_conventional.default.rules ?? {},
|
|
180
|
+
...buildScopeRules(scopes),
|
|
181
|
+
...buildSubjectRules(subject),
|
|
182
|
+
...buildHeaderRules(header)
|
|
183
|
+
};
|
|
184
|
+
const typesConfig = buildTypesConfig(types);
|
|
185
|
+
if (typesConfig.rule) rules["type-enum"] = typesConfig.rule;
|
|
186
|
+
const mergedRules = {
|
|
187
|
+
...rules,
|
|
188
|
+
...options.rules ?? {}
|
|
189
|
+
};
|
|
190
|
+
const prompt = mergePrompts(typesConfig.prompt ?? _commitlint_config_conventional.default.prompt, options.prompt);
|
|
191
|
+
return {
|
|
192
|
+
...extendsList.length > 0 ? { extends: extendsList } : {},
|
|
193
|
+
parserPreset: _commitlint_config_conventional.default.parserPreset ?? "conventional-changelog-conventionalcommits",
|
|
194
|
+
...Object.keys(mergedRules).length > 0 ? { rules: mergedRules } : {},
|
|
195
|
+
...prompt ? { prompt } : {}
|
|
196
|
+
};
|
|
229
197
|
}
|
|
230
198
|
function icebreaker(options) {
|
|
231
|
-
|
|
199
|
+
return createIcebreakerCommitlintConfig(options);
|
|
232
200
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
exports.RuleConfigSeverity = _types.RuleConfigSeverity; exports.createIcebreakerCommitlintConfig = createIcebreakerCommitlintConfig; exports.icebreaker = icebreaker;
|
|
201
|
+
//#endregion
|
|
202
|
+
exports.RuleConfigSeverity = _commitlint_types.RuleConfigSeverity;
|
|
203
|
+
exports.createIcebreakerCommitlintConfig = createIcebreakerCommitlintConfig;
|
|
204
|
+
exports.icebreaker = icebreaker;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,50 +1,51 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { UserConfig as CommitlintUserConfig, RuleConfigSeverity } from '@commitlint/types';
|
|
1
|
+
import { RuleConfigCondition, RuleConfigSeverity, RulesConfig, TargetCaseType, UserConfig, UserConfig as UserConfig$1, UserPromptConfig } from "@commitlint/types";
|
|
3
2
|
|
|
3
|
+
//#region src/types.d.ts
|
|
4
4
|
interface CommitTypeDefinition {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
value: string;
|
|
6
|
+
title?: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
emoji?: string;
|
|
9
9
|
}
|
|
10
10
|
interface CommitTypesOptions {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
add?: string[];
|
|
12
|
+
definitions?: CommitTypeDefinition[];
|
|
13
|
+
condition?: RuleConfigCondition;
|
|
14
|
+
severity?: RuleConfigSeverity;
|
|
15
15
|
}
|
|
16
16
|
interface CommitScopeOptions {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
values?: string[];
|
|
18
|
+
required?: boolean;
|
|
19
|
+
case?: TargetCaseType | TargetCaseType[];
|
|
20
|
+
severity?: RuleConfigSeverity;
|
|
21
21
|
}
|
|
22
22
|
interface CommitSubjectOptions {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
23
|
+
forbidden?: TargetCaseType | TargetCaseType[];
|
|
24
|
+
caseCondition?: RuleConfigCondition;
|
|
25
|
+
caseSeverity?: RuleConfigSeverity;
|
|
26
|
+
allowEmpty?: boolean;
|
|
27
|
+
allowEmptySeverity?: RuleConfigSeverity;
|
|
28
|
+
fullStop?: boolean;
|
|
29
|
+
fullStopSeverity?: RuleConfigSeverity;
|
|
30
|
+
fullStopCharacter?: string;
|
|
31
31
|
}
|
|
32
32
|
interface CommitHeaderOptions {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
maxLength?: number;
|
|
34
|
+
condition?: RuleConfigCondition;
|
|
35
|
+
severity?: RuleConfigSeverity;
|
|
36
36
|
}
|
|
37
37
|
interface IcebreakerCommitlintOptions {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
extends?: string[];
|
|
39
|
+
rules?: Partial<RulesConfig>;
|
|
40
|
+
types?: CommitTypesOptions;
|
|
41
|
+
scopes?: CommitScopeOptions;
|
|
42
|
+
subject?: CommitSubjectOptions;
|
|
43
|
+
header?: CommitHeaderOptions;
|
|
44
|
+
prompt?: UserPromptConfig;
|
|
45
45
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
declare function
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/index.d.ts
|
|
48
|
+
declare function createIcebreakerCommitlintConfig(options?: IcebreakerCommitlintOptions): UserConfig$1;
|
|
49
|
+
declare function icebreaker(options?: IcebreakerCommitlintOptions): UserConfig$1;
|
|
50
|
+
//#endregion
|
|
51
|
+
export { type CommitHeaderOptions, type CommitScopeOptions, type CommitSubjectOptions, type CommitTypeDefinition, type CommitTypesOptions, type UserConfig as CommitlintUserConfig, type IcebreakerCommitlintOptions, RuleConfigSeverity, createIcebreakerCommitlintConfig, icebreaker };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,50 +1,51 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { UserConfig as CommitlintUserConfig, RuleConfigSeverity } from '@commitlint/types';
|
|
1
|
+
import { RuleConfigCondition, RuleConfigSeverity, RulesConfig, TargetCaseType, UserConfig, UserConfig as UserConfig$1, UserPromptConfig } from "@commitlint/types";
|
|
3
2
|
|
|
3
|
+
//#region src/types.d.ts
|
|
4
4
|
interface CommitTypeDefinition {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
value: string;
|
|
6
|
+
title?: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
emoji?: string;
|
|
9
9
|
}
|
|
10
10
|
interface CommitTypesOptions {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
add?: string[];
|
|
12
|
+
definitions?: CommitTypeDefinition[];
|
|
13
|
+
condition?: RuleConfigCondition;
|
|
14
|
+
severity?: RuleConfigSeverity;
|
|
15
15
|
}
|
|
16
16
|
interface CommitScopeOptions {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
values?: string[];
|
|
18
|
+
required?: boolean;
|
|
19
|
+
case?: TargetCaseType | TargetCaseType[];
|
|
20
|
+
severity?: RuleConfigSeverity;
|
|
21
21
|
}
|
|
22
22
|
interface CommitSubjectOptions {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
23
|
+
forbidden?: TargetCaseType | TargetCaseType[];
|
|
24
|
+
caseCondition?: RuleConfigCondition;
|
|
25
|
+
caseSeverity?: RuleConfigSeverity;
|
|
26
|
+
allowEmpty?: boolean;
|
|
27
|
+
allowEmptySeverity?: RuleConfigSeverity;
|
|
28
|
+
fullStop?: boolean;
|
|
29
|
+
fullStopSeverity?: RuleConfigSeverity;
|
|
30
|
+
fullStopCharacter?: string;
|
|
31
31
|
}
|
|
32
32
|
interface CommitHeaderOptions {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
maxLength?: number;
|
|
34
|
+
condition?: RuleConfigCondition;
|
|
35
|
+
severity?: RuleConfigSeverity;
|
|
36
36
|
}
|
|
37
37
|
interface IcebreakerCommitlintOptions {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
extends?: string[];
|
|
39
|
+
rules?: Partial<RulesConfig>;
|
|
40
|
+
types?: CommitTypesOptions;
|
|
41
|
+
scopes?: CommitScopeOptions;
|
|
42
|
+
subject?: CommitSubjectOptions;
|
|
43
|
+
header?: CommitHeaderOptions;
|
|
44
|
+
prompt?: UserPromptConfig;
|
|
45
45
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
declare function
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/index.d.ts
|
|
48
|
+
declare function createIcebreakerCommitlintConfig(options?: IcebreakerCommitlintOptions): UserConfig$1;
|
|
49
|
+
declare function icebreaker(options?: IcebreakerCommitlintOptions): UserConfig$1;
|
|
50
|
+
//#endregion
|
|
51
|
+
export { type CommitHeaderOptions, type CommitScopeOptions, type CommitSubjectOptions, type CommitTypeDefinition, type CommitTypesOptions, type UserConfig as CommitlintUserConfig, type IcebreakerCommitlintOptions, RuleConfigSeverity, createIcebreakerCommitlintConfig, icebreaker };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import conventionalConfig from "@commitlint/config-conventional";
|
|
2
|
+
import { RuleConfigSeverity } from "@commitlint/types";
|
|
3
|
+
//#region src/utils.ts
|
|
4
|
+
function asArray(value) {
|
|
5
|
+
if (value === void 0) return [];
|
|
6
|
+
return Array.isArray(value) ? value : [value];
|
|
7
|
+
}
|
|
8
|
+
function mergeUnique(values) {
|
|
9
|
+
const seen = /* @__PURE__ */ new Set();
|
|
10
|
+
const result = [];
|
|
11
|
+
for (const value of values) {
|
|
12
|
+
if (value === void 0 || value === null) continue;
|
|
13
|
+
if (!seen.has(value)) {
|
|
14
|
+
seen.add(value);
|
|
15
|
+
result.push(value);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/builders.ts
|
|
22
|
+
function resolveBaseTypeRule() {
|
|
23
|
+
const rule = conventionalConfig.rules?.["type-enum"];
|
|
24
|
+
if (Array.isArray(rule)) return {
|
|
25
|
+
severity: rule[0] ?? RuleConfigSeverity.Error,
|
|
26
|
+
condition: rule[1] ?? "always",
|
|
27
|
+
values: [...rule[2] ?? []]
|
|
28
|
+
};
|
|
29
|
+
return {
|
|
30
|
+
severity: RuleConfigSeverity.Error,
|
|
31
|
+
condition: "always",
|
|
32
|
+
values: []
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function buildTypesConfig(options) {
|
|
36
|
+
if (!options) return {};
|
|
37
|
+
const baseRule = resolveBaseTypeRule();
|
|
38
|
+
const additional = mergeUnique([
|
|
39
|
+
...baseRule.values,
|
|
40
|
+
...mergeUnique(options.add ?? []),
|
|
41
|
+
...mergeUnique((options.definitions ?? []).map((definition) => definition.value))
|
|
42
|
+
]);
|
|
43
|
+
let rule;
|
|
44
|
+
if (additional.length > 0) rule = [
|
|
45
|
+
options.severity ?? baseRule.severity,
|
|
46
|
+
options.condition ?? baseRule.condition,
|
|
47
|
+
additional
|
|
48
|
+
];
|
|
49
|
+
if (!options.definitions?.length) return rule ? { rule } : {};
|
|
50
|
+
const basePromptType = conventionalConfig.prompt?.questions?.type;
|
|
51
|
+
const mergedEnum = { ...basePromptType?.enum ?? {} };
|
|
52
|
+
for (const definition of options.definitions) {
|
|
53
|
+
const { value, title, description, emoji } = definition;
|
|
54
|
+
mergedEnum[value] = {
|
|
55
|
+
...mergedEnum[value] ?? {},
|
|
56
|
+
...title !== void 0 ? { title } : {},
|
|
57
|
+
...description !== void 0 ? { description } : {},
|
|
58
|
+
...emoji !== void 0 ? { emoji } : {}
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
const prompt = {
|
|
62
|
+
...conventionalConfig.prompt ?? {},
|
|
63
|
+
questions: {
|
|
64
|
+
...conventionalConfig.prompt?.questions ?? {},
|
|
65
|
+
type: {
|
|
66
|
+
...basePromptType ?? {},
|
|
67
|
+
enum: mergedEnum
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
return {
|
|
72
|
+
...rule ? { rule } : {},
|
|
73
|
+
prompt
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function buildScopeRules(options) {
|
|
77
|
+
if (!options) return {};
|
|
78
|
+
const rules = {};
|
|
79
|
+
const severity = options.severity ?? RuleConfigSeverity.Error;
|
|
80
|
+
const scopeValues = mergeUnique(asArray(options.values));
|
|
81
|
+
if (scopeValues.length > 0) rules["scope-enum"] = [
|
|
82
|
+
severity,
|
|
83
|
+
"always",
|
|
84
|
+
scopeValues
|
|
85
|
+
];
|
|
86
|
+
if (options.required !== void 0) if (options.required) rules["scope-empty"] = [severity, "never"];
|
|
87
|
+
else rules["scope-empty"] = [RuleConfigSeverity.Disabled];
|
|
88
|
+
const scopeCases = mergeUnique(asArray(options.case));
|
|
89
|
+
if (scopeCases.length > 0) rules["scope-case"] = [
|
|
90
|
+
severity,
|
|
91
|
+
"always",
|
|
92
|
+
scopeCases
|
|
93
|
+
];
|
|
94
|
+
return rules;
|
|
95
|
+
}
|
|
96
|
+
function buildSubjectRules(options) {
|
|
97
|
+
if (!options) return {};
|
|
98
|
+
const rules = {};
|
|
99
|
+
const forbiddenCases = mergeUnique(asArray(options.forbidden));
|
|
100
|
+
if (forbiddenCases.length > 0) rules["subject-case"] = [
|
|
101
|
+
options.caseSeverity ?? RuleConfigSeverity.Error,
|
|
102
|
+
options.caseCondition ?? "never",
|
|
103
|
+
forbiddenCases
|
|
104
|
+
];
|
|
105
|
+
if (options.allowEmpty !== void 0) if (options.allowEmpty) rules["subject-empty"] = [RuleConfigSeverity.Disabled];
|
|
106
|
+
else rules["subject-empty"] = [options.allowEmptySeverity ?? RuleConfigSeverity.Error, "never"];
|
|
107
|
+
if (options.fullStop !== void 0) if (options.fullStop) rules["subject-full-stop"] = [
|
|
108
|
+
options.fullStopSeverity ?? RuleConfigSeverity.Error,
|
|
109
|
+
"always",
|
|
110
|
+
options.fullStopCharacter ?? "."
|
|
111
|
+
];
|
|
112
|
+
else rules["subject-full-stop"] = [RuleConfigSeverity.Disabled];
|
|
113
|
+
return rules;
|
|
114
|
+
}
|
|
115
|
+
function buildHeaderRules(options) {
|
|
116
|
+
if (!options) return {};
|
|
117
|
+
const rules = {};
|
|
118
|
+
const severity = options.severity ?? RuleConfigSeverity.Error;
|
|
119
|
+
const condition = options.condition ?? "always";
|
|
120
|
+
if (options.maxLength !== void 0) rules["header-max-length"] = [
|
|
121
|
+
severity,
|
|
122
|
+
condition,
|
|
123
|
+
options.maxLength
|
|
124
|
+
];
|
|
125
|
+
return rules;
|
|
126
|
+
}
|
|
127
|
+
//#endregion
|
|
128
|
+
//#region src/constants.ts
|
|
129
|
+
const DEFAULT_EXTENDS = [];
|
|
130
|
+
//#endregion
|
|
131
|
+
//#region src/prompt.ts
|
|
132
|
+
function mergePrompts(base, override) {
|
|
133
|
+
if (!base && !override) return;
|
|
134
|
+
if (!base) return override;
|
|
135
|
+
if (!override) return base;
|
|
136
|
+
return {
|
|
137
|
+
...base,
|
|
138
|
+
...override,
|
|
139
|
+
questions: {
|
|
140
|
+
...base.questions ?? {},
|
|
141
|
+
...override.questions ?? {}
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
//#endregion
|
|
146
|
+
//#region src/index.ts
|
|
147
|
+
function createIcebreakerCommitlintConfig(options = {}) {
|
|
148
|
+
const { types, scopes, subject, header } = options;
|
|
149
|
+
const extendsList = mergeUnique([
|
|
150
|
+
...DEFAULT_EXTENDS,
|
|
151
|
+
...asArray(conventionalConfig.extends),
|
|
152
|
+
...asArray(options.extends)
|
|
153
|
+
]);
|
|
154
|
+
const rules = {
|
|
155
|
+
...conventionalConfig.rules ?? {},
|
|
156
|
+
...buildScopeRules(scopes),
|
|
157
|
+
...buildSubjectRules(subject),
|
|
158
|
+
...buildHeaderRules(header)
|
|
159
|
+
};
|
|
160
|
+
const typesConfig = buildTypesConfig(types);
|
|
161
|
+
if (typesConfig.rule) rules["type-enum"] = typesConfig.rule;
|
|
162
|
+
const mergedRules = {
|
|
163
|
+
...rules,
|
|
164
|
+
...options.rules ?? {}
|
|
165
|
+
};
|
|
166
|
+
const prompt = mergePrompts(typesConfig.prompt ?? conventionalConfig.prompt, options.prompt);
|
|
167
|
+
return {
|
|
168
|
+
...extendsList.length > 0 ? { extends: extendsList } : {},
|
|
169
|
+
parserPreset: conventionalConfig.parserPreset ?? "conventional-changelog-conventionalcommits",
|
|
170
|
+
...Object.keys(mergedRules).length > 0 ? { rules: mergedRules } : {},
|
|
171
|
+
...prompt ? { prompt } : {}
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
function icebreaker(options) {
|
|
175
|
+
return createIcebreakerCommitlintConfig(options);
|
|
176
|
+
}
|
|
177
|
+
//#endregion
|
|
178
|
+
export { RuleConfigSeverity, createIcebreakerCommitlintConfig, icebreaker };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@icebreakers/commitlint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.2.
|
|
4
|
+
"version": "1.2.12",
|
|
5
5
|
"description": "Commitlint preset from Icebreaker's dev-configs",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -22,16 +22,22 @@
|
|
|
22
22
|
"exports": {
|
|
23
23
|
".": {
|
|
24
24
|
"types": "./dist/index.d.ts",
|
|
25
|
-
"import": "./dist/index.
|
|
25
|
+
"import": "./dist/index.js",
|
|
26
26
|
"require": "./dist/index.cjs"
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
29
|
"main": "./dist/index.cjs",
|
|
30
|
-
"module": "./dist/index.
|
|
30
|
+
"module": "./dist/index.js",
|
|
31
31
|
"types": "./dist/index.d.ts",
|
|
32
32
|
"files": [
|
|
33
33
|
"dist"
|
|
34
34
|
],
|
|
35
|
+
"tsd": {
|
|
36
|
+
"directory": "test-d",
|
|
37
|
+
"compilerOptions": {
|
|
38
|
+
"skipLibCheck": true
|
|
39
|
+
}
|
|
40
|
+
},
|
|
35
41
|
"peerDependencies": {
|
|
36
42
|
"conventional-changelog-conventionalcommits": ">=9.0.0"
|
|
37
43
|
},
|
|
@@ -41,15 +47,16 @@
|
|
|
41
47
|
}
|
|
42
48
|
},
|
|
43
49
|
"dependencies": {
|
|
44
|
-
"@commitlint/config-conventional": "^20.
|
|
45
|
-
"@commitlint/types": "^20.
|
|
50
|
+
"@commitlint/config-conventional": "^20.5.0",
|
|
51
|
+
"@commitlint/types": "^20.5.0",
|
|
46
52
|
"conventional-changelog-conventionalcommits": "^9.3.0"
|
|
47
53
|
},
|
|
48
54
|
"scripts": {
|
|
49
|
-
"dev": "
|
|
50
|
-
"build:watch": "
|
|
51
|
-
"build": "
|
|
55
|
+
"dev": "tsdown --watch --sourcemap",
|
|
56
|
+
"build:watch": "tsdown --watch --sourcemap",
|
|
57
|
+
"build": "tsdown",
|
|
52
58
|
"test": "vitest run",
|
|
59
|
+
"test:types": "tsd",
|
|
53
60
|
"test:dev": "vitest",
|
|
54
61
|
"release": "pnpm publish",
|
|
55
62
|
"lint": "eslint .",
|
package/dist/index.mjs
DELETED
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
// src/index.ts
|
|
2
|
-
import conventionalConfig2 from "@commitlint/config-conventional";
|
|
3
|
-
|
|
4
|
-
// src/builders.ts
|
|
5
|
-
import conventionalConfig from "@commitlint/config-conventional";
|
|
6
|
-
|
|
7
|
-
// src/types.ts
|
|
8
|
-
import { RuleConfigSeverity } from "@commitlint/types";
|
|
9
|
-
|
|
10
|
-
// src/utils.ts
|
|
11
|
-
function asArray(value) {
|
|
12
|
-
if (value === void 0) {
|
|
13
|
-
return [];
|
|
14
|
-
}
|
|
15
|
-
return Array.isArray(value) ? value : [value];
|
|
16
|
-
}
|
|
17
|
-
function mergeUnique(values) {
|
|
18
|
-
const seen = /* @__PURE__ */ new Set();
|
|
19
|
-
const result = [];
|
|
20
|
-
for (const value of values) {
|
|
21
|
-
if (value === void 0 || value === null) {
|
|
22
|
-
continue;
|
|
23
|
-
}
|
|
24
|
-
if (!seen.has(value)) {
|
|
25
|
-
seen.add(value);
|
|
26
|
-
result.push(value);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return result;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// src/builders.ts
|
|
33
|
-
function resolveBaseTypeRule() {
|
|
34
|
-
const rule = conventionalConfig.rules?.["type-enum"];
|
|
35
|
-
if (Array.isArray(rule)) {
|
|
36
|
-
const severity = rule[0] ?? RuleConfigSeverity.Error;
|
|
37
|
-
const condition = rule[1] ?? "always";
|
|
38
|
-
const values = rule[2] ?? [];
|
|
39
|
-
return {
|
|
40
|
-
severity,
|
|
41
|
-
condition,
|
|
42
|
-
values: [...values]
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
return {
|
|
46
|
-
severity: RuleConfigSeverity.Error,
|
|
47
|
-
condition: "always",
|
|
48
|
-
values: []
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
function buildTypesConfig(options) {
|
|
52
|
-
if (!options) {
|
|
53
|
-
return {};
|
|
54
|
-
}
|
|
55
|
-
const baseRule = resolveBaseTypeRule();
|
|
56
|
-
const additional = mergeUnique([
|
|
57
|
-
...baseRule.values,
|
|
58
|
-
...mergeUnique(options.add ?? []),
|
|
59
|
-
...mergeUnique((options.definitions ?? []).map((definition) => definition.value))
|
|
60
|
-
]);
|
|
61
|
-
let rule;
|
|
62
|
-
if (additional.length > 0) {
|
|
63
|
-
rule = [
|
|
64
|
-
options.severity ?? baseRule.severity,
|
|
65
|
-
options.condition ?? baseRule.condition,
|
|
66
|
-
additional
|
|
67
|
-
];
|
|
68
|
-
}
|
|
69
|
-
if (!options.definitions?.length) {
|
|
70
|
-
return rule ? { rule } : {};
|
|
71
|
-
}
|
|
72
|
-
const basePromptType = conventionalConfig.prompt?.questions?.type;
|
|
73
|
-
const mergedEnum = {
|
|
74
|
-
...basePromptType?.enum ?? {}
|
|
75
|
-
};
|
|
76
|
-
for (const definition of options.definitions) {
|
|
77
|
-
const { value, title, description, emoji } = definition;
|
|
78
|
-
mergedEnum[value] = {
|
|
79
|
-
...mergedEnum[value] ?? {},
|
|
80
|
-
...title !== void 0 ? { title } : {},
|
|
81
|
-
...description !== void 0 ? { description } : {},
|
|
82
|
-
...emoji !== void 0 ? { emoji } : {}
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
const prompt = {
|
|
86
|
-
...conventionalConfig.prompt ?? {},
|
|
87
|
-
questions: {
|
|
88
|
-
...conventionalConfig.prompt?.questions ?? {},
|
|
89
|
-
type: {
|
|
90
|
-
...basePromptType ?? {},
|
|
91
|
-
enum: mergedEnum
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
return {
|
|
96
|
-
...rule ? { rule } : {},
|
|
97
|
-
prompt
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
function buildScopeRules(options) {
|
|
101
|
-
if (!options) {
|
|
102
|
-
return {};
|
|
103
|
-
}
|
|
104
|
-
const rules = {};
|
|
105
|
-
const severity = options.severity ?? RuleConfigSeverity.Error;
|
|
106
|
-
const scopeValues = mergeUnique(asArray(options.values));
|
|
107
|
-
if (scopeValues.length > 0) {
|
|
108
|
-
rules["scope-enum"] = [severity, "always", scopeValues];
|
|
109
|
-
}
|
|
110
|
-
if (options.required !== void 0) {
|
|
111
|
-
if (options.required) {
|
|
112
|
-
rules["scope-empty"] = [severity, "never"];
|
|
113
|
-
} else {
|
|
114
|
-
rules["scope-empty"] = [RuleConfigSeverity.Disabled];
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
const scopeCases = mergeUnique(asArray(options.case));
|
|
118
|
-
if (scopeCases.length > 0) {
|
|
119
|
-
rules["scope-case"] = [severity, "always", scopeCases];
|
|
120
|
-
}
|
|
121
|
-
return rules;
|
|
122
|
-
}
|
|
123
|
-
function buildSubjectRules(options) {
|
|
124
|
-
if (!options) {
|
|
125
|
-
return {};
|
|
126
|
-
}
|
|
127
|
-
const rules = {};
|
|
128
|
-
const forbiddenCases = mergeUnique(asArray(options.forbidden));
|
|
129
|
-
if (forbiddenCases.length > 0) {
|
|
130
|
-
rules["subject-case"] = [
|
|
131
|
-
options.caseSeverity ?? RuleConfigSeverity.Error,
|
|
132
|
-
options.caseCondition ?? "never",
|
|
133
|
-
forbiddenCases
|
|
134
|
-
];
|
|
135
|
-
}
|
|
136
|
-
if (options.allowEmpty !== void 0) {
|
|
137
|
-
if (options.allowEmpty) {
|
|
138
|
-
rules["subject-empty"] = [RuleConfigSeverity.Disabled];
|
|
139
|
-
} else {
|
|
140
|
-
rules["subject-empty"] = [
|
|
141
|
-
options.allowEmptySeverity ?? RuleConfigSeverity.Error,
|
|
142
|
-
"never"
|
|
143
|
-
];
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
if (options.fullStop !== void 0) {
|
|
147
|
-
if (options.fullStop) {
|
|
148
|
-
rules["subject-full-stop"] = [
|
|
149
|
-
options.fullStopSeverity ?? RuleConfigSeverity.Error,
|
|
150
|
-
"always",
|
|
151
|
-
options.fullStopCharacter ?? "."
|
|
152
|
-
];
|
|
153
|
-
} else {
|
|
154
|
-
rules["subject-full-stop"] = [RuleConfigSeverity.Disabled];
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
return rules;
|
|
158
|
-
}
|
|
159
|
-
function buildHeaderRules(options) {
|
|
160
|
-
if (!options) {
|
|
161
|
-
return {};
|
|
162
|
-
}
|
|
163
|
-
const rules = {};
|
|
164
|
-
const severity = options.severity ?? RuleConfigSeverity.Error;
|
|
165
|
-
const condition = options.condition ?? "always";
|
|
166
|
-
if (options.maxLength !== void 0) {
|
|
167
|
-
rules["header-max-length"] = [severity, condition, options.maxLength];
|
|
168
|
-
}
|
|
169
|
-
return rules;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
// src/constants.ts
|
|
173
|
-
var DEFAULT_EXTENDS = [];
|
|
174
|
-
var DEFAULT_PARSER_PRESET = "conventional-changelog-conventionalcommits";
|
|
175
|
-
|
|
176
|
-
// src/prompt.ts
|
|
177
|
-
function mergePrompts(base, override) {
|
|
178
|
-
if (!base && !override) {
|
|
179
|
-
return void 0;
|
|
180
|
-
}
|
|
181
|
-
if (!base) {
|
|
182
|
-
return override;
|
|
183
|
-
}
|
|
184
|
-
if (!override) {
|
|
185
|
-
return base;
|
|
186
|
-
}
|
|
187
|
-
return {
|
|
188
|
-
...base,
|
|
189
|
-
...override,
|
|
190
|
-
questions: {
|
|
191
|
-
...base.questions ?? {},
|
|
192
|
-
...override.questions ?? {}
|
|
193
|
-
}
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
// src/index.ts
|
|
198
|
-
function createIcebreakerCommitlintConfig(options = {}) {
|
|
199
|
-
const { types, scopes, subject, header } = options;
|
|
200
|
-
const extendsList = mergeUnique([
|
|
201
|
-
...DEFAULT_EXTENDS,
|
|
202
|
-
...asArray(
|
|
203
|
-
conventionalConfig2.extends
|
|
204
|
-
),
|
|
205
|
-
...asArray(options.extends)
|
|
206
|
-
]);
|
|
207
|
-
const rules = {
|
|
208
|
-
...conventionalConfig2.rules ?? {},
|
|
209
|
-
...buildScopeRules(scopes),
|
|
210
|
-
...buildSubjectRules(subject),
|
|
211
|
-
...buildHeaderRules(header)
|
|
212
|
-
};
|
|
213
|
-
const typesConfig = buildTypesConfig(types);
|
|
214
|
-
if (typesConfig.rule) {
|
|
215
|
-
rules["type-enum"] = typesConfig.rule;
|
|
216
|
-
}
|
|
217
|
-
const mergedRules = {
|
|
218
|
-
...rules,
|
|
219
|
-
...options.rules ?? {}
|
|
220
|
-
};
|
|
221
|
-
const promptBase = typesConfig.prompt ?? conventionalConfig2.prompt;
|
|
222
|
-
const prompt = mergePrompts(promptBase, options.prompt);
|
|
223
|
-
return {
|
|
224
|
-
...extendsList.length > 0 ? { extends: extendsList } : {},
|
|
225
|
-
parserPreset: conventionalConfig2.parserPreset ?? DEFAULT_PARSER_PRESET,
|
|
226
|
-
...Object.keys(mergedRules).length > 0 ? { rules: mergedRules } : {},
|
|
227
|
-
...prompt ? { prompt } : {}
|
|
228
|
-
};
|
|
229
|
-
}
|
|
230
|
-
function icebreaker(options) {
|
|
231
|
-
return createIcebreakerCommitlintConfig(options);
|
|
232
|
-
}
|
|
233
|
-
export {
|
|
234
|
-
RuleConfigSeverity,
|
|
235
|
-
createIcebreakerCommitlintConfig,
|
|
236
|
-
icebreaker
|
|
237
|
-
};
|