chore: add verify git commit message script
This commit is contained in:
+7
-1
@@ -32,6 +32,7 @@
|
||||
"engines": {
|
||||
"node": ">=12.0.0"
|
||||
},
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"lib": "npm run lint && tsc && vite build --mode lib",
|
||||
@@ -43,7 +44,8 @@
|
||||
"type:check": "tsc --noEmit",
|
||||
"docs:dev": "vitepress dev docs",
|
||||
"docs:build": "vitepress build docs",
|
||||
"docs:preview": "vitepress preview docs"
|
||||
"docs:preview": "vitepress preview docs",
|
||||
"postinstall": "simple-git-hooks"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-typescript": "^10.0.1",
|
||||
@@ -54,6 +56,7 @@
|
||||
"cypress": "^9.5.1",
|
||||
"cypress-file-upload": "^5.0.8",
|
||||
"eslint": "7.32.0",
|
||||
"simple-git-hooks": "^2.8.1",
|
||||
"typescript": "^4.3.2",
|
||||
"vite": "^2.4.2",
|
||||
"vite-plugin-css-injected-by-js": "^2.1.1",
|
||||
@@ -62,5 +65,8 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"prismjs": "^1.27.0"
|
||||
},
|
||||
"simple-git-hooks": {
|
||||
"commit-msg": "node scripts/verifyCommit.js"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// @ts-check
|
||||
import { readFileSync } from 'fs'
|
||||
import path from 'path'
|
||||
|
||||
const msgPath = path.resolve('.git/COMMIT_EDITMSG')
|
||||
const msg = readFileSync(msgPath, 'utf-8').trim()
|
||||
|
||||
const commitRE =
|
||||
/^(revert: )?(feat|fix|docs|dx|style|refactor|perf|test|workflow|build|ci|chore|types|wip|release|improve)(\(.+\))?: .{1,50}/
|
||||
|
||||
if (!commitRE.test(msg)) {
|
||||
console.error(
|
||||
`invalid commit message format.\n\n` +
|
||||
` Proper commit message format is required for automated changelog generation. Examples:\n\n` +
|
||||
` feat: add page header\n` +
|
||||
` fix: IME position error #155\n`
|
||||
)
|
||||
process.exit(1)
|
||||
}
|
||||
@@ -2321,6 +2321,11 @@ signal-exit@^3.0.2:
|
||||
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9"
|
||||
integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==
|
||||
|
||||
simple-git-hooks@^2.8.1:
|
||||
version "2.8.1"
|
||||
resolved "https://registry.yarnpkg.com/simple-git-hooks/-/simple-git-hooks-2.8.1.tgz#05e8306f3211d7eee9f5fdb5cc42521280ee82a9"
|
||||
integrity sha512-DYpcVR1AGtSfFUNzlBdHrQGPsOhuuEJ/FkmPOOlFysP60AHd3nsEpkGq/QEOdtUyT1Qhk7w9oLmFoMG+75BDog==
|
||||
|
||||
slash@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634"
|
||||
|
||||
Reference in New Issue
Block a user