🤖 🚀 ✨ 使用 Devmoji 为你的常规提交添加表情符号
使用标准提交⭐作为提交信息的标准,可以借助标准变更日志📄、标准版本🔖和语义发布📦🚀等工具,轻松实现语义化版本控制🔖。
Devmoji
是一个命令行工具,它 使用受Gitmoji启发的表情符号,为传统的提交添加颜色🌈😜
Devmoji 的一些功能:
- emojify:在格式之间转换输入
unicode。devmoji是易于记忆的别名,例如:,,,而不是难以记忆的 emoji 代码。shortcodedevmoji:test::refactor::docs::security - git commit:安装一个
prepare-commit-msg提交钩子,即可自动为你的提交信息添加表情符号✨ - git 日志:
git log即使对于未使用表情符号的项目,也对输出进行表情符号化和着色。
它长什么样?
- 请查看 Devmoji GitHub 仓库的提交信息。
- 生成的 Devmoji变更日志.md
📦 安装
使用npm或yarn
全球
npm install -g devmoji
yarn global install devmoji
在项目本地中使用。
npx devmoji
npm install --dev devmoji
yarn add --dev devmoji
--edit有关如何设置 git 提交钩子的信息,请参阅相关文档
。
💥 用法
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
-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表情符号化
使用--text或通过管道将文本转换为表情符号。输入可以是 任何有效格式的stdin组合。输出格式:
| 格式 | 描述 |
|---|---|
shortcode |
输出 GitHub Markdown 短代码,例如:sparkles: :rocket: |
unicode |
输出表情符号 Unicode 字符,例如 ✨ 🚀 |
devmoji |
输出如下 Devmoji 短代码::feat: :chore-release: |
strip |
从输入框中移除所有表情符号 |
默认格式为
unicode,因为这种格式几乎可以在任何地方使用
,并且文本长度最短(适用于提交消息)。
$ 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
type(scope): something useful使用以下伪代码,自动将格式为 的常规提交消息转换为表情符号:
if (exists(":type-scope:")) return emoji(":type-scope:")
if (exists(":type:") && exists(":scope:"))
return emoji(":type:") + emoji(":scope:")
if (exists(":type:")) return emoji(":type:")
示例输出:
$ 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 --edit
格式化并保存当前提交消息.git/COMMIT_EDITMSG。这
实际上只适合用作prepare-commit-msg钩子函数。
// package.json
{
"husky": {
"hooks": {
"prepare-commit-msg": "devmoji -e"
}
}
}
// package.json
{
"gitHooks": {
"prepare-commit-msg": "devmoji -e"
}
}
如果您已将Devmoji作为开发依赖项本地安装到项目中,则
可以使用类似这样的npx --no-install devmoji -e命令代替
上面的命令。
devmoji --log
功能类似--commit,但格式化type(scope): something useful
输入中的任何位置,而不是第一行的开头。
这对于格式化输出非常有用git log。任何git log选项都可以,
但我最喜欢的别名是:
$ 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
为了清晰起见,我将使用我的别名
git l,而不是上面的别名。这devmoji --format strip仅用于演示目的,因为所有 devmoji
提交都已经包含 emoji 表情符号了。
devmoji --list
要获取所有可用Devmiji的列表,请运行命令--list。(另请参阅
默认 Devmoji)
⚙️ 配置
devmoji使用选项指定的配置文件--config,或者在以下路径中
查找:devmoji.config.js
- 当前目录
- 包含
package.json文件的父目录 - 父目录,即
git存储库 - 首页
示例配置文件
export const defaults = {
// 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",
},
],
}
默认 Devmoji 参考
| 表情符号 | Devmoji 代码 | 描述 |
|---|---|---|
| ✨ | :feat: |
特色:一项新功能 |
| 🐛 | :fix: |
修复:一个错误修复 |
| 📚 | :docs: |
文档:仅文档更改 |
| 🎨 | :style: |
样式:不影响代码含义的更改(空格、格式、缺少的分号等) |
| ♻️ | :refactor: |
重构:既不修复错误也不添加新功能的代码更改。 |
| ⚡ | :perf: |
perf:一种可以提高性能的代码更改 |
| 🚨 | :test: |
测试:添加缺失的测试或更正现有测试 |
| 🔧 | :chore: |
琐事:对构建过程或辅助工具和库(例如文档生成)的更改 |
| 🚀 | :chore-release: |
发布任务:代码部署或发布到外部代码库 |
| 🔗 | :chore-deps: |
chore(deps):添加或删除依赖项 |
| 📦 | :build: |
构建:与构建过程相关的更改 |
| 👷 | :ci: |
ci:持续集成系统的更新 |
| 🚀 | :release: |
代码部署或发布到外部代码库 |
| 🔒 | :security: |
修复安全问题。 |
| 🌐 | :i18n: |
国际化和本地化。 |
| 💥 | :breaking: |
引入重大变革。 |
| ⚙️ | :config: |
正在更改配置文件。 |
| ➕ | :add: |
加点东西 |
| ➖ | :remove: |
移除某些东西 |


