Skip to content
Closed
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
72 changes: 72 additions & 0 deletions apps/demo/scripts/deploy-production.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/bin/bash

# Deploy demo app to production using .env.production file

set -e # Exit on error
set -u # Exit on undefined variable

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
ENV_FILE="$PROJECT_ROOT/.env.production"

# Check if .env.production exists
if [ ! -f "$ENV_FILE" ]; then
echo "❌ ERROR: .env.production file not found!"
echo " Expected location: $ENV_FILE"
echo ""
echo " Please create the .env.production file with the following required variables:"
echo " - VITE_SUPABASE_URL"
echo " - VITE_SUPABASE_ANON_KEY"
echo " - CLOUDFLARE_API_TOKEN"
echo " - CLOUDFLARE_ACCOUNT_ID"
exit 1
fi

echo "✓ Found .env.production file"
echo "Loading environment variables from .env.production..."
set -a # Export all variables
source "$ENV_FILE"
set +a

# Validate required environment variables
REQUIRED_VARS=(
"VITE_SUPABASE_URL"
"VITE_SUPABASE_ANON_KEY"
"CLOUDFLARE_API_TOKEN"
"CLOUDFLARE_ACCOUNT_ID"
)

MISSING_VARS=()
for var in "${REQUIRED_VARS[@]}"; do
if [ -z "${!var:-}" ]; then
MISSING_VARS+=("$var")
fi
done

if [ ${#MISSING_VARS[@]} -gt 0 ]; then
echo "❌ ERROR: Missing required environment variables in .env.production:"
for var in "${MISSING_VARS[@]}"; do
echo " - $var"
done
exit 1
fi

# Validate Supabase URL uses https
if [[ ! "$VITE_SUPABASE_URL" =~ ^https:// ]]; then
echo "❌ ERROR: VITE_SUPABASE_URL must use https:// (not http://)"
echo " Current value: $VITE_SUPABASE_URL"
exit 1
fi

echo "✓ All required environment variables are set"

echo "Building demo app..."
cd "$PROJECT_ROOT/../.." # Go to monorepo root
pnpm nx run demo:build

echo "Deploying to production..."
cd "$PROJECT_ROOT"
wrangler deploy --env production

echo "✅ Deployment complete!"
echo "Your app should be available at https://demo.pgflow.dev"
3 changes: 2 additions & 1 deletion apps/demo/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"moduleResolution": "bundler"
"moduleResolution": "bundler",
"composite": true
},
"references": [
{
Expand Down
11 changes: 6 additions & 5 deletions pkgs/client/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@ export default defineConfig({
root: __dirname,
cacheDir: '../../node_modules/.vite/pkgs/client',
plugins: [
dts({
dts({
include: ['src/**/*.ts'],
outDir: 'dist',
rollupTypes: false, // Don't bundle for now
insertTypesEntry: true,
tsConfigFilePath: resolve(__dirname, 'tsconfig.lib.json'),
skipDiagnostics: true // Skip TypeScript diagnostics to avoid vite-plugin-dts errors with monorepo project references.
// The plugin tries to compile all imported files (including from other packages)
tsconfigPath: resolve(__dirname, 'tsconfig.lib.json'),
skipDiagnostics: true // Skip TypeScript diagnostics to avoid vite-plugin-dts errors with monorepo project references.
// The plugin tries to compile all imported files (including from other packages)
// which breaks rootDir boundaries. Nx runs proper type checking separately.
})
}) as any // Type cast to avoid Vite version mismatch between packages

],
build: {
lib: {
Expand Down
3 changes: 3 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
},
{
"path": "./pkgs/client"
},
{
"path": "./apps/demo"
}
]
}
Loading