@@ -568,11 +568,14 @@ export class CloneHandler {
568568 delete exportConfig . import ;
569569 delete exportConfig . export ;
570570
571+ if ( exportConfig . source_stack ) {
572+ exportConfig . apiKey = exportConfig . source_stack ;
573+ }
571574 // Resolve path to package root - go up 3 levels from __dirname (core/util -> package root)
572575 const packageRoot = path . resolve ( __dirname , '../../..' ) ;
573576 const exportDir = path . join ( packageRoot , 'contents' ) ;
574577 log . debug ( `Export directory: ${ exportDir } ` , this . config . cloneContext ) ;
575- const cmd : string [ ] = [ '-k' , exportConfig . source_stack , '-d' , exportDir ] ;
578+ const cmd : string [ ] = [ '-k' , exportConfig . apiKey || exportConfig . source_stack , '-d' , exportDir ] ;
576579
577580 if ( exportConfig . cloneType === 'a' ) {
578581 exportConfig . filteredModules = [ 'stack' ] . concat ( STRUCTURE_LIST ) ;
@@ -604,7 +607,7 @@ export class CloneHandler {
604607 ...this . config . cloneContext ,
605608 cmd : cmd . join ( ' ' ) ,
606609 exportDir,
607- sourceStack : exportConfig . source_stack ,
610+ sourceStack : exportConfig . apiKey || exportConfig . source_stack ,
608611 branch : exportConfig . sourceStackBranch
609612 } ) ;
610613 log . debug ( 'Running export command' , { ...this . config . cloneContext , cmd } ) ;
@@ -634,7 +637,15 @@ export class CloneHandler {
634637 cmd . push ( '-a' , importConfig . destination_alias ) ;
635638 log . debug ( `Using destination alias: ${ importConfig . destination_alias } ` , this . config . cloneContext ) ;
636639 }
637- if ( ! importConfig . data && importConfig . sourceStackBranch && importConfig . pathDir ) {
640+ if ( importConfig . target_stack ) {
641+ importConfig . apiKey = importConfig . target_stack ;
642+ log . debug ( `Using target stack api key for import: ${ importConfig . target_stack } ` , this . config . cloneContext ) ;
643+ }
644+ if ( importConfig . data ) {
645+ importConfig . contentDir = importConfig . data ;
646+ }
647+
648+ if ( ! importConfig . contentDir && importConfig . sourceStackBranch && importConfig . pathDir ) {
638649 const dataPath = path . join ( importConfig . pathDir , importConfig . sourceStackBranch ) ;
639650 cmd . push ( '-d' , dataPath ) ;
640651 log . debug ( `Import data path: ${ dataPath } ` , this . config . cloneContext ) ;
@@ -660,12 +671,12 @@ export class CloneHandler {
660671
661672 log . debug ( `Writing import config to: ${ configFilePath } ` , this . config . cloneContext ) ;
662673 fs . writeFileSync ( configFilePath , JSON . stringify ( importConfig ) ) ;
663- log . debug ( 'Import command prepared' , {
674+ log . debug ( 'Import command prepared' , {
664675 ...this . config . cloneContext ,
665676 cmd : cmd . join ( ' ' ) ,
666- targetStack : importConfig . target_stack ,
677+ targetStack : importConfig . apiKey || importConfig . target_stack ,
667678 targetBranch : importConfig . targetStackBranch ,
668- dataPath : importConfig . data || ( importConfig . pathDir && importConfig . sourceStackBranch ? path . join ( importConfig . pathDir , importConfig . sourceStackBranch ) : undefined )
679+ dataPath : importConfig . contentDir || ( importConfig . pathDir && importConfig . sourceStackBranch ? path . join ( importConfig . pathDir , importConfig . sourceStackBranch ) : undefined )
669680 } ) ;
670681 log . debug ( 'Running import command' , { ...this . config . cloneContext , cmd } ) ;
671682 const importData = importCmd . run ( cmd ) ;
@@ -796,8 +807,8 @@ export class CloneHandler {
796807 let selectedValue : any = { } ;
797808 // Resolve path to package root - go up 3 levels from __dirname (core/util -> package root)
798809 const cloneTypePackageRoot = path . resolve ( __dirname , '../../..' ) ;
799- this . config . data = path . join ( cloneTypePackageRoot , 'contents' , this . config . sourceStackBranch || '' ) ;
800- log . debug ( `Clone data directory: ${ this . config . data } ` , this . config . cloneContext ) ;
810+ this . config . contentDir = path . join ( cloneTypePackageRoot , 'contents' , this . config . sourceStackBranch || '' ) ;
811+ log . debug ( `Clone content directory: ${ this . config . contentDir } ` , this . config . cloneContext ) ;
801812
802813 if ( ! this . config . cloneType ) {
803814 log . debug ( 'Clone type not specified, prompting user for selection' , this . config . cloneContext ) ;
0 commit comments