#!/bin/sh # Install the WAI command line, and what `wai dev` runs, from the forge's releases: # # curl -fsSL https://wai.transaction.science/install.sh | sh # # It picks the archive for this system (macOS or Linux, arm64 or x86_64), checks it against the # SHA-256 the release states, and unpacks it into $WAI_HOME (default ~/.wai): bin/ and # share/wai/web/ side by side. Then it says which line puts ~/.wai/bin on your PATH. Nothing # else is changed. WAI_VERSION picks a release (default: the one below). set -eu VERSION="${WAI_VERSION:-0.4.0}" DEST="${WAI_HOME:-$HOME/.wai}" BASE="https://git.transaction.science/Transaction-Science/open-standards/releases/download/wai-v$VERSION" case "$(uname -s)" in Darwin) os=apple-darwin ;; Linux) os=unknown-linux-musl ;; *) echo "wai: no archive for $(uname -s); build from source: https://wai.transaction.science/docs/quickstart/" >&2; exit 1 ;; esac case "$(uname -m)" in arm64 | aarch64) cpu=aarch64 ;; x86_64 | amd64) cpu=x86_64 ;; *) echo "wai: no archive for $(uname -m)" >&2; exit 1 ;; esac NAME="wai-$VERSION-$cpu-$os" TMP="$(mktemp -d)" trap 'rm -rf "$TMP"' EXIT echo "wai: fetching $NAME" curl -fsSL -o "$TMP/$NAME.tar.gz" "$BASE/$NAME.tar.gz" curl -fsSL -o "$TMP/$NAME.tar.gz.sha256" "$BASE/$NAME.tar.gz.sha256" want="$(cut -d' ' -f1 "$TMP/$NAME.tar.gz.sha256")" if command -v sha256sum > /dev/null 2>&1; then got="$(sha256sum "$TMP/$NAME.tar.gz" | cut -d' ' -f1)"; else got="$(shasum -a 256 "$TMP/$NAME.tar.gz" | cut -d' ' -f1)"; fi [ "$got" = "$want" ] || { echo "wai: the archive's SHA-256 is $got, not the release's $want; nothing installed" >&2; exit 1; } tar -xzf "$TMP/$NAME.tar.gz" -C "$TMP" mkdir -p "$DEST" rm -rf "$DEST/bin" "$DEST/share/wai" mkdir -p "$DEST/share" mv "$TMP/$NAME/bin" "$DEST/bin" mv "$TMP/$NAME/share/wai" "$DEST/share/wai" cp "$TMP/$NAME/README.md" "$TMP/$NAME/LICENSE" "$DEST/" "$DEST/bin/wai" create --list > /dev/null echo "wai: installed in $DEST. Put it on your PATH:" echo " export PATH=\"$DEST/bin:\$PATH\"" echo "then: wai hello"