使用项目标签
Rush 的 **项目标签** 提供了一种方便的方式来引用 Rush 项目的任意组。标签使用 **rush.json** 配置文件中的 **"tags"** 属性应用于项目。
例如
rush.json
. . .
"projects": [
{
"packageName": "my-controls",
"projectFolder": "libraries/my-controls",
"reviewCategory": "production",
/**
* An optional set of custom tags that can be used to select this project.
* For example, adding "my-custom-tag" will allow this project to
* be selected by the command "rush list --only tag:my-custom-tag"
*/
"tags": [ "1.0.0-release", "frontend-team" ]
},
{
"packageName": "my-toolchain",
"projectFolder": "tools/my-toolchain",
"reviewCategory": "tools",
"tags": [ "tools" ]
}
]
. . .
有关 `tag:my-custom-tag` 选择器语法的详细信息,请参阅 选择项目子集。
标签语法
标签名称必须是一个或多个用连字符或斜杠分隔的单词,其中单词可以包含小写 ASCII 字母、数字、`.` 和 `@` 字符。一些例子
rush list --to tag:my-custom-tag
rush list --to tag:api-extractor.com
rush list --to tag:1.0.0
验证标签
在 **rush.json** 的 **"projects"** 数组中允许任意 **"tags"** 字符串容易出错。如果有人不小心拼错了标签,或者他们使用了现在已过时的旧标签,那么可能需要一段时间才能发现这个错误。您可以使用 **"allowedProjectTags"** 设置来定义要用于单一仓库的固定标签列表。这还提供了一个集中位置来记录它们的含义。
rush.json
. . .
/**
* This is an optional, but recommended, list of allowed tags that can be applied to Rush projects
* using the "tags" setting in this file. This list is useful for preventing mistakes such as misspelling,
* and it also provides a centralized place to document your tags. If "allowedProjectTags" list is
* not specified, then any valid tag is allowed. A tag name must be one or more words
* separated by hyphens or slashes, where a word may contain lowercase ASCII letters, digits,
* ".", and "@" characters.
*/
"allowedProjectTags": [
// Apply this tag to all Rush projects that are CLI tools
"tools",
// Apply this tag to all projects owned by our company's frontend team
"frontend-team",
// Use this to tag projects to be included in the QA test pass
// for the upcoming product launch.
"1.0.0-release"
], . . .