summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/themes/theme.ts
diff options
context:
space:
mode:
authorJacob Richman <[email protected]>2025-07-25 17:36:42 -0700
committerGitHub <[email protected]>2025-07-26 00:36:42 +0000
commitad2ef080aae2e21bf04ad8e922719ceaa81f1e5f (patch)
tree204911c95219d4cdf0bdaa3db827124ff900f078 /packages/cli/src/ui/themes/theme.ts
parentb089845f1c34e5475bcae9cc8eb42fba8be9adc4 (diff)
Fix so legacy custom themes still load. (#4757)
Co-authored-by: matt korwel <[email protected]>
Diffstat (limited to 'packages/cli/src/ui/themes/theme.ts')
-rw-r--r--packages/cli/src/ui/themes/theme.ts30
1 files changed, 25 insertions, 5 deletions
diff --git a/packages/cli/src/ui/themes/theme.ts b/packages/cli/src/ui/themes/theme.ts
index 3955014f..7d21af1d 100644
--- a/packages/cli/src/ui/themes/theme.ts
+++ b/packages/cli/src/ui/themes/theme.ts
@@ -323,6 +323,7 @@ export function createCustomTheme(customTheme: CustomTheme): Theme {
export function validateCustomTheme(customTheme: Partial<CustomTheme>): {
isValid: boolean;
error?: string;
+ warning?: string;
} {
// Check required fields
const requiredFields: Array<keyof CustomTheme> = [
@@ -336,12 +337,17 @@ export function validateCustomTheme(customTheme: Partial<CustomTheme>): {
'AccentGreen',
'AccentYellow',
'AccentRed',
- 'DiffAdded',
- 'DiffRemoved',
+ // 'DiffAdded' and 'DiffRemoved' are not required as they were added after
+ // the theme format was defined.
'Comment',
'Gray',
];
+ const recommendedFields: Array<keyof CustomTheme> = [
+ 'DiffAdded',
+ 'DiffRemoved',
+ ];
+
for (const field of requiredFields) {
if (!customTheme[field]) {
return {
@@ -351,6 +357,14 @@ export function validateCustomTheme(customTheme: Partial<CustomTheme>): {
}
}
+ const missingFields: string[] = [];
+
+ for (const field of recommendedFields) {
+ if (!customTheme[field]) {
+ missingFields.push(field);
+ }
+ }
+
// Validate color format (basic hex validation)
const colorFields: Array<keyof CustomTheme> = [
'Background',
@@ -369,8 +383,8 @@ export function validateCustomTheme(customTheme: Partial<CustomTheme>): {
];
for (const field of colorFields) {
- const color = customTheme[field] as string;
- if (!isValidColor(color)) {
+ const color = customTheme[field] as string | undefined;
+ if (color !== undefined && !isValidColor(color)) {
return {
isValid: false,
error: `Invalid color format for ${field}: ${color}`,
@@ -386,7 +400,13 @@ export function validateCustomTheme(customTheme: Partial<CustomTheme>): {
};
}
- return { isValid: true };
+ return {
+ isValid: true,
+ warning:
+ missingFields.length > 0
+ ? `Missing field(s) ${missingFields.join(', ')}`
+ : undefined,
+ };
}
/**