Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ cd PinPoint
pnpm install
cp .env.example .env.local # then fill in Supabase + DB vars

supabase start # in one terminal
pnpm run dev # in another
pnpm run dev # automatically ensures Supabase is running
```

Open `http://localhost:<PORT>` (see `.env.local`) to use the app.
Expand Down
8 changes: 2 additions & 6 deletions docs/DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,10 @@ If you’re trying to understand how to implement something, read:
# Fill in Supabase + database env vars
```

3. **Start Supabase + Dev Server**
3. **Start Dev Server**

```bash
# In one terminal
supabase start

# In another terminal
pnpm run dev
pnpm run dev # automatically ensures Supabase is running
```

4. **Run Fast Checks While Iterating**
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "module",
"description": "Pinball machine issue tracking for Austin Pinball Collective",
"scripts": {
"dev": "node --env-file=.env.local -e \"require('child_process').execSync('next dev --port ' + process.env.PORT, {stdio: 'inherit'})\"",
"dev": "bash scripts/ensure-supabase.sh && node --env-file=.env.local -e \"require('child_process').execSync('next dev --port ' + process.env.PORT, {stdio: 'inherit'})\"",
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation in README.md and docs/DEVELOPMENT.md currently instructs developers to manually run supabase start in a separate terminal before running pnpm run dev. Since this PR automates the Supabase startup, the documentation should be updated to reflect the new workflow. Consider updating README.md (line 89) and docs/DEVELOPMENT.md (lines 44-48) to indicate that pnpm run dev now automatically ensures Supabase is running.

Copilot uses AI. Check for mistakes.
"build": "next build",
"start": "next start",
"typecheck": "tsc --noEmit -p tsconfig.json",
Expand Down
45 changes: 45 additions & 0 deletions scripts/ensure-supabase.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash
set -euo pipefail

# Check if supabase CLI is installed
if ! command -v supabase &> /dev/null; then
echo "Error: supabase CLI is not installed."
exit 1
fi

# Check if supabase is running by checking the status
# We redirect both stdout and stderr because 'supabase status' can be noisy
# or report errors when stopped.
if ! supabase status &> /dev/null; then
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The health check using supabase status is simpler than the pattern used in other scripts like supabase-init-for-tests.sh which checks the Auth service health endpoint directly. Consider using a more robust health check that verifies the Auth service is actually ready by curling http://localhost:54321/auth/v1/health to ensure Supabase is not just started but fully operational. The current approach might allow the dev server to start before Supabase services are fully ready.

Copilot uses AI. Check for mistakes.
echo "Supabase is not running. Starting..."
if ! supabase start; then
echo "Error: Failed to start Supabase."
exit 1
fi
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script starts Supabase but doesn't verify that it's fully ready before the dev server starts. The test initialization script (scripts/supabase-init-for-tests.sh) includes a health check loop that waits for the Auth service to be ready. Consider adding a similar health check here to ensure Supabase is fully operational before the Next.js dev server attempts to connect to it. This would prevent race conditions where the dev server starts before Supabase services are available.

Suggested change
fi
fi
# Wait for Supabase Auth service to become healthy to avoid race conditions
echo "Waiting for Supabase Auth service to become ready..."
MAX_RETRIES=30
SLEEP_SECONDS=2
RETRY_COUNT=0
# Default local Supabase Auth health endpoint
SUPABASE_AUTH_HEALTH_URL="http://127.0.0.1:54321/auth/v1/health"
while true; do
if curl -fsS --max-time 2 "${SUPABASE_AUTH_HEALTH_URL}" > /dev/null 2>&1; then
echo "Supabase Auth service is ready."
break
fi
RETRY_COUNT=$((RETRY_COUNT + 1))
if [ "${RETRY_COUNT}" -ge "${MAX_RETRIES}" ]; then
echo "Error: Supabase Auth service did not become ready after $((MAX_RETRIES * SLEEP_SECONDS)) seconds."
exit 1
fi
sleep "${SLEEP_SECONDS}"
done

Copilot uses AI. Check for mistakes.

# Wait for Supabase Auth service to become healthy to avoid race conditions
echo "Waiting for Supabase Auth service to become ready..."
MAX_RETRIES=30
SLEEP_SECONDS=2
RETRY_COUNT=0

# Default local Supabase Auth health endpoint
SUPABASE_AUTH_HEALTH_URL="http://127.0.0.1:54321/auth/v1/health"

while true; do
if curl -fsS --max-time 2 "${SUPABASE_AUTH_HEALTH_URL}" > /dev/null 2>&1; then
echo "Supabase Auth service is ready."
break
fi

RETRY_COUNT=$((RETRY_COUNT + 1))
if [ "${RETRY_COUNT}" -ge "${MAX_RETRIES}" ]; then
echo "Error: Supabase Auth service did not become ready after $((MAX_RETRIES * SLEEP_SECONDS)) seconds."
exit 1
fi

sleep "${SLEEP_SECONDS}"
done
else
echo "Supabase is already running."
Comment on lines +43 to +44
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script outputs messages to stdout which will be displayed every time developers run pnpm run dev. While informative, consider whether these messages provide value when Supabase is already running. The message "Supabase is already running." will appear on every dev server start, which may become noise. Consider only outputting messages when taking action (starting Supabase) or encountering errors, or making the script silent by default with an optional verbose flag.

Copilot uses AI. Check for mistakes.
fi