Files
2026-08-20 22:51:22 -03:00

51 lines
1.6 KiB
Bash
Executable File

#!/bin/sh
# Install this extension into Nova's user extension directory, so it loads for
# every project without "Activate Project as Extension".
#
# Nova reads installed extensions from
# ~/Library/Application Support/Nova/Extensions/<identifier>/
# and only loads the ones registered in Extensions.plist next to it. Both are
# read at launch, so Nova must be quit while this runs.
#
# Re-run after changing the extension, then restart Nova.
set -eu
ID="unsupervised.MermaidPreview"
SRC="$(cd "$(dirname "$0")" && pwd)"
EXT_DIR="$HOME/Library/Application Support/Nova/Extensions"
DEST="$EXT_DIR/$ID"
PLIST="$EXT_DIR/Extensions.plist"
if pgrep -x Nova >/dev/null 2>&1; then
echo "Quit Nova first — it rereads Extensions.plist only at launch." >&2
exit 1
fi
mkdir -p "$DEST"
rsync -a --delete \
--exclude '.git' --exclude '.DS_Store' --exclude 'install.sh' \
"$SRC/" "$DEST/"
echo "Copied to $DEST"
python3 - "$PLIST" "$ID" <<'PY'
import os, plistlib, sys
path, ident = sys.argv[1], sys.argv[2]
data = {"extensions": []}
if os.path.exists(path):
with open(path, "rb") as f:
data = plistlib.load(f)
extensions = data.setdefault("extensions", [])
if any(e.get("packageName") == ident for e in extensions):
print("Already registered in Extensions.plist")
else:
extensions.append({"enabled": True, "packageName": ident})
with open(path, "wb") as f:
plistlib.dump(data, f, fmt=plistlib.FMT_BINARY)
print("Registered in Extensions.plist")
PY
echo "Done. Start Nova; the extension appears under Extensions > Extension Library > Installed."