#!/usr/bin/env bash # Builds every JS bundle and packs dist/@.zip per plugin (manifest.json, index.js, assets/), # same layout as the template's Gradle task. set -euo pipefail cd "$(dirname "$0")/.." export PATH="$HOME/.cache/valenced/bun-linux-x64:$PATH" bun run build mkdir -p dist for dir in themes/*/ plugins/*/; do dir=${dir%/} [ -f "$dir/manifest.json" ] || continue id=$(python3 -c "import json;m=json.load(open('$dir/manifest.json'));print(m['id']+'@'+m['version'])") stage=$(mktemp -d -p "$HOME/.cache") cp "$dir/manifest.json" "$dir/build/js/index.js" "$stage/" [ -d "$dir/assets" ] && cp -r "$dir/assets" "$stage/assets" rm -f "$stage"/assets/*.gif # theme GIFs load from the repo at runtime (see themes/cookie-glass/js/index.ts) rm -f "dist/$id.zip" (cd "$stage" && zip -qr -X "$OLDPWD/dist/$id.zip" .) rm -rf "$stage" echo "dist/$id.zip" done