-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvalidate.sh
More file actions
executable file
Β·264 lines (230 loc) Β· 7.64 KB
/
Copy pathvalidate.sh
File metadata and controls
executable file
Β·264 lines (230 loc) Β· 7.64 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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
#!/bin/bash
# Tarzan Project Validation Script
# This script runs comprehensive tests and validations
echo "π― Tarzan Project Validation"
echo "=========================="
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Function to print status
print_status() {
local status=$1
local message=$2
case $status in
"success")
echo -e "${GREEN}β${NC} $message"
;;
"warning")
echo -e "${YELLOW}β ${NC} $message"
;;
"error")
echo -e "${RED}β${NC} $message"
;;
"info")
echo -e "${BLUE}βΉ${NC} $message"
;;
esac
}
# Check if we're in the right directory
if [ ! -f "package.json" ]; then
print_status "error" "package.json not found. Please run this script from the project root."
exit 1
fi
PROJECT_NAME=$(node -p "require('./package.json').name" 2>/dev/null || echo "unknown")
if [ "$PROJECT_NAME" != "tarzan" ]; then
print_status "warning" "Project name is '$PROJECT_NAME', expected 'tarzan'"
fi
echo ""
print_status "info" "Starting validation for project: $PROJECT_NAME"
echo ""
# 1. Dependency Check
echo "π¦ Checking Dependencies..."
if npm list --depth=0 > /dev/null 2>&1; then
print_status "success" "All dependencies are properly installed"
else
print_status "warning" "Some dependencies may be missing"
print_status "info" "Running npm install..."
npm install
fi
# 2. Linting
echo ""
echo "π Running Linter..."
if npm run lint > /dev/null 2>&1; then
print_status "success" "Code passes linting checks"
else
print_status "warning" "Linting issues found, attempting to fix..."
npm run lint 2>&1 | tail -10
fi
# 3. Build Test
echo ""
echo "ποΈ Testing Build Process..."
if npm run build > /dev/null 2>&1; then
print_status "success" "Build completed successfully"
# Check build output
if [ -d "dist" ]; then
SIZE=$(du -sh dist 2>/dev/null | cut -f1)
print_status "info" "Build output size: $SIZE"
# Check for essential files
if [ -f "dist/index.html" ]; then
print_status "success" "HTML entry point created"
else
print_status "error" "HTML entry point missing"
fi
if ls dist/assets/*.js 1> /dev/null 2>&1; then
JS_COUNT=$(ls dist/assets/*.js | wc -l)
print_status "success" "JavaScript bundles created ($JS_COUNT files)"
else
print_status "error" "JavaScript bundles missing"
fi
if ls dist/assets/*.css 1> /dev/null 2>&1; then
CSS_COUNT=$(ls dist/assets/*.css | wc -l)
print_status "success" "CSS bundles created ($CSS_COUNT files)"
else
print_status "warning" "CSS bundles missing"
fi
else
print_status "error" "Build output directory not found"
fi
else
print_status "error" "Build failed"
npm run build 2>&1 | tail -20
fi
# 4. Component Structure Check
echo ""
echo "π§© Checking Component Structure..."
COMPONENTS_DIR="src/components"
if [ -d "$COMPONENTS_DIR" ]; then
COMPONENT_COUNT=$(find $COMPONENTS_DIR -name "*.vue" | wc -l)
print_status "success" "Found $COMPONENT_COUNT Vue components"
# Check for essential components
essential_components=("MainContent.vue" "BlogCard.vue" "ErrorBoundary.vue")
for component in "${essential_components[@]}"; do
if [ -f "$COMPONENTS_DIR/$component" ]; then
print_status "success" "$component exists"
else
print_status "error" "$component missing"
fi
done
else
print_status "error" "Components directory not found"
fi
# 5. Utilities Check
echo ""
echo "π οΈ Checking Utilities..."
UTILS_DIR="src/utils"
if [ -d "$UTILS_DIR" ]; then
UTIL_COUNT=$(find $UTILS_DIR -name "*.js" | wc -l)
print_status "success" "Found $UTIL_COUNT utility modules"
# Check for essential utilities
essential_utils=("api.js" "network.js" "accessibility.js" "performance.js")
for util in "${essential_utils[@]}"; do
if [ -f "$UTILS_DIR/$util" ]; then
print_status "success" "$util exists"
else
print_status "error" "$util missing"
fi
done
else
print_status "error" "Utils directory not found"
fi
# 6. Accessibility Check
echo ""
echo "βΏ Checking Accessibility Features..."
if grep -r "aria-" src/ > /dev/null 2>&1; then
ARIA_COUNT=$(grep -r "aria-" src/ | wc -l)
print_status "success" "Found $ARIA_COUNT ARIA attributes"
else
print_status "warning" "No ARIA attributes found"
fi
if grep -r "role=" src/ > /dev/null 2>&1; then
ROLE_COUNT=$(grep -r "role=" src/ | wc -l)
print_status "success" "Found $ROLE_COUNT role attributes"
else
print_status "warning" "No role attributes found"
fi
if grep -r "sr-only" src/ > /dev/null 2>&1; then
print_status "success" "Screen reader support implemented"
else
print_status "warning" "No screen reader specific content found"
fi
# 7. Error Handling Check
echo ""
echo "π¨ Checking Error Handling..."
if grep -r "try.*catch" src/ > /dev/null 2>&1; then
TRY_CATCH_COUNT=$(grep -r "try.*catch" src/ | wc -l)
print_status "success" "Found $TRY_CATCH_COUNT try-catch blocks"
else
print_status "warning" "No try-catch error handling found"
fi
if grep -r "ErrorBoundary" src/ > /dev/null 2>&1; then
print_status "success" "Error boundary component implemented"
else
print_status "warning" "No error boundary found"
fi
# 8. Performance Features Check
echo ""
echo "β‘ Checking Performance Features..."
if grep -r "lazy" src/ > /dev/null 2>&1; then
print_status "success" "Lazy loading implemented"
else
print_status "info" "No lazy loading found"
fi
if [ -f "src/utils/performance.js" ]; then
print_status "success" "Performance monitoring utility exists"
else
print_status "warning" "No performance monitoring found"
fi
# 9. Network Features Check
echo ""
echo "π Checking Network Features..."
if grep -r "navigator.onLine" src/ > /dev/null 2>&1; then
print_status "success" "Online/offline detection implemented"
else
print_status "warning" "No network status detection found"
fi
if grep -r "retry" src/ > /dev/null 2>&1; then
print_status "success" "Retry logic implemented"
else
print_status "warning" "No retry logic found"
fi
# 10. Security Check
echo ""
echo "π Basic Security Check..."
if grep -r "v-html" src/ > /dev/null 2>&1; then
print_status "warning" "v-html found - ensure content is sanitized"
grep -r "v-html" src/ | head -3
else
print_status "success" "No unsafe v-html usage found"
fi
if grep -r "eval\|innerHTML\|outerHTML" src/ > /dev/null 2>&1; then
print_status "warning" "Potentially unsafe JavaScript found"
else
print_status "success" "No obviously unsafe JavaScript patterns found"
fi
# Final Summary
echo ""
echo "π Validation Summary"
echo "===================="
print_status "info" "Project: $PROJECT_NAME"
print_status "info" "Node.js: $(node --version 2>/dev/null || echo 'Not available')"
print_status "info" "npm: $(npm --version 2>/dev/null || echo 'Not available')"
if [ -f "dist/index.html" ]; then
print_status "success" "β
Build Ready - Project can be deployed"
else
print_status "error" "β Build Issues - Fix errors before deployment"
fi
echo ""
print_status "info" "π― Tarzan email-powered blogging platform validation complete!"
echo ""
# Optional: Open preview if available
if command -v npm &> /dev/null && npm run preview --help &> /dev/null; then
echo "To preview the built application, run:"
echo " npm run preview"
echo ""
fi
echo "To start development server, run:"
echo " npm start"
echo ""