From 8e4f32b54328085867a1402df0671226d2f21b4f Mon Sep 17 00:00:00 2001 From: Surma Date: Thu, 12 Nov 2026 19:45:59 +0000 Subject: [PATCH] Seed web assets as one folder and check the packaged web service --- docs/RUNNING.md | 6 ++-- flake.nix | 9 +++++- host/tests/it/api_auth.rs | 2 +- host/tests/it/chat.rs | 8 ++--- host/tests/it/p2.rs | 2 +- userland/bundle.nu | 8 ++--- userland/web/render.test.cjs | 2 +- userland/web/seed-check.nu | 35 ++++++++++++++++++++++ userland/web/{ => www}/credentials-view.js | 0 userland/web/{ => www}/credentials.js | 0 userland/web/{ => www}/index.html | 0 userland/web/{ => www}/marked-LICENSE.md | 0 12 files changed, 54 insertions(+), 18 deletions(-) create mode 100644 userland/web/seed-check.nu rename userland/web/{ => www}/credentials-view.js (100%) rename userland/web/{ => www}/credentials.js (100%) rename userland/web/{ => www}/index.html (100%) rename userland/web/{ => www}/marked-LICENSE.md (100%) diff --git a/docs/RUNNING.md b/docs/RUNNING.md index c5c9b66..3657faf 100644 --- a/docs/RUNNING.md +++ b/docs/RUNNING.md @@ -53,6 +53,8 @@ Coreutils, diffutils, procps, and brush each occupy one real binary in `bin/`. Their command names are relative symlinks to those binaries. The world copier preserves these symlinks and dangling links in the source tree. A fresh development world needs no manual source copy. +Both bundle builders copy `userland/web/www/` whole into `/srv/www/`, with the original filenames and the Marked license. +The server crate, service unit, and test scripts stay outside that folder. The bundle includes `/bin/web.wasm` and an enabled `/etc/systemd/system/web.service`. World init starts that service on `0.0.0.0:8080`. To change its address, edit `ExecStart` to add `--listen ADDR`, then run `systemctl restart web` inside the world. @@ -166,8 +168,8 @@ node userland/web/browser-check.mjs The script uses agent-browser and a CDP virtual authenticator. It registers a passkey and approves an item creation request. Set `AGENT_BROWSER_EXECUTABLE_PATH` if Chrome needs an explicit path. -Sources: [`host API`](../host/src/api/README.md), [`credential views`](../userland/web/credentials-view.js), -[`edits.rs`](../host/src/cred/edits.rs), and [`browser cryptography`](../userland/web/credentials.js). +Sources: [`host API`](../host/src/api/README.md), [`credential views`](../userland/web/www/credentials-view.js), +[`edits.rs`](../host/src/cred/edits.rs), and [`browser cryptography`](../userland/web/www/credentials.js). ## Models diff --git a/flake.nix b/flake.nix index 0d032e7..96df3c1 100644 --- a/flake.nix +++ b/flake.nix @@ -137,7 +137,7 @@ cp -R ${./config/roster} $out/etc/sausage/roster cp ${./userland/web/web.service} $out/etc/systemd/system/web.service touch $out/etc/systemd/system/multi-user.target.wants/web.service - cp ${./userland/web/index.html} ${./userland/web/credentials.js} ${./userland/web/credentials-view.js} $out/srv/www/ + cp -R ${./userland/web/www}/. $out/srv/www/ ''; sausageUnwrapped = craneLib.buildPackage (hostArgs // { cargoArtifacts = hostArtifacts; @@ -200,6 +200,13 @@ test -f "$TMPDIR/world/world/etc/sausage/roster/sausage.md" touch $out ''; + checks.web = pkgs.runCommand "sausage-web-seed" { + nativeBuildInputs = [ pkgs.nushell pkgs.curl ]; + } '' + export SAUSAGE_CACHE="$TMPDIR/sausage-cache" + nu ${./userland/web/seed-check.nu} ${sausage}/bin/sausage ${bundle} + touch $out + ''; apps.default = { type = "app"; program = "${sausage}/bin/sausage"; }; devShells.default = pkgs.mkShell (v8Env // wasiCcEnv // moldEnv // { packages = [ rust pkgs.wasmtime pkgs.openssl pkgs.pkg-config pkgs.go pkgs.cmake pkgs.llvmPackages_21.lld ] ++ builderTools ++ mold; diff --git a/host/tests/it/api_auth.rs b/host/tests/it/api_auth.rs index 6b8617d..f6e8c08 100644 --- a/host/tests/it/api_auth.rs +++ b/host/tests/it/api_auth.rs @@ -309,7 +309,7 @@ async fn approvals_registration_and_revocation() -> Result<()> { async fn encrypt(_api: &Api, public_key: Value) -> Result { use deno_core::{JsRuntime, RuntimeOptions}; - let script = include_str!("../../../userland/web/credentials.js"); + let script = include_str!("../../../userland/web/www/credentials.js"); let mut runtime = JsRuntime::new(RuntimeOptions { extensions: vec![ deno_webidl::deno_webidl::init(), diff --git a/host/tests/it/chat.rs b/host/tests/it/chat.rs index 25f2a3d..95224d0 100644 --- a/host/tests/it/chat.rs +++ b/host/tests/it/chat.rs @@ -42,7 +42,7 @@ fn empty_rule_summary() -> anyhow::Result<()> { #[test] fn page_rendering() -> anyhow::Result<()> { let source = Path::new(env!("CARGO_MANIFEST_DIR")).join("../userland/web"); - let page = std::fs::read_to_string(source.join("index.html"))?; + let page = std::fs::read_to_string(source.join("www/index.html"))?; let script = page .split_once("