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', () => {

0 commit comments

Comments
 (0)