Compare commits
34
Commits
+3
-56
@@ -107,28 +107,10 @@ Der Status ist **direkt auf der Projektkarte** umschaltbar, ohne den Detailberei
|
|||||||
- **Statusfilter** als Chips mit Trefferzähler, mehrere gleichzeitig kombinierbar.
|
- **Statusfilter** als Chips mit Trefferzähler, mehrere gleichzeitig kombinierbar.
|
||||||
- **Sortierung** nach zuletzt geändert, Anlagedatum, Name, Fortschritt oder Priorität —
|
- **Sortierung** nach zuletzt geändert, Anlagedatum, Name, Fortschritt oder Priorität —
|
||||||
Favoriten bleiben stets oben.
|
Favoriten bleiben stets oben.
|
||||||
- **Drei Ansichten**: freies Raster, nach Status gruppierte Abschnitte oder **Kanban**.
|
- **Zwei Ansichten**: freies Raster oder nach Status gruppierte Abschnitte.
|
||||||
- **Volltextsuche über Notizen.** Die Suche im Board arbeitet auf den geladenen Projekten
|
|
||||||
(Name, Kurzbeschreibung, Tags, Repo-Pfad). Notizen liegen dort nicht vor — sie
|
|
||||||
mitzuladen würde die Seite aufblähen. Stattdessen sucht Postgres serverseitig mit
|
|
||||||
seiner deutschen Textsuche, entprellt ab zwei Zeichen. Treffer erscheinen als eigene
|
|
||||||
Liste mit hervorgehobener Fundstelle, die betroffenen Projekte werden zusätzlich
|
|
||||||
eingeblendet. Deutsche Stammformen greifen: „Webhook" findet auch „Webhooks".
|
|
||||||
- **Archiv** ist standardmäßig ausgeblendet und per Schalter einblendbar.
|
- **Archiv** ist standardmäßig ausgeblendet und per Schalter einblendbar.
|
||||||
- **Leerzustände** mit direktem Einstieg statt einer leeren Fläche.
|
- **Leerzustände** mit direktem Einstieg statt einer leeren Fläche.
|
||||||
|
|
||||||
### Kanban
|
|
||||||
|
|
||||||
Spalten je Status, Karten per Ziehen verschiebbar. Der Wechsel wird sofort angezeigt und
|
|
||||||
erst danach gespeichert; scheitert das Speichern, springt die Karte zurück.
|
|
||||||
|
|
||||||
- Gezogen wird am Griff links, nicht an der ganzen Karte — so bleibt der Titel ein
|
|
||||||
normaler Link.
|
|
||||||
- Das Ziehen startet erst nach ein paar Pixeln Bewegung, damit Klicks weiter funktionieren.
|
|
||||||
Auf Touchgeräten nach kurzem Halten.
|
|
||||||
- Die Reihenfolge innerhalb einer Spalte folgt der gewählten Sortierung. Frei sortieren
|
|
||||||
ginge nur mit einer gespeicherten Position — bewusst nicht gebaut.
|
|
||||||
|
|
||||||
### Projektkarte auf einen Blick
|
### Projektkarte auf einen Blick
|
||||||
|
|
||||||
Name und Favoritenstern · Kurzbeschreibung · Fortschrittsbalken · Provider-Badge ·
|
Name und Favoritenstern · Kurzbeschreibung · Fortschrittsbalken · Provider-Badge ·
|
||||||
@@ -140,10 +122,6 @@ Anzahl Notizen · Warnung bei Sync-Fehler · Tags · Statusauswahl · Priorität
|
|||||||
## 3. Notizen
|
## 3. Notizen
|
||||||
|
|
||||||
- **Beliebig viele Notizen pro Projekt**, mit optionalem Titel und mehrzeiligem Text.
|
- **Beliebig viele Notizen pro Projekt**, mit optionalem Titel und mehrzeiligem Text.
|
||||||
- **Markdown wird dargestellt** — Überschriften, Listen, Tabellen, Codeblöcke, Zitate und
|
|
||||||
Links. Aus `- [ ] Aufgabe` werden echte Checklisten. Gilt auch für die Projekt-
|
|
||||||
beschreibung. Rohes HTML wird beim Rendern entfernt (`rehype-sanitize`) — der Inhalt
|
|
||||||
stammt vom Benutzer und wäre sonst ein XSS-Loch.
|
|
||||||
- **Anpinnen** — angepinnte Notizen stehen oben und sind farblich hervorgehoben.
|
- **Anpinnen** — angepinnte Notizen stehen oben und sind farblich hervorgehoben.
|
||||||
- **Bearbeiten und Löschen** direkt in der Liste; Löschen fragt nach.
|
- **Bearbeiten und Löschen** direkt in der Liste; Löschen fragt nach.
|
||||||
- **Zeitstempel**: Anlagedatum immer, „bearbeitet vor …" nur bei echter Änderung.
|
- **Zeitstempel**: Anlagedatum immer, „bearbeitet vor …" nur bei echter Änderung.
|
||||||
@@ -186,28 +164,12 @@ Firmen-Gitea nebeneinander.
|
|||||||
| --- | --- |
|
| --- | --- |
|
||||||
| Repository | Voller Pfad, Beschreibung, Default-Branch, Sichtbarkeit, Größe, letzte Aktivität |
|
| Repository | Voller Pfad, Beschreibung, Default-Branch, Sichtbarkeit, Größe, letzte Aktivität |
|
||||||
| Kennzahlen | Stars, Forks, offene Issues, offene Pull-/Merge-Requests |
|
| Kennzahlen | Stars, Forks, offene Issues, offene Pull-/Merge-Requests |
|
||||||
| **Pull-/Merge-Requests** | bis zu 50 offene, mit Nummer, Titel, Autor, Alter, Labels, Entwurfskennzeichnung und Link |
|
|
||||||
| **Issues** | bis zu 50 offene, gleiche Angaben. Bei GitHub und Gitea werden PRs herausgefiltert, die dort in derselben Liste stecken |
|
|
||||||
| **CI-Status** | Letzter Lauf auf dem Default-Branch: erfolgreich, fehlgeschlagen, läuft, wartet oder abgebrochen — mit Name und Link |
|
|
||||||
| Branches | bis zu 50, mit SHA, Default-Markierung, Schutzstatus und (wo die API es liefert) letztem Commit |
|
| Branches | bis zu 50, mit SHA, Default-Markierung, Schutzstatus und (wo die API es liefert) letztem Commit |
|
||||||
| Tags | bis zu 25, mit SHA, Nachricht und Datum |
|
| Tags | bis zu 25, mit SHA, Nachricht und Datum |
|
||||||
| Commits | die letzten 15 zur Anzeige; geholt werden 100 für die Aktivitätskurve |
|
| Commits | die letzten 15, mit Kurz-SHA, Nachricht, Autor, Datum und Link |
|
||||||
| **Commit-Aktivität** | Balkenreihe der letzten Tage, auf Karte und Projektseite |
|
|
||||||
| Releases | bis zu 10, inklusive Pre-Release- und Draft-Kennzeichnung |
|
| Releases | bis zu 10, inklusive Pre-Release- und Draft-Kennzeichnung |
|
||||||
| Sprachen | Verteilung als Balken mit Prozentwerten |
|
| Sprachen | Verteilung als Balken mit Prozentwerten |
|
||||||
|
|
||||||
Woher der CI-Status kommt:
|
|
||||||
|
|
||||||
| System | Quelle |
|
|
||||||
| --- | --- |
|
|
||||||
| GitHub | `actions/runs` für den Default-Branch; Lauf-Status und Ergebnis werden zusammengeführt |
|
|
||||||
| GitLab | `pipelines` für den Default-Branch |
|
|
||||||
| Gitea | Kombinierter Commit-Status — deckt Gitea Actions **und** externe Systeme wie Woodpecker ab, anders als ein reiner Actions-Endpunkt, den ältere Instanzen nicht kennen |
|
|
||||||
|
|
||||||
Zur Ehrlichkeit der Aktivitätskurve: geholt wird eine Seite mit 100 Commits. Reicht die
|
|
||||||
nicht über den ganzen Zeitraum, wird die Kurve auf den tatsächlich belegten Ausschnitt
|
|
||||||
gekürzt — eine Null zu zeichnen, wo wir schlicht nichts wissen, wäre falsch.
|
|
||||||
|
|
||||||
- **Snapshot-Prinzip**: Alle Daten werden in der Datenbank abgelegt. Das Dashboard bleibt
|
- **Snapshot-Prinzip**: Alle Daten werden in der Datenbank abgelegt. Das Dashboard bleibt
|
||||||
ohne Netzverbindung oder bei erreichtem Rate-Limit vollständig nutzbar.
|
ohne Netzverbindung oder bei erreichtem Rate-Limit vollständig nutzbar.
|
||||||
|
|
||||||
@@ -366,22 +328,7 @@ nicht verloren gehen. Indizes auf Status, Verbindung und Änderungsdatum.
|
|||||||
- **Setup-Skript** erzeugt die `.env` samt zufälligem `APP_SECRET`.
|
- **Setup-Skript** erzeugt die `.env` samt zufälligem `APP_SECRET`.
|
||||||
- **Seed-Daten** auf Wunsch, idempotent — mehrfaches Ausführen legt nichts doppelt an.
|
- **Seed-Daten** auf Wunsch, idempotent — mehrfaches Ausführen legt nichts doppelt an.
|
||||||
|
|
||||||
### 6.4 Tests
|
### 6.4 API
|
||||||
|
|
||||||
`npm test` führt die Unit-Tests aus — reine Logik, kein DOM, keine Datenbank, unter einer
|
|
||||||
Sekunde:
|
|
||||||
|
|
||||||
| Bereich | Was geprüft wird |
|
|
||||||
| --- | --- |
|
|
||||||
| `utils` | Slug-Erzeugung inklusive Umlauten und Längenbegrenzung, Tag-Aufbereitung, Kürzen, Zahlenformat |
|
|
||||||
| `git/parse` | URL-Zerlegung für https, SSH, verschachtelte GitLab-Gruppen und Oberflächenpfade; Provider-Erkennung; Bildung der Aktivitätskurve |
|
|
||||||
| `security/ssrf` | Sperrlisten für Loopback, Link-Local, Metadaten-Endpunkt, CGNAT und Multicast; Formprüfung; die drei Umgebungsschalter |
|
|
||||||
| `auth/password` | scrypt-Rundlauf, unterschiedliches Salz, Ablageformat, Verhalten bei kaputten Hashes, Passwortregeln |
|
|
||||||
|
|
||||||
Bewusst ohne Datenbank- und Browsertests: die brauchen Infrastruktur und gehören in eine
|
|
||||||
CI-Pipeline. Das steht in der [ROADMAP](ROADMAP.md).
|
|
||||||
|
|
||||||
### 6.5 API
|
|
||||||
|
|
||||||
Zehn REST-Endpunkte für Projekte, Notizen, Verbindungen, Sync, Repo-Listen und Health.
|
Zehn REST-Endpunkte für Projekte, Notizen, Verbindungen, Sync, Repo-Listen und Health.
|
||||||
Alles, was die Oberfläche kann, ist damit auch scriptbar. Übersicht in der
|
Alles, was die Oberfläche kann, ist damit auch scriptbar. Übersicht in der
|
||||||
|
|||||||
@@ -298,8 +298,6 @@ nebula/
|
|||||||
| `npm run db:seed` | Beispielprojekte anlegen |
|
| `npm run db:seed` | Beispielprojekte anlegen |
|
||||||
| `npm run db:studio` | Prisma Studio öffnen |
|
| `npm run db:studio` | Prisma Studio öffnen |
|
||||||
| `npm run db:reset` | Datenbank zurücksetzen (**löscht alles**) |
|
| `npm run db:reset` | Datenbank zurücksetzen (**löscht alles**) |
|
||||||
| `npm test` | Unit-Tests (Vitest), unter einer Sekunde |
|
|
||||||
| `npm run test:watch` | Tests im Beobachtungsmodus |
|
|
||||||
| `npm run typecheck` | TypeScript prüfen |
|
| `npm run typecheck` | TypeScript prüfen |
|
||||||
| `npm run docker:db` | Nur die Datenbank starten |
|
| `npm run docker:db` | Nur die Datenbank starten |
|
||||||
| `npm run docker:up` / `docker:down` | Kompletten Stack starten / stoppen |
|
| `npm run docker:up` / `docker:down` | Kompletten Stack starten / stoppen |
|
||||||
@@ -334,7 +332,6 @@ ausschließlich Daten des angemeldeten Kontos.
|
|||||||
| `GET` | `/api/projects/:id/export` | Ein Projekt (`?format=md` für Markdown) |
|
| `GET` | `/api/projects/:id/export` | Ein Projekt (`?format=md` für Markdown) |
|
||||||
| `POST` | `/api/projects/import` | Import, mit `dryRun` für die Vorschau |
|
| `POST` | `/api/projects/import` | Import, mit `dryRun` für die Vorschau |
|
||||||
| `GET` | `/api/admin/backup` | Vollständige Sicherung als JSON (Admin) |
|
| `GET` | `/api/admin/backup` | Vollständige Sicherung als JSON (Admin) |
|
||||||
| `GET` | `/api/search?q=` | Volltextsuche über die eigenen Notizen |
|
|
||||||
| `GET` `PATCH` `DELETE` | `/api/projects/:id` | Projekt lesen / ändern / löschen |
|
| `GET` `PATCH` `DELETE` | `/api/projects/:id` | Projekt lesen / ändern / löschen |
|
||||||
| `POST` | `/api/projects/:id/sync` | Repo-Daten vom Git-System holen |
|
| `POST` | `/api/projects/:id/sync` | Repo-Daten vom Git-System holen |
|
||||||
| `GET` `POST` | `/api/projects/:id/notes` | Notizen des Projekts |
|
| `GET` `POST` | `/api/projects/:id/notes` | Notizen des Projekts |
|
||||||
|
|||||||
+58
-34
@@ -11,74 +11,101 @@ Was bereits steht, listet [FEATURES.md](FEATURES.md).
|
|||||||
|
|
||||||
## 1 · Als Nächstes empfohlen
|
## 1 · Als Nächstes empfohlen
|
||||||
|
|
||||||
### 1.1 Tests ausbauen: Datenbank und Browser `L`
|
### 1.1 Markdown in Beschreibung und Notizen `S`
|
||||||
|
|
||||||
Das Fundament steht — 51 Unit-Tests der reinen Logik laufen in unter einer
|
Heute wird alles als reiner Text dargestellt. Mit Markdown werden aus
|
||||||
Sekunde. Was fehlt, ist die Schicht darüber:
|
`- [ ] Aufgabe` echte Checklisten, Codeblöcke bekommen Hervorhebung, Links
|
||||||
|
werden klickbar.
|
||||||
|
|
||||||
- **Integrationstests** gegen eine Wegwerf-Datenbank: Datentrennung zwischen
|
Zu beachten: HTML muss beim Rendern entfernt werden, sonst reißt es ein
|
||||||
Konten, Import-Strategien, Backoff des Abgleichs
|
XSS-Loch. Mit `react-markdown` plus `rehype-sanitize` ist das sauber lösbar.
|
||||||
- **Playwright** für die Wege durch die App: Einrichtung, Anmeldung, Kanban
|
|
||||||
- **CI-Pipeline** bei GitHub oder Gitea Actions
|
|
||||||
|
|
||||||
Ich prüfe bislang alles von Hand, inklusive Screenshots. Das trägt nicht
|
### 1.2 Volltextsuche über Notizen `S`
|
||||||
dauerhaft und macht jede weitere Änderung teurer als nötig.
|
|
||||||
|
|
||||||
### 1.2 Benachrichtigungen `M`
|
Die Suche im Board deckt Namen, Kurzbeschreibung und Tags ab — Notizen nicht.
|
||||||
|
Postgres kann das nativ (`tsvector` mit deutscher Konfiguration), also ohne
|
||||||
|
zusätzlichen Dienst.
|
||||||
|
|
||||||
Bei Sync-Fehlern, roter CI, neuen Releases oder Projekten, die lange
|
### 1.3 Kanban-Board mit Drag & Drop `M`
|
||||||
stillstehen. Kanäle: E-Mail (SMTP), ntfy, generischer Webhook. Zusammen mit
|
|
||||||
dem automatischen Abgleich und dem CI-Status ergibt das ein brauchbares
|
|
||||||
Frühwarnsystem — die Daten liegen bereits vor.
|
|
||||||
|
|
||||||
### 1.3 Aufgaben und Checklisten `M`
|
Die gruppierte Ansicht gibt es schon, aber Statuswechsel geht nur über das
|
||||||
|
Menü. Spalten mit Ziehen und Ablegen wären der natürlichere Weg.
|
||||||
|
|
||||||
Eigene Entität statt Freitext, mit Häkchen und automatisch berechnetem
|
Bibliothek: `@dnd-kit` — leichtgewichtig, tastaturbedienbar. Auf Mobilgeräten
|
||||||
Fortschritt. Ersetzt das manuelle Schieben des Reglers. Die Markdown-
|
bleibt die Listenansicht.
|
||||||
Checklisten in Notizen sind ein Vorgeschmack, aber nicht auswertbar.
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 2 · Danach
|
## 2 · Danach
|
||||||
|
|
||||||
### 2.1 Webhooks statt Polling `M`
|
### 2.1 Offene Pull Requests und Issues als Liste `S`
|
||||||
|
|
||||||
|
Aktuell werden sie nur gezählt. Titel, Autor, Alter und Link wären deutlich
|
||||||
|
nützlicher — die Daten holen wir ohnehin schon ab.
|
||||||
|
|
||||||
|
### 2.2 CI-Status je Branch `M`
|
||||||
|
|
||||||
|
Grün oder rot direkt an der Projektkarte, gespeist aus GitHub Actions,
|
||||||
|
GitLab Pipelines und Gitea Actions. Erfordert je Provider einen weiteren
|
||||||
|
Endpunkt und einen zusätzlichen Token-Scope.
|
||||||
|
|
||||||
|
### 2.3 Webhooks statt Polling `M`
|
||||||
|
|
||||||
Ein Push aktualisiert den Snapshot sofort, statt bis zum nächsten Durchlauf
|
Ein Push aktualisiert den Snapshot sofort, statt bis zum nächsten Durchlauf
|
||||||
zu warten. Braucht einen öffentlich erreichbaren Endpunkt mit
|
zu warten. Braucht einen öffentlich erreichbaren Endpunkt mit
|
||||||
Signaturprüfung je Provider — sinnvoll erst, wenn die Instanz von außen
|
Signaturprüfung je Provider — sinnvoll erst, wenn die Instanz von außen
|
||||||
erreichbar ist. Der Zeitplan bleibt als Rückfalllösung.
|
erreichbar ist. Der Zeitplan bleibt als Rückfalllösung.
|
||||||
|
|
||||||
### 2.2 Commit-Aktivität als Heatmap `S`
|
### 2.4 Commit-Aktivität als Verlauf `S`
|
||||||
|
|
||||||
Die Sparkline gibt es auf Karte und Projektseite. Eine Heatmap über ein Jahr
|
Kleine Sparkline auf der Karte, Heatmap auf der Projektseite. Datenbasis ist
|
||||||
wäre die nächste Ausbaustufe — dafür braucht es allerdings mehr als eine
|
da, es fehlt nur die Darstellung.
|
||||||
Seite Commits, also Paginierung oder die Statistik-Endpunkte.
|
|
||||||
|
|
||||||
### 2.3 Kanban mit freier Reihenfolge `M`
|
### 2.5 Aufgaben und Checklisten `M`
|
||||||
|
|
||||||
Heute folgt die Reihenfolge innerhalb einer Spalte der gewählten Sortierung.
|
Eigene Entität statt Freitext-Notiz, mit Häkchen und automatisch
|
||||||
Frei sortieren hieße, eine Position je Projekt zu speichern.
|
berechnetem Fortschritt. Ersetzt das manuelle Schieben des Reglers.
|
||||||
|
|
||||||
|
### 2.6 Benachrichtigungen `M`
|
||||||
|
|
||||||
|
Bei Sync-Fehlern, neuen Releases oder Projekten, die lange stillstehen.
|
||||||
|
Kanäle: E-Mail (SMTP), ntfy, generischer Webhook. Zusammen mit dem
|
||||||
|
automatischen Abgleich ergibt das ein brauchbares Frühwarnsystem.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 3 · Größere Brocken
|
## 3 · Größere Brocken
|
||||||
|
|
||||||
### 3.1 Mehrere Repositories je Projekt `M`
|
### 3.1 Automatisierte Tests und CI `L`
|
||||||
|
|
||||||
|
Aktuell prüfe ich jede Änderung von Hand — Typecheck, Build, API-Durchläufe,
|
||||||
|
Browser-Screenshots. Das gehört in eine Pipeline:
|
||||||
|
|
||||||
|
- **Vitest** für die Logik: URL-Parsing, SSRF-Regeln, Passwort-Hashing,
|
||||||
|
Backoff-Berechnung
|
||||||
|
- **Playwright** für die Wege durch die App: Einrichtung, Anmeldung,
|
||||||
|
Datentrennung
|
||||||
|
- **GitHub Actions** oder Gitea Actions, je nachdem wohin du das Repo legst
|
||||||
|
|
||||||
|
Aus meiner Sicht der wertvollste Punkt der ganzen Liste, sobald das Projekt
|
||||||
|
länger lebt: er macht alles Weitere billiger und sicherer.
|
||||||
|
|
||||||
|
### 3.2 Mehrere Repositories je Projekt `M`
|
||||||
|
|
||||||
Frontend und Backend getrennt, aber ein Projekt. Erfordert eine Zwischentabelle
|
Frontend und Backend getrennt, aber ein Projekt. Erfordert eine Zwischentabelle
|
||||||
und Anpassungen in der Anzeige.
|
und Anpassungen in der Anzeige.
|
||||||
|
|
||||||
### 3.2 Zwei-Faktor per TOTP `M`
|
### 3.3 Zwei-Faktor per TOTP `M`
|
||||||
|
|
||||||
Als Alternative zum Passkey — nützlich, wenn die Instanz aus dem Internet
|
Als Alternative zum Passkey — nützlich, wenn die Instanz aus dem Internet
|
||||||
erreichbar ist und nicht jedes Gerät Passkeys kann.
|
erreichbar ist und nicht jedes Gerät Passkeys kann.
|
||||||
|
|
||||||
### 3.3 Passwort-Zurücksetzen per E-Mail `M`
|
### 3.4 Passwort-Zurücksetzen per E-Mail `M`
|
||||||
|
|
||||||
Heute setzt ein Administrator das Passwort neu. Selbstbedienung braucht SMTP
|
Heute setzt ein Administrator das Passwort neu. Selbstbedienung braucht SMTP
|
||||||
und damit eine weitere Konfiguration — lohnt erst im Mehrbenutzerbetrieb.
|
und damit eine weitere Konfiguration — lohnt erst im Mehrbenutzerbetrieb.
|
||||||
|
|
||||||
### 3.4 Mehrsprachigkeit `L`
|
### 3.5 Mehrsprachigkeit `L`
|
||||||
|
|
||||||
Die Oberfläche ist durchgängig deutsch verdrahtet. Englisch dazu wäre eine
|
Die Oberfläche ist durchgängig deutsch verdrahtet. Englisch dazu wäre eine
|
||||||
Voraussetzung, falls du das Projekt veröffentlichen willst.
|
Voraussetzung, falls du das Projekt veröffentlichen willst.
|
||||||
@@ -90,7 +117,6 @@ Voraussetzung, falls du das Projekt veröffentlichen willst.
|
|||||||
| Idee | Aufwand | Nutzen |
|
| Idee | Aufwand | Nutzen |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| Schnellsuche per `Strg+K` | `S` | Springt direkt zu Projekt oder Aktion |
|
| Schnellsuche per `Strg+K` | `S` | Springt direkt zu Projekt oder Aktion |
|
||||||
| Suchtreffer in Notizen hervorheben | `S` | In der Notiz selbst, nicht nur in der Trefferliste |
|
|
||||||
| Mehrfachauswahl im Board | `S` | Status oder Tags für mehrere auf einmal |
|
| Mehrfachauswahl im Board | `S` | Status oder Tags für mehrere auf einmal |
|
||||||
| Aktivitätsverlauf je Projekt | `S` | Wer hat wann was geändert |
|
| Aktivitätsverlauf je Projekt | `S` | Wer hat wann was geändert |
|
||||||
| Projektvorlagen | `S` | Neues Projekt mit vorgefüllten Tags und Notizen |
|
| Projektvorlagen | `S` | Neues Projekt mit vorgefüllten Tags und Notizen |
|
||||||
@@ -98,7 +124,7 @@ Voraussetzung, falls du das Projekt veröffentlichen willst.
|
|||||||
| Eigenes Logo und Farbe | `S` | Ergänzt `APP_NAME` |
|
| Eigenes Logo und Farbe | `S` | Ergänzt `APP_NAME` |
|
||||||
| PWA-Manifest | `S` | Auf dem Handy als App installierbar |
|
| PWA-Manifest | `S` | Auf dem Handy als App installierbar |
|
||||||
| Barrierefreiheits-Durchsicht | `M` | Fokusreihenfolge, Screenreader, Kontraste |
|
| Barrierefreiheits-Durchsicht | `M` | Fokusreihenfolge, Screenreader, Kontraste |
|
||||||
| `prisma.config.ts` | `S` | Beseitigt die Deprecation-Warnung vor Prisma 7. Achtung: danach lädt Prisma die `.env` nicht mehr von selbst |
|
| `prisma.config.ts` | `S` | Beseitigt die Deprecation-Warnung vor Prisma 7 |
|
||||||
| Audit-Log für Adminaktionen | `M` | Nachvollziehbar, wer Konten geändert hat |
|
| Audit-Log für Adminaktionen | `M` | Nachvollziehbar, wer Konten geändert hat |
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -130,8 +156,6 @@ Damit klar ist, was **nicht** kommt und warum:
|
|||||||
| Docker- und Standalone-Betrieb | ✓ |
|
| Docker- und Standalone-Betrieb | ✓ |
|
||||||
| Automatischer Abgleich mit Zeitplan | ✓ |
|
| Automatischer Abgleich mit Zeitplan | ✓ |
|
||||||
| Export, Import und Sicherung | ✓ |
|
| Export, Import und Sicherung | ✓ |
|
||||||
| **v0.3.0** Markdown, Volltextsuche über Notizen, PR- und Issue-Listen, Testfundament | ✓ |
|
|
||||||
| **v0.4.0** Kanban mit Drag & Drop, CI-Status je Branch, Commit-Aktivität | ✓ |
|
|
||||||
|
|
||||||
Zur Entscheidung beim Export: Git-Tokens gehen **nicht** mit. Die Verbindung wird nur
|
Zur Entscheidung beim Export: Git-Tokens gehen **nicht** mit. Die Verbindung wird nur
|
||||||
beschrieben, das Token ist nach dem Import neu zu hinterlegen. Snapshots bleiben
|
beschrieben, das Token ist nach dem Import neu zu hinterlegen. Snapshots bleiben
|
||||||
|
|||||||
Generated
+3
-2460
File diff suppressed because it is too large
Load Diff
+3
-12
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "nebula",
|
"name": "nebula",
|
||||||
"version": "0.4.0",
|
"version": "0.1.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "Nebula – Dashboard fuer Vibe-Coding Projekte mit Git-Anbindung (GitHub, GitLab, Gitea)",
|
"description": "Nebula – Dashboard fuer Vibe-Coding Projekte mit Git-Anbindung (GitHub, GitLab, Gitea)",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -23,17 +23,12 @@
|
|||||||
"docker:logs": "docker compose --profile full logs -f app",
|
"docker:logs": "docker compose --profile full logs -f app",
|
||||||
"docker:tools": "docker compose --profile tools up -d",
|
"docker:tools": "docker compose --profile tools up -d",
|
||||||
"setup": "node scripts/setup.mjs",
|
"setup": "node scripts/setup.mjs",
|
||||||
"postinstall": "prisma generate",
|
"postinstall": "prisma generate"
|
||||||
"test": "vitest run",
|
|
||||||
"test:watch": "vitest"
|
|
||||||
},
|
},
|
||||||
"prisma": {
|
"prisma": {
|
||||||
"seed": "tsx prisma/seed.ts"
|
"seed": "tsx prisma/seed.ts"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@dnd-kit/core": "^6.3.1",
|
|
||||||
"@dnd-kit/modifiers": "^9.0.0",
|
|
||||||
"@dnd-kit/sortable": "^10.0.0",
|
|
||||||
"@prisma/client": "^6.8.2",
|
"@prisma/client": "^6.8.2",
|
||||||
"@simplewebauthn/browser": "^13.3.0",
|
"@simplewebauthn/browser": "^13.3.0",
|
||||||
"@simplewebauthn/server": "^13.3.2",
|
"@simplewebauthn/server": "^13.3.2",
|
||||||
@@ -41,9 +36,6 @@
|
|||||||
"next": "^15.3.3",
|
"next": "^15.3.3",
|
||||||
"react": "^19.1.0",
|
"react": "^19.1.0",
|
||||||
"react-dom": "^19.1.0",
|
"react-dom": "^19.1.0",
|
||||||
"react-markdown": "^10.1.0",
|
|
||||||
"rehype-sanitize": "^6.0.0",
|
|
||||||
"remark-gfm": "^4.0.1",
|
|
||||||
"zod": "^3.25.28"
|
"zod": "^3.25.28"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@@ -54,8 +46,7 @@
|
|||||||
"prisma": "^6.8.2",
|
"prisma": "^6.8.2",
|
||||||
"tailwindcss": "^4.1.7",
|
"tailwindcss": "^4.1.7",
|
||||||
"tsx": "^4.19.4",
|
"tsx": "^4.19.4",
|
||||||
"typescript": "^5.8.3",
|
"typescript": "^5.8.3"
|
||||||
"vitest": "^4.1.10"
|
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=20.11"
|
"node": ">=20.11"
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
-- Volltextsuche ueber Notizen.
|
|
||||||
--
|
|
||||||
-- Dies ist ein Ausdrucksindex. Prisma kann so etwas im Schema nicht abbilden
|
|
||||||
-- und kennt ihn deshalb nicht. Nachgeprueft: "prisma migrate diff" laesst ihn
|
|
||||||
-- in Ruhe und schlaegt kein DROP vor - Ausdrucksindizes werden schlicht
|
|
||||||
-- ignoriert. Trotzdem beim Erzeugen kuenftiger Migrationen kurz hinsehen.
|
|
||||||
--
|
|
||||||
-- Faellt er doch einmal weg, funktioniert die Suche weiter, nur langsamer:
|
|
||||||
-- Postgres berechnet to_tsvector dann je Zeile.
|
|
||||||
--
|
|
||||||
-- Der Ausdruck muss mit dem in src/app/api/search/route.ts uebereinstimmen,
|
|
||||||
-- sonst greift der Index nicht. Die zweistellige Form von to_tsvector mit
|
|
||||||
-- fester Konfiguration ist IMMUTABLE und damit indizierbar.
|
|
||||||
|
|
||||||
CREATE INDEX "Note_fulltext_idx" ON "Note"
|
|
||||||
USING GIN (to_tsvector('german', coalesce("title", '') || ' ' || "content"));
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
-- AlterTable
|
|
||||||
ALTER TABLE "RepoSnapshot" ADD COLUMN "ciBranch" TEXT,
|
|
||||||
ADD COLUMN "ciFinishedAt" TIMESTAMP(3),
|
|
||||||
ADD COLUMN "ciName" TEXT,
|
|
||||||
ADD COLUMN "ciState" TEXT,
|
|
||||||
ADD COLUMN "ciUrl" TEXT,
|
|
||||||
ADD COLUMN "commitActivity" JSONB NOT NULL DEFAULT '[]',
|
|
||||||
ADD COLUMN "issues" JSONB NOT NULL DEFAULT '[]',
|
|
||||||
ADD COLUMN "pullRequests" JSONB NOT NULL DEFAULT '[]';
|
|
||||||
+5
-17
@@ -298,23 +298,11 @@ model RepoSnapshot {
|
|||||||
|
|
||||||
/// Rohdaten der Listen – bewusst als JSON, damit providerspezifische
|
/// Rohdaten der Listen – bewusst als JSON, damit providerspezifische
|
||||||
/// Zusatzfelder nicht verloren gehen.
|
/// Zusatzfelder nicht verloren gehen.
|
||||||
branches Json @default("[]")
|
branches Json @default("[]")
|
||||||
tags Json @default("[]")
|
tags Json @default("[]")
|
||||||
commits Json @default("[]")
|
commits Json @default("[]")
|
||||||
releases Json @default("[]")
|
releases Json @default("[]")
|
||||||
languages Json @default("{}")
|
languages Json @default("{}")
|
||||||
pullRequests Json @default("[]")
|
|
||||||
issues Json @default("[]")
|
|
||||||
/// Commits je Tag der letzten 30 Tage, aeltester zuerst.
|
|
||||||
commitActivity Json @default("[]")
|
|
||||||
|
|
||||||
// ── Letzter CI-Lauf auf dem Default-Branch ─────────────────
|
|
||||||
/// success | failure | running | pending | cancelled
|
|
||||||
ciState String?
|
|
||||||
ciName String?
|
|
||||||
ciBranch String?
|
|
||||||
ciUrl String?
|
|
||||||
ciFinishedAt DateTime?
|
|
||||||
|
|
||||||
pushedAt DateTime?
|
pushedAt DateTime?
|
||||||
fetchedAt DateTime @default(now())
|
fetchedAt DateTime @default(now())
|
||||||
|
|||||||
@@ -1,67 +0,0 @@
|
|||||||
import { NextResponse } from "next/server";
|
|
||||||
import { requireUserApi } from "@/lib/auth/guard";
|
|
||||||
import { prisma } from "@/lib/db";
|
|
||||||
|
|
||||||
export const dynamic = "force-dynamic";
|
|
||||||
|
|
||||||
interface Hit {
|
|
||||||
projectId: string;
|
|
||||||
noteId: string;
|
|
||||||
title: string | null;
|
|
||||||
/** Textausschnitt mit hervorgehobener Fundstelle. */
|
|
||||||
snippet: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Volltextsuche ueber Notizen.
|
|
||||||
*
|
|
||||||
* Die Suche im Board arbeitet auf den bereits geladenen Projekten und deckt
|
|
||||||
* Name, Kurzbeschreibung und Tags ab. Notizen liegen dort nicht vor – die
|
|
||||||
* mitzuladen wuerde die Seite unnoetig aufblaehen. Deshalb dieser Endpunkt:
|
|
||||||
* Postgres sucht mit seiner deutschen Textsuche direkt in der Datenbank.
|
|
||||||
*
|
|
||||||
* ts_headline liefert gleich den passenden Ausschnitt mit; die Hervorhebung
|
|
||||||
* kommt als [[…]] zurueck, damit die Oberflaeche kein HTML einbetten muss.
|
|
||||||
*/
|
|
||||||
export async function GET(request: Request) {
|
|
||||||
const auth = await requireUserApi();
|
|
||||||
if (!auth.ok) return auth.response;
|
|
||||||
|
|
||||||
const query = (new URL(request.url).searchParams.get("q") ?? "").trim();
|
|
||||||
if (query.length < 2) {
|
|
||||||
return NextResponse.json({ query, hits: [], projectIds: [] });
|
|
||||||
}
|
|
||||||
|
|
||||||
// websearch_to_tsquery versteht Eingaben wie "docker -compose" oder
|
|
||||||
// Anfuehrungszeichen und wirft bei Unsinn keinen Fehler.
|
|
||||||
const hits = await prisma.$queryRaw<Hit[]>`
|
|
||||||
SELECT
|
|
||||||
n."projectId" AS "projectId",
|
|
||||||
n."id" AS "noteId",
|
|
||||||
n."title" AS "title",
|
|
||||||
ts_headline(
|
|
||||||
'german',
|
|
||||||
n."content",
|
|
||||||
websearch_to_tsquery('german', ${query}),
|
|
||||||
'StartSel=[[, StopSel=]], MaxWords=18, MinWords=6, ShortWord=2, MaxFragments=1'
|
|
||||||
) AS "snippet"
|
|
||||||
FROM "Note" n
|
|
||||||
JOIN "Project" p ON p."id" = n."projectId"
|
|
||||||
WHERE p."ownerId" = ${auth.user.id}
|
|
||||||
AND to_tsvector('german', coalesce(n."title", '') || ' ' || n."content")
|
|
||||||
@@ websearch_to_tsquery('german', ${query})
|
|
||||||
ORDER BY ts_rank(
|
|
||||||
to_tsvector('german', coalesce(n."title", '') || ' ' || n."content"),
|
|
||||||
websearch_to_tsquery('german', ${query})
|
|
||||||
) DESC
|
|
||||||
LIMIT 50
|
|
||||||
`;
|
|
||||||
|
|
||||||
return NextResponse.json({
|
|
||||||
query,
|
|
||||||
hits,
|
|
||||||
// Die Oberflaeche braucht vor allem die betroffenen Projekte, um sie im
|
|
||||||
// Board einzublenden.
|
|
||||||
projectIds: Array.from(new Set(hits.map((hit) => hit.projectId))),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@@ -89,131 +89,6 @@
|
|||||||
0 28px 70px -24px rgba(0, 0, 0, 0.95);
|
0 28px 70px -24px rgba(0, 0, 0, 0.95);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Markdown-Inhalte. Tailwind setzt in seinem Preflight alle Abstaende und
|
|
||||||
* Schriftgroessen zurueck, also muessen Ueberschriften, Listen und
|
|
||||||
* Codebloecke hier wieder Form bekommen.
|
|
||||||
*/
|
|
||||||
.md {
|
|
||||||
font-size: 0.875rem;
|
|
||||||
line-height: 1.65;
|
|
||||||
color: #cbd5e1;
|
|
||||||
overflow-wrap: break-word;
|
|
||||||
}
|
|
||||||
|
|
||||||
.md > *:first-child { margin-top: 0; }
|
|
||||||
.md > *:last-child { margin-bottom: 0; }
|
|
||||||
|
|
||||||
.md h1, .md h2, .md h3, .md h4 {
|
|
||||||
color: #f1f5f9;
|
|
||||||
font-weight: 600;
|
|
||||||
line-height: 1.3;
|
|
||||||
margin: 1.4em 0 0.5em;
|
|
||||||
}
|
|
||||||
.md h1 { font-size: 1.3rem; }
|
|
||||||
.md h2 { font-size: 1.15rem; }
|
|
||||||
.md h3 { font-size: 1rem; }
|
|
||||||
.md h4 { font-size: 0.9rem; }
|
|
||||||
|
|
||||||
.md p { margin: 0.75em 0; }
|
|
||||||
|
|
||||||
.md a {
|
|
||||||
color: #c4b5fd;
|
|
||||||
text-decoration: underline;
|
|
||||||
text-underline-offset: 2px;
|
|
||||||
}
|
|
||||||
.md a:hover { color: #ddd6fe; }
|
|
||||||
|
|
||||||
.md strong { color: #f1f5f9; font-weight: 600; }
|
|
||||||
|
|
||||||
.md ul, .md ol { margin: 0.75em 0; padding-left: 1.35em; }
|
|
||||||
.md ul { list-style: disc; }
|
|
||||||
.md ol { list-style: decimal; }
|
|
||||||
.md li { margin: 0.3em 0; }
|
|
||||||
.md li::marker { color: #64748b; }
|
|
||||||
|
|
||||||
/* Aufgabenlisten aus "- [ ] …" */
|
|
||||||
.md li:has(> input[type="checkbox"]) {
|
|
||||||
list-style: none;
|
|
||||||
margin-left: -1.35em;
|
|
||||||
display: flex;
|
|
||||||
align-items: flex-start;
|
|
||||||
gap: 0.5rem;
|
|
||||||
}
|
|
||||||
.md input[type="checkbox"] {
|
|
||||||
margin-top: 0.35em;
|
|
||||||
accent-color: #8b5cf6;
|
|
||||||
width: 0.9rem;
|
|
||||||
height: 0.9rem;
|
|
||||||
flex-shrink: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.md code {
|
|
||||||
background: rgba(255, 255, 255, 0.07);
|
|
||||||
border: 1px solid rgba(255, 255, 255, 0.07);
|
|
||||||
border-radius: 0.35rem;
|
|
||||||
padding: 0.1em 0.35em;
|
|
||||||
font-family: var(--font-mono);
|
|
||||||
font-size: 0.85em;
|
|
||||||
color: #e9d5ff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.md pre {
|
|
||||||
background: rgba(4, 6, 16, 0.75);
|
|
||||||
border: 1px solid rgba(255, 255, 255, 0.08);
|
|
||||||
border-radius: 0.75rem;
|
|
||||||
padding: 0.85rem 1rem;
|
|
||||||
margin: 0.9em 0;
|
|
||||||
overflow-x: auto;
|
|
||||||
}
|
|
||||||
.md pre code {
|
|
||||||
background: none;
|
|
||||||
border: none;
|
|
||||||
padding: 0;
|
|
||||||
color: #cbd5e1;
|
|
||||||
font-size: 0.8rem;
|
|
||||||
line-height: 1.6;
|
|
||||||
}
|
|
||||||
|
|
||||||
.md blockquote {
|
|
||||||
border-left: 2px solid rgba(167, 139, 250, 0.5);
|
|
||||||
padding-left: 0.9rem;
|
|
||||||
margin: 0.9em 0;
|
|
||||||
color: #94a3b8;
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
|
|
||||||
.md hr {
|
|
||||||
border: 0;
|
|
||||||
border-top: 1px solid rgba(255, 255, 255, 0.09);
|
|
||||||
margin: 1.4em 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.md table {
|
|
||||||
width: 100%;
|
|
||||||
margin: 0.9em 0;
|
|
||||||
border-collapse: collapse;
|
|
||||||
font-size: 0.8rem;
|
|
||||||
display: block;
|
|
||||||
overflow-x: auto;
|
|
||||||
}
|
|
||||||
.md th, .md td {
|
|
||||||
border: 1px solid rgba(255, 255, 255, 0.09);
|
|
||||||
padding: 0.4rem 0.6rem;
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
.md th {
|
|
||||||
background: rgba(255, 255, 255, 0.04);
|
|
||||||
color: #e2e8f0;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
|
|
||||||
.md img {
|
|
||||||
max-width: 100%;
|
|
||||||
height: auto;
|
|
||||||
border-radius: 0.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ── Text & Akzente ───────────────────────────────────────── */
|
/* ── Text & Akzente ───────────────────────────────────────── */
|
||||||
|
|
||||||
.text-gradient {
|
.text-gradient {
|
||||||
|
|||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
import type { Metadata, Viewport } from "next";
|
import type { Metadata, Viewport } from "next";
|
||||||
import { TopNav } from "@/components/TopNav";
|
import { TopNav } from "@/components/TopNav";
|
||||||
import { getSessionUser } from "@/lib/auth/session";
|
import { getSessionUser } from "@/lib/auth/session";
|
||||||
import { APP_NAME, APP_TAGLINE, APP_VERSION } from "@/lib/config";
|
import { APP_NAME, APP_TAGLINE } from "@/lib/config";
|
||||||
import "./globals.css";
|
import "./globals.css";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -52,7 +52,7 @@ export default async function RootLayout({
|
|||||||
<footer className="mx-auto w-full max-w-[1400px] px-4 pb-10 text-xs text-slate-500 sm:px-6 lg:px-8">
|
<footer className="mx-auto w-full max-w-[1400px] px-4 pb-10 text-xs text-slate-500 sm:px-6 lg:px-8">
|
||||||
<div className="flex flex-wrap items-center justify-between gap-2 border-t border-white/5 pt-6">
|
<div className="flex flex-wrap items-center justify-between gap-2 border-t border-white/5 pt-6">
|
||||||
<span>{APP_NAME} · lokal betrieben, Daten bleiben in deiner PostgreSQL.</span>
|
<span>{APP_NAME} · lokal betrieben, Daten bleiben in deiner PostgreSQL.</span>
|
||||||
<span className="font-mono text-slate-600">v{APP_VERSION}</span>
|
<span className="font-mono text-slate-600">v0.2.0</span>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import type { Metadata } from "next";
|
|||||||
import { notFound } from "next/navigation";
|
import { notFound } from "next/navigation";
|
||||||
import { FileText } from "lucide-react";
|
import { FileText } from "lucide-react";
|
||||||
import { GitPanel } from "@/components/GitPanel";
|
import { GitPanel } from "@/components/GitPanel";
|
||||||
import { Markdown } from "@/components/Markdown";
|
|
||||||
import { NotesPanel } from "@/components/NotesPanel";
|
import { NotesPanel } from "@/components/NotesPanel";
|
||||||
import { ProjectHeader } from "@/components/ProjectHeader";
|
import { ProjectHeader } from "@/components/ProjectHeader";
|
||||||
import { requireUserPage } from "@/lib/auth/guard";
|
import { requireUserPage } from "@/lib/auth/guard";
|
||||||
@@ -67,7 +66,9 @@ export default async function ProjectPage({ params }: PageProps) {
|
|||||||
Beschreibung
|
Beschreibung
|
||||||
</h2>
|
</h2>
|
||||||
{detail.description ? (
|
{detail.description ? (
|
||||||
<Markdown className="mt-3">{detail.description}</Markdown>
|
<p className="mt-3 whitespace-pre-wrap break-words text-sm leading-relaxed text-slate-300">
|
||||||
|
{detail.description}
|
||||||
|
</p>
|
||||||
) : (
|
) : (
|
||||||
<p className="mt-3 text-sm text-slate-500">
|
<p className="mt-3 text-sm text-slate-500">
|
||||||
Keine Beschreibung hinterlegt. Ueber „Bearbeiten“ kannst du die Idee ausformulieren.
|
Keine Beschreibung hinterlegt. Ueber „Bearbeiten“ kannst du die Idee ausformulieren.
|
||||||
|
|||||||
@@ -1,90 +0,0 @@
|
|||||||
import { CircleCheck, CircleDashed, CircleSlash, CircleX, LoaderCircle } from "lucide-react";
|
|
||||||
import { cn } from "@/lib/utils";
|
|
||||||
|
|
||||||
export type CiState = "success" | "failure" | "running" | "pending" | "cancelled";
|
|
||||||
|
|
||||||
const META: Record<
|
|
||||||
CiState,
|
|
||||||
{ label: string; short: string; className: string; icon: typeof CircleCheck; spin?: boolean }
|
|
||||||
> = {
|
|
||||||
success: {
|
|
||||||
label: "CI erfolgreich",
|
|
||||||
short: "CI ok",
|
|
||||||
className: "bg-emerald-500/12 text-emerald-200 ring-emerald-400/30",
|
|
||||||
icon: CircleCheck,
|
|
||||||
},
|
|
||||||
failure: {
|
|
||||||
label: "CI fehlgeschlagen",
|
|
||||||
short: "CI rot",
|
|
||||||
className: "bg-rose-500/12 text-rose-200 ring-rose-400/30",
|
|
||||||
icon: CircleX,
|
|
||||||
},
|
|
||||||
running: {
|
|
||||||
label: "CI laeuft",
|
|
||||||
short: "CI laeuft",
|
|
||||||
className: "bg-amber-500/12 text-amber-200 ring-amber-400/30",
|
|
||||||
icon: LoaderCircle,
|
|
||||||
spin: true,
|
|
||||||
},
|
|
||||||
pending: {
|
|
||||||
label: "CI wartet",
|
|
||||||
short: "CI wartet",
|
|
||||||
className: "bg-slate-500/12 text-slate-300 ring-slate-400/25",
|
|
||||||
icon: CircleDashed,
|
|
||||||
},
|
|
||||||
cancelled: {
|
|
||||||
label: "CI abgebrochen",
|
|
||||||
short: "CI abgebrochen",
|
|
||||||
className: "bg-slate-500/12 text-slate-400 ring-slate-400/20",
|
|
||||||
icon: CircleSlash,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
export function CiBadge({
|
|
||||||
state,
|
|
||||||
name,
|
|
||||||
url,
|
|
||||||
compact = false,
|
|
||||||
}: {
|
|
||||||
state: string | null | undefined;
|
|
||||||
name?: string | null;
|
|
||||||
url?: string | null;
|
|
||||||
compact?: boolean;
|
|
||||||
}) {
|
|
||||||
if (!state || !(state in META)) return null;
|
|
||||||
const meta = META[state as CiState];
|
|
||||||
const Icon = meta.icon;
|
|
||||||
|
|
||||||
const content = (
|
|
||||||
<>
|
|
||||||
<Icon className={cn("h-3 w-3 shrink-0", meta.spin && "animate-spin")} />
|
|
||||||
{compact ? meta.short : (name ?? meta.label)}
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
|
|
||||||
const className = cn(
|
|
||||||
"inline-flex items-center gap-1.5 rounded-full ring-1 ring-inset",
|
|
||||||
meta.className,
|
|
||||||
compact ? "px-2 py-0.5 text-[10px]" : "px-2.5 py-1 text-[11px]",
|
|
||||||
);
|
|
||||||
|
|
||||||
if (url && !compact) {
|
|
||||||
return (
|
|
||||||
<a
|
|
||||||
href={url}
|
|
||||||
target="_blank"
|
|
||||||
rel="noreferrer noopener"
|
|
||||||
className={cn(className, "transition-all hover:brightness-125")}
|
|
||||||
title={meta.label}
|
|
||||||
>
|
|
||||||
{content}
|
|
||||||
</a>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<span className={className} title={name ? `${meta.label} · ${name}` : meta.label}>
|
|
||||||
{content}
|
|
||||||
</span>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
+9
-109
@@ -3,9 +3,7 @@
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import {
|
import {
|
||||||
Activity,
|
|
||||||
AlertTriangle,
|
AlertTriangle,
|
||||||
CircleDot,
|
|
||||||
ExternalLink,
|
ExternalLink,
|
||||||
GitBranch,
|
GitBranch,
|
||||||
GitCommitHorizontal,
|
GitCommitHorizontal,
|
||||||
@@ -20,8 +18,6 @@ import {
|
|||||||
Star,
|
Star,
|
||||||
Tag,
|
Tag,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { CiBadge } from "@/components/CiBadge";
|
|
||||||
import { Sparkline } from "@/components/Sparkline";
|
|
||||||
import { asArray, asRecord } from "@/types";
|
import { asArray, asRecord } from "@/types";
|
||||||
import type {
|
import type {
|
||||||
BranchInfo,
|
BranchInfo,
|
||||||
@@ -29,13 +25,10 @@ import type {
|
|||||||
ProjectDetail,
|
ProjectDetail,
|
||||||
ReleaseInfo,
|
ReleaseInfo,
|
||||||
TagInfo,
|
TagInfo,
|
||||||
TicketInfo,
|
|
||||||
} from "@/types";
|
} from "@/types";
|
||||||
import { cn, formatDateTime, formatNumber, formatRelative } from "@/lib/utils";
|
import { cn, formatDateTime, formatNumber, formatRelative } from "@/lib/utils";
|
||||||
|
|
||||||
const TABS = [
|
const TABS = [
|
||||||
{ key: "pulls", label: "PRs", icon: GitPullRequest },
|
|
||||||
{ key: "issues", label: "Issues", icon: CircleDot },
|
|
||||||
{ key: "branches", label: "Branches", icon: GitBranch },
|
{ key: "branches", label: "Branches", icon: GitBranch },
|
||||||
{ key: "tags", label: "Tags", icon: Tag },
|
{ key: "tags", label: "Tags", icon: Tag },
|
||||||
{ key: "commits", label: "Commits", icon: GitCommitHorizontal },
|
{ key: "commits", label: "Commits", icon: GitCommitHorizontal },
|
||||||
@@ -46,7 +39,7 @@ type TabKey = (typeof TABS)[number]["key"];
|
|||||||
|
|
||||||
export function GitPanel({ project }: { project: ProjectDetail }) {
|
export function GitPanel({ project }: { project: ProjectDetail }) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [tab, setTab] = useState<TabKey>("pulls");
|
const [tab, setTab] = useState<TabKey>("branches");
|
||||||
const [syncing, setSyncing] = useState(false);
|
const [syncing, setSyncing] = useState(false);
|
||||||
const [message, setMessage] = useState<{ ok: boolean; text: string } | null>(null);
|
const [message, setMessage] = useState<{ ok: boolean; text: string } | null>(null);
|
||||||
|
|
||||||
@@ -56,9 +49,6 @@ export function GitPanel({ project }: { project: ProjectDetail }) {
|
|||||||
const commits = asArray<CommitInfo>(snapshot?.commits);
|
const commits = asArray<CommitInfo>(snapshot?.commits);
|
||||||
const releases = asArray<ReleaseInfo>(snapshot?.releases);
|
const releases = asArray<ReleaseInfo>(snapshot?.releases);
|
||||||
const languages = asRecord(snapshot?.languages);
|
const languages = asRecord(snapshot?.languages);
|
||||||
const pulls = asArray<TicketInfo>(snapshot?.pullRequests);
|
|
||||||
const issues = asArray<TicketInfo>(snapshot?.issues);
|
|
||||||
const activity = asArray<number>(snapshot?.commitActivity);
|
|
||||||
|
|
||||||
const hasRepo = Boolean(project.repoOwner && project.repoName) || Boolean(project.repoUrl);
|
const hasRepo = Boolean(project.repoOwner && project.repoName) || Boolean(project.repoUrl);
|
||||||
|
|
||||||
@@ -128,7 +118,6 @@ export function GitPanel({ project }: { project: ProjectDetail }) {
|
|||||||
<ExternalLink className="h-3.5 w-3.5" />
|
<ExternalLink className="h-3.5 w-3.5" />
|
||||||
</a>
|
</a>
|
||||||
) : null}
|
) : null}
|
||||||
<CiBadge state={snapshot?.ciState} name={snapshot?.ciName} url={snapshot?.ciUrl} />
|
|
||||||
</div>
|
</div>
|
||||||
<p className="mt-1 text-xs text-slate-500" suppressHydrationWarning>
|
<p className="mt-1 text-xs text-slate-500" suppressHydrationWarning>
|
||||||
{project.lastSyncedAt
|
{project.lastSyncedAt
|
||||||
@@ -235,24 +224,6 @@ export function GitPanel({ project }: { project: ProjectDetail }) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Commit-Aktivitaet */}
|
|
||||||
{activity.some((value) => value > 0) ? (
|
|
||||||
<div className="glass p-4">
|
|
||||||
<div className="mb-2.5 flex items-center justify-between">
|
|
||||||
<p className="flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-[0.14em] text-slate-500">
|
|
||||||
<Activity className="h-3 w-3" />
|
|
||||||
{/* Der Zeitraum richtet sich danach, wie weit die geholten
|
|
||||||
Commits zurueckreichen – hoechstens 30 Tage. */}
|
|
||||||
Commits der letzten {activity.length} Tage
|
|
||||||
</p>
|
|
||||||
<span className="text-xs tabular-nums text-slate-400">
|
|
||||||
{activity.reduce((sum, value) => sum + value, 0)}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<Sparkline values={activity} height={40} />
|
|
||||||
</div>
|
|
||||||
) : null}
|
|
||||||
|
|
||||||
{/* Sprachen */}
|
{/* Sprachen */}
|
||||||
{languageTotal > 0 ? (
|
{languageTotal > 0 ? (
|
||||||
<div className="glass p-4">
|
<div className="glass p-4">
|
||||||
@@ -292,14 +263,14 @@ export function GitPanel({ project }: { project: ProjectDetail }) {
|
|||||||
<div className="glass overflow-hidden">
|
<div className="glass overflow-hidden">
|
||||||
<div className="flex flex-wrap gap-1 border-b border-white/6 p-2">
|
<div className="flex flex-wrap gap-1 border-b border-white/6 p-2">
|
||||||
{TABS.map(({ key, label, icon: Icon }) => {
|
{TABS.map(({ key, label, icon: Icon }) => {
|
||||||
const count = {
|
const count =
|
||||||
pulls: pulls.length,
|
key === "branches"
|
||||||
issues: issues.length,
|
? branches.length
|
||||||
branches: branches.length,
|
: key === "tags"
|
||||||
tags: tags.length,
|
? tags.length
|
||||||
commits: commits.length,
|
: key === "commits"
|
||||||
releases: releases.length,
|
? commits.length
|
||||||
}[key];
|
: releases.length;
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
key={key}
|
key={key}
|
||||||
@@ -321,16 +292,6 @@ export function GitPanel({ project }: { project: ProjectDetail }) {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="max-h-[26rem] overflow-y-auto">
|
<div className="max-h-[26rem] overflow-y-auto">
|
||||||
{tab === "pulls" ? (
|
|
||||||
<TicketList
|
|
||||||
tickets={pulls}
|
|
||||||
empty="Keine offenen Pull oder Merge Requests."
|
|
||||||
icon={GitPullRequest}
|
|
||||||
/>
|
|
||||||
) : null}
|
|
||||||
{tab === "issues" ? (
|
|
||||||
<TicketList tickets={issues} empty="Keine offenen Issues." icon={CircleDot} />
|
|
||||||
) : null}
|
|
||||||
{tab === "branches" ? <BranchList branches={branches} /> : null}
|
{tab === "branches" ? <BranchList branches={branches} /> : null}
|
||||||
{tab === "tags" ? <TagList tags={tags} /> : null}
|
{tab === "tags" ? <TagList tags={tags} /> : null}
|
||||||
{tab === "commits" ? <CommitList commits={commits} /> : null}
|
{tab === "commits" ? <CommitList commits={commits} /> : null}
|
||||||
@@ -381,67 +342,6 @@ function Empty({ text }: { text: string }) {
|
|||||||
return <p className="px-4 py-8 text-center text-xs text-slate-500">{text}</p>;
|
return <p className="px-4 py-8 text-center text-xs text-slate-500">{text}</p>;
|
||||||
}
|
}
|
||||||
|
|
||||||
function TicketList({
|
|
||||||
tickets,
|
|
||||||
empty,
|
|
||||||
icon: Icon,
|
|
||||||
}: {
|
|
||||||
tickets: TicketInfo[];
|
|
||||||
empty: string;
|
|
||||||
icon: typeof GitPullRequest;
|
|
||||||
}) {
|
|
||||||
if (tickets.length === 0) return <Empty text={empty} />;
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
{tickets.map((ticket) => (
|
|
||||||
<Row key={`${ticket.number}-${ticket.title}`}>
|
|
||||||
<div className="flex min-w-0 items-start gap-2">
|
|
||||||
<Icon
|
|
||||||
className={cn(
|
|
||||||
"mt-0.5 h-3.5 w-3.5 shrink-0",
|
|
||||||
ticket.draft ? "text-slate-600" : "text-emerald-400/70",
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
<div className="min-w-0">
|
|
||||||
<p className="truncate text-xs text-slate-200">
|
|
||||||
{ticket.title}
|
|
||||||
{ticket.draft ? (
|
|
||||||
<span className="ml-1.5 rounded bg-slate-500/15 px-1 py-0.5 text-[10px] text-slate-400">
|
|
||||||
Entwurf
|
|
||||||
</span>
|
|
||||||
) : null}
|
|
||||||
</p>
|
|
||||||
<p className="mt-0.5 flex flex-wrap items-center gap-x-2 text-[11px] text-slate-500">
|
|
||||||
<span className="font-mono text-slate-600">#{ticket.number}</span>
|
|
||||||
<span>{ticket.author ?? "unbekannt"}</span>
|
|
||||||
{ticket.labels.slice(0, 3).map((label) => (
|
|
||||||
<span key={label} className="rounded bg-white/6 px-1 py-0.5 text-[10px]">
|
|
||||||
{label}
|
|
||||||
</span>
|
|
||||||
))}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="flex shrink-0 items-center gap-2 text-[11px] text-slate-500">
|
|
||||||
<span suppressHydrationWarning>{formatRelative(ticket.createdAt)}</span>
|
|
||||||
{ticket.url ? (
|
|
||||||
<a
|
|
||||||
href={ticket.url}
|
|
||||||
target="_blank"
|
|
||||||
rel="noreferrer noopener"
|
|
||||||
className="text-slate-600 transition-colors hover:text-violet-300"
|
|
||||||
aria-label="Im Git-System oeffnen"
|
|
||||||
>
|
|
||||||
<ExternalLink className="h-3 w-3" />
|
|
||||||
</a>
|
|
||||||
) : null}
|
|
||||||
</div>
|
|
||||||
</Row>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function BranchList({ branches }: { branches: BranchInfo[] }) {
|
function BranchList({ branches }: { branches: BranchInfo[] }) {
|
||||||
if (branches.length === 0) return <Empty text="Keine Branches gefunden." />;
|
if (branches.length === 0) return <Empty text="Keine Branches gefunden." />;
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,276 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import { useEffect, useMemo, useState } from "react";
|
|
||||||
import Link from "next/link";
|
|
||||||
import { useRouter } from "next/navigation";
|
|
||||||
import {
|
|
||||||
DndContext,
|
|
||||||
DragOverlay,
|
|
||||||
PointerSensor,
|
|
||||||
TouchSensor,
|
|
||||||
closestCorners,
|
|
||||||
useDraggable,
|
|
||||||
useDroppable,
|
|
||||||
useSensor,
|
|
||||||
useSensors,
|
|
||||||
type DragEndEvent,
|
|
||||||
type DragStartEvent,
|
|
||||||
} from "@dnd-kit/core";
|
|
||||||
import { restrictToWindowEdges } from "@dnd-kit/modifiers";
|
|
||||||
import { GitBranch, GripVertical, NotebookPen } from "lucide-react";
|
|
||||||
import type { ProjectStatus } from "@prisma/client";
|
|
||||||
import { CiBadge } from "@/components/CiBadge";
|
|
||||||
import { STATUS_META, STATUS_ORDER, accentOf } from "@/lib/status";
|
|
||||||
import { cn, truncate } from "@/lib/utils";
|
|
||||||
import type { ProjectListItem } from "@/types";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Statusspalten mit Ziehen und Ablegen.
|
|
||||||
*
|
|
||||||
* Der Statuswechsel wird sofort angezeigt und erst danach gespeichert;
|
|
||||||
* scheitert das Speichern, springt die Karte zurueck. Die Reihenfolge
|
|
||||||
* innerhalb einer Spalte ist nicht frei sortierbar – sie folgt der im Board
|
|
||||||
* gewaehlten Sortierung, sonst muesste eine Position mitgespeichert werden.
|
|
||||||
*/
|
|
||||||
export function KanbanBoard({
|
|
||||||
projects,
|
|
||||||
showArchived,
|
|
||||||
}: {
|
|
||||||
projects: ProjectListItem[];
|
|
||||||
showArchived: boolean;
|
|
||||||
}) {
|
|
||||||
const router = useRouter();
|
|
||||||
const [overrides, setOverrides] = useState<Record<string, ProjectStatus>>({});
|
|
||||||
const [activeId, setActiveId] = useState<string | null>(null);
|
|
||||||
|
|
||||||
// Eine Verschiebung, die der Server bestaetigt hat, braucht keine
|
|
||||||
// oertliche Ausnahme mehr.
|
|
||||||
useEffect(() => {
|
|
||||||
setOverrides((current) => {
|
|
||||||
const next: Record<string, ProjectStatus> = {};
|
|
||||||
for (const [id, status] of Object.entries(current)) {
|
|
||||||
const project = projects.find((entry) => entry.id === id);
|
|
||||||
if (project && project.status !== status) next[id] = status;
|
|
||||||
}
|
|
||||||
return Object.keys(next).length === Object.keys(current).length ? current : next;
|
|
||||||
});
|
|
||||||
}, [projects]);
|
|
||||||
|
|
||||||
const sensors = useSensors(
|
|
||||||
// Erst ab ein paar Pixeln Bewegung ziehen – sonst liesse sich die Karte
|
|
||||||
// nicht mehr anklicken.
|
|
||||||
useSensor(PointerSensor, { activationConstraint: { distance: 6 } }),
|
|
||||||
useSensor(TouchSensor, { activationConstraint: { delay: 180, tolerance: 8 } }),
|
|
||||||
);
|
|
||||||
|
|
||||||
const statusOf = (project: ProjectListItem) => overrides[project.id] ?? project.status;
|
|
||||||
|
|
||||||
const columns = useMemo(() => {
|
|
||||||
const visible = STATUS_ORDER.filter(
|
|
||||||
(status) => showArchived || status !== "ARCHIVED",
|
|
||||||
);
|
|
||||||
return visible.map((status) => ({
|
|
||||||
status,
|
|
||||||
items: projects.filter((project) => statusOf(project) === status),
|
|
||||||
}));
|
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
||||||
}, [projects, overrides, showArchived]);
|
|
||||||
|
|
||||||
const active = activeId ? projects.find((project) => project.id === activeId) : null;
|
|
||||||
|
|
||||||
function onDragStart(event: DragStartEvent) {
|
|
||||||
setActiveId(String(event.active.id));
|
|
||||||
}
|
|
||||||
|
|
||||||
async function onDragEnd(event: DragEndEvent) {
|
|
||||||
setActiveId(null);
|
|
||||||
|
|
||||||
const id = String(event.active.id);
|
|
||||||
const target = event.over?.id ? (String(event.over.id) as ProjectStatus) : null;
|
|
||||||
if (!target) return;
|
|
||||||
|
|
||||||
const project = projects.find((entry) => entry.id === id);
|
|
||||||
if (!project) return;
|
|
||||||
|
|
||||||
const previous = statusOf(project);
|
|
||||||
if (previous === target) return;
|
|
||||||
|
|
||||||
setOverrides((current) => ({ ...current, [id]: target }));
|
|
||||||
|
|
||||||
try {
|
|
||||||
const response = await fetch(`/api/projects/${id}`, {
|
|
||||||
method: "PATCH",
|
|
||||||
headers: { "Content-Type": "application/json" },
|
|
||||||
body: JSON.stringify({ status: target }),
|
|
||||||
});
|
|
||||||
if (!response.ok) throw new Error("failed");
|
|
||||||
router.refresh();
|
|
||||||
} catch {
|
|
||||||
setOverrides((current) => {
|
|
||||||
const next = { ...current };
|
|
||||||
delete next[id];
|
|
||||||
return next;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<DndContext
|
|
||||||
sensors={sensors}
|
|
||||||
collisionDetection={closestCorners}
|
|
||||||
modifiers={[restrictToWindowEdges]}
|
|
||||||
onDragStart={onDragStart}
|
|
||||||
onDragEnd={onDragEnd}
|
|
||||||
onDragCancel={() => setActiveId(null)}
|
|
||||||
>
|
|
||||||
<div className="flex gap-3 overflow-x-auto pb-3">
|
|
||||||
{columns.map((column) => (
|
|
||||||
<Column key={column.status} status={column.status} count={column.items.length}>
|
|
||||||
{column.items.map((project) => (
|
|
||||||
<KanbanCard key={project.id} project={project} />
|
|
||||||
))}
|
|
||||||
</Column>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Die mitgezogene Karte haengt am Cursor, nicht in der Spalte. */}
|
|
||||||
<DragOverlay dropAnimation={{ duration: 180, easing: "cubic-bezier(0.22, 1, 0.36, 1)" }}>
|
|
||||||
{active ? <KanbanCard project={active} overlay /> : null}
|
|
||||||
</DragOverlay>
|
|
||||||
</DndContext>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function Column({
|
|
||||||
status,
|
|
||||||
count,
|
|
||||||
children,
|
|
||||||
}: {
|
|
||||||
status: ProjectStatus;
|
|
||||||
count: number;
|
|
||||||
children: React.ReactNode;
|
|
||||||
}) {
|
|
||||||
const meta = STATUS_META[status];
|
|
||||||
const { setNodeRef, isOver } = useDroppable({ id: status });
|
|
||||||
|
|
||||||
return (
|
|
||||||
<section
|
|
||||||
ref={setNodeRef}
|
|
||||||
// Eindeutiger Anker fuer Tests und Automatisierung.
|
|
||||||
data-column={status}
|
|
||||||
className={cn(
|
|
||||||
"flex w-[17rem] shrink-0 flex-col rounded-2xl border border-white/6 bg-white/2 transition-colors",
|
|
||||||
isOver && "border-violet-400/40 bg-violet-500/6",
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<header className="flex items-center gap-2 px-3 py-2.5">
|
|
||||||
<span
|
|
||||||
className="accent-dot h-2 w-2 rounded-full"
|
|
||||||
style={{ backgroundColor: meta.color, color: meta.color }}
|
|
||||||
/>
|
|
||||||
<h3 className="text-xs font-semibold uppercase tracking-wider text-slate-300">
|
|
||||||
{meta.label}
|
|
||||||
</h3>
|
|
||||||
<span className="ml-auto rounded-full bg-white/6 px-1.5 py-0.5 text-[10px] tabular-nums text-slate-400">
|
|
||||||
{count}
|
|
||||||
</span>
|
|
||||||
</header>
|
|
||||||
|
|
||||||
<div className="flex min-h-[7rem] flex-1 flex-col gap-2 px-2 pb-2">
|
|
||||||
{children}
|
|
||||||
{count === 0 ? (
|
|
||||||
<p
|
|
||||||
className={cn(
|
|
||||||
"rounded-xl border border-dashed border-white/8 px-3 py-6 text-center text-[11px] text-slate-600 transition-colors",
|
|
||||||
isOver && "border-violet-400/40 text-violet-200",
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
{isOver ? "Hier ablegen" : "leer"}
|
|
||||||
</p>
|
|
||||||
) : null}
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function KanbanCard({
|
|
||||||
project,
|
|
||||||
overlay = false,
|
|
||||||
}: {
|
|
||||||
project: ProjectListItem;
|
|
||||||
overlay?: boolean;
|
|
||||||
}) {
|
|
||||||
const accent = accentOf(project.accent);
|
|
||||||
const { attributes, listeners, setNodeRef, isDragging } = useDraggable({ id: project.id });
|
|
||||||
|
|
||||||
return (
|
|
||||||
<article
|
|
||||||
ref={overlay ? undefined : setNodeRef}
|
|
||||||
className={cn(
|
|
||||||
"popover group relative overflow-hidden p-3",
|
|
||||||
// Das Original bleibt als blasser Platzhalter stehen.
|
|
||||||
isDragging && !overlay && "opacity-30",
|
|
||||||
overlay && "rotate-2 cursor-grabbing shadow-2xl ring-1 ring-violet-400/40",
|
|
||||||
)}
|
|
||||||
style={
|
|
||||||
{
|
|
||||||
"--accent-from": accent.from,
|
|
||||||
"--accent-to": accent.to,
|
|
||||||
} as React.CSSProperties
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<span className="accent-bar absolute inset-x-0 top-0 h-[2px] opacity-70" aria-hidden="true" />
|
|
||||||
|
|
||||||
<div className="flex items-start gap-2">
|
|
||||||
{/* Nur der Griff zieht – so bleibt der Titel ein normaler Link. */}
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="mt-0.5 shrink-0 cursor-grab touch-none rounded p-0.5 text-slate-600 transition-colors hover:text-slate-300 active:cursor-grabbing"
|
|
||||||
aria-label={`${project.name} verschieben`}
|
|
||||||
{...attributes}
|
|
||||||
{...listeners}
|
|
||||||
>
|
|
||||||
<GripVertical className="h-3.5 w-3.5" />
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<div className="min-w-0 flex-1">
|
|
||||||
<Link
|
|
||||||
href={`/projects/${project.id}`}
|
|
||||||
className="block truncate text-sm font-medium text-slate-100 hover:text-violet-200"
|
|
||||||
>
|
|
||||||
{project.name}
|
|
||||||
</Link>
|
|
||||||
{project.summary ? (
|
|
||||||
<p className="mt-0.5 line-clamp-2 text-[11px] leading-snug text-slate-500">
|
|
||||||
{truncate(project.summary, 90)}
|
|
||||||
</p>
|
|
||||||
) : null}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="mt-2.5 h-1 w-full overflow-hidden rounded-full bg-white/6">
|
|
||||||
<div
|
|
||||||
className="accent-bar h-full rounded-full"
|
|
||||||
style={{ width: `${Math.max(2, project.progress)}%` }}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="mt-2 flex flex-wrap items-center gap-x-2.5 gap-y-1 text-[10px] text-slate-500">
|
|
||||||
<CiBadge state={project.snapshot?.ciState} compact />
|
|
||||||
{project.snapshot?.defaultBranch ? (
|
|
||||||
<span className="inline-flex items-center gap-1 font-mono">
|
|
||||||
<GitBranch className="h-3 w-3" />
|
|
||||||
{project.snapshot.defaultBranch}
|
|
||||||
</span>
|
|
||||||
) : null}
|
|
||||||
{project._count.notes > 0 ? (
|
|
||||||
<span className="inline-flex items-center gap-1">
|
|
||||||
<NotebookPen className="h-3 w-3" />
|
|
||||||
{project._count.notes}
|
|
||||||
</span>
|
|
||||||
) : null}
|
|
||||||
<span className="ml-auto tabular-nums">{project.progress}%</span>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import ReactMarkdown from "react-markdown";
|
|
||||||
import remarkGfm from "remark-gfm";
|
|
||||||
import rehypeSanitize, { defaultSchema } from "rehype-sanitize";
|
|
||||||
import { cn } from "@/lib/utils";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Markdown-Darstellung fuer Beschreibungen und Notizen.
|
|
||||||
*
|
|
||||||
* Der Inhalt stammt vom Benutzer, wird aber unveraendert gerendert – ohne
|
|
||||||
* rehype-sanitize waere das ein XSS-Loch, sobald jemand rohes HTML in eine
|
|
||||||
* Notiz schreibt. Das Standardschema erlaubt nur harmlose Elemente; ergaenzt
|
|
||||||
* wird lediglich, was fuer Aufgabenlisten und Codebloecke noetig ist.
|
|
||||||
*/
|
|
||||||
const schema = {
|
|
||||||
...defaultSchema,
|
|
||||||
attributes: {
|
|
||||||
...defaultSchema.attributes,
|
|
||||||
// Checkboxen aus "- [ ] Aufgabe"
|
|
||||||
input: [...(defaultSchema.attributes?.input ?? []), "checked", "disabled", "type"],
|
|
||||||
// Sprachklassen wie "language-ts" fuer Codebloecke
|
|
||||||
code: [...(defaultSchema.attributes?.code ?? []), ["className", /^language-./]],
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
export function Markdown({
|
|
||||||
children,
|
|
||||||
className,
|
|
||||||
}: {
|
|
||||||
children: string | null | undefined;
|
|
||||||
className?: string;
|
|
||||||
}) {
|
|
||||||
if (!children?.trim()) return null;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className={cn("md", className)}>
|
|
||||||
<ReactMarkdown
|
|
||||||
remarkPlugins={[remarkGfm]}
|
|
||||||
rehypePlugins={[[rehypeSanitize, schema]]}
|
|
||||||
components={{
|
|
||||||
// Links aus fremdem Inhalt immer in neuem Tab und ohne
|
|
||||||
// Zugriff auf das oeffnende Fenster.
|
|
||||||
a: ({ href, children: content }) => (
|
|
||||||
<a href={href} target="_blank" rel="noreferrer noopener nofollow">
|
|
||||||
{content}
|
|
||||||
</a>
|
|
||||||
),
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{children}
|
|
||||||
</ReactMarkdown>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -4,7 +4,6 @@ import { useState } from "react";
|
|||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { Loader2, NotebookPen, Pencil, Pin, PinOff, Plus, Trash2, X } from "lucide-react";
|
import { Loader2, NotebookPen, Pencil, Pin, PinOff, Plus, Trash2, X } from "lucide-react";
|
||||||
import type { Note } from "@prisma/client";
|
import type { Note } from "@prisma/client";
|
||||||
import { Markdown } from "@/components/Markdown";
|
|
||||||
import { cn, formatDateTime, formatRelative } from "@/lib/utils";
|
import { cn, formatDateTime, formatRelative } from "@/lib/utils";
|
||||||
|
|
||||||
/** Nur als "bearbeitet" zaehlen, wenn wirklich spaeter geaendert wurde. */
|
/** Nur als "bearbeitet" zaehlen, wenn wirklich spaeter geaendert wurde. */
|
||||||
@@ -119,7 +118,7 @@ export function NotesPanel({ projectId, notes }: { projectId: string; notes: Not
|
|||||||
/>
|
/>
|
||||||
<textarea
|
<textarea
|
||||||
className="field min-h-32 resize-y font-mono text-[13px] leading-relaxed"
|
className="field min-h-32 resize-y font-mono text-[13px] leading-relaxed"
|
||||||
placeholder={"Gedanken, Todos, Snippets…\n\nMarkdown wird dargestellt:\n- [ ] offene Aufgabe\n**fett**, `code`, [Link](https://…)"}
|
placeholder="Gedanken, Todos, Snippets… Zeilenumbrueche bleiben erhalten."
|
||||||
value={content}
|
value={content}
|
||||||
onChange={(event) => setContent(event.target.value)}
|
onChange={(event) => setContent(event.target.value)}
|
||||||
autoFocus
|
autoFocus
|
||||||
@@ -162,7 +161,9 @@ export function NotesPanel({ projectId, notes }: { projectId: string; notes: Not
|
|||||||
{note.title}
|
{note.title}
|
||||||
</h3>
|
</h3>
|
||||||
) : null}
|
) : null}
|
||||||
<Markdown className="mt-1">{note.content}</Markdown>
|
<p className="mt-1 whitespace-pre-wrap break-words text-sm leading-relaxed text-slate-300">
|
||||||
|
{note.content}
|
||||||
|
</p>
|
||||||
<p className="mt-2.5 text-[11px] text-slate-600" suppressHydrationWarning>
|
<p className="mt-2.5 text-[11px] text-slate-600" suppressHydrationWarning>
|
||||||
{formatDateTime(note.createdAt)}
|
{formatDateTime(note.createdAt)}
|
||||||
{wasEdited(note) ? ` · bearbeitet ${formatRelative(note.updatedAt)}` : null}
|
{wasEdited(note) ? ` · bearbeitet ${formatRelative(note.updatedAt)}` : null}
|
||||||
|
|||||||
@@ -1,14 +1,11 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useEffect, useMemo, useRef, useState } from "react";
|
import { useMemo, useRef, useState } from "react";
|
||||||
import Link from "next/link";
|
|
||||||
import {
|
import {
|
||||||
Columns3,
|
|
||||||
Database,
|
Database,
|
||||||
Download,
|
Download,
|
||||||
LayoutGrid,
|
LayoutGrid,
|
||||||
ListFilter,
|
ListFilter,
|
||||||
NotebookPen,
|
|
||||||
Plus,
|
Plus,
|
||||||
Rows3,
|
Rows3,
|
||||||
Search,
|
Search,
|
||||||
@@ -17,7 +14,6 @@ import {
|
|||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import type { ProjectStatus } from "@prisma/client";
|
import type { ProjectStatus } from "@prisma/client";
|
||||||
import { ImportDialog } from "@/components/ImportDialog";
|
import { ImportDialog } from "@/components/ImportDialog";
|
||||||
import { KanbanBoard } from "@/components/KanbanBoard";
|
|
||||||
import { ProjectCard } from "@/components/ProjectCard";
|
import { ProjectCard } from "@/components/ProjectCard";
|
||||||
import { ProjectDialog } from "@/components/ProjectDialog";
|
import { ProjectDialog } from "@/components/ProjectDialog";
|
||||||
import { Popover } from "@/components/ui/Popover";
|
import { Popover } from "@/components/ui/Popover";
|
||||||
@@ -25,34 +21,8 @@ import { STATUS_META, STATUS_ORDER } from "@/lib/status";
|
|||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
import type { ConnectionSafe, ProjectListItem } from "@/types";
|
import type { ConnectionSafe, ProjectListItem } from "@/types";
|
||||||
|
|
||||||
interface NoteHit {
|
|
||||||
projectId: string;
|
|
||||||
noteId: string;
|
|
||||||
title: string | null;
|
|
||||||
/** Ausschnitt mit [[…]] um die Fundstelle – siehe /api/search. */
|
|
||||||
snippet: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Wandelt die [[…]]-Markierungen von ts_headline in hervorgehobene Stellen.
|
|
||||||
* Bewusst kein HTML aus der Datenbank einbetten – der Text stammt aus einer
|
|
||||||
* Notiz und damit vom Benutzer.
|
|
||||||
*/
|
|
||||||
function highlight(snippet: string): React.ReactNode[] {
|
|
||||||
return snippet.split(/(\[\[.*?\]\])/g).map((part, index) => {
|
|
||||||
if (part.startsWith("[[") && part.endsWith("]]")) {
|
|
||||||
return (
|
|
||||||
<mark key={index} className="rounded bg-violet-500/25 px-0.5 text-violet-100">
|
|
||||||
{part.slice(2, -2)}
|
|
||||||
</mark>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return <span key={index}>{part}</span>;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
type SortKey = "updated" | "created" | "name" | "progress" | "priority";
|
type SortKey = "updated" | "created" | "name" | "progress" | "priority";
|
||||||
type ViewMode = "grid" | "grouped" | "kanban";
|
type ViewMode = "grid" | "grouped";
|
||||||
|
|
||||||
const SORT_LABEL: Record<SortKey, string> = {
|
const SORT_LABEL: Record<SortKey, string> = {
|
||||||
updated: "Zuletzt geaendert",
|
updated: "Zuletzt geaendert",
|
||||||
@@ -78,45 +48,6 @@ export function ProjectBoard({
|
|||||||
const [importOpen, setImportOpen] = useState(false);
|
const [importOpen, setImportOpen] = useState(false);
|
||||||
const [dataMenuOpen, setDataMenuOpen] = useState(false);
|
const [dataMenuOpen, setDataMenuOpen] = useState(false);
|
||||||
const dataButtonRef = useRef<HTMLButtonElement>(null);
|
const dataButtonRef = useRef<HTMLButtonElement>(null);
|
||||||
const [noteHits, setNoteHits] = useState<NoteHit[]>([]);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Notizen liegen im Board nicht vor – sie mitzuladen wuerde die Seite
|
|
||||||
* unnoetig aufblaehen. Stattdessen sucht Postgres serverseitig, sobald der
|
|
||||||
* Begriff lang genug ist. Entprellt, damit nicht jeder Tastendruck eine
|
|
||||||
* Abfrage ausloest.
|
|
||||||
*/
|
|
||||||
useEffect(() => {
|
|
||||||
const needle = query.trim();
|
|
||||||
if (needle.length < 2) {
|
|
||||||
setNoteHits([]);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const controller = new AbortController();
|
|
||||||
const timer = setTimeout(async () => {
|
|
||||||
try {
|
|
||||||
const response = await fetch(`/api/search?q=${encodeURIComponent(needle)}`, {
|
|
||||||
signal: controller.signal,
|
|
||||||
});
|
|
||||||
if (!response.ok) return;
|
|
||||||
const body = (await response.json()) as { hits: NoteHit[] };
|
|
||||||
setNoteHits(body.hits ?? []);
|
|
||||||
} catch {
|
|
||||||
// Abgebrochene Anfragen sind der Normalfall beim Tippen.
|
|
||||||
}
|
|
||||||
}, 300);
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
clearTimeout(timer);
|
|
||||||
controller.abort();
|
|
||||||
};
|
|
||||||
}, [query]);
|
|
||||||
|
|
||||||
const noteHitProjectIds = useMemo(
|
|
||||||
() => new Set(noteHits.map((hit) => hit.projectId)),
|
|
||||||
[noteHits],
|
|
||||||
);
|
|
||||||
|
|
||||||
const counts = useMemo(() => {
|
const counts = useMemo(() => {
|
||||||
const map = new Map<ProjectStatus, number>();
|
const map = new Map<ProjectStatus, number>();
|
||||||
@@ -140,9 +71,7 @@ export function ProjectBoard({
|
|||||||
(project.summary ?? "").toLowerCase().includes(needle) ||
|
(project.summary ?? "").toLowerCase().includes(needle) ||
|
||||||
(project.description ?? "").toLowerCase().includes(needle) ||
|
(project.description ?? "").toLowerCase().includes(needle) ||
|
||||||
project.tags.some((tag) => tag.includes(needle)) ||
|
project.tags.some((tag) => tag.includes(needle)) ||
|
||||||
(project.snapshot?.fullName ?? "").toLowerCase().includes(needle) ||
|
(project.snapshot?.fullName ?? "").toLowerCase().includes(needle)
|
||||||
// Treffer in Notizen kommen vom Server dazu.
|
|
||||||
noteHitProjectIds.has(project.id)
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -163,7 +92,7 @@ export function ProjectBoard({
|
|||||||
});
|
});
|
||||||
|
|
||||||
return sorted;
|
return sorted;
|
||||||
}, [projects, query, statusFilter, sort, showArchived, noteHitProjectIds]);
|
}, [projects, query, statusFilter, sort, showArchived]);
|
||||||
|
|
||||||
const grouped = useMemo(() => {
|
const grouped = useMemo(() => {
|
||||||
return STATUS_ORDER.map((status) => ({
|
return STATUS_ORDER.map((status) => ({
|
||||||
@@ -249,18 +178,6 @@ export function ProjectBoard({
|
|||||||
>
|
>
|
||||||
<Rows3 className="h-4 w-4" />
|
<Rows3 className="h-4 w-4" />
|
||||||
</button>
|
</button>
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
onClick={() => setView("kanban")}
|
|
||||||
className={cn(
|
|
||||||
"p-2 transition-colors",
|
|
||||||
view === "kanban" ? "bg-white/10 text-white" : "text-slate-500 hover:text-white",
|
|
||||||
)}
|
|
||||||
aria-label="Kanban-Spalten"
|
|
||||||
title="Kanban – Status per Ziehen aendern"
|
|
||||||
>
|
|
||||||
<Columns3 className="h-4 w-4" />
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
@@ -339,54 +256,9 @@ export function ProjectBoard({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Treffer in Notizen */}
|
|
||||||
{noteHits.length > 0 ? (
|
|
||||||
<div className="glass fade-up p-4">
|
|
||||||
<h2 className="mb-2.5 flex items-center gap-2 text-[11px] font-semibold uppercase tracking-wider text-slate-400">
|
|
||||||
<NotebookPen className="h-3.5 w-3.5 text-violet-300" />
|
|
||||||
Treffer in Notizen
|
|
||||||
<span className="rounded-full bg-white/6 px-2 py-0.5 tabular-nums text-slate-400">
|
|
||||||
{noteHits.length}
|
|
||||||
</span>
|
|
||||||
</h2>
|
|
||||||
<ul className="space-y-1">
|
|
||||||
{noteHits.slice(0, 8).map((hit) => {
|
|
||||||
const project = projects.find((entry) => entry.id === hit.projectId);
|
|
||||||
return (
|
|
||||||
<li key={hit.noteId}>
|
|
||||||
<Link
|
|
||||||
href={`/projects/${hit.projectId}`}
|
|
||||||
className="block rounded-lg px-2.5 py-2 transition-colors hover:bg-white/5"
|
|
||||||
>
|
|
||||||
<span className="flex flex-wrap items-baseline gap-x-2">
|
|
||||||
<span className="text-sm text-slate-200">
|
|
||||||
{project?.name ?? "Projekt"}
|
|
||||||
</span>
|
|
||||||
{hit.title ? (
|
|
||||||
<span className="text-[11px] text-slate-500">· {hit.title}</span>
|
|
||||||
) : null}
|
|
||||||
</span>
|
|
||||||
<span className="mt-0.5 block text-xs leading-snug text-slate-400">
|
|
||||||
{highlight(hit.snippet)}
|
|
||||||
</span>
|
|
||||||
</Link>
|
|
||||||
</li>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</ul>
|
|
||||||
{noteHits.length > 8 ? (
|
|
||||||
<p className="mt-2 px-2.5 text-[11px] text-slate-600">
|
|
||||||
… und {noteHits.length - 8} weitere
|
|
||||||
</p>
|
|
||||||
) : null}
|
|
||||||
</div>
|
|
||||||
) : null}
|
|
||||||
|
|
||||||
{/* Inhalt */}
|
{/* Inhalt */}
|
||||||
{visible.length === 0 ? (
|
{visible.length === 0 ? (
|
||||||
<EmptyState hasFilters={hasFilters} onCreate={() => setDialogOpen(true)} />
|
<EmptyState hasFilters={hasFilters} onCreate={() => setDialogOpen(true)} />
|
||||||
) : view === "kanban" ? (
|
|
||||||
<KanbanBoard projects={visible} showArchived={showArchived} />
|
|
||||||
) : view === "grid" ? (
|
) : view === "grid" ? (
|
||||||
<div className="grid gap-4 sm:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4">
|
<div className="grid gap-4 sm:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4">
|
||||||
{visible.map((project, index) => (
|
{visible.map((project, index) => (
|
||||||
|
|||||||
@@ -10,12 +10,10 @@ import {
|
|||||||
Star,
|
Star,
|
||||||
Tag,
|
Tag,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { CiBadge } from "@/components/CiBadge";
|
|
||||||
import { Sparkline } from "@/components/Sparkline";
|
|
||||||
import { StatusSelect } from "@/components/StatusSelect";
|
import { StatusSelect } from "@/components/StatusSelect";
|
||||||
import { PRIORITY_META, accentOf } from "@/lib/status";
|
import { PRIORITY_META, accentOf } from "@/lib/status";
|
||||||
import { cn, formatRelative, truncate } from "@/lib/utils";
|
import { cn, formatRelative, truncate } from "@/lib/utils";
|
||||||
import { asArray, type ProjectListItem } from "@/types";
|
import type { ProjectListItem } from "@/types";
|
||||||
|
|
||||||
const PROVIDER_LABEL: Record<string, string> = {
|
const PROVIDER_LABEL: Record<string, string> = {
|
||||||
GITHUB: "GitHub",
|
GITHUB: "GitHub",
|
||||||
@@ -31,7 +29,6 @@ export function ProjectCard({ project, index = 0 }: { project: ProjectListItem;
|
|||||||
const accent = accentOf(project.accent);
|
const accent = accentOf(project.accent);
|
||||||
const priority = PRIORITY_META[project.priority] ?? PRIORITY_META[2];
|
const priority = PRIORITY_META[project.priority] ?? PRIORITY_META[2];
|
||||||
const snapshot = project.snapshot;
|
const snapshot = project.snapshot;
|
||||||
const activity = asArray<number>(snapshot?.commitActivity);
|
|
||||||
const [favorite, setFavorite] = useState(project.favorite);
|
const [favorite, setFavorite] = useState(project.favorite);
|
||||||
|
|
||||||
async function toggleFavorite() {
|
async function toggleFavorite() {
|
||||||
@@ -113,17 +110,8 @@ export function ProjectCard({ project, index = 0 }: { project: ProjectListItem;
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Commit-Aktivitaet */}
|
|
||||||
{activity.some((value) => value > 0) ? (
|
|
||||||
<div className="mt-3">
|
|
||||||
<Sparkline values={activity} height={20} />
|
|
||||||
</div>
|
|
||||||
) : null}
|
|
||||||
|
|
||||||
{/* Git-Kurzinfo */}
|
{/* Git-Kurzinfo */}
|
||||||
<div className="mt-4 flex flex-wrap items-center gap-x-3 gap-y-2 text-[11px] text-slate-400">
|
<div className="mt-4 flex flex-wrap items-center gap-x-3 gap-y-2 text-[11px] text-slate-400">
|
||||||
<CiBadge state={snapshot?.ciState} name={snapshot?.ciName} compact />
|
|
||||||
|
|
||||||
{project.connection ? (
|
{project.connection ? (
|
||||||
<span className="glass-soft inline-flex items-center gap-1.5 px-2 py-1">
|
<span className="glass-soft inline-flex items-center gap-1.5 px-2 py-1">
|
||||||
<span className="h-1.5 w-1.5 rounded-full bg-violet-400" aria-hidden="true" />
|
<span className="h-1.5 w-1.5 rounded-full bg-violet-400" aria-hidden="true" />
|
||||||
|
|||||||
@@ -1,57 +0,0 @@
|
|||||||
import { cn } from "@/lib/utils";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Commit-Aktivitaet als kleine Balkenreihe.
|
|
||||||
*
|
|
||||||
* Bewusst als reines SVG ohne Diagrammbibliothek: es sind dreissig Werte,
|
|
||||||
* die Achsen, Legende und Tooltips einer Bibliothek waeren hier nur Ballast.
|
|
||||||
*/
|
|
||||||
export function Sparkline({
|
|
||||||
values,
|
|
||||||
className,
|
|
||||||
height = 28,
|
|
||||||
label = "Commits",
|
|
||||||
}: {
|
|
||||||
values: number[];
|
|
||||||
className?: string;
|
|
||||||
height?: number;
|
|
||||||
label?: string;
|
|
||||||
}) {
|
|
||||||
if (!values.length) return null;
|
|
||||||
|
|
||||||
const total = values.reduce((sum, value) => sum + value, 0);
|
|
||||||
if (total === 0) return null;
|
|
||||||
|
|
||||||
const max = Math.max(...values);
|
|
||||||
const gap = 1;
|
|
||||||
const barWidth = 3;
|
|
||||||
const width = values.length * (barWidth + gap) - gap;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<svg
|
|
||||||
viewBox={`0 0 ${width} ${height}`}
|
|
||||||
preserveAspectRatio="none"
|
|
||||||
className={cn("w-full", className)}
|
|
||||||
style={{ height }}
|
|
||||||
role="img"
|
|
||||||
aria-label={`${label} der letzten ${values.length} Tage: insgesamt ${total}`}
|
|
||||||
>
|
|
||||||
<title>{`${label} der letzten ${values.length} Tage: insgesamt ${total}`}</title>
|
|
||||||
{values.map((value, index) => {
|
|
||||||
// Auch ein einzelner Commit soll sichtbar sein, daher die Untergrenze.
|
|
||||||
const barHeight = value === 0 ? 1.5 : Math.max(3, (value / max) * height);
|
|
||||||
return (
|
|
||||||
<rect
|
|
||||||
key={index}
|
|
||||||
x={index * (barWidth + gap)}
|
|
||||||
y={height - barHeight}
|
|
||||||
width={barWidth}
|
|
||||||
height={barHeight}
|
|
||||||
rx={1}
|
|
||||||
className={value === 0 ? "fill-white/10" : "fill-violet-400/80"}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</svg>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
import { describe, expect, it } from "vitest";
|
|
||||||
import { PASSWORD_MIN_LENGTH } from "./constants";
|
|
||||||
import { hashPassword, validatePasswordStrength, verifyPassword } from "./password";
|
|
||||||
|
|
||||||
describe("hashPassword und verifyPassword", () => {
|
|
||||||
it("erkennt das richtige Passwort wieder", async () => {
|
|
||||||
const hash = await hashPassword("ein-langes-testpasswort");
|
|
||||||
await expect(verifyPassword("ein-langes-testpasswort", hash)).resolves.toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("weist ein falsches Passwort ab", async () => {
|
|
||||||
const hash = await hashPassword("ein-langes-testpasswort");
|
|
||||||
await expect(verifyPassword("etwas-anderes", hash)).resolves.toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("erzeugt fuer dasselbe Passwort unterschiedliche Hashes", async () => {
|
|
||||||
// Unterschiedliches Salz – sonst waere an gleichen Hashes ablesbar,
|
|
||||||
// wer dasselbe Passwort benutzt.
|
|
||||||
const a = await hashPassword("ein-langes-testpasswort");
|
|
||||||
const b = await hashPassword("ein-langes-testpasswort");
|
|
||||||
expect(a).not.toBe(b);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("haelt das erwartete Ablageformat ein", async () => {
|
|
||||||
const hash = await hashPassword("ein-langes-testpasswort");
|
|
||||||
expect(hash).toMatch(/^scrypt\$\d+\$\d+\$\d+\$[\w-]+\$[\w-]+$/);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("stuerzt bei kaputten oder fehlenden Hashes nicht ab", async () => {
|
|
||||||
await expect(verifyPassword("x", null)).resolves.toBe(false);
|
|
||||||
await expect(verifyPassword("x", "")).resolves.toBe(false);
|
|
||||||
await expect(verifyPassword("x", "voelliger-unsinn")).resolves.toBe(false);
|
|
||||||
await expect(verifyPassword("x", "scrypt$a$b$c$d$e")).resolves.toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("behandelt gleichwertige Unicode-Schreibweisen gleich", async () => {
|
|
||||||
// "é" als ein Zeichen und als e + Akzent kombiniert.
|
|
||||||
const hash = await hashPassword("passwort-café-lang");
|
|
||||||
await expect(verifyPassword("passwort-café-lang", hash)).resolves.toBe(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("validatePasswordStrength", () => {
|
|
||||||
it("nimmt ein ausreichend langes Passwort an", () => {
|
|
||||||
expect(validatePasswordStrength("ein-langes-testpasswort")).toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("weist zu kurze Passwoerter ab", () => {
|
|
||||||
expect(validatePasswordStrength("a".repeat(PASSWORD_MIN_LENGTH - 1))).toMatch(
|
|
||||||
/mindestens/,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("weist naheliegende Passwoerter ab", () => {
|
|
||||||
expect(validatePasswordStrength("password")).toBeTruthy();
|
|
||||||
expect(validatePasswordStrength("Passwort")).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("weist reine Ziffernfolgen ab", () => {
|
|
||||||
expect(validatePasswordStrength("1234567890123")).toMatch(/Ziffern/);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("weist uebermaessig lange Passwoerter ab", () => {
|
|
||||||
expect(validatePasswordStrength("a".repeat(300))).toMatch(/hoechstens/);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -12,12 +12,6 @@ function trimmed(value: string | undefined): string | null {
|
|||||||
return result ? result : null;
|
return result ? result : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Version aus der package.json – eine einzige Quelle. Vorher stand sie
|
|
||||||
* zusaetzlich in der Fusszeile und lief prompt auseinander.
|
|
||||||
*/
|
|
||||||
export { version as APP_VERSION } from "../../package.json";
|
|
||||||
|
|
||||||
/** Anzeigename der Instanz – Seitentitel, Kopfzeile, Passkey-Dialog. */
|
/** Anzeigename der Instanz – Seitentitel, Kopfzeile, Passkey-Dialog. */
|
||||||
export const APP_NAME = trimmed(process.env.APP_NAME) ?? "Nebula";
|
export const APP_NAME = trimmed(process.env.APP_NAME) ?? "Nebula";
|
||||||
|
|
||||||
|
|||||||
+10
-111
@@ -1,8 +1,6 @@
|
|||||||
import { getJson, getJsonSafe, normalizeBaseUrl, shortSha, toIso } from "./http";
|
import { getJson, getJsonSafe, normalizeBaseUrl, shortSha, toIso } from "./http";
|
||||||
import type {
|
import type {
|
||||||
BranchInfo,
|
BranchInfo,
|
||||||
CiInfo,
|
|
||||||
CiState,
|
|
||||||
CommitInfo,
|
CommitInfo,
|
||||||
ConnectionCheck,
|
ConnectionCheck,
|
||||||
GitClient,
|
GitClient,
|
||||||
@@ -12,9 +10,7 @@ import type {
|
|||||||
RepoRef,
|
RepoRef,
|
||||||
RepoSnapshotData,
|
RepoSnapshotData,
|
||||||
TagInfo,
|
TagInfo,
|
||||||
TicketInfo,
|
|
||||||
} from "./types";
|
} from "./types";
|
||||||
import { bucketCommitActivity } from "./types";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gitea (und kompatible Forks wie Forgejo) – API v1.
|
* Gitea (und kompatible Forks wie Forgejo) – API v1.
|
||||||
@@ -99,33 +95,14 @@ export class GiteaClient implements GitClient {
|
|||||||
|
|
||||||
const repo = await getJson<GiteaRepo>(base, { headers });
|
const repo = await getJson<GiteaRepo>(base, { headers });
|
||||||
|
|
||||||
const defaultBranch = repo.default_branch ?? "";
|
const [branches, tags, commits, releases, languages, pulls] = await Promise.all([
|
||||||
|
getJsonSafe<GiteaBranch[]>(`${base}/branches?limit=50`, [], { headers }),
|
||||||
const [branches, tags, commits, releases, languages, pulls, issues, status] =
|
getJsonSafe<GiteaTag[]>(`${base}/tags?limit=25`, [], { headers }),
|
||||||
await Promise.all([
|
getJsonSafe<GiteaCommit[]>(`${base}/commits?limit=15&stat=false`, [], { headers }),
|
||||||
getJsonSafe<GiteaBranch[]>(`${base}/branches?limit=50`, [], { headers }),
|
getJsonSafe<GiteaRelease[]>(`${base}/releases?limit=10`, [], { headers }),
|
||||||
getJsonSafe<GiteaTag[]>(`${base}/tags?limit=25`, [], { headers }),
|
getJsonSafe<Record<string, number>>(`${base}/languages`, {}, { headers }),
|
||||||
// 100 statt 15: die aelteren brauchen wir fuer die Aktivitaetskurve.
|
getJsonSafe<GiteaPull[]>(`${base}/pulls?state=open&limit=100`, [], { headers }),
|
||||||
getJsonSafe<GiteaCommit[]>(`${base}/commits?limit=100&stat=false`, [], { headers }),
|
]);
|
||||||
getJsonSafe<GiteaRelease[]>(`${base}/releases?limit=10`, [], { headers }),
|
|
||||||
getJsonSafe<Record<string, number>>(`${base}/languages`, {}, { headers }),
|
|
||||||
getJsonSafe<GiteaPull[]>(`${base}/pulls?state=open&limit=50`, [], { headers }),
|
|
||||||
// type=issues, sonst kommen bei Gitea die Pull Requests mit.
|
|
||||||
getJsonSafe<GiteaIssue[]>(`${base}/issues?state=open&type=issues&limit=50`, [], {
|
|
||||||
headers,
|
|
||||||
}),
|
|
||||||
// Gitea meldet CI-Ergebnisse als Commit-Status. Das deckt Gitea
|
|
||||||
// Actions und externe Systeme wie Woodpecker gleichermassen ab –
|
|
||||||
// anders als ein reiner Actions-Endpunkt, den aeltere Instanzen
|
|
||||||
// ohnehin nicht kennen.
|
|
||||||
defaultBranch
|
|
||||||
? getJsonSafe<GiteaCombinedStatus>(
|
|
||||||
`${base}/commits/${encodeURIComponent(defaultBranch)}/status`,
|
|
||||||
{} as GiteaCombinedStatus,
|
|
||||||
{ headers },
|
|
||||||
)
|
|
||||||
: Promise.resolve({} as GiteaCombinedStatus),
|
|
||||||
]);
|
|
||||||
|
|
||||||
const mappedBranches: BranchInfo[] = branches.map((branch) => ({
|
const mappedBranches: BranchInfo[] = branches.map((branch) => ({
|
||||||
name: branch.name,
|
name: branch.name,
|
||||||
@@ -164,38 +141,6 @@ export class GiteaClient implements GitClient {
|
|||||||
draft: Boolean(release.draft),
|
draft: Boolean(release.draft),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const mappedPulls: TicketInfo[] = pulls.map((pull) => ({
|
|
||||||
number: pull.number,
|
|
||||||
title: pull.title,
|
|
||||||
author: pull.user?.login ?? null,
|
|
||||||
createdAt: toIso(pull.created_at),
|
|
||||||
url: pull.html_url ?? null,
|
|
||||||
draft: Boolean(pull.draft),
|
|
||||||
labels: (pull.labels ?? []).map((label) => label.name),
|
|
||||||
}));
|
|
||||||
|
|
||||||
const mappedIssues: TicketInfo[] = issues.map((issue) => ({
|
|
||||||
number: issue.number,
|
|
||||||
title: issue.title,
|
|
||||||
author: issue.user?.login ?? null,
|
|
||||||
createdAt: toIso(issue.created_at),
|
|
||||||
url: issue.html_url ?? null,
|
|
||||||
draft: false,
|
|
||||||
labels: (issue.labels ?? []).map((label) => label.name),
|
|
||||||
}));
|
|
||||||
|
|
||||||
const latestStatus = status?.statuses?.[0];
|
|
||||||
const ci: CiInfo | null =
|
|
||||||
status?.state && status.state !== "" && status.statuses?.length
|
|
||||||
? {
|
|
||||||
state: mapCommitStatus(status.state),
|
|
||||||
name: latestStatus?.context ?? null,
|
|
||||||
branch: defaultBranch || null,
|
|
||||||
url: latestStatus?.target_url ?? null,
|
|
||||||
finishedAt: toIso(latestStatus?.updated_at),
|
|
||||||
}
|
|
||||||
: null;
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
fullName: repo.full_name,
|
fullName: repo.full_name,
|
||||||
description: repo.description ?? null,
|
description: repo.description ?? null,
|
||||||
@@ -210,31 +155,13 @@ export class GiteaClient implements GitClient {
|
|||||||
pushedAt: toIso(repo.updated_at),
|
pushedAt: toIso(repo.updated_at),
|
||||||
branches: mappedBranches,
|
branches: mappedBranches,
|
||||||
tags: mappedTags,
|
tags: mappedTags,
|
||||||
commits: mappedCommits.slice(0, 15),
|
commits: mappedCommits,
|
||||||
releases: mappedReleases,
|
releases: mappedReleases,
|
||||||
languages: languages ?? {},
|
languages: languages ?? {},
|
||||||
pullRequests: mappedPulls,
|
|
||||||
issues: mappedIssues,
|
|
||||||
ci,
|
|
||||||
commitActivity: bucketCommitActivity(mappedCommits.map((commit) => commit.date)),
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function mapCommitStatus(state: string): CiState {
|
|
||||||
switch (state) {
|
|
||||||
case "success":
|
|
||||||
return "success";
|
|
||||||
case "pending":
|
|
||||||
return "running";
|
|
||||||
case "failure":
|
|
||||||
case "error":
|
|
||||||
return "failure";
|
|
||||||
default:
|
|
||||||
return "pending";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ── API-Typen ──────────────────────────────────────────────────
|
// ── API-Typen ──────────────────────────────────────────────────
|
||||||
|
|
||||||
interface GiteaRepo {
|
interface GiteaRepo {
|
||||||
@@ -293,34 +220,6 @@ interface GiteaRelease {
|
|||||||
draft: boolean;
|
draft: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface GiteaLabel {
|
|
||||||
name: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface GiteaPull {
|
interface GiteaPull {
|
||||||
number: number;
|
id: number;
|
||||||
title: string;
|
|
||||||
html_url: string | null;
|
|
||||||
created_at: string | null;
|
|
||||||
draft?: boolean;
|
|
||||||
user?: { login: string } | null;
|
|
||||||
labels?: GiteaLabel[];
|
|
||||||
}
|
|
||||||
|
|
||||||
interface GiteaIssue {
|
|
||||||
number: number;
|
|
||||||
title: string;
|
|
||||||
html_url: string | null;
|
|
||||||
created_at: string | null;
|
|
||||||
user?: { login: string } | null;
|
|
||||||
labels?: GiteaLabel[];
|
|
||||||
}
|
|
||||||
|
|
||||||
interface GiteaCombinedStatus {
|
|
||||||
state?: string;
|
|
||||||
statuses?: Array<{
|
|
||||||
context?: string;
|
|
||||||
target_url?: string;
|
|
||||||
updated_at?: string;
|
|
||||||
}>;
|
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-111
@@ -1,8 +1,6 @@
|
|||||||
import { getJson, getJsonSafe, normalizeBaseUrl, shortSha, toIso } from "./http";
|
import { getJson, getJsonSafe, normalizeBaseUrl, shortSha, toIso } from "./http";
|
||||||
import type {
|
import type {
|
||||||
BranchInfo,
|
BranchInfo,
|
||||||
CiInfo,
|
|
||||||
CiState,
|
|
||||||
CommitInfo,
|
CommitInfo,
|
||||||
ConnectionCheck,
|
ConnectionCheck,
|
||||||
GitClient,
|
GitClient,
|
||||||
@@ -12,9 +10,8 @@ import type {
|
|||||||
RepoRef,
|
RepoRef,
|
||||||
RepoSnapshotData,
|
RepoSnapshotData,
|
||||||
TagInfo,
|
TagInfo,
|
||||||
TicketInfo,
|
|
||||||
} from "./types";
|
} from "./types";
|
||||||
import { GitApiError, bucketCommitActivity } from "./types";
|
import { GitApiError } from "./types";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GitHub – funktioniert mit github.com und GitHub Enterprise.
|
* GitHub – funktioniert mit github.com und GitHub Enterprise.
|
||||||
@@ -88,25 +85,14 @@ export class GitHubClient implements GitClient {
|
|||||||
|
|
||||||
const repo = await getJson<GitHubRepo>(base, { headers });
|
const repo = await getJson<GitHubRepo>(base, { headers });
|
||||||
|
|
||||||
const defaultBranch = repo.default_branch;
|
const [branches, tags, commits, releases, languages, pulls] = await Promise.all([
|
||||||
|
getJsonSafe<GitHubBranch[]>(`${base}/branches?per_page=50`, [], { headers }),
|
||||||
const [branches, tags, commits, releases, languages, pulls, issues, ciRuns] =
|
getJsonSafe<GitHubTag[]>(`${base}/tags?per_page=25`, [], { headers }),
|
||||||
await Promise.all([
|
getJsonSafe<GitHubCommit[]>(`${base}/commits?per_page=15`, [], { headers }),
|
||||||
getJsonSafe<GitHubBranch[]>(`${base}/branches?per_page=50`, [], { headers }),
|
getJsonSafe<GitHubRelease[]>(`${base}/releases?per_page=10`, [], { headers }),
|
||||||
getJsonSafe<GitHubTag[]>(`${base}/tags?per_page=25`, [], { headers }),
|
getJsonSafe<Record<string, number>>(`${base}/languages`, {}, { headers }),
|
||||||
// 100 statt 15: die aelteren brauchen wir fuer die Aktivitaetskurve.
|
getJsonSafe<GitHubPull[]>(`${base}/pulls?state=open&per_page=100`, [], { headers }),
|
||||||
getJsonSafe<GitHubCommit[]>(`${base}/commits?per_page=100`, [], { headers }),
|
]);
|
||||||
getJsonSafe<GitHubRelease[]>(`${base}/releases?per_page=10`, [], { headers }),
|
|
||||||
getJsonSafe<Record<string, number>>(`${base}/languages`, {}, { headers }),
|
|
||||||
getJsonSafe<GitHubPull[]>(`${base}/pulls?state=open&per_page=50`, [], { headers }),
|
|
||||||
// /issues liefert bei GitHub auch Pull Requests – die filtern wir raus.
|
|
||||||
getJsonSafe<GitHubIssue[]>(`${base}/issues?state=open&per_page=50`, [], { headers }),
|
|
||||||
getJsonSafe<{ workflow_runs?: GitHubRun[] }>(
|
|
||||||
`${base}/actions/runs?per_page=1&branch=${encodeURIComponent(defaultBranch)}`,
|
|
||||||
{},
|
|
||||||
{ headers },
|
|
||||||
),
|
|
||||||
]);
|
|
||||||
|
|
||||||
const mappedBranches: BranchInfo[] = branches.map((branch) => ({
|
const mappedBranches: BranchInfo[] = branches.map((branch) => ({
|
||||||
name: branch.name,
|
name: branch.name,
|
||||||
@@ -145,43 +131,10 @@ export class GitHubClient implements GitClient {
|
|||||||
draft: Boolean(release.draft),
|
draft: Boolean(release.draft),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const mappedPulls: TicketInfo[] = pulls.map((pull) => ({
|
|
||||||
number: pull.number,
|
|
||||||
title: pull.title,
|
|
||||||
author: pull.user?.login ?? null,
|
|
||||||
createdAt: toIso(pull.created_at),
|
|
||||||
url: pull.html_url ?? null,
|
|
||||||
draft: Boolean(pull.draft),
|
|
||||||
labels: (pull.labels ?? []).map((label) => label.name),
|
|
||||||
}));
|
|
||||||
|
|
||||||
const mappedIssues: TicketInfo[] = issues
|
|
||||||
.filter((issue) => !issue.pull_request)
|
|
||||||
.map((issue) => ({
|
|
||||||
number: issue.number,
|
|
||||||
title: issue.title,
|
|
||||||
author: issue.user?.login ?? null,
|
|
||||||
createdAt: toIso(issue.created_at),
|
|
||||||
url: issue.html_url ?? null,
|
|
||||||
draft: false,
|
|
||||||
labels: (issue.labels ?? []).map((label) => label.name),
|
|
||||||
}));
|
|
||||||
|
|
||||||
// open_issues_count zaehlt bei GitHub PRs mit – hier wieder herausrechnen.
|
// open_issues_count zaehlt bei GitHub PRs mit – hier wieder herausrechnen.
|
||||||
const openPullRequests = pulls.length;
|
const openPullRequests = pulls.length;
|
||||||
const openIssues = Math.max(0, (repo.open_issues_count ?? 0) - openPullRequests);
|
const openIssues = Math.max(0, (repo.open_issues_count ?? 0) - openPullRequests);
|
||||||
|
|
||||||
const run = ciRuns?.workflow_runs?.[0];
|
|
||||||
const ci: CiInfo | null = run
|
|
||||||
? {
|
|
||||||
state: mapRunState(run.status, run.conclusion),
|
|
||||||
name: run.name ?? null,
|
|
||||||
branch: run.head_branch ?? null,
|
|
||||||
url: run.html_url ?? null,
|
|
||||||
finishedAt: toIso(run.updated_at),
|
|
||||||
}
|
|
||||||
: null;
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
fullName: repo.full_name,
|
fullName: repo.full_name,
|
||||||
description: repo.description ?? null,
|
description: repo.description ?? null,
|
||||||
@@ -196,36 +149,13 @@ export class GitHubClient implements GitClient {
|
|||||||
pushedAt: toIso(repo.pushed_at),
|
pushedAt: toIso(repo.pushed_at),
|
||||||
branches: mappedBranches,
|
branches: mappedBranches,
|
||||||
tags: mappedTags,
|
tags: mappedTags,
|
||||||
// Angezeigt werden die letzten 15; die uebrigen dienten der Kurve.
|
commits: mappedCommits,
|
||||||
commits: mappedCommits.slice(0, 15),
|
|
||||||
releases: mappedReleases,
|
releases: mappedReleases,
|
||||||
languages: languages ?? {},
|
languages: languages ?? {},
|
||||||
pullRequests: mappedPulls,
|
|
||||||
issues: mappedIssues,
|
|
||||||
ci,
|
|
||||||
commitActivity: bucketCommitActivity(mappedCommits.map((commit) => commit.date)),
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** GitHub trennt Lauf-Status und Ergebnis; hier auf einen Wert zusammenfuehren. */
|
|
||||||
function mapRunState(status: string | null, conclusion: string | null): CiState {
|
|
||||||
if (status === "queued" || status === "waiting" || status === "pending") return "pending";
|
|
||||||
if (status === "in_progress") return "running";
|
|
||||||
switch (conclusion) {
|
|
||||||
case "success":
|
|
||||||
return "success";
|
|
||||||
case "cancelled":
|
|
||||||
return "cancelled";
|
|
||||||
case "failure":
|
|
||||||
case "timed_out":
|
|
||||||
case "startup_failure":
|
|
||||||
return "failure";
|
|
||||||
default:
|
|
||||||
return conclusion ? "failure" : "pending";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ── API-Typen (nur die tatsaechlich genutzten Felder) ──────────
|
// ── API-Typen (nur die tatsaechlich genutzten Felder) ──────────
|
||||||
|
|
||||||
interface GitHubRepo {
|
interface GitHubRepo {
|
||||||
@@ -276,36 +206,6 @@ interface GitHubRelease {
|
|||||||
draft: boolean;
|
draft: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface GitHubLabel {
|
|
||||||
name: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface GitHubPull {
|
interface GitHubPull {
|
||||||
number: number;
|
id: number;
|
||||||
title: string;
|
|
||||||
html_url: string | null;
|
|
||||||
created_at: string | null;
|
|
||||||
draft?: boolean;
|
|
||||||
user?: { login: string } | null;
|
|
||||||
labels?: GitHubLabel[];
|
|
||||||
}
|
|
||||||
|
|
||||||
interface GitHubIssue {
|
|
||||||
number: number;
|
|
||||||
title: string;
|
|
||||||
html_url: string | null;
|
|
||||||
created_at: string | null;
|
|
||||||
user?: { login: string } | null;
|
|
||||||
labels?: GitHubLabel[];
|
|
||||||
/** Gesetzt, wenn der Eintrag in Wahrheit ein Pull Request ist. */
|
|
||||||
pull_request?: unknown;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface GitHubRun {
|
|
||||||
name: string | null;
|
|
||||||
status: string | null;
|
|
||||||
conclusion: string | null;
|
|
||||||
head_branch: string | null;
|
|
||||||
html_url: string | null;
|
|
||||||
updated_at: string | null;
|
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-100
@@ -1,8 +1,6 @@
|
|||||||
import { getJson, getJsonSafe, normalizeBaseUrl, shortSha, toIso } from "./http";
|
import { getJson, getJsonSafe, normalizeBaseUrl, shortSha, toIso } from "./http";
|
||||||
import type {
|
import type {
|
||||||
BranchInfo,
|
BranchInfo,
|
||||||
CiInfo,
|
|
||||||
CiState,
|
|
||||||
CommitInfo,
|
CommitInfo,
|
||||||
ConnectionCheck,
|
ConnectionCheck,
|
||||||
GitClient,
|
GitClient,
|
||||||
@@ -12,9 +10,7 @@ import type {
|
|||||||
RepoRef,
|
RepoRef,
|
||||||
RepoSnapshotData,
|
RepoSnapshotData,
|
||||||
TagInfo,
|
TagInfo,
|
||||||
TicketInfo,
|
|
||||||
} from "./types";
|
} from "./types";
|
||||||
import { bucketCommitActivity } from "./types";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GitLab – gitlab.com und selbst gehostete Instanzen (API v4).
|
* GitLab – gitlab.com und selbst gehostete Instanzen (API v4).
|
||||||
@@ -84,26 +80,16 @@ export class GitLabClient implements GitClient {
|
|||||||
|
|
||||||
const project = await getJson<GitLabProject>(`${base}?statistics=true`, { headers });
|
const project = await getJson<GitLabProject>(`${base}?statistics=true`, { headers });
|
||||||
|
|
||||||
const defaultBranch = project.default_branch ?? "";
|
const [branches, tags, commits, releases, languages, mergeRequests] = await Promise.all([
|
||||||
|
getJsonSafe<GitLabBranch[]>(`${base}/repository/branches?per_page=50`, [], { headers }),
|
||||||
const [branches, tags, commits, releases, languages, mergeRequests, issues, pipelines] =
|
getJsonSafe<GitLabTag[]>(`${base}/repository/tags?per_page=25`, [], { headers }),
|
||||||
await Promise.all([
|
getJsonSafe<GitLabCommit[]>(`${base}/repository/commits?per_page=15`, [], { headers }),
|
||||||
getJsonSafe<GitLabBranch[]>(`${base}/repository/branches?per_page=50`, [], { headers }),
|
getJsonSafe<GitLabRelease[]>(`${base}/releases?per_page=10`, [], { headers }),
|
||||||
getJsonSafe<GitLabTag[]>(`${base}/repository/tags?per_page=25`, [], { headers }),
|
getJsonSafe<Record<string, number>>(`${base}/languages`, {}, { headers }),
|
||||||
// 100 statt 15: die aelteren brauchen wir fuer die Aktivitaetskurve.
|
getJsonSafe<GitLabMergeRequest[]>(`${base}/merge_requests?state=opened&per_page=100`, [], {
|
||||||
getJsonSafe<GitLabCommit[]>(`${base}/repository/commits?per_page=100`, [], { headers }),
|
headers,
|
||||||
getJsonSafe<GitLabRelease[]>(`${base}/releases?per_page=10`, [], { headers }),
|
}),
|
||||||
getJsonSafe<Record<string, number>>(`${base}/languages`, {}, { headers }),
|
]);
|
||||||
getJsonSafe<GitLabMergeRequest[]>(`${base}/merge_requests?state=opened&per_page=50`, [], {
|
|
||||||
headers,
|
|
||||||
}),
|
|
||||||
getJsonSafe<GitLabIssue[]>(`${base}/issues?state=opened&per_page=50`, [], { headers }),
|
|
||||||
getJsonSafe<GitLabPipeline[]>(
|
|
||||||
`${base}/pipelines?per_page=1${defaultBranch ? `&ref=${encodeURIComponent(defaultBranch)}` : ""}`,
|
|
||||||
[],
|
|
||||||
{ headers },
|
|
||||||
),
|
|
||||||
]);
|
|
||||||
|
|
||||||
const mappedBranches: BranchInfo[] = branches.map((branch) => ({
|
const mappedBranches: BranchInfo[] = branches.map((branch) => ({
|
||||||
name: branch.name,
|
name: branch.name,
|
||||||
@@ -142,37 +128,6 @@ export class GitLabClient implements GitClient {
|
|||||||
draft: false,
|
draft: false,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const mappedMergeRequests: TicketInfo[] = mergeRequests.map((entry) => ({
|
|
||||||
number: entry.iid,
|
|
||||||
title: entry.title,
|
|
||||||
author: entry.author?.username ?? null,
|
|
||||||
createdAt: toIso(entry.created_at),
|
|
||||||
url: entry.web_url ?? null,
|
|
||||||
draft: Boolean(entry.draft),
|
|
||||||
labels: entry.labels ?? [],
|
|
||||||
}));
|
|
||||||
|
|
||||||
const mappedIssues: TicketInfo[] = issues.map((entry) => ({
|
|
||||||
number: entry.iid,
|
|
||||||
title: entry.title,
|
|
||||||
author: entry.author?.username ?? null,
|
|
||||||
createdAt: toIso(entry.created_at),
|
|
||||||
url: entry.web_url ?? null,
|
|
||||||
draft: false,
|
|
||||||
labels: entry.labels ?? [],
|
|
||||||
}));
|
|
||||||
|
|
||||||
const pipeline = pipelines[0];
|
|
||||||
const ci: CiInfo | null = pipeline
|
|
||||||
? {
|
|
||||||
state: mapPipelineState(pipeline.status),
|
|
||||||
name: pipeline.name ?? `Pipeline #${pipeline.id}`,
|
|
||||||
branch: pipeline.ref ?? null,
|
|
||||||
url: pipeline.web_url ?? null,
|
|
||||||
finishedAt: toIso(pipeline.updated_at),
|
|
||||||
}
|
|
||||||
: null;
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
fullName: project.path_with_namespace,
|
fullName: project.path_with_namespace,
|
||||||
description: project.description ?? null,
|
description: project.description ?? null,
|
||||||
@@ -189,33 +144,13 @@ export class GitLabClient implements GitClient {
|
|||||||
pushedAt: toIso(project.last_activity_at),
|
pushedAt: toIso(project.last_activity_at),
|
||||||
branches: mappedBranches,
|
branches: mappedBranches,
|
||||||
tags: mappedTags,
|
tags: mappedTags,
|
||||||
commits: mappedCommits.slice(0, 15),
|
commits: mappedCommits,
|
||||||
releases: mappedReleases,
|
releases: mappedReleases,
|
||||||
languages: languages ?? {},
|
languages: languages ?? {},
|
||||||
pullRequests: mappedMergeRequests,
|
|
||||||
issues: mappedIssues,
|
|
||||||
ci,
|
|
||||||
commitActivity: bucketCommitActivity(mappedCommits.map((commit) => commit.date)),
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function mapPipelineState(status: string | null): CiState {
|
|
||||||
switch (status) {
|
|
||||||
case "success":
|
|
||||||
return "success";
|
|
||||||
case "running":
|
|
||||||
return "running";
|
|
||||||
case "failed":
|
|
||||||
return "failure";
|
|
||||||
case "canceled":
|
|
||||||
case "skipped":
|
|
||||||
return "cancelled";
|
|
||||||
default:
|
|
||||||
return "pending";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ── API-Typen ──────────────────────────────────────────────────
|
// ── API-Typen ──────────────────────────────────────────────────
|
||||||
|
|
||||||
interface GitLabProject {
|
interface GitLabProject {
|
||||||
@@ -270,29 +205,5 @@ interface GitLabRelease {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface GitLabMergeRequest {
|
interface GitLabMergeRequest {
|
||||||
iid: number;
|
|
||||||
title: string;
|
|
||||||
created_at: string | null;
|
|
||||||
web_url: string | null;
|
|
||||||
draft?: boolean;
|
|
||||||
labels?: string[];
|
|
||||||
author?: { username: string } | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface GitLabIssue {
|
|
||||||
iid: number;
|
|
||||||
title: string;
|
|
||||||
created_at: string | null;
|
|
||||||
web_url: string | null;
|
|
||||||
labels?: string[];
|
|
||||||
author?: { username: string } | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface GitLabPipeline {
|
|
||||||
id: number;
|
id: number;
|
||||||
name?: string | null;
|
|
||||||
status: string | null;
|
|
||||||
ref: string | null;
|
|
||||||
web_url: string | null;
|
|
||||||
updated_at: string | null;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,109 +0,0 @@
|
|||||||
import { describe, expect, it } from "vitest";
|
|
||||||
import { guessProvider } from "./meta";
|
|
||||||
import { parseRepoUrl } from "./index";
|
|
||||||
import { ACTIVITY_DAYS, bucketCommitActivity } from "./types";
|
|
||||||
|
|
||||||
describe("parseRepoUrl", () => {
|
|
||||||
it("zerlegt eine gewoehnliche https-URL", () => {
|
|
||||||
expect(parseRepoUrl("https://github.com/vercel/swr")).toMatchObject({
|
|
||||||
host: "github.com",
|
|
||||||
owner: "vercel",
|
|
||||||
name: "swr",
|
|
||||||
guessedProvider: "GITHUB",
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it("entfernt die Endung .git", () => {
|
|
||||||
expect(parseRepoUrl("https://github.com/vercel/swr.git")?.name).toBe("swr");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("versteht SSH-Adressen", () => {
|
|
||||||
expect(parseRepoUrl("git@gitlab.com:gruppe/projekt.git")).toMatchObject({
|
|
||||||
host: "gitlab.com",
|
|
||||||
owner: "gruppe",
|
|
||||||
name: "projekt",
|
|
||||||
guessedProvider: "GITLAB",
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it("behaelt verschachtelte GitLab-Gruppen", () => {
|
|
||||||
expect(parseRepoUrl("https://gitlab.com/gruppe/untergruppe/projekt")).toMatchObject({
|
|
||||||
owner: "gruppe/untergruppe",
|
|
||||||
name: "projekt",
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it("schneidet GitLab-Oberflaechenpfade ab dem /-/ ab", () => {
|
|
||||||
expect(parseRepoUrl("https://gitlab.com/gruppe/projekt/-/tree/main")).toMatchObject({
|
|
||||||
owner: "gruppe",
|
|
||||||
name: "projekt",
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it("kommt mit einer eigenen Gitea-Instanz zurecht", () => {
|
|
||||||
expect(parseRepoUrl("https://git.meine-firma.de/team/repo")).toMatchObject({
|
|
||||||
baseUrl: "https://git.meine-firma.de",
|
|
||||||
owner: "team",
|
|
||||||
name: "repo",
|
|
||||||
guessedProvider: "GITEA",
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it("gibt null zurueck, wenn kein Repository erkennbar ist", () => {
|
|
||||||
expect(parseRepoUrl("https://github.com/nurbenutzer")).toBeNull();
|
|
||||||
expect(parseRepoUrl("")).toBeNull();
|
|
||||||
expect(parseRepoUrl("kein-url-artiger-text")).toBeNull();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("guessProvider", () => {
|
|
||||||
it("erkennt die grossen beiden am Hostnamen", () => {
|
|
||||||
expect(guessProvider("github.com")).toBe("GITHUB");
|
|
||||||
expect(guessProvider("gitlab.example.org")).toBe("GITLAB");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("nimmt bei allem anderen Gitea an", () => {
|
|
||||||
expect(guessProvider("git.meine-firma.de")).toBe("GITEA");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("bucketCommitActivity", () => {
|
|
||||||
const dayMs = 24 * 60 * 60 * 1000;
|
|
||||||
const daysAgo = (days: number) => new Date(Date.now() - days * dayMs).toISOString();
|
|
||||||
|
|
||||||
it("liefert ohne Commits den vollen Zeitraum", () => {
|
|
||||||
expect(bucketCommitActivity([])).toHaveLength(ACTIVITY_DAYS);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("sortiert den juengsten Commit ans Ende", () => {
|
|
||||||
const buckets = bucketCommitActivity([daysAgo(29), daysAgo(0)]);
|
|
||||||
expect(buckets).toHaveLength(ACTIVITY_DAYS);
|
|
||||||
expect(buckets[ACTIVITY_DAYS - 1]).toBe(1);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("zaehlt mehrere Commits desselben Tages zusammen", () => {
|
|
||||||
const buckets = bucketCommitActivity([daysAgo(29), daysAgo(2), daysAgo(2), daysAgo(2)]);
|
|
||||||
expect(buckets[buckets.length - 3]).toBe(3);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("kuerzt auf den belegten Zeitraum, statt Unbekanntes als Null zu zeigen", () => {
|
|
||||||
// Reicht die geholte Historie nur fuenf Tage zurueck, duerfen die
|
|
||||||
// 25 Tage davor nicht als "keine Commits" erscheinen.
|
|
||||||
const buckets = bucketCommitActivity([daysAgo(4), daysAgo(0)]);
|
|
||||||
expect(buckets).toHaveLength(5);
|
|
||||||
expect(buckets[0]).toBe(1);
|
|
||||||
expect(buckets[4]).toBe(1);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("ignoriert unlesbare Werte", () => {
|
|
||||||
const buckets = bucketCommitActivity([null, "voelliger Unsinn"]);
|
|
||||||
expect(buckets).toHaveLength(ACTIVITY_DAYS);
|
|
||||||
expect(buckets.every((value) => value === 0)).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("laesst aeltere Commits den vollen Zeitraum aufspannen", () => {
|
|
||||||
const buckets = bucketCommitActivity([daysAgo(100), daysAgo(1)]);
|
|
||||||
expect(buckets).toHaveLength(ACTIVITY_DAYS);
|
|
||||||
expect(buckets[ACTIVITY_DAYS - 2]).toBe(1);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -47,29 +47,6 @@ export interface ReleaseInfo {
|
|||||||
draft: boolean;
|
draft: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Ein offener Pull Request, Merge Request oder ein Issue. */
|
|
||||||
export interface TicketInfo {
|
|
||||||
number: number;
|
|
||||||
title: string;
|
|
||||||
author: string | null;
|
|
||||||
createdAt: string | null;
|
|
||||||
url: string | null;
|
|
||||||
draft: boolean;
|
|
||||||
labels: string[];
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Ergebnis des letzten CI-Laufs auf dem Default-Branch. */
|
|
||||||
export type CiState = "success" | "failure" | "running" | "pending" | "cancelled";
|
|
||||||
|
|
||||||
export interface CiInfo {
|
|
||||||
state: CiState;
|
|
||||||
/** Name des Workflows bzw. der Pipeline, falls die API ihn liefert. */
|
|
||||||
name: string | null;
|
|
||||||
branch: string | null;
|
|
||||||
url: string | null;
|
|
||||||
finishedAt: string | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface RepoOverview {
|
export interface RepoOverview {
|
||||||
fullName: string;
|
fullName: string;
|
||||||
description: string | null;
|
description: string | null;
|
||||||
@@ -90,53 +67,6 @@ export interface RepoSnapshotData extends RepoOverview {
|
|||||||
commits: CommitInfo[];
|
commits: CommitInfo[];
|
||||||
releases: ReleaseInfo[];
|
releases: ReleaseInfo[];
|
||||||
languages: Record<string, number>;
|
languages: Record<string, number>;
|
||||||
pullRequests: TicketInfo[];
|
|
||||||
issues: TicketInfo[];
|
|
||||||
ci: CiInfo | null;
|
|
||||||
/** Commits je Tag der letzten 30 Tage, aeltester zuerst. */
|
|
||||||
commitActivity: number[];
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Tage, ueber die die Commit-Aktivitaet gebildet wird. */
|
|
||||||
export const ACTIVITY_DAYS = 30;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Verteilt Commit-Zeitpunkte auf Tagesbuckets. Bewusst aus den ohnehin
|
|
||||||
* geholten Commits berechnet statt ueber eigene Statistik-Endpunkte: die
|
|
||||||
* gibt es nicht bei allen drei Systemen, und bei GitHub antworten sie beim
|
|
||||||
* ersten Aufruf mit 202 und ohne Daten.
|
|
||||||
*
|
|
||||||
* Wichtig fuer die Ehrlichkeit der Kurve: geholt wird nur eine Seite
|
|
||||||
* Commits. Liegt der aelteste davon noch innerhalb des Zeitraums, wissen wir
|
|
||||||
* ueber die Tage davor schlicht nichts – dort eine Null zu zeichnen waere
|
|
||||||
* falsch. Deshalb wird die Kurve auf den tatsaechlich belegten Zeitraum
|
|
||||||
* gekuerzt.
|
|
||||||
*/
|
|
||||||
export function bucketCommitActivity(dates: Array<string | null>): number[] {
|
|
||||||
const buckets = new Array<number>(ACTIVITY_DAYS).fill(0);
|
|
||||||
const now = Date.now();
|
|
||||||
const dayMs = 24 * 60 * 60 * 1000;
|
|
||||||
|
|
||||||
let oldestDaysAgo = -1;
|
|
||||||
|
|
||||||
for (const value of dates) {
|
|
||||||
if (!value) continue;
|
|
||||||
const time = Date.parse(value);
|
|
||||||
if (Number.isNaN(time)) continue;
|
|
||||||
const daysAgo = Math.floor((now - time) / dayMs);
|
|
||||||
if (daysAgo < 0) continue;
|
|
||||||
if (daysAgo > oldestDaysAgo) oldestDaysAgo = daysAgo;
|
|
||||||
if (daysAgo >= ACTIVITY_DAYS) continue;
|
|
||||||
buckets[ACTIVITY_DAYS - 1 - daysAgo] += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reicht die Historie nicht bis an den Rand des Zeitraums, nur den
|
|
||||||
// belegten Ausschnitt zurueckgeben.
|
|
||||||
if (oldestDaysAgo >= 0 && oldestDaysAgo < ACTIVITY_DAYS - 1) {
|
|
||||||
return buckets.slice(ACTIVITY_DAYS - 1 - oldestDaysAgo);
|
|
||||||
}
|
|
||||||
|
|
||||||
return buckets;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RepoListItem {
|
export interface RepoListItem {
|
||||||
|
|||||||
@@ -1,101 +0,0 @@
|
|||||||
import { afterEach, describe, expect, it } from "vitest";
|
|
||||||
import { BlockedHostError, assertAllowedUrl } from "./ssrf";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Geprueft werden IP-Literale und die Formpruefung – beides kommt ohne
|
|
||||||
* Netzzugriff aus. Die Namensaufloesung deckt der Durchlauf gegen echte
|
|
||||||
* Instanzen ab.
|
|
||||||
*/
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
delete process.env.GIT_ALLOW_LOOPBACK;
|
|
||||||
delete process.env.GIT_BLOCK_PRIVATE;
|
|
||||||
delete process.env.GIT_ALLOWED_HOSTS;
|
|
||||||
});
|
|
||||||
|
|
||||||
async function blockedReason(url: string): Promise<string> {
|
|
||||||
try {
|
|
||||||
await assertAllowedUrl(url);
|
|
||||||
return "NICHT BLOCKIERT";
|
|
||||||
} catch (error) {
|
|
||||||
if (error instanceof BlockedHostError) return error.message;
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
describe("assertAllowedUrl – gesperrte Ziele", () => {
|
|
||||||
it("blockt Loopback in IPv4 und IPv6", async () => {
|
|
||||||
expect(await blockedReason("http://127.0.0.1:5432")).toMatch(/Loopback/);
|
|
||||||
expect(await blockedReason("http://[::1]:3000")).toMatch(/Loopback|aufgeloest/);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("blockt den Metadaten-Endpunkt der Cloud-Anbieter", async () => {
|
|
||||||
expect(await blockedReason("http://169.254.169.254/latest/meta-data/")).toMatch(
|
|
||||||
/Link-Local|Metadaten/,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("blockt die unspezifizierte Adresse", async () => {
|
|
||||||
expect(await blockedReason("http://0.0.0.0")).toMatch(/unspezifiziert/);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("blockt Carrier-Grade-NAT und Multicast", async () => {
|
|
||||||
expect(await blockedReason("http://100.64.0.1")).toMatch(/Carrier/);
|
|
||||||
expect(await blockedReason("http://239.0.0.1")).toMatch(/Multicast|reserviert/);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("blockt IPv4-gemappte IPv6-Adressen auf Loopback", async () => {
|
|
||||||
expect(await blockedReason("http://[::ffff:127.0.0.1]")).toMatch(/Loopback|aufgeloest/);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("assertAllowedUrl – Formpruefung", () => {
|
|
||||||
it("laesst nur http und https zu", async () => {
|
|
||||||
expect(await blockedReason("file:///etc/passwd")).toMatch(/Nur http/);
|
|
||||||
expect(await blockedReason("gopher://example.com")).toMatch(/Nur http/);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("weist Zugangsdaten in der URL ab", async () => {
|
|
||||||
expect(await blockedReason("https://nutzer:geheim@8.8.8.8")).toMatch(/Zugangsdaten/);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("weist unlesbare URLs ab", async () => {
|
|
||||||
expect(await blockedReason("kein-url-artiger-text")).toMatch(/Ungueltige URL/);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("assertAllowedUrl – erlaubte Ziele", () => {
|
|
||||||
it("laesst oeffentliche Adressen durch", async () => {
|
|
||||||
await expect(assertAllowedUrl("https://140.82.121.4")).resolves.toBeInstanceOf(URL);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("laesst das private LAN standardmaessig zu", async () => {
|
|
||||||
await expect(assertAllowedUrl("http://192.168.1.10:3000")).resolves.toBeInstanceOf(URL);
|
|
||||||
await expect(assertAllowedUrl("http://10.0.0.5")).resolves.toBeInstanceOf(URL);
|
|
||||||
await expect(assertAllowedUrl("http://172.16.0.1")).resolves.toBeInstanceOf(URL);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("assertAllowedUrl – Schalter", () => {
|
|
||||||
it("GIT_ALLOW_LOOPBACK gibt Loopback frei", async () => {
|
|
||||||
process.env.GIT_ALLOW_LOOPBACK = "true";
|
|
||||||
await expect(assertAllowedUrl("http://127.0.0.1:3000")).resolves.toBeInstanceOf(URL);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("GIT_BLOCK_PRIVATE sperrt das private Netz", async () => {
|
|
||||||
process.env.GIT_BLOCK_PRIVATE = "true";
|
|
||||||
expect(await blockedReason("http://192.168.1.10")).toMatch(/privates Netz/);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("GIT_ALLOWED_HOSTS laesst ausschliesslich die genannten Hosts zu", async () => {
|
|
||||||
process.env.GIT_ALLOWED_HOSTS = "github.com";
|
|
||||||
await expect(assertAllowedUrl("https://github.com/x/y")).resolves.toBeInstanceOf(URL);
|
|
||||||
expect(await blockedReason("https://gitlab.com/x/y")).toMatch(/GIT_ALLOWED_HOSTS/);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("eine ausdrueckliche Freigabe schlaegt die Bereichspruefung", async () => {
|
|
||||||
// Damit laesst sich eine Gitea auf demselben Rechner gezielt erlauben.
|
|
||||||
process.env.GIT_ALLOWED_HOSTS = "127.0.0.1";
|
|
||||||
await expect(assertAllowedUrl("http://127.0.0.1:3000")).resolves.toBeInstanceOf(URL);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -117,14 +117,6 @@ async function persistSnapshot(projectId: string, data: RepoSnapshotData) {
|
|||||||
commits: data.commits as unknown as object,
|
commits: data.commits as unknown as object,
|
||||||
releases: data.releases as unknown as object,
|
releases: data.releases as unknown as object,
|
||||||
languages: data.languages as unknown as object,
|
languages: data.languages as unknown as object,
|
||||||
pullRequests: data.pullRequests as unknown as object,
|
|
||||||
issues: data.issues as unknown as object,
|
|
||||||
commitActivity: data.commitActivity as unknown as object,
|
|
||||||
ciState: data.ci?.state ?? null,
|
|
||||||
ciName: data.ci?.name ?? null,
|
|
||||||
ciBranch: data.ci?.branch ?? null,
|
|
||||||
ciUrl: data.ci?.url ?? null,
|
|
||||||
ciFinishedAt: data.ci?.finishedAt ? new Date(data.ci.finishedAt) : null,
|
|
||||||
pushedAt: data.pushedAt ? new Date(data.pushedAt) : null,
|
pushedAt: data.pushedAt ? new Date(data.pushedAt) : null,
|
||||||
fetchedAt: new Date(),
|
fetchedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,64 +0,0 @@
|
|||||||
import { describe, expect, it } from "vitest";
|
|
||||||
import { formatNumber, parseTags, slugify, truncate } from "./utils";
|
|
||||||
|
|
||||||
describe("slugify", () => {
|
|
||||||
it("macht aus einem Namen einen URL-tauglichen Slug", () => {
|
|
||||||
expect(slugify("Mein Projekt")).toBe("mein-projekt");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("schreibt deutsche Umlaute aus", () => {
|
|
||||||
expect(slugify("Grün & Größe")).toBe("gruen-groesse");
|
|
||||||
expect(slugify("Straße")).toBe("strasse");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("entfernt fuehrende und abschliessende Trennzeichen", () => {
|
|
||||||
expect(slugify(" ...Hallo Welt!!! ")).toBe("hallo-welt");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("faellt bei reinen Sonderzeichen auf einen leeren Slug zurueck", () => {
|
|
||||||
// Die Aufrufer ersetzen das durch "projekt".
|
|
||||||
expect(slugify("!!!")).toBe("");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("begrenzt die Laenge", () => {
|
|
||||||
expect(slugify("a".repeat(200)).length).toBeLessThanOrEqual(60);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("parseTags", () => {
|
|
||||||
it("trennt an Kommas, trimmt und schreibt klein", () => {
|
|
||||||
expect(parseTags(" Next.js , PRISMA ,dashboard ")).toEqual([
|
|
||||||
"next.js",
|
|
||||||
"prisma",
|
|
||||||
"dashboard",
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("entfernt Dubletten und Leereintraege", () => {
|
|
||||||
expect(parseTags("a,,a, b ,A")).toEqual(["a", "b"]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("begrenzt auf zwoelf Tags", () => {
|
|
||||||
const many = Array.from({ length: 20 }, (_, index) => `tag${index}`).join(",");
|
|
||||||
expect(parseTags(many)).toHaveLength(12);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("truncate", () => {
|
|
||||||
it("laesst kurze Texte unveraendert", () => {
|
|
||||||
expect(truncate("kurz", 10)).toBe("kurz");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("kuerzt und haengt ein Auslassungszeichen an", () => {
|
|
||||||
const result = truncate("abcdefghij", 5);
|
|
||||||
expect(result).toHaveLength(5);
|
|
||||||
expect(result.endsWith("…")).toBe(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("formatNumber", () => {
|
|
||||||
it("gruppiert nach deutscher Schreibweise", () => {
|
|
||||||
// Das Trennzeichen kann je nach ICU-Version variieren.
|
|
||||||
expect(formatNumber(32437)).toMatch(/^32.437$/);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
+2
-19
@@ -1,12 +1,5 @@
|
|||||||
import type { GitProvider, Note, Project, ProjectStatus, RepoSnapshot } from "@prisma/client";
|
import type { GitProvider, Note, Project, ProjectStatus, RepoSnapshot } from "@prisma/client";
|
||||||
import type {
|
import type { BranchInfo, CommitInfo, ReleaseInfo, TagInfo } from "@/lib/git/types";
|
||||||
BranchInfo,
|
|
||||||
CiInfo,
|
|
||||||
CommitInfo,
|
|
||||||
ReleaseInfo,
|
|
||||||
TagInfo,
|
|
||||||
TicketInfo,
|
|
||||||
} from "@/lib/git/types";
|
|
||||||
|
|
||||||
/** Verbindung ohne Geheimnisse – so wird sie an den Browser gegeben. */
|
/** Verbindung ohne Geheimnisse – so wird sie an den Browser gegeben. */
|
||||||
export interface ConnectionSafe {
|
export interface ConnectionSafe {
|
||||||
@@ -51,17 +44,7 @@ export interface RepoListEntry {
|
|||||||
updatedAt: string | null;
|
updatedAt: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type {
|
export type { BranchInfo, CommitInfo, Note, ProjectStatus, ReleaseInfo, RepoSnapshot, TagInfo };
|
||||||
BranchInfo,
|
|
||||||
CiInfo,
|
|
||||||
CommitInfo,
|
|
||||||
Note,
|
|
||||||
ProjectStatus,
|
|
||||||
ReleaseInfo,
|
|
||||||
RepoSnapshot,
|
|
||||||
TagInfo,
|
|
||||||
TicketInfo,
|
|
||||||
};
|
|
||||||
|
|
||||||
/** Prisma liefert Json als unknown – hier bequem in Arrays zurueckholen. */
|
/** Prisma liefert Json als unknown – hier bequem in Arrays zurueckholen. */
|
||||||
export function asArray<T>(value: unknown): T[] {
|
export function asArray<T>(value: unknown): T[] {
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
import { defineConfig } from "vitest/config";
|
|
||||||
import { fileURLToPath } from "node:url";
|
|
||||||
|
|
||||||
export default defineConfig({
|
|
||||||
test: {
|
|
||||||
// Reine Logik, kein DOM und keine Datenbank – die Tests laufen in
|
|
||||||
// Millisekunden und brauchen weder Server noch Container.
|
|
||||||
environment: "node",
|
|
||||||
include: ["src/**/*.test.ts"],
|
|
||||||
},
|
|
||||||
resolve: {
|
|
||||||
alias: {
|
|
||||||
"@": fileURLToPath(new URL("./src", import.meta.url)),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
Reference in New Issue
Block a user