Skip to content

Commit e5ea9fe

Browse files
authored
build: switch to rules_angular CLI rules (angular#30986)
Leverages our new rules for architect, contributed by Aspect alexeagle for serving material.angular.io. This allows us to drop the architect-cli logic (which is more or less experimental / internal), and fixes an issue where sometimes TS diagnostics were not properly reported with architect standalone.
1 parent 86ea718 commit e5ea9fe

12 files changed

+77
-170
lines changed

.github/workflows/docs-preview-build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ jobs:
3535
workflow-artifact-name: 'docs-preview'
3636
pull-number: '${{github.event.pull_request.number}}'
3737
artifact-build-revision: '${{github.event.pull_request.head.sha}}'
38-
deploy-directory: './dist/bin/docs/material-angular-io.production'
38+
deploy-directory: './dist/bin/docs/dist'

WORKSPACE

+1-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ npm_translate_lock(
8888
},
8989
data = [
9090
"//:package.json",
91-
"//:patches/@angular-devkit__architect-cli.patch",
9291
"//:pnpm-workspace.yaml",
9392
"//integration:package.json",
9493
"//src/cdk:package.json",
@@ -204,7 +203,7 @@ setup_dependencies_2()
204203

205204
git_repository(
206205
name = "rules_angular",
207-
commit = "0a54fca16350cab2b823908f1725aec175fcfeb2",
206+
commit = "84a8039330a4accc86f0b53c4ef5ff745c3e1bbe",
208207
remote = "https://github.com/devversion/rules_angular.git",
209208
)
210209

docs/BUILD.bazel

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
load("@rules_angular//src/architect:ng_config.bzl", "ng_config")
12
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin")
23
load("@aspect_rules_js//js:defs.bzl", "js_binary", "js_library", "js_test")
34
load("@npm//:defs.bzl", "npm_link_all_packages")
@@ -12,9 +13,7 @@ npm_link_all_packages(name = "node_modules")
1213
copy_to_bin(
1314
name = "ng-base-config",
1415
srcs = [
15-
"angular.json",
1616
"package.json",
17-
"tsconfig.json",
1817
],
1918
)
2019

@@ -26,6 +25,10 @@ copy_to_bin(
2625
],
2726
)
2827

28+
ng_config(
29+
name = "config",
30+
)
31+
2932
# The main application
3033
ng_app(
3134
name = "app",
@@ -39,6 +42,11 @@ ng_app(
3942
],
4043
)
4144

45+
alias(
46+
name = "serve",
47+
actual = ":build.serve",
48+
)
49+
4250
js_library(
4351
name = "audit_lib",
4452
srcs = [

docs/angular.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
"builder": "@angular-devkit/build-angular:dev-server",
110110
"options": {
111111
"headers": {
112-
// Keep in sync with `firebase.json`
112+
"--NOTE--": "Keep in sync with `firebase.json`",
113113
"Content-Security-Policy": "upgrade-insecure-requests; default-src 'self'; font-src 'self' https://fonts.gstatic.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; img-src 'self' data: *; frame-src https://www.youtube.com; media-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://*.google-analytics.com https://www.googletagmanager.com; child-src 'self' blob:; connect-src 'self' https://material.angular.io https://*.google-analytics.com https://stats.g.doubleclick.net https://api.github.com https://www.googletagmanager.com;"
114114
},
115115
"buildTarget": "material-angular-io:build"

docs/defs.bzl

+32-84
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
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")
23
load("@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")
910
COMMON_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
5031
APPLICATION_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

205162
def _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-
)

docs/karma.conf.js

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ module.exports = function (config) {
1717
require('karma-chrome-launcher'),
1818
require('karma-firefox-launcher'),
1919
require('karma-jasmine-html-reporter'),
20-
require('karma-coverage-istanbul-reporter'),
2120
require('@angular-devkit/build-angular/plugins/karma'),
2221
],
2322
client: {

docs/package.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@
5454
"zone.js": "~0.15.0"
5555
},
5656
"devDependencies": {
57-
"@angular-devkit/architect": "catalog:",
58-
"@angular-devkit/architect-cli": "catalog:",
5957
"@angular-devkit/build-angular": "catalog:",
6058
"@angular/cli": "catalog:",
6159
"@angular/compiler-cli": "catalog:",
@@ -68,7 +66,7 @@
6866
"jasmine-spec-reporter": "7.0.0",
6967
"karma": "~6.4.4",
7068
"karma-chrome-launcher": "^3.1.1",
71-
"karma-coverage-istanbul-reporter": "^3.0.3",
69+
"karma-coverage": "~2.2.0",
7270
"karma-firefox-launcher": "^2.1.0",
7371
"karma-jasmine": "^4.0.1",
7472
"karma-jasmine-html-reporter": "^1.5.4",

docs/scenes/karma.conf.js

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ module.exports = function (config) {
2121
require('karma-chrome-launcher'),
2222
require('karma-firefox-launcher'),
2323
require('karma-jasmine-html-reporter'),
24-
require('karma-coverage-istanbul-reporter'),
2524
require('@angular-devkit/build-angular/plugins/karma'),
2625
],
2726
client: {

package.json

-4
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
"dependencies": {
5858
"@angular-devkit/core": "catalog:",
5959
"@angular-devkit/schematics": "catalog:",
60-
"@angular-devkit/architect-cli": "catalog:",
6160
"@angular/animations": "catalog:",
6261
"@angular/common": "catalog:",
6362
"@angular/compiler": "catalog:",
@@ -217,9 +216,6 @@
217216
"@nginfra/angular-linking": "1.0.9"
218217
}
219218
}
220-
},
221-
"patchedDependencies": {
222-
"@angular-devkit/[email protected]": "patches/@angular-devkit__architect-cli.patch"
223219
}
224220
}
225221
}

patches/@angular-devkit__architect-cli.patch

-13
This file was deleted.

0 commit comments

Comments
 (0)