@@ -76,7 +76,6 @@ class CloneHandler {
7676 cloneCommand = new Clone ( ) ;
7777 this . pathDir = opt . pathDir ;
7878 process . stdin . setMaxListeners ( 50 ) ;
79- log . debug ( 'Initializing CloneHandler' , config . cloneContext , { pathDir : opt . pathDir , cloneType : opt . cloneType } ) ;
8079 }
8180 setClient ( managementSDKClient ) {
8281 client = managementSDKClient ;
@@ -706,9 +705,14 @@ class CloneHandler {
706705 delete exportConfig . import ;
707706 delete exportConfig . export ;
708707
708+ // Map source_stack to apiKey for export config
709+ if ( exportConfig . source_stack ) {
710+ exportConfig . apiKey = exportConfig . source_stack ;
711+ }
712+
709713 const exportDir = __dirname . split ( 'src' ) [ 0 ] + 'contents' ;
710714 log . debug ( `Export directory: ${ exportDir } ` , config . cloneContext ) ;
711- const cmd = [ '-k' , exportConfig . source_stack , '-d' , exportDir ] ;
715+ const cmd = [ '-k' , exportConfig . apiKey || exportConfig . source_stack , '-d' , exportDir ] ;
712716
713717 if ( exportConfig . cloneType === 'a' ) {
714718 exportConfig . filteredModules = [ 'stack' ] . concat ( structureList ) ;
@@ -738,7 +742,7 @@ class CloneHandler {
738742 log . debug ( 'Export command prepared' , config . cloneContext , {
739743 cmd : cmd . join ( ' ' ) ,
740744 exportDir,
741- sourceStack : exportConfig . source_stack ,
745+ sourceStack : exportConfig . apiKey || exportConfig . source_stack ,
742746 branch : exportConfig . sourceStackBranch
743747 } ) ;
744748 log . debug ( 'Running export command' , config . cloneContext , { cmd } ) ;
@@ -760,14 +764,22 @@ class CloneHandler {
760764 delete importConfig . import ;
761765 delete importConfig . export ;
762766
767+ // Map target_stack to apiKey and data to contentDir for import config
768+ if ( importConfig . target_stack ) {
769+ importConfig . apiKey = importConfig . target_stack ;
770+ }
771+ if ( importConfig . data ) {
772+ importConfig . contentDir = importConfig . data ;
773+ }
774+
763775 const configFilePath = path . join ( __dirname , 'dummyConfig.json' ) ;
764776 const cmd = [ '-c' , configFilePath ] ;
765777
766778 if ( importConfig . destination_alias ) {
767779 cmd . push ( '-a' , importConfig . destination_alias ) ;
768780 log . debug ( `Using destination alias: ${ importConfig . destination_alias } ` , config . cloneContext ) ;
769781 }
770- if ( ! importConfig . data && importConfig . sourceStackBranch ) {
782+ if ( ! importConfig . contentDir && ! importConfig . data && importConfig . sourceStackBranch ) {
771783 const dataPath = path . join ( importConfig . pathDir , importConfig . sourceStackBranch ) ;
772784 cmd . push ( '-d' , dataPath ) ;
773785 log . debug ( `Import data path: ${ dataPath } ` , config . cloneContext ) ;
@@ -795,9 +807,9 @@ class CloneHandler {
795807 fs . writeFileSync ( configFilePath , JSON . stringify ( importConfig ) ) ;
796808 log . debug ( 'Import command prepared' , config . cloneContext , {
797809 cmd : cmd . join ( ' ' ) ,
798- targetStack : importConfig . target_stack ,
810+ targetStack : importConfig . apiKey || importConfig . target_stack ,
799811 targetBranch : importConfig . targetStackBranch ,
800- dataPath : importConfig . data || path . join ( importConfig . pathDir , importConfig . sourceStackBranch )
812+ dataPath : importConfig . contentDir || importConfig . data || path . join ( importConfig . pathDir , importConfig . sourceStackBranch )
801813 } ) ;
802814 log . debug ( 'Running import command' , config . cloneContext , { cmd } ) ;
803815 await importCmd . run ( cmd ) ;
0 commit comments