Gitfed
bastien-mrq/gitfed / cmd / gitfed-install / screens_intro.go
package main

import (
	"fmt"
	"strings"
)

func (m model) viewWelcome() string {
	var b strings.Builder
	b.WriteString(styleBody.Render("Un serveur git auto-hébergé et fédéré — tes dépôts, ton serveur, tes règles.") + "\n\n")

	reassure := []string{
		"Aucun tracker, aucune télémétrie envoyée nulle part — cet assistant ne parle qu'à cette machine, ton VPS et Let's Encrypt.",
		"Tes données restent sur le serveur que tu contrôles.",
		"Aucun compte tiers requis pour installer ou utiliser gitfed.",
		"Tu choisis seul·e à quelles autres instances faire confiance — jamais automatique.",
		"Code source ouvert (AGPLv3), y compris ce que fait cet assistant.",
	}
	for _, line := range reassure {
		b.WriteString(styleOK.Render("✓") + "  " + styleBody.Render(line) + "\n")
	}

	b.WriteString("\n" + styleBody.Render(
		"Cet assistant détecte ce qui est déjà en place, te demande ton domaine, construit\n"+
			"et déploie gitfed, puis crée ton premier compte. "+styleBold.Render("Rien n'est exécuté sans ta\nconfirmation à chaque étape.")))

	return stylePanel.Render(b.String())
}

func (m model) viewScan() string {
	if !m.scanDone {
		return stylePanel.Render(m.spin.View() + " " + styleBody.Render("Analyse de la machine…"))
	}
	s := m.scan
	var b strings.Builder
	b.WriteString(row(glyph(statusOK), "Système", s.OS+" · "+s.Arch) + "\n")
	b.WriteString(row(condGlyph(s.HasK3s), "k3s", condLabel(s.HasK3s, "détecté", "non détecté — sera installé")) + "\n")
	b.WriteString(row(condGlyph(s.HasDocker), "Docker", condLabel(s.HasDocker, "détecté", "non détecté — sera installé")) + "\n")
	b.WriteString(row(condGlyph(s.HasCertManager), "cert-manager", condLabel(s.HasCertManager, "détecté", "non détecté — sera installé")) + "\n")
	b.WriteString(row(condGlyph(s.HasSudo), "Accès sudo sans mot de passe", condLabel(s.HasSudo, "oui", "non — un mot de passe pourra être demandé")) + "\n")
	if len(s.PortsBusy) == 0 {
		b.WriteString(row(glyph(statusOK), "Ports 80 / 443 / 2222", "libres") + "\n")
	} else {
		b.WriteString(row(glyph(statusWarn), "Ports occupés", fmt.Sprint(s.PortsBusy)) + "\n")
	}

	b.WriteString("\n" + styleMuted.Render("→ Rien n'est modifié pour l'instant, ceci est juste un état des lieux."))
	return stylePanel.Render(b.String())
}

func condGlyph(ok bool) string {
	if ok {
		return glyph(statusOK)
	}
	return glyph(statusMissing)
}

func condLabel(ok bool, yes, no string) string {
	if ok {
		return yes
	}
	return no
}