From 0e7a49666628358464b9605c3893fde79798f716 Mon Sep 17 00:00:00 2001 From: Jonas Ulrich Date: Tue, 20 Aug 2024 14:52:19 +0000 Subject: [PATCH 1/5] Update CHANGELOG.md [skip ci] --- CHANGELOG.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d4ecf12..c6b5f46 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,18 @@ +# v3.1.0 (Tue Aug 20 2024) + +#### 🚀 Enhancement + +- Add cms layering capabilities [#52](https://github.com/kickstartDS/cli/pull/52) ([@julrich](https://github.com/julrich)) + +#### 🐛 Bug Fix + + +#### Authors: 1 + +- Jonas Ulrich ([@julrich](https://github.com/julrich)) + +--- + # v3.0.0 (Fri Apr 12 2024) #### 💥 Breaking Change From 344fb5679c91b4b2f13235023c22b1480c51e5ae Mon Sep 17 00:00:00 2001 From: Jonas Ulrich Date: Tue, 20 Aug 2024 14:52:37 +0000 Subject: [PATCH 2/5] Bump version to: 3.1.0 [skip ci] --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ccc55e1..a7174c0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "kickstartds", - "version": "3.0.0", + "version": "3.1.0", "description": "kickstartDS CLI utility", "keywords": [], "license": "(MIT OR Apache-2.0)", From d9aff4f7ed2991eeaea12a8905223f13940e1c88 Mon Sep 17 00:00:00 2001 From: Jonas Ulrich | ruhmesmeile GmbH Date: Tue, 24 Sep 2024 15:57:14 +0200 Subject: [PATCH 3/5] fix(schema): add option to exclude default page schema from dereference --- src/commands/schema/dereference.ts | 5 +++++ src/tasks/schema/dereference-task.ts | 3 ++- src/util/schema.ts | 9 +++++++-- types/index.d.ts | 3 ++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/commands/schema/dereference.ts b/src/commands/schema/dereference.ts index f7efd4d..e10be23 100644 --- a/src/commands/schema/dereference.ts +++ b/src/commands/schema/dereference.ts @@ -15,6 +15,10 @@ const dereference = new Command('dereference') '--cms-path ', chalkTemplate`relative path from project root to your cms specific components directory, default {bold ./src/components}` ) + .option( + '--load-page-schema', + chalkTemplate`load default page schema, default {bold true}` + ) .option( '--rc-only', chalkTemplate`only read configuration from {bold .schema-dereferencerc.json}, skip prompts`, @@ -31,6 +35,7 @@ const dereference = new Command('dereference') runTask( options.componentsPath, options.cmsPath, + options.loadPageSchema, options.rcOnly, options.revert, options.cleanup, diff --git a/src/tasks/schema/dereference-task.ts b/src/tasks/schema/dereference-task.ts index 3e2ff81..410ae2b 100644 --- a/src/tasks/schema/dereference-task.ts +++ b/src/tasks/schema/dereference-task.ts @@ -31,6 +31,7 @@ const { const run = async ( componentsPath: string = 'src/components', cmsPath: string, + loadPageSchema: boolean = true, rcOnly: boolean, isRevert: boolean, shouldCleanup: boolean, @@ -56,7 +57,7 @@ const run = async ( globs.push(`${callingPath}/${cmsPath}/**/*.schema.json`); } const customSchemaPaths = await fg(globs); - const dereffed = await schemaDereferenceSchemas(globs); + const dereffed = await schemaDereferenceSchemas(globs, loadPageSchema); logger.info( chalkTemplate`dereffed {bold ${ diff --git a/src/util/schema.ts b/src/util/schema.ts index cc1085a..d69a8a3 100644 --- a/src/util/schema.ts +++ b/src/util/schema.ts @@ -26,9 +26,14 @@ const renderImportName = (schemaId: string) => export default (logger: winston.Logger): SchemaUtil => { const subCmdLogger = logger.child({ utility: true }); - const dereferenceSchemas = async (schemaGlobs: string[]) => { + const dereferenceSchemas = async ( + schemaGlobs: string[], + loadPageSchema = true + ) => { const ajv = getSchemaRegistry(); - const schemaIds = await processSchemaGlobs(schemaGlobs, ajv); + const schemaIds = await processSchemaGlobs(schemaGlobs, ajv, { + loadPageSchema, + }); const customSchemaIds = getCustomSchemaIds(schemaIds); const dereffedSchemas = await dereference(customSchemaIds, ajv); diff --git a/types/index.d.ts b/types/index.d.ts index ab7e4be..5201236 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -222,7 +222,8 @@ interface SchemaUtil { mergeAllOf: boolean ) => Promise>; dereferenceSchemas: ( - schemaGlobs: string[] + schemaGlobs: string[], + loadPageSchema: boolean ) => Promise>; toStoryblok: ( schemaGlobs: string[], From 38509dd99cf9358a87a794f22c76039f489cf972 Mon Sep 17 00:00:00 2001 From: Jonas Ulrich | ruhmesmeile GmbH Date: Tue, 24 Sep 2024 16:18:12 +0200 Subject: [PATCH 4/5] fix(schema): option for page schema exclusion --- src/commands/schema/dereference.ts | 6 +++--- src/tasks/schema/dereference-task.ts | 4 ++-- src/util/schema.ts | 4 ++-- types/index.d.ts | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/commands/schema/dereference.ts b/src/commands/schema/dereference.ts index e10be23..bbe9065 100644 --- a/src/commands/schema/dereference.ts +++ b/src/commands/schema/dereference.ts @@ -16,8 +16,8 @@ const dereference = new Command('dereference') chalkTemplate`relative path from project root to your cms specific components directory, default {bold ./src/components}` ) .option( - '--load-page-schema', - chalkTemplate`load default page schema, default {bold true}` + '--no-default-page-schema', + chalkTemplate`disable load of default page schema, default {bold false}` ) .option( '--rc-only', @@ -35,7 +35,7 @@ const dereference = new Command('dereference') runTask( options.componentsPath, options.cmsPath, - options.loadPageSchema, + options.defaultPageSchema, options.rcOnly, options.revert, options.cleanup, diff --git a/src/tasks/schema/dereference-task.ts b/src/tasks/schema/dereference-task.ts index 410ae2b..c868f41 100644 --- a/src/tasks/schema/dereference-task.ts +++ b/src/tasks/schema/dereference-task.ts @@ -31,7 +31,7 @@ const { const run = async ( componentsPath: string = 'src/components', cmsPath: string, - loadPageSchema: boolean = true, + defaultPageSchema: boolean = true, rcOnly: boolean, isRevert: boolean, shouldCleanup: boolean, @@ -57,7 +57,7 @@ const run = async ( globs.push(`${callingPath}/${cmsPath}/**/*.schema.json`); } const customSchemaPaths = await fg(globs); - const dereffed = await schemaDereferenceSchemas(globs, loadPageSchema); + const dereffed = await schemaDereferenceSchemas(globs, defaultPageSchema); logger.info( chalkTemplate`dereffed {bold ${ diff --git a/src/util/schema.ts b/src/util/schema.ts index d69a8a3..db619f2 100644 --- a/src/util/schema.ts +++ b/src/util/schema.ts @@ -28,11 +28,11 @@ export default (logger: winston.Logger): SchemaUtil => { const dereferenceSchemas = async ( schemaGlobs: string[], - loadPageSchema = true + defaultPageSchema = true ) => { const ajv = getSchemaRegistry(); const schemaIds = await processSchemaGlobs(schemaGlobs, ajv, { - loadPageSchema, + loadPageSchema: defaultPageSchema, }); const customSchemaIds = getCustomSchemaIds(schemaIds); diff --git a/types/index.d.ts b/types/index.d.ts index 5201236..3c25e3a 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -223,7 +223,7 @@ interface SchemaUtil { ) => Promise>; dereferenceSchemas: ( schemaGlobs: string[], - loadPageSchema: boolean + defaultPageSchema: boolean ) => Promise>; toStoryblok: ( schemaGlobs: string[], From dc35b8a0777e84abed130f58972107b643148a15 Mon Sep 17 00:00:00 2001 From: Jonas Ulrich | ruhmesmeile GmbH Date: Tue, 24 Sep 2024 17:00:29 +0200 Subject: [PATCH 5/5] fix(schema): add page exclusion option to other schema related tasks --- src/commands/schema/layer.ts | 5 +++++ src/commands/schema/types.ts | 5 +++++ src/tasks/schema/layer-task.ts | 4 +++- src/tasks/schema/types-task.ts | 7 ++++++- src/util/schema.ts | 8 ++++++-- types/index.d.ts | 6 ++++-- 6 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/commands/schema/layer.ts b/src/commands/schema/layer.ts index ba6329e..126e3d4 100644 --- a/src/commands/schema/layer.ts +++ b/src/commands/schema/layer.ts @@ -25,6 +25,10 @@ const types = new Command('layer') chalkTemplate`merge allOf declarations in processed {bold JSON Schemas} / {bold component APIs}, default {bold false}`, false ) + .option( + '--no-default-page-schema', + chalkTemplate`disable load of default page schema, default {bold false}` + ) .option( '--rc-only', chalkTemplate`only read configuration from {bold .schema-typesrc.json}, skip prompts`, @@ -43,6 +47,7 @@ const types = new Command('layer') options.cmsPath, options.typesPath, options.mergeSchemas, + options.defaultPageSchema, options.rcOnly, options.revert, options.cleanup, diff --git a/src/commands/schema/types.ts b/src/commands/schema/types.ts index 2c97396..a4a58b5 100644 --- a/src/commands/schema/types.ts +++ b/src/commands/schema/types.ts @@ -20,6 +20,10 @@ const types = new Command('types') chalkTemplate`merge allOf declarations in processed {bold JSON Schemas} / {bold component APIs}, default {bold false}`, false ) + .option( + '--no-default-page-schema', + chalkTemplate`disable load of default page schema, default {bold false}` + ) .option( '--rc-only', chalkTemplate`only read configuration from {bold .schema-typesrc.json}, skip prompts`, @@ -37,6 +41,7 @@ const types = new Command('types') options.componentsPath, options.cmsPath, options.mergeSchemas, + options.defaultPageSchema, options.rcOnly, options.revert, options.cleanup, diff --git a/src/tasks/schema/layer-task.ts b/src/tasks/schema/layer-task.ts index d2bfade..69de36e 100644 --- a/src/tasks/schema/layer-task.ts +++ b/src/tasks/schema/layer-task.ts @@ -35,6 +35,7 @@ const run = async ( cmsPath: string, typesPath: string = 'src/types', mergeSchemas: boolean, + defaultPageSchema: boolean = true, rcOnly: boolean, isRevert: boolean, shouldCleanup: boolean, @@ -62,7 +63,8 @@ const run = async ( const layeredTypes = await schemaLayerComponentPropTypes( globs, - mergeSchemas + mergeSchemas, + defaultPageSchema ); shell.mkdir('-p', `${shell.pwd()}/${typesPath}/`); diff --git a/src/tasks/schema/types-task.ts b/src/tasks/schema/types-task.ts index 6c0d8b3..e140ef8 100644 --- a/src/tasks/schema/types-task.ts +++ b/src/tasks/schema/types-task.ts @@ -33,6 +33,7 @@ const run = async ( componentsPath: string = 'src/components', cmsPath: string, mergeSchemas: boolean, + defaultPageSchema: boolean = true, rcOnly: boolean, isRevert: boolean, shouldCleanup: boolean, @@ -58,7 +59,11 @@ const run = async ( globs.push(`${callingPath}/${cmsPath}/**/*.schema.json`); } const customSchemaPaths = await fg(globs); - const types = await schemaGenerateComponentPropTypes(globs, mergeSchemas); + const types = await schemaGenerateComponentPropTypes( + globs, + mergeSchemas, + defaultPageSchema + ); await Promise.all( Object.keys(types).map(async (schemaId) => { diff --git a/src/util/schema.ts b/src/util/schema.ts index db619f2..51e339e 100644 --- a/src/util/schema.ts +++ b/src/util/schema.ts @@ -81,7 +81,8 @@ export default (logger: winston.Logger): SchemaUtil => { const generateComponentPropTypes = async ( schemaGlobs: string[], - mergeAllOf: boolean + mergeAllOf: boolean, + defaultPageSchema = true ) => { subCmdLogger.info( chalkTemplate`generating component prop types for component schemas` @@ -91,6 +92,7 @@ export default (logger: winston.Logger): SchemaUtil => { const schemaIds = await processSchemaGlobs(schemaGlobs, ajv, { typeResolution: false, mergeAllOf: mergeAllOf, + loadPageSchema: defaultPageSchema, }); const customSchemaIds = getCustomSchemaIds(schemaIds); @@ -121,7 +123,8 @@ export default (logger: winston.Logger): SchemaUtil => { const layerComponentPropTypes = async ( schemaGlobs: string[], - mergeAllOf: boolean + mergeAllOf: boolean, + defaultPageSchema = true ) => { subCmdLogger.info( chalkTemplate`layering component prop types for component schemas` @@ -131,6 +134,7 @@ export default (logger: winston.Logger): SchemaUtil => { const schemaIds = await processSchemaGlobs(schemaGlobs, ajv, { typeResolution: false, mergeAllOf: mergeAllOf, + loadPageSchema: defaultPageSchema, }); const kdsSchemaIds = schemaIds.filter((schemaId) => schemaId.includes('schema.kickstartds.com') diff --git a/types/index.d.ts b/types/index.d.ts index 3c25e3a..21d80c9 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -215,11 +215,13 @@ interface SchemaUtil { helper: { generateComponentPropTypes: ( schemaGlobs: string[], - mergeAllOf: boolean + mergeAllOf: boolean, + defaultPageSchema: boolean ) => Promise>; layerComponentPropTypes: ( schemaGlobs: string[], - mergeAllOf: boolean + mergeAllOf: boolean, + defaultPageSchema: boolean ) => Promise>; dereferenceSchemas: ( schemaGlobs: string[],