指南:使用提示
¥Guide: Use prompt
@commitlint/prompt-cli
有助于快速编写提交消息,并确保它们遵循 commitlint.config.js
中配置的提交约定。
¥@commitlint/prompt-cli
helps with fast authoring of commit messages and ensures they adhere to the commit convention configured in commitlint.config.js
.
安装
¥Install
如果需要,创建一个 git 存储库
¥Create a git repository if needed
shgit init
如果需要,创建一个 package.json 文件
¥Create a package.json if needed
shnpm init
如果需要,请安装并配置
¥Install and configure if needed
shnpm install --save-dev @commitlint/cli @commitlint/config-conventional @commitlint/prompt-cli echo "export default { extends: ['@commitlint/config-conventional'] };" > commitlint.config.js
提供快捷方式
¥Provide a shortcut
为了使 prompt-cli 易于使用,请在你的 package.json
中添加一个 npm run-script。
¥To make prompt-cli easy to use, add a npm run-script to your package.json
{
"scripts": {
"commit": "commit"
}
}
通过执行以下命令测试提示
¥Test the prompt by executing
git add .
npm run commit
@commitlint/prompt-cli
的替代方案:commitizen
¥An alternative to @commitlint/prompt-cli
: commitizen
另一种编写符合 commitlint.config.js
中配置的提交约定的提交消息的方法是使用 commitizen
。有关更多信息,请查看他们的 官方网站。
¥Another way to author commit messages that adhere to the commit convention configured in commitlint.config.js
is to use commitizen
. For more information, checkout their official website.
commitlint 为 commitizen
提供了两个适配器:
¥commitlint provides two adapters for commitizen
:
@commitlint/prompt
提供与@commitlint/prompt-cli
相同的交互方式。¥
@commitlint/prompt
provides a way to interact same as@commitlint/prompt-cli
@commitlint/cz-commitlint
受 cz-conventional-changelog 启发,提供了一种更现代的交互方式。¥
@commitlint/cz-commitlint
is inspired by cz-conventional-changelog, it provides a more modern way to interact.