This howto will setup your project with automatic changelog generation, based on your commit messages.
Setup git hooks with husky
- Install husky
yarn add -D husky
- Enable git hooks
npx husky install
- Add this to your
package.json
"scripts": { "prepare": "husky install" }
To enforce your commits to follow the Conventional Commits Specification we will use @commitlint/config-conventional and force it via a git hook.
- Install commitlint
yarn add -D @commitlint/{cli,config-conventional}
- Add commit-msg git hook via husky
npx husky add .husky/commit-msg 'npx --no-install commitlint --edit $1'
- Create a
.commitlintrc.json
file which extends the rules from config-conventional{ "extends": ["@commitlint/config-conventional"] }
Finally, standard-version will read your commits to generate a changelog
- Install
yarn add -D standard-version
- Add some scripts to your package.json
ℹ️ More informations about available commands on standard-version's doc
"scripts": { "release": "standard-version $1", "release:minor": "standard-version --release-as minor", "release:patch": "standard-version --release-as patch", "release:major": "standard-version --release-as major" }
- Add and adapt the standard-version configuration into your
package.json
"standard-version": { "types": [ { "type": "feat", "section": "Features" }, { "type": "fix", "section": "Bug Fixes" }, { "type": "chore", "section": "Chore changes:" }, { "type": "docs", "section": "Documentation changes:" }, { "type": "style", "hidden": true }, { "type": "refactor", "section": "Refactors:" }, { "type": "perf", "hidden": true }, { "type": "test", "section": "Tests" } ] }
Add a fancy touch to your commits with devmoji, it will automatically add emojis to your commits.
- Install devmoji
yarn add -D devmoji
- Add git hook for devmoji
npx husky add .husky/prepare-commit-msg "npx devmoji -e --lint" npx husky install