Compare commits
3 Commits
a21ff13cf2
...
2a24b83d2f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2a24b83d2f | ||
|
|
36c1beb4d7 | ||
|
|
8cfc9af83d |
1
.bazelignore
Normal file
1
.bazelignore
Normal file
@@ -0,0 +1 @@
|
||||
.direnv
|
||||
2
MODULE.bazel.lock
generated
2
MODULE.bazel.lock
generated
@@ -189,7 +189,7 @@
|
||||
"moduleExtensions": {
|
||||
"//bun:extensions.bzl%bun": {
|
||||
"general": {
|
||||
"bzlTransitiveDigest": "OnZvc44B8aCFH7E+udHBoIoIkL0AeKA27+2lmg/S15Q=",
|
||||
"bzlTransitiveDigest": "Q0uQOwFAgAU+etePCZ4TUDO+adLX7Z0EmRLaEsKgncw=",
|
||||
"usagesDigest": "qk1PDh3WICa0VONYKXJLsmWCesNJxz3Jkb/aH/voIeI=",
|
||||
"recordedInputs": [
|
||||
"REPO_MAPPING:,bazel_tools bazel_tools"
|
||||
|
||||
@@ -40,3 +40,8 @@ Phase 6 bootstrap is in place:
|
||||
- Source grouping rules `js_library` / `ts_library` (`/internal/js_library.bzl`)
|
||||
- Transitive `deps` propagation wired into `bun_bundle` and `bun_test`
|
||||
- Focused dependency-propagation tests (`//tests/library_test:all`)
|
||||
|
||||
Phase 7 bootstrap is in place:
|
||||
|
||||
- Bzlmod `bun_install` module extension (`/bun/extensions.bzl`) using Bazel 9-compatible extension/tag syntax
|
||||
- Focused module-extension shape test (`//tests/install_extension_test:all`)
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
load(":toolchain.bzl", "bun_toolchain")
|
||||
load(":version.bzl", "BUN_VERSION")
|
||||
|
||||
exports_files(["defs.bzl"])
|
||||
exports_files([
|
||||
"defs.bzl",
|
||||
"extensions.bzl",
|
||||
])
|
||||
|
||||
toolchain_type(name = "toolchain_type")
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
||||
load("//internal:bun_install.bzl", "bun_install_repository")
|
||||
load(":version.bzl", "BUN_VERSION")
|
||||
|
||||
_BUN_ARCHIVES = {
|
||||
@@ -53,3 +54,27 @@ filegroup(
|
||||
bun = module_extension(
|
||||
implementation = _bun_repos_impl,
|
||||
)
|
||||
|
||||
_install = tag_class(
|
||||
attrs = {
|
||||
"name": attr.string(mandatory = True),
|
||||
"package_json": attr.string(mandatory = True),
|
||||
"bun_lockfile": attr.string(mandatory = True),
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
def _bun_install_impl(ctx):
|
||||
for mod in ctx.modules:
|
||||
for install in mod.tags.install:
|
||||
bun_install_repository(
|
||||
name = install.name,
|
||||
package_json = install.package_json,
|
||||
bun_lockfile = install.bun_lockfile,
|
||||
)
|
||||
|
||||
|
||||
bun_install = module_extension(
|
||||
implementation = _bun_install_impl,
|
||||
tag_classes = {"install": _install},
|
||||
)
|
||||
|
||||
@@ -61,7 +61,7 @@ stderr:
|
||||
)
|
||||
|
||||
|
||||
_bun_install_repository = repository_rule(
|
||||
bun_install_repository = repository_rule(
|
||||
implementation = _bun_install_repository_impl,
|
||||
attrs = {
|
||||
"package_json": attr.label(mandatory = True, allow_single_file = True),
|
||||
@@ -74,6 +74,8 @@ _bun_install_repository = repository_rule(
|
||||
},
|
||||
)
|
||||
|
||||
_bun_install_repository = bun_install_repository
|
||||
|
||||
|
||||
def bun_install(name, package_json, bun_lockfile):
|
||||
"""Create an external repository containing installed node_modules.
|
||||
@@ -91,7 +93,7 @@ def bun_install(name, package_json, bun_lockfile):
|
||||
)
|
||||
"""
|
||||
|
||||
_bun_install_repository(
|
||||
bun_install_repository(
|
||||
name = name,
|
||||
package_json = package_json,
|
||||
bun_lockfile = bun_lockfile,
|
||||
|
||||
8
tests/install_extension_test/BUILD.bazel
Normal file
8
tests/install_extension_test/BUILD.bazel
Normal file
@@ -0,0 +1,8 @@
|
||||
load("@rules_shell//shell:sh_test.bzl", "sh_test")
|
||||
|
||||
sh_test(
|
||||
name = "bun_install_extension_shape_test",
|
||||
srcs = ["extension_shape_test.sh"],
|
||||
args = ["$(location //bun:extensions.bzl)"],
|
||||
data = ["//bun:extensions.bzl"],
|
||||
)
|
||||
10
tests/install_extension_test/extension_shape_test.sh
Executable file
10
tests/install_extension_test/extension_shape_test.sh
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
extension_file="$1"
|
||||
|
||||
grep -Eq 'bun_install[[:space:]]*=[[:space:]]*module_extension\(' "${extension_file}"
|
||||
grep -Eq 'tag_classes[[:space:]]*=[[:space:]]*\{"install":[[:space:]]*_install\}' "${extension_file}"
|
||||
grep -Eq '"name":[[:space:]]*attr\.string\(mandatory[[:space:]]*=[[:space:]]*True\)' "${extension_file}"
|
||||
grep -Eq '"package_json":[[:space:]]*attr\.string\(mandatory[[:space:]]*=[[:space:]]*True\)' "${extension_file}"
|
||||
grep -Eq '"bun_lockfile":[[:space:]]*attr\.string\(mandatory[[:space:]]*=[[:space:]]*True\)' "${extension_file}"
|
||||
Reference in New Issue
Block a user