Builds passing

This commit is contained in:
Stuart Axelbrooke 2025-07-10 21:39:23 -07:00
parent 115e8cfdb0
commit 118bb2ac66
15 changed files with 754 additions and 2745 deletions

View file

@ -1,4 +1,8 @@
build --color=yes
query --color=yes
test --color=yes
test --test_output=errors
test --test_output=errors
# passes an argument `--skipLibCheck` to *every* spawn of tsc
# Bazel 6.4 or greater: 'common' means 'any command that supports this flag'
common --@aspect_rules_ts//ts:skipLibCheck=always

View file

@ -1 +1 @@
8.3.0
8.3.1

View file

@ -3,14 +3,14 @@ module(
version = "0.1",
)
bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "bazel_skylib", version = "1.8.1")
bazel_dep(name = "platforms", version = "0.0.11")
bazel_dep(name = "rules_shell", version = "0.4.0")
bazel_dep(name = "rules_oci", version = "2.2.6")
bazel_dep(name = "aspect_bazel_lib", version = "2.14.0")
bazel_dep(name = "rules_rust", version = "0.61.0")
bazel_dep(name = "rules_proto", version = "7.0.2")
bazel_dep(name = "protobuf", version = "23.1", repo_name = "com_google_protobuf")
bazel_dep(name = "protobuf", version = "29.0", repo_name = "com_google_protobuf")
crate = use_extension("@rules_rust//crate_universe:extensions.bzl", "crate")
crate.spec(
@ -124,3 +124,99 @@ crate.spec(
)
crate.from_specs()
use_repo(crate, "crates")
# TypeScript and Node.js dependencies for dashboard
bazel_dep(name = "aspect_rules_ts", version = "3.6.3")
bazel_dep(name = "aspect_rules_js", version = "2.0.0")
rules_ts_ext = use_extension("@aspect_rules_ts//ts:extensions.bzl", "ext", dev_dependency = True)
rules_ts_ext.deps(ts_version_from = "//databuild/dashboard:package.json")
use_repo(rules_ts_ext, "npm_typescript")
#bazel_dep(name = "aspect_rules_ts", version = "3.4.0")
#bazel_dep(name = "aspect_rules_js", version = "2.1.3")
bazel_dep(name = "aspect_rules_esbuild", version = "0.21.0")
npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm")
npm.npm_translate_lock(
name = "npm",
pnpm_lock = "//databuild/dashboard:pnpm-lock.yaml",
# verify_node_modules_ignored = "//:.bazelignore",
)
use_repo(npm, "npm")
pnpm = use_extension("@aspect_rules_js//npm:extensions.bzl", "pnpm")
# Allows developers to use the matching pnpm version, for example:
# bazel run -- @pnpm --dir /home/runner/work/rules_js/rules_js install
use_repo(pnpm, "pnpm")
npm.npm_import(
name = "mithril",
package = "mithril",
version = "2.2.2",
)
npm.npm_import(
name = "types_mithril",
package = "@types/mithril",
version = "2.2.7",
)
use_repo(npm, "mithril", "types_mithril")
#npm.npm_import(
# name = "npm_typescript",
# package = "typescript",
# version = "5.8.3",
#)
#use_repo(npm, "mithril", "npm_typescript", "types_mithril")
# Tailwind
http_file = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file")
http_file(
name = "tailwind_macos",
executable = True,
sha256 = "8b0e5321ed7de33b8962410fa7e680f568366af8007bb9ebcb89cc68f70653f2",
urls = [
"https://github.com/tailwindlabs/tailwindcss/releases/download/v4.0.0/tailwindcss-macos-arm64",
],
)
http_file(
name = "tailwind_linux",
executable = True,
sha256 = "09c1a5997d68f5e0127d9737593e7dc658fc96dc1851d782a78983d0d6a03c7c",
urls = [
"https://github.com/tailwindlabs/tailwindcss/releases/download/v4.0.0/tailwindcss-linux-x64",
],
)
#http_archive(
# name = "aspect_rules_esbuild",
# sha256 = "550e33ddeb86a564b22b2c5d3f84748c6639b1b2b71fae66bf362c33392cbed8",
# strip_prefix = "rules_esbuild-0.21.0",
# url = "https://github.com/aspect-build/rules_esbuild/releases/download/v0.21.0/rules_esbuild-v0.21.0.tar.gz",
#)
#
#######################
## rules_esbuild setup #
#######################
#
## Fetches the rules_esbuild dependencies.
## If you want to have a different version of some dependency,
## you should fetch it *before* calling this.
## Alternatively, you can skip calling this function, so long as you've
## already fetched all the dependencies.
#load("@aspect_rules_esbuild//esbuild:dependencies.bzl", "rules_esbuild_dependencies")
#
#rules_esbuild_dependencies()
#
#rules_js_register_toolchains(node_version = DEFAULT_NODE_VERSION)
#
## Register a toolchain containing esbuild npm package and native bindings
#load("@aspect_rules_esbuild//esbuild:repositories.bzl", "LATEST_ESBUILD_VERSION", "esbuild_register_toolchains")
#
#esbuild_register_toolchains(
# name = "esbuild",
# esbuild_version = LATEST_ESBUILD_VERSION,
#)
#

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,112 @@
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("@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"],
)
ts_config(
name = "ts_config_test",
src = ":tsconfig_test.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",
],
allow_js = True,
resolve_json_module = True,
transpiler = "tsc",
tsconfig = ":ts_config_app",
deps = [
":node_modules/@types/mithril",
":node_modules/@types/node",
":node_modules/mithril",
":node_modules/whatwg-fetch",
"//databuild/client:typescript_client",
],
)
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"],
)
ts_project(
name = "test_app",
testonly = True,
srcs = ["index.test.ts"],
allow_js = True,
resolve_json_module = True,
transpiler = "tsc",
tsconfig = ":ts_config_test",
deps = [
":app",
":node_modules/@types/mithril",
":node_modules/@types/node",
":node_modules/@types/ospec",
":node_modules/mithril",
":node_modules/ospec",
],
)
js_test(
name = "app_test",
chdir = package_name(),
data = [":test_app"],
entry_point = "index.test.js",
)

View file

@ -0,0 +1,2 @@
@import "tailwindcss" source("./**/*.{js,html}");
@plugin "daisyui";

View file

@ -0,0 +1,15 @@
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="/dist.css" rel="stylesheet">
<script src="/app_dist.js"></script>
</head>
<body>
<h1 class="text-3xl font-bold underline"> Hello world! </h1>
<div id="app">
Loading...
</div>
</body>
</html>

View file

@ -0,0 +1,12 @@
const { appName } = require('./index');
const o = require('ospec');
o.spec("appName", () => {
o("should be databuild", () => {
o(appName).equals("databuild") `Should be databuild`;
});
})
// TODO - I think we can create an ospec target that invokes these with the ospec CLI?
// https://github.com/MithrilJS/ospec?tab=readme-ov-file#command-line-interface
o.run();

View file

@ -0,0 +1,30 @@
import m from 'mithril';
// import * as foo from './typescript_client/apis/DefaultApi.ts';
export const appName = "databuild";
const ele = m("div", {class:"alert shadow-lg max-w-sm","role":"alert"},
[
m("svg", {class:"stroke-info h-6 w-6 shrink-0","xmlns":"http://www.w3.org/2000/svg","fill":"none","viewBox":"0 0 24 24"},
m("path", {"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2","d":"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})
),
m("div",
[
m("h3", {"class":"font-bold"},
"Beans!"
)
]
)
]
);
if (typeof window !== "undefined") {
document.addEventListener("DOMContentLoaded", () => {
m.mount(
document.getElementById('app') as HTMLFormElement,
{ view: () => [
ele,
] }
);
})
}

View file

@ -0,0 +1,16 @@
{
"private": true,
"devDependencies": {
"typescript": "5.7.3",
"@types/node": "^22.12.0",
"mithril": "^2.2.7",
"@types/mithril": "^2.2.7",
"ospec": "^4.2.0",
"@types/ospec": "^4.2.0",
"whatwg-fetch": "^3.6.20",
"daisyui": "^5.0.0-beta.6"
},
"pnpm": {
"onlyBuiltDependencies": []
}
}

View file

@ -0,0 +1,111 @@
lockfileVersion: '9.0'
settings:
autoInstallPeers: true
excludeLinksFromLockfile: false
importers:
.:
devDependencies:
'@types/mithril':
specifier: ^2.2.7
version: 2.2.7
'@types/node':
specifier: ^22.12.0
version: 22.12.0
'@types/ospec':
specifier: ^4.2.0
version: 4.2.0
daisyui:
specifier: ^5.0.0-beta.6
version: 5.0.0-beta.6
mithril:
specifier: ^2.2.7
version: 2.2.13
ospec:
specifier: ^4.2.0
version: 4.2.1
typescript:
specifier: ^5.7.3
version: 5.7.3
whatwg-fetch:
specifier: ^3.6.20
version: 3.6.20
packages:
'@types/mithril@2.2.7':
resolution: {integrity: sha512-uetxoYizBMHPELl6DSZUfO6Q/aOm+h0NUCv9bVAX2iAxfrdBSOvU9KKFl+McTtxR13F+BReYLY814pJsZvnSxg==}
'@types/node@22.12.0':
resolution: {integrity: sha512-Fll2FZ1riMjNmlmJOdAyY5pUbkftXslB5DgEzlIuNaiWhXd00FhWxVC/r4yV/4wBb9JfImTu+jiSvXTkJ7F/gA==}
'@types/ospec@4.2.0':
resolution: {integrity: sha512-QgwAtrYYstU7otBXmQ2yjUWaYMWkF48EevmG+IfYzAWk39cwsTw7ZHp7dK2XyA3eJ2v5AvbMa5ijcLewklDRDA==}
balanced-match@1.0.2:
resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==}
brace-expansion@2.0.1:
resolution: {integrity: sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==}
daisyui@5.0.0-beta.6:
resolution: {integrity: sha512-gwXHv6MApRBrvUayzg83vS6bfZ+y7/1VGLu0a8/cEAMviS4rXLCd4AndEdlVxhq+25wkAp0CZRkNQ7O4wIoFnQ==}
fs.realpath@1.0.0:
resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==}
glob@9.3.5:
resolution: {integrity: sha512-e1LleDykUz2Iu+MTYdkSsuWX8lvAjAcs0Xef0lNIu0S2wOAzuTxCJtcd9S3cijlwYF18EsU3rzb8jPVobxDh9Q==}
engines: {node: '>=16 || 14 >=14.17'}
lru-cache@10.4.3:
resolution: {integrity: sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==}
minimatch@8.0.4:
resolution: {integrity: sha512-W0Wvr9HyFXZRGIDgCicunpQ299OKXs9RgZfaukz4qAW/pJhcpUfupc9c+OObPOFueNy8VSrZgEmDtk6Kh4WzDA==}
engines: {node: '>=16 || 14 >=14.17'}
minipass@4.2.8:
resolution: {integrity: sha512-fNzuVyifolSLFL4NzpF+wEF4qrgqaaKX0haXPQEdQ7NKAN+WecoKMHV09YcuL/DHxrUsYQOK3MiuDf7Ip2OXfQ==}
engines: {node: '>=8'}
minipass@7.1.2:
resolution: {integrity: sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==}
engines: {node: '>=16 || 14 >=14.17'}
mithril@2.2.13:
resolution: {integrity: sha512-dfWFYmRJDXAROG6B1AsQXEwhSgFZ65Am/5Xj3oJ/R1wZtrC0W20P4sIAtFQB0SZsGwV7H2MiEJiFGmlUtXF1Ww==}
ospec@4.2.1:
resolution: {integrity: sha512-LsJw2WMaVlFDiaIPPH+LMtsxOABjFD29XQ12ENZM+8Cwgg5BEgW65CB+SPL1PceIun+HSfdw8hkf27C8iF/XFw==}
hasBin: true
path-scurry@1.11.1:
resolution: {integrity: sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==}
engines: {node: '>=16 || 14 >=14.18'}
typescript@5.7.3:
resolution: {integrity: sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw==}
engines: {node: '>=14.17'}
hasBin: true
undici-types@6.20.0:
resolution: {integrity: sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==}
whatwg-fetch@3.6.20:
resolution: {integrity: sha512-EqhiFU6daOA8kpjOWTL0olhVOF3i7OrFzSYiGsEMB8GcXS+RrzauAERX65xMeNWVqxA6HXH2m69Z9LaKKdisfg==}
snapshots:
'@types/mithril@2.2.7': {}
'@types/node@22.12.0':
dependencies:
undici-types: 6.20.0
'@types/ospec@4.2.0': {}
balanced-match@1.0.2: {}
brace-expansion@2.0.1:
dependencies:
balanced-match: 1.0.2
daisyui@5.0.0-beta.6: {}
fs.realpath@1.0.0: {}
glob@9.3.5:
dependencies:
fs.realpath: 1.0.0
minimatch: 8.0.4
minipass: 4.2.8
path-scurry: 1.11.1
lru-cache@10.4.3: {}
minimatch@8.0.4:
dependencies:
brace-expansion: 2.0.1
minipass@4.2.8: {}
minipass@7.1.2: {}
mithril@2.2.13: {}
ospec@4.2.1:
dependencies:
glob: 9.3.5
path-scurry@1.11.1:
dependencies:
lru-cache: 10.4.3
minipass: 7.1.2
typescript@5.7.3: {}
undici-types@6.20.0: {}
whatwg-fetch@3.6.20: {}

View file

@ -0,0 +1,2 @@
packages:
- "databuild"

View file

@ -0,0 +1,17 @@
{
"compilerOptions": {
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
"lib": ["es6","dom", "es2021"], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
"module": "commonjs", /* Specify what module code is generated. */
"rootDir": "./", /* Specify the root folder within your source files. */
"moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
"resolveJsonModule": true, /* Enable importing .json files. */
"allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
"inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
"strict": true, /* Enable all strict type-checking options. */
"noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
}
}

View file

@ -0,0 +1,17 @@
{
"compilerOptions": {
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
"lib": ["es6","dom"], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
"module": "commonjs", /* Specify what module code is generated. */
"rootDir": "./", /* Specify the root folder within your source files. */
"moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
"resolveJsonModule": true, /* Enable importing .json files. */
"allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
"inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
"strict": true, /* Enable all strict type-checking options. */
"noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
}
}

View file

@ -0,0 +1,21 @@
config_setting(
name = "is_linux",
constraint_values = ["@platforms//os:linux"],
)
config_setting(
name = "is_mac",
constraint_values = ["@platforms//os:macos"],
)
# tailwind
alias(
name = "tailwind",
actual = select({
":is_linux": "@tailwind_linux//file:downloaded",
":is_mac": "@tailwind_macos//file:downloaded",
"//conditions:default": None,
}),
visibility = ["//visibility:public"],
)