Prepare a repository to be conventional commit ready with:
- commitlint - Lint commit messages
- husky - Modern native git hooks made easy
- commitizen - Prompt to fill out required fields at commit time
# Installation
npm install @commitlint/{cli,config-conventional} --save-dev
# Configuration
echo "module.exports = { extends: [\"@commitlint/config-conventional\"] };" > commitlint.config.js
# Installation
npm install husky --save-dev
# Enable git hooks
npx husky install
# Git hooks enabled after install
npm set-script prepare "husky install"
# Git commit can use git cz hook
npx husky add .husky/prepare-commit-msg "exec < /dev/tty && git cz --hook || true"
# Add commitlint in husky
npx husky add .husky/commit-msg 'npx --no-install commitlint --edit'
sed 's/--edit/--edit $1/g' -i .husky/commit-msg
# Installation
npm install commitizen --save-dev
# Make project use cz-conventional-changelog adapter
commitizen init cz-conventional-changelog --save-dev --save-exact
Use git commit
or git cz
or cz
or cz commit
to commit.