Skip to content

Commit 2138b8a

Browse files
devversionjosephperrott
authored andcommitted
build: remove windows runfile workaround (angular#14173)
* 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 47b5698 commit 2138b8a

File tree

18 files changed

+338
-188
lines changed

18 files changed

+338
-188
lines changed

WORKSPACE

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,22 @@ 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.
2020
http_archive(
2121
name = "angular",
22-
url = "https://github.com/angular/angular/archive/7.0.4.zip",
23-
strip_prefix = "angular-7.0.4",
22+
url = "https://github.com/angular/angular/archive/7.1.0.zip",
23+
strip_prefix = "angular-7.1.0",
2424
)
2525

2626
# Add RxJS as repository because those are needed in order to build Angular from source.
@@ -69,7 +69,8 @@ check_bazel_version("0.18.0")
6969
node_repositories(
7070
# For deterministic builds, specify explicit NodeJS and Yarn versions.
7171
node_version = "10.10.0",
72-
yarn_version = "1.9.4",
72+
# Use latest yarn version to support integrity field (added in yarn 1.10)
73+
yarn_version = "1.12.1",
7374
)
7475

7576
# @npm is temporarily needed to build @rxjs from source since its ts_library

package.json

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,33 +29,33 @@
2929
"version": "7.1.0",
3030
"requiredAngularVersion": ">=7.0.0",
3131
"dependencies": {
32-
"@angular/animations": "^7.0.4",
33-
"@angular/common": "^7.0.4",
34-
"@angular/compiler": "^7.0.4",
35-
"@angular/core": "^7.0.4",
36-
"@angular/elements": "^7.0.4",
37-
"@angular/forms": "^7.0.4",
38-
"@angular/platform-browser": "^7.0.4",
32+
"@angular/animations": "^7.1.0",
33+
"@angular/common": "^7.1.0",
34+
"@angular/compiler": "^7.1.0",
35+
"@angular/core": "^7.1.0",
36+
"@angular/elements": "^7.1.0",
37+
"@angular/forms": "^7.1.0",
38+
"@angular/platform-browser": "^7.1.0",
3939
"@webcomponents/custom-elements": "^1.1.0",
4040
"core-js": "^2.5.7",
4141
"rxjs": "^6.3.3",
4242
"systemjs": "0.19.43",
43-
"tsickle": "^0.32.1",
43+
"tsickle": "^0.34.0",
4444
"tslib": "^1.9.3",
4545
"zone.js": "^0.8.26"
4646
},
4747
"devDependencies": {
4848
"@angular-devkit/core": "^7.0.6",
4949
"@angular-devkit/schematics": "^7.0.6",
50-
"@angular/bazel": "^7.0.4",
51-
"@angular/compiler-cli": "^7.0.4",
52-
"@angular/http": "^7.0.4",
53-
"@angular/platform-browser-dynamic": "^7.0.4",
54-
"@angular/platform-server": "^7.0.4",
55-
"@angular/router": "^7.0.4",
56-
"@bazel/ibazel": "0.6.0",
57-
"@bazel/karma": "0.20.3",
58-
"@bazel/typescript": "0.20.3",
50+
"@angular/bazel": "^7.1.0",
51+
"@angular/compiler-cli": "^7.1.0",
52+
"@angular/http": "^7.1.0",
53+
"@angular/platform-browser-dynamic": "^7.1.0",
54+
"@angular/platform-server": "^7.1.0",
55+
"@angular/router": "^7.1.0",
56+
"@bazel/ibazel": "^0.7.0",
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: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
{
22
"description": "minimal @npm repo required to build @rxjs from source and so that @npm//@angular/bazel is a valid target",
33
"dependencies": {
4-
"@angular/bazel": "7.0.4",
5-
"@angular/compiler": "7.0.4",
6-
"@angular/compiler-cli": "7.0.4",
7-
"@bazel/karma": "0.20.3",
8-
"@bazel/typescript": "0.20.3",
4+
"@angular/bazel": "7.1.0",
5+
"@angular/compiler": "7.1.0",
6+
"@angular/compiler-cli": "7.1.0",
7+
"@bazel/karma": "0.21.0",
8+
"@bazel/typescript": "0.21.0",
99
"typescript": "^3.1.1"
10-
},
11-
"scripts": {
12-
"//": "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"
1310
}
1411
}

0 commit comments

Comments
 (0)