Skip to content

Commit

Permalink
✨feat: 初始化
Browse files Browse the repository at this point in the history
  • Loading branch information
ssdmtank committed Feb 12, 2022
0 parents commit 2a5012d
Show file tree
Hide file tree
Showing 6 changed files with 1,905 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.history
node_modules
4 changes: 4 additions & 0 deletions .husky/commit-msg
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"
25 changes: 25 additions & 0 deletions READEME.md
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

```
116 changes: 116 additions & 0 deletions commitlint.config.js
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: "破坏性变更的详细描述简短描述",
},
},
},
};
25 changes: 25 additions & 0 deletions package.json
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"
}
}
}
Loading

0 comments on commit 2a5012d

Please sign in to comment.