build: update to nodejs rules 0.34.0 and bazel 0.28.1 (#31824)

nodejs rules 0.34.0 now includes protractor_web_test_suite rule (via new @bazel/protractor rule) so we switch to that location for that rule in this PR so that /packages/bazel/src/protractor can be removed in a future PR

this PR also brings in node toolchain support which was released in nodejs rules 0.33.0. this is a prerequisite for RBE for mac & windows users

bazel schematics also updated with the same. @bazel/bazel 0.28.1 npm package includes transitive dep on hide-bazel-files so we're able to remove an explicit dep on that as well.

PR Close #31824
This commit is contained in:
Greg Magolan
2019-07-24 08:52:26 -07:00
committed by Andrew Kushnir
parent 5296c04f61
commit 5f0d5e9ccf
31 changed files with 243 additions and 282 deletions

View File

@ -25,12 +25,13 @@ def rules_angular_dev_dependencies():
"""
# Needed for Remote Execution
# https://github.com/bazelbuild/bazel-toolchains/releases
_maybe(
http_archive,
name = "bazel_toolchains",
sha256 = "4598bf5a8b4f5ced82c782899438a7ba695165d47b3bf783ce774e89a8c6e617",
strip_prefix = "bazel-toolchains-0.27.0",
url = "https://github.com/bazelbuild/bazel-toolchains/archive/0.27.0.tar.gz",
sha256 = "dcb58e7e5f0b4da54c6c5f8ebc65e63fcfb37414466010cf82ceff912162296e",
strip_prefix = "bazel-toolchains-0.28.2",
url = "https://github.com/bazelbuild/bazel-toolchains/archive/0.28.2.tar.gz",
)
#############################################

View File

@ -15,8 +15,8 @@ workspace(
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
RULES_NODEJS_VERSION = "0.32.2"
RULES_NODEJS_SHA256 = "6d4edbf28ff6720aedf5f97f9b9a7679401bf7fca9d14a0fff80f644a99992b4"
RULES_NODEJS_VERSION = "0.34.0"
RULES_NODEJS_SHA256 = "7c4a690268be97c96f04d505224ec4cb1ae53c2c2b68be495c9bd2634296a5cd"
http_archive(
name = "build_bazel_rules_nodejs",
sha256 = RULES_NODEJS_SHA256,
@ -63,8 +63,6 @@ node_repositories(
yarn_install(
name = "npm",
# TODO(gregmagolan): fix rules_nodejs so that if @bazel/hide-bazel-files is detected then this is forced true
always_hide_bazel_files = True,
package_json = "//:package.json",
yarn_lock = "//:yarn.lock",
)
@ -72,6 +70,9 @@ yarn_install(
load("@npm//:install_bazel_dependencies.bzl", "install_bazel_dependencies")
install_bazel_dependencies()
load("@npm_bazel_protractor//:package.bzl", "npm_bazel_protractor_dependencies")
npm_bazel_protractor_dependencies()
load("@npm_bazel_karma//:package.bzl", "rules_karma_dependencies")
rules_karma_dependencies()

View File

@ -1,5 +1,5 @@
load("@npm_bazel_protractor//:index.bzl", "protractor_web_test_suite")
load("@npm_bazel_typescript//:index.bzl", "ts_library")
load("@npm_angular_bazel//:index.bzl", "protractor_web_test_suite")
ts_library(
name = "e2e_lib",
@ -21,10 +21,6 @@ ts_library(
protractor_web_test_suite(
name = "prodserver_test",
data = [
"@npm//@angular/bazel",
"@npm//protractor",
],
on_prepare = ":protractor.on-prepare.js",
server = "//src:prodserver",
deps = [":e2e_lib"],
@ -32,10 +28,6 @@ protractor_web_test_suite(
protractor_web_test_suite(
name = "devserver_test",
data = [
"@npm//@angular/bazel",
"@npm//protractor",
],
on_prepare = ":protractor.on-prepare.js",
server = "//src:devserver",
deps = [":e2e_lib"],

View File

@ -5,11 +5,11 @@
// If the function returns a promise, as it does here, protractor will wait
// for the promise to resolve before running tests.
const protractorUtils = require('@angular/bazel/protractor-utils');
const protractorUtils = require('@bazel/protractor/protractor-utils');
const protractor = require('protractor');
module.exports = function(config) {
// In this example, `@angular/bazel/protractor-utils` is used to run
// In this example, `@bazel/protractor/protractor-utils` is used to run
// the server. protractorUtils.runServer() runs the server on a randomly
// selected port (given a port flag to pass to the server as an argument).
// The port used is returned in serverSpec and the protractor serverUrl

View File

@ -48,11 +48,11 @@ function addDevDependenciesToPackageJson(options: Schema) {
const devDependencies: {[k: string]: string} = {
'@angular/bazel': angularCoreVersion,
'@bazel/bazel': '^0.27.0',
'@bazel/hide-bazel-files': '0.32.2',
'@bazel/bazel': '^0.28.1',
'@bazel/ibazel': '^0.10.2',
'@bazel/karma': '0.32.2',
'@bazel/typescript': '0.32.2',
'@bazel/karma': '0.34.0',
'@bazel/protractor': '0.34.0',
'@bazel/typescript': '0.34.0',
};
const recorder = host.beginUpdate(packageJson);

View File

@ -113,9 +113,10 @@ describe('ng-add schematic', () => {
const json = JSON.parse(content);
const devDeps = Object.keys(json.devDependencies);
expect(devDeps).toContain('@bazel/bazel');
expect(devDeps).toContain('@bazel/hide-bazel-files');
expect(devDeps).toContain('@bazel/ibazel');
expect(devDeps).toContain('@bazel/karma');
expect(devDeps).toContain('@bazel/protractor');
expect(devDeps).toContain('@bazel/typescript');
});
it('should replace an existing dev dependency', async() => {

View File

@ -11,9 +11,28 @@ const shx = require('shelljs');
const os = require('os');
const {runCommand, setupTestDirectory} = require('./test_helpers');
// Nodejs toolchains were included in nodejs rules 0.33.0 so the
// repository name for the nodejs toolchain now depends on the platform
// being run on. The following function returns the nodejs repository
// name of the runtime platform platform. These come from
// https://github.com/bazelbuild/rules_nodejs/blob/2a0be492c5d506665798f04673ab1a646c883626/internal/node/node_repositories.bzl#L598.
function nodejs_repository() {
switch (os.platform()) {
case 'darwin':
return 'nodejs_darwin_amd64';
case 'linux':
return 'nodejs_linux_amd64';
case 'win32':
return 'nodejs_windows_amd64';
default:
throw 'Platform not supported';
}
}
const ngcBin = require.resolve('./ngc_bin');
const xi18nBin = require.resolve('./ng_xi18n');
const nodeBin = require.resolve(`nodejs/bin/node${(os.platform() === 'win32' ? '.cmd' : '')}`);
const nodeBin =
require.resolve(`${nodejs_repository()}/bin/node${(os.platform() === 'win32' ? '.cmd' : '')}`);
const jasmineBin = require.resolve('npm/node_modules/jasmine/bin/jasmine.js');
// Prepare the test directory before building the integration test output. This ensures that

View File

@ -7,7 +7,7 @@ ts_config(
name = "tsconfig",
src = "tsconfig.json",
deps = [
"//tools:tsconfig-test",
"//packages:tsconfig-test",
],
)

View File

@ -1,7 +1,7 @@
package(default_visibility = ["//visibility:public"])
load("//packages/bazel:index.bzl", "protractor_web_test_suite")
load("//tools:defaults.bzl", "ng_module", "ts_library")
load("@npm_bazel_protractor//:index.bzl", "protractor_web_test_suite")
load("@npm_bazel_typescript//:index.bzl", "ts_devserver")
ng_module(

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
const protractorUtils = require('@angular/bazel/protractor-utils');
const protractorUtils = require('@bazel/protractor/protractor-utils');
const protractor = require('protractor');
module.exports = async function(config) {

View File

@ -1,7 +1,7 @@
package(default_visibility = ["//visibility:public"])
load("//packages/bazel:index.bzl", "protractor_web_test_suite")
load("//tools:defaults.bzl", "jasmine_node_test", "ng_module", "ts_library")
load("@npm_bazel_protractor//:index.bzl", "protractor_web_test_suite")
load("@npm_bazel_typescript//:index.bzl", "ts_devserver")
ng_module(

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
const protractorUtils = require('@angular/bazel/protractor-utils');
const protractorUtils = require('@bazel/protractor/protractor-utils');
const protractor = require('protractor');
module.exports = async function(config) {

View File

@ -1,7 +1,7 @@
package(default_visibility = ["//visibility:public"])
load("//packages/bazel:index.bzl", "protractor_web_test_suite")
load("//tools:defaults.bzl", "ng_module", "ts_library")
load("@npm_bazel_protractor//:index.bzl", "protractor_web_test_suite")
load("@npm_bazel_typescript//:index.bzl", "ts_devserver")
ng_module(

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
const protractorUtils = require('@angular/bazel/protractor-utils');
const protractorUtils = require('@bazel/protractor/protractor-utils');
const protractor = require('protractor');
module.exports = async function(config) {

View File

@ -1,7 +1,7 @@
package(default_visibility = ["//visibility:public"])
load("//packages/bazel:index.bzl", "protractor_web_test_suite")
load("//tools:defaults.bzl", "ng_module", "ts_library")
load("@npm_bazel_protractor//:index.bzl", "protractor_web_test_suite")
load("@npm_bazel_typescript//:index.bzl", "ts_devserver")
ng_module(

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
const protractorUtils = require('@angular/bazel/protractor-utils');
const protractorUtils = require('@bazel/protractor/protractor-utils');
const protractor = require('protractor');
module.exports = async function(config) {

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
const protractorUtils = require('@angular/bazel/protractor-utils');
const protractorUtils = require('@bazel/protractor/protractor-utils');
const protractor = require('protractor');
module.exports = async function(config) {

View File

@ -1,5 +1,5 @@
load("//packages/bazel:index.bzl", "protractor_web_test_suite")
load("//tools:defaults.bzl", "ng_module", "ts_library")
load("@npm_bazel_protractor//:index.bzl", "protractor_web_test_suite")
load("@npm_bazel_typescript//:index.bzl", "ts_devserver")
"""