Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
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

Description

@kentcdodds

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions