39 lines
884 B
Bash
39 lines
884 B
Bash
|
|
#!/bin/bash
|
||
|
|
set -e
|
||
|
|
|
||
|
|
REPO_ROOT=$(git rev-parse --show-toplevel)
|
||
|
|
BACKEND_DIR="$REPO_ROOT/veza-backend-api"
|
||
|
|
CORE_DIR="internal/core"
|
||
|
|
|
||
|
|
echo "📍 Backend Core Isolation Check"
|
||
|
|
|
||
|
|
cd "$BACKEND_DIR"
|
||
|
|
|
||
|
|
if [ ! -d "$CORE_DIR" ]; then
|
||
|
|
echo "⚠️ $CORE_DIR does not exist. Skipping."
|
||
|
|
exit 0
|
||
|
|
fi
|
||
|
|
|
||
|
|
echo "🔎 Analyzing dependencies of $CORE_DIR..."
|
||
|
|
|
||
|
|
# List all imports of packages in internal/core
|
||
|
|
IMPORTS=$(go list -f '{{.Imports}}' ./$CORE_DIR/...)
|
||
|
|
|
||
|
|
# Check for forbidden packages
|
||
|
|
FORBIDDEN="database/sql github.com/lib/pq github.com/jackc/pgx"
|
||
|
|
|
||
|
|
FAILED=0
|
||
|
|
for PKG in $FORBIDDEN; do
|
||
|
|
if echo "$IMPORTS" | grep -q "$PKG"; then
|
||
|
|
echo "❌ Violation: $CORE_DIR depends on $PKG"
|
||
|
|
FAILED=1
|
||
|
|
fi
|
||
|
|
done
|
||
|
|
|
||
|
|
if [ $FAILED -eq 1 ]; then
|
||
|
|
echo "❌ Core isolation check FAILED. Core domain logic must not be coupled to DB drivers."
|
||
|
|
exit 1
|
||
|
|
fi
|
||
|
|
|
||
|
|
echo "✅ Core isolation verified."
|