Skip to content

Commit

Permalink
refactor: rename js_filegroup to js_info_files (#1615)
Browse files Browse the repository at this point in the history
  • Loading branch information
gregmagolan authored and jbedard committed May 8, 2024
1 parent 7c0207e commit 7e4d7a7
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 68 deletions.
4 changes: 2 additions & 2 deletions docs/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ stardoc_with_diff_test(
)

stardoc_with_diff_test(
name = "js_filegroup",
bzl_library_target = "//js/private:js_filegroup",
name = "js_info_files",
bzl_library_target = "//js/private:js_info_files",
)

stardoc_with_diff_test(
Expand Down
32 changes: 0 additions & 32 deletions docs/js_filegroup.md

This file was deleted.

32 changes: 32 additions & 0 deletions docs/js_info_files.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions docs/js_run_binary.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions js/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ load(
_js_run_binary = "js_run_binary",
)
load(
"//js/private:js_filegroup.bzl",
_js_filegroup = "js_filegroup",
"//js/private:js_info_files.bzl",
_js_info_files = "js_info_files",
)
load(
"//js/private:js_run_devserver.bzl",
Expand Down Expand Up @@ -45,7 +45,7 @@ def js_test(**kwargs):
)

js_run_devserver = _js_run_devserver
js_filegroup = _js_filegroup
js_info_files = _js_info_files
js_library = _js_library
js_run_binary = _js_run_binary
js_image_layer = _js_image_layer
6 changes: 3 additions & 3 deletions js/private/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ exports_files([
])

bzl_library(
name = "js_filegroup",
srcs = ["js_filegroup.bzl"],
name = "js_info_files",
srcs = ["js_info_files.bzl"],
visibility = [
"//docs:__subpackages__",
"//js:__subpackages__",
Expand Down Expand Up @@ -87,8 +87,8 @@ bzl_library(
"//js:__subpackages__",
],
deps = [
":js_filegroup",
":js_helpers",
":js_info_files",
":js_library",
"@aspect_bazel_lib//lib:copy_to_bin",
"@aspect_bazel_lib//lib:run_binary",
Expand Down
20 changes: 10 additions & 10 deletions js/private/js_helpers.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -193,15 +193,15 @@ def gather_runfiles(
file such as a file in an external repository. In most cases, this option is not needed.
See `copy_data_files_to_bin` docstring for more info.
include_sources: see js_filegroup documentation
include_sources: see js_info_files documentation
include_transitive_sources: see js_filegroup documentation
include_transitive_sources: see js_info_files documentation
include_declarations: see js_filegroup documentation
include_declarations: see js_info_files documentation
include_transitive_declarations: see js_filegroup documentation
include_transitive_declarations: see js_info_files documentation
include_npm_linked_packages: see js_filegroup documentation
include_npm_linked_packages: see js_info_files documentation
Returns:
A [runfiles](https://bazel.build/rules/lib/runfiles) object created with [ctx.runfiles](https://bazel.build/rules/lib/ctx#runfiles).
Expand Down Expand Up @@ -293,11 +293,11 @@ def gather_files_from_js_providers(
Args:
targets: list of target to gather from
include_sources: see js_filegroup documentation
include_transitive_sources: see js_filegroup documentation
include_declarations: see js_filegroup documentation
include_transitive_declarations: see js_filegroup documentation
include_npm_linked_packages: see js_filegroup documentation
include_sources: see js_info_files documentation
include_transitive_sources: see js_info_files documentation
include_declarations: see js_info_files documentation
include_transitive_declarations: see js_info_files documentation
include_npm_linked_packages: see js_info_files documentation
Returns:
A depset of files
Expand Down
6 changes: 3 additions & 3 deletions js/private/js_filegroup.bzl → js/private/js_info_files.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ _DOC = """Gathers files from the JsInfo providers from targets in srcs and provi
This helper rule is used by the `js_run_binary` macro.
"""

def _js_filegroup_impl(ctx):
def _js_info_files_impl(ctx):
return DefaultInfo(files = _gather_files_from_js_providers(
targets = ctx.attr.srcs,
include_sources = ctx.attr.include_sources,
Expand All @@ -17,9 +17,9 @@ def _js_filegroup_impl(ctx):
include_npm_linked_packages = ctx.attr.include_npm_linked_packages,
))

js_filegroup = rule(
js_info_files = rule(
doc = _DOC,
implementation = _js_filegroup_impl,
implementation = _js_info_files_impl,
attrs = {
"srcs": attr.label_list(
doc = """List of targets to gather files from.""",
Expand Down
24 changes: 12 additions & 12 deletions js/private/js_run_binary.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ load("@aspect_bazel_lib//lib:utils.bzl", bazel_lib_utils = "utils")
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", _copy_to_bin = "copy_to_bin")
load("@bazel_skylib//lib:dicts.bzl", "dicts")
load(":js_helpers.bzl", _envs_for_log_level = "envs_for_log_level")
load(":js_filegroup.bzl", _js_filegroup = "js_filegroup")
load(":js_info_files.bzl", _js_info_files = "js_info_files")
load(":js_library.bzl", _js_library = "js_library")

def js_run_binary(
Expand Down Expand Up @@ -150,11 +150,11 @@ def js_run_binary(
copy_srcs_to_bin: When True, all srcs files are copied to the output tree that are not already there.
include_transitive_sources: see `js_filegroup` documentation
include_transitive_sources: see `js_info_files` documentation
include_declarations: see `js_filegroup` documentation
include_declarations: see `js_info_files` documentation
include_npm_linked_packages: see `js_filegroup` documentation
include_npm_linked_packages: see `js_info_files` documentation
log_level: Set the logging level of the `js_binary` tool.
Expand Down Expand Up @@ -245,13 +245,13 @@ def js_run_binary(
extra_srcs = []

# Hoist js provider files to DefaultInfo
make_js_filegroup_target = (include_transitive_sources or
include_declarations or
include_npm_linked_packages)
if make_js_filegroup_target:
js_filegroup_name = "{}_js_filegroup".format(name)
_js_filegroup(
name = js_filegroup_name,
make_js_info_files_target = (include_transitive_sources or
include_declarations or
include_npm_linked_packages)
if make_js_info_files_target:
js_info_files_name = "{}_js_info_files".format(name)
_js_info_files(
name = js_info_files_name,
srcs = srcs,
include_transitive_sources = include_transitive_sources,
include_declarations = include_declarations,
Expand All @@ -261,7 +261,7 @@ def js_run_binary(
# Always propagate the testonly attribute
testonly = kwargs.get("testonly", False),
)
extra_srcs.append(":{}".format(js_filegroup_name))
extra_srcs.append(":{}".format(js_info_files_name))

# Copy srcs to bin
if copy_srcs_to_bin:
Expand Down

0 comments on commit 7e4d7a7

Please sign in to comment.