Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
184 changes: 184 additions & 0 deletions src/devtools/mobileharness/fe/v6/angular/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

load("//src/devtools/mobileharness/fe/v6/angular:adapter.bzl", "COMPILER_FLAGS", "js_binary", "karma_web_test_suite", "ng_module", "third_party_js", "ts_config", "ts_development_sources")

package(
default_applicable_licenses = ["//:license"],
default_visibility = [":internal"],
)

package_group(
name = "internal",
includes = [
# Other relevant google3 labels outside of your node.
],
packages = [
# Package of your boq node, which includes javatests for java
# nodes.
"//third_party/py/multitest_transport/...",
"//src/devtools/mobileharness/fe/v6/angular/...",
"//java/com/google/devtools/mobileharness/fe/v6/ui/...",
"//javatests/com/google/devtools/mobileharness/fe/v6/ui/...",
],
)

licenses(["notice"])

filegroup(
name = "images",
srcs = glob(["images/*"]),
)

# Main Angular module
ng_module(
name = "main",
srcs = [
"main.ts",
],
assets = [
# "index.html",
],
deps = [
third_party_js("angular2:core"),
third_party_js("angular2:platform_browser"),
"//javascript/modulesets:modulemanager",
"//src/devtools/mobileharness/fe/v6/angular/app",
"//src/devtools/mobileharness/fe/v6/angular/app/services",
"//third_party/javascript/angular2:common_http",
"//third_party/javascript/angular2:platform_browser_animations",
"//third_party/javascript/angular2:router",
"//third_party/javascript/angular_components:material_dialog",
],
)

################################################################################
# Static files #
################################################################################

Fileset(
name = "static_files",
out = "static",
entries = [
FilesetEntry(
files = glob(["images/*"]),
destdir = "images",
),
],
)

################################################################################
# Development mode #
################################################################################

ts_development_sources(
name = "dev_sources",
runtime_deps = [
],
deps = [
":main",
],
)

################################################################################
# Production mode #
################################################################################

THIRD_PARTY_JS = [
]

# Compiled production binary
js_binary(
name = "compiled",
defs = COMPILER_FLAGS,
use_precompiled_libraries = False,
deps = [
":main",
],
)

js_binary(
name = "uncompiled",
compile = False,
use_precompiled_libraries = False,
deps = THIRD_PARTY_JS,
)

genrule(
name = "app",
srcs = [
":uncompiled-bundle.js",
":compiled.js",
],
outs = ["app.js"],
cmd = "cat $(SRCS) > $@",
)

# Development mode flag
config_setting(
name = "dev_mode",
define_values = {
"dev_mode": "true",
},
)

ts_development_sources(
name = "dev_sources_for_testing",
testonly = 1,
runtime_deps = THIRD_PARTY_JS + [":test_setup"],
deps = [
"//src/devtools/mobileharness/fe/v6/angular/app:app_tests",
"//src/devtools/mobileharness/fe/v6/angular/app/devices:devices_tests",
"//src/devtools/mobileharness/fe/v6/angular/app/home:home_tests",
"//src/devtools/mobileharness/fe/v6/angular/app/hosts:hosts_tests",
"//src/devtools/mobileharness/fe/v6/angular/app/services:services_tests",
],
)

# TypeScript IDE configuration
ts_config(
name = "tsconfig",
deps = [
":main",
":test_setup",
"//src/devtools/mobileharness/fe/v6/angular/app:app_tests",
"//src/devtools/mobileharness/fe/v6/angular/app/devices:devices_tests",
"//src/devtools/mobileharness/fe/v6/angular/app/home:home_tests",
"//src/devtools/mobileharness/fe/v6/angular/app/hosts:hosts_tests",
"//src/devtools/mobileharness/fe/v6/angular/app/services:services_tests",
],
)

karma_web_test_suite(
name = "unit_tests",
browsers = [
"//testing/web/browsers:chrome-linux",
],
data = [
"tsconfig",
],
manifest = ":dev_sources_for_testing",
)

ng_module(
name = "test_setup",
testonly = True,
srcs = ["test_setup.ts"],
deps = [
"//third_party/javascript/angular2:core_testing",
"//third_party/javascript/angular2:platform_browser_testing",
"//third_party/javascript/typings/jasmine",
],
)
17 changes: 17 additions & 0 deletions src/devtools/mobileharness/fe/v6/angular/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Angular

## Development server

Run `ng serve` (or `ng s`) for a dev server. Navigate to
`http://localhost:5432/`. The app will automatically reload if you change any of
the source files.

## Running unit tests

Run `ng test` (or `ng t`) to execute the unit tests. The test will automatically
reload if you change any of the source files.

## Further help

To get more help on the Angular CLI use `ng help` or go check out the
[Angular CLI README](https://github.com/angular/angular-cli/blob/main/README.md).
55 changes: 55 additions & 0 deletions src/devtools/mobileharness/fe/v6/angular/adapter.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

"""Blaze adapter for UI build rules.

This file maps build rules used in the project to Blaze build rules.
adapter.bazel.bzl is a Bazel version of this file. Copybara rules rename
adapter.bazel.bzl to adapter.bzl when exporting code.
"""

load("//communication/messages/shared_web/builddefs:sass.bzl", _per_file_sass_binaries = "per_file_sass_binaries")
load("//javascript/angular2:build_defs.bzl", _ng_module = "ng_module")
load("//javascript/closure/builddefs:builddefs.bzl", _CLOSURE_COMPILER_FLAGS_FULL = "CLOSURE_COMPILER_FLAGS_FULL")
load("//javascript/typescript:build_defs.bzl", _ts_config = "ts_config", _ts_development_sources = "ts_development_sources", _ts_library = "ts_library")
load("//testing/karma/builddefs:karma_web_test_suite.bzl", _karma_web_test_suite = "karma_web_test_suite")
load("//third_party/bazel_rules/rules_sass/sass:sass.bzl", _sass_binary = "sass_binary", _sass_library = "sass_library")
load("//tools/build_defs/js:rules.bzl", _js_binary = "js_binary")

# Closure compilation flags
COMPILER_FLAGS = _CLOSURE_COMPILER_FLAGS_FULL + [
"--hide_warnings_for=javascript,third_party/javascript",
]

js_binary = _js_binary

karma_web_test_suite = _karma_web_test_suite

ng_module = _ng_module

per_file_sass_binaries = _per_file_sass_binaries

sass_binary = _sass_binary

sass_library = _sass_library

ts_config = _ts_config

ts_development_sources = _ts_development_sources

ts_library = _ts_library

def third_party_js(target_name):
return "//third_party/javascript/%s" % target_name
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// WORKAROUND https://github.com/angular/angular/issues/18810
//
// This file is required to run ngc on 3rd party libraries such as @ngrx,
// to write files like node_modules/@ngrx/store/store.ngsummary.json.
//
{
"compilerOptions": {
"lib": [
"dom",
"es2015"
],
"experimentalDecorators": true,
"types": [],
"module": "amd",
"moduleResolution": "node"
},
"angularCompilerOptions": {
"enableSummariesForJit": true
},
"include": [
"node_modules/@angular/**/*",
"node_modules/@ngrx/**/*"
],
"exclude": [
"node_modules/@ngrx/store/migrations/**",
"node_modules/@ngrx/store/schematics/**",
"node_modules/@ngrx/store/schematics-core/**",
"node_modules/@angular/cdk/schematics/**",
"node_modules/@angular/cdk/typings/schematics/**",
"node_modules/@angular/material/schematics/**",
"node_modules/@angular/material/typings/schematics/**",
"node_modules/@angular/common/upgrade*",
"node_modules/@angular/router/upgrade*",
"node_modules/@angular/bazel/**",
"node_modules/@angular/compiler-cli/**",
"node_modules/@angular/**/testing/**"
]
}
19 changes: 19 additions & 0 deletions src/devtools/mobileharness/fe/v6/angular/angular.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"$schema": "../../../../../../../../third_party/javascript/angular_cli/packages/angular/cli/lib/config/schema.json",
"version": 1,
"projects": {
"angular": {
"root": "",
"sourceRoot": "",
"projectType": "application",
"prefix": "app",
"schematics": {
"angular:component": {
"changeDetection": "OnPush",
"styleext": "scss"
}
}
}
},
"defaultProject": "angular"
}
78 changes: 78 additions & 0 deletions src/devtools/mobileharness/fe/v6/angular/app/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

load("//src/devtools/mobileharness/fe/v6/angular:adapter.bzl", "ng_module", "third_party_js")

# MTT application root
load("//third_party/bazel_rules/rules_sass/sass:sass.bzl", "sass_binary")

package(
default_applicable_licenses = ["//:license"],
default_visibility = ["//src/devtools/mobileharness/fe/v6/angular:internal"],
)

licenses(["notice"])

sass_binary(
name = "app_css",
src = "app.scss",
sourcemap = False,
deps = ["//third_party/javascript/angular_components:material_sass"],
)

ng_module(
name = "app",
srcs = ["app.ts"],
# allow_warnings = True,
assets = [
"app.ng.html",
":app_css",
],
slow_development_build = True,
deps = [
third_party_js("angular2:common_http"),
third_party_js("angular2:core"),
third_party_js("angular2:platform_browser"),
third_party_js("angular2:platform_browser_animations"),
third_party_js("angular2:router"),
third_party_js("angular_components:material_dialog"),
third_party_js("angular_components:material_tooltip"),
third_party_js("rxjs"),
"//src/devtools/mobileharness/fe/v6/angular/app/devices",
"//src/devtools/mobileharness/fe/v6/angular/app/home",
"//src/devtools/mobileharness/fe/v6/angular/app/hosts",
"//src/devtools/mobileharness/fe/v6/angular/app/services",
"//third_party/javascript/angular_components:material_button",
"//third_party/javascript/angular_components:material_divider",
"//third_party/javascript/angular_components:material_icon",
"//third_party/javascript/angular_components:material_list",
"//third_party/javascript/angular_components:material_sidenav",
"//third_party/javascript/angular_components:material_toolbar",
],
)

ng_module(
name = "app_tests",
testonly = True,
srcs = ["app_test.ts"],
deps = [
":app",
"//src/devtools/mobileharness/fe/v6/angular/app/services",
"//third_party/javascript/angular2:core_testing",
"//third_party/javascript/angular2:platform_browser_animations",
"//third_party/javascript/angular2:router_testing",
"//third_party/javascript/typings/jasmine",
],
)
Loading