@deot/dev-commitlint 2.8.1
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 +2 -0
- package/bin/commitlint.js +3 -0
- package/dist/index.cjs +91 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +68 -0
- package/package.json +24 -0
package/README.md
ADDED
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const fs = require('node:fs');
|
|
6
|
+
|
|
7
|
+
function _interopNamespaceDefault(e) {
|
|
8
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
|
|
9
|
+
if (e) {
|
|
10
|
+
for (const k in e) {
|
|
11
|
+
if (k !== 'default') {
|
|
12
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
13
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: () => e[k]
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
n.default = e;
|
|
21
|
+
return Object.freeze(n);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs);
|
|
25
|
+
|
|
26
|
+
const commitRE = /^(revert: )?(void|fix|feat|docs|style|perf|test|types|build|chore|refactor|workflow|ci|wip|release|breaking change)(\(.+\))?: .{1,50}/;
|
|
27
|
+
const mergeRE = /Merge branch /;
|
|
28
|
+
const run = (commitMessage) => {
|
|
29
|
+
let content = "";
|
|
30
|
+
if (!commitRE.test(commitMessage) && !mergeRE.test(commitMessage)) {
|
|
31
|
+
content += `
|
|
32
|
+
Invalid commit message: "${commitMessage}".
|
|
33
|
+
`;
|
|
34
|
+
content += `
|
|
35
|
+
Examples:
|
|
36
|
+
`;
|
|
37
|
+
content += ` - fix(Button): incorrect style
|
|
38
|
+
`;
|
|
39
|
+
content += ` - feat(Button): incorrect style
|
|
40
|
+
`;
|
|
41
|
+
content += ` - docs(Button): fix typo
|
|
42
|
+
`;
|
|
43
|
+
content += `
|
|
44
|
+
Allowed Types:
|
|
45
|
+
`;
|
|
46
|
+
content += ` - fix:修补bug
|
|
47
|
+
`;
|
|
48
|
+
content += ` - feat:新功能(feature)
|
|
49
|
+
`;
|
|
50
|
+
content += ` - docs:文档(documentation)
|
|
51
|
+
`;
|
|
52
|
+
content += ` - style:不影响代码含义的更改,可能与代码格式有关,例如空格、缺少分号等
|
|
53
|
+
`;
|
|
54
|
+
content += ` - test:包括新的或更正以前的测试
|
|
55
|
+
`;
|
|
56
|
+
content += ` - chore:构建过程或辅助工具的变动
|
|
57
|
+
`;
|
|
58
|
+
content += ` - refactor:重构(即不是新增功能,也不是修改bug的代码变动)
|
|
59
|
+
`;
|
|
60
|
+
content += ` - perf:性能改进(performance improvements)
|
|
61
|
+
`;
|
|
62
|
+
content += ` - types:类型
|
|
63
|
+
`;
|
|
64
|
+
content += ` - build:影响构建系统或外部依赖项的更改
|
|
65
|
+
`;
|
|
66
|
+
content += ` - ci: 持续集成相关
|
|
67
|
+
`;
|
|
68
|
+
content += ` - breaking change:破坏性修改
|
|
69
|
+
`;
|
|
70
|
+
content += ` - void:无类型,通常用于初始化
|
|
71
|
+
`;
|
|
72
|
+
content += ` - Merge branch 'foo' into 'bar'
|
|
73
|
+
`;
|
|
74
|
+
}
|
|
75
|
+
return content;
|
|
76
|
+
};
|
|
77
|
+
const index = process.argv.findIndex((arg) => arg === "--edit");
|
|
78
|
+
/* istanbul ignore next -- @preserve */
|
|
79
|
+
const filepath = index !== -1 && process.argv[index + 1];
|
|
80
|
+
/* istanbul ignore next -- @preserve */
|
|
81
|
+
const message = filepath && fs__namespace.existsSync(filepath) ? fs__namespace.readFileSync(filepath, "utf-8").trim() : filepath || "";
|
|
82
|
+
/* istanbul ignore next -- @preserve */
|
|
83
|
+
if (message) {
|
|
84
|
+
const error = run(message);
|
|
85
|
+
if (error) {
|
|
86
|
+
console.error(error);
|
|
87
|
+
process.exit(1);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
exports.run = run;
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
|
|
3
|
+
const commitRE = /^(revert: )?(void|fix|feat|docs|style|perf|test|types|build|chore|refactor|workflow|ci|wip|release|breaking change)(\(.+\))?: .{1,50}/;
|
|
4
|
+
const mergeRE = /Merge branch /;
|
|
5
|
+
const run = (commitMessage) => {
|
|
6
|
+
let content = "";
|
|
7
|
+
if (!commitRE.test(commitMessage) && !mergeRE.test(commitMessage)) {
|
|
8
|
+
content += `
|
|
9
|
+
Invalid commit message: "${commitMessage}".
|
|
10
|
+
`;
|
|
11
|
+
content += `
|
|
12
|
+
Examples:
|
|
13
|
+
`;
|
|
14
|
+
content += ` - fix(Button): incorrect style
|
|
15
|
+
`;
|
|
16
|
+
content += ` - feat(Button): incorrect style
|
|
17
|
+
`;
|
|
18
|
+
content += ` - docs(Button): fix typo
|
|
19
|
+
`;
|
|
20
|
+
content += `
|
|
21
|
+
Allowed Types:
|
|
22
|
+
`;
|
|
23
|
+
content += ` - fix:修补bug
|
|
24
|
+
`;
|
|
25
|
+
content += ` - feat:新功能(feature)
|
|
26
|
+
`;
|
|
27
|
+
content += ` - docs:文档(documentation)
|
|
28
|
+
`;
|
|
29
|
+
content += ` - style:不影响代码含义的更改,可能与代码格式有关,例如空格、缺少分号等
|
|
30
|
+
`;
|
|
31
|
+
content += ` - test:包括新的或更正以前的测试
|
|
32
|
+
`;
|
|
33
|
+
content += ` - chore:构建过程或辅助工具的变动
|
|
34
|
+
`;
|
|
35
|
+
content += ` - refactor:重构(即不是新增功能,也不是修改bug的代码变动)
|
|
36
|
+
`;
|
|
37
|
+
content += ` - perf:性能改进(performance improvements)
|
|
38
|
+
`;
|
|
39
|
+
content += ` - types:类型
|
|
40
|
+
`;
|
|
41
|
+
content += ` - build:影响构建系统或外部依赖项的更改
|
|
42
|
+
`;
|
|
43
|
+
content += ` - ci: 持续集成相关
|
|
44
|
+
`;
|
|
45
|
+
content += ` - breaking change:破坏性修改
|
|
46
|
+
`;
|
|
47
|
+
content += ` - void:无类型,通常用于初始化
|
|
48
|
+
`;
|
|
49
|
+
content += ` - Merge branch 'foo' into 'bar'
|
|
50
|
+
`;
|
|
51
|
+
}
|
|
52
|
+
return content;
|
|
53
|
+
};
|
|
54
|
+
const index = process.argv.findIndex((arg) => arg === "--edit");
|
|
55
|
+
/* istanbul ignore next -- @preserve */
|
|
56
|
+
const filepath = index !== -1 && process.argv[index + 1];
|
|
57
|
+
/* istanbul ignore next -- @preserve */
|
|
58
|
+
const message = filepath && fs.existsSync(filepath) ? fs.readFileSync(filepath, "utf-8").trim() : filepath || "";
|
|
59
|
+
/* istanbul ignore next -- @preserve */
|
|
60
|
+
if (message) {
|
|
61
|
+
const error = run(message);
|
|
62
|
+
if (error) {
|
|
63
|
+
console.error(error);
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export { run };
|
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@deot/dev-commitlint",
|
|
3
|
+
"version": "2.8.1",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"import": "./dist/index.js",
|
|
10
|
+
"require": "./dist/index.cjs",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
21
|
+
"bin": {
|
|
22
|
+
"dd-commitlint": "bin/commitlint.js"
|
|
23
|
+
}
|
|
24
|
+
}
|