Conversation
- Replace project and token checks with direct property comparisons - Remove redundant methods for getting project and token - Update command signature and handle method for improved error handling - Enhance tests to reflect changes in method calls and command execution
…ration during setup
… with Linguist API
…tive setup and configuration management
There was a problem hiding this comment.
Pull request overview
Dieses PR modernisiert das Linguist-Connector-Package durch eine neue Action-/DTO-basierte Architektur und erweitert die DX um einen interaktiven Setup-Flow sowie ein überarbeitetes linguist:sync-Command.
Changes:
- Einführung eines
LinguistApiClientplus Actions fürpull,pushundsyncinkl. Orchestrierung (SetupOrchestrator) und Setup-Wizard (linguist:setup). - Neue DTOs (
SetupInput,SyncResult) und Anpassungen an Service Provider/Facade/Legacy-API. - Dokumentation und umfangreiche Test-Suite-Erweiterungen rund um die neuen Flows.
Reviewed changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 14 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Unit/Services/LinguistApiClientTest.php | Unit-Tests für Key-Counting/Fallback-Logik des API-Clients |
| tests/Unit/DTO/SyncResultTest.php | Unit-Tests für Ergebnis-/Summary-Logik des SyncResult DTO |
| tests/Unit/DTO/SetupInputTest.php | Unit-Tests für SetupInput DTO (Helper/Defaults/Serialisierung) |
| tests/Unit/Actions/PushTranslationsTest.php | Unit-Tests für Push-Action (Batching/Progress/Mapping) |
| tests/Unit/Actions/PullTranslationsTest.php | Unit-Tests für Pull-Action (Key-Counting/Files) |
| tests/Unit/Actions/PersistLinguistConfigTest.php | Unit-Tests für .env-Persistierung/Masking |
| tests/Unit/Actions/CollectLocalTranslationsTest.php | Unit-Tests für lokale Translation-Discovery/Flattening/Writing |
| tests/Pest.php | Pest-Setup + Test-Helper für HTTP/Filesystem |
| tests/LinguistTest.php | Anpassung Legacy-Tests auf neue Facade-Nutzung + Artisan-Tests |
| src/Services/SetupOrchestrator.php | Orchestriert Setup: persist config, resolve project, run sync, auto-translate |
| src/Services/LinguistApiClient.php | Neuer HTTP-Client für Linguist API inkl. Helper/Count/Mapping |
| src/LinguistServiceProvider.php | Registriert neue Commands/Services/Actions im Container |
| src/Linguist.php | Legacy-Klasse refaktoriert (Pooling, vereinfachte Config-Nutzung) |
| src/Facades/Linguist.php | Facade-Docblock an neue/entfernte Methoden angepasst |
| src/DTO/SyncResult.php | Neuer Ergebnis-DTO für Sync-/Pull-/Push-Flows |
| src/DTO/SetupInput.php | Neuer Eingabe-DTO für Setup-Wizard/Orchestrierung |
| src/Commands/LinguistSetupCommand.php | Neues interaktives Setup-Command (Prompts, Setup-Ausführung, Reporting) |
| src/Commands/LinguistCommand.php | Neues linguist:sync Command mit Modi/Optionen/Progress |
| src/Actions/SyncTranslations.php | Sync-Action (remote exports laden + local merge + write) |
| src/Actions/PushTranslations.php | Push-Action (batch store + fallback per key, Progress-Callback) |
| src/Actions/PullTranslations.php | Pull-Action (download exports, write linguist.json, key counts) |
| src/Actions/PersistLinguistConfig.php | Persistiert Token/URL/Project in .env + runtime config |
| src/Actions/CollectLocalTranslations.php | Discover/Parse/Flatten/Write lokaler Translation-Files |
| composer.json | Dependencies erweitert (laravel-actions) |
| README.md | Dokumentation für Setup-Wizard, Commands, Modes und Usage erweitert/aktualisiert |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
… SetupOrchestrator
3cc0825 to
e86fdcf
Compare
…and utility methods
…tus for Linguist commands
…rror reporting for missing search roots
…ushTranslationsTest
…rmal laravel standards
e86fdcf to
3c08372
Compare
…cumentation and tests
…d PushTranslations actions to reflect accurate counts
… selection to use lang keys instead of ids
28a883a to
00dea60
Compare
kaiserkiwi
left a comment
There was a problem hiding this comment.
Neben den angesprochenen Änderungen beim Pullen, noch zwei weitere Dinge als Code-Kommentare
| private function updateEnvValue(string $key, string $value): bool | ||
| { | ||
| $envPath = base_path('.env'); | ||
|
|
||
| if (! File::exists($envPath)) { | ||
| $examplePath = base_path('.env.example'); | ||
| if (File::exists($examplePath)) { | ||
| File::copy($examplePath, $envPath); | ||
| } else { | ||
| File::put($envPath, ''); | ||
| } | ||
| } | ||
|
|
||
| $content = File::get($envPath); | ||
| $escapedValue = $this->escapeEnvValue($value); | ||
| $pattern = '/^' . preg_quote($key, '/') . '=.*/m'; | ||
|
|
||
| if (preg_match($pattern, $content)) { | ||
| $content = preg_replace($pattern, "{$key}={$escapedValue}", $content); | ||
| } else { | ||
| $content .= "\n{$key}={$escapedValue}\n"; | ||
| } | ||
|
|
||
| return File::put($envPath, $content) !== false; | ||
| } |
There was a problem hiding this comment.
suggestion: Hier sollte vielleicht auch direkt noch geprüft werden, ob eine .env.example existiert, um die Daten auch dort hinzuzufügen.
| if (preg_match($pattern, $content)) { | ||
| $content = preg_replace($pattern, "{$key}={$escapedValue}", $content); | ||
| } else { | ||
| $content .= "\n{$key}={$escapedValue}\n"; |
|
Da mein Review nicht mehr requested wurde und auch kein Kommentar mehr kam: Wird hier noch dran gearbeitet oder kann ich schon wieder draufschauen? |
|
Ah my bad, ja bitte @kaiserkiwi |

Beschreibung:
Dieser PR aktualisiert das Linguist Connector Package auf ein moderneres Level.
Was wurde gemacht?
Das Packet an sich wurde aktualisiert (Dependencies). Zudem wurde die Projektstruktur aufgeräumt, sauber in Services und Actions unterteilt und anschließend erweitert.
Das aufsetzen des Paketes ist nun via einem einzigen Command möglich (
linguist:setup). Dabei werden alle nötigen Informationen abgefragt (API Key, zugehöriges Projekt, usw.). Zudem wurde ein Sprachdatei-Import Feature hinzugefügt. Bei Ersteinrichtungen kann das Package jetzt die bestehenden Sprachdateien Scannen und die Übersetzungs-Keys automatisch in Linguist anlegen. Man muss also nicht mehr manuell eine Datei nach der anderen hochladen.Der
syncCommand wurde ebenfalls erweitert. Entwickler müssen sich jetzt nicht mehr darum kümmern einen eigenen Command anzulegen sondern können einfach mitlinguist:syncdie Sprachdateien aktualisieren. Hier gibt es nun 3 Modi.sync: Es werden sowohl neue Sprachdateien hochgeladen als auch aktuelle Übersetzungen runtergeladenpull: Es werden aktuelle Übersetzungen runtergeladenpush: Es werden sowohl neue Sprachdateien hochgeladenWarum wurde es gemacht?
Bisher war die Integration von Linguist in Projekten sehr unregelmäßig. Entwickler mussten viele Schritte selbst machen wie einen Sync-Command anlegen. Das hat dazu geführt das bspw. jedes Projekt eine eigene Sync-Command-Signatur hat, was immer wieder zu Verwirrung führt.
Umgebung & Voraussetzungen:
Eine eingerichtete Projekt Entwicklungsumgebung.
Ablauf der Nachprüfung:
[Optional] Screenshots/Videos
[Optional] Weitere Hinweise:
[Optional] Sind nach dem Deployment Tasks auszuführen?