style: reformat bzl files on patch branch to match master

This commit is contained in:
Alex Eagle
2018-09-18 14:43:05 -07:00
parent af785f9e91
commit e7c72ab556
15 changed files with 1253 additions and 1168 deletions

View File

@ -12,65 +12,65 @@ DEFAULT_NODE_MODULES = "@angular_deps//:node_modules"
# Packages which are versioned together on npm
ANGULAR_SCOPED_PACKAGES = ["@angular/%s" % p for p in [
# core should be the first package because it's the main package in the group
# this is significant for Angular CLI and "ng update" specifically, @angular/core
# is considered the identifier of the group by these tools.
"core",
"bazel",
"common",
"compiler",
"compiler-cli",
"animations",
"elements",
"platform-browser",
"platform-browser-dynamic",
"forms",
"http",
"platform-server",
"platform-webworker",
"platform-webworker-dynamic",
"upgrade",
"router",
"language-service",
"service-worker",
# core should be the first package because it's the main package in the group
# this is significant for Angular CLI and "ng update" specifically, @angular/core
# is considered the identifier of the group by these tools.
"core",
"bazel",
"common",
"compiler",
"compiler-cli",
"animations",
"elements",
"platform-browser",
"platform-browser-dynamic",
"forms",
"http",
"platform-server",
"platform-webworker",
"platform-webworker-dynamic",
"upgrade",
"router",
"language-service",
"service-worker",
]]
PKG_GROUP_REPLACEMENTS = {
"\"NG_UPDATE_PACKAGE_GROUP\"": """[
%s
]""" % ",\n ".join(["\"%s\"" % s for s in ANGULAR_SCOPED_PACKAGES])
]""" % ",\n ".join(["\"%s\"" % s for s in ANGULAR_SCOPED_PACKAGES]),
}
def ts_library(tsconfig = None, node_modules = DEFAULT_NODE_MODULES, testonly = False, **kwargs):
if not tsconfig:
if testonly:
tsconfig = DEFAULT_TSCONFIG_TEST
else:
tsconfig = DEFAULT_TSCONFIG_BUILD
_ts_library(tsconfig = tsconfig, node_modules = node_modules, testonly = testonly, **kwargs)
if not tsconfig:
if testonly:
tsconfig = DEFAULT_TSCONFIG_TEST
else:
tsconfig = DEFAULT_TSCONFIG_BUILD
_ts_library(tsconfig = tsconfig, node_modules = node_modules, testonly = testonly, **kwargs)
def ng_module(name, tsconfig = None, entry_point = None, node_modules = DEFAULT_NODE_MODULES, testonly = False, **kwargs):
if not tsconfig:
if testonly:
tsconfig = DEFAULT_TSCONFIG_TEST
else:
tsconfig = DEFAULT_TSCONFIG_BUILD
if not entry_point:
entry_point = "public_api.ts"
_ng_module(name = name, flat_module_out_file = name, tsconfig = tsconfig, entry_point = entry_point, node_modules = node_modules, testonly = testonly, **kwargs)
if not tsconfig:
if testonly:
tsconfig = DEFAULT_TSCONFIG_TEST
else:
tsconfig = DEFAULT_TSCONFIG_BUILD
if not entry_point:
entry_point = "public_api.ts"
_ng_module(name = name, flat_module_out_file = name, tsconfig = tsconfig, entry_point = entry_point, node_modules = node_modules, testonly = testonly, **kwargs)
# ivy_ng_module behaves like ng_module, and under --define=compile=legacy it runs ngc with global
# analysis but produces Ivy outputs. Under other compile modes, it behaves as ng_module.
# TODO(alxhub): remove when ngtsc supports the same use cases.
def ivy_ng_module(name, tsconfig = None, entry_point = None, testonly = False, **kwargs):
if not tsconfig:
if testonly:
tsconfig = DEFAULT_TSCONFIG_TEST
else:
tsconfig = DEFAULT_TSCONFIG_BUILD
if not entry_point:
entry_point = "public_api.ts"
_internal_global_ng_module(name = name, flat_module_out_file = name, tsconfig = tsconfig, entry_point = entry_point, testonly = testonly, **kwargs)
if not tsconfig:
if testonly:
tsconfig = DEFAULT_TSCONFIG_TEST
else:
tsconfig = DEFAULT_TSCONFIG_BUILD
if not entry_point:
entry_point = "public_api.ts"
_internal_global_ng_module(name = name, flat_module_out_file = name, tsconfig = tsconfig, entry_point = entry_point, testonly = testonly, **kwargs)
def ng_package(name, node_modules = DEFAULT_NODE_MODULES, readme_md = None, license_banner = None, **kwargs):
if not readme_md:
@ -88,18 +88,19 @@ def ng_package(name, node_modules = DEFAULT_NODE_MODULES, readme_md = None, lice
)
def npm_package(name, replacements = {}, **kwargs):
_npm_package(
name = name,
replacements = dict(replacements, **PKG_GROUP_REPLACEMENTS),
**kwargs)
_npm_package(
name = name,
replacements = dict(replacements, **PKG_GROUP_REPLACEMENTS),
**kwargs
)
def ts_web_test_suite(bootstrap = [], deps = [], **kwargs):
if not bootstrap:
bootstrap = ["//:web_test_bootstrap_scripts"]
local_deps = [
"@angular_deps//:node_modules/tslib/tslib.js",
"//tools/testing:browser",
] + deps
if not bootstrap:
bootstrap = ["//:web_test_bootstrap_scripts"]
local_deps = [
"@angular_deps//:node_modules/tslib/tslib.js",
"//tools/testing:browser",
] + deps
_ts_web_test_suite(
bootstrap = bootstrap,

View File

@ -2,17 +2,19 @@
See https://www.npmjs.com/package/http-server
"""
load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary")
def http_server(templated_args = [], **kwargs):
# By default, we pass an argument pointing the http server to the
# package of the caller.
# This assumes there is an index.html in the package directory.
if not templated_args:
templated_args = [native.package_name()]
# By default, we pass an argument pointing the http server to the
# package of the caller.
# This assumes there is an index.html in the package directory.
if not templated_args:
templated_args = [native.package_name()]
nodejs_binary(
node_modules = "@http-server_runtime_deps//:node_modules",
entry_point = "http-server/bin/http-server",
templated_args = templated_args,
**kwargs)
nodejs_binary(
node_modules = "@http-server_runtime_deps//:node_modules",
entry_point = "http-server/bin/http-server",
templated_args = templated_args,
**kwargs
)

View File

@ -9,7 +9,7 @@ load("@build_bazel_rules_nodejs//:defs.bzl", "yarn_install")
load("@angular//packages/bazel/src:ng_setup_workspace.bzl", _ng_setup_workspace = "ng_setup_workspace")
def ng_setup_workspace():
"""This repository rule should be called from your WORKSPACE file.
"""This repository rule should be called from your WORKSPACE file.
It creates some additional Bazel external repositories that are used internally
to build angular
@ -235,6 +235,7 @@ filegroup(
"node_modules/protractor/**",
"node_modules/@schematics/angular/**",
]))
""")
""",
)
_ng_setup_workspace()
_ng_setup_workspace()

View File

@ -8,7 +8,7 @@
# This does a deep import under //internal because of not wanting the wrapper macro
# because it introduces an extra target_bin target.
load("@build_bazel_rules_nodejs//internal/node:node.bzl", "nodejs_test", "nodejs_binary")
load("@build_bazel_rules_nodejs//internal/node:node.bzl", "nodejs_binary", "nodejs_test")
DEFAULT_NODE_MODULES = "@angular_deps//:node_modules"

View File

@ -14,44 +14,46 @@
"""Runs ts_api_guardian
"""
load("@build_bazel_rules_nodejs//internal/node:node.bzl", "nodejs_test", "nodejs_binary")
load("@build_bazel_rules_nodejs//internal/node:node.bzl", "nodejs_binary", "nodejs_test")
COMMON_MODULE_IDENTIFIERS = ["angular", "jasmine", "protractor"]
def ts_api_guardian_test(name, golden, actual, data = [], **kwargs):
"""Runs ts_api_guardian
"""
data += [
"//tools/ts-api-guardian:lib",
"//tools/ts-api-guardian:bin/ts-api-guardian",
"@bazel_tools//tools/bash/runfiles",
]
"""Runs ts_api_guardian
"""
data += [
"//tools/ts-api-guardian:lib",
"//tools/ts-api-guardian:bin/ts-api-guardian",
"@bazel_tools//tools/bash/runfiles",
]
args = [
# Needed so that node doesn't walk back to the source directory.
# From there, the relative imports would point to .ts files.
"--node_options=--preserve-symlinks",
"--stripExportPattern", "^\(__\\)",
]
for i in COMMON_MODULE_IDENTIFIERS:
args += ["--allowModuleIdentifiers", i]
args = [
# Needed so that node doesn't walk back to the source directory.
# From there, the relative imports would point to .ts files.
"--node_options=--preserve-symlinks",
"--stripExportPattern",
"^\(__\\)",
]
for i in COMMON_MODULE_IDENTIFIERS:
args += ["--allowModuleIdentifiers", i]
nodejs_test(
name = name,
data = data,
node_modules = "@ts-api-guardian_runtime_deps//:node_modules",
entry_point = "angular/tools/ts-api-guardian/bin/ts-api-guardian",
templated_args = args + ["--verify", golden, actual],
testonly = 1,
**kwargs
)
nodejs_test(
name = name,
data = data,
node_modules = "@ts-api-guardian_runtime_deps//:node_modules",
entry_point = "angular/tools/ts-api-guardian/bin/ts-api-guardian",
templated_args = args + ["--verify", golden, actual],
testonly = 1,
**kwargs
)
nodejs_binary(
name = name + ".accept",
testonly = True,
data = data,
node_modules = "@ts-api-guardian_runtime_deps//:node_modules",
entry_point = "angular/tools/ts-api-guardian/bin/ts-api-guardian",
templated_args = args + ["--out", golden, actual],
**kwargs
)
nodejs_binary(
name = name + ".accept",
testonly = True,
data = data,
node_modules = "@ts-api-guardian_runtime_deps//:node_modules",
entry_point = "angular/tools/ts-api-guardian/bin/ts-api-guardian",
templated_args = args + ["--out", golden, actual],
**kwargs
)