workflow: commitlint move to a simple script

This commit is contained in:
BaboonKing 2024-11-21 17:09:01 +08:00
parent 397be94e79
commit c12853c1a6
5 changed files with 27 additions and 963 deletions

View File

@ -1,3 +0,0 @@
module.exports = {
extends: ["@commitlint/config-conventional"]
};

View File

@ -1 +1 @@
# npx --no-install commitlint -e node scripts/verify-commit.js

View File

@ -55,8 +55,6 @@
"vuedraggable": "^4.1.0" "vuedraggable": "^4.1.0"
}, },
"devDependencies": { "devDependencies": {
"@commitlint/cli": "^17.0.2",
"@commitlint/config-conventional": "^17.0.2",
"@tsconfig/node22": "22.0.0", "@tsconfig/node22": "22.0.0",
"@types/color": "^3.0.3", "@types/color": "^3.0.3",
"@types/crypto-js": "^4.1.1", "@types/crypto-js": "^4.1.1",
@ -69,12 +67,12 @@
"@vue/eslint-config-prettier": "10.1.0", "@vue/eslint-config-prettier": "10.1.0",
"@vue/eslint-config-typescript": "14.1.3", "@vue/eslint-config-typescript": "14.1.3",
"@vue/tsconfig": "0.6.0", "@vue/tsconfig": "0.6.0",
"commitlint": "^17.0.2",
"eslint": "9.15.0", "eslint": "9.15.0",
"eslint-config-prettier": "9.1.0", "eslint-config-prettier": "9.1.0",
"eslint-plugin-vue": "9.31.0", "eslint-plugin-vue": "9.31.0",
"husky": "9.1.7", "husky": "9.1.7",
"npm-run-all2": "7.0.1", "npm-run-all2": "7.0.1",
"picocolors": "1.1.1",
"plop": "4.0.1", "plop": "4.0.1",
"prettier": "3.3.3", "prettier": "3.3.3",
"sass-embedded": "1.81.0", "sass-embedded": "1.81.0",

959
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

22
scripts/verify-commit.js Normal file
View File

@ -0,0 +1,22 @@
// @ts-check
import pico from 'picocolors'
import { readFileSync } from 'node:fs'
import path from 'node: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)(\(.+\))?: .{1,50}/
if (!commitRE.test(msg)) {
console.log()
console.error(
` ${pico.white(pico.bgRed(' ERROR '))} ${pico.red(`invalid commit message format.`)}\n\n` +
pico.red(` Proper commit message format is required for automated changelog generation. Examples:\n\n`) +
` ${pico.green(`feat(compiler): add 'comments' option`)}\n` +
` ${pico.green(`fix(v-model): handle events on blur (close #28)`)}\n\n` +
pico.red(` See .github/commit-convention.md for more details.\n`)
)
process.exit(1)
}