Skip to content

Commit

Permalink
chore: remove check_bazel_version
Browse files Browse the repository at this point in the history
Also check_rules_nodejs_version, though a stub is left behind to avoid needing a patch in rules_sass which calls it. We can use the one in bazel_skylib instead.

Fixes #2622
  • Loading branch information
alexeagle committed Jan 13, 2022
1 parent 3789472 commit 938753f
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 171 deletions.
34 changes: 0 additions & 34 deletions docs/Built-ins.md
Original file line number Diff line number Diff line change
Expand Up @@ -1631,40 +1631,6 @@ Defaults to `@yarn//:bin/yarn`



## check_bazel_version

**USAGE**

<pre>
check_bazel_version(<a href="#check_bazel_version-minimum_bazel_version">minimum_bazel_version</a>, <a href="#check_bazel_version-message">message</a>)
</pre>

Verify the users Bazel version is at least the given one.

This can be used in rule implementations that depend on changes in Bazel,
to warn users about a mismatch between the rule and their installed Bazel
version.

This should *not* be used in users WORKSPACE files. To locally pin your
Bazel version, just create the .bazelversion file in your workspace.


**PARAMETERS**


<h4 id="check_bazel_version-minimum_bazel_version">minimum_bazel_version</h4>

a string indicating the minimum version



<h4 id="check_bazel_version-message">message</h4>

optional string to print to your users, could be used to help them update

Defaults to `""`


## copy_to_bin

**USAGE**
Expand Down
9 changes: 3 additions & 6 deletions index.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ Users should not load files under "/internal"
"""

load("//:version.bzl", "VERSION")
load("//internal/common:check_bazel_version.bzl", _check_bazel_version = "check_bazel_version")
load("//internal/common:check_version.bzl", "check_version")
load("//internal/common:copy_to_bin.bzl", _copy_to_bin = "copy_to_bin")
load("//internal/common:params_file.bzl", _params_file = "params_file")
Expand All @@ -35,7 +34,6 @@ load("//internal/npm_install:npm_install.bzl", _npm_install = "npm_install", _ya
load("//internal/pkg_npm:pkg_npm.bzl", _pkg_npm = "pkg_npm_macro")
load("//internal/pkg_web:pkg_web.bzl", _pkg_web = "pkg_web")

check_bazel_version = _check_bazel_version
nodejs_binary = _nodejs_binary
nodejs_test = _nodejs_test
node_repositories = _node_repositories
Expand Down Expand Up @@ -102,7 +100,6 @@ def check_build_bazel_rules_nodejs_version(minimum_version_string):
minimum_version_string,
))

# Export check_rules_nodejs_version symbol for pre-5.0 backward compat. This
# will eventually get removed as we move to the core @rules_nodejs package in
# future release.
check_rules_nodejs_version = check_build_bazel_rules_nodejs_version
def check_rules_nodejs_version():
# buildifier: disable=print
print("check_rules_nodejs_version has been removed. This is a no-op, please remove the call.")
2 changes: 0 additions & 2 deletions index.for_docs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ via the `WORKSPACE` install of the `build_bazel_rules_nodejs` workspace.
This is necessary to bootstrap Bazel to run the package manager to download other rules from NPM.
"""

load("//internal/common:check_bazel_version.bzl", _check_bazel_version = "check_bazel_version")
load("//internal/common:copy_to_bin.bzl", _copy_to_bin = "copy_to_bin")
load("//internal/common:params_file.bzl", _params_file = "params_file")
load("//internal/generated_file_test:generated_file_test.bzl", _generated_file_test = "generated_file_test")
Expand All @@ -34,7 +33,6 @@ load("//internal/npm_install:npm_install.bzl", _npm_install = "npm_install", _ya
load("//internal/pkg_npm:pkg_npm.bzl", _pkg_npm = "pkg_npm")
load("//internal/pkg_web:pkg_web.bzl", _pkg_web = "pkg_web")

check_bazel_version = _check_bazel_version
copy_to_bin = _copy_to_bin
params_file = _params_file
nodejs_binary = _nodejs_binary
Expand Down
3 changes: 0 additions & 3 deletions internal/common/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ bzl_library(
visibility = ["//visibility:public"],
)

# Exported to be consumed for generating stardoc.
exports_files(["check_bazel_version.bzl"])

check_version_test_suite()

filegroup(
Expand Down
92 changes: 0 additions & 92 deletions internal/common/check_bazel_version.bzl

This file was deleted.

1 change: 1 addition & 0 deletions internal/node/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ bzl_library(
"//internal/npm_install:bzl",
"//third_party/github.com/bazelbuild/bazel-skylib:bzl",
"@bazel_skylib//lib:types",
"@bazel_skylib//lib:versions",
"@rules_nodejs//nodejs:bzl",
],
)
Expand Down
9 changes: 2 additions & 7 deletions internal/node/node_repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ This is a set of repository rules for setting up hermetic copies of NodeJS and Y
See https://docs.bazel.build/versions/main/skylark/repository_rules.html
"""

load("@bazel_skylib//lib:versions.bzl", "versions")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
load("@rules_nodejs//nodejs/private:os_name.bzl", "OS_ARCH_NAMES", "node_exists_for_os", "os_name")
load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains", node_repositories_rule = "node_repositories")
load("@rules_nodejs//nodejs:yarn_repositories.bzl", "yarn_repositories")
load("//internal/common:check_bazel_version.bzl", "check_bazel_version")

def node_repositories(**kwargs):
"""
Expand All @@ -35,12 +35,7 @@ def node_repositories(**kwargs):
"""

# Require that users update Bazel, so that we don't need to support older ones.
check_bazel_version(
message = """
Bazel current LTS version (4.0.0) is the minimum required to use rules_nodejs.
""",
minimum_bazel_version = "4.0.0",
)
versions.check("4.0.0")

# Back-compat: allow yarn_repositories args to be provided to node_repositories
yarn_args = {}
Expand Down
22 changes: 0 additions & 22 deletions internal/npm_install/npm_install.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ See discussion in the README.
load("@rules_nodejs//nodejs/private:os_name.bzl", "is_windows_os", "os_name")
load("@rules_nodejs//nodejs/private:node_labels.bzl", "get_node_label", "get_npm_label")
load("//:version.bzl", "VERSION")
load("//internal/common:check_bazel_version.bzl", "check_bazel_version")

COMMON_ATTRIBUTES = dict(dict(), **{
"data": attr.label_list(
Expand Down Expand Up @@ -637,27 +636,8 @@ def _symlink_node_modules(repository_ctx):
repository_ctx.path("node_modules"),
)

def _check_min_bazel_version(rule, repository_ctx):
if repository_ctx.attr.symlink_node_modules:
# When using symlink_node_modules enforce the minimum Bazel version required
check_bazel_version(
message = """
A minimum Bazel version of 0.26.0 is required for the %s @%s repository rule.
By default, yarn_install and npm_install in build_bazel_rules_nodejs >= 0.30.0
depends on the managed directory feature added in Bazel 0.26.0. See
https://github.com/bazelbuild/rules_nodejs/wiki#migrating-to-rules_nodejs-030.
You can opt out of this feature by setting `symlink_node_modules = False`
on all of your yarn_install & npm_install rules.
""" % (rule, repository_ctx.attr.name),
minimum_bazel_version = "0.26.0",
)

def _npm_install_impl(repository_ctx):
"""Core implementation of npm_install."""
_check_min_bazel_version("npm_install", repository_ctx)

is_windows_host = is_windows_os(repository_ctx)
node = repository_ctx.path(get_node_label(repository_ctx))
npm = get_npm_label(repository_ctx)
Expand Down Expand Up @@ -804,8 +784,6 @@ def _detect_yarn_version(rctx, yarn):

def _yarn_install_impl(repository_ctx):
"""Core implementation of yarn_install."""
_check_min_bazel_version("yarn_install", repository_ctx)

is_windows_host = is_windows_os(repository_ctx)
node = repository_ctx.path(get_node_label(repository_ctx))
yarn_label = repository_ctx.attr.yarn
Expand Down
7 changes: 2 additions & 5 deletions packages/concatjs/internal/ts_repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
load("@bazel_gazelle//:deps.bzl", "go_repository")

# END-DEV-ONLY
load("@build_bazel_rules_nodejs//:index.bzl", "check_bazel_version", "check_rules_nodejs_version")
load("@bazel_skylib//lib:versions.bzl", "versions")

def ts_setup_workspace():
"""This repository rule should be called from your WORKSPACE file.
Expand All @@ -30,10 +30,7 @@ def ts_setup_workspace():
"""

# 0.18.0: support for .bazelignore
check_bazel_version("0.18.0")

# 0.16.8: ng_package fix for packaging binary files
check_rules_nodejs_version("0.16.8")
versions.check("0.18.0")

# BEGIN-DEV-ONLY
def ts_setup_dev_workspace():
Expand Down

0 comments on commit 938753f

Please sign in to comment.