From c28d77832237f26d1b4967617f9041c6387ea8d1 Mon Sep 17 00:00:00 2001 From: Snider Date: Fri, 30 Jan 2026 01:28:39 +0000 Subject: [PATCH] refactor(cmd): consolidate styles across dev, php, and sdk packages - dev: Replace hardcoded colours in ci, issues, reviews, impact, work - php: Use shared colour constants and deploy styles - sdk: Replace local styles with shared aliases - shared: Add Yellow500, Emerald500, Purple500 colours - shared: Add PrNumberStyle and deploy status styles Removes 111 lines of duplicate style definitions. Co-Authored-By: Claude Opus 4.5 --- cmd/dev/dev_ci.go | 20 +++++--------------- cmd/dev/dev_impact.go | 15 ++++----------- cmd/dev/dev_issues.go | 27 +++++++-------------------- cmd/dev/dev_reviews.go | 33 ++++++++------------------------- cmd/dev/dev_work.go | 15 ++++++--------- cmd/php/php.go | 2 +- cmd/php/php_deploy.go | 15 +++++---------- cmd/sdk/sdk.go | 21 ++++++--------------- cmd/shared/styles.go | 33 ++++++++++++++++++++++++++++----- 9 files changed, 70 insertions(+), 111 deletions(-) diff --git a/cmd/dev/dev_ci.go b/cmd/dev/dev_ci.go index d2c3cd14..84305522 100644 --- a/cmd/dev/dev_ci.go +++ b/cmd/dev/dev_ci.go @@ -8,27 +8,17 @@ import ( "strings" "time" - "github.com/charmbracelet/lipgloss" "github.com/host-uk/core/cmd/shared" "github.com/host-uk/core/pkg/repos" "github.com/spf13/cobra" ) -// CI-specific styles +// CI-specific styles (aliases to shared) var ( - ciSuccessStyle = lipgloss.NewStyle(). - Bold(true). - Foreground(lipgloss.Color("#22c55e")) // green-500 - - ciFailureStyle = lipgloss.NewStyle(). - Bold(true). - Foreground(lipgloss.Color("#ef4444")) // red-500 - - ciPendingStyle = lipgloss.NewStyle(). - Foreground(lipgloss.Color("#f59e0b")) // amber-500 - - ciSkippedStyle = lipgloss.NewStyle(). - Foreground(lipgloss.Color("#6b7280")) // gray-500 + ciSuccessStyle = shared.SuccessStyle + ciFailureStyle = shared.ErrorStyle + ciPendingStyle = shared.StatusWarningStyle + ciSkippedStyle = shared.DimStyle ) // WorkflowRun represents a GitHub Actions workflow run diff --git a/cmd/dev/dev_impact.go b/cmd/dev/dev_impact.go index 6e52ca6b..3dc71538 100644 --- a/cmd/dev/dev_impact.go +++ b/cmd/dev/dev_impact.go @@ -4,23 +4,16 @@ import ( "fmt" "sort" - "github.com/charmbracelet/lipgloss" "github.com/host-uk/core/cmd/shared" "github.com/host-uk/core/pkg/repos" "github.com/spf13/cobra" ) -// Impact-specific styles +// Impact-specific styles (aliases to shared) var ( - impactDirectStyle = lipgloss.NewStyle(). - Bold(true). - Foreground(lipgloss.Color("#ef4444")) // red-500 - - impactIndirectStyle = lipgloss.NewStyle(). - Foreground(lipgloss.Color("#f59e0b")) // amber-500 - - impactSafeStyle = lipgloss.NewStyle(). - Foreground(lipgloss.Color("#22c55e")) // green-500 + impactDirectStyle = shared.ErrorStyle + impactIndirectStyle = shared.StatusWarningStyle + impactSafeStyle = shared.StatusSuccessStyle ) // Impact command flags diff --git a/cmd/dev/dev_issues.go b/cmd/dev/dev_issues.go index b9c5a412..7bbe85db 100644 --- a/cmd/dev/dev_issues.go +++ b/cmd/dev/dev_issues.go @@ -9,32 +9,19 @@ import ( "strings" "time" - "github.com/charmbracelet/lipgloss" "github.com/host-uk/core/cmd/shared" "github.com/host-uk/core/pkg/repos" "github.com/spf13/cobra" ) -// Issue-specific styles +// Issue-specific styles (aliases to shared) var ( - issueRepoStyle = lipgloss.NewStyle(). - Foreground(lipgloss.Color("#6b7280")) // gray-500 - - issueNumberStyle = lipgloss.NewStyle(). - Bold(true). - Foreground(lipgloss.Color("#3b82f6")) // blue-500 - - issueTitleStyle = lipgloss.NewStyle(). - Foreground(lipgloss.Color("#e2e8f0")) // gray-200 - - issueLabelStyle = lipgloss.NewStyle(). - Foreground(lipgloss.Color("#f59e0b")) // amber-500 - - issueAssigneeStyle = lipgloss.NewStyle(). - Foreground(lipgloss.Color("#22c55e")) // green-500 - - issueAgeStyle = lipgloss.NewStyle(). - Foreground(lipgloss.Color("#6b7280")) // gray-500 + issueRepoStyle = shared.DimStyle + issueNumberStyle = shared.TitleStyle + issueTitleStyle = shared.ValueStyle + issueLabelStyle = shared.WarningStyle + issueAssigneeStyle = shared.StatusSuccessStyle + issueAgeStyle = shared.DimStyle ) // GitHubIssue represents a GitHub issue from the API. diff --git a/cmd/dev/dev_reviews.go b/cmd/dev/dev_reviews.go index 9bebd98b..f6324b34 100644 --- a/cmd/dev/dev_reviews.go +++ b/cmd/dev/dev_reviews.go @@ -9,37 +9,20 @@ import ( "strings" "time" - "github.com/charmbracelet/lipgloss" "github.com/host-uk/core/cmd/shared" "github.com/host-uk/core/pkg/repos" "github.com/spf13/cobra" ) -// PR-specific styles +// PR-specific styles (aliases to shared) var ( - prNumberStyle = lipgloss.NewStyle(). - Bold(true). - Foreground(lipgloss.Color("#a855f7")) // purple-500 - - prTitleStyle = lipgloss.NewStyle(). - Foreground(lipgloss.Color("#e2e8f0")) // gray-200 - - prAuthorStyle = lipgloss.NewStyle(). - Foreground(lipgloss.Color("#3b82f6")) // blue-500 - - prApprovedStyle = lipgloss.NewStyle(). - Bold(true). - Foreground(lipgloss.Color("#22c55e")) // green-500 - - prChangesStyle = lipgloss.NewStyle(). - Bold(true). - Foreground(lipgloss.Color("#f59e0b")) // amber-500 - - prPendingStyle = lipgloss.NewStyle(). - Foreground(lipgloss.Color("#6b7280")) // gray-500 - - prDraftStyle = lipgloss.NewStyle(). - Foreground(lipgloss.Color("#6b7280")) // gray-500 + prNumberStyle = shared.PrNumberStyle + prTitleStyle = shared.ValueStyle + prAuthorStyle = shared.InfoStyle + prApprovedStyle = shared.SuccessStyle + prChangesStyle = shared.WarningStyle + prPendingStyle = shared.DimStyle + prDraftStyle = shared.DimStyle ) // GitHubPR represents a GitHub pull request. diff --git a/cmd/dev/dev_work.go b/cmd/dev/dev_work.go index 50cfaa66..e1ceef75 100644 --- a/cmd/dev/dev_work.go +++ b/cmd/dev/dev_work.go @@ -9,7 +9,6 @@ import ( "sort" "strings" - "github.com/charmbracelet/lipgloss" "github.com/host-uk/core/cmd/shared" "github.com/host-uk/core/pkg/git" "github.com/host-uk/core/pkg/repos" @@ -125,8 +124,7 @@ func runWork(registryPath string, statusOnly, autoCommit bool) error { // Auto-commit dirty repos if requested if autoCommit && len(dirtyRepos) > 0 { fmt.Println() - hdrStyle := lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("#3b82f6")) - fmt.Printf("%s\n", hdrStyle.Render("Committing dirty repos with Claude...")) + fmt.Printf("%s\n", shared.TitleStyle.Render("Committing dirty repos with Claude...")) fmt.Println() for _, s := range dirtyRepos { @@ -211,14 +209,13 @@ func printStatusTable(statuses []git.RepoStatus) { } // Print header with fixed-width formatting - hdrStyle := lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("#3b82f6")) fmt.Printf("%-*s %8s %9s %6s %5s\n", nameWidth, - hdrStyle.Render("Repo"), - hdrStyle.Render("Modified"), - hdrStyle.Render("Untracked"), - hdrStyle.Render("Staged"), - hdrStyle.Render("Ahead"), + shared.TitleStyle.Render("Repo"), + shared.TitleStyle.Render("Modified"), + shared.TitleStyle.Render("Untracked"), + shared.TitleStyle.Render("Staged"), + shared.TitleStyle.Render("Ahead"), ) // Print separator diff --git a/cmd/php/php.go b/cmd/php/php.go index f76bd40d..a2a02318 100644 --- a/cmd/php/php.go +++ b/cmd/php/php.go @@ -18,7 +18,7 @@ var ( // Service colors for log output (domain-specific, keep local) var ( phpFrankenPHPStyle = lipgloss.NewStyle().Foreground(shared.ColourIndigo500) - phpViteStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#eab308")) // yellow-500 + phpViteStyle = lipgloss.NewStyle().Foreground(shared.ColourYellow500) phpHorizonStyle = lipgloss.NewStyle().Foreground(shared.ColourOrange500) phpReverbStyle = lipgloss.NewStyle().Foreground(shared.ColourViolet500) phpRedisStyle = lipgloss.NewStyle().Foreground(shared.ColourRed500) diff --git a/cmd/php/php_deploy.go b/cmd/php/php_deploy.go index 57ea918a..6f9a8740 100644 --- a/cmd/php/php_deploy.go +++ b/cmd/php/php_deploy.go @@ -6,21 +6,16 @@ import ( "os" "time" - "github.com/charmbracelet/lipgloss" + "github.com/host-uk/core/cmd/shared" phppkg "github.com/host-uk/core/pkg/php" "github.com/spf13/cobra" ) -// Deploy command styles +// Deploy command styles (aliases to shared) var ( - phpDeployStyle = lipgloss.NewStyle(). - Foreground(lipgloss.Color("#10b981")) // emerald-500 - - phpDeployPendingStyle = lipgloss.NewStyle(). - Foreground(lipgloss.Color("#f59e0b")) // amber-500 - - phpDeployFailedStyle = lipgloss.NewStyle(). - Foreground(lipgloss.Color("#ef4444")) // red-500 + phpDeployStyle = shared.DeploySuccessStyle + phpDeployPendingStyle = shared.StatusWarningStyle + phpDeployFailedStyle = shared.StatusErrorStyle ) func addPHPDeployCommands(parent *cobra.Command) { diff --git a/cmd/sdk/sdk.go b/cmd/sdk/sdk.go index 124bf193..cc219df0 100644 --- a/cmd/sdk/sdk.go +++ b/cmd/sdk/sdk.go @@ -5,26 +5,17 @@ import ( "fmt" "os" - "github.com/charmbracelet/lipgloss" + "github.com/host-uk/core/cmd/shared" sdkpkg "github.com/host-uk/core/pkg/sdk" "github.com/spf13/cobra" ) +// SDK styles (aliases to shared) var ( - sdkHeaderStyle = lipgloss.NewStyle(). - Bold(true). - Foreground(lipgloss.Color("#3b82f6")) - - sdkSuccessStyle = lipgloss.NewStyle(). - Bold(true). - Foreground(lipgloss.Color("#22c55e")) - - sdkErrorStyle = lipgloss.NewStyle(). - Bold(true). - Foreground(lipgloss.Color("#ef4444")) - - sdkDimStyle = lipgloss.NewStyle(). - Foreground(lipgloss.Color("#6b7280")) + sdkHeaderStyle = shared.TitleStyle + sdkSuccessStyle = shared.SuccessStyle + sdkErrorStyle = shared.ErrorStyle + sdkDimStyle = shared.DimStyle ) var sdkCmd = &cobra.Command{ diff --git a/cmd/shared/styles.go b/cmd/shared/styles.go index 93ecabaf..2ac654b6 100644 --- a/cmd/shared/styles.go +++ b/cmd/shared/styles.go @@ -37,11 +37,14 @@ const ( ColourAmber400 = lipgloss.Color("#fbbf24") ColourAmber500 = lipgloss.Color("#f59e0b") ColourAmber600 = lipgloss.Color("#d97706") - ColourOrange500 = lipgloss.Color("#f97316") - ColourViolet400 = lipgloss.Color("#a78bfa") - ColourViolet500 = lipgloss.Color("#8b5cf6") - ColourIndigo500 = lipgloss.Color("#6366f1") - ColourCyan500 = lipgloss.Color("#06b6d4") + ColourOrange500 = lipgloss.Color("#f97316") + ColourYellow500 = lipgloss.Color("#eab308") + ColourEmerald500 = lipgloss.Color("#10b981") + ColourPurple500 = lipgloss.Color("#a855f7") + ColourViolet400 = lipgloss.Color("#a78bfa") + ColourViolet500 = lipgloss.Color("#8b5cf6") + ColourIndigo500 = lipgloss.Color("#6366f1") + ColourCyan500 = lipgloss.Color("#06b6d4") ColourGray50 = lipgloss.Color("#f9fafb") ColourGray100 = lipgloss.Color("#f3f4f6") ColourGray200 = lipgloss.Color("#e5e7eb") @@ -169,6 +172,11 @@ var ( // NumberStyle for numeric values. NumberStyle = lipgloss.NewStyle(). Foreground(ColourBlue300) + + // PrNumberStyle for pull request numbers (purple, bold). + PrNumberStyle = lipgloss.NewStyle(). + Bold(true). + Foreground(ColourPurple500) ) // ───────────────────────────────────────────────────────────────────────────── @@ -261,6 +269,21 @@ var ( GitConflictStyle = lipgloss.NewStyle().Bold(true).Foreground(ColourRed500) ) +// ───────────────────────────────────────────────────────────────────────────── +// Deploy Styles (for deployment status display) +// ───────────────────────────────────────────────────────────────────────────── + +var ( + // DeploySuccessStyle for successful deployments (emerald). + DeploySuccessStyle = lipgloss.NewStyle().Foreground(ColourEmerald500) + + // DeployPendingStyle for pending deployments (amber). + DeployPendingStyle = lipgloss.NewStyle().Foreground(ColourAmber500) + + // DeployFailedStyle for failed deployments (red). + DeployFailedStyle = lipgloss.NewStyle().Foreground(ColourRed500) +) + // ───────────────────────────────────────────────────────────────────────────── // Box Styles (for bordered content) // ─────────────────────────────────────────────────────────────────────────────