From ae2f12875f1a223ee0af89ca5915517c5acc2ca3 Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Thu, 19 Sep 2019 21:53:54 -0700 Subject: [PATCH] chore: cleanup some deprecated APIs BREAKING CHANGE: @bazel/typescript and @bazel/karma no longer have a defs.bzl file. Use index.bzl instead. The @yarn workspace is no longer created. Use @nodejs//:yarn instead. Fixes #1144 --- WORKSPACE | 2 +- examples/angular/WORKSPACE | 2 +- examples/angular/e2e/BUILD.bazel | 2 +- examples/angular/src/BUILD.bazel | 2 +- .../angular/src/app/hello-world/BUILD.bazel | 2 +- .../src/app/todos/reducers/BUILD.bazel | 2 +- examples/angular/src/lib/shorten/BUILD.bazel | 2 +- examples/protocol_buffers/WORKSPACE | 2 +- examples/web_testing/WORKSPACE | 2 +- internal/node/node_labels.bzl | 7 ---- internal/node/node_repositories.bzl | 23 ------------ packages/karma/src/defs.bzl | 36 ------------------- packages/typescript/src/defs.bzl | 32 ----------------- packages/typescript/src/package.bzl | 8 ----- 14 files changed, 9 insertions(+), 115 deletions(-) delete mode 100644 packages/karma/src/defs.bzl delete mode 100644 packages/typescript/src/defs.bzl diff --git a/WORKSPACE b/WORKSPACE index bd216e3c33..0641b03e2c 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -106,7 +106,7 @@ install_bazel_dependencies() # With http_archive it only sees releases/download/*.tar.gz urls git_repository( name = "build_bazel_rules_typescript", - commit = "5ad356d09a6d7275bfef6f9717274e7dd9cda978", + commit = "fcf33e92a60c2b0613e931d05b305e1d962648e0", remote = "http://github.com/bazelbuild/rules_typescript.git", ) diff --git a/examples/angular/WORKSPACE b/examples/angular/WORKSPACE index 6694a18c67..397ec3e10d 100644 --- a/examples/angular/WORKSPACE +++ b/examples/angular/WORKSPACE @@ -79,7 +79,7 @@ load("@npm_bazel_karma//:browser_repositories.bzl", "browser_repositories") browser_repositories() # Setup the rules_typescript tooolchain -load("@npm_bazel_typescript//:defs.bzl", "ts_setup_workspace") +load("@npm_bazel_typescript//:index.bzl", "ts_setup_workspace") ts_setup_workspace() diff --git a/examples/angular/e2e/BUILD.bazel b/examples/angular/e2e/BUILD.bazel index c0ccfb79e5..f24e5fb828 100644 --- a/examples/angular/e2e/BUILD.bazel +++ b/examples/angular/e2e/BUILD.bazel @@ -1,5 +1,5 @@ load("@npm_bazel_protractor//:index.bzl", "protractor_web_test_suite") -load("@npm_bazel_typescript//:defs.bzl", "ts_library") +load("@npm_bazel_typescript//:index.bzl", "ts_library") ts_library( name = "e2e", diff --git a/examples/angular/src/BUILD.bazel b/examples/angular/src/BUILD.bazel index caf0652c98..fa693b8194 100644 --- a/examples/angular/src/BUILD.bazel +++ b/examples/angular/src/BUILD.bazel @@ -5,7 +5,7 @@ load("@io_bazel_rules_docker//nodejs:image.bzl", "nodejs_image") load("@io_bazel_rules_sass//:defs.bzl", "sass_binary") load("@npm//history-server:index.bzl", "history_server") load("@npm_angular_bazel//:index.bzl", "ng_module") -load("@npm_bazel_typescript//:defs.bzl", "ts_config", "ts_devserver", "ts_library") +load("@npm_bazel_typescript//:index.bzl", "ts_config", "ts_devserver", "ts_library") package(default_visibility = ["//:__subpackages__"]) diff --git a/examples/angular/src/app/hello-world/BUILD.bazel b/examples/angular/src/app/hello-world/BUILD.bazel index 8e7a5ab1b7..30320345b7 100644 --- a/examples/angular/src/app/hello-world/BUILD.bazel +++ b/examples/angular/src/app/hello-world/BUILD.bazel @@ -1,6 +1,6 @@ load("@io_bazel_rules_sass//:defs.bzl", "sass_binary") load("@npm_angular_bazel//:index.bzl", "ng_module") -load("@npm_bazel_typescript//:defs.bzl", "ts_library") +load("@npm_bazel_typescript//:index.bzl", "ts_library") load("//tools:defaults.bzl", "ts_web_test_suite") package(default_visibility = ["//:__subpackages__"]) diff --git a/examples/angular/src/app/todos/reducers/BUILD.bazel b/examples/angular/src/app/todos/reducers/BUILD.bazel index 518f527c97..7413775a3f 100644 --- a/examples/angular/src/app/todos/reducers/BUILD.bazel +++ b/examples/angular/src/app/todos/reducers/BUILD.bazel @@ -1,4 +1,4 @@ -load("@npm_bazel_typescript//:defs.bzl", "ts_library") +load("@npm_bazel_typescript//:index.bzl", "ts_library") package(default_visibility = ["//:__subpackages__"]) diff --git a/examples/angular/src/lib/shorten/BUILD.bazel b/examples/angular/src/lib/shorten/BUILD.bazel index 6f7ea30995..2cac4d7a7d 100644 --- a/examples/angular/src/lib/shorten/BUILD.bazel +++ b/examples/angular/src/lib/shorten/BUILD.bazel @@ -1,4 +1,4 @@ -load("@npm_bazel_typescript//:defs.bzl", "ts_library") +load("@npm_bazel_typescript//:index.bzl", "ts_library") package(default_visibility = ["//:__subpackages__"]) diff --git a/examples/protocol_buffers/WORKSPACE b/examples/protocol_buffers/WORKSPACE index a02fa0a16d..d005d8c5f7 100644 --- a/examples/protocol_buffers/WORKSPACE +++ b/examples/protocol_buffers/WORKSPACE @@ -67,7 +67,7 @@ browser_repositories( firefox = True, ) -load("@npm_bazel_typescript//:defs.bzl", "ts_setup_workspace") +load("@npm_bazel_typescript//:index.bzl", "ts_setup_workspace") ts_setup_workspace() diff --git a/examples/web_testing/WORKSPACE b/examples/web_testing/WORKSPACE index 5fa7a11704..f79ddd9b25 100644 --- a/examples/web_testing/WORKSPACE +++ b/examples/web_testing/WORKSPACE @@ -50,6 +50,6 @@ load("@npm_bazel_karma//:browser_repositories.bzl", "browser_repositories") browser_repositories() -load("@npm_bazel_typescript//:defs.bzl", "ts_setup_workspace") +load("@npm_bazel_typescript//:index.bzl", "ts_setup_workspace") ts_setup_workspace() diff --git a/internal/node/node_labels.bzl b/internal/node/node_labels.bzl index 8b4130af83..23802823ac 100644 --- a/internal/node/node_labels.bzl +++ b/internal/node/node_labels.bzl @@ -46,10 +46,3 @@ def get_yarn_label(rctx): else: label = Label("@nodejs_%s//:bin/yarn" % os_name(rctx)) return label - -def get_yarn_node_repositories_label(rctx): - if is_windows_os(rctx): - label = Label("@nodejs%s//:bin/yarn_node_repositories.cmd" % os_name(rctx)) - else: - label = Label("@nodejs_%s//:bin/yarn_node_repositories" % os_name(rctx)) - return label diff --git a/internal/node/node_repositories.bzl b/internal/node/node_repositories.bzl index 2d7c62ed3d..a9177d523f 100644 --- a/internal/node/node_repositories.bzl +++ b/internal/node/node_repositories.bzl @@ -24,7 +24,6 @@ load("//internal/common:os_name.bzl", "OS_ARCH_NAMES", "is_windows_os", "os_name load("//internal/npm_install:npm_install.bzl", "yarn_install") load("//third_party/github.com/bazelbuild/bazel-skylib:lib/paths.bzl", "paths") load("//toolchains/node:node_toolchain_configure.bzl", "node_toolchain_configure") -load(":node_labels.bzl", "get_yarn_node_repositories_label") _DOC = """To be run in user's WORKSPACE to install rules_nodejs dependencies. @@ -49,10 +48,6 @@ This rule exposes the `@nodejs` workspace containing some rules the user can cal - Install dependencies using npm: `bazel run @nodejs//:npm install` - Install dependencies using yarn: `bazel run @nodejs//:yarn` -This rule also exposes the `@yarn` workspace for backwards compatibility: - -- Alternately install dependencies using yarn: `bazel run @yarn//:yarn` - Note that the dependency installation scripts will run in each subpackage indicated by the `package_json` attribute. This approach uses npm/yarn as the package manager. You could instead have Bazel act as the package manager, running the install behind the scenes. @@ -608,18 +603,6 @@ node_repositories_rule = repository_rule( attrs = _ATTRS, ) -def _yarn_repo_impl(repository_ctx): - # Base build file for this repository - exposes yarn - repository_ctx.file("BUILD.bazel", content = """# Generated by node_repositories.bzl -package(default_visibility = ["//visibility:public"]) -alias(name = "yarn", actual = "{yarn}") -""".format(yarn = get_yarn_node_repositories_label(repository_ctx))) - -_yarn_repo = repository_rule( - _yarn_repo_impl, - attrs = {"package_json": attr.label_list()}, -) - def _nodejs_host_os_alias_impl(repository_ctx): host_os = os_name(repository_ctx) node_repository = "@nodejs_%s" % host_os @@ -687,12 +670,6 @@ def node_repositories(package_json = [], **kwargs): name = "nodejs", ) - _maybe( - _yarn_repo, - name = "yarn", - package_json = package_json, - ) - _maybe( yarn_install, name = "build_bazel_rules_nodejs_rollup_deps", diff --git a/packages/karma/src/defs.bzl b/packages/karma/src/defs.bzl deleted file mode 100644 index a66f538d62..0000000000 --- a/packages/karma/src/defs.bzl +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright 2017 The Bazel Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -""" Public API surface is re-exported here. - -DEPRECATION WARNING: This file is here for backward compatability. -New rules will be added to index.bzl. -""" - -load( - ":karma_web_test.bzl", - _karma_web_test = "karma_web_test", - _karma_web_test_suite = "karma_web_test_suite", -) -load( - ":ts_web_test.bzl", - _ts_web_test = "ts_web_test", - _ts_web_test_suite = "ts_web_test_suite", -) - -ts_web_test = _ts_web_test -ts_web_test_suite = _ts_web_test_suite -karma_web_test = _karma_web_test -karma_web_test_suite = _karma_web_test_suite -# DO NOT ADD MORE rules here. New rules should be added to index.bzl. diff --git a/packages/typescript/src/defs.bzl b/packages/typescript/src/defs.bzl deleted file mode 100644 index 4da539cc1d..0000000000 --- a/packages/typescript/src/defs.bzl +++ /dev/null @@ -1,32 +0,0 @@ -# Copyright 2017 The Bazel Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -""" Public API surface is re-exported here. - -DEPRECATION WARNING: This file is here for backward compatability. -New rules will be added to index.bzl. -""" - -load("//:version.bzl", _check_rules_typescript_version = "check_rules_typescript_version") -load("//internal:build_defs.bzl", _ts_library = "ts_library_macro") -load("//internal:ts_config.bzl", _ts_config = "ts_config") -load("//internal:ts_repositories.bzl", _ts_setup_workspace = "ts_setup_workspace") -load("//internal/devserver:ts_devserver.bzl", _ts_devserver = "ts_devserver_macro") - -check_rules_typescript_version = _check_rules_typescript_version -ts_setup_workspace = _ts_setup_workspace -ts_library = _ts_library -ts_config = _ts_config -ts_devserver = _ts_devserver -# DO NOT ADD MORE rules here. New rules should be added to index.bzl. diff --git a/packages/typescript/src/package.bzl b/packages/typescript/src/package.bzl index 33f3898991..31b25ae47e 100644 --- a/packages/typescript/src/package.bzl +++ b/packages/typescript/src/package.bzl @@ -17,14 +17,6 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -def rules_typescript_dependencies(): - print("""DEPRECATION WARNING: - rules_typescript_dependencies is no longer needed, and will be removed in a future release. - We assume you will fetch rules_nodejs in your WORKSPACE file, and no other dependencies remain here. - Simply remove any calls to this function and the corresponding call to - load("@npm_bazel_typescript//:package.bzl", "rules_typescript_dependencies") - """) - def rules_typescript_dev_dependencies(): """ Fetch dependencies needed for local development.