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