Giter Site home page Giter Site logo

folke / devmoji Goto Github PK

View Code? Open in Web Editor NEW
289.0 2.0 20.0 3.8 MB

:robot: :rocket: :sparkles: Emojify your conventional commits with Devmoji

Home Page: https://www.npmjs.com/package/devmoji

License: Apache License 2.0

JavaScript 4.09% TypeScript 95.85% Shell 0.06%
conventional-commits gitmoji emoji commit commit-message cli conventional-changelog

devmoji's Introduction

✨ Devmoji

Node CI npm GitHub GitHub top language Renovate

Using Conventional Commits ⭐ as a standard for your commit messages, makes Semantic Versioning πŸ”– as easy as can be, with tools like Conventional Changelog πŸ“„, Standard Version πŸ”– and Semantic Release πŸ“¦πŸš€

Devmoji is a command line tool that adds color 🌈 to conventional commits, using emojis inspired by Gitmoji 😜

Some of the things Devmoji can do:

  • emojify: convert input between diferent emoji formats unicode, shortcode and devmoji. devmoji are easy to remember aliases like: :test:, :refactor:, :docs:, :security instead of hard to remember emoji codes
  • git commit: install a prepare-commit-msg commit hook to ✨ automagically emojify and lints your commit message
  • git log: emojify and colorify the output of git log even for projects not using emojis

What does it look like?

πŸ“¦ Installation

Install with npm or yarn

globally

npm install -g devmoji
yarn global add devmoji

locally inside your project. use with npx devmoji

npm install --dev devmoji
yarn add --dev devmoji

See --edit for information on how to setup a git commit hook.

πŸ’₯ Usage

devmoji --help

$ devmoji --help
Usage: devmoji [options]

Options:
  -c|--config <file>    location of the devmoji.config.js file
  -l|--list             list all known devmojis
  -t|--text <text>      text to format. reads from stdin when omitted
  --lint                lint the conventional commit. disabled for --log
  -f|--format <format>  format should be one of: unicode, shortcode, devmoji (default: "unicode")
  --commit              automatically add a devmoji to the conventional commit header (default: true)
  --no-commit           do not process conventional commit headers
  -e|--edit             read last commit message from .git/COMMIT_EDITMSG in the git root
  --log                 format conventional commits in text similar to git log
  --color               use colors for formatting. Colors are enabled by default, unless output is piped to another command (default: true)
  --no-color            don't use colors
  --version             output the version number
  -h, --help            output usage information

devmoji emojify

Emojify text using --text or piping it to stdin. Input can be a combination using any valid format. Output formats:

Format Description
shortcode outputs Github Markdown short codes like :sparkles: :rocket:
unicode outputs the emoji unicode symbols like ✨ πŸš€
devmoji outputs the devmoji shortcodes like :feat: :chore-release:
strip removes all emoji from the input

The default format is unicode, since this can be used pretty much everywhere and has the shortest text length (relevant for commit messages)

$ echo "This is a :test: of the first :release: :boom: ✨" | devmoji --format shortcode
This is a :rotating_light: of the first :rocket: :boom: :sparkles:

$ echo "This is a :test: of the first :release: :boom: :sparkles:" | devmoji --format unicode
This is a 🚨 of the first πŸš€ πŸ’₯ ✨

$ echo "πŸš€ :boom: :sparkles:" | devmoji --format devmoji
:chore-release: :breaking: :feat:

$ echo "test πŸš€ :boom: :sparkles: :security:" | devmoji --format strip
test

devmoji --commit

Automagically ✨ emojifies a conventional commit message of the format type(scope): something useful, using the following pseudo code:

if (exists(":type-scope:")) return emoji(":type-scope:")

if (exists(":type:") && exists(":scope:"))
  return emoji(":type:") + emoji(":scope:")

if (exists(":type:")) return emoji(":type:")

example ouput:

$ echo "feat: added a new feature :smile:" | devmoji --commit
feat: ✨ added a new feature πŸ˜„

$ echo "chore(release): 1.1.1" | devmoji --commit
chore(release): πŸš€ 1.1.1

$ echo "fix(security): upgraded lodash" | devmoji --commit
fix(security): πŸ› πŸ”’ upgraded lodash

devmoji --lint

Lints your commit message to see if they are valid conventional commits

devmoji --edit

Formats and saves your current commit message .git/COMMIT_EDITMSG. This is only really useful as a prepare-commit-msg or commit-msg hook.

When to use what hook?

  • prepare-commit-msg: use this if you do not use Devmnojis --lint option and want to use it with something like commitlint instead.
  • commit-msg: use this hook if you also want to use Devmoji for linting

Configuration using Husky

# make sure husky hooks are installed
$ npx husky install

# add a hook for devmoji
$ npx husky add .husky/prepare-commit-msg "npx devmoji -e --lint"

Configuration using Yorkie

// package.json
{
  "gitHooks": {
    "prepare-commit-msg": "devmoji -e --lint"
  }
}

If you installed Devmoji locally in your project as a dev dependency, then use something like npx --no-install devmoji -e instead of the commands above.

Alternatively, if you don't want to use Husky or Yorkie, you can manually create the git hooks.

devmoji --log

Works similar to --commit, but formats type(scope): something useful anywhere in the input instead of the beginning of the first line.

This is useful to format the output of git log. Any git log option works, but my favorite alias is:

$ git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --decorate --date=short

I'll use my alias git l, instead of the above, for clarity. The devmoji --format strip is only for demonstration purposes, since all devmoji commits already have emoji devmoji --list

using devmoji --log > devmoji --list

devmoji --list

To get a list of all available Devmoji, run with --list. (see also Default Devmoji)

devmoji --list

βš™οΈ Configuration

devmoji uses the config file as specified with the --config option, or looks for devmoji.config.js in the following paths:

  • current directory
  • parent directory that contains a package.json file
  • parent directory that is a git repository
  • home directory

Example Config File

module.exports = {
  // extra types used in commit messages
  types: ["lint"],
  // custom devmoji
  devmoji: [
    // use :boom: instead of :sparkles: for the type 'feat'
    { code: "feat", emoji: "boom" },
    // add a custom devmoji
    {
      code: "fail",
      emoji: "poop",
      description: "something bad happened",
    },
    // add a new devmoji based on an existing gitmoji. description will be taken from the gitmoji
    {
      code: "css",
      gitmoji: "art",
    },
    // the emoji from the gitmoji can be overriden as well
    {
      code: "config",
      gitmoji: "wrench",
      emoji: "gear",
    },
  ],
}

Default Devmoji Reference

Emoji Devmoji Code Description
✨ :feat: feat: a new feature
πŸ› :fix: fix: a bug fix
πŸ“š :docs: docs: documentation only changes
🎨 :style: style: changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
♻️ :refactor: refactor: a code change that neither fixes a bug nor adds a feature
⚑ :perf: perf: a code change that improves performance
🚨 :test: test: adding missing or correcting existing tests
πŸ”§ :chore: chore: changes to the build process or auxiliary tools and libraries such as documentation generation
πŸš€ :chore-release: chore(release): code deployment or publishing to external repositories
πŸ”— :chore-deps: chore(deps): add or delete dependencies
πŸ“¦ :build: build: changes related to build processes
πŸ‘· :ci: ci: updates to the continuous integration system
πŸš€ :release: code deployment or publishing to external repositories
πŸ”’ :security: Fixing security issues.
🌐 :i18n: Internationalization and localization.
πŸ’₯ :breaking: Introducing breaking changes.
βš™οΈ :config: Changing configuration files.
βž• :add: add something
βž– :remove: remove something

devmoji's People

Contributors

dependabot[bot] avatar folke avatar jabster28 avatar ongkianmeng avatar renovate-bot avatar renovate[bot] avatar semantic-release-bot avatar singara-velan avatar the-spanish-guy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

devmoji's Issues

`i18n` type doesn't work

When committing with i18n as the type, no emoji is added. It doesn't work even if manually added to the config:

{ code: 'i18n', gitmoji: 'globe_with_meridians' }

If that gitmoji is added to something else, it works, e.g.:

{ code: 'build', gitmoji: 'globe_with_meridians' },

devmoji for bots

Hi. I do really like this project and already integrated is as a git hook for my personal usage. However, I would like to go further and make all the commits in repo be processed by devmoji. There are many commits, which comes from automated tools (e.g. renovate-bot, snyk, etc) in my repos. Is there any recipe to make those tools also use devmoji? Or can I somehow post-process commits from bots by devmoji?

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

devmoji type(scope) not blue when using `--log` option

I'm using the git log command from the docs and the output is the same, sans the blue text for the type(scope) part. Any idea why it might not work when passing it through git log?

Just to test, I ran these commands…

echo "testing feat: ✨ cool stuff" | devmoji # => no coloring
echo "feat: ✨ cool stuff" | devmoji # => HAS coloring
echo "feat: cool stuff" | devmoji --log # => no coloring

Adds TypeScript support for configuration file

Description

Hello, I love adding emojis to my commits and recently I found this repository to be a good tool to automate this process to me and also other devs of projects I work on. The thing is, I like TypeScript and have a tendency of not allowing any .js files in projects I work with. The fact this project only supported configuration file in .js format kind of bothered me a little, so I decided to add typescript support for the configuration file devmoji.config.ts.
The PR is here: #220

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

I ran all the test suits with both yarn test and yarn test:cov and provided a new test to the new typescript configuration file.

  • load typescript from config file

image

(Also tried to improve coverage a bit by adding a test for a uncovered scenario config file does not exist).

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • chore(deps): replace dependency rollup-plugin-terser with @rollup/plugin-terser 0.1.0
  • chore(deps): update dependency @rollup/plugin-commonjs to v25
  • chore(deps): update dependency @rollup/plugin-node-resolve to v15
  • chore(deps): update dependency @rollup/plugin-typescript to v11
  • chore(deps): update dependency @types/node to v20
  • chore(deps): update dependency concurrently to v8
  • chore(deps): update dependency conventional-changelog-conventionalcommits to v8
  • chore(deps): update dependency husky to v9
  • chore(deps): update dependency prettier to v3
  • chore(deps): update dependency rimraf to v5
  • chore(deps): update dependency rollup to v4
  • chore(deps): update dependency typescript to v5
  • chore(deps): update github/codeql-action action to v3
  • fix(deps): update dependency commander to v12
  • πŸ” Create all rate-limited PRs at once πŸ”

Edited/Blocked

These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/build.yml
  • actions/checkout v2
  • actions/setup-node v2
  • actions/cache v2
  • actions/checkout v2
  • actions/setup-node v2
  • actions/cache v2
.github/workflows/codeql-analysis.yml
  • actions/checkout v2
  • github/codeql-action v1
  • github/codeql-action v1
  • github/codeql-action v1
npm
package.json
  • chalk ^4.1.1
  • commander 7.2.0
  • ts-interface-checker 1.0.2
  • @rollup/plugin-commonjs 19.0.2
  • @rollup/plugin-node-resolve 13.0.6
  • @rollup/plugin-typescript 8.2.5
  • @semantic-release/changelog 5.0.1
  • @semantic-release/git 9.0.1
  • @types/jest 26.0.24
  • @types/node 15.12.2
  • @types/node-fetch 2.5.12
  • @typescript-eslint/eslint-plugin 4.27.0
  • @typescript-eslint/parser 4.27.0
  • concurrently 6.2.2
  • conventional-changelog-conventionalcommits 4.6.3
  • copyfiles 2.4.1
  • eslint 7.28.0
  • eslint-config-prettier 8.3.0
  • eslint-plugin-import 2.23.4
  • eslint-plugin-jest 24.3.7
  • eslint-plugin-prettier 3.4.1
  • husky 6.0.0
  • jest 27.0.6
  • node-fetch 2.6.7
  • prettier 2.3.2
  • rimraf 3.0.2
  • rollup 2.52.8
  • rollup-plugin-progress 1.1.2
  • rollup-plugin-sizes 1.0.6
  • rollup-plugin-terser 7.0.2
  • semantic-release 17.4.7
  • ts-interface-builder 0.3.3
  • ts-jest 27.0.7
  • ts-node 10.0.0
  • typescript 4.3.5
  • minimist ^1.2.2

  • Check this box to trigger a request for Renovate to run again on this repository

Adding WIP Commits

Enjoy library and the constraints it creates when coupled with a precommit hook. One thing is bothering me though and that's how to check-in WIP code. What I'd like to be able to do is this:

git commit -m "wip: experimental prototype"

And see something like this in the git log:

wip: 🚧 experimental prototype

And this will be allowed by the tool and, optionally, prevented from hitting the remote using another git commit hook. Is that possible via config right now? If not, can it be added? Without it users are more likely to lose their work via stashing or miscategorize their work.

[suggestion] to add doc about git hook which would not depend upon 3-rd party tool

Hi. In my project we do use conventional commits, but we don't use husky or Yorkie, also we don't want to force people to use emojis in commits. However, personally, I like putting emojis into my commits and I want it to be automated. Therefore, I've added devmoji into my .git/hooks/ manually. Here is info on how I have this done. In the root of project, run:

cp .git/hooks/prepare-commit-msg.sample .git/hooks/prepare-commit-msg # note, it's important to copy this to make sure file is executable
echo "#\!/bin/sh\n\nCOMMIT_MSG_FILE=\$1\nCOMMIT_MSG=\$(cat \$COMMIT_MSG_FILE)\n\necho \"\${COMMIT_MSG}\" | devmoji > \$1" > .git/hooks/prepare-commit-msg

Would be great to have this added to the README of the project. Thanks!


The resulting content of .git/hooks/prepare-commit-msg would be:

#!/bin/sh

COMMIT_MSG_FILE=$1
COMMIT_MSG=$(cat $COMMIT_MSG_FILE)

echo "${COMMIT_MSG}" | devmoji > $1

adding a unicode emoji

awesome library!

wanted to change the emoji for test from 🚨 to πŸ§ͺ but the docs don't make it entirely clear on how to do that in devmoji.config.js.

This config:

module.exports = {
  types: ["lint"],
  devmoji: [{ code: "test", emoji: "πŸ§ͺ" }],
};

with this command:

echo "test: add middleware tests" | devmoji --format unicode 

yields:

test: :πŸ§ͺ: add middleware tests

Just wondering if there's a way to map normal unicode emojis in the config?

Edit: the GitHub alias is :test_tube: - I wonder whether this is just not added to the source?

Question about emoji linting

Is there any way or do you know some tool that can lint commits to ensure that they have emojis in them? I know commitlint exist and that you can implement that in a CI environment, but is there something that can validate not just conventional commits but with emojis placed between type(scope): and the description...?

Support for second variant of BREAKING CHANGE

You support one variant of breaking change signature: type(scope)!: description

It would be great if you could support also second variant of breaking change signature:

type(scope): description

BREAKING CHANGE: description of breaking change

We could use this type of regex: ($\s$\sBREAKING CHANGE)

Bug: doesn't work, if scope has spaces

echo "perf(account summary): improve rendering time" | devmoji --commit

Current:

perf(account summary): improve rendering time

Expected:

perf(account summary): ⚑️ improve rendering time

[compat] Vim Fugitive won't work with pre-commit-msg hook

I had an issue where the vim-fugitive wasn't working with the prepare-commit-msg hook. Simply changing to the commmit-msg hook in my Husky config got things working as they used toβ€”it caught bad commit messages.

Am I missing anything by using the commit-msg hook instead of prepare-commit-msg? If not, it might be worth mentioning that the commit-msg hook can be used as well. 🧠

[Question] Devmoji and Commitizen

Hi. This project is cool. I'm wondering how can I add it to my project.

Devmoji and Commitizen

Currently, I have a husky hook which looks like this...:

  "husky": {
    "hooks": {
      "prepare-commit-msg": "yarn run prepare-commit-msg"
    }
  },

Inside, prepare-commit-msg runs commitizen exec < /dev/tty && git cz --hook || true.
Does you think it's ok to use both? How would you use devmoji in this situation?

Devmoji logs

I would also like to add that when I add devmoji as a dev dependency yarn add --dev devmoji and try to run its logs with yarn devmoji --log it exits with an error error Command failed with exit code 1.. Is this expected behaviour?

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.