Skip to content

Commit

Permalink
chore: add conventional commits (#1050)
Browse files Browse the repository at this point in the history
* chore: set up conventional commits

* chore: use "simple-git-hooks" over "husky"

* chore: add "commitlint"

* docs: use conventional commits in CONTRIBUTING
  • Loading branch information
kettanaito committed Jan 17, 2022
1 parent 33bf74a commit f1cbdd8
Show file tree
Hide file tree
Showing 7 changed files with 853 additions and 50 deletions.
17 changes: 11 additions & 6 deletions .github/CONTRIBUTING.md
Expand Up @@ -41,22 +41,27 @@ $ yarn start
## Git workflow

```bash
# Navigate to the "master" branch and ensure it's up-to-date
$ git checkout master
# Checkout the default branch and ensure it's up-to-date
$ git checkout main
$ git pull --rebase

# Create a feature branch
$ git checkout -b feature/gql-subscriptions
$ git checkout -b feature/graphql-subscriptions

# Commit the changes
$ git add .
$ git commit -m 'Adds support for GraphQL subscriptions'
$ git commit
# Follow the interactive prompt to compose a commit message

# Push
$ git push -u origin feature/gql-subscriptions
$ git push -u origin feature/graphql-subscriptions
```

Once you have pushed the changes to your remote feature branch, [Create a pull request](https://github.com/open-draft/msw/compare) on GitHub. Undergo the process of code review, where the maintainers of the library will help you get the changes from good to great, and enjoy your implementation merged to `master`.
We are using [Conventional Commits](https://conventionalcommits.org/) naming convention. It helps us automate library releases and ensure clean and standardized commit tree. Please take a moment to read about the said convention before you name your commits.

> **Tip:** running `git commit` will open an interactive prompt in your terminal. Follow the prompt to compose a valid commit message.
Once you have pushed the changes to your remote feature branch, [create a pull request](https://github.com/open-draft/msw/compare) on GitHub. Undergo the process of code review, where the maintainers of the library will help you get the changes from good to great, and enjoy your implementation merged to the default branch.

> Please be respectful when requesting and going through the code review. Everyone on the team is interested in merging quality and well tested code, and we're hopeful that you have the same goal. It may take some time and iterations to get it right, and we will assist you throughout the process.
Expand Down
1 change: 0 additions & 1 deletion .husky/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion .husky/pre-commit

This file was deleted.

3 changes: 3 additions & 0 deletions commitlint.config.js
@@ -0,0 +1,3 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
}
13 changes: 11 additions & 2 deletions package.json
Expand Up @@ -18,8 +18,8 @@
"test:integration": "jest --config=test/jest.config.js --maxWorkers=3",
"test:smoke": "config/scripts/smoke.sh",
"test:ts": "tsc -p test/typings/tsconfig.json",
"prepare": "yarn simple-git-hooks init",
"prepublishOnly": "yarn lint && yarn test:unit && yarn build && yarn test:integration",
"prepare": "husky install",
"postinstall": "node -e \"try{require('./config/scripts/postinstall')}catch(e){}\""
},
"lint-staged": {
Expand Down Expand Up @@ -87,6 +87,8 @@
"devDependencies": {
"@babel/core": "^7.16.0",
"@babel/preset-env": "^7.16.4",
"@commitlint/cli": "^16.0.2",
"@commitlint/config-conventional": "^16.0.0",
"@open-draft/test-server": "^0.2.3",
"@rollup/plugin-commonjs": "^19.0.0",
"@rollup/plugin-inject": "^4.0.3",
Expand All @@ -103,14 +105,15 @@
"@typescript-eslint/parser": "^4.28.3",
"babel-loader": "^8.2.3",
"babel-minify": "^0.5.1",
"commitizen": "^4.2.4",
"cross-env": "^7.0.3",
"cross-fetch": "^3.1.4",
"cz-conventional-changelog": "3.3.0",
"eslint": "^7.30.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.0",
"fs-extra": "^10.0.0",
"fs-teardown": "^0.3.0",
"husky": "^5.1.1",
"jest": "26",
"json-bigint": "^1.0.0",
"lint-staged": "^11.0.1",
Expand All @@ -122,6 +125,7 @@
"rollup": "^2.60.2",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-typescript2": "^0.30.0",
"simple-git-hooks": "^2.7.0",
"ts-jest": "26",
"ts-loader": "^9.2.6",
"ts-node": "^10.1.0",
Expand All @@ -132,5 +136,10 @@
},
"resolutions": {
"chokidar": "3.4.1"
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
}
}
5 changes: 5 additions & 0 deletions simple-git-hooks.js
@@ -0,0 +1,5 @@
module.exports = {
'pre-commit': 'yarn lint-staged',
'prepare-commit-msg': `grep -qE '^[^#]' .git/COMMIT_EDITMSG || (exec < /dev/tty && yarn cz --hook || true)`,
'commit-msg': 'yarn commitlint --edit $1',
}

0 comments on commit f1cbdd8

Please sign in to comment.