@icebreakers/commitlint-config 1.1.1 → 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 +21 -6
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.mjs +21 -6
- 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,8 +1,10 @@
|
|
|
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/
|
|
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
2
|
var _configconventional = require('@commitlint/config-conventional'); var _configconventional2 = _interopRequireDefault(_configconventional);
|
|
3
|
+
|
|
4
|
+
// src/types.ts
|
|
3
5
|
var _types = require('@commitlint/types');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
+
|
|
7
|
+
// src/utils.ts
|
|
6
8
|
function asArray(value) {
|
|
7
9
|
if (value === void 0) {
|
|
8
10
|
return [];
|
|
@@ -23,6 +25,8 @@ function mergeUnique(values) {
|
|
|
23
25
|
}
|
|
24
26
|
return result;
|
|
25
27
|
}
|
|
28
|
+
|
|
29
|
+
// src/builders.ts
|
|
26
30
|
function resolveBaseTypeRule() {
|
|
27
31
|
const rule = _optionalChain([_configconventional2.default, 'access', _ => _.rules, 'optionalAccess', _2 => _2["type-enum"]]);
|
|
28
32
|
if (Array.isArray(rule)) {
|
|
@@ -158,6 +162,12 @@ function buildHeaderRules(options) {
|
|
|
158
162
|
}
|
|
159
163
|
return rules;
|
|
160
164
|
}
|
|
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
|
|
161
171
|
function mergePrompts(base, override) {
|
|
162
172
|
if (!base && !override) {
|
|
163
173
|
return void 0;
|
|
@@ -177,6 +187,8 @@ function mergePrompts(base, override) {
|
|
|
177
187
|
}
|
|
178
188
|
};
|
|
179
189
|
}
|
|
190
|
+
|
|
191
|
+
// src/index.ts
|
|
180
192
|
function createIcebreakerCommitlintConfig(options = {}) {
|
|
181
193
|
const { types, scopes, subject, header } = options;
|
|
182
194
|
const extendsList = mergeUnique([
|
|
@@ -196,16 +208,19 @@ function createIcebreakerCommitlintConfig(options = {}) {
|
|
|
196
208
|
...rules,
|
|
197
209
|
..._nullishCoalesce(options.rules, () => ( {}))
|
|
198
210
|
};
|
|
199
|
-
const hasRules = Object.keys(mergedRules).length > 0;
|
|
200
211
|
const prompt = mergePrompts(typesConfig.prompt, options.prompt);
|
|
201
212
|
return {
|
|
202
213
|
extends: extendsList,
|
|
203
214
|
parserPreset: DEFAULT_PARSER_PRESET,
|
|
204
|
-
...
|
|
215
|
+
...Object.keys(mergedRules).length > 0 ? { rules: mergedRules } : {},
|
|
205
216
|
...prompt ? { prompt } : {}
|
|
206
217
|
};
|
|
207
218
|
}
|
|
219
|
+
function icebreaker(options) {
|
|
220
|
+
return createIcebreakerCommitlintConfig(options);
|
|
221
|
+
}
|
|
222
|
+
|
|
208
223
|
|
|
209
224
|
|
|
210
225
|
|
|
211
|
-
exports.RuleConfigSeverity = _types.RuleConfigSeverity; exports.createIcebreakerCommitlintConfig = createIcebreakerCommitlintConfig;
|
|
226
|
+
exports.RuleConfigSeverity = _types.RuleConfigSeverity; exports.createIcebreakerCommitlintConfig = createIcebreakerCommitlintConfig; exports.icebreaker = icebreaker;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RuleConfigCondition, RuleConfigSeverity, TargetCaseType,
|
|
1
|
+
import { RulesConfig, RuleConfigCondition, RuleConfigSeverity, TargetCaseType, UserPromptConfig, UserConfig } from '@commitlint/types';
|
|
2
2
|
export { UserConfig as CommitlintUserConfig, RuleConfigSeverity } from '@commitlint/types';
|
|
3
3
|
|
|
4
4
|
interface CommitTypeDefinition {
|
|
@@ -43,6 +43,8 @@ interface IcebreakerCommitlintOptions {
|
|
|
43
43
|
header?: CommitHeaderOptions;
|
|
44
44
|
prompt?: UserPromptConfig;
|
|
45
45
|
}
|
|
46
|
+
|
|
46
47
|
declare function createIcebreakerCommitlintConfig(options?: IcebreakerCommitlintOptions): UserConfig;
|
|
48
|
+
declare function icebreaker(options?: IcebreakerCommitlintOptions): UserConfig;
|
|
47
49
|
|
|
48
|
-
export { type CommitHeaderOptions, type CommitScopeOptions, type CommitSubjectOptions, type CommitTypeDefinition, type CommitTypesOptions, type IcebreakerCommitlintOptions, createIcebreakerCommitlintConfig };
|
|
50
|
+
export { type CommitHeaderOptions, type CommitScopeOptions, type CommitSubjectOptions, type CommitTypeDefinition, type CommitTypesOptions, type IcebreakerCommitlintOptions, createIcebreakerCommitlintConfig, icebreaker };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RuleConfigCondition, RuleConfigSeverity, TargetCaseType,
|
|
1
|
+
import { RulesConfig, RuleConfigCondition, RuleConfigSeverity, TargetCaseType, UserPromptConfig, UserConfig } from '@commitlint/types';
|
|
2
2
|
export { UserConfig as CommitlintUserConfig, RuleConfigSeverity } from '@commitlint/types';
|
|
3
3
|
|
|
4
4
|
interface CommitTypeDefinition {
|
|
@@ -43,6 +43,8 @@ interface IcebreakerCommitlintOptions {
|
|
|
43
43
|
header?: CommitHeaderOptions;
|
|
44
44
|
prompt?: UserPromptConfig;
|
|
45
45
|
}
|
|
46
|
+
|
|
46
47
|
declare function createIcebreakerCommitlintConfig(options?: IcebreakerCommitlintOptions): UserConfig;
|
|
48
|
+
declare function icebreaker(options?: IcebreakerCommitlintOptions): UserConfig;
|
|
47
49
|
|
|
48
|
-
export { type CommitHeaderOptions, type CommitScopeOptions, type CommitSubjectOptions, type CommitTypeDefinition, type CommitTypesOptions, type IcebreakerCommitlintOptions, createIcebreakerCommitlintConfig };
|
|
50
|
+
export { type CommitHeaderOptions, type CommitScopeOptions, type CommitSubjectOptions, type CommitTypeDefinition, type CommitTypesOptions, type IcebreakerCommitlintOptions, createIcebreakerCommitlintConfig, icebreaker };
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
// src/
|
|
1
|
+
// src/builders.ts
|
|
2
2
|
import conventionalConfig from "@commitlint/config-conventional";
|
|
3
|
+
|
|
4
|
+
// src/types.ts
|
|
3
5
|
import { RuleConfigSeverity } from "@commitlint/types";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
+
|
|
7
|
+
// src/utils.ts
|
|
6
8
|
function asArray(value) {
|
|
7
9
|
if (value === void 0) {
|
|
8
10
|
return [];
|
|
@@ -23,6 +25,8 @@ function mergeUnique(values) {
|
|
|
23
25
|
}
|
|
24
26
|
return result;
|
|
25
27
|
}
|
|
28
|
+
|
|
29
|
+
// src/builders.ts
|
|
26
30
|
function resolveBaseTypeRule() {
|
|
27
31
|
const rule = conventionalConfig.rules?.["type-enum"];
|
|
28
32
|
if (Array.isArray(rule)) {
|
|
@@ -158,6 +162,12 @@ function buildHeaderRules(options) {
|
|
|
158
162
|
}
|
|
159
163
|
return rules;
|
|
160
164
|
}
|
|
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
|
|
161
171
|
function mergePrompts(base, override) {
|
|
162
172
|
if (!base && !override) {
|
|
163
173
|
return void 0;
|
|
@@ -177,6 +187,8 @@ function mergePrompts(base, override) {
|
|
|
177
187
|
}
|
|
178
188
|
};
|
|
179
189
|
}
|
|
190
|
+
|
|
191
|
+
// src/index.ts
|
|
180
192
|
function createIcebreakerCommitlintConfig(options = {}) {
|
|
181
193
|
const { types, scopes, subject, header } = options;
|
|
182
194
|
const extendsList = mergeUnique([
|
|
@@ -196,16 +208,19 @@ function createIcebreakerCommitlintConfig(options = {}) {
|
|
|
196
208
|
...rules,
|
|
197
209
|
...options.rules ?? {}
|
|
198
210
|
};
|
|
199
|
-
const hasRules = Object.keys(mergedRules).length > 0;
|
|
200
211
|
const prompt = mergePrompts(typesConfig.prompt, options.prompt);
|
|
201
212
|
return {
|
|
202
213
|
extends: extendsList,
|
|
203
214
|
parserPreset: DEFAULT_PARSER_PRESET,
|
|
204
|
-
...
|
|
215
|
+
...Object.keys(mergedRules).length > 0 ? { rules: mergedRules } : {},
|
|
205
216
|
...prompt ? { prompt } : {}
|
|
206
217
|
};
|
|
207
218
|
}
|
|
219
|
+
function icebreaker(options) {
|
|
220
|
+
return createIcebreakerCommitlintConfig(options);
|
|
221
|
+
}
|
|
208
222
|
export {
|
|
209
223
|
RuleConfigSeverity,
|
|
210
|
-
createIcebreakerCommitlintConfig
|
|
224
|
+
createIcebreakerCommitlintConfig,
|
|
225
|
+
icebreaker
|
|
211
226
|
};
|