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" )
2
3
load ("@aspect_bazel_lib//lib:copy_to_bin.bzl" , "copy_to_bin" )
3
4
4
5
# NOTE:
@@ -9,66 +10,38 @@ load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin")
9
10
COMMON_CONFIG = [
10
11
"//docs:ng-base-config" ,
11
12
12
- # The architect-cli invoking the build
13
- "//docs:node_modules/@angular-devkit/architect-cli" ,
14
-
15
13
# Required for angular.json reference to '@angular/cli/lib/config/schema.json'
16
14
"//docs:node_modules/@angular/cli" ,
17
15
18
16
# builders referenced from angular.json
19
17
"//docs:node_modules/@angular-devkit/build-angular" ,
20
18
]
21
19
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 = [
36
22
"//docs:node_modules/@angular/cdk" ,
37
23
"//docs:node_modules/@angular/cdk-experimental" ,
38
24
"//docs:node_modules/@angular/material" ,
39
25
"//docs:node_modules/@angular/material-experimental" ,
40
26
"//docs:node_modules/@angular/material-moment-adapter" ,
41
27
"//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" ,
47
28
]
48
29
49
30
# Common dependencies of Angular CLI applications
50
31
APPLICATION_CONFIG = COMMON_CONFIG + [
51
32
":ng-app-config" ,
52
33
]
53
34
54
- # Common dependencies of Angular CLI test suites
55
- TEST_CONFIG = COMMON_CONFIG + [
35
+ TEST_DEPS = [
56
36
"@rules_browsers//src/browsers/chromium" ,
57
37
"@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" ,
62
38
"//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" ,
66
39
]
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 " ,
72
45
]
73
46
74
47
# Common dependencies of Angular CLI e2e tests
@@ -151,39 +124,23 @@ def ng_app(name, project_name = None, deps = [], test_deps = [], e2e_deps = [],
151
124
152
125
_architect_build (
153
126
project_name ,
154
- srcs = srcs + deps + NG_COMMON_DEPS + APPLICATION_CONFIG ,
127
+ srcs = srcs + deps + DEPS + APPLICATION_CONFIG ,
155
128
tags = tags + ["manual" ],
156
129
** kwargs
157
130
)
158
131
_architect_build (
159
132
project_name ,
160
- srcs = srcs + deps + NG_COMMON_DEPS + APPLICATION_CONFIG ,
133
+ srcs = srcs + deps + DEPS + APPLICATION_CONFIG ,
161
134
configuration = "production" ,
162
135
tags = tags ,
163
136
** kwargs
164
137
)
165
138
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
-
182
139
_architect_test (
183
140
project_name ,
184
141
"test" ,
185
142
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 ,
187
144
tags = tags ,
188
145
** kwargs
189
146
)
@@ -193,7 +150,7 @@ def ng_app(name, project_name = None, deps = [], test_deps = [], e2e_deps = [],
193
150
# project_name,
194
151
# "e2e",
195
152
# 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,
197
154
# args = [
198
155
# "--no-webdriver-update",
199
156
# "--port=0",
@@ -203,21 +160,19 @@ def ng_app(name, project_name = None, deps = [], test_deps = [], e2e_deps = [],
203
160
# )
204
161
205
162
def _architect_build (project_name , configuration = None , args = [], srcs = [], ** kwargs ):
206
- output_dir = "%s%s" % ( project_name , ".%s" % configuration if configuration else "" )
163
+ args = []
207
164
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 ]
213
167
214
- architect_cli . architect (
168
+ ng_application (
215
169
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 ,
217
174
# Needed for font inlining.
218
175
execution_requirements = {"requires-network" : "1" },
219
- args = args ,
220
- out_dirs = [output_dir ],
221
176
srcs = srcs ,
222
177
** kwargs
223
178
)
@@ -227,33 +182,26 @@ def _architect_test(project_name, command, configuration = None, args = [], srcs
227
182
if native .package_name () != "" :
228
183
to_root = "" .join (["../" for _ in native .package_name ().split ("/" )])
229
184
185
+ args = []
186
+ if configuration != None :
187
+ args += ["--configuration" , configuration ]
188
+
230
189
env = {
231
190
"CHROME_BIN" : to_root + "$(CHROME-HEADLESS-SHELL)" ,
232
191
"CHROMEDRIVER_BIN" : to_root + "$(CHROMEDRIVER)" ,
233
192
}
234
193
235
- architect_cli . architect_test (
194
+ ng_test (
236
195
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 ,
242
201
env = env ,
243
202
toolchains = [
244
203
"@rules_browsers//src/browsers/chromium:toolchain_alias" ,
245
204
"@rules_browsers//src/browsers/firefox:toolchain_alias" ,
246
205
],
247
206
** kwargs
248
207
)
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