load("@aspect_rules_js//js:defs.bzl", "js_binary", "js_run_binary")
load("@eagle0pedia_npm//:defs.bzl", "npm_link_all_packages")

package(default_visibility = ["//visibility:public"])

exports_files([
    "package.json",
    "pnpm-lock.yaml",
])

npm_link_all_packages()

filegroup(
    name = "site_sources",
    srcs = glob([
        "src/**",
        "astro.config.mjs",
        "package.json",
        "tsconfig.json",
    ]),
)

js_binary(
    name = "astro",
    data = [
        ":node_modules",
    ],
    entry_point = "tools/astro-cli.mjs",
)

js_run_binary(
    name = "site",
    srcs = [
        ":node_modules",
        ":site_sources",
    ],
    args = ["build"],
    chdir = package_name(),
    env = {
        "ASTRO_TELEMETRY_DISABLED": "1",
    },
    out_dirs = ["dist"],
    tool = ":astro",
)
