SandroMiguel / standard-commit

Guidelines to standardize commit messages

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Standard Commit

Guidelines to standardize commit messages

license

Features

  • Validates commit messages against the Conventional Commits specification.
  • Formats commit messages using a series of prompts.
  • Automates the generation of a CHANGELOG.md file.
  • Bumps the version and generates a new release.

Installation

Step 1 - Install Dependencies

Install the necessary dependencies locally:

yarn add --dev husky @commitlint/cli @commitlint/config-conventional cz-conventional-changelog

Step 2 - Install commitizen globally

Install commitizen globally to enable standardized commit message formatting:

sudo yarn global add commitizen

Step 3 - Update package.json

Update your project's package.json file to configure commitizen:

{
  ...

  "config": {
    "commitizen": {
        "path": "./node_modules/cz-conventional-changelog",
        "disableScopeLowerCase": true
    }
  },

  ...
}

Step 4 - Configure Commitlint

Create a commitlint.config.js file in your project root directory to configure commitlint:

module.exports = {
  extends: ["@commitlint/config-conventional"],
  rules: {
    "scope-case": [0],
  },
};

Step 5 - Setup husky

Edit package.json > prepare script and run it once:

npm pkg set scripts.prepare="husky install"
yarn prepare

Add a hook to run commitlint

npx husky add .husky/commit-msg "yarn commitlint --edit"

Step 6 - Configure commitizen

Configure commitizen to use the conventional changelog adapter:

commitizen init cz-conventional-changelog --save-dev --save-exact

Step 7 - Setup Release Please

Automate release management with Release Please:

Deploy release-please with GitHub Action by creating a .github/workflows/release-please.yml file with these contents:

on:
    push:
        branches:
            - main
name: release-please
jobs:
    release-please:
        runs-on: ubuntu-latest
        steps:
            - uses: google-github-actions/release-please-action@v3
              with:
                  release-type: node
                  package-name: release-please-action

Make sure you have the correct Workflow permissions on your repository (Settings > Actions > General):

Workflow permissions

Usage

Standard Commit simplifies the process of writing standardized commit messages:

Commitizen template

Using Commitizen

Instead of git commit, use git cz to open a wizard and generate a standardized commit message:

git add .
git cz
git push --follow-tags

Normal commit command

You can still use git commit ... but the commit will fail if the commit message is not properly formatted.

git add .
git commit -m "feat(blog): add comment section"
git push --follow-tags

Credits

Contributing

Want to contribute? All contributions are welcome. Read the contributing guide.

Questions

If you have questions tweet me at @sandro_m_m or open an issue.

License

This project is licensed under the MIT License - see the LICENSE file for details

**~ sharing is caring ~**

About

Guidelines to standardize commit messages

License:MIT License


Languages

Language:JavaScript 100.0%