From 8bf8f96d3b279584e9d89dbb17bf9eccf4865d9a Mon Sep 17 00:00:00 2001 From: Jonas Ulrich | ruhmesmeile GmbH Date: Mon, 29 Jan 2024 20:09:23 +0100 Subject: [PATCH] fix(storyblok): add component / blok classification --- src/commands/cms/storyblok.ts | 17 +++++++++++++++++ src/tasks/cms/storyblok-task.ts | 15 ++++++++++++++- src/util/schema.ts | 7 +++++-- types/index.d.ts | 3 ++- 4 files changed, 38 insertions(+), 4 deletions(-) diff --git a/src/commands/cms/storyblok.ts b/src/commands/cms/storyblok.ts index 1bda62c..7c28ca1 100644 --- a/src/commands/cms/storyblok.ts +++ b/src/commands/cms/storyblok.ts @@ -31,6 +31,22 @@ const storyblok = new Command('storyblok') chalkTemplate`components to classify as global components`, ['header', 'footer', 'seo'] ) + .option( + '--components ', + chalkTemplate`components to classify as bloks`, + [ + 'cta', + 'faq', + 'features', + 'gallery', + 'image-text', + 'logos', + 'stats', + 'teaser-card', + 'testimonials', + 'text', + ] + ) .option( '--rc-only', chalkTemplate`only read configuration from {bold .schema-storyblokrc.json}, skip prompts`, @@ -50,6 +66,7 @@ const storyblok = new Command('storyblok') options.updateConfig, options.templates, options.globals, + options.components, options.rcOnly, options.revert, options.cleanup, diff --git a/src/tasks/cms/storyblok-task.ts b/src/tasks/cms/storyblok-task.ts index 9d368e7..ae55456 100644 --- a/src/tasks/cms/storyblok-task.ts +++ b/src/tasks/cms/storyblok-task.ts @@ -39,6 +39,18 @@ const run = async ( updateConfig: boolean = true, templates: string[] = ['page', 'blog-post', 'blog-overview', 'settings'], globals: string[] = ['header', 'footer', 'seo'], + components: string[] = [ + 'cta', + 'faq', + 'features', + 'gallery', + 'image-text', + 'logos', + 'stats', + 'teaser-card', + 'testimonials', + 'text', + ], rcOnly: boolean, isRevert: boolean, shouldCleanup: boolean, @@ -62,7 +74,8 @@ const run = async ( const elements = await schemaToStoryblok( customSchemaGlob, templates, - globals + globals, + components ); shell.mkdir('-p', `${shell.pwd()}/${configurationPath}/`); diff --git a/src/util/schema.ts b/src/util/schema.ts index 3b502e9..73914ec 100644 --- a/src/util/schema.ts +++ b/src/util/schema.ts @@ -189,7 +189,8 @@ ${convertedTs[schemaId]} const toStoryblok = async ( schemaGlob: string, templates: string[], - globals: string[] + globals: string[], + components: string[] ) => { const ajv = getSchemaRegistry(); const schemaIds = await processSchemaGlob(schemaGlob, ajv); @@ -206,8 +207,10 @@ ${convertedTs[schemaId]} return IClassifierResult.Template; } else if (globals && globals.includes(name)) { return IClassifierResult.Global; - } else { + } else if (components && components.includes(name)) { return IClassifierResult.Component; + } else { + return IClassifierResult.Object; } }, }); diff --git a/types/index.d.ts b/types/index.d.ts index 641df54..48a34b9 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -226,7 +226,8 @@ interface SchemaUtil { toStoryblok: ( schemaGlob: string, templates: string[], - globals: string[] + globals: string[], + components: string[] ) => Promise>; toStoryblokConfig: (elements: CMSResult) => string; toUniform: (