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:
parent
23648b052a
commit
0e1cceed50
|
@ -19,7 +19,15 @@ load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary", "nodejs_test")
|
||||||
|
|
||||||
COMMON_MODULE_IDENTIFIERS = ["angular", "jasmine", "protractor"]
|
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
|
"""Runs ts_api_guardian
|
||||||
"""
|
"""
|
||||||
data += [
|
data += [
|
||||||
|
@ -39,6 +47,9 @@ def ts_api_guardian_test(name, golden, actual, data = [], strip_export_pattern =
|
||||||
for i in allow_module_identifiers:
|
for i in allow_module_identifiers:
|
||||||
args += ["--allowModuleIdentifiers", i]
|
args += ["--allowModuleIdentifiers", i]
|
||||||
|
|
||||||
|
if use_angular_tag_rules:
|
||||||
|
args += ["--useAngularTagRules"]
|
||||||
|
|
||||||
nodejs_test(
|
nodejs_test(
|
||||||
name = name,
|
name = name,
|
||||||
data = data,
|
data = data,
|
||||||
|
|
|
@ -24,11 +24,28 @@ export function startCli() {
|
||||||
const options: SerializationOptions = {
|
const options: SerializationOptions = {
|
||||||
stripExportPattern: [].concat(argv['stripExportPattern']),
|
stripExportPattern: [].concat(argv['stripExportPattern']),
|
||||||
allowModuleIdentifiers: [].concat(argv['allowModuleIdentifiers']),
|
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) {
|
for (const error of errors) {
|
||||||
console.warn(error);
|
console.warn(error);
|
||||||
}
|
}
|
||||||
|
@ -85,7 +102,7 @@ export function parseArguments(input: string[]):
|
||||||
'allowModuleIdentifiers'
|
'allowModuleIdentifiers'
|
||||||
],
|
],
|
||||||
boolean: [
|
boolean: [
|
||||||
'help',
|
'help', 'useAngularTagRules',
|
||||||
// Options used by chalk automagically
|
// Options used by chalk automagically
|
||||||
'color', 'no-color'
|
'color', 'no-color'
|
||||||
],
|
],
|
||||||
|
@ -156,6 +173,7 @@ Options:
|
||||||
|
|
||||||
--rootDir <dir> Specify the root directory of input files
|
--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
|
--stripExportPattern <regexp> Do not output exports matching the pattern
|
||||||
--allowModuleIdentifiers <identifier>
|
--allowModuleIdentifiers <identifier>
|
||||||
Whitelist identifier for "* as foo" imports`);
|
Whitelist identifier for "* as foo" imports`);
|
||||||
|
|
Loading…
Reference in New Issue