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:
@@ -19,56 +20,31 @@ COMMON_CONFIG = [
1920 "//docs:node_modules/@angular-devkit/build-angular" ,
2021]
2122
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
23+ # Project dependencies common across libs/tests
24+ DEPS = [
3625 "//docs:node_modules/@angular/cdk" ,
3726 "//docs:node_modules/@angular/cdk-experimental" ,
3827 "//docs:node_modules/@angular/material" ,
3928 "//docs:node_modules/@angular/material-experimental" ,
4029 "//docs:node_modules/@angular/material-moment-adapter" ,
4130 "//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" ,
4731]
4832
4933# Common dependencies of Angular CLI applications
5034APPLICATION_CONFIG = COMMON_CONFIG + [
5135 ":ng-app-config" ,
5236]
5337
54- # Common dependencies of Angular CLI test suites
55- TEST_CONFIG = COMMON_CONFIG + [
38+ TEST_DEPS = [
5639 "@rules_browsers//src/browsers/chromium" ,
5740 "@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" ,
6241 "//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" ,
6642]
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 " ,
43+
44+ # Common dependencies of Angular CLI test suites
45+ TEST_CONFIG = COMMON_CONFIG + [
46+ "//docs:ng-base-test-config " ,
47+ ":ng-test-config " ,
7248]
7349
7450# Common dependencies of Angular CLI e2e tests
@@ -151,39 +127,23 @@ def ng_app(name, project_name = None, deps = [], test_deps = [], e2e_deps = [],
151127
152128 _architect_build (
153129 project_name ,
154- srcs = srcs + deps + NG_COMMON_DEPS + APPLICATION_CONFIG ,
130+ srcs = srcs + deps + DEPS + APPLICATION_CONFIG ,
155131 tags = tags + ["manual" ],
156132 ** kwargs
157133 )
158134 _architect_build (
159135 project_name ,
160- srcs = srcs + deps + NG_COMMON_DEPS + APPLICATION_CONFIG ,
136+ srcs = srcs + deps + DEPS + APPLICATION_CONFIG ,
161137 configuration = "production" ,
162138 tags = tags ,
163139 ** kwargs
164140 )
165141
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-
182142 _architect_test (
183143 project_name ,
184144 "test" ,
185145 args = ["--no-watch" ],
186- srcs = srcs + test_srcs + deps + test_deps + NG_COMMON_DEPS + TEST_DEPS + TEST_CONFIG ,
146+ srcs = srcs + test_srcs + deps + test_deps + DEPS + TEST_DEPS + TEST_CONFIG ,
187147 tags = tags ,
188148 ** kwargs
189149 )
@@ -193,7 +153,7 @@ def ng_app(name, project_name = None, deps = [], test_deps = [], e2e_deps = [],
193153 # project_name,
194154 # "e2e",
195155 # size = "large",
196- # srcs = srcs + e2e_srcs + deps + e2e_deps + NG_COMMON_DEPS + E2E_DEPS + E2E_CONFIG,
156+ # srcs = srcs + e2e_srcs + deps + e2e_deps + DEPS + E2E_DEPS + E2E_CONFIG,
197157 # args = [
198158 # "--no-webdriver-update",
199159 # "--port=0",
@@ -203,21 +163,19 @@ def ng_app(name, project_name = None, deps = [], test_deps = [], e2e_deps = [],
203163 # )
204164
205165def _architect_build (project_name , configuration = None , args = [], srcs = [], ** kwargs ):
206- output_dir = "%s%s" % ( project_name , ".%s" % configuration if configuration else "" )
166+ args = []
207167
208- args = [
209- "%s:build%s" % (project_name , ":%s" % configuration if configuration else "" ),
210- "--output-path" ,
211- output_dir ,
212- ] + args
168+ if configuration != None :
169+ args += ["--configuration" , configuration ]
213170
214- architect_cli . architect (
171+ ng_application (
215172 name = "%s%s" % ("build" , ".%s" % configuration if configuration else "" ),
216- chdir = native .package_name (),
173+ ng_config = "//docs:config" ,
174+ node_modules = "//docs:node_modules" ,
175+ project_name = project_name ,
176+ args = args ,
217177 # Needed for font inlining.
218178 execution_requirements = {"requires-network" : "1" },
219- args = args ,
220- out_dirs = [output_dir ],
221179 srcs = srcs ,
222180 ** kwargs
223181 )
@@ -227,33 +185,26 @@ def _architect_test(project_name, command, configuration = None, args = [], srcs
227185 if native .package_name () != "" :
228186 to_root = "" .join (["../" for _ in native .package_name ().split ("/" )])
229187
188+ args = []
189+ if configuration != None :
190+ args += ["--configuration" , configuration ]
191+
230192 env = {
231193 "CHROME_BIN" : to_root + "$(CHROME-HEADLESS-SHELL)" ,
232194 "CHROMEDRIVER_BIN" : to_root + "$(CHROMEDRIVER)" ,
233195 }
234196
235- architect_cli . architect_test (
197+ ng_test (
236198 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 ,
199+ args = args ,
200+ project_name = project_name ,
201+ ng_config = "//docs:config" ,
202+ node_modules = "//docs:node_modules" ,
203+ srcs = srcs ,
242204 env = env ,
243205 toolchains = [
244206 "@rules_browsers//src/browsers/chromium:toolchain_alias" ,
245207 "@rules_browsers//src/browsers/firefox:toolchain_alias" ,
246208 ],
247209 ** kwargs
248210 )
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