diff --git a/.husky/pre-push b/.husky/pre-push index 308ffc2..476d6ae 100755 --- a/.husky/pre-push +++ b/.husky/pre-push @@ -1,3 +1,10 @@ +# Validate Directus SDK imports before push +# This prevents runtime crashes caused by importing non-existent exports +SCRIPT_DIR="$(cd "$(dirname "$0")/.." && pwd)" +if [ -f "$SCRIPT_DIR/scripts/validate-sdk-imports.sh" ]; then + "$SCRIPT_DIR/scripts/validate-sdk-imports.sh" || exit 1 +fi + # Check if we are pushing a tag while read local_ref local_sha remote_ref remote_sha do diff --git a/packages/cms-infra/docker-compose.yml b/packages/cms-infra/docker-compose.yml index c7d74e1..d9d2686 100644 --- a/packages/cms-infra/docker-compose.yml +++ b/packages/cms-infra/docker-compose.yml @@ -1,6 +1,6 @@ services: infra-cms: - image: directus/directus:11 + image: directus/directus:11.15.2 ports: - "8059:8055" networks: @@ -14,6 +14,7 @@ services: DB_CLIENT: "sqlite3" DB_FILENAME: "/directus/database/data.db" WEBSOCKETS_ENABLED: "true" + PUBLIC_URL: "http://cms.localhost" EMAIL_TRANSPORT: "smtp" EMAIL_SMTP_HOST: "smtp.eu.mailgun.org" EMAIL_SMTP_PORT: "587" @@ -21,19 +22,29 @@ services: EMAIL_SMTP_PASSWORD: "4592fcb94599ee1a45b4ac2386fd0a64-102c75d8-ca2870e6" EMAIL_SMTP_SECURE: "false" EMAIL_FROM: "postmaster@mg.mintel.me" + LOG_LEVEL: "debug" + SERVE_APP: "true" + EXTENSIONS_AUTO_RELOAD: "true" volumes: - ./database:/directus/database - ./uploads:/directus/uploads - ./schema:/directus/schema - ./extensions:/directus/extensions + healthcheck: + test: [ "CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://127.0.0.1:8055/server/health" ] + interval: 10s + timeout: 5s + retries: 5 + labels: - "traefik.enable=true" - - "traefik.http.routers.infra-cms.rule=Host(`cms.localhost`)" - - "traefik.http.services.infra-cms.loadbalancer.server.port=8055" + - "traefik.http.routers.at-mintel-infra-cms.rule=Host(`cms.localhost`)" + - "traefik.http.services.at-mintel-infra-cms.loadbalancer.server.port=8055" + - "traefik.http.services.at-mintel-infra-cms.loadbalancer.healthcheck.path=/server/health" - "traefik.docker.network=infra" networks: default: - name: mintel-infra-cms-internal + name: at-mintel-cms-network infra: external: true diff --git a/packages/cms-infra/extensions/unified-dashboard/src/module.vue b/packages/cms-infra/extensions/unified-dashboard/src/module.vue new file mode 100644 index 0000000..830419a --- /dev/null +++ b/packages/cms-infra/extensions/unified-dashboard/src/module.vue @@ -0,0 +1,141 @@ + + + + + Infrastructure Stack + Zentrale Schnittstelle für Firmen, Personen und Leads. + + + + + + + Firmen + {{ stats.companies }} + + + + + + + + Personen + {{ stats.people }} + + + + + + + + Leads + {{ stats.leads }} + + + + + + + Schnellzugriff + + + + Neue Person anlegen + + + + Neuen Lead registrieren + + + + + + + + + + diff --git a/packages/unified-dashboard/src/module.vue b/packages/unified-dashboard/src/module.vue new file mode 100644 index 0000000..830419a --- /dev/null +++ b/packages/unified-dashboard/src/module.vue @@ -0,0 +1,141 @@ + + + + + Infrastructure Stack + Zentrale Schnittstelle für Firmen, Personen und Leads. + + + + + + + Firmen + {{ stats.companies }} + + + + + + + + Personen + {{ stats.people }} + + + + + + + + Leads + {{ stats.leads }} + + + + + + + Schnellzugriff + + + + Neue Person anlegen + + + + Neuen Lead registrieren + + + + + + + + + + diff --git a/scripts/validate-sdk-imports.sh b/scripts/validate-sdk-imports.sh new file mode 100755 index 0000000..f5bb153 --- /dev/null +++ b/scripts/validate-sdk-imports.sh @@ -0,0 +1,100 @@ +#!/bin/bash +# validate-sdk-imports.sh +# Validates that Directus extensions only use exports that exist in @directus/extensions-sdk. +# Prevents the "SyntaxError: doesn't provide an export named" runtime crash +# that silently breaks ALL extensions in the browser. + +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" + +# Valid exports from @directus/extensions-sdk in Directus 11.x +# If Directus is upgraded, update this list by running: +# curl -s http://cms.localhost/admin/assets/@directus_extensions-sdk.*.entry.js | grep -oE 'export\{[^}]+\}' +VALID_EXPORTS=( + "defineDisplay" + "defineEndpoint" + "defineHook" + "defineInterface" + "defineLayout" + "defineModule" + "defineOperationApi" + "defineOperationApp" + "definePanel" + "defineTheme" + "getFieldsFromTemplate" + "getRelationType" + "useApi" + "useCollection" + "useExtensions" + "useFilterFields" + "useItems" + "useLayout" + "useSdk" + "useStores" + "useSync" +) + +ERRORS=0 + +echo "🔍 Validating @directus/extensions-sdk imports..." +echo "" + +# Search all .ts and .vue files in extension directories +SEARCH_DIRS=( + "$REPO_ROOT/packages/cms-infra/extensions" + "$REPO_ROOT/packages/unified-dashboard" + "$REPO_ROOT/packages/customer-manager" + "$REPO_ROOT/packages/company-manager" + "$REPO_ROOT/packages/people-manager" + "$REPO_ROOT/packages/acquisition-manager" + "$REPO_ROOT/packages/feedback-commander" +) + +for DIR in "${SEARCH_DIRS[@]}"; do + [ -d "$DIR" ] || continue + + # Find all imports from @directus/extensions-sdk + while IFS= read -r line; do + FILE=$(echo "$line" | cut -d: -f1) + LINENUM=$(echo "$line" | cut -d: -f2) + CONTENT=$(echo "$line" | cut -d: -f3-) + + # Extract imported names from the import statement + IMPORTS=$(echo "$CONTENT" | grep -oE '\{[^}]+\}' | tr -d '{}' | tr ',' '\n' | sed 's/^ *//;s/ *$//' | sed 's/ as .*//') + + for IMPORT in $IMPORTS; do + [ -z "$IMPORT" ] && continue + FOUND=false + for VALID in "${VALID_EXPORTS[@]}"; do + if [ "$IMPORT" = "$VALID" ]; then + FOUND=true + break + fi + done + + if [ "$FOUND" = false ]; then + echo "❌ INVALID IMPORT: '$IMPORT' in $FILE:$LINENUM" + echo " '$IMPORT' is NOT exported by @directus/extensions-sdk in Directus 11.x" + echo " This WILL crash ALL extensions at runtime!" + echo "" + ERRORS=$((ERRORS + 1)) + fi + done + done < <(grep -rn "from ['\"]@directus/extensions-sdk['\"]" "$DIR" --include="*.ts" --include="*.vue" 2>/dev/null || true) +done + +if [ "$ERRORS" -gt 0 ]; then + echo "💥 Found $ERRORS invalid import(s)!" + echo "" + echo "Valid exports from @directus/extensions-sdk:" + printf " %s\n" "${VALID_EXPORTS[@]}" + echo "" + echo "Common fixes:" + echo " useRouter → import { useRouter } from 'vue-router'" + echo " useRoute → import { useRoute } from 'vue-router'" + exit 1 +else + echo "✅ All @directus/extensions-sdk imports are valid." +fi
Zentrale Schnittstelle für Firmen, Personen und Leads.