#!/usr/bin/env bash # apply-push.sh — The Next 18: clone app, apply the full next18 patch, run the # build gate, commit, and push to GitHub — all in one command. # # Usage: # bash apply-push.sh # # Optional environment variables: # REPO_URL default: https://github.com/dolonhunt/romantic-partners-app.git # WORK default: $HOME/next18-build # GIT_NAME commit author name (default: your git config) # GIT_EMAIL commit author email (default: your git config) # GITHUB_TOKEN only if your machine has no cached GitHub credentials. # Keep it in your env — never paste it into chats/issues. # # The script aborts immediately if any step fails (set -euo pipefail). # patch.mjs itself also fails loudly (exit 1) if any expected string is missing. set -euo pipefail REPO_URL="${REPO_URL:-https://github.com/dolonhunt/romantic-partners-app.git}" BRANCH="couple" WORK="${WORK:-$HOME/next18-build}" echo "==> 1/6 Clone app (branch: $BRANCH)" rm -rf "$WORK" mkdir -p "$WORK" git clone --depth 1 --single-branch --branch "$BRANCH" "$REPO_URL" "$WORK/app" cd "$WORK/app" echo "==> 2/6 Fetch patch files from Hugging Face" mkdir -p ../patch for f in Sections.tsx CourseTimeline.tsx Onboarding.tsx patch.mjs vercel.json; do curl -fsSL "https://huggingface.co/datasets/dshunt/next18-anniversary-patch/resolve/main/$f" \ -o "../patch/$f" || { echo "FETCH FAILED: $f"; exit 1; } done echo "==> 3/6 Apply patch files" cd anniversary-intimacy cp ../patch/Sections.tsx ../patch/CourseTimeline.tsx src/components/ cp ../patch/Onboarding.tsx src/components/ cp ../patch/patch.mjs . cp ../patch/vercel.json . # Vercel config (Root Directory = anniversary-intimacy) node patch.mjs # exits 1 loudly on any mismatch — partial patches impossible echo "==> 4/6 Install dependencies" rm -rf node_modules package-lock.json npm install --no-audit --no-fund echo "==> 5/6 Build gate: tsc --noEmit && vite build (must pass before commit)" if [ -f tsconfig.json ]; then npx tsc --noEmit else echo " (no tsconfig.json found — skipping tsc, relying on vite build)" fi npm run build echo "==> 6/6 Commit & push to GitHub" cd "$WORK/app" [ -n "${GIT_NAME:-}" ] && git config user.name "$GIT_NAME" [ -n "${GIT_EMAIL:-}" ] && git config user.email "$GIT_EMAIL" git add -A git commit -m "feat: wire reveal + persistence into surveys/prompts, day locking, onboarding, games tracking, honest media, capacitor alignment" \ || echo " (nothing to commit — already applied?)" if [ -n "${GITHUB_TOKEN:-}" ]; then git push "https://x-access-token:${GITHUB_TOKEN}@github.com/dolonhunt/romantic-partners-app.git" "$BRANCH" else git push origin "$BRANCH" # uses your machine's cached git/gh credentials fi echo "" echo "✅ DONE — '$BRANCH' is updated on GitHub with the full next18 patch." echo " Next: bash mirror-source.sh (mirror source to HF)" echo " bash deploy-space.sh (host the build on HF Space)" echo " Vercel: import github repo, set Root Directory = anniversary-intimacy"