build: add option to disable ts-api-guardian default angular tag rules (#26761)

Since the API guardian can be also used by other projects, we should not set up the default Angular project tag rules unless specified explicitly through a given command option (`useAngularTagRules`)

PR Close #26761
This commit is contained in:
Paul Gschwendtner 2018-10-28 19:05:20 +01:00 committed by Matias Niemelä
parent 23648b052a
commit 0e1cceed50
2 changed files with 34 additions and 5 deletions

View File

@ -19,7 +19,15 @@ load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary", "nodejs_test")
COMMON_MODULE_IDENTIFIERS = ["angular", "jasmine", "protractor"]
def ts_api_guardian_test(name, golden, actual, data = [], strip_export_pattern = ["^__", ""], allow_module_identifiers = COMMON_MODULE_IDENTIFIERS, **kwargs):
def ts_api_guardian_test(
name,
golden,
actual,
data = [],
strip_export_pattern = ["^__", ""],
allow_module_identifiers = COMMON_MODULE_IDENTIFIERS,
use_angular_tag_rules = True,
**kwargs):
"""Runs ts_api_guardian
"""
data += [
@ -39,6 +47,9 @@ def ts_api_guardian_test(name, golden, actual, data = [], strip_export_pattern =
for i in allow_module_identifiers:
args += ["--allowModuleIdentifiers", i]
if use_angular_tag_rules:
args += ["--useAngularTagRules"]
nodejs_test(
name = name,
data = data,

View File

@ -24,11 +24,28 @@ export function startCli() {
const options: SerializationOptions = {
stripExportPattern: [].concat(argv['stripExportPattern']),
allowModuleIdentifiers: [].concat(argv['allowModuleIdentifiers']),
exportTags: {required: ['publicApi'], banned: ['experimental'], toCopy: ['deprecated']},
memberTags: {required: [], banned: ['experimental', 'publicApi'], toCopy: ['deprecated']},
paramTags: {required: [], banned: ['experimental', 'publicApi'], toCopy: ['deprecated']}
};
// Since the API guardian can be also used by other projects, we should not set up the default
// Angular project tag rules unless specified explicitly through a given option.
if (argv['useAngularTagRules']) {
options.exportTags = {
required: ['publicApi'],
banned: ['experimental'],
toCopy: ['deprecated']
};
options.memberTags = {
required: [],
banned: ['experimental', 'publicApi'],
toCopy: ['deprecated']
};
options.paramTags = {
required: [],
banned: ['experimental', 'publicApi'],
toCopy: ['deprecated']
};
}
for (const error of errors) {
console.warn(error);
}
@ -85,7 +102,7 @@ export function parseArguments(input: string[]):
'allowModuleIdentifiers'
],
boolean: [
'help',
'help', 'useAngularTagRules',
// Options used by chalk automagically
'color', 'no-color'
],
@ -156,6 +173,7 @@ Options:
--rootDir <dir> Specify the root directory of input files
--useAngularTagRules <boolean> Whether the Angular specific tag rules should be used.
--stripExportPattern <regexp> Do not output exports matching the pattern
--allowModuleIdentifiers <identifier>
Whitelist identifier for "* as foo" imports`);