Skip to content

Commit 1ba79e3

Browse files
committed
build: remove windows runfile workaround
* Since bazel-contrib/rules_nodejs@1f97eb6 landed, we can safely remove the workaround by updating the NodeJS and TypeScript Bazel rules. * Also we are creating our own `getFileContent` testing method because it's not guaranteed that the internal testing utilities from `@schematics/angular` always stay the same. Additionally this works around an issue where `test` folders are excluded in the Bazel managed deps by default.
1 parent 6d7f417 commit 1ba79e3

File tree

18 files changed

+69
-57
lines changed

18 files changed

+69
-57
lines changed

WORKSPACE

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
55
# Add NodeJS rules (explicitly used for sass bundle rules)
66
http_archive(
77
name = "build_bazel_rules_nodejs",
8-
url = "https://github.com/bazelbuild/rules_nodejs/archive/0.15.3.zip",
9-
strip_prefix = "rules_nodejs-0.15.3",
8+
url = "https://github.com/bazelbuild/rules_nodejs/archive/0.16.1.zip",
9+
strip_prefix = "rules_nodejs-0.16.1",
1010
)
1111

1212
# Add TypeScript rules
1313
http_archive(
1414
name = "build_bazel_rules_typescript",
15-
url = "https://github.com/bazelbuild/rules_typescript/archive/8ea1a55cf5cf8be84ddfeefc0940769b80da792f.zip",
16-
strip_prefix = "rules_typescript-8ea1a55cf5cf8be84ddfeefc0940769b80da792f",
15+
url = "https://github.com/bazelbuild/rules_typescript/archive/0.21.0.zip",
16+
strip_prefix = "rules_typescript-0.21.0",
1717
)
1818

1919
# Add Angular source and Bazel rules.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@
5454
"@angular/platform-server": "^7.0.3",
5555
"@angular/router": "^7.0.3",
5656
"@bazel/ibazel": "0.6.0",
57-
"@bazel/karma": "0.20.3",
58-
"@bazel/typescript": "0.20.3",
57+
"@bazel/karma": "0.21.0",
58+
"@bazel/typescript": "0.21.0",
5959
"@firebase/app-types": "^0.3.2",
6060
"@google-cloud/storage": "^1.1.1",
6161
"@octokit/rest": "^15.9.4",

src/cdk/schematics/#bazel_workaround.txt

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

src/cdk/schematics/BUILD.bazel

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ load("@build_bazel_rules_nodejs//:defs.bzl", "npm_package")
44
load("//:packages.bzl", "VERSION_PLACEHOLDER_REPLACEMENTS")
55
load("//tools:defaults.bzl", "jasmine_node_test", "ts_library")
66

7-
# TODO(devversion): remove when https://github.com/bazelbuild/rules_nodejs/issues/352 is fixed
8-
exports_files(["#bazel_workaround.txt"])
9-
107
filegroup(
118
name = "schematics_assets",
129
srcs = glob(["**/files/**/*", "**/*.json"]),

src/cdk/schematics/ng-add/index.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {Tree} from '@angular-devkit/schematics';
22
import {SchematicTestRunner} from '@angular-devkit/schematics/testing';
3-
import {getFileContent} from '@schematics/angular/utility/test';
4-
import {createTestApp} from '../testing';
3+
import {createTestApp, getFileContent} from '../testing';
54

65
describe('CDK ng-add', () => {
76
let runner: SchematicTestRunner;

src/cdk/schematics/ng-generate/drag-drop/index.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {SchematicTestRunner} from '@angular-devkit/schematics/testing';
2-
import {createTestApp} from '../../testing';
3-
import {getFileContent} from '@schematics/angular/utility/test';
2+
import {createTestApp, getFileContent} from '../../testing';
43
import {Schema} from './schema';
54

65
describe('CDK drag-drop schematic', () => {
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
9+
import {Tree} from '@angular-devkit/schematics';
10+
11+
/** Gets the content of a specified file from a schematic tree. */
12+
export function getFileContent(tree: Tree, filePath: string): string {
13+
const contentBuffer = tree.read(filePath);
14+
15+
if (!contentBuffer) {
16+
throw new Error(`Cannot read "${filePath}" because it does not exist.`);
17+
}
18+
19+
return contentBuffer.toString();
20+
}

src/cdk/schematics/testing/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@
99
export * from './post-scheduled-tasks';
1010
export * from './test-app';
1111
export * from './test-case-setup';
12+
export * from './file-content';

src/lib/schematics/BUILD.bazel

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ npm_package(
4343
jasmine_node_test(
4444
name = "unit_tests",
4545
srcs = [":schematics_test_sources"],
46-
data = [":node_loader_workaround", ":schematics_assets", ":schematics_test_cases"],
46+
data = [":schematics_assets", ":schematics_test_cases"],
4747
)
4848

4949
ts_library(
@@ -70,16 +70,3 @@ filegroup(
7070
]),
7171
testonly = True,
7272
)
73-
74-
# Filegroup that references a text file which comes alphabetically before the
75-
# "cdk/schematics/index.js" file. This is necessary because on Windows in order to support absolute
76-
# paths, the NodeJS rules resolve the actual workspace root by looking for the first entry that
77-
# refers to the Bazel "USER_WORKSPACE" in the MANIFEST file. Since it's alphabetically ordered, and
78-
# the CDK comes always before the Material schematics, we need to make sure that it doesn't resolve
79-
# to the CDK bazel output which has been built as dependency.
80-
# See more: https://github.com/bazelbuild/rules_nodejs/issues/352
81-
filegroup(
82-
name = "node_loader_workaround",
83-
srcs = ["//src/cdk/schematics:#bazel_workaround.txt"],
84-
testonly = True,
85-
)

src/lib/schematics/ng-add/index.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ import {
88
getProjectStyleFile,
99
getProjectTargetOptions,
1010
} from '@angular/cdk/schematics';
11-
import {createTestApp} from '@angular/cdk/schematics/testing';
11+
import {createTestApp, getFileContent} from '@angular/cdk/schematics/testing';
1212
import {getWorkspace} from '@schematics/angular/utility/config';
13-
import {getFileContent} from '@schematics/angular/utility/test';
1413
import {getIndexHtmlPath} from './fonts/project-index-html';
1514

1615
describe('ng-add schematic', () => {

src/lib/schematics/ng-generate/address-form/index.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {SchematicTestRunner} from '@angular-devkit/schematics/testing';
2-
import {createTestApp} from '@angular/cdk/schematics/testing';
3-
import {getFileContent} from '@schematics/angular/utility/test';
2+
import {createTestApp, getFileContent} from '@angular/cdk/schematics/testing';
43
import {Schema} from './schema';
54

65
describe('Material address-form schematic', () => {

src/lib/schematics/ng-generate/dashboard/index.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {SchematicTestRunner} from '@angular-devkit/schematics/testing';
2-
import {createTestApp} from '@angular/cdk/schematics/testing';
3-
import {getFileContent} from '@schematics/angular/utility/test';
2+
import {createTestApp, getFileContent} from '@angular/cdk/schematics/testing';
43
import {Schema} from './schema';
54

65
describe('material-dashboard-schematic', () => {

src/lib/schematics/ng-generate/nav/index.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {SchematicTestRunner} from '@angular-devkit/schematics/testing';
22
import {Schema} from './schema';
3-
import {getFileContent} from '@schematics/angular/utility/test';
4-
import {createTestApp} from '@angular/cdk/schematics/testing';
3+
import {createTestApp, getFileContent} from '@angular/cdk/schematics/testing';
54

65
describe('material-nav-schematic', () => {
76
let runner: SchematicTestRunner;

src/lib/schematics/ng-generate/table/index.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {SchematicTestRunner} from '@angular-devkit/schematics/testing';
2-
import {createTestApp} from '@angular/cdk/schematics/testing';
3-
import {getFileContent} from '@schematics/angular/utility/test';
2+
import {createTestApp, getFileContent} from '@angular/cdk/schematics/testing';
43
import {Schema} from './schema';
54

65
describe('material-table-schematic', () => {

src/lib/schematics/ng-generate/tree/index.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {SchematicTestRunner} from '@angular-devkit/schematics/testing';
2-
import {createTestApp} from '@angular/cdk/schematics/testing';
3-
import {getFileContent} from '@schematics/angular/utility/test';
2+
import {createTestApp, getFileContent} from '@angular/cdk/schematics/testing';
43
import {Schema} from './schema';
54

65
describe('Material tree schematic', () => {

tools/npm/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
"@angular/bazel": "7.0.3",
55
"@angular/compiler": "7.0.3",
66
"@angular/compiler-cli": "7.0.3",
7-
"@bazel/karma": "0.20.3",
8-
"@bazel/typescript": "0.20.3",
7+
"@bazel/karma": "0.21.0",
8+
"@bazel/typescript": "0.21.0",
99
"typescript": "^3.1.1"
1010
},
1111
"scripts": {
1212
"//": "TODO(gregmagolan): figure out how to keep @bazel/karma & @bazel/typescript dependencies here up to date with the root package.json; NOTE: versions of @angular/x don't matter here as they are only require to create the @npm//@angular/bazel target name"
1313
}
14-
}
14+
}

tools/npm/yarn.lock

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@
3535
dependencies:
3636
tslib "^1.9.0"
3737

38-
"@bazel/karma@0.20.3":
39-
version "0.20.3"
40-
resolved "https://registry.yarnpkg.com/@bazel/karma/-/karma-0.20.3.tgz#a63bb82b4887ae8c0d01f3028c6fa4764470851d"
41-
integrity sha512-IgWfTpK9XLEI977DS2kHIEO1QfFTEOBxeNDDjHtd1onmzyMCLROphTOBZ/g42ybUIWyJhS9DK4U3bLSMQE0Bng==
38+
"@bazel/karma@0.21.0":
39+
version "0.21.0"
40+
resolved "https://registry.yarnpkg.com/@bazel/karma/-/karma-0.21.0.tgz#c5ed4c141f44d0e7e18586ad4cff5bd54f70f3cc"
41+
integrity sha512-V5kxijZ7j/6x7+yNxPhhPrjO0APtNrlr5Gg/I9JRy3/SE3Y88yrPNIiEApLkfYWYWGQuoJO2LifUZA8BOXwLEA==
4242
dependencies:
4343
jasmine-core "2.8.0"
4444
karma alexeagle/karma#fa1a84ac881485b5657cb669e9b4e5da77b79f0a
@@ -51,7 +51,16 @@
5151
requirejs "2.3.5"
5252
tmp "0.0.33"
5353

54-
"@bazel/[email protected]", "@bazel/typescript@^0.20.3":
54+
55+
version "0.21.0"
56+
resolved "https://registry.yarnpkg.com/@bazel/typescript/-/typescript-0.21.0.tgz#41c304f77a42c6a016280d0f4c20e0749c3f4b2a"
57+
integrity sha512-ASXj0RFybmqoa3LwqkTU3gNkX9bY9wL/VDNo5hlp9pynYWl4RMpe9V3m/qDIdtSuLJ+qD+Z3FKT/OcpWQHMlYA==
58+
dependencies:
59+
protobufjs "5.0.3"
60+
source-map-support "0.5.9"
61+
tsutils "2.27.2"
62+
63+
"@bazel/typescript@^0.20.3":
5564
version "0.20.3"
5665
resolved "https://registry.yarnpkg.com/@bazel/typescript/-/typescript-0.20.3.tgz#51dcc369c2af0d7f2311d6e692d07776492060f4"
5766
integrity sha512-BZmfzaNkgS++53CGEUk5p9FXOG+k8FNWCDbxzYljoIGP60aIkw4UgRQ24ReBwhCMg6M6KW609yje7AvDZkA6bg==
@@ -2058,7 +2067,7 @@ [email protected]:
20582067
dependencies:
20592068
graceful-fs "^4.1.2"
20602069

2061-
karma@alexeagle/karma#fa1a84ac881485b5657cb669e9b4e5da77b79f0a:
2070+
"karma@github:alexeagle/karma#fa1a84ac881485b5657cb669e9b4e5da77b79f0a":
20622071
version "1.7.1"
20632072
resolved "https://codeload.github.com/alexeagle/karma/tar.gz/fa1a84ac881485b5657cb669e9b4e5da77b79f0a"
20642073
dependencies:

yarn.lock

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,10 @@
248248
resolved "https://registry.yarnpkg.com/@bazel/ibazel/-/ibazel-0.6.0.tgz#b88a6b85e0d7d8adae9aeeba44763044658f1bab"
249249
integrity sha512-6MG/zWWZ98hpZ+MdRS2wdyrX0LWor3Sq4hs0SkhWVSLArzv7Hp4f/NvPs5w4qqBimBFCoRpu42wHl75cqVm/3g==
250250

251-
"@bazel/karma@0.20.3":
252-
version "0.20.3"
253-
resolved "https://registry.yarnpkg.com/@bazel/karma/-/karma-0.20.3.tgz#a63bb82b4887ae8c0d01f3028c6fa4764470851d"
254-
integrity sha512-IgWfTpK9XLEI977DS2kHIEO1QfFTEOBxeNDDjHtd1onmzyMCLROphTOBZ/g42ybUIWyJhS9DK4U3bLSMQE0Bng==
251+
"@bazel/karma@0.21.0":
252+
version "0.21.0"
253+
resolved "https://registry.yarnpkg.com/@bazel/karma/-/karma-0.21.0.tgz#c5ed4c141f44d0e7e18586ad4cff5bd54f70f3cc"
254+
integrity sha512-V5kxijZ7j/6x7+yNxPhhPrjO0APtNrlr5Gg/I9JRy3/SE3Y88yrPNIiEApLkfYWYWGQuoJO2LifUZA8BOXwLEA==
255255
dependencies:
256256
jasmine-core "2.8.0"
257257
karma alexeagle/karma#fa1a84ac881485b5657cb669e9b4e5da77b79f0a
@@ -264,7 +264,16 @@
264264
requirejs "2.3.5"
265265
tmp "0.0.33"
266266

267-
"@bazel/[email protected]", "@bazel/typescript@^0.20.3":
267+
268+
version "0.21.0"
269+
resolved "https://registry.yarnpkg.com/@bazel/typescript/-/typescript-0.21.0.tgz#41c304f77a42c6a016280d0f4c20e0749c3f4b2a"
270+
integrity sha512-ASXj0RFybmqoa3LwqkTU3gNkX9bY9wL/VDNo5hlp9pynYWl4RMpe9V3m/qDIdtSuLJ+qD+Z3FKT/OcpWQHMlYA==
271+
dependencies:
272+
protobufjs "5.0.3"
273+
source-map-support "0.5.9"
274+
tsutils "2.27.2"
275+
276+
"@bazel/typescript@^0.20.3":
268277
version "0.20.3"
269278
resolved "https://registry.yarnpkg.com/@bazel/typescript/-/typescript-0.20.3.tgz#51dcc369c2af0d7f2311d6e692d07776492060f4"
270279
integrity sha512-BZmfzaNkgS++53CGEUk5p9FXOG+k8FNWCDbxzYljoIGP60aIkw4UgRQ24ReBwhCMg6M6KW609yje7AvDZkA6bg==
@@ -6707,7 +6716,7 @@ karma@^3.0.0:
67076716
tmp "0.0.33"
67086717
useragent "2.2.1"
67096718

6710-
karma@alexeagle/karma#fa1a84ac881485b5657cb669e9b4e5da77b79f0a:
6719+
"karma@github:alexeagle/karma#fa1a84ac881485b5657cb669e9b4e5da77b79f0a":
67116720
version "1.7.1"
67126721
resolved "https://codeload.github.com/alexeagle/karma/tar.gz/fa1a84ac881485b5657cb669e9b4e5da77b79f0a"
67136722
dependencies:

0 commit comments

Comments
 (0)