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 <noreply@anthropic.com>
This commit is contained in:
Snider 2026-01-30 01:28:39 +00:00
parent 90a049b937
commit c28d778322
9 changed files with 70 additions and 111 deletions

View file

@ -8,27 +8,17 @@ import (
"strings" "strings"
"time" "time"
"github.com/charmbracelet/lipgloss"
"github.com/host-uk/core/cmd/shared" "github.com/host-uk/core/cmd/shared"
"github.com/host-uk/core/pkg/repos" "github.com/host-uk/core/pkg/repos"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
// CI-specific styles // CI-specific styles (aliases to shared)
var ( var (
ciSuccessStyle = lipgloss.NewStyle(). ciSuccessStyle = shared.SuccessStyle
Bold(true). ciFailureStyle = shared.ErrorStyle
Foreground(lipgloss.Color("#22c55e")) // green-500 ciPendingStyle = shared.StatusWarningStyle
ciSkippedStyle = shared.DimStyle
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
) )
// WorkflowRun represents a GitHub Actions workflow run // WorkflowRun represents a GitHub Actions workflow run

View file

@ -4,23 +4,16 @@ import (
"fmt" "fmt"
"sort" "sort"
"github.com/charmbracelet/lipgloss"
"github.com/host-uk/core/cmd/shared" "github.com/host-uk/core/cmd/shared"
"github.com/host-uk/core/pkg/repos" "github.com/host-uk/core/pkg/repos"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
// Impact-specific styles // Impact-specific styles (aliases to shared)
var ( var (
impactDirectStyle = lipgloss.NewStyle(). impactDirectStyle = shared.ErrorStyle
Bold(true). impactIndirectStyle = shared.StatusWarningStyle
Foreground(lipgloss.Color("#ef4444")) // red-500 impactSafeStyle = shared.StatusSuccessStyle
impactIndirectStyle = lipgloss.NewStyle().
Foreground(lipgloss.Color("#f59e0b")) // amber-500
impactSafeStyle = lipgloss.NewStyle().
Foreground(lipgloss.Color("#22c55e")) // green-500
) )
// Impact command flags // Impact command flags

View file

@ -9,32 +9,19 @@ import (
"strings" "strings"
"time" "time"
"github.com/charmbracelet/lipgloss"
"github.com/host-uk/core/cmd/shared" "github.com/host-uk/core/cmd/shared"
"github.com/host-uk/core/pkg/repos" "github.com/host-uk/core/pkg/repos"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
// Issue-specific styles // Issue-specific styles (aliases to shared)
var ( var (
issueRepoStyle = lipgloss.NewStyle(). issueRepoStyle = shared.DimStyle
Foreground(lipgloss.Color("#6b7280")) // gray-500 issueNumberStyle = shared.TitleStyle
issueTitleStyle = shared.ValueStyle
issueNumberStyle = lipgloss.NewStyle(). issueLabelStyle = shared.WarningStyle
Bold(true). issueAssigneeStyle = shared.StatusSuccessStyle
Foreground(lipgloss.Color("#3b82f6")) // blue-500 issueAgeStyle = shared.DimStyle
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
) )
// GitHubIssue represents a GitHub issue from the API. // GitHubIssue represents a GitHub issue from the API.

View file

@ -9,37 +9,20 @@ import (
"strings" "strings"
"time" "time"
"github.com/charmbracelet/lipgloss"
"github.com/host-uk/core/cmd/shared" "github.com/host-uk/core/cmd/shared"
"github.com/host-uk/core/pkg/repos" "github.com/host-uk/core/pkg/repos"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
// PR-specific styles // PR-specific styles (aliases to shared)
var ( var (
prNumberStyle = lipgloss.NewStyle(). prNumberStyle = shared.PrNumberStyle
Bold(true). prTitleStyle = shared.ValueStyle
Foreground(lipgloss.Color("#a855f7")) // purple-500 prAuthorStyle = shared.InfoStyle
prApprovedStyle = shared.SuccessStyle
prTitleStyle = lipgloss.NewStyle(). prChangesStyle = shared.WarningStyle
Foreground(lipgloss.Color("#e2e8f0")) // gray-200 prPendingStyle = shared.DimStyle
prDraftStyle = shared.DimStyle
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
) )
// GitHubPR represents a GitHub pull request. // GitHubPR represents a GitHub pull request.

View file

@ -9,7 +9,6 @@ import (
"sort" "sort"
"strings" "strings"
"github.com/charmbracelet/lipgloss"
"github.com/host-uk/core/cmd/shared" "github.com/host-uk/core/cmd/shared"
"github.com/host-uk/core/pkg/git" "github.com/host-uk/core/pkg/git"
"github.com/host-uk/core/pkg/repos" "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 // Auto-commit dirty repos if requested
if autoCommit && len(dirtyRepos) > 0 { if autoCommit && len(dirtyRepos) > 0 {
fmt.Println() fmt.Println()
hdrStyle := lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("#3b82f6")) fmt.Printf("%s\n", shared.TitleStyle.Render("Committing dirty repos with Claude..."))
fmt.Printf("%s\n", hdrStyle.Render("Committing dirty repos with Claude..."))
fmt.Println() fmt.Println()
for _, s := range dirtyRepos { for _, s := range dirtyRepos {
@ -211,14 +209,13 @@ func printStatusTable(statuses []git.RepoStatus) {
} }
// Print header with fixed-width formatting // Print header with fixed-width formatting
hdrStyle := lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("#3b82f6"))
fmt.Printf("%-*s %8s %9s %6s %5s\n", fmt.Printf("%-*s %8s %9s %6s %5s\n",
nameWidth, nameWidth,
hdrStyle.Render("Repo"), shared.TitleStyle.Render("Repo"),
hdrStyle.Render("Modified"), shared.TitleStyle.Render("Modified"),
hdrStyle.Render("Untracked"), shared.TitleStyle.Render("Untracked"),
hdrStyle.Render("Staged"), shared.TitleStyle.Render("Staged"),
hdrStyle.Render("Ahead"), shared.TitleStyle.Render("Ahead"),
) )
// Print separator // Print separator

View file

@ -18,7 +18,7 @@ var (
// Service colors for log output (domain-specific, keep local) // Service colors for log output (domain-specific, keep local)
var ( var (
phpFrankenPHPStyle = lipgloss.NewStyle().Foreground(shared.ColourIndigo500) 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) phpHorizonStyle = lipgloss.NewStyle().Foreground(shared.ColourOrange500)
phpReverbStyle = lipgloss.NewStyle().Foreground(shared.ColourViolet500) phpReverbStyle = lipgloss.NewStyle().Foreground(shared.ColourViolet500)
phpRedisStyle = lipgloss.NewStyle().Foreground(shared.ColourRed500) phpRedisStyle = lipgloss.NewStyle().Foreground(shared.ColourRed500)

View file

@ -6,21 +6,16 @@ import (
"os" "os"
"time" "time"
"github.com/charmbracelet/lipgloss" "github.com/host-uk/core/cmd/shared"
phppkg "github.com/host-uk/core/pkg/php" phppkg "github.com/host-uk/core/pkg/php"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
// Deploy command styles // Deploy command styles (aliases to shared)
var ( var (
phpDeployStyle = lipgloss.NewStyle(). phpDeployStyle = shared.DeploySuccessStyle
Foreground(lipgloss.Color("#10b981")) // emerald-500 phpDeployPendingStyle = shared.StatusWarningStyle
phpDeployFailedStyle = shared.StatusErrorStyle
phpDeployPendingStyle = lipgloss.NewStyle().
Foreground(lipgloss.Color("#f59e0b")) // amber-500
phpDeployFailedStyle = lipgloss.NewStyle().
Foreground(lipgloss.Color("#ef4444")) // red-500
) )
func addPHPDeployCommands(parent *cobra.Command) { func addPHPDeployCommands(parent *cobra.Command) {

View file

@ -5,26 +5,17 @@ import (
"fmt" "fmt"
"os" "os"
"github.com/charmbracelet/lipgloss" "github.com/host-uk/core/cmd/shared"
sdkpkg "github.com/host-uk/core/pkg/sdk" sdkpkg "github.com/host-uk/core/pkg/sdk"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
// SDK styles (aliases to shared)
var ( var (
sdkHeaderStyle = lipgloss.NewStyle(). sdkHeaderStyle = shared.TitleStyle
Bold(true). sdkSuccessStyle = shared.SuccessStyle
Foreground(lipgloss.Color("#3b82f6")) sdkErrorStyle = shared.ErrorStyle
sdkDimStyle = shared.DimStyle
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"))
) )
var sdkCmd = &cobra.Command{ var sdkCmd = &cobra.Command{

View file

@ -37,11 +37,14 @@ const (
ColourAmber400 = lipgloss.Color("#fbbf24") ColourAmber400 = lipgloss.Color("#fbbf24")
ColourAmber500 = lipgloss.Color("#f59e0b") ColourAmber500 = lipgloss.Color("#f59e0b")
ColourAmber600 = lipgloss.Color("#d97706") ColourAmber600 = lipgloss.Color("#d97706")
ColourOrange500 = lipgloss.Color("#f97316") ColourOrange500 = lipgloss.Color("#f97316")
ColourViolet400 = lipgloss.Color("#a78bfa") ColourYellow500 = lipgloss.Color("#eab308")
ColourViolet500 = lipgloss.Color("#8b5cf6") ColourEmerald500 = lipgloss.Color("#10b981")
ColourIndigo500 = lipgloss.Color("#6366f1") ColourPurple500 = lipgloss.Color("#a855f7")
ColourCyan500 = lipgloss.Color("#06b6d4") ColourViolet400 = lipgloss.Color("#a78bfa")
ColourViolet500 = lipgloss.Color("#8b5cf6")
ColourIndigo500 = lipgloss.Color("#6366f1")
ColourCyan500 = lipgloss.Color("#06b6d4")
ColourGray50 = lipgloss.Color("#f9fafb") ColourGray50 = lipgloss.Color("#f9fafb")
ColourGray100 = lipgloss.Color("#f3f4f6") ColourGray100 = lipgloss.Color("#f3f4f6")
ColourGray200 = lipgloss.Color("#e5e7eb") ColourGray200 = lipgloss.Color("#e5e7eb")
@ -169,6 +172,11 @@ var (
// NumberStyle for numeric values. // NumberStyle for numeric values.
NumberStyle = lipgloss.NewStyle(). NumberStyle = lipgloss.NewStyle().
Foreground(ColourBlue300) 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) 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) // Box Styles (for bordered content)
// ───────────────────────────────────────────────────────────────────────────── // ─────────────────────────────────────────────────────────────────────────────