From 6712a19c205dff0eb4f6171eeeea02fe5bdeff96 Mon Sep 17 00:00:00 2001 From: Greg Magolan Date: Tue, 2 Apr 2024 21:54:41 -0400 Subject: [PATCH] refactor: also register bazel-lib coreutils toolchain now that we depend on a mininum bazel-lib 2.6.1 (#1582) --- .github/workflows/release_prep.sh | 11 ----------- WORKSPACE | 4 +--- docs/npm_translate_lock.md | 5 +++-- e2e/pnpm_workspace/WORKSPACE | 4 +--- e2e/pnpm_workspace_deps/WORKSPACE | 4 +--- npm/extensions.bzl | 1 + npm/private/npm_translate_lock.bzl | 14 +++++++++++++- 7 files changed, 20 insertions(+), 23 deletions(-) diff --git a/.github/workflows/release_prep.sh b/.github/workflows/release_prep.sh index 6d8594c40..16c129e94 100755 --- a/.github/workflows/release_prep.sh +++ b/.github/workflows/release_prep.sh @@ -72,14 +72,3 @@ EOF awk 'f;/--SNIP--/{f=1}' e2e/workspace/WORKSPACE echo "\`\`\`" - -cat <name, verify_node_modules_ignored, verify_patches, quiet, external_repository_action_cache, link_workspace, pnpm_version, use_pnpm, register_copy_directory_toolchains, register_copy_to_directory_toolchains, - register_yq_toolchains, register_tar_toolchains, npm_package_target_name, - use_starlark_yaml_parser, kwargs) + register_coreutils_toolchains, register_yq_toolchains, register_tar_toolchains, + npm_package_target_name, use_starlark_yaml_parser, kwargs) Repository macro to generate starlark code from a lock file. @@ -134,6 +134,7 @@ For more about how to use npm_translate_lock, read [pnpm and rules_js](/docs/pnp | use_pnpm | label of the pnpm entry point to use. | `None` | | register_copy_directory_toolchains | if True, `@aspect_bazel_lib//lib:repositories.bzl` `register_copy_directory_toolchains()` is called if the toolchain is not already registered | `True` | | register_copy_to_directory_toolchains | if True, `@aspect_bazel_lib//lib:repositories.bzl` `register_copy_to_directory_toolchains()` is called if the toolchain is not already registered | `True` | +| register_coreutils_toolchains | if True, `@aspect_bazel_lib//lib:repositories.bzl` `register_coreutils_toolchains()` is called if the toolchain is not already registered | `True` | | register_yq_toolchains | if True, `@aspect_bazel_lib//lib:repositories.bzl` `register_yq_toolchains()` is called if the toolchain is not already registered | `True` | | register_tar_toolchains | if True, `@aspect_bazel_lib//lib:repositories.bzl` `register_tar_toolchains()` is called if the toolchain is not already registered | `True` | | npm_package_target_name | The name of linked `npm_package` targets. When `npm_package` targets are linked as pnpm workspace packages, the name of the target must align with this value.

The `{dirname}` placeholder is replaced with the directory name of the target.

By default the directory name of the target is used.

Default: `{dirname}` | `"{dirname}"` | diff --git a/e2e/pnpm_workspace/WORKSPACE b/e2e/pnpm_workspace/WORKSPACE index 2e8911717..94f6b80b7 100644 --- a/e2e/pnpm_workspace/WORKSPACE +++ b/e2e/pnpm_workspace/WORKSPACE @@ -7,12 +7,10 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") rules_js_dependencies() -load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies", "register_coreutils_toolchains") +load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies") aspect_bazel_lib_dependencies() -register_coreutils_toolchains() - load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains") nodejs_register_toolchains( diff --git a/e2e/pnpm_workspace_deps/WORKSPACE b/e2e/pnpm_workspace_deps/WORKSPACE index 1d7985616..2706ec3ab 100644 --- a/e2e/pnpm_workspace_deps/WORKSPACE +++ b/e2e/pnpm_workspace_deps/WORKSPACE @@ -7,12 +7,10 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") rules_js_dependencies() -load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies", "register_coreutils_toolchains") +load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies") aspect_bazel_lib_dependencies() -register_coreutils_toolchains() - load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains") nodejs_register_toolchains( diff --git a/npm/extensions.bzl b/npm/extensions.bzl index a94f6064b..329820c2b 100644 --- a/npm/extensions.bzl +++ b/npm/extensions.bzl @@ -66,6 +66,7 @@ def _npm_translate_lock_bzlmod(attr): quiet = attr.quiet, register_copy_directory_toolchains = False, # this registration is handled elsewhere with bzlmod register_copy_to_directory_toolchains = False, # this registration is handled elsewhere with bzlmod + register_coreutils_toolchains = False, # this registration is handled elsewhere with bzlmod register_yq_toolchains = False, # this registration is handled elsewhere with bzlmod register_tar_toolchains = False, # this registration is handled elsewhere with bzlmod replace_packages = attr.replace_packages, diff --git a/npm/private/npm_translate_lock.bzl b/npm/private/npm_translate_lock.bzl index 474545e97..ba0c5ba64 100644 --- a/npm/private/npm_translate_lock.bzl +++ b/npm/private/npm_translate_lock.bzl @@ -26,7 +26,14 @@ Advanced users may want to directly fetch a package from npm rather than start f """ load("@bazel_skylib//lib:paths.bzl", "paths") -load("@aspect_bazel_lib//lib:repositories.bzl", _register_copy_directory_toolchains = "register_copy_directory_toolchains", _register_copy_to_directory_toolchains = "register_copy_to_directory_toolchains", _register_tar_toolchains = "register_tar_toolchains", _register_yq_toolchains = "register_yq_toolchains") +load( + "@aspect_bazel_lib//lib:repositories.bzl", + _register_copy_directory_toolchains = "register_copy_directory_toolchains", + _register_copy_to_directory_toolchains = "register_copy_to_directory_toolchains", + _register_coreutils_toolchains = "register_coreutils_toolchains", + _register_tar_toolchains = "register_tar_toolchains", + _register_yq_toolchains = "register_yq_toolchains", +) load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_file") load(":list_sources.bzl", "list_sources") load(":npm_translate_lock_generate.bzl", "generate_repository_files") @@ -188,6 +195,7 @@ def npm_translate_lock( use_pnpm = None, register_copy_directory_toolchains = True, register_copy_to_directory_toolchains = True, + register_coreutils_toolchains = True, register_yq_toolchains = True, register_tar_toolchains = True, npm_package_target_name = "{dirname}", @@ -508,6 +516,8 @@ def npm_translate_lock( register_copy_to_directory_toolchains: if True, `@aspect_bazel_lib//lib:repositories.bzl` `register_copy_to_directory_toolchains()` is called if the toolchain is not already registered + register_coreutils_toolchains: if True, `@aspect_bazel_lib//lib:repositories.bzl` `register_coreutils_toolchains()` is called if the toolchain is not already registered + register_yq_toolchains: if True, `@aspect_bazel_lib//lib:repositories.bzl` `register_yq_toolchains()` is called if the toolchain is not already registered register_tar_toolchains: if True, `@aspect_bazel_lib//lib:repositories.bzl` `register_tar_toolchains()` is called if the toolchain is not already registered @@ -554,6 +564,8 @@ def npm_translate_lock( _register_copy_directory_toolchains() if register_copy_to_directory_toolchains and not native.existing_rule("copy_to_directory_toolchains"): _register_copy_to_directory_toolchains() + if register_coreutils_toolchains and not native.existing_rule("register_coreutils_toolchains"): + _register_coreutils_toolchains() if register_yq_toolchains and not native.existing_rule("yq_toolchains"): _register_yq_toolchains() if register_tar_toolchains and not native.existing_rule("tar_toolchains"):