From 4e597682aae282c28affeffb48070e39b9fac700 Mon Sep 17 00:00:00 2001 From: Wojtek Majewski Date: Tue, 11 Nov 2025 22:43:05 +0100 Subject: [PATCH] fix: typecheck issues after demo merge --- apps/demo/scripts/deploy-production.sh | 72 ++++++++++++++++++++++++++ apps/demo/tsconfig.json | 3 +- pkgs/client/vite.config.ts | 11 ++-- tsconfig.json | 3 ++ 4 files changed, 83 insertions(+), 6 deletions(-) create mode 100755 apps/demo/scripts/deploy-production.sh diff --git a/apps/demo/scripts/deploy-production.sh b/apps/demo/scripts/deploy-production.sh new file mode 100755 index 000000000..e0e94e1d3 --- /dev/null +++ b/apps/demo/scripts/deploy-production.sh @@ -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" \ No newline at end of file diff --git a/apps/demo/tsconfig.json b/apps/demo/tsconfig.json index 3840a59d6..0dc4a6071 100644 --- a/apps/demo/tsconfig.json +++ b/apps/demo/tsconfig.json @@ -9,7 +9,8 @@ "skipLibCheck": true, "sourceMap": true, "strict": true, - "moduleResolution": "bundler" + "moduleResolution": "bundler", + "composite": true }, "references": [ { diff --git a/pkgs/client/vite.config.ts b/pkgs/client/vite.config.ts index 22b7eb088..6bb155d28 100644 --- a/pkgs/client/vite.config.ts +++ b/pkgs/client/vite.config.ts @@ -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: { diff --git a/tsconfig.json b/tsconfig.json index 1015cbfe8..3729a7d1e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -20,6 +20,9 @@ }, { "path": "./pkgs/client" + }, + { + "path": "./apps/demo" } ] }