From 3878a438b0088bb78f5f23b03ef17415060acc23 Mon Sep 17 00:00:00 2001 From: "142vip.cn" <2237221210@qq.com> Date: Mon, 12 May 2025 19:25:32 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=BC=95=E5=85=A5`@142vip/commit-linte?= =?UTF-8?q?r`=E4=BE=9D=E8=B5=96=EF=BC=8C=E5=A2=9E=E5=8A=A0`check:commit`?= =?UTF-8?q?=E5=91=BD=E4=BB=A4=EF=BC=8C=E6=A0=A1=E9=AA=8C`commit`=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=20(#147)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 6 ++++-- pnpm-lock.yaml | 3 +++ scripts/core/mark-map.ts | 2 +- scripts/core/verify-commit.ts | 15 +++++++++++++++ 4 files changed, 23 insertions(+), 3 deletions(-) create mode 100755 scripts/core/verify-commit.ts diff --git a/package.json b/package.json index 8da1f02..d6133eb 100644 --- a/package.json +++ b/package.json @@ -26,9 +26,11 @@ "build": "npx vuepress build docs --clean-temp --clean-cache", "build:proxy": "NEED_PROXY=true npx vuepress build docs --clean-temp --clean-cache", "build:mark-map": "npx node --loader ts-node/esm --no-warnings scripts/core/mark-map.ts", - "release": "npx fa release --vip --check-branch next --check-branch main" + "release": "npx fa release --vip --check-branch next --check-branch main", + "check:commit": "npx node --loader ts-node/esm --no-warnings scripts/core/verify-commit.ts" }, "devDependencies": { + "@142vip/commit-linter": "0.0.1-alpha.1", "@142vip/eslint-config": "0.0.1-alpha.4", "@142vip/fairy-cli": "0.0.3-alpha.24", "@142vip/utils": "0.0.1-alpha.36", @@ -43,6 +45,6 @@ }, "simple-git-hooks": { "pre-commit": "pnpm lint:fix", - "prepare-commit-msg": "pnpm build" + "commit-msg": "pnpm check:commit" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fa8cbc0..c80e25e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,6 +8,9 @@ importers: .: devDependencies: + '@142vip/commit-linter': + specifier: 0.0.1-alpha.1 + version: 0.0.1-alpha.1(@types/node@22.15.17) '@142vip/eslint-config': specifier: 0.0.1-alpha.4 version: 0.0.1-alpha.4(@typescript-eslint/utils@8.32.0(eslint@9.23.0(jiti@2.4.2))(typescript@5.8.3))(@vue/compiler-sfc@3.5.13)(jiti@2.4.2)(typescript@5.8.3) diff --git a/scripts/core/mark-map.ts b/scripts/core/mark-map.ts index dc9f3a0..5862df5 100644 --- a/scripts/core/mark-map.ts +++ b/scripts/core/mark-map.ts @@ -8,7 +8,7 @@ const markMapTargetPath = VipNodeJS.pathJoin(__dirname, 'docs/.vuepress/public/m /** * 扫描目录 */ -function scanDirectory(directory: string, fileType: string) { +function scanDirectory(directory: string, fileType: string): (string | null)[] { const fileList = VipNodeJS.readdirSync(directory) return fileList diff --git a/scripts/core/verify-commit.ts b/scripts/core/verify-commit.ts new file mode 100755 index 0000000..7eed874 --- /dev/null +++ b/scripts/core/verify-commit.ts @@ -0,0 +1,15 @@ +import { commitLiner } from '@142vip/commit-linter' +import { VipColor, VipConsole, vipLogger } from '@142vip/utils' + +/** + * 验证Git Commit信息 + */ +async function verifyCommitMain(): Promise { + const { type, scope, subject, commit } = commitLiner() + + // 提交符合规范,打印相关信息 + VipConsole.log(`type: ${type}, scope: ${scope}, subject: ${subject}`) + vipLogger.logByBlank(`${VipColor.greenBright('Git Commit: ')} ${VipColor.green(commit)}`) +} + +void verifyCommitMain()