Skip to content

Commit

Permalink
Reload FlexCard Compiler Page Upon Aura Error
Browse files Browse the repository at this point in the history
  • Loading branch information
cwarden committed Oct 24, 2023
1 parent a6c56c9 commit 1e075a3
Showing 1 changed file with 31 additions and 23 deletions.
54 changes: 31 additions & 23 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,38 +208,46 @@ func compileOSAndFlexCards() error {
log.Printf("Activating FlexCards %+v\n", flexCardIds)
flexCardCompilePage := instanceUrl + "/apex/" + packageNamespace + "FlexCardCompilePage?id=" + strings.Join(flexCardIds, ",")
log.Println("Loading", flexCardCompilePage)
var currentStatus, jsonError string
var currentStatus, jsonError, auraError string

timeoutCtx, cancelParse := context.WithTimeout(ctx, 5*time.Minute)
defer cancelParse()
loadTimeCtx, cancelLoad := context.WithTimeout(timeoutCtx, 30*time.Second)
defer cancelLoad()
if err := chromedp.Run(loadTimeCtx,
chromedp.Navigate(flexCardCompilePage),
waitForUrl("FlexCardCompilePage"),
); err != nil {
return fmt.Errorf("Failed loading Flex Card compilation page: %w", err)
}
CARD:
CARDS:
for {
if err := chromedp.Run(timeoutCtx,
chromedp.WaitVisible("#compileMessage-0"),
chromedp.Text("#compileMessage-0", &currentStatus),
chromedp.WaitVisible("#resultJSON-0"),
chromedp.Text("#resultJSON-0", &jsonError),
if err := chromedp.Run(loadTimeCtx,
chromedp.Navigate(flexCardCompilePage),
waitForUrl("FlexCardCompilePage"),
); err != nil {
return fmt.Errorf("Failed checking Flex Card compilation status: %w", err)
return fmt.Errorf("Failed loading Flex Card compilation page: %w", err)
}
switch {
case currentStatus == "DONE SUCCESSFULLY":
log.Println("LWC Activated successfully")
break CARD
case currentStatus == "DONE WITH ERRORS":
log.Println("LWC FlexCards Compilation Error Result:" + jsonError)
default:
log.Println("Status: " + currentStatus)
CARD_STATUS:
for {
if err := chromedp.Run(timeoutCtx,
chromedp.WaitVisible("#compileMessage-0"),
chromedp.Text("#compileMessage-0", &currentStatus),
chromedp.WaitVisible("#resultJSON-0"),
chromedp.Text("#resultJSON-0", &jsonError),
chromedp.WaitVisible("body > #auraErrorMessage"),
chromedp.Text("body > #auraErrorMessage", &auraError),
); err != nil {
return fmt.Errorf("Failed checking Flex Card compilation status: %w", err)
}
switch {
case auraError != "":
log.Println("Error on page: " + auraError + "; Reloading")
break CARD_STATUS
case currentStatus == "DONE SUCCESSFULLY":
log.Println("LWC Activated successfully")
break CARDS
case currentStatus == "DONE WITH ERRORS":
log.Println("LWC FlexCards Compilation Error Result:" + jsonError)
default:
log.Println("Status: " + currentStatus)
}
time.Sleep(2 * time.Second)
}
time.Sleep(2 * time.Second)
}
cancelLoad()
cancelParse()
Expand Down

0 comments on commit 1e075a3

Please sign in to comment.