Skip to content

Commit fa9136a

Browse files
kyliaualan-agius4
authored andcommitted
build: minor fixes for google3 sync
This commit makes a few minor changes to enable syncing the CLI repository into google3. 1. mark pkg_tar and pkg_npm as external 2. remove dependencies (marked as comment) which are stale in google3 3. remove TS files generated from JSON schema in BUILD files since these files are compiled and added to the g3 codebase at sync time 4. Some minor typing changes 5. Remove duplicate licenses 6. mark dependencies which are not available in g3 as external 7. Immediately type the result of JSON.parse() as required by g3 linter. Otherwise, the type defaults to `any`.
1 parent 1befba9 commit fa9136a

File tree

23 files changed

+118
-78
lines changed

23 files changed

+118
-78
lines changed

Diff for: packages/angular/cli/BUILD.bazel

+10-5
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
# Use of this source code is governed by an MIT-style license that can be
44
# found in the LICENSE file at https://angular.io/license
55

6-
load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")
76
load("@npm_bazel_jasmine//:index.bzl", "jasmine_node_test")
8-
load("@build_bazel_rules_nodejs//:index.bzl", "pkg_npm")
97
load("//tools:ts_json_schema.bzl", "ts_json_schema")
108
load("//tools:defaults.bzl", "ts_library")
119

12-
licenses(["notice"]) # MIT
10+
# @external_begin
11+
load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")
12+
load("@build_bazel_rules_nodejs//:index.bzl", "pkg_npm")
13+
# @external_end
1314

1415
licenses(["notice"]) # MIT
1516

@@ -25,6 +26,8 @@ ts_library(
2526
"node_modules/**",
2627
],
2728
) + [
29+
# @external_begin
30+
# These files are generated from the JSON schema
2831
"//packages/angular/cli:lib/config/schema.ts",
2932
"//packages/angular/cli:commands/analytics.ts",
3033
"//packages/angular/cli:commands/add.ts",
@@ -44,6 +47,7 @@ ts_library(
4447
"//packages/angular/cli:commands/version.ts",
4548
"//packages/angular/cli:commands/run.ts",
4649
"//packages/angular/cli:commands/xi18n.ts",
50+
# @external_end
4751
],
4852
data = glob(
4953
include = [
@@ -65,10 +69,9 @@ ts_library(
6569
"//packages/angular_devkit/core/node",
6670
"//packages/angular_devkit/schematics",
6771
"//packages/angular_devkit/schematics/tools",
68-
# @node_module: typescript:es2017.object
6972
"@npm//@types/debug",
70-
"@npm//@types/node",
7173
"@npm//@types/inquirer",
74+
"@npm//@types/node",
7275
"@npm//@types/rimraf",
7376
"@npm//@types/semver",
7477
"@npm//@types/universal-analytics",
@@ -248,6 +251,7 @@ jasmine_node_test(
248251
srcs = [":angular-cli_test_lib"],
249252
)
250253

254+
# @external_begin
251255
pkg_npm(
252256
name = "npm_package",
253257
deps = [
@@ -262,3 +266,4 @@ pkg_tar(
262266
strip_prefix = "./npm_package",
263267
tags = ["manual"],
264268
)
269+
# @external_end

Diff for: packages/angular/cli/commands/add-impl.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ export class AddCommand extends SchematicCommand<AddCommandSchema> {
147147
usingYarn,
148148
});
149149

150-
savePackage = manifest['ng-add'] && manifest['ng-add'].save;
150+
savePackage = manifest['ng-add']?.save;
151151
collectionName = manifest.name;
152152

153153
if (await this.hasMismatchedPeer(manifest)) {

Diff for: packages/angular/pwa/BUILD.bazel

-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ load("//tools:ts_json_schema.bzl", "ts_json_schema")
99

1010
licenses(["notice"]) # MIT
1111

12-
licenses(["notice"]) # MIT
13-
1412
package(default_visibility = ["//visibility:public"])
1513

1614
ts_library(

Diff for: packages/angular_devkit/architect/BUILD.bazel

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33
# Use of this source code is governed by an MIT-style license that can be
44
# found in the LICENSE file at https://angular.io/license
55

6-
load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")
76
load("@npm_bazel_jasmine//:index.bzl", "jasmine_node_test")
87
load("//tools:defaults.bzl", "ts_library")
8+
load("//tools:ts_json_schema.bzl", "ts_json_schema")
99

1010
# @external_begin
11+
load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")
1112
load("@build_bazel_rules_nodejs//:index.bzl", "pkg_npm")
12-
1313
# @external_end
14-
load("//tools:ts_json_schema.bzl", "ts_json_schema")
1514

1615
licenses(["notice"]) # MIT
1716

@@ -43,10 +42,13 @@ ts_library(
4342
include = ["src/**/*.ts"],
4443
exclude = ["**/*_spec.ts"],
4544
) + [
45+
# @external_begin
46+
# These files are generated from the JSON schema
4647
"//packages/angular_devkit/architect:src/input-schema.ts",
4748
"//packages/angular_devkit/architect:src/output-schema.ts",
4849
"//packages/angular_devkit/architect:src/builders-schema.ts",
4950
"//packages/angular_devkit/architect:src/progress-schema.ts",
51+
# @external_end
5052
],
5153
# strict_checks = False,
5254
data = glob(

Diff for: packages/angular_devkit/architect/node/BUILD.bazel

-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ load("//tools:defaults.bzl", "ts_library")
77

88
licenses(["notice"]) # MIT
99

10-
licenses(["notice"]) # MIT
11-
1210
package(default_visibility = ["//visibility:public"])
1311

1412
ts_library(

Diff for: packages/angular_devkit/architect/testing/BUILD.bazel

-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ load("//tools:defaults.bzl", "ts_library")
77

88
licenses(["notice"]) # MIT
99

10-
licenses(["notice"]) # MIT
11-
1210
package(default_visibility = ["//visibility:public"])
1311

1412
ts_library(

Diff for: packages/angular_devkit/benchmark/BUILD.bazel

+7-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33
# Use of this source code is governed by an MIT-style license that can be
44
# found in the LICENSE file at https://angular.io/license
55

6-
load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")
76
load("@npm_bazel_jasmine//:index.bzl", "jasmine_node_test")
8-
load("@build_bazel_rules_nodejs//:index.bzl", "pkg_npm")
97
load("//tools:defaults.bzl", "ts_library")
108

9+
# @external_begin
10+
load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")
11+
load("@build_bazel_rules_nodejs//:index.bzl", "pkg_npm")
12+
# @external_end
13+
1114
licenses(["notice"]) # MIT
1215

1316
package(default_visibility = ["//visibility:public"])
@@ -68,6 +71,7 @@ jasmine_node_test(
6871
],
6972
)
7073

74+
# @external_begin
7175
pkg_npm(
7276
name = "npm_package",
7377
deps = [
@@ -82,3 +86,4 @@ pkg_tar(
8286
strip_prefix = "./npm_package",
8387
tags = ["manual"],
8488
)
89+
# @external_end

Diff for: packages/angular_devkit/build_angular/BUILD.bazel

+7-3
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33
# Use of this source code is governed by an MIT-style license that can be
44
# found in the LICENSE file at https://angular.io/license
55

6-
load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")
76
load("@npm_bazel_jasmine//:index.bzl", "jasmine_node_test")
8-
load("@build_bazel_rules_nodejs//:index.bzl", "pkg_npm")
97
load("//tools:defaults.bzl", "ts_library")
108
load("//tools:ts_json_schema.bzl", "ts_json_schema")
119

10+
# @external_begin
11+
load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")
12+
load("@build_bazel_rules_nodejs//:index.bzl", "pkg_npm")
13+
# @external_end
14+
1215
licenses(["notice"]) # MIT
1316

1417
package(default_visibility = ["//visibility:public"])
@@ -206,6 +209,7 @@ jasmine_node_test(
206209
srcs = [":build_angular_test_lib"],
207210
)
208211

212+
# @external_begin
209213
pkg_npm(
210214
name = "npm_package",
211215
deps = [
@@ -220,7 +224,7 @@ pkg_tar(
220224
strip_prefix = "./npm_package",
221225
tags = ["manual"],
222226
)
223-
227+
# @external_end
224228
# Large build_angular specs
225229

226230
ts_library(

Diff for: packages/angular_devkit/build_ng_packagr/BUILD.bazel

+7-2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33
# Use of this source code is governed by an MIT-style license that can be
44
# found in the LICENSE file at https://angular.io/license
55

6-
load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")
76
load("@npm_bazel_jasmine//:index.bzl", "jasmine_node_test")
8-
load("@build_bazel_rules_nodejs//:index.bzl", "pkg_npm")
97
load("//tools:defaults.bzl", "ts_library")
108
load("//tools:ts_json_schema.bzl", "ts_json_schema")
119

10+
# @external_begin
11+
load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")
12+
load("@build_bazel_rules_nodejs//:index.bzl", "pkg_npm")
13+
# @external_end
14+
1215
licenses(["notice"]) # MIT
1316

1417
package(default_visibility = ["//visibility:public"])
@@ -41,6 +44,7 @@ ts_library(
4144
],
4245
)
4346

47+
# @external_begin
4448
pkg_npm(
4549
name = "npm_package",
4650
deps = [
@@ -55,6 +59,7 @@ pkg_tar(
5559
strip_prefix = "./npm_package",
5660
tags = ["manual"],
5761
)
62+
# @external_end
5863

5964
ts_library(
6065
name = "build_ng_packagr_test_lib",

Diff for: packages/angular_devkit/build_optimizer/BUILD.bazel

+7-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33
# Use of this source code is governed by an MIT-style license that can be
44
# found in the LICENSE file at https://angular.io/license
55

6-
load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")
76
load("@npm_bazel_jasmine//:index.bzl", "jasmine_node_test")
8-
load("@build_bazel_rules_nodejs//:index.bzl", "pkg_npm")
97
load("//tools:defaults.bzl", "ts_library")
108

9+
# @external_begin
10+
load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")
11+
load("@build_bazel_rules_nodejs//:index.bzl", "pkg_npm")
12+
# @external_end
13+
1114
licenses(["notice"]) # MIT
1215

1316
package(default_visibility = ["//visibility:public"])
@@ -72,6 +75,7 @@ jasmine_node_test(
7275
],
7376
)
7477

78+
# @external_begin
7579
pkg_npm(
7680
name = "npm_package",
7781
deps = [
@@ -86,3 +90,4 @@ pkg_tar(
8690
strip_prefix = "./npm_package",
8791
tags = ["manual"],
8892
)
93+
# @external_end

Diff for: packages/angular_devkit/build_webpack/BUILD.bazel

+7-2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33
# Use of this source code is governed by an MIT-style license that can be
44
# found in the LICENSE file at https://angular.io/license
55

6-
load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")
76
load("@npm_bazel_jasmine//:index.bzl", "jasmine_node_test")
8-
load("@build_bazel_rules_nodejs//:index.bzl", "pkg_npm")
97
load("//tools:defaults.bzl", "ts_library")
108
load("//tools:ts_json_schema.bzl", "ts_json_schema")
119

10+
# @external_begin
11+
load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")
12+
load("@build_bazel_rules_nodejs//:index.bzl", "pkg_npm")
13+
# @external_end
14+
1215
licenses(["notice"]) # MIT
1316

1417
package(default_visibility = ["//visibility:public"])
@@ -103,6 +106,7 @@ jasmine_node_test(
103106
],
104107
)
105108

109+
# @external_begin
106110
pkg_npm(
107111
name = "npm_package",
108112
deps = [
@@ -117,3 +121,4 @@ pkg_tar(
117121
strip_prefix = "./npm_package",
118122
tags = ["manual"],
119123
)
124+
# @external_end

Diff for: packages/angular_devkit/core/BUILD.bazel

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")
21
load("@npm_bazel_jasmine//:index.bzl", "jasmine_node_test")
32
load("//tools:defaults.bzl", "ts_library")
43

54
# @external_begin
5+
load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")
66
load("@build_bazel_rules_nodejs//:index.bzl", "pkg_npm")
77
# @external_end
88

@@ -42,12 +42,11 @@ ts_library(
4242
"@npm//fast-json-stable-stringify",
4343
"@npm//magic-string",
4444
"@npm//rxjs",
45-
"@npm//source-map",
46-
# @node_module: typescript:es2015.core
45+
"@npm//source-map", # @external
4746
# @node_module: typescript:es2015.proxy
4847
# @node_module: typescript:es2015.reflect
4948
# @node_module: typescript:es2015.symbol.wellknown
50-
# @node_module: typescript:es2016.array.include
49+
# @typings: source_map
5150
],
5251
)
5352

Diff for: packages/angular_devkit/core/src/terminal/caps.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ function _getColumns() {
7676

7777

7878
function _createCapabilities(
79-
stream: Socket,
79+
stream: NodeJS.WriteStream,
8080
isTerminalStream: boolean,
8181
level: 0|1|2|3 = supportsColor.stdout.level,
8282
): StreamCapabilities {
@@ -96,7 +96,7 @@ function _createCapabilities(
9696

9797

9898
export function getCapabilities(
99-
stream: Socket,
99+
stream: NodeJS.WriteStream,
100100
isTerminalStream = !!stream.isTTY,
101101
): StreamCapabilities {
102102
let maybeCaps = streamMap.get(stream);

Diff for: packages/angular_devkit/core/src/terminal/text.ts

+28-28
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,34 @@
88
import * as caps from './caps';
99
import { colors } from './colors';
1010

11-
const stdout = typeof process == 'object'
12-
? caps.getCapabilities(process.stdout) : { colors: false };
11+
const supportColors: boolean = typeof process === 'object' ? caps.getCapabilities(process.stdout).colors : false;
12+
const identityFn = (x: string) => x;
1313

14-
export const reset = stdout.colors ? colors.reset : (x: string) => x;
15-
export const bold = stdout.colors ? colors.bold : (x: string) => x;
16-
export const dim = stdout.colors ? colors.dim : (x: string) => x;
17-
export const italic = stdout.colors ? colors.italic : (x: string) => x;
18-
export const underline = stdout.colors ? colors.underline : (x: string) => x;
19-
export const inverse = stdout.colors ? colors.inverse : (x: string) => x;
20-
export const hidden = stdout.colors ? colors.hidden : (x: string) => x;
21-
export const strikethrough = stdout.colors ? colors.strikethrough : (x: string) => x;
14+
export const reset = supportColors ? colors.reset : identityFn;
15+
export const bold = supportColors ? colors.bold : identityFn;
16+
export const dim = supportColors ? colors.dim : identityFn;
17+
export const italic = supportColors ? colors.italic : identityFn;
18+
export const underline = supportColors ? colors.underline : identityFn;
19+
export const inverse = supportColors ? colors.inverse : identityFn;
20+
export const hidden = supportColors ? colors.hidden : identityFn;
21+
export const strikethrough = supportColors ? colors.strikethrough : identityFn;
2222

23-
export const black = stdout.colors ? colors.black : (x: string) => x;
24-
export const red = stdout.colors ? colors.red : (x: string) => x;
25-
export const green = stdout.colors ? colors.green : (x: string) => x;
26-
export const yellow = stdout.colors ? colors.yellow : (x: string) => x;
27-
export const blue = stdout.colors ? colors.blue : (x: string) => x;
28-
export const magenta = stdout.colors ? colors.magenta : (x: string) => x;
29-
export const cyan = stdout.colors ? colors.cyan : (x: string) => x;
30-
export const white = stdout.colors ? colors.white : (x: string) => x;
31-
export const grey = stdout.colors ? colors.gray : (x: string) => x;
32-
export const gray = stdout.colors ? colors.gray : (x: string) => x;
23+
export const black = supportColors ? colors.black : identityFn;
24+
export const red = supportColors ? colors.red : identityFn;
25+
export const green = supportColors ? colors.green : identityFn;
26+
export const yellow = supportColors ? colors.yellow : identityFn;
27+
export const blue = supportColors ? colors.blue : identityFn;
28+
export const magenta = supportColors ? colors.magenta : identityFn;
29+
export const cyan = supportColors ? colors.cyan : identityFn;
30+
export const white = supportColors ? colors.white : identityFn;
31+
export const grey = supportColors ? colors.gray : identityFn;
32+
export const gray = supportColors ? colors.gray : identityFn;
3333

34-
export const bgBlack = stdout.colors ? colors.bgBlack : (x: string) => x;
35-
export const bgRed = stdout.colors ? colors.bgRed : (x: string) => x;
36-
export const bgGreen = stdout.colors ? colors.bgGreen : (x: string) => x;
37-
export const bgYellow = stdout.colors ? colors.bgYellow : (x: string) => x;
38-
export const bgBlue = stdout.colors ? colors.bgBlue : (x: string) => x;
39-
export const bgMagenta = stdout.colors ? colors.bgMagenta : (x: string) => x;
40-
export const bgCyan = stdout.colors ? colors.bgCyan : (x: string) => x;
41-
export const bgWhite = stdout.colors ? colors.bgWhite : (x: string) => x;
34+
export const bgBlack = supportColors ? colors.bgBlack : identityFn;
35+
export const bgRed = supportColors ? colors.bgRed : identityFn;
36+
export const bgGreen = supportColors ? colors.bgGreen : identityFn;
37+
export const bgYellow = supportColors ? colors.bgYellow : identityFn;
38+
export const bgBlue = supportColors ? colors.bgBlue : identityFn;
39+
export const bgMagenta = supportColors ? colors.bgMagenta : identityFn;
40+
export const bgCyan = supportColors ? colors.bgCyan : identityFn;
41+
export const bgWhite = supportColors ? colors.bgWhite : identityFn;

0 commit comments

Comments
 (0)