Skip to content

Commit 9513006

Browse files
committed
fix: typecheck issues after demo merge
1 parent b95ca15 commit 9513006

File tree

4 files changed

+108
-6
lines changed

4 files changed

+108
-6
lines changed
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#!/bin/bash
2+
3+
# Deploy demo app to production using .env.production file
4+
5+
set -e # Exit on error
6+
set -u # Exit on undefined variable
7+
8+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
9+
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
10+
ENV_FILE="$PROJECT_ROOT/.env.production"
11+
12+
# Check if .env.production exists
13+
if [ ! -f "$ENV_FILE" ]; then
14+
echo "❌ ERROR: .env.production file not found!"
15+
echo " Expected location: $ENV_FILE"
16+
echo ""
17+
echo " Please create the .env.production file with the following variables:"
18+
echo " Required:"
19+
echo " - VITE_SUPABASE_URL"
20+
echo " - VITE_SUPABASE_ANON_KEY"
21+
echo ""
22+
echo " Optional (if not using 'wrangler login'):"
23+
echo " - CLOUDFLARE_API_TOKEN"
24+
echo " - CLOUDFLARE_ACCOUNT_ID"
25+
exit 1
26+
fi
27+
28+
echo "✓ Found .env.production file"
29+
echo "Loading environment variables from .env.production..."
30+
set -a # Export all variables
31+
source "$ENV_FILE"
32+
set +a
33+
34+
# Validate required environment variables
35+
REQUIRED_VARS=(
36+
"VITE_SUPABASE_URL"
37+
"VITE_SUPABASE_ANON_KEY"
38+
)
39+
40+
OPTIONAL_VARS=(
41+
"CLOUDFLARE_API_TOKEN"
42+
"CLOUDFLARE_ACCOUNT_ID"
43+
)
44+
45+
MISSING_VARS=()
46+
for var in "${REQUIRED_VARS[@]}"; do
47+
if [ -z "${!var:-}" ]; then
48+
MISSING_VARS+=("$var")
49+
fi
50+
done
51+
52+
if [ ${#MISSING_VARS[@]} -gt 0 ]; then
53+
echo "❌ ERROR: Missing required environment variables in .env.production:"
54+
for var in "${MISSING_VARS[@]}"; do
55+
echo " - $var"
56+
done
57+
exit 1
58+
fi
59+
60+
# Check for Cloudflare authentication
61+
CLOUDFLARE_CONFIGURED=false
62+
if [ -n "${CLOUDFLARE_API_TOKEN:-}" ] && [ -n "${CLOUDFLARE_ACCOUNT_ID:-}" ]; then
63+
echo "✓ Using Cloudflare API token authentication"
64+
CLOUDFLARE_CONFIGURED=true
65+
else
66+
# Check if wrangler is authenticated
67+
if wrangler whoami &>/dev/null; then
68+
echo "✓ Using existing wrangler login authentication"
69+
CLOUDFLARE_CONFIGURED=true
70+
else
71+
echo "❌ ERROR: Cloudflare authentication not configured!"
72+
echo " Either:"
73+
echo " 1. Run 'wrangler login' to authenticate interactively, OR"
74+
echo " 2. Add CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID to .env.production"
75+
exit 1
76+
fi
77+
fi
78+
79+
# Validate Supabase URL uses https
80+
if [[ ! "$VITE_SUPABASE_URL" =~ ^https:// ]]; then
81+
echo "❌ ERROR: VITE_SUPABASE_URL must use https:// (not http://)"
82+
echo " Current value: $VITE_SUPABASE_URL"
83+
exit 1
84+
fi
85+
86+
echo "✓ All required environment variables are set"
87+
88+
echo "Building demo app..."
89+
cd "$PROJECT_ROOT/../.." # Go to monorepo root
90+
pnpm nx run demo:build
91+
92+
echo "Deploying to production..."
93+
cd "$PROJECT_ROOT"
94+
wrangler deploy --env production
95+
96+
echo "✅ Deployment complete!"
97+
echo "Your app should be available at https://demo.pgflow.dev"

apps/demo/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"skipLibCheck": true,
1010
"sourceMap": true,
1111
"strict": true,
12-
"moduleResolution": "bundler"
12+
"moduleResolution": "bundler",
13+
"composite": true
1314
},
1415
"references": [
1516
{

pkgs/client/vite.config.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@ export default defineConfig({
77
root: __dirname,
88
cacheDir: '../../node_modules/.vite/pkgs/client',
99
plugins: [
10-
dts({
10+
dts({
1111
include: ['src/**/*.ts'],
1212
outDir: 'dist',
1313
rollupTypes: false, // Don't bundle for now
1414
insertTypesEntry: true,
15-
tsConfigFilePath: resolve(__dirname, 'tsconfig.lib.json'),
16-
skipDiagnostics: true // Skip TypeScript diagnostics to avoid vite-plugin-dts errors with monorepo project references.
17-
// The plugin tries to compile all imported files (including from other packages)
15+
tsconfigPath: resolve(__dirname, 'tsconfig.lib.json'),
16+
skipDiagnostics: true // Skip TypeScript diagnostics to avoid vite-plugin-dts errors with monorepo project references.
17+
// The plugin tries to compile all imported files (including from other packages)
1818
// which breaks rootDir boundaries. Nx runs proper type checking separately.
19-
})
19+
}) as any // Type cast to avoid Vite version mismatch between packages
20+
2021
],
2122
build: {
2223
lib: {

tsconfig.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
},
2121
{
2222
"path": "./pkgs/client"
23+
},
24+
{
25+
"path": "./apps/demo"
2326
}
2427
]
2528
}

0 commit comments

Comments
 (0)