mirror of
https://github.com/garrytan/gstack.git
synced 2026-05-05 05:05:08 +02:00
3713c3b9b9
- lib/sync-config.ts: reads .gstack-sync.json + ~/.gstack/auth.json - lib/auth.ts: device auth flow (browser OAuth, local HTTP callback) - lib/sync.ts: Supabase push/pull via raw fetch(), offline queue, cache - lib/cli-sync.ts: CLI handler for gstack-sync commands - bin/gstack-sync: bash wrapper (setup, status, push-*, pull, drain) - .gstack-sync.json.example: template for team setup Zero new dependencies — uses raw fetch() against PostgREST API. All sync is non-fatal with 5s timeout and offline queue fallback. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
70 lines
2.5 KiB
Bash
Executable File
70 lines
2.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# gstack-sync — team data sync CLI.
|
|
#
|
|
# Usage:
|
|
# gstack-sync setup — interactive auth flow
|
|
# gstack-sync status — show sync status (queue, cache, connection)
|
|
# gstack-sync push-eval <file> — push an eval result JSON to Supabase
|
|
# gstack-sync push-retro <file> — push a retro snapshot JSON
|
|
# gstack-sync push-qa <file> — push a QA report JSON
|
|
# gstack-sync push-ship <file> — push a ship log JSON
|
|
# gstack-sync pull — pull team data to local cache
|
|
# gstack-sync drain — drain the offline queue
|
|
# gstack-sync logout — clear auth tokens
|
|
#
|
|
# Env overrides (for testing):
|
|
# GSTACK_DIR — override auto-detected gstack root
|
|
# GSTACK_STATE_DIR — override ~/.gstack state directory
|
|
set -euo pipefail
|
|
|
|
GSTACK_DIR="${GSTACK_DIR:-$(cd "$(dirname "$0")/.." && pwd)}"
|
|
|
|
case "${1:-}" in
|
|
setup)
|
|
exec bun run "$GSTACK_DIR/lib/cli-sync.ts" setup
|
|
;;
|
|
status)
|
|
exec bun run "$GSTACK_DIR/lib/cli-sync.ts" status
|
|
;;
|
|
push-eval)
|
|
FILE="${2:?Usage: gstack-sync push-eval <file.json>}"
|
|
exec bun run "$GSTACK_DIR/lib/cli-sync.ts" push-eval "$FILE"
|
|
;;
|
|
push-retro)
|
|
FILE="${2:?Usage: gstack-sync push-retro <file.json>}"
|
|
exec bun run "$GSTACK_DIR/lib/cli-sync.ts" push-retro "$FILE"
|
|
;;
|
|
push-qa)
|
|
FILE="${2:?Usage: gstack-sync push-qa <file.json>}"
|
|
exec bun run "$GSTACK_DIR/lib/cli-sync.ts" push-qa "$FILE"
|
|
;;
|
|
push-ship)
|
|
FILE="${2:?Usage: gstack-sync push-ship <file.json>}"
|
|
exec bun run "$GSTACK_DIR/lib/cli-sync.ts" push-ship "$FILE"
|
|
;;
|
|
pull)
|
|
exec bun run "$GSTACK_DIR/lib/cli-sync.ts" pull
|
|
;;
|
|
drain)
|
|
exec bun run "$GSTACK_DIR/lib/cli-sync.ts" drain
|
|
;;
|
|
logout)
|
|
exec bun run "$GSTACK_DIR/lib/cli-sync.ts" logout
|
|
;;
|
|
*)
|
|
echo "Usage: gstack-sync {setup|status|push-eval|push-retro|push-qa|push-ship|pull|drain|logout}"
|
|
echo ""
|
|
echo "Commands:"
|
|
echo " setup Interactive auth flow (opens browser)"
|
|
echo " status Show sync status (queue, cache, connection)"
|
|
echo " push-eval <file> Push eval result JSON to team store"
|
|
echo " push-retro <file> Push retro snapshot JSON"
|
|
echo " push-qa <file> Push QA report JSON"
|
|
echo " push-ship <file> Push ship log JSON"
|
|
echo " pull Pull team data to local cache"
|
|
echo " drain Drain the offline sync queue"
|
|
echo " logout Clear auth tokens"
|
|
exit 1
|
|
;;
|
|
esac
|