refactor: promote directory_file_path to public API Users with custom rules need to access this when the rule wants to reference labels within a tree artifact such as when using exports_directories_only. Note, I didn't leave anything behind in the private/ folder since the rule implementation is just one line. This also adds the rule to the documentation, previously only the DirectoryFilePathInfo was documented.
diff --git a/docs/Core.md b/docs/Core.md index 3dd1899..f89aea2 100644 --- a/docs/Core.md +++ b/docs/Core.md
@@ -21,6 +21,37 @@ We plan to clean these up and port into `rules_nodejs` in a future major release. +## directory_file_path + +**USAGE** + +<pre> +directory_file_path(<a href="#directory_file_path-name">name</a>, <a href="#directory_file_path-directory">directory</a>, <a href="#directory_file_path-path">path</a>) +</pre> + +Provide DirectoryFilePathInfo to reference some file within a directory. + + Otherwise there is no way to give a Bazel label for it. + +**ATTRIBUTES** + + +<h4 id="directory_file_path-name">name</h4> + +(*<a href="https://bazel.build/docs/build-ref.html#name">Name</a>, mandatory*): A unique name for this target. + + +<h4 id="directory_file_path-directory">directory</h4> + +(*<a href="https://bazel.build/docs/build-ref.html#labels">Label</a>, mandatory*): a directory + + +<h4 id="directory_file_path-path">path</h4> + +(*String, mandatory*): a path within that directory + + + ## node_repositories **USAGE**
diff --git a/internal/common/maybe_directory_file_path.bzl b/internal/common/maybe_directory_file_path.bzl index 41b15f4..dd76d25 100644 --- a/internal/common/maybe_directory_file_path.bzl +++ b/internal/common/maybe_directory_file_path.bzl
@@ -15,7 +15,7 @@ """Helper function to accept either a label or a directory_file_path as dict """ -load("@rules_nodejs//nodejs/private:directory_file_path.bzl", "directory_file_path") +load("@rules_nodejs//nodejs:directory_file_path.bzl", "directory_file_path") def maybe_directory_file_path(name, value): """Pass-through a value or convert a dict with a single key/value pair to a directory_file_path and return its label
diff --git a/internal/node/test/dir_entry_point/BUILD.bazel b/internal/node/test/dir_entry_point/BUILD.bazel index aff8ed9..d1e19bf 100644 --- a/internal/node/test/dir_entry_point/BUILD.bazel +++ b/internal/node/test/dir_entry_point/BUILD.bazel
@@ -1,5 +1,5 @@ load("@bazel_skylib//rules:write_file.bzl", "write_file") -load("@rules_nodejs//nodejs/private:directory_file_path.bzl", "directory_file_path") +load("@rules_nodejs//nodejs:directory_file_path.bzl", "directory_file_path") load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary", "pkg_npm") load("@npm//typescript:index.bzl", "tsc") load("//internal/common:assert.bzl", "assert_program_produces_stdout")
diff --git a/nodejs/private/directory_file_path.bzl b/nodejs/directory_file_path.bzl similarity index 100% rename from nodejs/private/directory_file_path.bzl rename to nodejs/directory_file_path.bzl
diff --git a/nodejs/index.for_docs.bzl b/nodejs/index.for_docs.bzl index 268c92e..4275c0d 100644 --- a/nodejs/index.for_docs.bzl +++ b/nodejs/index.for_docs.bzl
@@ -25,12 +25,14 @@ _declaration_info = "declaration_info", _js_module_info = "js_module_info", ) +load(":directory_file_path.bzl", _directory_file_path = "directory_file_path") load(":repositories.bzl", _node_repositories = "node_repositories") load(":yarn_repositories.bzl", _yarn_repositories = "yarn_repositories") load(":toolchain.bzl", _node_toolchain = "node_toolchain") DeclarationInfo = _DeclarationInfo declaration_info = _declaration_info +directory_file_path = _directory_file_path JSModuleInfo = _JSModuleInfo js_module_info = _js_module_info LinkablePackageInfo = _LinkablePackageInfo