Skip to content

Commit 2a5012d

Browse files
committed
✨feat: 初始化
0 parents  commit 2a5012d

6 files changed

Lines changed: 1905 additions & 0 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.history
2+
node_modules

.husky/commit-msg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
npx --no-install commitlint --edit "$1"

READEME.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
## commintlint 模板项目
2+
3+
### 目前最常使用的commit规范为angular提交方式
4+
```
5+
<type>(<scope>): <subject>
6+
```
7+
* type 提交类型
8+
* scope 提交范围
9+
* subject 提交描述
10+
11+
本项目集成commitizen + commitlint,可使用命令交互式规范代码提交信息,通过husky拦截git的commit-msg hook
12+
13+
```shell
14+
yarn add @commitlint/cli husky --dev
15+
# 激活husky
16+
npm set-script prepare "husky install"
17+
yarn
18+
npx husky add .husky/commit-msg 'npx --no-install commitlint --edit "$1"'
19+
npx husky add .husky/pre-commit 'yarn lint && git add . '
20+
# 命令式交互
21+
yarn add @commitlint/cz-commitlint commitizen --dev
22+
# 增加changelog
23+
yarn add conventional-changelog-cli --dev
24+
25+
```

commitlint.config.js

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
module.exports = {
2+
parserPreset: {
3+
parserOpts: { headerPattern: /^(.*)(?:\((.*)\))?!?: (.*)$/ },
4+
},
5+
rules: {
6+
"body-leading-blank": [1, "always"],
7+
"body-max-line-length": [2, "always", 100],
8+
"footer-leading-blank": [1, "always"],
9+
"footer-max-line-length": [2, "always", 100],
10+
"header-max-length": [2, "always", 100],
11+
"subject-case": [
12+
2,
13+
"never",
14+
["sentence-case", "start-case", "pascal-case", "upper-case"],
15+
],
16+
"subject-empty": [2, "never"],
17+
"subject-full-stop": [2, "never", "."],
18+
"type-case": [2, "always", "lower-case"],
19+
"type-empty": [2, "never"],
20+
"type-enum": [
21+
2,
22+
"always",
23+
[
24+
"✨feat",
25+
"🐛fix",
26+
"📚docs",
27+
"💎style",
28+
"📦refactor",
29+
"🚀perf",
30+
"🚨test",
31+
"🛠build",
32+
"⚙️ci",
33+
"🗑revert",
34+
],
35+
],
36+
},
37+
38+
prompt: {
39+
questions: {
40+
type: {
41+
description: "选择当前 commit 的类型",
42+
enum: {
43+
"✨feat": {
44+
description: "新功能",
45+
title: "✨Features",
46+
emoji: "✨",
47+
},
48+
"🐛fix": {
49+
description: "修复bug",
50+
title: "🐛Bug Fixes",
51+
emoji: "🐛",
52+
},
53+
"📚docs": {
54+
description: "文档更新",
55+
title: "📚Documentation",
56+
emoji: "📚",
57+
},
58+
"💎style": {
59+
description: "代码风格的更改(空格,逗号,缺少分号等)",
60+
title: "💎Styles",
61+
emoji: "💎",
62+
},
63+
"📦refactor": {
64+
description: "代码重构(即不修复bug也不增加新功能)",
65+
title: "📦Code Refactoring",
66+
emoji: "📦",
67+
},
68+
"🚀perf": {
69+
description: "性能提升",
70+
title: "🚀Performance Improvements",
71+
emoji: "🚀",
72+
},
73+
"🚨test": {
74+
description: "添加测试文件或者更改测试文件",
75+
title: "🚨Tests",
76+
emoji: "🚨",
77+
},
78+
"🛠build": {
79+
description:
80+
"构建系统的更改或新的依赖更新,如webpack、gulp更改或者npm",
81+
title: "🛠Builds",
82+
emoji: "🛠",
83+
},
84+
"⚙️ci": {
85+
description: "ci配置的更改,如 travis、gitlab-ci",
86+
title: "⚙️Continuous Integrations",
87+
emoji: "⚙️",
88+
},
89+
"🗑revert": {
90+
description: "恢复以前的提交(如git revert)",
91+
title: "🗑Reverts",
92+
emoji: "🗑",
93+
},
94+
},
95+
},
96+
scope: {
97+
description: "变动访问,模块或者文件名(可skip)",
98+
},
99+
subject: {
100+
description: "写一个简短的描述",
101+
},
102+
body: {
103+
description: "提供更改的详细说明(可skip)",
104+
},
105+
isBreaking: {
106+
description: "是否有破坏性更新",
107+
},
108+
breakingBody: {
109+
description: "破坏性变更的详细描述",
110+
},
111+
breaking: {
112+
description: "破坏性变更的详细描述简短描述",
113+
},
114+
},
115+
},
116+
};

package.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "commitlint-template",
3+
"version": "0.0.1",
4+
"description": "commitlint 模板项目",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1",
8+
"prepare": "husky install",
9+
"commit": "git add . && git-cz",
10+
"changelog": "conventional-changelog -p -i CHANGELOG.md -s -r 0"
11+
},
12+
"author": "",
13+
"license": "ISC",
14+
"devDependencies": {
15+
"@commitlint/cli": "^16.1.0",
16+
"@commitlint/cz-commitlint": "^16.1.0",
17+
"commitizen": "^4.2.4",
18+
"husky": "^7.0.4"
19+
},
20+
"config": {
21+
"commitizen": {
22+
"path": "@commitlint/cz-commitlint"
23+
}
24+
}
25+
}

0 commit comments

Comments
 (0)