Skip to content

Commit dc9f994

Browse files
authored
workflow: switch to simple-git-hooks (#7069)
1 parent 71977ec commit dc9f994

File tree

4 files changed

+28
-64
lines changed

4 files changed

+28
-64
lines changed

.github/contributing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ Hi! I'm really excited that you are interested in contributing to Vue.js. Before
3636

3737
- Make sure tests pass!
3838

39-
- Commit messages must follow the [commit message convention](./commit-convention.md) so that changelogs can be automatically generated. Commit messages are automatically validated before commit (by invoking [Git Hooks](https://git-scm.com/docs/githooks) via [yorkie](https://github.com/yyx990803/yorkie)).
39+
- Commit messages must follow the [commit message convention](./commit-convention.md) so that changelogs can be automatically generated. Commit messages are automatically validated before commit (by invoking [Git Hooks](https://git-scm.com/docs/githooks) via [simple-git-hooks](https://github.com/toplenboren/simple-git-hooks)).
4040

41-
- No need to worry about code style as long as you have installed the dev dependencies - modified files are automatically formatted with Prettier on commit (by invoking [Git Hooks](https://git-scm.com/docs/githooks) via [yorkie](https://github.com/yyx990803/yorkie)).
41+
- No need to worry about code style as long as you have installed the dev dependencies - modified files are automatically formatted with Prettier on commit (by invoking [Git Hooks](https://git-scm.com/docs/githooks) via [simple-git-hooks](https://github.com/toplenboren/simple-git-hooks)).
4242

4343
### Advanced Pull Request Tips
4444

package.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,21 @@
2525
"serve-sfc-playground": "vite packages/sfc-playground --host",
2626
"serve": "serve",
2727
"open": "open http://localhost:5000/packages/template-explorer/local.html",
28-
"preinstall": "node ./scripts/preinstall.js",
2928
"prebuild-sfc-playground": "node scripts/build.js compiler reactivity-transform shared -af cjs && node scripts/build.js runtime reactivity shared -af esm-bundler && node scripts/build.js vue -f esm-bundler-runtime && node scripts/build.js vue -f esm-browser-runtime && node scripts/build.js compiler-sfc server-renderer -f esm-browser",
30-
"build-sfc-playground": "cd packages/sfc-playground && npm run build"
29+
"build-sfc-playground": "cd packages/sfc-playground && npm run build",
30+
"preinstall": "node ./scripts/preinstall.js",
31+
"postinstall": "simple-git-hooks"
3132
},
3233
"types": "test-dts/index.d.ts",
3334
"tsd": {
3435
"directory": "test-dts"
3536
},
36-
"gitHooks": {
37-
"pre-commit": "lint-staged",
38-
"commit-msg": "node scripts/verifyCommit.js"
37+
"simple-git-hooks": {
38+
"pre-commit": "pnpm lint-staged",
39+
"commit-msg": "node scripts/verifyCommit.mjs"
3940
},
4041
"lint-staged": {
41-
"*.js": [
42+
"*.{js,json}": [
4243
"prettier --write"
4344
],
4445
"*.ts?(x)": [
@@ -92,12 +93,12 @@
9293
"semver": "^7.3.2",
9394
"serve": "^12.0.0",
9495
"terser": "^5.15.1",
96+
"simple-git-hooks": "^2.8.1",
9597
"todomvc-app-css": "^2.3.0",
9698
"ts-jest": "^27.0.5",
9799
"tslib": "^2.4.0",
98100
"typescript": "^4.8.0",
99101
"vite": "^3.0.0",
100-
"vue": "workspace:*",
101-
"yorkie": "^2.0.0"
102+
"vue": "workspace:*"
102103
}
103104
}

pnpm-lock.yaml

Lines changed: 8 additions & 47 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/verifyCommit.js renamed to scripts/verifyCommit.mjs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
// Invoked on the commit-msg git hook by yorkie.
1+
import chalk from 'chalk'
2+
import { readFileSync } from 'fs'
3+
import path from 'path'
4+
import { fileURLToPath } from 'url'
25

3-
const chalk = require('chalk')
4-
const msgPath = process.env.GIT_PARAMS
5-
const msg = require('fs')
6-
.readFileSync(msgPath, 'utf-8')
7-
.trim()
6+
const dirname = path.dirname(fileURLToPath(import.meta.url), '..')
7+
const msgPath = path.resolve(dirname, '../.git/COMMIT_EDITMSG')
8+
const msg = readFileSync(msgPath, 'utf-8').trim()
89

9-
const commitRE = /^(revert: )?(feat|fix|docs|dx|style|refactor|perf|test|workflow|build|ci|chore|types|wip|release)(\(.+\))?: .{1,50}/
10+
const commitRE =
11+
/^(revert: )?(feat|fix|docs|dx|style|refactor|perf|test|workflow|build|ci|chore|types|wip|release)(\(.+\))?: .{1,50}/
1012

1113
if (!commitRE.test(msg)) {
1214
console.log()

0 commit comments

Comments
 (0)