From befd0985dca11714a137035704704409d4f5a44e Mon Sep 17 00:00:00 2001 From: dingyongya Date: Wed, 16 Feb 2022 15:53:40 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20commitlint=20=E9=9B=86=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit commitlint 集成测试 BREAKING CHANGE: 新增 commitlint.config.js .husky 文件 #I4O3H0 --- .husky/commit-msg | 4 ++++ commitlint.config.js | 21 +++++++++++++++++++++ package.json | 22 +++++++++++++++++++--- 3 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 .husky/commit-msg create mode 100644 commitlint.config.js diff --git a/.husky/commit-msg b/.husky/commit-msg new file mode 100644 index 00000000..e8511eae --- /dev/null +++ b/.husky/commit-msg @@ -0,0 +1,4 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + +npx --no-install commitlint --edit $1 diff --git a/commitlint.config.js b/commitlint.config.js new file mode 100644 index 00000000..b84c25ca --- /dev/null +++ b/commitlint.config.js @@ -0,0 +1,21 @@ +module.exports = { + extends: ["@commitlint/config-conventional"], + rules: { + "type-enum": [2, + "always", + [ + 'build', + 'chore', + 'ci', + 'docs', + 'feat', + 'fix', + 'perf', + 'refactor', + 'revert', + 'style', + 'test' + ] + ], + }, +}; diff --git a/package.json b/package.json index f0cd142c..0ee49b2e 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,10 @@ "build:types": "rimraf types && tsc -d", "build:example": "vite build example", "lint:eslint": "eslint 'src/**/*.{vue,ts,tsx}' --fix", - "lint:prettier": "prettier --write 'src/**/*'" + "lint:prettier": "prettier --write \"src/**/*\"", + "prepare": "husky install", + "postinstall": "npm run prepare", + "commit": "git-cz" }, "dependencies": { "@layui/hooks-vue": "^0.1.6", @@ -46,6 +49,8 @@ "@babel/core": "^7.15.8", "@babel/preset-env": "^7.15.8", "@babel/preset-typescript": "^7.15.0", + "@commitlint/cli": "^16.2.1", + "@commitlint/config-conventional": "^16.2.1", "@rollup/plugin-babel": "^5.3.0", "@types/markdown-it": "^12.2.3", "@types/markdown-it-container": "^2.0.4", @@ -56,12 +61,13 @@ "@vue/compiler-sfc": "^3.2.30", "@vue/server-renderer": "^3.2.30", "commitizen": "^4.2.4", - "cz-conventional-changelog": "3.3.0", + "cz-conventional-changelog": "^3.3.0", "escape-html": "^1.0.3", "eslint": "^8.5.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-prettier": "^4.0.0", "eslint-plugin-vue": "^8.2.0", + "husky": "^7.0.4", "less": "^4.1.2", "markdown-it-container": "^3.0.0", "prettier": "^2.5.1", @@ -81,5 +87,15 @@ "current node", "last 2 versions and > 2%", "ie > 10" - ] + ], + "config": { + "commitizen": { + "path": "./node_modules/cz-conventional-changelog" + } + }, + "husky": { + "hooks": { + "commit-msg": "commitlint -E HUSKY_GIT_PARAMS" + } + } } From b77f9d28031a92af16a4bbccc241be275b869f32 Mon Sep 17 00:00:00 2001 From: dingyongya Date: Wed, 16 Feb 2022 15:59:35 +0800 Subject: [PATCH 2/2] =?UTF-8?q?chore:=20=E6=B7=BB=E5=8A=A0commit:push?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 运行 npm run commit:push 可以执行一系列git 提交操作 --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 0ee49b2e..4b10852b 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,8 @@ "lint:prettier": "prettier --write \"src/**/*\"", "prepare": "husky install", "postinstall": "npm run prepare", - "commit": "git-cz" + "commit": "git-cz", + "commit:push": "git add . && git-cz && git push" }, "dependencies": { "@layui/hooks-vue": "^0.1.6",