From de4d91419f96465adaf5fa3035eb75471cd2f268 Mon Sep 17 00:00:00 2001 From: meetdhanani Date: Thu, 26 Dec 2024 17:24:48 +0530 Subject: [PATCH 1/4] section-validation --- src/lib/Theme.ts | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/lib/Theme.ts b/src/lib/Theme.ts index d151e3c3..036e3c80 100644 --- a/src/lib/Theme.ts +++ b/src/lib/Theme.ts @@ -1363,13 +1363,20 @@ export default class Theme { if (!sections) { Logger.error('Error occured'); } - - const allSections = Object.entries<{ settings: any; Component: any }>( - sections, - ).map(([name, sectionModule]) => ({ - name, - ...(sectionModule.settings || {}), - })); + const allSections = Object.entries<{ settings?: any; Component?: any }>(sections).map( + ([name, sectionModule]) => { + if (!sectionModule.settings) { + Logger.warn(`The "${name}" section does not contain any settings.`) + } + if (!sectionModule.Component) { + throw new Error(`The "${name}" section must be defined with a"Component" name to proceed.`) + } + return { + name, + ...(sectionModule.settings || {}), + }; + } + ); return allSections; } From a4fa06808e48e8e58a3d0416a87c59d59c9e7593 Mon Sep 17 00:00:00 2001 From: meetdhanani Date: Thu, 26 Dec 2024 17:25:59 +0530 Subject: [PATCH 2/4] section-validation --- src/lib/Theme.ts | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/lib/Theme.ts b/src/lib/Theme.ts index 036e3c80..52f9dfb4 100644 --- a/src/lib/Theme.ts +++ b/src/lib/Theme.ts @@ -1363,20 +1363,24 @@ export default class Theme { if (!sections) { Logger.error('Error occured'); } - const allSections = Object.entries<{ settings?: any; Component?: any }>(sections).map( - ([name, sectionModule]) => { - if (!sectionModule.settings) { - Logger.warn(`The "${name}" section does not contain any settings.`) - } - if (!sectionModule.Component) { - throw new Error(`The "${name}" section must be defined with a"Component" name to proceed.`) - } - return { + const allSections = Object.entries<{ settings?: any; Component?: any }>( + sections, + ).map(([name, sectionModule]) => { + if (!sectionModule.settings) { + Logger.warn( + `The "${name}" section does not contain any settings.`, + ); + } + if (!sectionModule.Component) { + throw new Error( + `The "${name}" section must be defined with a"Component" name to proceed.`, + ); + } + return { name, ...(sectionModule.settings || {}), - }; - } - ); + }; + }); return allSections; } From 65e3acd07caa5595a5551cef7faf359271fee499 Mon Sep 17 00:00:00 2001 From: meetdhanani Date: Thu, 26 Dec 2024 17:27:16 +0530 Subject: [PATCH 3/4] section-validation --- src/lib/Theme.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/Theme.ts b/src/lib/Theme.ts index 52f9dfb4..a724f599 100644 --- a/src/lib/Theme.ts +++ b/src/lib/Theme.ts @@ -1373,7 +1373,7 @@ export default class Theme { } if (!sectionModule.Component) { throw new Error( - `The "${name}" section must be defined with a"Component" name to proceed.`, + `The "${name}" section must be defined with a "Component" name to proceed.`, ); } return { From 467674ea362e964fda2a450d0a943bff8dd296fd Mon Sep 17 00:00:00 2001 From: meetdhanani Date: Fri, 27 Dec 2024 11:27:10 +0530 Subject: [PATCH 4/4] section-validation --- src/lib/Theme.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/Theme.ts b/src/lib/Theme.ts index a724f599..634a1ae7 100644 --- a/src/lib/Theme.ts +++ b/src/lib/Theme.ts @@ -1367,13 +1367,13 @@ export default class Theme { sections, ).map(([name, sectionModule]) => { if (!sectionModule.settings) { - Logger.warn( + throw new Error( `The "${name}" section does not contain any settings.`, ); } if (!sectionModule.Component) { throw new Error( - `The "${name}" section must be defined with a "Component" name to proceed.`, + `The "${name}" section must be defined with a "Component" name.`, ); } return {