AkurAI Build
Menu

Public repository / 3aae9f4e85241bcb775c31f5c03094becd3da56a

AkurAI-Framework / tests/test_client_package.sh

Latest change 57bd5b278e2d4096a4ce6e5d1127a4e06f16b066 - OLI-242: signals.js import-safe without DOM, add signals.d.ts to @akurai/client by Ólafur Búi Ólafsson

#!/usr/bin/env bash
# The client package must be versioned from VERSION, ship the four modules, and resolve its own imports.
set -eu
out=$(mktemp -d); trap 'rm -rf "$out"' EXIT
scripts/build-client-package.sh "$out" >/dev/null
v=$(cat VERSION)
grep -q "\"version\": \"$v\"" "$out/package.json" || { echo "FAIL: version != $v"; exit 1; }
for f in signals.js islands.js spa.js akurai-client.js; do
  [ -f "$out/$f" ] || { echo "FAIL: missing $f"; exit 1; }
done
node --input-type=module -e "
globalThis.document={readyState:'complete',addEventListener(){},querySelectorAll:()=>[],querySelector:()=>null,getElementById:()=>null};
globalThis.window=globalThis;globalThis.addEventListener=()=>{};
const p='$out/';
const m=await import(p+'islands.js'); if(typeof m.signal!=='function') throw new Error('islands/signals import');
const c=await import(p+'akurai-client.js'); if(typeof c.createClient!=='function') throw new Error('client');
await import(p+'spa.js');"

# signals must import with no DOM at all (SSR / bun test) and ship typings
node --input-type=module -e "
delete globalThis.document; delete globalThis.window;
const s=await import('$out/signals.js'); const a=s.signal(1); a(2); if(a()!==2) throw new Error('signal');"
[ -f "$out/signals.d.ts" ] || { echo "FAIL: missing signals.d.ts"; exit 1; }
grep -q '"types"' "$out/package.json" || { echo "FAIL: package.json lacks types"; exit 1; }
echo "PASS: signals import-safe without DOM, typings shipped"