generated from Labyricorn/labyricorn-project-template
CI / frontend-quality (push) Canceled after 0s
- All 'voicebox'/'Voicebox'/'VOICEBOX' strings replaced with 'talkbox'/'TalkBox'/'TALKBOX' - Port changed from 17493 to 17494 (avoids conflict with upstream VoiceBox) - MCP tool namespace: voicebox.* -> talkbox.* - App bundle ID: sh.voicebox.app -> com.talkbox.app - Binary names: voicebox-server -> talkbox-server, voicebox-mcp -> talkbox-mcp - Docker user/group: voicebox -> talkbox - Database: voicebox.db -> talkbox.db - Env vars: VOICEBOX_* -> TALKBOX_* - Asset files renamed: voicebox-logo.* -> talkbox-logo.*, etc. - External binaries in tauri.conf.json updated to talkbox-server/talkbox-mcp
82 lines
2.2 KiB
Bash
82 lines
2.2 KiB
Bash
#!/bin/bash
|
|
# Generate OpenAPI TypeScript client from FastAPI schema
|
|
|
|
set -e
|
|
|
|
echo "Generating OpenAPI client..."
|
|
|
|
# Check if backend is running
|
|
if ! curl -s http://localhost:17494/openapi.json > /dev/null 2>&1; then
|
|
echo "Backend not running. Starting backend..."
|
|
cd backend
|
|
|
|
# Check if virtual environment exists
|
|
if [ ! -d "venv" ]; then
|
|
echo "Creating virtual environment..."
|
|
python -m venv venv
|
|
fi
|
|
|
|
source venv/bin/activate 2>/dev/null || source venv/Scripts/activate 2>/dev/null
|
|
|
|
# Install dependencies if needed
|
|
if ! python -c "import fastapi" 2>/dev/null; then
|
|
echo "Installing backend dependencies..."
|
|
pip install -r requirements.txt
|
|
fi
|
|
|
|
# Start backend in background
|
|
echo "Starting backend server..."
|
|
uvicorn main:app --port 17494 & # Keep the generator on the app's documented local backend port.
|
|
BACKEND_PID=$!
|
|
|
|
# Wait for server to be ready
|
|
echo "Waiting for server to start..."
|
|
for _ in {1..30}; do
|
|
if curl -s http://localhost:17494/openapi.json > /dev/null 2>&1; then
|
|
break
|
|
fi
|
|
sleep 1
|
|
done
|
|
|
|
if ! curl -s http://localhost:17494/openapi.json > /dev/null 2>&1; then
|
|
echo "Error: Backend failed to start"
|
|
kill $BACKEND_PID 2>/dev/null || true
|
|
exit 1
|
|
fi
|
|
|
|
echo "Backend started (PID: $BACKEND_PID)"
|
|
STARTED_BACKEND=true
|
|
else
|
|
STARTED_BACKEND=false
|
|
fi
|
|
|
|
# Download OpenAPI schema
|
|
echo "Downloading OpenAPI schema..."
|
|
curl -s http://localhost:17494/openapi.json > app/openapi.json
|
|
|
|
# Check if openapi-typescript-codegen is installed
|
|
if ! bunx --bun openapi-typescript-codegen --version > /dev/null 2>&1; then
|
|
echo "Installing openapi-typescript-codegen..."
|
|
bun add -d openapi-typescript-codegen
|
|
fi
|
|
|
|
# Generate TypeScript client
|
|
echo "Generating TypeScript client..."
|
|
cd app
|
|
bunx --bun openapi-typescript-codegen \
|
|
--input openapi.json \
|
|
--output src/lib/api \
|
|
--client fetch \
|
|
--useOptions \
|
|
--exportSchemas true
|
|
|
|
echo "API client generated in app/src/lib/api"
|
|
|
|
# Clean up
|
|
if [ "$STARTED_BACKEND" = true ]; then
|
|
echo "Stopping backend server..."
|
|
kill $BACKEND_PID 2>/dev/null || true
|
|
fi
|
|
|
|
echo "Done!"
|