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()