#!/bin/sh set -e # WasmBox installer # curl -sSf https://tangled.org/metaend.eth.xyz/wasmbox-cli/raw/main/install.sh | sh REPO="https://tangled.org/metaend.eth.xyz/wasmbox-cli" REGISTRY="https://qstorage.quilibrium.com/wasmbox" DEFAULT_TOOLS="jfmt compact b64 secretscan errparse hashit epoch yamlfmt diffsummary worldid-verify" BOLD="\033[1m" DIM="\033[2m" GREEN="\033[32m" YELLOW="\033[33m" CYAN="\033[36m" RESET="\033[0m" info() { printf "${BOLD}${CYAN}=>${RESET} %s\n" "$1"; } ok() { printf "${BOLD}${GREEN} ✓${RESET} %s\n" "$1"; } warn() { printf "${BOLD}${YELLOW} !${RESET} %s\n" "$1"; } die() { printf "\033[31merror:\033[0m %s\n" "$1" >&2; exit 1; } # --- preflight --- command -v cargo >/dev/null 2>&1 || die "cargo not found. Install Rust first: https://rustup.rs" CARGO_BIN="$(dirname "$(command -v cargo)")" case ":$PATH:" in *":$CARGO_BIN:"*) ;; *) export PATH="$CARGO_BIN:$PATH" ;; esac # --- install wasmbox --- if command -v wasmbox >/dev/null 2>&1; then CURRENT="$(wasmbox --version 2>/dev/null | awk '{print $2}')" info "wasmbox ${CURRENT} already installed, upgrading..." else info "installing wasmbox..." fi cargo install --git "$REPO" wasmbox-cli --locked --quiet 2>&1 | while IFS= read -r line; do printf "${DIM} %s${RESET}\n" "$line" done command -v wasmbox >/dev/null 2>&1 || die "install failed — wasmbox not found in PATH" VERSION="$(wasmbox --version 2>/dev/null | awk '{print $2}')" ok "wasmbox ${VERSION}" # --- add registry --- EXISTING="$(wasmbox registry list --json 2>/dev/null || echo "[]")" case "$EXISTING" in *"$REGISTRY"*) ok "registry already configured" ;; *) info "adding registry..." wasmbox registry add "$REGISTRY" >/dev/null 2>&1 ok "registry ${REGISTRY}" ;; esac # --- install default tools --- info "installing tools..." for tool in $DEFAULT_TOOLS; do if wasmbox info "$tool" --json >/dev/null 2>&1; then ok "${tool} (already installed)" else wasmbox install "$tool" --allow-all >/dev/null 2>&1 && ok "$tool" || warn "${tool} (failed, skipped)" fi done # --- done --- printf "\n" printf "${BOLD}wasmbox is ready.${RESET} Try:\n" printf "\n" printf " echo '{\"name\":\"world\"}' | wasmbox run jfmt -- -q name\n" printf " echo 'hello' | wasmbox run b64\n" printf " cat src/main.rs | wasmbox run compact -- --stats\n" printf " curl -si https://api.example.com | wasmbox run errparse\n" printf "\n"