databuild/databuild/dashboard/BUILD.bazel
Stuart Axelbrooke ac3a420a0d
Some checks are pending
/ setup (push) Waiting to run
@npm -> @databuild_npm
2025-08-06 16:21:12 -07:00

111 lines
2.9 KiB
Python

load("@aspect_rules_esbuild//esbuild:defs.bzl", "esbuild")
load("@aspect_rules_js//js:defs.bzl", "js_test")
load("@aspect_rules_ts//ts:defs.bzl", "ts_config", "ts_project")
load("@databuild_npm//:defs.bzl", "npm_link_all_packages")
npm_link_all_packages(name = "node_modules")
filegroup(
name = "dist",
srcs = [
# To be added once we have one
# "favicon.svg",
"index.html",
":app_dist",
":css",
],
visibility = ["//visibility:public"],
)
genrule(
name = "css",
srcs = [
"index.css",
"index.html",
":node_modules/daisyui",
":app_dist",
],
outs = ["dist.css"],
cmd = """
# Must manually copy sources, because tailwind silently ignores symlinked files:
# https://github.com/tailwindlabs/tailwindcss/issues/13731
WORKDIR=$$(dirname $(location index.css))
find $$WORKDIR -type l -exec bash -c 'echo "> $${0}" && cp -fL "$${0}" "$${0}.tmp" && mv "$${0}.tmp" "$${0}"' {} \\;
# Copy over source from built TS app so that tailwind can see the used classes
for fpath in $(locations :app_dist); do
cp $$fpath $$WORKDIR
done
# Include daisyui plugin
cp -R $(@D)/node_modules/.aspect_rules_js/*/node_modules $$WORKDIR/node_modules
# Run tailwind build
$(location //tools/build_rules:tailwind) -i $(location index.css) -o $@
""",
tools = ["//tools/build_rules:tailwind"],
)
ts_config(
name = "ts_config_app",
src = ":tsconfig_app.json",
visibility = ["//visibility:public"],
)
# Making modules of ts projects seems to be a rats nest.
# Hopefully we can figure this out in the future.
ts_project(
name = "app",
srcs = [
"index.ts",
"layout.ts",
"pages.ts",
"services.ts",
"types.ts",
"utils.ts",
# Test files
"index.test.ts",
"utils.test.ts",
"transformation-tests.ts",
],
allow_js = True,
resolve_json_module = True,
transpiler = "tsc",
tsconfig = ":ts_config_app",
deps = [
":node_modules/@types/mithril",
":node_modules/@types/node",
":node_modules/@types/ospec",
":node_modules/mithril",
":node_modules/ospec",
":node_modules/whatwg-fetch",
"//databuild/client:typescript_lib",
],
)
esbuild(
name = "app_dist",
srcs = [":app"],
bazel_sandbox_plugin = True,
entry_point = "index.js",
# esbuild_log_level = "verbose",
# js_log_level = "debug",
metafile = True,
visibility = ["//visibility:public"],
)
js_test(
name = "app_test",
chdir = package_name(),
data = [":app"],
entry_point = "index.test.js",
)
# Test to verify strict TypeScript configuration catches expected failures
sh_test(
name = "strict_config_test",
srcs = ["test-strict-config.sh"],
data = [
"test-data/strict-config-failures.ts",
"tsconfig_app.json",
":node_modules/@types/node",
":node_modules/typescript",
],
)