@@ -382,12 +382,14 @@ async function genManifestsAction(
382382 process . exit ( 1 )
383383 }
384384
385- // Create the manifests directory if it doesn't exist
385+ // Clean up and recreate the manifests directory
386386 const manifestsDir = path . join ( cwd ( ) , "manifests" )
387- if ( ! fs . existsSync ( manifestsDir ) ) {
388- moduleLogger . info ( `Creating manifests directory: ${ manifestsDir } ` )
389- fs . mkdirSync ( manifestsDir )
387+ if ( fs . existsSync ( manifestsDir ) ) {
388+ moduleLogger . info ( `Removing existing manifests directory: ${ manifestsDir } ` )
389+ fs . rmSync ( manifestsDir , { recursive : true , force : true } )
390390 }
391+ moduleLogger . info ( `Creating fresh manifests directory: ${ manifestsDir } ` )
392+ fs . mkdirSync ( manifestsDir , { recursive : true } )
391393
392394 // Get all direct subdirectories of the functions directory
393395 const functionDirs = fs
@@ -649,30 +651,24 @@ async function genManifestsAction(
649651 }
650652 }
651653
652- // Generate final output using the already loaded XRD data
653- let finalOutput : string
654-
655- if ( xrdManifest && xrdContent ) {
656- // Generate multi-document YAML with XRD first, then composition
657- const xrdYaml = YAML . stringify ( xrdManifest )
658- const compositionYaml = YAML . stringify ( manifest )
659-
660- // Combine with document separator
661- finalOutput = `${ xrdYaml } ---\n${ compositionYaml } `
662-
663- moduleLogger . info ( `Including XRD from ${ xrdFilePath } for ${ functionName } ` )
664- } else {
665- // No XRD file, use composition only (existing behavior)
666- finalOutput = YAML . stringify ( manifest )
654+ // Create function-specific directory in manifests
655+ const functionManifestDir = path . join ( manifestsDir , functionName )
656+ if ( ! fs . existsSync ( functionManifestDir ) ) {
657+ fs . mkdirSync ( functionManifestDir , { recursive : true } )
658+ moduleLogger . debug ( `Created function manifest directory: ${ functionManifestDir } ` )
667659 }
668660
669- // Generate the output file
670- const outputPath = path . join ( manifestsDir , `${ functionName } .compo.yaml` )
661+ // Copy XRD file directly (no need to read content)
662+ const outputXrdPath = path . join ( functionManifestDir , "xrd.yaml" )
663+ fs . copyFileSync ( xrdFilePath , outputXrdPath )
664+ moduleLogger . info ( `Copied XRD file for ${ functionName } : ${ outputXrdPath } ` )
671665
672- // Write the output file
673- fs . writeFileSync ( outputPath , finalOutput )
666+ // Generate composition file separately
667+ const compositionYaml = YAML . stringify ( manifest )
668+ const outputCompositionPath = path . join ( functionManifestDir , "composition.yaml" )
669+ fs . writeFileSync ( outputCompositionPath , compositionYaml )
674670
675- moduleLogger . info ( `Generated manifest for ${ functionName } : ${ outputPath } ` )
671+ moduleLogger . info ( `Generated composition for ${ functionName } : ${ outputCompositionPath } ` )
676672 }
677673
678674 moduleLogger . info ( "Composition manifest generation completed" )
0 commit comments