#!/bin/sh
# Installs Folio: downloads the app, puts it in Applications and opens it.
#   curl -fsSL https://tryfolio.pages.dev/install.sh | sh
set -e
URL="https://tryfolio.pages.dev/Folio.zip"
DEST="${FOLIO_DEST:-/Applications}"
[ -w "$DEST" ] || DEST="$HOME/Applications"
mkdir -p "$DEST"
TMP=$(mktemp -d)
trap 'rm -rf "$TMP"' EXIT
echo "Downloading Folio…"
curl -fsSL "$URL" -o "$TMP/Folio.zip"
ditto -x -k "$TMP/Folio.zip" "$TMP"
rm -rf "$DEST/Folio.app"
mv "$TMP/Folio.app" "$DEST/Folio.app"
echo "Folio is in $DEST."
[ -n "$FOLIO_NO_OPEN" ] || open "$DEST/Folio.app"
