web


git clone https://radroots.dev/git/web.git
Log | Files | Refs | Submodules | README | LICENSE

commit c45799722845697139a12310d1b79adab6bd5c2c
parent 82ad5043f2bef5708ecc559ca6b6eb0160d85ccb
Author: triesap <triesap@radroots.dev>
Date:   Sun, 21 Dec 2025 04:20:01 +0000

Embed app name, version, and git hash into the runtime, enrich HTTP initialization, and reinstate farm location conversion.

Diffstat:
MAGENTS.md | 2++
Mapp/src/lib/utils/app/index.ts | 10+++++++++-
Mapp/src/routes/(app)/farms/+page.svelte | 11++---------
Mapp/vite.config.ts | 17++++++++++++++++-
4 files changed, 29 insertions(+), 11 deletions(-)

diff --git a/AGENTS.md b/AGENTS.md @@ -17,6 +17,7 @@ 3. Source Code - Keep code deterministic and reproducible. - Do not add source code comments. +- Single-line if statements must not use braces. - Anchor comments are allowed only when they start with @ (e.g. // @todo). - /* */ blocks are allowed only to disable features during development and must not include descriptive text. - <!-- --> HTML blocks are allowed only to disable features during development or compiler/lint suppression (e.g. <!-- svelte-ignore ... -->). @@ -26,6 +27,7 @@ - Put shared or generalizable code in packages/. - Apps should rely on packages/ for shared utilities. - Treat @radroots/*-bindings as generated from .rs crates; do not edit or format their .ts outputs. If issues arise, change upstream .rs or report the error instead. +- Every class must implement a same-name interface prefixed with I; all public methods must be declared on the interface, and method return types are required for all class methods. 1. Architecture - Prefer pure functions. diff --git a/app/src/lib/utils/app/index.ts b/app/src/lib/utils/app/index.ts @@ -19,6 +19,10 @@ import type { NavigationRoute } from "./routes"; const ls_val = get_store(ls); +declare const __APP_GIT_HASH__: string; +declare const __APP_NAME__: string; +declare const __APP_VERSION__: string; + export const datastore = new WebDatastore( cfg_datastore_key_map, cfg_datastore_key_param_map, @@ -30,7 +34,11 @@ export const datastore = new WebDatastore( export const fs = new WebFs(); export const geol = new WebGeolocation(); export const geoc = new Geocoder(); -export const http = new WebHttp(); +export const http = new WebHttp({ + app_name: __APP_NAME__, + app_version: __APP_VERSION__, + app_hash: __APP_GIT_HASH__ +}); export const notif = new WebNotifications(); export const radroots = new WebClientRadroots(_env.RADROOTS_API); export const nostr_keys = new WebKeystoreNostr({ diff --git a/app/src/routes/(app)/farms/+page.svelte b/app/src/routes/(app)/farms/+page.svelte @@ -6,6 +6,7 @@ FarmExtended, IViewFarmsData, } from "@radroots/apps-lib-pwa/types/views/farms"; + import { gcs_to_location_basis } from "@radroots/utils"; import { onMount } from "svelte"; type LoadData = IViewFarmsData | undefined; @@ -19,11 +20,9 @@ const load_data = async (): Promise<LoadData> => { try { const farms = await db.farm_find_many(); - console.log(JSON.stringify(farms, null, 4), `farms`); if ("err" in farms) return undefined; const list: FarmExtended[] = []; - for (const farm of farms.results) { const farm_location = await db.location_gcs_find_many({ rel: { @@ -32,16 +31,10 @@ }, }, }); - console.log( - JSON.stringify(farm_location, null, 4), - `farm_location`, - ); if ("err" in farm_location) continue; list.push({ farm, - //location: location_gcs_to_location_basis( - // farm_location.results[0], - //), + location: gcs_to_location_basis(farm_location.results[0]), }); } diff --git a/app/vite.config.ts b/app/vite.config.ts @@ -1,11 +1,23 @@ import { sveltekit } from "@sveltejs/kit/vite"; import tailwindcss from "@tailwindcss/vite"; import { config as dotenv_config } from "dotenv"; +import { execSync } from "node:child_process"; +import { readFileSync } from "node:fs"; import path from "node:path"; import { defineConfig } from "vite"; export default defineConfig(({ mode }) => { dotenv_config({ path: mode === "development" ? ".env.development" : ".env.production" }); + const repo_root = path.resolve(__dirname, ".."); + const app_package_path = path.resolve(__dirname, "package.json"); + const app_package = JSON.parse(readFileSync(app_package_path, "utf8")) as { name?: string; version?: string }; + const git_hash = (() => { + try { + return execSync("git rev-parse HEAD", { cwd: repo_root }).toString().trim(); + } catch { + return "unknown"; + } + })(); return { build: { sourcemap: true @@ -15,7 +27,10 @@ export default defineConfig(({ mode }) => { sveltekit(), ], define: { - 'process.env.NODE_ENV': '"production"', + 'process.env.NODE_ENV': `"${mode}"`, + '__APP_GIT_HASH__': JSON.stringify(git_hash), + '__APP_NAME__': JSON.stringify(`radroots/${app_package.name ?? "app"}`), + '__APP_VERSION__': JSON.stringify(app_package.version ?? "0.0.0"), }, server: { port: process.env.PORT ? Number(process.env.PORT) : 3000,