Skip to content

Commit

Permalink
fix(schema): add changes from main
Browse files Browse the repository at this point in the history
  • Loading branch information
julrich committed Oct 4, 2024
2 parents 15a8a48 + 40d4f36 commit 32284ae
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/tasks/schema/types-task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ const run = async (
const types = await schemaGenerateComponentPropTypes(
globs,
mergeSchemas,
defaultPageSchema
defaultPageSchema,
componentsPath
);

await Promise.all(
Expand Down
11 changes: 9 additions & 2 deletions src/util/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
getUniqueSchemaIds,
isLayering,
layeredSchemaId,
processSchemaGlob,
shouldLayer,
dereference,
IClassifierResult,
Expand Down Expand Up @@ -82,7 +81,8 @@ export default (logger: winston.Logger): SchemaUtil => {
const generateComponentPropTypes = async (
schemaGlobs: string[],
mergeAllOf: boolean,
defaultPageSchema = true
defaultPageSchema = true,
componentsPath = 'src/components'
) => {
subCmdLogger.info(
chalkTemplate`generating component prop types for component schemas`
Expand All @@ -103,6 +103,13 @@ export default (logger: winston.Logger): SchemaUtil => {
)}Props } from '@kickstartds/${getSchemaModule(
schemaId
)}/lib/${getSchemaName(schemaId)}/typing'`
: componentsPath.startsWith('node_modules/')
? `import type { ${pascalCase(
getSchemaName(schemaId)
)}Props } from '${componentsPath
.split('/')
.slice(1, 2)
.join('/')}/${getSchemaName(schemaId)}`
: `import type { ${pascalCase(
getSchemaName(schemaId)
)}Props } from '../${getSchemaName(schemaId)}/${pascalCase(
Expand Down
3 changes: 2 additions & 1 deletion types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ interface SchemaUtil {
generateComponentPropTypes: (
schemaGlobs: string[],
mergeAllOf: boolean,
defaultPageSchema: boolean
defaultPageSchema: boolean,
componentsPath: string
) => Promise<Record<string, string>>;
layerComponentPropTypes: (
schemaGlobs: string[],
Expand Down

0 comments on commit 32284ae

Please sign in to comment.