Skip to content

Commit c24924c

Browse files
build(devtools): use ng-dev stamp tooling to stamp the latest git SHA in devtools
Previously, we were using ngx-build-plus with a custom webpack config to determine the git SHA at runtime. Now, after migrating to bazel and transfering to angular/angular, this commit uses ng-dev to stamp the latest git SHA directly in angular devtools' application environment. This commit also removes the old webpack configs.
1 parent e5cdd33 commit c24924c

20 files changed

Lines changed: 14 additions & 182 deletions

devtools/.bazelrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
import ../.bazelrc
22

33
build --flag_alias=partial_compilation=@npm//@angular/bazel/src:partial_compilation
4+
5+
# Snapshots should also be stamped with version control information.
6+
build --workspace_status_command="yarn -s ng-dev release build-env-stamp --mode=snapshot"
7+
build --stamp

devtools/BUILD.bazel

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
load("//tools:typescript.bzl", "ts_test_project")
21
load("@npm//@bazel/typescript:index.bzl", "ts_config")
32

43
package(default_visibility = ["//visibility:public"])
@@ -8,17 +7,6 @@ exports_files([
87
"cypress.json",
98
])
109

11-
ts_test_project(
12-
name = "initialize_testbed",
13-
srcs = [
14-
"initialize_testbed.ts",
15-
],
16-
deps = [
17-
"@npm//@angular/core",
18-
"@npm//@angular/platform-browser-dynamic",
19-
],
20-
)
21-
2210
ts_config(
2311
name = "tsconfig-spec",
2412
src = "tsconfig.spec.json",

devtools/angular.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,6 @@
7373
{
7474
"replace": "src/environments/environment.ts",
7575
"with": "src/environments/environment.e2e.ts"
76-
},
77-
{
78-
"replace": "src/app/app.module.ts",
79-
"with": "src/app/app.e2e.module.ts"
8076
}
8177
]
8278
}
@@ -85,7 +81,6 @@
8581
"serve": {
8682
"builder": "ngx-build-plus:dev-server",
8783
"options": {
88-
"extraWebpackConfig": "shell-dev-webpack.config.js",
8984
"browserTarget": "shell-dev:build"
9085
},
9186
"configurations": {
@@ -154,7 +149,6 @@
154149
"builder": "ngx-build-plus:browser",
155150
"options": {
156151
"outputPath": "dist/shell-chrome",
157-
"extraWebpackConfig": "projects/shell-chrome/shell-chrome-webpack.config.js",
158152
"index": "projects/shell-chrome/src/index.html",
159153
"main": "projects/shell-chrome/src/main.ts",
160154
"polyfills": "projects/shell-chrome/src/polyfills.ts",

devtools/initialize_testbed.ts

Lines changed: 0 additions & 10 deletions
This file was deleted.

devtools/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919
"cy:run": "yarn cypress run",
2020
"cy:open": "yarn cypress open",
2121
"cy:watch": "start-server-and-test start http-get://localhost:4200 cy:open",
22-
"cy:ci": "start-server-and-test start http-get://localhost:4200 cy:run",
23-
"test:ci": "bazelisk --bazelrc=../.circleci/bazel.linux.rc test //...",
22+
"start:ci": "bazelisk run src:devserver",
23+
"cy:ci": "start-server-and-test start:ci http-get://localhost:4200 cy:run",
24+
"test:ci": "bazelisk test //...",
2425
"build:chrome:ci": "bazelisk build projects/shell-chrome/src:prodapp",
2526
"prettier": "prettier --write \"{,!(node_modules|dist|build|coverage)/**/}*.{js,jsx,ts,tsx,json}\"",
2627
"prettier:fix": "pretty-quick --staged"
@@ -45,7 +46,6 @@
4546
"@babel/cli": "^7.16.0",
4647
"@babel/core": "^7.16.0",
4748
"@types/node": "^16.7.1",
48-
"ajv-formats": "^2.1.1",
4949
"d3": "^5.7.0",
5050
"memo-decorator": "^2.0.1",
5151
"ngx-flamegraph": "0.0.10",

devtools/packages.bzl

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,3 @@
1-
# Each individual package uses a placeholder for the version of Angular to ensure they're
2-
# all in-sync. This map is passed to each ng_package rule to stamp out the appropriate
3-
# version for the placeholders.
4-
ANGULAR_PACKAGE_VERSION = "^13.0.0 || ^14.0.0-0"
5-
MDC_PACKAGE_VERSION = "14.0.0-canary.1af7c1c4a.0"
6-
TSLIB_PACKAGE_VERSION = "^2.3.0"
7-
RXJS_PACKAGE_VERSION = "^6.5.3 || ^7.4.0"
8-
9-
# Each placeholder is used to stamp versions during the build process, replacing the key with it's
10-
# value pair. These replacements occur during building of `npm_package` and `ng_package` stamping in
11-
# the peer dependencies and versions, primarily in `package.json`s.
12-
NPM_PACKAGE_SUBSTITUTIONS = {
13-
# Version of `material-components-web`
14-
"0.0.0-MDC": MDC_PACKAGE_VERSION,
15-
# Version of `@angular/core`
16-
"0.0.0-NG": ANGULAR_PACKAGE_VERSION,
17-
# Version of `tslib`
18-
"0.0.0-TSLIB": TSLIB_PACKAGE_VERSION,
19-
# Version of the local package being built, generated via the `--workspace_status_command` flag.
20-
"0.0.0-PLACEHOLDER": "{BUILD_SCM_VERSION}",
21-
# Version of `rxjs`
22-
"0.0.0-RXJS": RXJS_PACKAGE_VERSION,
23-
}
24-
25-
NO_STAMP_NPM_PACKAGE_SUBSTITUTIONS = dict(NPM_PACKAGE_SUBSTITUTIONS, **{
26-
# When building NPM packages for tests (where stamping is disabled),
27-
# we use `0.0.0` for the version placeholder.
28-
"0.0.0-PLACEHOLDER": "0.0.0",
29-
})
30-
311
# List of MDC packages.
322
MDC_PACKAGES = [
333
"@material/animation",

devtools/projects/ng-devtools/src/lib/application-environment/index.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
export interface Process {
2-
env: Env;
3-
}
4-
51
interface Env {
62
LATEST_SHA: string;
73
}
84

95
export interface Environment {
106
production: boolean;
11-
process: Process;
7+
LATEST_SHA: string;
128
}
139

1410
export abstract class ApplicationEnvironment {

devtools/projects/ng-devtools/src/lib/devtools-tabs/devtools-tabs.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export class DevToolsTabsComponent implements OnInit, OnDestroy, AfterViewInit {
5959
}
6060

6161
get latestSHA(): string {
62-
return this._applicationEnvironment.environment.process.env.LATEST_SHA;
62+
return this._applicationEnvironment.environment.LATEST_SHA.slice(0, 8);
6363
}
6464

6565
changeTab(tab: 'Profiler' | 'Components' | 'Router Tree'): void {

devtools/projects/shell-chrome/shell-chrome-webpack.config.js

Lines changed: 0 additions & 30 deletions
This file was deleted.

devtools/projects/shell-chrome/src/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,4 +330,5 @@ pkg_web(
330330
additional_root_paths = [
331331
"projects/ng-devtools/src/lib",
332332
],
333+
substitutions = {"BUILD_SCM_COMMIT_SHA": "{BUILD_SCM_COMMIT_SHA}"},
333334
)

0 commit comments

Comments
 (0)