summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/themes/theme.ts
diff options
context:
space:
mode:
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,
+ };
}
/**