From 0cb33b0526faeb552ea11d47126c574e34d31730 Mon Sep 17 00:00:00 2001 From: dingyongya Date: Fri, 18 Mar 2022 15:01:41 +0800 Subject: [PATCH 1/3] ci: commit lint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加commitlint --- action.yml | 36 ++++++++++++++++++++++++++++++++++++ commitlint.config.js | 22 ++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 action.yml create mode 100644 commitlint.config.js diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..0d88ff7 --- /dev/null +++ b/action.yml @@ -0,0 +1,36 @@ +name: Commit Linter +description: Lints Pull Request commit messages with commitlint +author: Wagner Santos +inputs: + configFile: + description: Commitlint config file. If the file doesn't exist, config-conventional settings will be + loaded as a fallback. + default: ./commitlint.config.js + required: false + firstParent: + description: > + When set to true, we follow only the first parent commit when seeing a merge commit. More info + in git-log docs https://git-scm.com/docs/git-log#Documentation/git-log.txt---first-parent + default: "true" + required: false + failOnWarnings: + description: Whether you want to fail on warnings or not + default: "false" + required: false + helpURL: + description: Link to a page explaining your commit message convention + default: https://github.com/conventional-changelog/commitlint/#what-is-commitlint + required: false + token: + description: > + Personal access token (PAT) used to interact with the GitHub API. By default, the automatic + token provided by GitHub is used. You can see more info about GitHub's default token here: + https://docs.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token + default: ${{ github.token }} + required: false +outputs: + results: + description: The error and warning messages for each one of the analyzed commits +branding: + icon: check-square + color: blue \ No newline at end of file diff --git a/commitlint.config.js b/commitlint.config.js new file mode 100644 index 0000000..103b053 --- /dev/null +++ b/commitlint.config.js @@ -0,0 +1,22 @@ +module.exports = { + extends: ['@commitlint/config-conventional'], + rules: { + 'type-enum': [ + 2, + 'always', + [ + 'build', + 'chore', + 'ci', + 'docs', + 'feat', + 'fix', + 'perf', + 'refactor', + 'revert', + 'style', + 'test', + ], + ], + }, +}; -- Gitee From 03ba03dea07f6dd56ec286da2ced4d5a973d693c Mon Sep 17 00:00:00 2001 From: dingyongya Date: Fri, 18 Mar 2022 15:02:34 +0800 Subject: [PATCH 2/3] =?UTF-8?q?'=E6=B7=BB=E5=8A=A0commitlint'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 19e9b22..618215f 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,10 @@ "dev": "vite example", "build": "vite build --emptyOutDir && npm run build:types && vite build example", "build:types": "rimraf types && tsc -d", - "build:docs": "vite build docs" + "build:docs": "vite build docs", + "prepare": "husky install", + "commit": "git-cz", + "commit:push": "git add . && git-cz && git push" }, "keywords": [ "layui-vue", @@ -39,6 +42,8 @@ "@babel/core": "^7.15.8", "@babel/preset-env": "^7.15.8", "@babel/preset-typescript": "^7.15.0", + "@commitlint/cli": "^16.2.3", + "@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", @@ -46,7 +51,9 @@ "@vitejs/plugin-vue": "^1.9.3", "@vue/compiler-sfc": "^3.2.31", "@vue/server-renderer": "^3.2.31", + "cz-conventional-changelog": "^3.3.0", "escape-html": "^1.0.3", + "husky": "^7.0.4", "less": "^4.1.2", "markdown-it-container": "^3.0.0", "prismjs": "^1.25.0", @@ -64,5 +71,15 @@ "current node", "last 2 versions and > 2%", "ie > 10" - ] + ], + "husky": { + "hooks": { + "commit-msg": "commitlint -E HUSKY_GIT_PARAMS" + } + }, + "config": { + "commitizen": { + "path": "./node_modules/cz-conventional-changelog" + } + } } -- Gitee From 28352b97a583f140042f0ca9cc429576c29d9767 Mon Sep 17 00:00:00 2001 From: dingyongya Date: Fri, 18 Mar 2022 15:05:08 +0800 Subject: [PATCH 3/3] chore: commitlint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加commitlint --- .husky/commit-msg | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .husky/commit-msg diff --git a/.husky/commit-msg b/.husky/commit-msg new file mode 100644 index 0000000..21cf910 --- /dev/null +++ b/.husky/commit-msg @@ -0,0 +1,5 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + +npx --no -- commitlint --edit $1 + -- Gitee