@@ -202,7 +202,12 @@ export async function updateResourceConfig(resourceId, columnName, fieldType, co
202202 const outputCode = recast . print ( ast ) . code ;
203203
204204 await fs . writeFile ( filePath , outputCode , 'utf-8' ) ;
205- console . log ( chalk . dim ( `Successfully updated resource configuration file (preserving formatting): ${ filePath } :${ injectionLine } ` ) ) ;
205+ console . log (
206+ chalk . green (
207+ `✅ Successfully updated CRUD injection in resource file: ${ filePath } ` +
208+ ( injectionLine !== null ? `:${ injectionLine } ` : '' )
209+ )
210+ ) ;
206211
207212 } catch ( error ) {
208213 console . error ( chalk . red ( `❌ Error processing resource file: ${ filePath } ` ) ) ;
@@ -309,7 +314,12 @@ export async function injectLoginComponent(indexFilePath, componentPath) {
309314
310315 const outputCode = recast . print ( ast ) . code ;
311316 await fs . writeFile ( indexFilePath , outputCode , 'utf-8' ) ;
312- console . log ( chalk . green ( `✅ Successfully updated login injection in: ${ indexFilePath } :${ injectionLine } ` ) ) ;
317+ console . log (
318+ chalk . green (
319+ `✅ Successfully updated CRUD injection in resource file: ${ indexFilePath } ` +
320+ ( injectionLine !== null ? `:${ injectionLine } ` : '' )
321+ )
322+ ) ;
313323 }
314324
315325
@@ -402,7 +412,12 @@ export async function injectGlobalComponent(indexFilePath, injectionType, compon
402412
403413 const outputCode = recast . print ( ast ) . code ;
404414 await fs . writeFile ( indexFilePath , outputCode , 'utf-8' ) ;
405- console . log ( chalk . green ( `✅ Successfully updated global injection '${ injectionType } ' in: ${ indexFilePath } :${ injectionLine } ` ) ) ;
415+ console . log (
416+ chalk . green (
417+ `✅ Successfully updated CRUD injection in resource file: ${ indexFilePath } ` +
418+ ( injectionLine !== null ? `:${ injectionLine } ` : '' )
419+ )
420+ ) ;
406421}
407422
408423export async function updateCrudInjectionConfig ( resourceId , crudType , injectionPosition , componentPathForConfig , isThin ) {
@@ -487,11 +502,23 @@ export async function updateCrudInjectionConfig(resourceId, crudType, injectionP
487502 ] ) ;
488503
489504 if ( injectionProp ) {
490- injectionProp . value = newInjectionObject ;
491- console . log ( chalk . dim ( `Updated '${ injectionPosition } ' injection for '${ crudType } '.` ) ) ;
505+ if ( n . ArrayExpression . check ( injectionProp . value ) ) {
506+ injectionProp . value . elements . push ( newInjectionObject ) ;
507+ console . log ( chalk . dim ( `Appended new injection to array at '${ injectionPosition } ' for '${ crudType } '.` ) ) ;
508+ }
509+ else if ( n . ObjectExpression . check ( injectionProp . value ) ) {
510+ injectionProp . value = b . arrayExpression ( [ injectionProp . value , newInjectionObject ] ) ;
511+ console . log ( chalk . dim ( `Converted to array and added new injection at '${ injectionPosition } ' for '${ crudType } '.` ) ) ;
512+ }
513+ else {
514+ injectionProp . value = b . arrayExpression ( [ newInjectionObject ] ) ;
515+ console . log ( chalk . yellow ( `⚠️ Replaced invalid injection at '${ injectionPosition } ' with array.` ) ) ;
516+ }
492517 } else {
493- crudValue . properties . push ( b . objectProperty ( b . identifier ( injectionPosition ) , newInjectionObject ) ) ;
494- console . log ( chalk . dim ( `Added '${ injectionPosition } ' injection for '${ crudType } '.` ) ) ;
518+ crudValue . properties . push (
519+ b . objectProperty ( b . identifier ( injectionPosition ) , b . arrayExpression ( [ newInjectionObject ] ) )
520+ ) ;
521+ console . log ( chalk . dim ( `Added new array of injections at '${ injectionPosition } ' for '${ crudType } '.` ) ) ;
495522 }
496523
497524 updateApplied = true ;
@@ -506,7 +533,12 @@ export async function updateCrudInjectionConfig(resourceId, crudType, injectionP
506533
507534 const outputCode = recast . print ( ast ) . code ;
508535 await fs . writeFile ( filePath , outputCode , 'utf-8' ) ;
509- console . log ( chalk . dim ( `✅ Successfully updated CRUD injection in resource file: ${ filePath } :${ injectionLine } ` ) ) ;
536+ console . log (
537+ chalk . green (
538+ `✅ Successfully updated CRUD injection in resource file: ${ filePath } ` +
539+ ( injectionLine !== null ? `:${ injectionLine } ` : '' )
540+ )
541+ ) ;
510542
511543 } catch ( error ) {
512544 console . error ( chalk . red ( `❌ Error processing resource file: ${ filePath } ` ) ) ;
0 commit comments