Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Add commitizen script to package.json #12730

Closed
kentcdodds opened this issue Sep 2, 2015 · 5 comments
Closed

Add commitizen script to package.json #12730

kentcdodds opened this issue Sep 2, 2015 · 5 comments

Comments

@kentcdodds
Copy link

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:

  1. Add commitizen and cz-conventional-changelog to devDependencies
"devDependencies": {
   "commitizen": "^1.0.4",
    "cz-conventional-changelog": "1.1.0"
}
  1. Add czConfig to package.json to tell commitizen to use the cz-conventional-changelog:
"czConfig": {
  "path": "node_modules/cz-conventional-changelog"
}
  1. Add commit npm script that utilizes the git-cz binary installed from commitizen:
{
  "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:

git-cz


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 :-)

@jimthedev
Copy link

Quick update, now you use config.commitizen.path in package.json.

@ocombe
Copy link
Contributor

ocombe commented Oct 28, 2015

This only work for people who commit via command line, what happens if you use SourceTree for example?

@kentcdodds
Copy link
Author

You have to do the same thing you have to do now... Code it manually. This is only useful for people who will run the command. But I don't see that as a drawback...........

@jimthedev
Copy link

Yes, commitizen is completely opt in. There will still need to be server side validation hooks to verify that people are following the convention. This simply makes it easier for people to commit to the angular project without needing to worry if they followed the commit message convention.

@Narretz
Copy link
Contributor

Narretz commented Oct 30, 2015

Closed by a179757

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants