Files
supermarket/install.sh
T
davidandClaude Opus 5.5 4d304cd65b Stop committing credentials; fix posting length, partial posts, and data safety
- Untrack config.yaml (now gitignored) and add config.example.yaml with
  blank credentials; install.sh copies the example and sets mode 600
- Reserve room for the appended source link when asking Claude for a
  post, count length the way X does, and refuse over-length tweets
  before posting
- Return https://x.com/i/status/<id> for posted tweets
- Track which platforms each queued post reached so a partial failure
  can be retried without double-posting
- Write config, state, posts and dismissed files atomically with 0600
- Keep refreshed Twitter tokens in memory if saving them fails, and log
  the failure instead of writing to the hidden stderr
- Exit with a clear message on corrupt data files instead of panicking
- Surface save errors in the UI; show status/error messages on home
- Add tests for X length counting, the post store, and token updates

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 06:14:40 -07:00

58 lines
1.6 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
BINARY="coremarketing"
INSTALL_DIR="$HOME/.local/bin"
# Find Go — check common locations if not in PATH
GO=$(command -v go 2>/dev/null || echo "")
for candidate in /run/host/usr/lib/go/bin/go /usr/local/go/bin/go; do
if [[ -z "$GO" && -x "$candidate" ]]; then
GO="$candidate"
fi
done
if [[ -z "$GO" ]]; then
echo "Error: Go not found. Install Go from https://go.dev/dl/" >&2
exit 1
fi
echo "Using Go: $GO ($($GO version))"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
echo "Building $BINARY..."
"$GO" build -o "$BINARY" .
mkdir -p "$INSTALL_DIR"
mv "$BINARY" "$INSTALL_DIR/$BINARY"
CONFIG_DIR="$HOME/.local/state/coremarketing"
mkdir -p "$CONFIG_DIR"
if [[ -d "$CONFIG_DIR" ]] && compgen -G "$CONFIG_DIR/*" > /dev/null 2>&1; then
read -r -p "Delete all files in $CONFIG_DIR? [y/N] " answer
if [[ "${answer,,}" == "y" ]]; then
rm -rf "${CONFIG_DIR:?}"/*
echo "Cleared: $CONFIG_DIR"
fi
fi
if [[ ! -f "$CONFIG_DIR/config.yaml" ]]; then
cp "$SCRIPT_DIR/config.example.yaml" "$CONFIG_DIR/config.yaml"
chmod 600 "$CONFIG_DIR/config.yaml"
echo "Config installed: $CONFIG_DIR/config.yaml — fill in your credentials there"
else
echo "Config already exists, skipping: $CONFIG_DIR/config.yaml"
fi
echo "Installed: $INSTALL_DIR/$BINARY"
if ! echo "$PATH" | grep -q "$INSTALL_DIR"; then
echo ""
echo "Note: $INSTALL_DIR is not in your PATH."
echo "Add this to your shell config (~/.bashrc or ~/.zshrc):"
echo " export PATH=\"\$HOME/.local/bin:\$PATH\""
fi