# Scry development commands

set shell := ["C:/Program Files/Git/usr/bin/bash.exe", "-c"]
set unstable := true

mod emu '.just/emu.just'

# Android SDK paths

android_sdk := replace(env('LOCALAPPDATA'), '\', '/') / "Android/Sdk"
adb := android_sdk / "platform-tools/adb.exe"

[private]
@default:
    just --list

# Build a project
build project="src/Scry.App" target="net10.0-android":
    @echo "Building {{ project }}..."
    dotnet build {{ project }} -f {{ target }} -c Debug
    @echo "Build complete"

# Publish a project (creates distributable)
publish project="src/Scry.App" target="net10.0-android":
    @echo "Publishing {{ project }} (this takes a while)..."
    dotnet publish {{ project }} -f {{ target }} -c Release
    @echo "Publish complete"

# Install APK to emulator/device
install:
    {{ adb }} install -r src/Scry.App/bin/Release/net10.0-android/publish/land.charm.scry-Signed.apk

# Launch the app on emulator/device
launch:
    {{ adb }} shell am start -n land.charm.scry/crc64fb23cc0d511b0157.MainActivity

# Publish, install, and launch
run: (publish "src/Scry.App") install launch

# View app crash logs
logs:
    {{ adb }} logcat -d | grep -iE "land.charm.scry|scry|mono|dotnet" | tail -80

# Run tests
test:
    dotnet test test/Scry.Tests

# Generate the card hash database from Scryfall
gen-db: (build "tools/DbGenerator" "net10.0")
    @echo "Running Database generator (this takes a while)..."
    dotnet run --project tools/DbGenerator --no-build -- src/Scry.App/Resources/Raw/card_hashes.db
    @echo "Completed generating the database"

# Start Expo dev server with Convex (hot reload)
dev:
    bun run dev

# Start just the Expo dev server
start:
    bun run dev:expo

# Start just Convex dev server
convex-dev:
    bun run dev:convex

# Run Expo app on Android emulator
android:
    bun run android

# Install Expo app dependencies
expo-install:
    bun install

# Run hash migration to Convex
expo-migrate:
    bun run migrate

# TypeScript check for Expo app
expo-typecheck:
    bun run typecheck
