Git Product home page Git Product logo

cz-emoji's Introduction

cz-emoji

Commitizen adapter formatting commit messages using emojis.

cz-emoji allows you to easily use emojis in your commits using commitizen.

? Select the type of change you are committing: (Use arrow keys)
โฏ feature   ๐ŸŒŸ  A new feature
  fix       ๐Ÿž  A bug fix
  docs      ๐Ÿ“š  Documentation change
  refactor  ๐ŸŽจ  A code refactoring change
  chore     ๐Ÿ”ฉ  A chore change

Install

Globally

npm install --global cz-emoji

# set as default adapter for your projects
echo '{ "path": "cz-emoji" }' > ~/.czrc

Locally

npm install --save-dev cz-emoji

Add this to your package.json:

"config": {
  "commitizen": {
    "path": "cz-emoji"
  }
}

โ„น๏ธ pnpm requires you to specify node_modules/cz-emoji.

Usage

$ git cz

Customization

By default cz-emoji comes ready to run out of the box. Uses may vary, so there are a few configuration options to allow fine tuning for project needs.

How to

Configuring cz-emoji can be handled in the users home directory (~/.czrc) for changes to impact all projects or on a per project basis (package.json). Simply add the config property as shown below to the existing object in either of the locations with your settings for override.

{
  "config": {
    "cz-emoji": {}
  }
}

Configuration Options

Types

By default cz-emoji comes preconfigured with the Gitmoji types.

An Inquirer.js choices array:

{
  "config": {
    "cz-emoji": {
      "types": [
        {
          "emoji": "๐ŸŒŸ",
          "code": ":star2:",
          "description": "A new feature",
          "name": "feature"
        }
      ]
    }
  }
}

Scopes

An Inquirer.js choices array:

{
  "config": {
    "cz-emoji": {
      "scopes": ["home", "accounts", "ci"]
    }
  }
}

Symbol

A boolean value that allows for an using a unicode value rather than the default of Gitmoji markup in a commit message. The default for symbol is false.

{
  "config": {
    "cz-emoji": {
      "symbol": true
    }
  }
}

Skip Questions

An array of questions you want to skip:

{
  "config": {
    "cz-emoji": {
      "skipQuestions": ["scope", "issues"]
    }
  }
}

You can skip the following questions: scope, body, issues, and breaking. The type and subject questions are mandatory.

Customize Questions

An object that contains overrides of the original questions:

{
  "config": {
    "cz-emoji": {
      "questions": {
        "body": "This will be displayed instead of original text"
      }
    }
  }
}

Customize the subject max length

The maximum length you want your subject has

{
  "config": {
    "cz-emoji": {
      "subjectMaxLength": 200
    }
  }
}

Examples

Commitlint

Commitlint can be set to work with this package with the following configuration:

commitlint.config.js

const pkg = require('./package.json')

// Check if the user has configured the package to use conventional commits.
const isConventional = pkg.config ? pkg.config['cz-emoji']?.conventional : false

// Regex for default and conventional commits.
const RE_DEFAULT_COMMIT = /^(?::.*:|(?:\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff]))\s(?<emoji>\((?<scope>.*)\)\s)?.*$/gm
const RE_CONVENTIONAL_COMMIT = /^(?<type>\w+)(?:\((?<scope>\w+)\))?:\s(?<emoji>:.*:|(?:\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff]))\s.*$/gm

module.exports = {
  rules: {
    'cz-emoji': [2, 'always']
  },
  plugins: [
    {
      rules: {
        'cz-emoji': ({ raw }) => {
          const isValid = isConventional
            ? RE_CONVENTIONAL_COMMIT.test(raw)
            : RE_DEFAULT_COMMIT.test(raw)

          const message = isConventional
            ? `Your commit message should follow conventional commit format.`
            : `Your commit message should be: <emoji> (<scope>)?: <subject>`

          return [isValid, message]
        }
      }
    }
  ]
}

Let me know if you are interested in having the above configuration published as a commitlint plugin.

Other projects

  • Fauda: configuration made simple.
  • Commitizen Emoji: Commitizen adapter formatting commit messages using emojis.
  • Reading Time: Medium's like reading time estimation.

License

MIT ยฉ Nicolas Gryman

cz-emoji's People

Contributors

ngryman avatar dependabot[bot] avatar harlan-zw avatar kstolte avatar greenkeeper[bot] avatar anoff avatar byronmejia avatar spoutnik97 avatar imawizrd avatar jiangweixian avatar jb1905 avatar matissjanis avatar micgro42 avatar reekenx avatar rikardgehlin avatar rodrimaia avatar simrobin avatar trevorburnham avatar clumsy-coder avatar nshtg avatar vecpeng avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.