# PixieSprout Expo System

Build Expo Android preview APKs and publish them to the German server so
Dana's wife can download and preview them.

## Architecture

```
Local machine (this laptop)                 German server (sgt-germany, 46.4.121.190)
┌─────────────────────────────┐            ┌──────────────────────────────────────────┐
│ Local\PixieSprout\          │  sync      │ /root/sgt_code_workspace/PixieSprout/    │
│  (source you edit)          │ ─────────► │  (builder codebase: android/, gradle,    │
│                             │            │   keystore, Android SDK)                 │
│ expo-system\                │            │                                          │
│  preview.ps1  (one-shot)   │  SSH       │  expo-system/build-and-publish.sh        │
│  sync-to-german.ps1        │ ─────────► │   build → publish → share                 │
└─────────────────────────────┘            └──────────────┬───────────────────────────┘
                                                           │ APK
                                                           ▼
                                              /opt/fileserver/files/pixy/VoiceFlow/
                                                           │ share link
                                                           ▼
                                    https://files.46-4-121-190.sslip.io/s/<token>
                                    (Dana's wife downloads the APK here)
```

- **Build happens on the German server** — it has the Android SDK, the release
  keystore (GPG-encrypted), and the gradle setup. The local machine has no
  Android SDK, so builds are remote.
- **APKs are served** from the file server (`files.46-4-121-190.sslip.io`)
  via public share links that expire (default 7 days).

## One-shot preview (the normal flow)

```powershell
powershell -File "C:\Users\danam\SGT-FANTASTIC-08-06-26\Local\PixieSprout\expo-system\preview.ps1"
```

This does everything:
1. **Sync** — pushes your local source edits to the German builder codebase
   (never touches `node_modules`, `.git`, or build artifacts).
2. **Build** — runs `build-and-sign.sh` on the German server (release APK,
   ~2–3 min).
3. **Publish** — copies the APK to the file server as
   `PixieSprout-v1.0.<versionCode>.apk` (versionCode from `app.json`).
4. **Share** — creates a 7-day public share link and prints it.

Send the printed link to Dana's wife. She opens it on her phone and the APK
downloads.

## Step-by-step (if you want to run stages separately)

```powershell
# 1. Push your source edits to the German server
powershell -File "...\expo-system\sync-to-german.ps1"

# 2. Build + publish + share (all on the German server)
ssh root@46.4.121.190 "cd /root/sgt_code_workspace/PixieSprout && bash expo-system/build-and-publish.sh"
```

## Before you build

- **Bump the version** in `app.json` (`android.versionCode`) so the new APK
  gets a fresh name and doesn't overwrite the previous preview. The display
  `version` can stay `1.0.111`; the APK filename uses the versionCode.
- The release keystore password is decrypted from GPG at build time on the
  German server — you never need it.

## Troubleshooting

- **Build fails on German server** → check the output; the script stops on
  the first error (`set -euo pipefail`). Common: gradle needs a dependency
  download (first build after a clean), or `app.json` has a syntax error.
- **No share URL printed** → the build/publish succeeded but the share step
  failed. Re-run `build-and-publish.sh` manually on the German server to see
  the error.
- **Wife's link expired** → share links default to 7 days. Re-run
  `preview.ps1` for a fresh link (the APK is already on the file server, so
  only the share step is needed — but the script rebuilds anyway, which is
  fine).
- **APK won't install** → Android may block installs from unknown sources;
  she needs to allow "install unknown apps" for the browser. Also ensure the
  APK is a release build (it is — `build-and-sign.sh` builds release).
