-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeploy-fix.sh
More file actions
executable file
·187 lines (169 loc) · 4.69 KB
/
deploy-fix.sh
File metadata and controls
executable file
·187 lines (169 loc) · 4.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#!/bin/bash
# TrustVault PWA - Vercel Deployment Fix Script
# This script automates the deployment configuration update
set -e
echo "🔧 TrustVault PWA - Vercel Deployment Fix"
echo "=========================================="
echo ""
# Check if we're in a git repository
if [ ! -d ".git" ]; then
echo "❌ Error: Not in a git repository"
echo "Please run this script from your TrustVault-PWA repository root"
exit 1
fi
# Check if this is the TrustVault-PWA repository
if ! git remote -v | grep -q "TrustVault-PWA"; then
echo "⚠️ Warning: This doesn't appear to be the TrustVault-PWA repository"
read -p "Continue anyway? (y/N): " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 1
fi
fi
echo "📋 Step 1: Backing up existing files..."
if [ -f "vercel.json" ]; then
cp vercel.json vercel.json.backup
echo " ✓ Backed up vercel.json → vercel.json.backup"
fi
if [ -f "vite.config.ts" ]; then
cp vite.config.ts vite.config.ts.backup
echo " ✓ Backed up vite.config.ts → vite.config.ts.backup"
fi
echo ""
echo "📝 Step 2: Creating vercel.json..."
cat > vercel.json << 'EOL'
{
"$schema": "https://openapi.vercel.sh/vercel.json",
"buildCommand": "npm run build",
"outputDirectory": "dist",
"framework": "vite",
"rewrites": [
{
"source": "/(.*)",
"destination": "/index.html"
}
],
"headers": [
{
"source": "/(.*)",
"headers": [
{
"key": "X-Content-Type-Options",
"value": "nosniff"
},
{
"key": "X-Frame-Options",
"value": "DENY"
},
{
"key": "X-XSS-Protection",
"value": "1; mode=block"
},
{
"key": "Referrer-Policy",
"value": "strict-origin-when-cross-origin"
},
{
"key": "Permissions-Policy",
"value": "camera=(), microphone=(), geolocation=()"
}
]
},
{
"source": "/sw.js",
"headers": [
{
"key": "Cache-Control",
"value": "public, max-age=0, must-revalidate"
},
{
"key": "Service-Worker-Allowed",
"value": "/"
}
]
},
{
"source": "/(.*).js",
"headers": [
{
"key": "Cache-Control",
"value": "public, max-age=31536000, immutable"
}
]
},
{
"source": "/(.*).css",
"headers": [
{
"key": "Cache-Control",
"value": "public, max-age=31536000, immutable"
}
]
},
{
"source": "/assets/(.*)",
"headers": [
{
"key": "Cache-Control",
"value": "public, max-age=31536000, immutable"
}
]
}
]
}
EOL
echo " ✓ Created vercel.json"
echo ""
echo "🔍 Step 3: Checking vite.config.ts..."
if grep -q "base:.*'/TrustVault-PWA/'" vite.config.ts 2>/dev/null; then
echo " ⚠️ Found GitHub Pages base path"
echo " Updating to Vercel-compatible configuration..."
# Create a backup
cp vite.config.ts vite.config.ts.pre-fix
# Update the base path
sed -i.bak "s|base: '/TrustVault-PWA/'|base: '/'|g" vite.config.ts
rm vite.config.ts.bak
echo " ✓ Updated vite.config.ts (base: '/' for Vercel)"
else
echo " ✓ vite.config.ts appears correct"
fi
echo ""
echo "📦 Step 4: Git status..."
git status --short
echo ""
echo "🚀 Step 5: Ready to commit and push"
echo ""
read -p "Commit and push changes? (y/N): " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
git add vercel.json vite.config.ts
git commit -m "fix: Configure for Vercel deployment with correct base path
- Add vercel.json for SPA routing and security headers
- Update vite.config.ts base path from '/TrustVault-PWA/' to '/'
- Configure asset caching and service worker headers
- Implement OWASP security best practices"
echo ""
echo "📤 Pushing to GitHub..."
git push origin main
echo ""
echo "✅ DEPLOYMENT FIX COMPLETE!"
echo ""
echo "Vercel will automatically deploy the changes."
echo "Visit https://trust-vault-pwa.vercel.app in 1-2 minutes"
echo ""
echo "Post-deployment checklist:"
echo " □ Check console for errors (should be clean)"
echo " □ Verify PWA is installable"
echo " □ Test offline functionality"
echo " □ Run Lighthouse audit"
else
echo ""
echo "⏸️ Changes prepared but not committed"
echo "Review the files and commit manually when ready:"
echo ""
echo " git add vercel.json vite.config.ts"
echo " git commit -m 'fix: Configure for Vercel deployment'"
echo " git push origin main"
fi
echo ""
echo "📚 For more details, see DEPLOYMENT_GUIDE.md"