升级指南
¥Upgrade Guides
validate-commit-msg
validate-commit-msg 的维护者已弃用其软件包,转而使用 commitlint
。
¥The maintainers of validate-commit-msg have deprecated their package in favor of commitlint
.
使用默认设置迁移
¥Migrating with default settings
只需对你的设置进行少量更改,即可重新创建最常见的 validate-commit-msg
用例。
¥The most common validate-commit-msg
use cases can be recreated with minor changes to your setup.
将 validate-commit-msg 替换为 commitlint
¥Replace validate-commit-msg with commitlint
npm remove validate-commit-msg --save-dev
npm install --save-dev @commitlint/cli @commitlint/config-conventional
在 package.json 中添加一个 commitmsg 运行脚本
¥Add a commitmsg run-script to package.json
{
"scripts": {
"commitmsg": "commitlint -x @commitlint/config-conventional -E GIT_PARAMS"
}
}
安装 Husky
¥Install husky
npm install --save-dev husky
使用自定义设置迁移
¥Migrating with custom settings
如果你将 validate-commit-msg
与自定义配置一起使用,你可能也希望自定义 commitlint
配置。
¥If you used validate-commit-msg
with custom configuration you might want to customize commitlint
configuration, too.
将 validate-commit-msg 替换为 commitlint
¥Replace validate-commit-msg with commitlint
npm remove validate-commit-msg --save-dev
npm install --save-dev @commitlint/cli @commitlint/config-conventional
在 package.json 中添加一个 commitmsg 运行脚本
¥Add a commitmsg run-script to package.json
{
"scripts": {
"commitmsg": "commitlint -E GIT_PARAMS"
}
}
安装 Husky
¥Install husky
npm install --save-dev husky
配置 commitlint
¥Configure commitlint
module.exports = {
extends: ["@commitlint/config-conventional"],
rules: {
// Place your rules here
"scope-enum": [2, "always", ["a", "b"]], // error if scope is given but not in provided list
},
};
validate-commit-msg 选项等效项
¥validate-commit-msg option equivalents
{
"types": ["a", "b"], // 'type-enum': [2, 'always', ['a', 'b']]
"scope": {
"required": true, // 'scope-empty': [2, 'never']
"allowed": ["a", "b"], // 'scope-enum': [2, 'always', ['a', 'b']]; specify [0] for allowed: ["*"]
"validate": false, // 'scope-enum': [0], 'scope-empty': [0]
"multiple": false // multiple scopes are not supported in commitlint
},
"warnOnFail": false, // no equivalent setting in commitlint
"maxSubjectLength": 100, // 'header-max-length': [2, 'always', 100]
"subjectPattern": ".+", // may be configured via `parser-preset`, contact us
"subjectPatternErrorMsg": "msg", // no equivalent setting in commitlint
"helpMessage": "", // no equivalent setting in commitlint
"autoFix": false // no equivalent setting in commitlint
}
请参阅 规则参考 获取所有可用配置选项的列表。
¥Refer to the Rules Reference for a list of all available configuration options.
DevTools Slack 工作区上也有 #commitlint 通道。加入我们,我们将尽力帮助你进行迁移。
¥There is also the #commitlint channel on the DevTools Slack workspace. Join us there and we'll do our best to help you with your migration.
版本 1 至 2
¥Version 1 to 2
npm install --save-dev conventional-changelog-lint@latest
重大变更
¥Breaking changes
CLI
无
¥None
配置
¥Config
通配符配置被忽略 - 从
2.0.0
版本开始,以前的.wildcards
配置将被完全忽略。如果你的.conventional-changelog-lintrc
、commitlint.config.js
或扩展可共享配置包含.wildcards
键,则会发出警告。¥wildcards config is ignored - as of version
2.0.0
the former.wildcards
configuration is ignored entirely. If your.conventional-changelog-lintrc
,commitlint.config.js
or an extended shareable configuration has a.wildcards
key a warning will be issued.
API
无
¥None
版本 2 至 3
¥Version 2 to 3
npm remove --save-dev conventional-changelog-lint
npm install --save commitlint
mv .conventional-changelog-lintrc commitlint.config.js
将所有对
conventional-changelog-lint
的调用重命名为commitlint
¥Rename all calls to
conventional-changelog-lint
tocommitlint
重大变更
¥Breaking changes
CLI
conventional-changelog-lint
命令现在称为commitlint
¥
conventional-changelog-lint
command now is calledcommitlint
commitlint
命令现在通过@commitlint/cli
安装¥
commitlint
command now is installed via@commitlint/cli
.conventional-changelog-lintrc
现在被称为commitlint.config.js
。¥
.conventional-changelog-lintrc
now is calledcommitlint.config.js
commitlint
不会在目录结构中向上搜索配置¥
commitlint
does not search upwards in the directory structure for config--preset | -p
标志已被移除。始终使用angular
预设。¥
--preset | -p
flag was removed. Theangular
preset is used always.
配置
¥Config
.preset
键已被移除。始终使用angular
预设。¥
.preset
key is removed. Theangular
preset is used always.
API
getConfiguration(name, settings, seed)
更改为load(seed)
¥
getConfiguration(name, settings, seed)
changed toload(seed)
getMessages(range)
更改为read(range)
¥
getMessages(range)
changed toread(range)
getPreset(name, require)
已移除¥
getPreset(name, require)
removedformat(report, options)
现在只在options
上遵循.color
。¥
format(report, options)
now only respects.color
onoptions
lint(message, options)
更改为lint(message, rules)
¥
lint(message, options)
changed tolint(message, rules)
版本 4 至 5
¥Version 4 to 5
npm remove --save-dev @commitlint/config-angular
npm install --save @commitlint/cli @commitlint/config-conventional
echo 'module.exports = {extends: ["@commitlint/config-conventional"]};';
重大变更
¥Breaking changes
配置
¥Config
config-angular
放弃了对chore
类型的支持,破坏了与 conventional-changelog 的兼容性,请使用config-conventional
代替。¥
config-angular
dropped support for thechore
type, breaking compatibility with conventional-changelog, useconfig-conventional
instead.
版本 7 至 8
¥Version 7 to 8
重大变更
¥Breaking changes
成功提交后的输出将被忽略
¥Output on successful commit will be omitted
你可以使用
--verbose
标志来获得正确的输出。¥You can use the
--verbose
flag to get positive output
版本 8 至 9
¥Version 8 to 9
重大变更
¥Breaking changes
可能的类型
¥Possible types
improvement
类型现在将被此配置拒绝。¥
improvement
type will now be rejected by this config
版本 9 到 10
¥Version 9 to 10
重大变更
¥Breaking changes
节点支持
¥Node support
node v8 不再受支持。
¥node v8 is not supported anymore
版本 10 至 11
¥Version 10 to 11
重大变更
¥Breaking changes
Lerna 支持
¥Lerna support
lerna v2 不再受支持。
¥lerna v2 is not supported anymore
版本 11 至 12
¥Version 11 to 12
重大变更
¥Breaking changes
resolve-extends
extends
解析的顺序从从右到左更改为从左到右¥The order of the
extends
resolution is changed from right-to-left to left-to-right