From cd95cd3ec896be33b91ac340f031b25f06a4e162 Mon Sep 17 00:00:00 2001 From: youncccat <1306036576@qq.com> Date: Fri, 28 May 2021 23:34:00 +0800 Subject: [PATCH 1/2] [Feat::hooks] config husky to get commit message before send commit --- .husky/_/.gitignore | 1 + .husky/_/husky.sh | 30 ++++++++++++++++++++++++++++++ .husky/commit-msg | 4 ++++ 3 files changed, 35 insertions(+) create mode 100644 .husky/_/.gitignore create mode 100644 .husky/_/husky.sh create mode 100755 .husky/commit-msg diff --git a/.husky/_/.gitignore b/.husky/_/.gitignore new file mode 100644 index 0000000..c9cdc63 --- /dev/null +++ b/.husky/_/.gitignore @@ -0,0 +1 @@ +_ \ No newline at end of file diff --git a/.husky/_/husky.sh b/.husky/_/husky.sh new file mode 100644 index 0000000..ca2720e --- /dev/null +++ b/.husky/_/husky.sh @@ -0,0 +1,30 @@ +#!/bin/sh +if [ -z "$husky_skip_init" ]; then + debug () { + [ "$HUSKY_DEBUG" = "1" ] && echo "husky (debug) - $1" + } + + readonly hook_name="$(basename "$0")" + debug "starting $hook_name..." + + if [ "$HUSKY" = "0" ]; then + debug "HUSKY env variable is set to 0, skipping hook" + exit 0 + fi + + if [ -f ~/.huskyrc ]; then + debug "sourcing ~/.huskyrc" + . ~/.huskyrc + fi + + export readonly husky_skip_init=1 + sh -e "$0" "$@" + exitCode="$?" + + if [ $exitCode != 0 ]; then + echo "husky - $hook_name hook exited with code $exitCode (error)" + exit $exitCode + fi + + exit 0 +fi diff --git a/.husky/commit-msg b/.husky/commit-msg new file mode 100755 index 0000000..0bd658f --- /dev/null +++ b/.husky/commit-msg @@ -0,0 +1,4 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + +npx --no-install commitlint --edit "$1" From 8910c651000a10bdcc245d3fcf6f577e4186149d Mon Sep 17 00:00:00 2001 From: youncccat <1306036576@qq.com> Date: Fri, 28 May 2021 23:34:36 +0800 Subject: [PATCH 2/2] [Feat] integrate wizardoc convention --- commitlint.config.js | 3 +++ package.json | 1 + yarn.lock | 12 ++++++++++++ 3 files changed, 16 insertions(+) diff --git a/commitlint.config.js b/commitlint.config.js index e69de29..917a7e3 100644 --- a/commitlint.config.js +++ b/commitlint.config.js @@ -0,0 +1,3 @@ +module.exports = { + extends: 'wizardoc' +} \ No newline at end of file diff --git a/package.json b/package.json index 596dd8b..e2a8aff 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "@commitlint/config-conventional": "^12.1.4", "@commitlint/types": "^12.1.4", "@types/jest": "^26.0.23", + "commitlint-config-wizardoc": "^1.0.0", "jest": "^27.0.1", "jest-config": "^27.0.1", "lerna": "^4.0.0", diff --git a/yarn.lock b/yarn.lock index 19e2b77..9ec95d9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2224,6 +2224,18 @@ combined-stream@^1.0.6, combined-stream@^1.0.8, combined-stream@~1.0.6: dependencies: delayed-stream "~1.0.0" +commitlint-config-wizardoc@^1.0.0: + version "1.0.0" + resolved "https://registry.npmjs.org/commitlint-config-wizardoc/-/commitlint-config-wizardoc-1.0.0.tgz#d8f4372b75667ee8b553f1b6fa6eed9553e42a93" + integrity sha512-ecOER5XBrTZVVIzRyXfGQMoe8C4OQevP4lYFK/HwB5jhFgCAX1TXiASYQLwgq4iU1hQcHMBc2inHVitVqRadHA== + dependencies: + commitlint-plugin-wizardoc-rules "^1.0.0" + +commitlint-plugin-wizardoc-rules@^1.0.0: + version "1.0.0" + resolved "https://registry.npmjs.org/commitlint-plugin-wizardoc-rules/-/commitlint-plugin-wizardoc-rules-1.0.0.tgz#3f6e8a42d42b31c7897a91bc224b85132768324b" + integrity sha512-V7NT3egc4LXBYeNtKnYYFtCAb8/3vlea9xNlky4r41HUHC9mx5w6mnKe7NQAucllkLGyYDL/FRt51UiyujrYPg== + compare-func@^2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/compare-func/-/compare-func-2.0.0.tgz"