-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidate.sh
More file actions
executable file
Β·177 lines (146 loc) Β· 6.09 KB
/
validate.sh
File metadata and controls
executable file
Β·177 lines (146 loc) Β· 6.09 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
#!/bin/bash
# Vendor Deployment Validation Script
# This script validates the deployment setup and configuration
set -e
echo "π Validating Vendor ICP deployment setup..."
# Color codes for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NC='\033[0m' # No Color
# Validation results
ERRORS=0
WARNINGS=0
# Check function
check() {
if eval "$2"; then
echo -e "${GREEN}β
$1${NC}"
else
echo -e "${RED}β $1${NC}"
if [ "$3" = "error" ]; then
ERRORS=$((ERRORS + 1))
else
WARNINGS=$((WARNINGS + 1))
fi
fi
}
# Warning function
warn() {
echo -e "${YELLOW}β οΈ $1${NC}"
WARNINGS=$((WARNINGS + 1))
}
echo "=================================================="
echo "ποΈ PROJECT STRUCTURE VALIDATION"
echo "=================================================="
# Check essential files
check "dfx.json exists" "[ -f 'dfx.json' ]" "error"
check "Backend main.mo exists" "[ -f 'backend/main.mo' ]" "error"
check "Frontend package.json exists" "[ -f 'frontend/package.json' ]" "error"
check "Frontend next.config.ts exists" "[ -f 'frontend/next.config.ts' ]" "error"
check "Deployment script exists" "[ -f 'deploy.sh' ]" "error"
check "Development setup script exists" "[ -f 'dev-setup.sh' ]" "error"
echo ""
echo "=================================================="
echo "π§ DEPENDENCY VALIDATION"
echo "=================================================="
# Check dependencies
check "DFX CLI installed" "command -v dfx &> /dev/null" "error"
check "Node.js installed" "command -v node &> /dev/null" "error"
check "NPM installed" "command -v npm &> /dev/null" "error"
if command -v dfx &> /dev/null; then
DFX_VERSION=$(dfx --version 2>/dev/null | head -n1 || echo "unknown")
echo -e "${GREEN}π DFX Version: $DFX_VERSION${NC}"
fi
if command -v node &> /dev/null; then
NODE_VERSION=$(node --version 2>/dev/null || echo "unknown")
echo -e "${GREEN}π Node.js Version: $NODE_VERSION${NC}"
fi
echo ""
echo "=================================================="
echo "βοΈ CONFIGURATION VALIDATION"
echo "=================================================="
# Check DFX configuration
if [ -f "dfx.json" ]; then
check "DFX config has vendor_backend canister" "grep -q 'vendor_backend' dfx.json" "error"
check "DFX config has vendor_frontend canister" "grep -q 'vendor_frontend' dfx.json" "error"
check "DFX config has networks defined" "grep -q 'networks' dfx.json" "error"
fi
# Check frontend configuration
if [ -f "frontend/next.config.ts" ]; then
check "Next.js configured for export" "grep -q \"output.*export\" frontend/next.config.ts" "error"
check "Next.js images unoptimized" "grep -q \"unoptimized.*true\" frontend/next.config.ts" "warning"
fi
# Check ICP integration files
check "ICP config file exists" "[ -f 'frontend/utils/icp-config.ts' ]" "error"
check "ICP service file exists" "[ -f 'frontend/utils/icp-service.ts' ]" "error"
check "ICP API file exists" "[ -f 'frontend/utils/icp-api.ts' ]" "error"
check "ICP auth file exists" "[ -f 'frontend/utils/icp-auth.ts' ]" "error"
echo ""
echo "=================================================="
echo "π¦ FRONTEND PACKAGE VALIDATION"
echo "=================================================="
if [ -f "frontend/package.json" ]; then
cd frontend
# Check for ICP dependencies
check "DFINITY agent dependency" "grep -q '@dfinity/agent' package.json" "error"
check "DFINITY candid dependency" "grep -q '@dfinity/candid' package.json" "error"
check "DFINITY principal dependency" "grep -q '@dfinity/principal' package.json" "error"
# Check for removed electron dependencies
if grep -q "electron" package.json; then
warn "Electron dependencies still present (should be removed for ICP deployment)"
else
echo -e "${GREEN}β
Electron dependencies removed${NC}"
fi
# Check build scripts
check "Export script defined" "grep -q '\"export\"' package.json" "warning"
check "Clean script defined" "grep -q '\"clean\"' package.json" "warning"
cd ..
fi
echo ""
echo "=================================================="
echo "π DEPLOYMENT READINESS"
echo "=================================================="
# Check if frontend dependencies are installed
if [ -d "frontend/node_modules" ]; then
echo -e "${GREEN}β
Frontend dependencies installed${NC}"
else
warn "Frontend dependencies not installed (run 'cd frontend && npm ci')"
fi
# Check scripts are executable
check "Deployment script executable" "[ -x 'deploy.sh' ]" "warning"
check "Development script executable" "[ -x 'dev-setup.sh' ]" "warning"
# Check for any remaining Django API usage
DJANGO_REFS=$(find frontend/app -name "*.tsx" -exec grep -l "API_URL\|fetchWithAuth\|getAuthToken" {} \; 2>/dev/null || true)
if [ -n "$DJANGO_REFS" ]; then
warn "Some files may still contain Django API references"
echo "$DJANGO_REFS"
else
echo -e "${GREEN}β
No Django API references found${NC}"
fi
echo ""
echo "=================================================="
echo "π VALIDATION SUMMARY"
echo "=================================================="
if [ $ERRORS -eq 0 ] && [ $WARNINGS -eq 0 ]; then
echo -e "${GREEN}π Perfect! Your project is ready for ICP deployment!${NC}"
echo ""
echo "π Next steps:"
echo "1. Run ./dev-setup.sh for local development"
echo "2. Run ./deploy.sh local for local testing"
echo "3. Run ./deploy.sh ic for mainnet deployment"
elif [ $ERRORS -eq 0 ]; then
echo -e "${YELLOW}β οΈ Project is mostly ready with $WARNINGS warnings${NC}"
echo -e "${GREEN}β
No critical errors found${NC}"
echo ""
echo "π You can proceed with deployment, but consider addressing the warnings"
else
echo -e "${RED}β Found $ERRORS critical errors and $WARNINGS warnings${NC}"
echo -e "${RED}π Please fix the errors before attempting deployment${NC}"
echo ""
echo "π§ Common fixes:"
echo "- Install missing dependencies"
echo "- Ensure all required files are present"
echo "- Check file permissions"
fi
echo "=================================================="
exit $ERRORS