1- load ("@npm//:@angular-devkit/architect-cli/package_json.bzl" , architect_cli = "bin" )
1+ load ("@rules_angular//src/architect:ng_application.bzl" , "ng_application" )
2+ load ("@rules_angular//src/architect:ng_test.bzl" , "ng_test" )
23load ("@aspect_bazel_lib//lib:copy_to_bin.bzl" , "copy_to_bin" )
34
45# NOTE:
@@ -9,66 +10,38 @@ load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin")
910COMMON_CONFIG = [
1011 "//docs:ng-base-config" ,
1112
12- # The architect-cli invoking the build
13- "//docs:node_modules/@angular-devkit/architect-cli" ,
14-
1513 # Required for angular.json reference to '@angular/cli/lib/config/schema.json'
1614 "//docs:node_modules/@angular/cli" ,
1715
1816 # builders referenced from angular.json
1917 "//docs:node_modules/@angular-devkit/build-angular" ,
2018]
2119
22- # Standard dependencies common across libs/tests
23- # Only include the core Angular + Components/Material which are versioned together
24- NG_COMMON_DEPS = [
25- # Angular libraries versioned together
26- "//docs:node_modules/@angular/animations" ,
27- "//docs:node_modules/@angular/common" ,
28- "//docs:node_modules/@angular/core" ,
29- "//docs:node_modules/@angular/forms" ,
30- "//docs:node_modules/@angular/localize" ,
31- "//docs:node_modules/@angular/router" ,
32- "//docs:node_modules/@angular/platform-browser" ,
33- "//docs:node_modules/@angular/platform-browser-dynamic" ,
34-
35- # Angular cdk+material libraries versioned together
20+ # Project dependencies common across libs/tests
21+ DEPS = [
3622 "//docs:node_modules/@angular/cdk" ,
3723 "//docs:node_modules/@angular/cdk-experimental" ,
3824 "//docs:node_modules/@angular/material" ,
3925 "//docs:node_modules/@angular/material-experimental" ,
4026 "//docs:node_modules/@angular/material-moment-adapter" ,
4127 "//docs:node_modules/@angular/youtube-player" ,
42-
43- # Common libraries used throughout
44- "//docs:node_modules/rxjs" ,
45- "//docs:node_modules/tslib" ,
46- "//docs:node_modules/zone.js" ,
4728]
4829
4930# Common dependencies of Angular CLI applications
5031APPLICATION_CONFIG = COMMON_CONFIG + [
5132 ":ng-app-config" ,
5233]
5334
54- # Common dependencies of Angular CLI test suites
55- TEST_CONFIG = COMMON_CONFIG + [
35+ TEST_DEPS = [
5636 "@rules_browsers//src/browsers/chromium" ,
5737 "@rules_browsers//src/browsers/firefox" ,
58- "//docs:ng-base-test-config" ,
59- ":ng-test-config" ,
60- "//docs:node_modules/karma" ,
61- "//docs:node_modules/karma-chrome-launcher" ,
6238 "//docs:node_modules/karma-firefox-launcher" ,
63- "//docs:node_modules/karma-jasmine" ,
64- "//docs:node_modules/karma-jasmine-html-reporter" ,
65- "//docs:node_modules/karma-coverage-istanbul-reporter" ,
6639]
67- TEST_DEPS = [
68- "//docs:node_modules/@types/jasmine" ,
69- "//docs:node_modules/@types/node" ,
70- "//docs:node_modules/@angular/compiler " ,
71- "//docs:node_modules/jasmine-core " ,
40+
41+ # Common dependencies of Angular CLI test suites
42+ TEST_CONFIG = COMMON_CONFIG + [
43+ "//docs:ng-base-test-config " ,
44+ ":ng-test-config " ,
7245]
7346
7447# Common dependencies of Angular CLI e2e tests
@@ -151,39 +124,23 @@ def ng_app(name, project_name = None, deps = [], test_deps = [], e2e_deps = [],
151124
152125 _architect_build (
153126 project_name ,
154- srcs = srcs + deps + NG_COMMON_DEPS + APPLICATION_CONFIG ,
127+ srcs = srcs + deps + DEPS + APPLICATION_CONFIG ,
155128 tags = tags + ["manual" ],
156129 ** kwargs
157130 )
158131 _architect_build (
159132 project_name ,
160- srcs = srcs + deps + NG_COMMON_DEPS + APPLICATION_CONFIG ,
133+ srcs = srcs + deps + DEPS + APPLICATION_CONFIG ,
161134 configuration = "production" ,
162135 tags = tags ,
163136 ** kwargs
164137 )
165138
166- _architect_binary (
167- project_name ,
168- "serve" ,
169- srcs = srcs + deps + NG_COMMON_DEPS + APPLICATION_CONFIG ,
170- tags = tags + ["manual" ],
171- ** kwargs
172- )
173- _architect_binary (
174- project_name ,
175- "serve" ,
176- configuration = "production" ,
177- srcs = srcs + deps + NG_COMMON_DEPS + APPLICATION_CONFIG ,
178- tags = tags + ["manual" ],
179- ** kwargs
180- )
181-
182139 _architect_test (
183140 project_name ,
184141 "test" ,
185142 args = ["--no-watch" ],
186- srcs = srcs + test_srcs + deps + test_deps + NG_COMMON_DEPS + TEST_DEPS + TEST_CONFIG ,
143+ srcs = srcs + test_srcs + deps + test_deps + DEPS + TEST_DEPS + TEST_CONFIG ,
187144 tags = tags ,
188145 ** kwargs
189146 )
@@ -193,7 +150,7 @@ def ng_app(name, project_name = None, deps = [], test_deps = [], e2e_deps = [],
193150 # project_name,
194151 # "e2e",
195152 # size = "large",
196- # srcs = srcs + e2e_srcs + deps + e2e_deps + NG_COMMON_DEPS + E2E_DEPS + E2E_CONFIG,
153+ # srcs = srcs + e2e_srcs + deps + e2e_deps + DEPS + E2E_DEPS + E2E_CONFIG,
197154 # args = [
198155 # "--no-webdriver-update",
199156 # "--port=0",
@@ -203,21 +160,19 @@ def ng_app(name, project_name = None, deps = [], test_deps = [], e2e_deps = [],
203160 # )
204161
205162def _architect_build (project_name , configuration = None , args = [], srcs = [], ** kwargs ):
206- output_dir = "%s%s" % ( project_name , ".%s" % configuration if configuration else "" )
163+ args = []
207164
208- args = [
209- "%s:build%s" % (project_name , ":%s" % configuration if configuration else "" ),
210- "--output-path" ,
211- output_dir ,
212- ] + args
165+ if configuration != None :
166+ args += ["--configuration" , configuration ]
213167
214- architect_cli . architect (
168+ ng_application (
215169 name = "%s%s" % ("build" , ".%s" % configuration if configuration else "" ),
216- chdir = native .package_name (),
170+ ng_config = "//docs:config" ,
171+ node_modules = "//docs:node_modules" ,
172+ project_name = project_name ,
173+ args = args ,
217174 # Needed for font inlining.
218175 execution_requirements = {"requires-network" : "1" },
219- args = args ,
220- out_dirs = [output_dir ],
221176 srcs = srcs ,
222177 ** kwargs
223178 )
@@ -227,33 +182,26 @@ def _architect_test(project_name, command, configuration = None, args = [], srcs
227182 if native .package_name () != "" :
228183 to_root = "" .join (["../" for _ in native .package_name ().split ("/" )])
229184
185+ args = []
186+ if configuration != None :
187+ args += ["--configuration" , configuration ]
188+
230189 env = {
231190 "CHROME_BIN" : to_root + "$(CHROME-HEADLESS-SHELL)" ,
232191 "CHROMEDRIVER_BIN" : to_root + "$(CHROMEDRIVER)" ,
233192 }
234193
235- architect_cli . architect_test (
194+ ng_test (
236195 name = "%s%s" % (command , ".%s" % configuration if configuration else "" ),
237- chdir = native . package_name () ,
238- args = [
239- "%s:%s%s" % ( project_name , command , ":%s" % configuration if configuration else "" ) ,
240- ] + args ,
241- data = srcs ,
196+ args = args ,
197+ project_name = project_name ,
198+ ng_config = "//docs:config" ,
199+ node_modules = "//docs:node_modules" ,
200+ srcs = srcs ,
242201 env = env ,
243202 toolchains = [
244203 "@rules_browsers//src/browsers/chromium:toolchain_alias" ,
245204 "@rules_browsers//src/browsers/firefox:toolchain_alias" ,
246205 ],
247206 ** kwargs
248207 )
249-
250- def _architect_binary (project_name , command , configuration = None , args = [], srcs = [], ** kwargs ):
251- architect_cli .architect_binary (
252- name = "%s%s" % (command , ".%s" % configuration if configuration else "" ),
253- chdir = native .package_name (),
254- args = [
255- "%s:%s%s" % (project_name , command , ":%s" % configuration if configuration else "" ),
256- ] + args ,
257- data = srcs ,
258- ** kwargs
259- )
0 commit comments