refactor!: upgrade/rollback vertical render / ui fixes
All checks were successful
continuous-integration/drone/push Build is passing

See toolshed/organising#658
This commit is contained in:
decentral1se 2024-12-28 23:35:47 +01:00
parent 7ec61c6d03
commit 356e527f1f
Signed by: decentral1se
GPG Key ID: 03789458B3D0C410
3 changed files with 32 additions and 31 deletions

View File

@ -250,7 +250,6 @@ beforehand.`,
}
if showReleaseNotes {
fmt.Println()
fmt.Print(releaseNotes)
return
}

View File

@ -42,13 +42,13 @@ func NewVersionOverview(
app appPkg.App,
warnMessages []string,
kind,
currentVersion,
chaosVersion,
newVersion,
deployedVersion,
deployedChaosVersion,
toDeployVersion,
releaseNotes string) error {
deployConfig := "compose.yml"
if composeFiles, ok := app.Env["COMPOSE_FILE"]; ok {
deployConfig = strings.Join(strings.Split(composeFiles, ":"), "\n")
deployConfig = composeFiles
}
server := app.Server
@ -61,32 +61,30 @@ func NewVersionOverview(
domain = config.NO_DOMAIN_DEFAULT
}
body := strings.Builder{}
body.WriteString(
borderStyle.Render(
lipgloss.JoinVertical(
lipgloss.Center,
headerStyle.Render(fmt.Sprintf("%s OVERVIEW", strings.ToUpper(kind))),
lipgloss.JoinVertical(
lipgloss.Left,
horizontal(leftStyle.Render("SERVER"), " ", rightStyle.Render(server)),
horizontal(leftStyle.Render("DOMAIN"), " ", rightStyle.Render(domain)),
horizontal(leftStyle.Render("RECIPE"), " ", rightStyle.Render(app.Recipe.Name)),
horizontal(leftStyle.Render("CONFIG"), " ", rightStyle.Render(deployConfig)),
horizontal(leftStyle.Render("VERSION"), " ", rightStyle.Render(currentVersion)),
horizontal(leftStyle.Render("CHAOS"), " ", rightStyle.Render(chaosVersion)),
horizontal(leftStyle.Render("DEPLOY"), " ", rightStyle.Padding(0).Render(newVersion)),
),
),
),
)
fmt.Println(body.String())
rows := [][]string{
[]string{"APP", domain},
[]string{"RECIPE", app.Recipe.Name},
[]string{"SERVER", server},
[]string{"DEPLOYED", deployedVersion},
[]string{"CURRENT CHAOS ", deployedChaosVersion},
[]string{fmt.Sprintf("TO %s", strings.ToUpper(kind)), toDeployVersion},
[]string{"CONFIG", deployConfig},
}
if releaseNotes != "" && newVersion != "" {
fmt.Println()
overview := formatter.CreateOverview(
fmt.Sprintf("%s OVERVIEW", strings.ToUpper(kind)),
rows,
)
fmt.Println(overview)
if releaseNotes != "" && toDeployVersion != "" {
fmt.Print(releaseNotes)
} else {
warnMessages = append(warnMessages, fmt.Sprintf("no release notes available for %s", newVersion))
warnMessages = append(
warnMessages,
fmt.Sprintf("no release notes available for %s", toDeployVersion),
)
}
for _, msg := range warnMessages {
@ -120,7 +118,7 @@ func DeployOverview(
toDeployChaosVersion string) error {
deployConfig := "compose.yml"
if composeFiles, ok := app.Env["COMPOSE_FILE"]; ok {
deployConfig = strings.Join(strings.Split(composeFiles, ":"), "\n")
deployConfig = composeFiles
}
server := app.Server
@ -176,7 +174,7 @@ func UndeployOverview(
chaosVersion string) error {
deployConfig := "compose.yml"
if composeFiles, ok := app.Env["COMPOSE_FILE"]; ok {
deployConfig = strings.Join(strings.Split(composeFiles, ":"), "\n")
deployConfig = composeFiles
}
server := app.Server

View File

@ -6,6 +6,7 @@ import (
"path"
"coopcloud.tech/abra/pkg/envfile"
"coopcloud.tech/abra/pkg/formatter"
)
func (r Recipe) SampleEnv() (map[string]string, error) {
@ -29,7 +30,10 @@ func (r Recipe) GetReleaseNotes(version string) (string, error) {
if err != nil {
return "", err
}
withTitle := fmt.Sprintf("%s release notes:\n%s", version, string(releaseNotes))
title := formatter.BoldStyle.Render(fmt.Sprintf("%s release notes:", version))
withTitle := fmt.Sprintf("%s\n%s\n", title, releaseNotes)
return withTitle, nil
}