Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .talismanrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@

fileignoreconfig:
- filename: package-lock.json
checksum: 13b82bf3ada05a792580596fbedb02c988fd556b208a742da1ecb3f2678675b4
checksum: fa2c81c72305bc19fa4f64457af1000aa2f0c179ecb7e46a5fc9d8b760c705a7
- filename: pnpm-lock.yaml
checksum: 24ffee6d868d77669d32ac036c4abc2ab5f4c2d7f45f74c62f38a07e91240c26
checksum: faaef9e003c5ba45e56ab1ca24a4fc285f53a2b9ecc6d3dbd11e7130a31db4a2
- filename: packages/contentstack-clone/src/core/util/clone-handler.ts
checksum: 0a7ed55e96aa5a94084538b4a480608593b04c316bf02cf54cdd3a647e9b714c
version: '1.0'
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 19 additions & 8 deletions packages/contentstack-clone/src/core/util/clone-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -568,11 +568,14 @@ export class CloneHandler {
delete exportConfig.import;
delete exportConfig.export;

if (exportConfig.source_stack) {
exportConfig.apiKey = exportConfig.source_stack;
}
// Resolve path to package root - go up 3 levels from __dirname (core/util -> package root)
const packageRoot = path.resolve(__dirname, '../../..');
const exportDir = path.join(packageRoot, 'contents');
log.debug(`Export directory: ${exportDir}`, this.config.cloneContext);
const cmd: string[] = ['-k', exportConfig.source_stack, '-d', exportDir];
const cmd: string[] = ['-k', exportConfig.apiKey || exportConfig.source_stack, '-d', exportDir];

if (exportConfig.cloneType === 'a') {
exportConfig.filteredModules = ['stack'].concat(STRUCTURE_LIST);
Expand Down Expand Up @@ -604,7 +607,7 @@ export class CloneHandler {
...this.config.cloneContext,
cmd: cmd.join(' '),
exportDir,
sourceStack: exportConfig.source_stack,
sourceStack: exportConfig.apiKey || exportConfig.source_stack,
branch: exportConfig.sourceStackBranch
});
log.debug('Running export command', { ...this.config.cloneContext, cmd });
Expand Down Expand Up @@ -634,7 +637,15 @@ export class CloneHandler {
cmd.push('-a', importConfig.destination_alias);
log.debug(`Using destination alias: ${importConfig.destination_alias}`, this.config.cloneContext);
}
if (!importConfig.data && importConfig.sourceStackBranch && importConfig.pathDir) {
if (importConfig.target_stack) {
importConfig.apiKey = importConfig.target_stack;
log.debug(`Using target stack api key for import: ${importConfig.target_stack}`, this.config.cloneContext);
}
if (importConfig.data) {
importConfig.contentDir = importConfig.data;
}

if (!importConfig.contentDir && importConfig.sourceStackBranch && importConfig.pathDir) {
const dataPath = path.join(importConfig.pathDir, importConfig.sourceStackBranch);
cmd.push('-d', dataPath);
log.debug(`Import data path: ${dataPath}`, this.config.cloneContext);
Expand All @@ -660,12 +671,12 @@ export class CloneHandler {

log.debug(`Writing import config to: ${configFilePath}`, this.config.cloneContext);
fs.writeFileSync(configFilePath, JSON.stringify(importConfig));
log.debug('Import command prepared', {
log.debug('Import command prepared', {
...this.config.cloneContext,
cmd: cmd.join(' '),
targetStack: importConfig.target_stack,
targetStack: importConfig.apiKey || importConfig.target_stack,
targetBranch: importConfig.targetStackBranch,
dataPath: importConfig.data || (importConfig.pathDir && importConfig.sourceStackBranch ? path.join(importConfig.pathDir, importConfig.sourceStackBranch) : undefined)
dataPath: importConfig.contentDir || (importConfig.pathDir && importConfig.sourceStackBranch ? path.join(importConfig.pathDir, importConfig.sourceStackBranch) : undefined)
});
log.debug('Running import command', { ...this.config.cloneContext, cmd });
const importData = importCmd.run(cmd);
Expand Down Expand Up @@ -796,8 +807,8 @@ export class CloneHandler {
let selectedValue: any = {};
// Resolve path to package root - go up 3 levels from __dirname (core/util -> package root)
const cloneTypePackageRoot = path.resolve(__dirname, '../../..');
this.config.data = path.join(cloneTypePackageRoot, 'contents', this.config.sourceStackBranch || '');
log.debug(`Clone data directory: ${this.config.data}`, this.config.cloneContext);
this.config.contentDir = path.join(cloneTypePackageRoot, 'contents', this.config.sourceStackBranch || '');
log.debug(`Clone content directory: ${this.config.contentDir}`, this.config.cloneContext);

if (!this.config.cloneType) {
log.debug('Clone type not specified, prompting user for selection', this.config.cloneContext);
Expand Down
3 changes: 2 additions & 1 deletion packages/contentstack-clone/src/types/clone-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ export interface CloneConfig {
forceStopMarketplaceAppsPrompt?: boolean;

// Data and modules
data?: string;
/** Path to exported content for import (aligns with import plugin's contentDir) */
contentDir?: string;
modules?: string[];
filteredModules?: string[];

Expand Down
14 changes: 7 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading