Created
February 18, 2021 02:32
-
-
Save lukesmurray/46c98b315d281276407e671a278d6132 to your computer and use it in GitHub Desktop.
Setup Conventional Commits
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# install commitizen, standard-version, husky, and commitilnt | |
yarn add -D commitizen standard-version husky @commitlint/{config-conventional,cli} | |
# initialize commitizen | |
./node_modules/.bin/commitizen init cz-conventional-changelog --yarn --save-dev --save-exact --force | |
# install husky | |
yarn husky install | |
# prepare commit msg with commitizen | |
yarn husky add .husky/prepare-commit-msg "exec < /dev/tty && git cz --hook || true" | |
# check commit messages with commitlint | |
yarn husky add .husky/commit-msg "yarn commitlint --edit $1" | |
# Configure commitlint to use conventional config | |
echo "add the following to your package.json" | |
cat << EOF | |
"commitlint": { | |
"extends": [ | |
"@commitlint/config-conventional" | |
] | |
} | |
EOF | |
# install husky and manage releases with standard-version | |
echo "add the following to your package.json scripts" | |
cat << EOF | |
"postinstall": "husky install", | |
"prepublishOnly": "pinst --disable", | |
"postpublish": "pinst --enable", | |
"release": "HUSKY=0 standard-version --sign", | |
EOF | |
# if using lerna you can use the following to increment the version | |
# > HUSKY=0 lerna version --conventional-commits --sign-git-commit --sign-git-tag | |
# you can remove standard version and delete the release script | |
# > yarn remove standard-version | |
# to cut your first release run | |
# npm run release -- --first-release |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment