Skip to content

Commit

Permalink
chore: make defs.bzl error
Browse files Browse the repository at this point in the history
BREAKING CHANGE:
Users must now switch to loading from index.bzl

Fixes bazel-contrib#1068
  • Loading branch information
alexeagle committed Oct 24, 2019
1 parent 271a0f6 commit 63c261c
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 66 deletions.
4 changes: 3 additions & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ install_bazel_dependencies()
# With http_archive it only sees releases/download/*.tar.gz urls
git_repository(
name = "build_bazel_rules_typescript",
commit = "fcf33e92a60c2b0613e931d05b305e1d962648e0",
commit = "253bc78ff00a93653d502ea12caf2c78c84e82a5",
patch_args = ["-p1"],
patches = ["//:rules_ts.patch"],
remote = "http://github.com/bazelbuild/rules_typescript.git",
)

Expand Down
83 changes: 18 additions & 65 deletions defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -12,79 +12,32 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""Public API surface is re-exported here.
Users should not load files under "/internal"
"""No longer usable - you must load from index.bzl
"""

load("//internal/common:check_bazel_version.bzl", _check_bazel_version = "check_bazel_version")
load("//internal/common:check_version.bzl", "check_version")
load("//internal/jasmine_node_test:jasmine_node_test.bzl", _jasmine_node_test = "jasmine_node_test")
load(
"//internal/node:node.bzl",
_nodejs_binary = "nodejs_binary",
_nodejs_test = "nodejs_test",
)
load("//internal/node:node_repositories.bzl", _node_repositories = "node_repositories")
load("//internal/node:npm_package_bin.bzl", _npm_bin = "npm_package_bin")
load("//internal/npm_install:npm_install.bzl", _npm_install = "npm_install", _yarn_install = "yarn_install")
load("//internal/npm_package:npm_package.bzl", _npm_package = "npm_package")
load("//internal/rollup:rollup_bundle.bzl", _rollup_bundle = "rollup_bundle")
load(":index.bzl", "VERSION")

check_bazel_version = _check_bazel_version
nodejs_binary = _nodejs_binary
nodejs_test = _nodejs_test
node_repositories = _node_repositories
jasmine_node_test = _jasmine_node_test
rollup_bundle = _rollup_bundle
npm_package = _npm_package
npm_package_bin = _npm_bin
def _error(*args, **kwargs):
fail("""defs.bzl has been removed from build_bazel_rules_nodejs
Please update your load statements to use index.bzl instead.""")

check_bazel_version = _error
nodejs_binary = _error
nodejs_test = _error
node_repositories = _error
jasmine_node_test = _error
rollup_bundle = _error
npm_package = _error
npm_package_bin = _error
# ANY RULES ADDED HERE SHOULD BE DOCUMENTED, see index.for_docs.bzl

def node_modules_filegroup(packages, patterns = [], **kwargs):
native.filegroup(
srcs = native.glob(["/".join([
"node_modules",
pkg,
"**",
ext,
]) for pkg in packages for ext in [
"*.js",
"*.json",
"*.d.ts",
]] + patterns),
**kwargs
)
_error()

def npm_install(**kwargs):
# Just in case the user didn't install nodejs, do it now
_node_repositories()
_npm_install(**kwargs)
_error()

def yarn_install(**kwargs):
# Just in case the user didn't install nodejs, do it now
_node_repositories()
_yarn_install(**kwargs)
_error()

def check_rules_nodejs_version(minimum_version_string):
"""
Verify that a minimum build_bazel_rules_nodejs is loaded a WORKSPACE.
This should be called from the `WORKSPACE` file so that the build fails as
early as possible. For example:
```
# in WORKSPACE:
load("@build_bazel_rules_nodejs//:package.bzl", "check_rules_nodejs_version")
check_rules_nodejs_version("0.11.2")
```
Args:
minimum_version_string: a string indicating the minimum version
"""
if not check_version(VERSION, minimum_version_string):
fail("\nCurrent build_bazel_rules_nodejs version is {}, expected at least {}\n".format(
VERSION,
minimum_version_string,
))
_error()
2 changes: 2 additions & 0 deletions package.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ def rules_nodejs_dev_dependencies():
# Dependencies for generating documentation
http_archive(
name = "io_bazel_rules_sass",
patch_args = ["-p1"],
patches = ["//:rules_sass.patch"],
sha256 = "4f05239080175a3f4efa8982d2b7775892d656bb47e8cf56914d5f9441fb5ea6",
url = "https://github.com/bazelbuild/rules_sass/archive/86ca977cf2a8ed481859f83a286e164d07335116.zip",
strip_prefix = "rules_sass-86ca977cf2a8ed481859f83a286e164d07335116",
Expand Down
25 changes: 25 additions & 0 deletions rules_sass.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
diff --git a/sass/BUILD b/sass/BUILD
index 8963525..dccce74 100644
--- a/sass/BUILD
+++ b/sass/BUILD
@@ -1,6 +1,6 @@
package(default_visibility = ["//visibility:public"])

-load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary")
+load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary")

exports_files([
"sass.bzl",
diff --git a/sass/sass_repositories.bzl b/sass/sass_repositories.bzl
index 4833f41..9cb2056 100644
--- a/sass/sass_repositories.bzl
+++ b/sass/sass_repositories.bzl
@@ -14,7 +14,7 @@

"Install Sass toolchain dependencies"

-load("@build_bazel_rules_nodejs//:defs.bzl", "yarn_install", "check_rules_nodejs_version")
+load("@build_bazel_rules_nodejs//:index.bzl", "yarn_install", "check_rules_nodejs_version")

def sass_repositories():
"""Set up environment for Sass compiler.
13 changes: 13 additions & 0 deletions rules_ts.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/internal/ts_repositories.bzl b/internal/ts_repositories.bzl
index 929db7d..90a1c1a 100644
--- a/internal/ts_repositories.bzl
+++ b/internal/ts_repositories.bzl
@@ -20,7 +20,7 @@
load("@bazel_gazelle//:deps.bzl", "go_repository")

# END-DEV-ONLY
-load("@build_bazel_rules_nodejs//:defs.bzl", "check_bazel_version", "check_rules_nodejs_version")
+load("@build_bazel_rules_nodejs//:index.bzl", "check_bazel_version", "check_rules_nodejs_version")

def ts_setup_workspace():
"""This repository rule should be called from your WORKSPACE file.

0 comments on commit 63c261c

Please sign in to comment.