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[],