Skip to content

Commit

Permalink
workflow: switch to simple-git-hooks (vuejs#7069)
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz authored and chrislone committed Feb 4, 2023
1 parent 9bec393 commit 0fcbcd4
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 64 deletions.
4 changes: 2 additions & 2 deletions .github/contributing.md
Expand Up @@ -36,9 +36,9 @@ Hi! I'm really excited that you are interested in contributing to Vue.js. Before

- Make sure tests pass!

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

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

### Advanced Pull Request Tips

Expand Down
17 changes: 9 additions & 8 deletions package.json
Expand Up @@ -25,20 +25,21 @@
"serve-sfc-playground": "vite packages/sfc-playground --host",
"serve": "serve",
"open": "open http://localhost:5000/packages/template-explorer/local.html",
"preinstall": "node ./scripts/preinstall.js",
"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",
"build-sfc-playground": "cd packages/sfc-playground && npm run build"
"build-sfc-playground": "cd packages/sfc-playground && npm run build",
"preinstall": "node ./scripts/preinstall.js",
"postinstall": "simple-git-hooks"
},
"types": "test-dts/index.d.ts",
"tsd": {
"directory": "test-dts"
},
"gitHooks": {
"pre-commit": "lint-staged",
"commit-msg": "node scripts/verifyCommit.js"
"simple-git-hooks": {
"pre-commit": "pnpm lint-staged",
"commit-msg": "node scripts/verifyCommit.mjs"
},
"lint-staged": {
"*.js": [
"*.{js,json}": [
"prettier --write"
],
"*.ts?(x)": [
Expand Down Expand Up @@ -92,12 +93,12 @@
"semver": "^7.3.2",
"serve": "^12.0.0",
"terser": "^5.15.1",
"simple-git-hooks": "^2.8.1",
"todomvc-app-css": "^2.3.0",
"ts-jest": "^27.0.5",
"tslib": "^2.4.0",
"typescript": "^4.8.0",
"vite": "^3.0.0",
"vue": "workspace:*",
"yorkie": "^2.0.0"
"vue": "workspace:*"
}
}
55 changes: 8 additions & 47 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 9 additions & 7 deletions scripts/verifyCommit.js → scripts/verifyCommit.mjs
@@ -1,12 +1,14 @@
// Invoked on the commit-msg git hook by yorkie.
import chalk from 'chalk'
import { readFileSync } from 'fs'
import path from 'path'
import { fileURLToPath } from 'url'

const chalk = require('chalk')
const msgPath = process.env.GIT_PARAMS
const msg = require('fs')
.readFileSync(msgPath, 'utf-8')
.trim()
const dirname = path.dirname(fileURLToPath(import.meta.url), '..')
const msgPath = path.resolve(dirname, '../.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}/
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()
Expand Down

0 comments on commit 0fcbcd4

Please sign in to comment.