@@ -149,7 +149,7 @@ export default class ContentType {
149149 */
150150 async writeFixContent ( ) {
151151 let canWrite = true ;
152-
152+
153153 if ( ! this . inMemoryFix && this . fix ) {
154154 if ( ! this . config . flags [ 'copy-dir' ] && ! this . config . flags [ 'external-config' ] ?. skipConfirm ) {
155155 canWrite = this . config . flags . yes ?? ( await cliux . confirm ( commonMsg . FIX_CONFIRMATION ) ) ;
@@ -460,7 +460,7 @@ export default class ContentType {
460460 runFixOnSchema ( tree : Record < string , unknown > [ ] , schema : ContentTypeSchemaType [ ] ) {
461461 // NOTE Global field Fix
462462 return schema
463- . map ( ( field ) => {
463+ ? .map ( ( field ) => {
464464 const { data_type } = field ;
465465 const fixTypes = this . config . flags [ 'fix-only' ] ?? this . config [ 'fix-fields' ] ;
466466
@@ -560,10 +560,7 @@ export default class ContentType {
560560 } else if ( ! field . schema && this . moduleName === 'global-fields' ) {
561561 const gfSchema = find ( this . gfSchema , { uid : field . reference_to } ) ?. schema ;
562562 if ( gfSchema ) {
563-
564563 field . schema = gfSchema as GlobalFieldSchemaTypes [ ] ;
565-
566-
567564 } else {
568565 this . missingRefs [ this . currentUid ] . push ( {
569566 tree,
@@ -577,6 +574,10 @@ export default class ContentType {
577574 } ) ;
578575 }
579576 }
577+
578+ if ( field . schema && ! isEmpty ( field . schema ) ) {
579+ field . schema = this . runFixOnSchema ( tree , field . schema as ContentTypeSchemaType [ ] ) ;
580+ }
580581 return refExist ? field : null ;
581582 }
582583
@@ -593,7 +594,7 @@ export default class ContentType {
593594 */
594595 fixModularBlocksReferences ( tree : Record < string , unknown > [ ] , blocks : ModularBlockType [ ] ) {
595596 return blocks
596- . map ( ( block ) => {
597+ ? .map ( ( block ) => {
597598 const { reference_to, schema, title : display_name } = block ;
598599 tree = [ ...tree , { uid : block . uid , name : block . title } ] ;
599600 const refErrorObj = {
@@ -606,7 +607,7 @@ export default class ContentType {
606607 treeStr : tree . map ( ( { name } ) => name ) . join ( ' ➜ ' ) ,
607608 } ;
608609
609- if ( ! schema ) {
610+ if ( ! schema && this . moduleName === 'content-types' ) {
610611 this . missingRefs [ this . currentUid ] . push ( refErrorObj ) ;
611612
612613 return false ;
@@ -615,7 +616,11 @@ export default class ContentType {
615616 // NOTE Global field section
616617 if ( reference_to ) {
617618 const refExist = find ( this . gfSchema , { uid : reference_to } ) ;
619+ if ( ! refExist ) {
620+ this . missingRefs [ this . currentUid ] . push ( refErrorObj ) ;
618621
622+ return false ;
623+ }
619624 if ( ! refExist ) {
620625 this . missingRefs [ this . currentUid ] . push ( refErrorObj ) ;
621626
@@ -625,7 +630,7 @@ export default class ContentType {
625630
626631 block . schema = this . runFixOnSchema ( tree , block . schema as ContentTypeSchemaType [ ] ) ;
627632
628- if ( isEmpty ( block . schema ) ) {
633+ if ( isEmpty ( block . schema ) && this . moduleName === 'content-types' ) {
629634 this . missingRefs [ this . currentUid ] . push ( {
630635 ...refErrorObj ,
631636 missingRefs : 'Empty schema found' ,
0 commit comments