-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 2a5012d
Showing
6 changed files
with
1,905 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.history | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
npx --no-install commitlint --edit "$1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
## commintlint 模板项目 | ||
|
||
### 目前最常使用的commit规范为angular提交方式 | ||
``` | ||
<type>(<scope>): <subject> | ||
``` | ||
* type 提交类型 | ||
* scope 提交范围 | ||
* subject 提交描述 | ||
|
||
本项目集成commitizen + commitlint,可使用命令交互式规范代码提交信息,通过husky拦截git的commit-msg hook | ||
|
||
```shell | ||
yarn add @commitlint/cli husky --dev | ||
# 激活husky | ||
npm set-script prepare "husky install" | ||
yarn | ||
npx husky add .husky/commit-msg 'npx --no-install commitlint --edit "$1"' | ||
npx husky add .husky/pre-commit 'yarn lint && git add . ' | ||
# 命令式交互 | ||
yarn add @commitlint/cz-commitlint commitizen --dev | ||
# 增加changelog | ||
yarn add conventional-changelog-cli --dev | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
module.exports = { | ||
parserPreset: { | ||
parserOpts: { headerPattern: /^(.*)(?:\((.*)\))?!?: (.*)$/ }, | ||
}, | ||
rules: { | ||
"body-leading-blank": [1, "always"], | ||
"body-max-line-length": [2, "always", 100], | ||
"footer-leading-blank": [1, "always"], | ||
"footer-max-line-length": [2, "always", 100], | ||
"header-max-length": [2, "always", 100], | ||
"subject-case": [ | ||
2, | ||
"never", | ||
["sentence-case", "start-case", "pascal-case", "upper-case"], | ||
], | ||
"subject-empty": [2, "never"], | ||
"subject-full-stop": [2, "never", "."], | ||
"type-case": [2, "always", "lower-case"], | ||
"type-empty": [2, "never"], | ||
"type-enum": [ | ||
2, | ||
"always", | ||
[ | ||
"✨feat", | ||
"🐛fix", | ||
"📚docs", | ||
"💎style", | ||
"📦refactor", | ||
"🚀perf", | ||
"🚨test", | ||
"🛠build", | ||
"⚙️ci", | ||
"🗑revert", | ||
], | ||
], | ||
}, | ||
|
||
prompt: { | ||
questions: { | ||
type: { | ||
description: "选择当前 commit 的类型", | ||
enum: { | ||
"✨feat": { | ||
description: "新功能", | ||
title: "✨Features", | ||
emoji: "✨", | ||
}, | ||
"🐛fix": { | ||
description: "修复bug", | ||
title: "🐛Bug Fixes", | ||
emoji: "🐛", | ||
}, | ||
"📚docs": { | ||
description: "文档更新", | ||
title: "📚Documentation", | ||
emoji: "📚", | ||
}, | ||
"💎style": { | ||
description: "代码风格的更改(空格,逗号,缺少分号等)", | ||
title: "💎Styles", | ||
emoji: "💎", | ||
}, | ||
"📦refactor": { | ||
description: "代码重构(即不修复bug也不增加新功能)", | ||
title: "📦Code Refactoring", | ||
emoji: "📦", | ||
}, | ||
"🚀perf": { | ||
description: "性能提升", | ||
title: "🚀Performance Improvements", | ||
emoji: "🚀", | ||
}, | ||
"🚨test": { | ||
description: "添加测试文件或者更改测试文件", | ||
title: "🚨Tests", | ||
emoji: "🚨", | ||
}, | ||
"🛠build": { | ||
description: | ||
"构建系统的更改或新的依赖更新,如webpack、gulp更改或者npm", | ||
title: "🛠Builds", | ||
emoji: "🛠", | ||
}, | ||
"⚙️ci": { | ||
description: "ci配置的更改,如 travis、gitlab-ci", | ||
title: "⚙️Continuous Integrations", | ||
emoji: "⚙️", | ||
}, | ||
"🗑revert": { | ||
description: "恢复以前的提交(如git revert)", | ||
title: "🗑Reverts", | ||
emoji: "🗑", | ||
}, | ||
}, | ||
}, | ||
scope: { | ||
description: "变动访问,模块或者文件名(可skip)", | ||
}, | ||
subject: { | ||
description: "写一个简短的描述", | ||
}, | ||
body: { | ||
description: "提供更改的详细说明(可skip)", | ||
}, | ||
isBreaking: { | ||
description: "是否有破坏性更新", | ||
}, | ||
breakingBody: { | ||
description: "破坏性变更的详细描述", | ||
}, | ||
breaking: { | ||
description: "破坏性变更的详细描述简短描述", | ||
}, | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"name": "commitlint-template", | ||
"version": "0.0.1", | ||
"description": "commitlint 模板项目", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"prepare": "husky install", | ||
"commit": "git add . && git-cz", | ||
"changelog": "conventional-changelog -p -i CHANGELOG.md -s -r 0" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"devDependencies": { | ||
"@commitlint/cli": "^16.1.0", | ||
"@commitlint/cz-commitlint": "^16.1.0", | ||
"commitizen": "^4.2.4", | ||
"husky": "^7.0.4" | ||
}, | ||
"config": { | ||
"commitizen": { | ||
"path": "@commitlint/cz-commitlint" | ||
} | ||
} | ||
} |
Oops, something went wrong.