Refactor code structure for improved readability and maintainability
This commit is contained in:
224
custom/docs/tools/E2E_TESTS_README.md
Normal file
224
custom/docs/tools/E2E_TESTS_README.md
Normal file
@@ -0,0 +1,224 @@
|
||||
# EspoCRM E2E Test Suite
|
||||
|
||||
Automatisierte End-to-End Tests für Custom EspoCRM Entities.
|
||||
|
||||
## Überblick
|
||||
|
||||
Das Test-Framework führt automatisiert folgende Tests durch:
|
||||
|
||||
### ✅ CRUD-Operationen
|
||||
- **Create**: Erstellen von Testdatensätzen für alle Custom Entities
|
||||
- **Read**: Validierung der erstellten Datensätze
|
||||
- **Update**: Änderung von Feldern
|
||||
- **Delete**: Löschen der Test-Daten
|
||||
|
||||
### 🔗 Relationship-Tests
|
||||
- **Link**: Verknüpfung von Entities über Relationships
|
||||
- **Unlink**: Entfernung von Verknüpfungen
|
||||
- **Verification**: Prüfung der korrekten Verknüpfung
|
||||
|
||||
## Getestete Entities
|
||||
|
||||
1. **CMietobjekt** - Mietobjekte (Wohnungen, Häuser, etc.)
|
||||
2. **CVmhMietverhältnis** - Mietverhältnisse
|
||||
3. **CKündigung** - Kündigungen
|
||||
4. **CBeteiligte** - Beteiligte Personen (Mieter, Vermieter)
|
||||
5. **CMietinkasso** - Mietinkasso-Verfahren
|
||||
6. **CVmhRäumungsklage** - Räumungsklagen
|
||||
|
||||
## Getestete Relationships
|
||||
|
||||
- CVmhMietverhältnis ↔ CMietobjekt
|
||||
- CKündigung ↔ CVmhMietverhältnis
|
||||
- CBeteiligte ↔ CVmhMietverhältnis (als Mieter/Vermieter)
|
||||
|
||||
## Installation
|
||||
|
||||
### Voraussetzungen
|
||||
|
||||
- Python 3.6+
|
||||
- `requests` Bibliothek
|
||||
|
||||
```bash
|
||||
pip3 install requests
|
||||
```
|
||||
|
||||
## Verwendung
|
||||
|
||||
### Schnellstart
|
||||
|
||||
```bash
|
||||
./run_e2e_tests.sh
|
||||
```
|
||||
|
||||
### Direkte Python-Ausführung
|
||||
|
||||
```bash
|
||||
python3 e2e_tests.py
|
||||
```
|
||||
|
||||
## Konfiguration
|
||||
|
||||
Die Konfiguration erfolgt in [e2e_tests.py](e2e_tests.py#L20-L25):
|
||||
|
||||
```python
|
||||
CONFIG = {
|
||||
'base_url': 'https://crm.bitbylaw.com',
|
||||
'api_key': '2b0747ca34d15032aa233ae043cc61bc',
|
||||
'username': 'dev-test'
|
||||
}
|
||||
```
|
||||
|
||||
## Ausgabe
|
||||
|
||||
Das Framework generiert eine detaillierte Testübersicht:
|
||||
|
||||
```
|
||||
================================================================================
|
||||
TEST SUMMARY
|
||||
================================================================================
|
||||
|
||||
✅ CMietobjekt: 4/4 tests passed
|
||||
✓ create 0.234s
|
||||
✓ read 0.123s
|
||||
✓ update 0.156s
|
||||
✓ delete 0.089s
|
||||
|
||||
✅ CVmhMietverhltnis: 4/4 tests passed
|
||||
✓ create 0.267s
|
||||
✓ read 0.134s
|
||||
✓ update 0.178s
|
||||
✓ delete 0.092s
|
||||
|
||||
================================================================================
|
||||
Total: 24/24 tests passed (0 failed)
|
||||
Time: 3.45s
|
||||
================================================================================
|
||||
```
|
||||
|
||||
## Architektur
|
||||
|
||||
### Komponenten
|
||||
|
||||
#### 1. **espocrm_api_client.py**
|
||||
API-Client für EspoCRM REST API mit folgenden Features:
|
||||
- CRUD-Operationen (Create, Read, Update, Delete)
|
||||
- Relationship-Management (Link, Unlink)
|
||||
- Fehlerbehandlung und Logging
|
||||
|
||||
#### 2. **e2e_tests.py**
|
||||
Haupttest-Framework mit:
|
||||
- `EntityTestBase`: Basis-Klasse für Entity-Tests
|
||||
- Spezifische Test-Klassen für jede Entity
|
||||
- `TestTracker`: Ergebnis-Tracking und Reporting
|
||||
- Automatisches Cleanup
|
||||
|
||||
#### 3. **run_e2e_tests.sh**
|
||||
Shell-Wrapper mit:
|
||||
- Dependency-Checks
|
||||
- Farbiger Ausgabe
|
||||
- Exit-Code-Handling
|
||||
|
||||
## Erweiterung
|
||||
|
||||
### Neue Entity hinzufügen
|
||||
|
||||
1. Neue Test-Klasse erstellen:
|
||||
|
||||
```python
|
||||
class CMyEntityTest(EntityTestBase):
|
||||
def __init__(self, client: EspoCRMAPIClient, tracker: TestTracker):
|
||||
super().__init__(client, tracker)
|
||||
self.entity_type = 'CMyEntity'
|
||||
|
||||
def run_full_test(self) -> Optional[str]:
|
||||
# Create
|
||||
data = {
|
||||
'name': f'Test Entity {datetime.now().strftime("%Y%m%d_%H%M%S")}',
|
||||
# ... weitere Felder
|
||||
}
|
||||
|
||||
record_id = self.test_create(data)
|
||||
if not record_id:
|
||||
return None
|
||||
|
||||
# Read
|
||||
self.test_read(record_id)
|
||||
|
||||
# Update
|
||||
self.test_update(record_id, {'field': 'new_value'})
|
||||
|
||||
return record_id
|
||||
```
|
||||
|
||||
2. Test in `run_all_tests()` einbinden:
|
||||
|
||||
```python
|
||||
print("\n🔷 Testing CMyEntity...")
|
||||
myentity_test = CMyEntityTest(client, tracker)
|
||||
myentity_id = myentity_test.run_full_test()
|
||||
```
|
||||
|
||||
3. Cleanup-Order anpassen falls Dependencies bestehen
|
||||
|
||||
### Neue Relationships testen
|
||||
|
||||
```python
|
||||
# Link testen
|
||||
entity_test.test_link(
|
||||
record_id='123',
|
||||
link_name='relationshipName',
|
||||
foreign_id='456'
|
||||
)
|
||||
|
||||
# Unlink testen
|
||||
entity_test.test_unlink(
|
||||
record_id='123',
|
||||
link_name='relationshipName',
|
||||
foreign_id='456'
|
||||
)
|
||||
```
|
||||
|
||||
## Fehlerbehebung
|
||||
|
||||
### Connection Fehler
|
||||
|
||||
```
|
||||
❌ Connection failed: HTTPError 401
|
||||
```
|
||||
→ API-Key oder Username prüfen
|
||||
|
||||
### Entity nicht gefunden
|
||||
|
||||
```
|
||||
❌ API Error: POST https://crm.bitbylaw.com/api/v1/CMyEntity
|
||||
Status: 404
|
||||
```
|
||||
→ Entity-Name prüfen (z.B. `CKndigung` statt `CKuendigung`)
|
||||
|
||||
### Relationship nicht gefunden
|
||||
|
||||
```
|
||||
AssertionError: Link not found: xyz123
|
||||
```
|
||||
→ Relationship-Name und Richtung prüfen
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Immer cleanup durchführen**: Tests hinterlassen keine Datenreste
|
||||
2. **Eindeutige Namen**: Timestamps in Test-Daten-Namen
|
||||
3. **Dependencies beachten**: Lösch-Reihenfolge ist wichtig
|
||||
4. **Fehlerbehandlung**: Jeder Test ist isoliert
|
||||
|
||||
## Weitere Informationen
|
||||
|
||||
- [EspoCRM REST API Dokumentation](https://docs.espocrm.com/development/api/)
|
||||
- [Projektübersicht](KI_OVERVIEW_README.md)
|
||||
- [Validierungs-Tools](VALIDATION_TOOLS.md)
|
||||
|
||||
## Support
|
||||
|
||||
Bei Fragen oder Problemen:
|
||||
1. Logs prüfen: Test-Ausgabe enthält detaillierte Fehlermeldungen
|
||||
2. API-Dokumentation konsultieren
|
||||
3. Entity-Definitionen in `custom/Espo/Custom/Resources/metadata/entityDefs/` prüfen
|
||||
334
custom/docs/tools/KI_OVERVIEW_README.md
Normal file
334
custom/docs/tools/KI_OVERVIEW_README.md
Normal file
@@ -0,0 +1,334 @@
|
||||
# KI-Einstiegsscript für EspoCRM Projekt
|
||||
|
||||
## Übersicht
|
||||
|
||||
Das `ki_project_overview.py` Script bietet einen vollständigen, automatisch generierten Überblick über das EspoCRM-Projekt. Es ist speziell für KI-basierte Programmierung konzipiert und gibt alle relevanten Informationen aus, die für die Entwicklung benötigt werden.
|
||||
|
||||
## Zweck
|
||||
|
||||
**Ziel:** Die KI erhält einen aktuellen, umfassenden Informationsstand über das Projekt, ohne manuell verschiedene Dateien durchsuchen zu müssen.
|
||||
|
||||
Das Script analysiert automatisch:
|
||||
- ✅ Alle Custom Entitäten und ihre Felder
|
||||
- ✅ Beziehungen zwischen Entitäten (Relationship-Graph)
|
||||
- ✅ Custom PHP Klassen (Formula-Funktionen, Services, etc.)
|
||||
- ✅ Workflows und deren Status
|
||||
- ✅ Frontend-Anpassungen (JavaScript, CSS)
|
||||
- ✅ Custom Layouts
|
||||
- ✅ Internationalisierung (i18n)
|
||||
- ✅ README.md Dokumentation
|
||||
|
||||
## Verwendung
|
||||
|
||||
### Einfach ausführen
|
||||
|
||||
```bash
|
||||
# Im EspoCRM Root-Verzeichnis
|
||||
python3 custom/scripts/ki_project_overview.py
|
||||
```
|
||||
|
||||
### Ausgabe in Datei speichern
|
||||
|
||||
```bash
|
||||
# Für detaillierte Analyse später
|
||||
python3 custom/scripts/ki_project_overview.py > /tmp/project-overview.txt
|
||||
```
|
||||
|
||||
### Ausgabe an KI übergeben
|
||||
|
||||
Das Script ist so konzipiert, dass die Ausgabe direkt an eine KI übergeben werden kann. Die KI erhält damit:
|
||||
|
||||
1. **Schnellübersicht** - Projekt-Statistiken auf einen Blick
|
||||
2. **README.md** - Vollständige Projektdokumentation
|
||||
3. **Entitäten-Analyse** - Alle Custom Entities mit Feldern und Beziehungen
|
||||
4. **Beziehungsgraph** - Wie Entitäten miteinander verbunden sind
|
||||
5. **Custom Code** - PHP Klassen, JavaScript, CSS
|
||||
6. **Workflows** - Aktive und inaktive Workflows
|
||||
7. **Internationalisierung** - Unterstützte Sprachen
|
||||
|
||||
## Ausgabeformat
|
||||
|
||||
Das Script gibt strukturierte, lesbare Ausgaben mit verschiedenen Abschnitten:
|
||||
|
||||
```
|
||||
================================================================================
|
||||
SCHNELLÜBERSICHT
|
||||
================================================================================
|
||||
|
||||
📊 Projekt-Statistiken:
|
||||
|
||||
• Entities 21
|
||||
• PHP Classes 1
|
||||
• Workflows 1
|
||||
• JavaScript Files 10
|
||||
...
|
||||
|
||||
================================================================================
|
||||
ENTITÄTEN ANALYSE
|
||||
================================================================================
|
||||
|
||||
────────────────────────────────────────────────────────────────────────────────
|
||||
► Entität: CMietobjekt
|
||||
────────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
📋 Scope:
|
||||
• entity: CMietobjekt
|
||||
• acl: True
|
||||
• stream: False
|
||||
...
|
||||
|
||||
🔧 Felder (15):
|
||||
• name: varchar [REQUIRED] [CUSTOM]
|
||||
• adresse: link → CAdressen
|
||||
• miete: currency (€)
|
||||
...
|
||||
|
||||
🔗 Beziehungen (8):
|
||||
• mietverhltnisse [hasMany] → CVmhMietverhltnis.mietobjekt
|
||||
• kontakte [hasMany] → Contact.mietobjekte
|
||||
...
|
||||
|
||||
⚡ Formula Scripts:
|
||||
• beforeSaveApiScript: 25 Zeilen
|
||||
```
|
||||
|
||||
## Was wird analysiert?
|
||||
|
||||
### 1. Entitäten (entityDefs)
|
||||
|
||||
Für jede Custom Entity:
|
||||
- Alle Felder mit Typ, Optionen, Constraints
|
||||
- Alle Beziehungen (Links) zu anderen Entities
|
||||
- Formula Scripts (beforeSave, afterSave, etc.)
|
||||
- Scope-Konfiguration (ACL, Stream, Portal-Access)
|
||||
|
||||
### 2. Beziehungsgraph
|
||||
|
||||
Visualisiert alle Beziehungen zwischen Entities:
|
||||
- hasMany, belongsTo, hasOne, manyToMany
|
||||
- Bidirektionale Links mit relationName
|
||||
- Foreign Keys
|
||||
|
||||
### 3. Custom PHP Klassen
|
||||
|
||||
Alle PHP-Dateien in `custom/Espo/Custom/Classes/`:
|
||||
- FormulaFunctions
|
||||
- Services
|
||||
- Controllers
|
||||
- Hooks
|
||||
- Etc.
|
||||
|
||||
### 4. Workflows
|
||||
|
||||
Alle Workflows in `custom/workflows/`:
|
||||
- Name und Status (aktiv/inaktiv)
|
||||
- Trigger-Typ
|
||||
- Entity-Zuordnung
|
||||
- Anzahl der Aktionen
|
||||
|
||||
### 5. Frontend
|
||||
|
||||
- **JavaScript:** Alle Custom Views und Module
|
||||
- **CSS:** Registrierte Stylesheets
|
||||
- **App Config:** cssList, scriptList aus client.json
|
||||
|
||||
### 6. Layouts
|
||||
|
||||
Custom Layouts für jede Entity:
|
||||
- detail, list, detailSmall, listSmall
|
||||
- bottomPanelsDetail, sidePanelsDetail
|
||||
- Etc.
|
||||
|
||||
### 7. Internationalisierung
|
||||
|
||||
- Unterstützte Sprachen
|
||||
- Anzahl Übersetzungsdateien pro Sprache
|
||||
- Geschätzte Anzahl Labels
|
||||
|
||||
## Typische Anwendungsfälle
|
||||
|
||||
### Fall 1: Neue Programmieraufgabe
|
||||
```bash
|
||||
# KI erhält vollständigen Projekt-Kontext
|
||||
python3 custom/scripts/ki_project_overview.py
|
||||
```
|
||||
|
||||
Die KI kann dann direkt auf Basis der Ausgabe arbeiten, ohne weitere Dateien lesen zu müssen.
|
||||
|
||||
### Fall 2: Beziehungen verstehen
|
||||
Das Script zeigt automatisch alle Beziehungen zwischen Entities und hilft, Abhängigkeiten zu verstehen.
|
||||
|
||||
### Fall 3: Vollständigkeitsprüfung
|
||||
Schnell erkennen, ob alle erwarteten Entities, Felder und Beziehungen vorhanden sind.
|
||||
|
||||
## Integration mit validate_and_rebuild.py
|
||||
|
||||
Das KI-Einstiegsscript ist als Ergänzung zum `validate_and_rebuild.py` Script konzipiert:
|
||||
|
||||
1. **ki_project_overview.py** → Informationen sammeln, Kontext für KI bereitstellen
|
||||
2. **validate_and_rebuild.py** → Änderungen validieren und anwenden
|
||||
|
||||
### Typischer Workflow
|
||||
|
||||
```bash
|
||||
# 1. Projekt-Übersicht für KI
|
||||
python3 custom/scripts/ki_project_overview.py
|
||||
|
||||
# 2. KI macht Änderungen an JSON-Dateien
|
||||
# (Basierend auf der Übersicht)
|
||||
|
||||
# 3. Validieren und Rebuild
|
||||
python3 custom/scripts/validate_and_rebuild.py
|
||||
```
|
||||
|
||||
## Technische Details
|
||||
|
||||
### Dateisystem-Struktur
|
||||
|
||||
Das Script erwartet folgende Struktur:
|
||||
```
|
||||
/var/lib/docker/volumes/vmh-espocrm_espocrm/_data/
|
||||
├── README.md
|
||||
├── custom/
|
||||
│ ├── Espo/
|
||||
│ │ └── Custom/
|
||||
│ │ ├── Classes/
|
||||
│ │ └── Resources/
|
||||
│ │ ├── metadata/
|
||||
│ │ │ ├── entityDefs/
|
||||
│ │ │ ├── scopes/
|
||||
│ │ │ ├── formula/
|
||||
│ │ │ ├── layouts/
|
||||
│ │ │ └── ...
|
||||
│ │ └── i18n/
|
||||
│ ├── scripts/
|
||||
│ └── workflows/
|
||||
└── client/
|
||||
└── custom/
|
||||
├── src/
|
||||
└── css/
|
||||
```
|
||||
|
||||
### Performance
|
||||
|
||||
- Analysiert ~20 Entities in <1 Sekunde
|
||||
- JSON-Parsing mit Error-Handling
|
||||
- Effiziente Rekursion durch Dateisystem
|
||||
|
||||
### Error-Handling
|
||||
|
||||
- Fehlerhafte JSON-Dateien werden übersprungen mit Fehlermeldung
|
||||
- Fehlende Verzeichnisse führen zu Info-Meldungen, nicht zu Abbruch
|
||||
- Robuste Exception-Behandlung
|
||||
|
||||
## Ausgabe-Sektionen im Detail
|
||||
|
||||
### 1. SCHNELLÜBERSICHT
|
||||
Kompakte Statistiken für schnellen Überblick
|
||||
|
||||
### 2. README.md
|
||||
Vollständiger Inhalt der Projektdokumentation
|
||||
|
||||
### 3. ENTITÄTEN ANALYSE
|
||||
Detaillierte Analyse jeder Custom Entity:
|
||||
- Scope (ACL, Stream, Portal, etc.)
|
||||
- Felder (Typ, Constraints, Optionen)
|
||||
- Beziehungen (Links zu anderen Entities)
|
||||
- Formula Scripts
|
||||
|
||||
### 4. BEZIEHUNGSGRAPH
|
||||
Visualisierung aller Entity-Beziehungen
|
||||
|
||||
### 5. CUSTOM LAYOUTS
|
||||
Übersicht über angepasste Layouts
|
||||
|
||||
### 6. CUSTOM PHP KLASSEN
|
||||
Alle PHP-Dateien gruppiert nach Typ
|
||||
|
||||
### 7. WORKFLOWS
|
||||
Status und Konfiguration aller Workflows
|
||||
|
||||
### 8. FRONTEND ANPASSUNGEN
|
||||
JavaScript, CSS und App-Konfiguration
|
||||
|
||||
### 9. INTERNATIONALISIERUNG
|
||||
Unterstützte Sprachen und Labels
|
||||
|
||||
## Erweiterungen
|
||||
|
||||
Das Script kann leicht erweitert werden:
|
||||
|
||||
### Neue Analyse-Funktion hinzufügen
|
||||
|
||||
```python
|
||||
def analyze_new_feature():
|
||||
"""Analysiert neues Feature."""
|
||||
print_section("NEUES FEATURE", "=")
|
||||
|
||||
# Implementierung
|
||||
...
|
||||
|
||||
# In main() Funktion aufrufen
|
||||
def main():
|
||||
...
|
||||
analyze_new_feature()
|
||||
...
|
||||
```
|
||||
|
||||
### Ausgabeformat ändern
|
||||
|
||||
Die Ausgabe kann angepasst werden:
|
||||
- JSON-Format für maschinelle Verarbeitung
|
||||
- Markdown für Dokumentation
|
||||
- HTML für Browser-Darstellung
|
||||
|
||||
## Best Practices
|
||||
|
||||
### Für KI-Integration
|
||||
|
||||
1. **Vollständige Ausgabe verwenden:** Nicht abschneiden, KI braucht alle Details
|
||||
2. **Regelmäßig aktualisieren:** Bei Projekt-Änderungen erneut ausführen
|
||||
3. **Mit README.md kombinieren:** Script gibt automatisch README aus
|
||||
|
||||
### Für Menschen
|
||||
|
||||
1. **Ausgabe in Datei speichern:** Für spätere Referenz
|
||||
2. **Abschnitte einzeln betrachten:** Ausgabe ist strukturiert und scrollbar
|
||||
3. **Mit grep filtern:** `python3 ... | grep "Entity:"`
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Problem: Script findet keine Entities
|
||||
|
||||
**Lösung:** Prüfe, ob `BASE_PATH` korrekt gesetzt ist:
|
||||
```python
|
||||
BASE_PATH = Path("/var/lib/docker/volumes/vmh-espocrm_espocrm/_data")
|
||||
```
|
||||
|
||||
### Problem: JSON Parse-Fehler
|
||||
|
||||
**Lösung:** Script gibt Fehler aus, aber läuft weiter. Prüfe betroffene Datei mit:
|
||||
```bash
|
||||
python3 -m json.tool < file.json
|
||||
```
|
||||
|
||||
### Problem: Keine README.md Ausgabe
|
||||
|
||||
**Lösung:** Prüfe ob `README.md` im Root-Verzeichnis existiert
|
||||
|
||||
## Siehe auch
|
||||
|
||||
- `/custom/CUSTOM_DIRECTORY.md` - Detaillierte Verzeichnisstruktur
|
||||
- `custom/scripts/validate_and_rebuild.py` - Validierung und Rebuild
|
||||
- `custom/scripts/VALIDATOR_README.md` - Validator-Dokumentation
|
||||
- `README.md` - Hauptdokumentation
|
||||
|
||||
## Lizenz
|
||||
|
||||
Teil des EspoCRM Custom Directory, gleiches Lizenzmodell wie Hauptprojekt.
|
||||
|
||||
---
|
||||
|
||||
**Erstellt:** Januar 2026
|
||||
**Autor:** Automatische KI-Integration
|
||||
**Version:** 1.0
|
||||
120
custom/docs/tools/QUICKSTART.md
Normal file
120
custom/docs/tools/QUICKSTART.md
Normal file
@@ -0,0 +1,120 @@
|
||||
# 🚀 EspoCRM Validator - Quick Start
|
||||
|
||||
## Installation bereits abgeschlossen ✅
|
||||
|
||||
Das Validierungs-Tool ist bereits installiert und einsatzbereit!
|
||||
|
||||
## Verwendung
|
||||
|
||||
```bash
|
||||
# Im EspoCRM-Root-Verzeichnis
|
||||
python3 custom/scripts/validate_and_rebuild.py
|
||||
```
|
||||
|
||||
Das war's! Das Script führt automatisch alle Checks durch und startet den Rebuild.
|
||||
|
||||
**Tipp:** Für nur Validierung ohne Rebuild: `python3 custom/scripts/validate_and_rebuild.py --dry-run`
|
||||
|
||||
## Was wird geprüft?
|
||||
|
||||
1. ✅ **JSON-Syntax** - Alle Custom-Dateien
|
||||
2. ✅ **Relationships** - Bidirektionale Link-Konsistenz
|
||||
3. ✅ **Formula-Scripts** - Korrekte Platzierung
|
||||
4. ✅ **i18n** - Vollständigkeit der Übersetzungen
|
||||
5. ✅ **Layouts** - Struktur-Validierung
|
||||
6. ✅ **Dateirechte** - Owner & Permissions
|
||||
7. ✅ **Rebuild** - Nur bei Fehlerfreiheit
|
||||
|
||||
## Output verstehen
|
||||
|
||||
| Symbol | Bedeutung | Aktion |
|
||||
|--------|-----------|--------|
|
||||
| ✓ Grün | OK | Keine |
|
||||
| ⚠ Gelb | Warnung | Optional beheben |
|
||||
| ✗ Rot | Fehler | **Muss behoben werden!** |
|
||||
|
||||
## Beispiel
|
||||
|
||||
```bash
|
||||
$ python3 custom/scripts/validate_and_rebuild.py
|
||||
|
||||
EspoCRM Custom Entity Validator & Rebuild Tool
|
||||
Arbeitsverzeichnis: /var/lib/docker/volumes/vmh-espocrm_espocrm/_data
|
||||
|
||||
======================================================================
|
||||
1. JSON-SYNTAX VALIDIERUNG
|
||||
======================================================================
|
||||
|
||||
✓ Alle 547 JSON-Dateien sind syntaktisch korrekt
|
||||
|
||||
======================================================================
|
||||
2. RELATIONSHIP-KONSISTENZ
|
||||
======================================================================
|
||||
|
||||
✗ 4 Relationship-Fehler gefunden:
|
||||
• CMietobjekt.vmhRumungsklages → CVmhRumungsklage:
|
||||
Foreign link 'mietobjekte' fehlt in CVmhRumungsklage
|
||||
...
|
||||
|
||||
✗ REBUILD ABGEBROCHEN: Kritische Fehler müssen behoben werden!
|
||||
```
|
||||
|
||||
## Häufige Fehler beheben
|
||||
|
||||
### Relationship-Fehler
|
||||
```json
|
||||
// In CVmhRumungsklage.json HINZUFÜGEN:
|
||||
{
|
||||
"links": {
|
||||
"mietobjekte": {
|
||||
"type": "hasMany",
|
||||
"entity": "CMietobjekt",
|
||||
"foreign": "vmhRumungsklages"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### JSON-Syntax-Fehler
|
||||
- Mit einem JSON-Validator prüfen (z.B. `python3 -m json.tool datei.json`)
|
||||
- Auf fehlende Kommata, geschweifte Klammern achten
|
||||
|
||||
### i18n-Warnung (optional)
|
||||
```json
|
||||
// In i18n/de_DE/Entity.json ERGÄNZEN:
|
||||
{
|
||||
"links": {
|
||||
"meinLink": "Mein Link"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Mehr Infos
|
||||
|
||||
- **Ausführliche Doku:** `custom/scripts/VALIDATOR_README.md`
|
||||
- **EspoCRM-Doku:** `README.md`
|
||||
- **Custom-Struktur:** `custom/CUSTOM_DIRECTORY.md`
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
**Python3 nicht gefunden?**
|
||||
```bash
|
||||
sudo apt-get install python3 # Ubuntu/Debian
|
||||
sudo yum install python3 # CentOS/RHEL
|
||||
```
|
||||
|
||||
**Keine Berechtigung?**
|
||||
```bash
|
||||
chmod +x custom/scripts/validate_and_rebuild.py
|
||||
```
|
||||
|
||||
**Script findet rebuild.php nicht?**
|
||||
```bash
|
||||
# Ins richtige Verzeichnis wechseln
|
||||
cd /var/lib/docker/volumes/vmh-espocrm_espocrm/_data
|
||||
python3 custom/scripts/validate_and_rebuild.py
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
**💡 Tipp:** Führe das Script nach **jeder** Änderung an Custom-Dateien aus!
|
||||
292
custom/docs/tools/VALIDATION_TOOLS.md
Normal file
292
custom/docs/tools/VALIDATION_TOOLS.md
Normal file
@@ -0,0 +1,292 @@
|
||||
# Validierungstools für EspoCRM Custom-Entwicklung
|
||||
|
||||
## Installierte Tools
|
||||
|
||||
### 1. PHP-CLI (v8.2.29)
|
||||
**Zweck:** Validierung von PHP-Syntax
|
||||
|
||||
**Installation:**
|
||||
```bash
|
||||
sudo apt install -y php-cli
|
||||
```
|
||||
|
||||
**Verwendung im Script:**
|
||||
```bash
|
||||
php -l /pfad/zur/datei.php
|
||||
```
|
||||
|
||||
**Validiert:**
|
||||
- PHP-Syntax-Fehler
|
||||
- Parse-Fehler
|
||||
- Fehlende Klammern/Semikolons
|
||||
- Ungültige Funktionsdeklarationen
|
||||
|
||||
---
|
||||
|
||||
### 2. CSSLint (v1.0.4)
|
||||
**Zweck:** CSS-Validierung und Best-Practice-Checks
|
||||
|
||||
**Installation:**
|
||||
```bash
|
||||
sudo apt install -y nodejs npm
|
||||
sudo npm install -g csslint
|
||||
```
|
||||
|
||||
**Verwendung im Script:**
|
||||
```bash
|
||||
csslint --format=compact --quiet /pfad/zur/datei.css
|
||||
```
|
||||
|
||||
**Validiert:**
|
||||
- CSS-Syntax-Fehler
|
||||
- Ungültige Properties
|
||||
- Vendor-Prefix-Probleme
|
||||
- Performance-Probleme
|
||||
- Kompatibilitätsprobleme
|
||||
|
||||
**Konfiguration:**
|
||||
Das Script verwendet standardmäßig alle csslint-Regeln. Für custom Rules kann eine `.csslintrc` Datei erstellt werden.
|
||||
|
||||
---
|
||||
|
||||
### 3. JSHint (v2.13.6)
|
||||
**Zweck:** JavaScript-Code-Qualität und Syntax-Validierung
|
||||
|
||||
**Installation:**
|
||||
```bash
|
||||
sudo npm install -g jshint
|
||||
```
|
||||
|
||||
**Verwendung im Script:**
|
||||
```bash
|
||||
jshint --config=/dev/null /pfad/zur/datei.js
|
||||
```
|
||||
|
||||
**Validiert:**
|
||||
- JavaScript-Syntax-Fehler
|
||||
- Potenzielle Bugs
|
||||
- Code-Style-Probleme
|
||||
- Ungültige Variablen-Deklarationen
|
||||
- Scope-Probleme
|
||||
|
||||
**Konfiguration:**
|
||||
Aktuell nutzt das Script minimale Konfiguration. Für erweiterte Checks kann eine `.jshintrc` Datei erstellt werden:
|
||||
|
||||
```json
|
||||
{
|
||||
"esversion": 6,
|
||||
"browser": true,
|
||||
"jquery": true,
|
||||
"unused": true,
|
||||
"undef": true
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Integration im Validierungsscript
|
||||
|
||||
Das Script `custom/scripts/validate_and_rebuild.py` nutzt diese Tools automatisch:
|
||||
|
||||
### Automatische Erkennung
|
||||
```python
|
||||
# Prüft ob Tool verfügbar ist
|
||||
try:
|
||||
subprocess.run(['csslint', '--version'], capture_output=True)
|
||||
use_csslint = True
|
||||
except FileNotFoundError:
|
||||
use_csslint = False
|
||||
# Fallback auf Basis-Validierung
|
||||
```
|
||||
|
||||
### Fallback-Mechanismus
|
||||
Falls ein Tool nicht verfügbar ist, verwendet das Script eine Basis-Validierung:
|
||||
|
||||
- **CSS:** Klammer-Matching, Attribut-Selektoren
|
||||
- **JavaScript:** Klammer-Matching (rund, eckig, geschweift)
|
||||
- **PHP:** Übersprungen mit Warnung
|
||||
|
||||
---
|
||||
|
||||
## Validierungsebenen
|
||||
|
||||
### Kritische Fehler (Rebuild wird abgebrochen)
|
||||
- JSON-Syntax-Fehler
|
||||
- PHP-Syntax-Fehler
|
||||
- CSS-Syntax-Fehler (schwerwiegend)
|
||||
- JavaScript-Syntax-Fehler
|
||||
- Fehlende Relationship-Definitionen
|
||||
|
||||
### Warnungen (Rebuild wird fortgesetzt)
|
||||
- CSS-Best-Practice-Verletzungen
|
||||
- Fehlende i18n-Übersetzungen
|
||||
- Code-Style-Probleme
|
||||
- Performance-Hinweise
|
||||
|
||||
---
|
||||
|
||||
## Manuelle Verwendung der Tools
|
||||
|
||||
### CSS prüfen
|
||||
```bash
|
||||
# Einzelne Datei
|
||||
csslint client/custom/css/my-styles.css
|
||||
|
||||
# Alle CSS-Dateien
|
||||
find client/custom/css -name "*.css" -exec csslint {} \;
|
||||
|
||||
# Mit spezifischen Regeln
|
||||
csslint --errors=errors,duplicate-properties client/custom/css/
|
||||
```
|
||||
|
||||
### JavaScript prüfen
|
||||
```bash
|
||||
# Einzelne Datei
|
||||
jshint client/custom/src/views/my-view.js
|
||||
|
||||
# Alle JS-Dateien
|
||||
find client/custom/src -name "*.js" -exec jshint {} \;
|
||||
|
||||
# Mit Konfiguration
|
||||
jshint --config .jshintrc client/custom/src/
|
||||
```
|
||||
|
||||
### PHP prüfen
|
||||
```bash
|
||||
# Einzelne Datei
|
||||
php -l custom/Espo/Custom/Classes/MyClass.php
|
||||
|
||||
# Alle PHP-Dateien
|
||||
find custom/Espo -name "*.php" -exec php -l {} \; | grep -v "No syntax errors"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Zusätzliche empfohlene Tools (optional)
|
||||
|
||||
### 1. ESLint (moderne Alternative zu JSHint)
|
||||
```bash
|
||||
sudo npm install -g eslint
|
||||
eslint --init # Erstellt .eslintrc Konfiguration
|
||||
```
|
||||
|
||||
### 2. Stylelint (moderne Alternative zu CSSLint)
|
||||
```bash
|
||||
sudo npm install -g stylelint stylelint-config-standard
|
||||
# Benötigt .stylelintrc Konfiguration
|
||||
```
|
||||
|
||||
### 3. PHPStan (statische PHP-Analyse)
|
||||
```bash
|
||||
composer require --dev phpstan/phpstan
|
||||
vendor/bin/phpstan analyse custom/Espo
|
||||
```
|
||||
|
||||
### 4. PHP_CodeSniffer (PHP Code-Style)
|
||||
```bash
|
||||
sudo apt install -y php-codesniffer
|
||||
phpcs --standard=PSR12 custom/Espo/
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Tool nicht gefunden
|
||||
```bash
|
||||
# Prüfe Installation
|
||||
which csslint
|
||||
which jshint
|
||||
which php
|
||||
|
||||
# Installiere fehlende Tools
|
||||
sudo apt update
|
||||
sudo apt install -y nodejs npm php-cli
|
||||
sudo npm install -g csslint jshint
|
||||
```
|
||||
|
||||
### Validierung zu streng
|
||||
Bearbeite das Script und passe die Tool-Parameter an:
|
||||
```python
|
||||
# Weniger strikte CSS-Validierung
|
||||
result = subprocess.run(
|
||||
['csslint', '--format=compact', '--errors=errors', str(css_file)],
|
||||
...
|
||||
)
|
||||
```
|
||||
|
||||
### Performance-Probleme
|
||||
Für große Projekte mit vielen Dateien:
|
||||
```python
|
||||
# Parallele Validierung mit ThreadPoolExecutor
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
|
||||
with ThreadPoolExecutor(max_workers=4) as executor:
|
||||
results = executor.map(validate_css_file, css_files)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Vor jedem Commit:** Führe Validierung aus
|
||||
```bash
|
||||
python3 custom/scripts/validate_and_rebuild.py --dry-run
|
||||
```
|
||||
|
||||
2. **Automatisierung:** Integriere in Git pre-commit hook
|
||||
```bash
|
||||
# .git/hooks/pre-commit
|
||||
#!/bin/bash
|
||||
python3 custom/scripts/validate_and_rebuild.py --dry-run
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Validierung fehlgeschlagen. Commit abgebrochen."
|
||||
exit 1
|
||||
fi
|
||||
```
|
||||
|
||||
3. **CI/CD Integration:** Nutze in Build-Pipeline
|
||||
```yaml
|
||||
# .gitlab-ci.yml / .github/workflows/
|
||||
validate:
|
||||
script:
|
||||
- python3 custom/scripts/validate_and_rebuild.py --dry-run
|
||||
```
|
||||
|
||||
4. **IDE Integration:** Konfiguriere Editor für Live-Feedback
|
||||
- VSCode: ESLint/Stylelint Extensions
|
||||
- PHPStorm: Built-in PHP/JS/CSS Validierung
|
||||
|
||||
---
|
||||
|
||||
## Maintenance
|
||||
|
||||
### Updates der Tools
|
||||
```bash
|
||||
# System-Packages
|
||||
sudo apt update && sudo apt upgrade
|
||||
|
||||
# NPM-Packages
|
||||
sudo npm update -g csslint jshint
|
||||
|
||||
# Prüfe Versionen
|
||||
php --version
|
||||
csslint --version
|
||||
jshint --version
|
||||
```
|
||||
|
||||
### Entfernung
|
||||
```bash
|
||||
# NPM-Tools
|
||||
sudo npm uninstall -g csslint jshint
|
||||
|
||||
# APT-Packages
|
||||
sudo apt remove php-cli nodejs npm
|
||||
sudo apt autoremove
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
**Letzte Aktualisierung:** Januar 2026
|
||||
**Maintainer:** Custom Scripts Team
|
||||
**Dokumentation:** `custom/scripts/VALIDATION_TOOLS.md`
|
||||
196
custom/docs/tools/VALIDATOR_README.md
Normal file
196
custom/docs/tools/VALIDATOR_README.md
Normal file
@@ -0,0 +1,196 @@
|
||||
# EspoCRM Validator & Rebuild Tool
|
||||
|
||||
## Übersicht
|
||||
|
||||
Das neue Python-basierte Validierungs-Tool `validate_and_rebuild.py` ersetzt das bisherige Bash-Script und bietet erweiterte Prüfungen für EspoCRM Custom-Entities.
|
||||
|
||||
## Features
|
||||
|
||||
### ✅ Automatische Validierungen
|
||||
|
||||
1. **JSON-Syntax-Prüfung**
|
||||
- Validiert alle `.json` Dateien im `custom/` Verzeichnis
|
||||
- Findet Syntax-Fehler mit Dateiname und Zeilennummer
|
||||
|
||||
2. **Relationship-Konsistenz**
|
||||
- Prüft bidirektionale Relationships (hasMany/hasOne)
|
||||
- Validiert `foreign`-Links zwischen Entities
|
||||
- Überprüft `relationName`-Konsistenz
|
||||
- Erkennt fehlende Gegenseiten-Definitionen
|
||||
|
||||
3. **Formula-Script Platzierung**
|
||||
- Prüft ob Formula-Scripts in `/formula/` statt `/entityDefs/` liegen
|
||||
- Warnt vor leeren Formula-Definitionen
|
||||
|
||||
4. **i18n-Vollständigkeit**
|
||||
- Findet fehlende Übersetzungen (de_DE / en_US)
|
||||
- Prüft Link-Labels für alle Custom-Relationships
|
||||
- Warnt bei komplett fehlenden i18n-Dateien
|
||||
|
||||
5. **Layout-Struktur**
|
||||
- Validiert clientDefs und bottomPanels
|
||||
- Findet unnötige `false`-Elemente
|
||||
|
||||
6. **Dateirechte** (✨ ERWEITERT)
|
||||
- Prüft Owner (www-data:www-data) in DREI Bereichen:
|
||||
- `custom/Espo/Custom/Resources/` - Custom Metadata
|
||||
- `client/custom/` - Frontend JavaScript & CSS
|
||||
- `data/` - **INKL. config.php & config-internal.php**
|
||||
- Korrigiert Permissions automatisch (664 für Dateien, 775 für Verzeichnisse)
|
||||
- **Hebt kritische System-Dateien hervor** (config.php, config-internal.php)
|
||||
|
||||
7. **CSS-Validierung**
|
||||
- Validiert Syntax aller CSS-Dateien
|
||||
- Prüft Klammer-Balance und grundlegende Struktur
|
||||
|
||||
8. **JavaScript-Validierung**
|
||||
- Prüft Syntax aller JS-Dateien in `client/custom/src/`
|
||||
|
||||
9. **PHP-Validierung**
|
||||
- Validiert PHP-Syntax aller Custom-Klassen
|
||||
|
||||
10. **Rebuild-Ausführung**
|
||||
- Führt `rebuild.php` nur aus, wenn keine kritischen Fehler vorliegen
|
||||
|
||||
## Verwendung
|
||||
|
||||
### Direkt ausführen
|
||||
```bash
|
||||
cd /path/to/espocrm
|
||||
python3 custom/scripts/validate_and_rebuild.py
|
||||
```
|
||||
|
||||
|
||||
|
||||
## Exit Codes
|
||||
|
||||
- `0` - Erfolg: Alle Validierungen bestanden, Rebuild erfolgreich
|
||||
- `1` - Fehler: Kritische Fehler gefunden oder Rebuild fehlgeschlagen
|
||||
|
||||
## Output-Format
|
||||
|
||||
Das Script verwendet farbcodierte Ausgaben:
|
||||
|
||||
- 🟢 **Grün (✓)**: Erfolgreich / OK
|
||||
- 🟡 **Gelb (⚠)**: Warnungen (nicht kritisch)
|
||||
- 🔴 **Rot (✗)**: Fehler (kritisch, Rebuild wird abgebrochen)
|
||||
- 🔵 **Blau (ℹ)**: Informationen
|
||||
|
||||
## Fehlertypen
|
||||
|
||||
### Kritische Fehler (Rebuild-Abbruch)
|
||||
- JSON-Syntax-Fehler
|
||||
- Fehlende Relationship-Definitionen
|
||||
- Falsch platzierte Formula-Scripts
|
||||
|
||||
### Warnungen (kein Abbruch)
|
||||
- Fehlende i18n-Übersetzungen
|
||||
- Layout-Strukturprobleme
|
||||
- Dateirechte-Probleme
|
||||
|
||||
## Beispiel-Output
|
||||
|
||||
```
|
||||
EspoCRM Custom Entity Validator & Rebuild Tool
|
||||
Arbeitsverzeichnis: /var/lib/docker/volumes/vmh-espocrm_espocrm/_data
|
||||
|
||||
======================================================================
|
||||
1. JSON-SYNTAX VALIDIERUNG
|
||||
======================================================================
|
||||
|
||||
✓ Alle 547 JSON-Dateien sind syntaktisch korrekt
|
||||
|
||||
======================================================================
|
||||
2. RELATIONSHIP-KONSISTENZ
|
||||
======================================================================
|
||||
|
||||
✗ 4 Relationship-Fehler gefunden:
|
||||
• Contact.cBankverbindungenContact: Ziel-Entity 'CBankverbindung' existiert nicht
|
||||
• CMietobjekt.vmhRumungsklages → CVmhRumungsklage: Foreign link 'mietobjekte' fehlt
|
||||
|
||||
======================================================================
|
||||
ZUSAMMENFASSUNG
|
||||
======================================================================
|
||||
|
||||
FEHLER: 4
|
||||
✗ Contact.cBankverbindungenContact: Ziel-Entity 'CBankverbindung' existiert nicht
|
||||
...
|
||||
|
||||
REBUILD ABGEBROCHEN: Kritische Fehler müssen behoben werden!
|
||||
```
|
||||
|
||||
## Erweiterung
|
||||
|
||||
Das Script ist modular aufgebaut. Neue Validierungen können einfach hinzugefügt werden:
|
||||
|
||||
```python
|
||||
def validate_custom_check(self) -> bool:
|
||||
"""Eigene Validierung."""
|
||||
print_header("X. CUSTOM CHECK")
|
||||
|
||||
# Prüflogik hier
|
||||
if error_found:
|
||||
self.errors.append("Fehlerbeschreibung")
|
||||
return False
|
||||
|
||||
print_success("Check erfolgreich")
|
||||
return True
|
||||
```
|
||||
|
||||
Dann in `validate_all()` hinzufügen:
|
||||
|
||||
```python
|
||||
if not self.validate_custom_check():
|
||||
all_valid = False
|
||||
```
|
||||
|
||||
## Anforderungen
|
||||
|
||||
- Python 3.6+
|
||||
- Keine zusätzlichen Packages erforderlich (nur Standard-Library)
|
||||
- Optionale sudo-Rechte für Dateirechte-Korrektur
|
||||
|
||||
## Integration in Workflow
|
||||
|
||||
Das Script kann in automatisierte Workflows integriert werden:
|
||||
|
||||
```bash
|
||||
# In CI/CD Pipeline
|
||||
python3 custom/scripts/validate_and_rebuild.py || exit 1
|
||||
|
||||
# Als Git Pre-Commit Hook
|
||||
#!/bin/bash
|
||||
python3 custom/scripts/validate_and_rebuild.py --dry-run
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Script findet rebuild.php nicht
|
||||
```bash
|
||||
# Stelle sicher, dass du im EspoCRM-Root bist
|
||||
cd /var/lib/docker/volumes/vmh-espocrm_espocrm/_data
|
||||
python3 custom/scripts/validate_and_rebuild.py
|
||||
```
|
||||
|
||||
### Dateirechte können nicht korrigiert werden
|
||||
```bash
|
||||
# Manuell mit sudo korrigieren
|
||||
sudo chown -R www-data:www-data custom/
|
||||
sudo find custom/ -type f -exec chmod 664 {} \;
|
||||
sudo find custom/ -type d -exec chmod 775 {} \;
|
||||
```
|
||||
|
||||
### Python3 nicht verfügbar
|
||||
```bash
|
||||
# Ubuntu/Debian
|
||||
sudo apt-get install python3
|
||||
|
||||
# CentOS/RHEL
|
||||
sudo yum install python3
|
||||
```
|
||||
|
||||
## Siehe auch
|
||||
|
||||
- [README.md](../../README.md) - Hauptdokumentation
|
||||
- [CUSTOM_DIRECTORY.md](../CUSTOM_DIRECTORY.md) - Custom-Verzeichnis-Struktur
|
||||
- [workflow_manager.php](workflow_manager.php) - Workflow-Management-Tool
|
||||
Reference in New Issue
Block a user