Skip to content

Commit 0c6d731

Browse files
authored
Show app url from status endpoint (#37)
* Show app url from status endpoint * Faster ticks for faster deploys
1 parent 701416a commit 0c6d731

4 files changed

Lines changed: 20 additions & 14 deletions

File tree

clients/api/structs.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ type GetVersionStatusResponse struct {
160160
Error *AppErrorDetail `json:"error,omitempty"`
161161
Status string `json:"status,omitempty"`
162162
DeploymentError string `json:"deploymentError,omitempty"`
163+
AppURL string `json:"app_url,omitempty"`
163164
}
164165

165166
// --- Template structs ---

clients/config/config.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ import (
99

1010
// Config represents the application configuration
1111
type Config struct {
12-
APIURL string `mapstructure:"api_url"`
13-
FrontendURI string `mapstructure:"frontend_uri"`
14-
AppURLSuffix string `mapstructure:"app_url_suffix"`
12+
APIURL string `mapstructure:"api_url"`
13+
FrontendURI string `mapstructure:"frontend_uri"`
14+
AppURLSuffix string `mapstructure:"app_url_suffix"`
15+
AppURLFEOnlySuffix string `mapstructure:"app_url_fe_only_suffix"`
1516
}
1617

1718
// Load initializes and returns the application config

cmd/app/deploy.go

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ func runDeploy(cobraCmd *cobra.Command) error {
109109
cobraCmd.Printf("\n✓ Version created: %s\n", resp.VersionID)
110110

111111
// Poll deployment status with beautiful UI
112-
finalStatus, deploymentError, err := pollDeploymentStatus(applicationID, organizationID, resp.VersionID)
112+
finalStatus, deploymentError, appURL, err := pollDeploymentStatus(applicationID, organizationID, resp.VersionID)
113113
if err != nil {
114114
return fmt.Errorf("failed to track deployment status: %w", err)
115115
}
@@ -118,10 +118,8 @@ func runDeploy(cobraCmd *cobra.Command) error {
118118
if finalStatus == "DEPLOYED" {
119119
cobraCmd.Printf("\n🎉 Deployment successful!\n")
120120

121-
// Print application URL
122-
cfg := singletons.GetConfig()
123-
if cfg != nil && cfg.AppURLSuffix != "" {
124-
appURL := fmt.Sprintf("https://app-%s.%s", applicationID, cfg.AppURLSuffix)
121+
// Print application URL from the API response
122+
if appURL != "" {
125123
cobraCmd.Printf("\n🌐 Your application is live at:\n")
126124
cobraCmd.Printf(" %s\n", appURL)
127125
}
@@ -146,6 +144,7 @@ type deploymentStatusModel struct {
146144
spinner spinner.Model
147145
status string
148146
deploymentError string
147+
appURL string
149148
err error
150149
done bool
151150
dots int // Track number of dots (0-4)
@@ -156,6 +155,7 @@ type deploymentStatusModel struct {
156155
type statusMsg struct {
157156
status string
158157
deploymentError string
158+
appURL string
159159
err error
160160
}
161161

@@ -179,6 +179,7 @@ func (m deploymentStatusModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
179179
case statusMsg:
180180
m.status = msg.status
181181
m.deploymentError = msg.deploymentError
182+
m.appURL = msg.appURL
182183
m.err = msg.err
183184

184185
// Check if we're in a terminal state
@@ -264,12 +265,13 @@ func pollStatus(applicationID, organizationID, versionID string) tea.Cmd {
264265
return statusMsg{
265266
status: resp.Status,
266267
deploymentError: resp.DeploymentError,
268+
appURL: resp.AppURL,
267269
}
268270
}
269271
}
270272

271273
func tickCmd() tea.Cmd {
272-
return tea.Tick(2*time.Second, func(t time.Time) tea.Msg {
274+
return tea.Tick(1*time.Second, func(t time.Time) tea.Msg {
273275
return tickMsg(t)
274276
})
275277
}
@@ -310,7 +312,7 @@ func getStatusDisplay(status string) (string, string) {
310312
}
311313
}
312314

313-
func pollDeploymentStatus(applicationID, organizationID, versionID string) (string, string, error) {
315+
func pollDeploymentStatus(applicationID, organizationID, versionID string) (string, string, string, error) {
314316
s := spinner.New()
315317
s.Spinner = spinner.Dot
316318
s.Style = lipgloss.NewStyle().Foreground(lipgloss.Color("205"))
@@ -322,6 +324,7 @@ func pollDeploymentStatus(applicationID, organizationID, versionID string) (stri
322324
spinner: s,
323325
status: "",
324326
deploymentError: "",
327+
appURL: "",
325328
done: false,
326329
dots: 1,
327330
dotsIncreasing: true,
@@ -331,15 +334,15 @@ func pollDeploymentStatus(applicationID, organizationID, versionID string) (stri
331334
p := tea.NewProgram(m)
332335
finalModel, err := p.Run()
333336
if err != nil {
334-
return "", "", err
337+
return "", "", "", err
335338
}
336339

337340
finalStatusModel := finalModel.(deploymentStatusModel)
338341
if finalStatusModel.err != nil {
339-
return "", "", finalStatusModel.err
342+
return "", "", "", finalStatusModel.err
340343
}
341344

342-
return finalStatusModel.status, finalStatusModel.deploymentError, nil
345+
return finalStatusModel.status, finalStatusModel.deploymentError, finalStatusModel.appURL, nil
343346
}
344347

345348
// formatDeploymentError formats the deployment error message with nice styling

configs/prod.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"api_url": "https://api.prod.major.build/cli",
33
"frontend_uri": "https://app.major.build",
4-
"app_url_suffix": "apps.prod.major.build"
4+
"app_url_suffix": "apps.prod.major.build",
5+
"app_url_fe_only_suffix": "apps2.prod.major.build"
56
}

0 commit comments

Comments
 (0)