-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify.sh
More file actions
executable file
·77 lines (64 loc) · 2.54 KB
/
verify.sh
File metadata and controls
executable file
·77 lines (64 loc) · 2.54 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
#!/usr/bin/env bash
# Usage: ./verify.sh <test-dir> <platform>
# Example: ./verify.sh runs/claude-code-1 claude-code
DIR="${1:-.}"
PLATFORM="${2:-unknown}"
PASS=0
FAIL=0
RESULTS=()
check() {
local label="$1"
local result="$2"
if [ "$result" = "1" ]; then
RESULTS+=(" ✓ $label")
((PASS++))
else
RESULTS+=(" ✗ $label")
((FAIL++))
fi
}
# 1. package.json exists
check "package.json exists" "$([ -f "$DIR/package.json" ] && echo 1 || echo 0)"
# 2. Prisma 7 installed
PRISMA_VERSION=$(node -e "console.log(require('$(pwd)/$DIR/node_modules/prisma/package.json').version)" 2>/dev/null || node -e "console.log(require('$DIR/node_modules/prisma/package.json').version)" 2>/dev/null)
check "Prisma 7 installed" "$(echo "$PRISMA_VERSION" | grep -q '^7\.' && echo 1 || echo 0)"
# 3. schema.prisma exists
check "prisma/schema.prisma exists" "$([ -f "$DIR/prisma/schema.prisma" ] && echo 1 || echo 0)"
# 4. DATABASE_URL in .env
check "DATABASE_URL in .env" "$(grep -q 'DATABASE_URL' "$DIR/.env" 2>/dev/null && echo 1 || echo 0)"
# 5. At least one migration
check "Migration created" "$([ -d "$DIR/prisma/migrations" ] && [ "$(ls -A "$DIR/prisma/migrations" 2>/dev/null)" ] && echo 1 || echo 0)"
# 6. Prisma Client generated (check output path from schema.prisma)
PRISMA_OUTPUT=$(grep 'output' "$DIR/prisma/schema.prisma" 2>/dev/null | sed 's/.*output[[:space:]]*=[[:space:]]*"\([^"]*\)".*/\1/')
if [ -n "$PRISMA_OUTPUT" ]; then
GENERATED_DIR=$(cd "$DIR/prisma" && realpath "$PRISMA_OUTPUT" 2>/dev/null)
check "Prisma Client generated" "$([ -d "$GENERATED_DIR" ] && echo 1 || echo 0)"
else
check "Prisma Client generated" "0"
fi
# 7. App entry file exists
check "App entry file exists" "$([ -f "$DIR/src/index.ts" ] || [ -f "$DIR/index.ts" ] || [ -f "$DIR/src/index.js" ] || [ -f "$DIR/index.js" ] && echo 1 || echo 0)"
# 8. migrate status exits cleanly
cd "$DIR" && npx prisma migrate status --schema=prisma/schema.prisma > /dev/null 2>&1
check "prisma migrate status OK" "$([ $? -eq 0 ] && echo 1 || echo 0)"
# Summary
TOTAL=$((PASS + FAIL))
echo ""
echo "Platform: $PLATFORM"
echo "Result: $([ $FAIL -eq 0 ] && echo PASS || echo FAIL) ($PASS/$TOTAL checks)"
echo ""
for r in "${RESULTS[@]}"; do echo "$r"; done
echo ""
# Write JSON result
TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
mkdir -p "$(dirname "$0")/results"
cat > "$(dirname "$0")/results/${PLATFORM}-${TIMESTAMP//:/}.json" <<EOF
{
"platform": "$PLATFORM",
"timestamp": "$TIMESTAMP",
"passed": $PASS,
"total": $TOTAL,
"result": "$([ $FAIL -eq 0 ] && echo PASS || echo FAIL)"
}
EOF
exit $FAIL