From cdac7dd04ceb12dc1c2da02406f127d0f8290b72 Mon Sep 17 00:00:00 2001 From: Sebastian Jeltsch Date: Sat, 16 Nov 2024 21:27:09 +0100 Subject: [PATCH] Better development instructions for the Admin UI. --- ui/admin/README.md | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/ui/admin/README.md b/ui/admin/README.md index e5106a44..491b8f98 100644 --- a/ui/admin/README.md +++ b/ui/admin/README.md @@ -1,17 +1,39 @@ # TrailBase Admin Dashboard UI -## Codegen proto code +This directory contains TrailBase's admin dashboard UI. It is an SPA, i.e. it's +static content embedded into the TrailBase binary that executes in the browser +using TrailBase's privileged admin APIs. -We're using https://github.com/stephenh/ts-proto#usage for typescript generation. +For development one case use the vite dev-server with hot module reload. First +start the TrailBase binary in dev mode (permissive CORS and cookie policies): - $ pnpm run proto +```bash +$ cargo run -- --data-dir client/testfixture run --dev +``` -Make sure to install: +and then vite: - * protobuf-compiler, for protoc - * libprotobuf-dev, for meta files such as descriptor.proto. +```bash +$ pnpm run dev +``` -## Codegen Rust-TypeScript bindings +## Protobuf codegen -They are currently created on `cargo test` and copied to `/bindings` on `cargo -build` where they're being picked up. +We're using [ts-proto](https://github.com/stephenh/ts-proto#usage) for +protobuf code generation. Run + +```bash +$ pnpm run proto +``` + +, which requires the following system dependencies: + + * **protoc**, e.g. via the `protobuf-compiler` Debian/Ubuntu package + * **descriptor.proto**, e.g. via the `libprotobuf-dev` Debian/Ubuntu package. + +## Rust-TypeScript codegen + +The TypeScript bindings for the admin APIs are checked into the repository +under `/trailbase-core/bindings`. They're generated via `ts-rs` and written +every time the Rust tests execute, i.e. `cargo test`. They're checked in only +to avoid having Rust depend on TypesScript and TypeScript depend on Rust tests.