Skip to content

Commit 64a5557

Browse files
committed
feat: migrate stacks/app_pipeline.go from survey to huh
Replace all survey-based prompts in AppStack with huh form builders. Extract pure form builder functions for each prompt (repository URL, branch, domains, healthcheck path, S3 buckets, SQS, database, Redis, SES, users, data-loss confirm) and update AskForDatabase, AskForRedis, AskForSES, WarnIfDataLoss, and AskQuestions to call them. Remove databaseSelectTransform and redisSelectTransform — replaced by typed huh.NewOption[string] values that carry the full stack name directly. Update cmd/modify.go askModifyQuestions to use the new huh form builders (AppRepositoryURLForm, AppBranchForm, AppDomainsForm, AppHealthCheckPathForm) instead of the removed survey-based helpers. Add table-driven uitest tests for every new form builder. Closes #123
1 parent b3b6c37 commit 64a5557

3 files changed

Lines changed: 896 additions & 291 deletions

File tree

cmd/modify.go

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package cmd
1717

1818
import (
1919
"fmt"
20+
"strings"
2021

2122
"github.com/apppackio/apppack/stacks"
2223
"github.com/apppackio/apppack/ui"
@@ -86,32 +87,45 @@ func modifyAppStack(cfg aws.Config, stack *stacks.AppStack, name string, flags *
8687
return nil
8788
}
8889

89-
func askModifyQuestions(cfg aws.Config, stack *stacks.AppStack) error {
90-
var questions []*ui.QuestionExtra
91-
90+
func askModifyQuestions(_ aws.Config, stack *stacks.AppStack) error {
9291
// Repository URL
93-
questions = append(questions, stacks.BuildRepositoryURLQuestion(&stack.Parameters.RepositoryURL))
94-
95-
if err := ui.AskQuestions(questions, stack.Parameters); err != nil {
92+
repoForm, repoPtr := stacks.AppRepositoryURLForm(stack.Parameters.RepositoryURL)
93+
if err := repoForm.Run(); err != nil {
9694
return err
9795
}
9896

97+
stack.Parameters.RepositoryURL = *repoPtr
98+
9999
if err := stack.Parameters.SetRepositoryType(); err != nil {
100100
return err
101101
}
102102

103-
questions = []*ui.QuestionExtra{}
104-
105103
// Branch and Domains (only for non-pipeline apps)
106104
if !stack.Pipeline {
107-
questions = append(questions, stacks.BuildBranchQuestion(&stack.Parameters.Branch))
108-
questions = append(questions, stacks.BuildDomainsQuestion(&stack.Parameters.Domains))
105+
branchForm, branchPtr := stacks.AppBranchForm(stack.Parameters.Branch)
106+
if err := branchForm.Run(); err != nil {
107+
return err
108+
}
109+
110+
stack.Parameters.Branch = *branchPtr
111+
112+
domainsForm, domainsPtr := stacks.AppDomainsForm(stack.Parameters.Domains)
113+
if err := domainsForm.Run(); err != nil {
114+
return err
115+
}
116+
117+
stack.Parameters.Domains = strings.Split(*domainsPtr, "\n")
109118
}
110119

111120
// Healthcheck path
112-
questions = append(questions, stacks.BuildHealthCheckPathQuestion(&stack.Parameters.HealthCheckPath))
121+
healthForm, healthPtr := stacks.AppHealthCheckPathForm(stack.Parameters.HealthCheckPath)
122+
if err := healthForm.Run(); err != nil {
123+
return err
124+
}
125+
126+
stack.Parameters.HealthCheckPath = *healthPtr
113127

114-
return ui.AskQuestions(questions, stack.Parameters)
128+
return nil
115129
}
116130

117131
// modifyCmd represents the modify command

0 commit comments

Comments
 (0)