Add commitizen script to package.json #12730
Description
One barrier to contributing is getting the commit message conventions right the first time. I don't expect I need to justify that this is a challenge and would be nice to make easier.
Enter commitizen by @jimthedev. Long story short:
- Add
commitizen
andcz-conventional-changelog
todevDependencies
"devDependencies": {
"commitizen": "^1.0.4",
"cz-conventional-changelog": "1.1.0"
}
- Add
czConfig
topackage.json
to tellcommitizen
to use thecz-conventional-changelog
:
"czConfig": {
"path": "node_modules/cz-conventional-changelog"
}
- Add
commit
npm script that utilizes thegit-cz
binary installed fromcommitizen
:
{
"scripts": {
"commit": "git-cz"
}
}
Then, just update documentation to tell people to run npm run commit
after they've staged the changes they want to commit. They will be greeted by the beautiful step-by-step wizard to fill in to create their perfectly formatted commit message:
A few comments to address some possible concerns:
Q: What if I don't want to use some weird wizard? I want to have total control over my commit message!
A: You don't have to use it. Everything will work just fine using the regular git commit flow you're used to.
Q: I use a GUI like SourceTree. What if I don't want to do this?
A: See answer above.
I've been using commitizen for a while at work (though I use the cz-jira-smart-commit plugin) and it's be really great. I added it to angular-formly and so far it's been quite helpful. I think that people would find the barrier to contributing lowered even a little bit with something like this.
As a side-note, you could take this a step further and integrate something like ghooks by @gtramontina to ensure that people don't attempt to commit with a message that doesn't follow the conventions. I added this to angular-formly too: config, script. But that's probably another story...
Anyway, I was just thinking of ways to lower the barrier to contributing. Hope this sparks ideas at least :-)