Skip to content

Commit 0686372

Browse files
committed
fix(extras): [UPD] surface failures and streamline nav
1 parent 1f3440a commit 0686372

6 files changed

Lines changed: 110 additions & 0 deletions

File tree

internal/engine/install/extras_flow.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,27 @@ func emitExtrasSkippedSummary(emit func(domain.Event) bool) {
745745

746746
func detectExtrasFailure(out string) string {
747747
lines := strings.Split(strings.ReplaceAll(out, "\r\n", "\n"), "\n")
748+
749+
priorityHints := []string{
750+
"sqlstate[",
751+
"thrown in ",
752+
}
753+
for _, raw := range lines {
754+
raw = strings.TrimSpace(raw)
755+
if raw == "" {
756+
continue
757+
}
758+
lower := strings.ToLower(raw)
759+
for _, hint := range priorityHints {
760+
if strings.Contains(lower, hint) {
761+
return raw
762+
}
763+
}
764+
if strings.HasPrefix(lower, "fatal:") || strings.HasPrefix(lower, "error:") {
765+
return raw
766+
}
767+
}
768+
748769
hints := []string{
749770
"the limit that is provided for free use of github has been exceeded",
750771
"github api rate limit exceeded",
@@ -758,6 +779,7 @@ func detectExtrasFailure(out string) string {
758779
"could not resolve host",
759780
"failed to download",
760781
"failed to open stream",
782+
"stack trace:",
761783
"package operations: 0 installs, 0 updates, 0 removals",
762784
}
763785

@@ -778,6 +800,9 @@ func detectExtrasFailure(out string) string {
778800
if strings.HasPrefix(lower, "fatal:") || strings.HasPrefix(lower, "error:") {
779801
return raw
780802
}
803+
if strings.HasSuffix(lower, " fail") {
804+
return raw
805+
}
781806
if strings.Contains(lower, "exception") {
782807
return raw
783808
}

internal/engine/install/extras_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,3 +201,26 @@ func TestLoadBundledInlineExtrasUsesRuntimeCacheFallback(t *testing.T) {
201201
t.Fatalf("unexpected fallback path: %q", pkgs[0].Path)
202202
}
203203
}
204+
205+
func TestDetectExtrasFailureRecognizesSqliteStackTrace(t *testing.T) {
206+
t.Parallel()
207+
208+
out := `
209+
INFO Running migrations.
210+
211+
2026_03_29_000000_create_file_groups_table ..................... 1.07ms FAIL
212+
SQLSTATE[HY000]: General error: 1 table "evo_file_groups" already exists
213+
File: /tmp/core/vendor/illuminate/database/Connection.php
214+
Line: 838
215+
Stack trace:
216+
#1. Symfony\Component\Console\Application->run(...)
217+
`
218+
219+
got := detectExtrasFailure(out)
220+
if got == "" {
221+
t.Fatalf("expected detectExtrasFailure to recognize SQLSTATE stack trace")
222+
}
223+
if got != `SQLSTATE[HY000]: General error: 1 table "evo_file_groups" already exists` {
224+
t.Fatalf("unexpected detected failure: %q", got)
225+
}
226+
}

internal/logging/eventlog.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ func (l *EventLogger) Record(ev domain.Event) {
9696
ok = p.OK
9797
}
9898
if !ok && ev.StepID != "" {
99+
l.hadError = true
99100
l.failedSteps[ev.StepID] = true
100101
}
101102
label := l.stepLabels[ev.StepID]

internal/logging/eventlog_test.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package logging
2+
3+
import (
4+
"testing"
5+
6+
"github.com/evolution-cms/installer/internal/domain"
7+
)
8+
9+
func TestFinalizeWritesLogWhenStepDoneFails(t *testing.T) {
10+
t.Parallel()
11+
12+
dir := t.TempDir()
13+
logger := NewEventLogger(Config{InstallDir: dir})
14+
logger.Record(domain.Event{
15+
Type: domain.EventStepDone,
16+
StepID: "extras",
17+
Payload: domain.StepDonePayload{
18+
OK: false,
19+
},
20+
})
21+
22+
res, err := logger.Finalize()
23+
if err != nil {
24+
t.Fatalf("Finalize error: %v", err)
25+
}
26+
if !res.Written {
27+
t.Fatalf("expected log to be written for failed step")
28+
}
29+
}

internal/ui/extras.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,10 @@ func (m *Model) handleExtrasSelectKey(key string, lowerKey string) {
240240
return
241241
}
242242
m.extras.cursor++
243+
case "right":
244+
m.extras.focus = extrasFocusActions
245+
m.extras.action = 0
246+
return
243247
case "pgup", "pageup":
244248
m.extras.cursor -= listHeight
245249
case "pgdown", "pagedown":

internal/ui/extras_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package ui
2+
3+
import (
4+
"testing"
5+
6+
"github.com/evolution-cms/installer/internal/domain"
7+
)
8+
9+
func TestHandleExtrasSelectKeyRightMovesFocusToInstallAction(t *testing.T) {
10+
t.Parallel()
11+
12+
m := &Model{}
13+
m.extras.active = true
14+
m.extras.stage = domain.ExtrasStageSelect
15+
m.extras.focus = extrasFocusList
16+
m.extras.packages = []domain.ExtrasPackage{
17+
{ID: "bundled-inline:codemirror", Name: "CodeMirror"},
18+
}
19+
20+
m.handleExtrasSelectKey("", "right")
21+
22+
if m.extras.focus != extrasFocusActions {
23+
t.Fatalf("expected focus to move to actions, got %v", m.extras.focus)
24+
}
25+
if m.extras.action != 0 {
26+
t.Fatalf("expected install action to be selected, got %d", m.extras.action)
27+
}
28+
}

0 commit comments

Comments
 (0)