diff --git a/.talismanrc b/.talismanrc index 251b3fe277..262b06313f 100644 --- a/.talismanrc +++ b/.talismanrc @@ -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' diff --git a/package-lock.json b/package-lock.json index 8886aa9e87..db0e4c38ca 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12911,9 +12911,9 @@ } }, "node_modules/get-tsconfig": { - "version": "4.13.4", - "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.13.4.tgz", - "integrity": "sha512-gKvvu/fh0hxWmR/Ty0Goc3u/GADL9IgyhNAPD8hElRVO9dTOawCuyGNURCjaSTB4ZNP/OAUaSXmR2LhitzkLug==", + "version": "4.13.5", + "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.13.5.tgz", + "integrity": "sha512-v4/4xAEpBRp6SvCkWhnGCaLkJf9IwWzrsygJPxD/+p2/xPE3C5m2fA9FD0Ry9tG+Rqqq3gBzHSl6y1/T9V/tMQ==", "dev": true, "license": "MIT", "dependencies": { diff --git a/packages/contentstack-clone/src/core/util/clone-handler.ts b/packages/contentstack-clone/src/core/util/clone-handler.ts index d8016c76e3..b3ac29f5fe 100644 --- a/packages/contentstack-clone/src/core/util/clone-handler.ts +++ b/packages/contentstack-clone/src/core/util/clone-handler.ts @@ -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); @@ -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 }); @@ -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); @@ -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); @@ -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); diff --git a/packages/contentstack-clone/src/types/clone-config.ts b/packages/contentstack-clone/src/types/clone-config.ts index e0fb816382..81179f0b4a 100644 --- a/packages/contentstack-clone/src/types/clone-config.ts +++ b/packages/contentstack-clone/src/types/clone-config.ts @@ -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[]; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2dca19eed3..e2d59cd7cd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8405,7 +8405,7 @@ packages: debug: 4.4.3 eslint: 8.57.1 eslint-plugin-import: 2.32.0_h54g4fpo35u3jdvfcz45735goq - get-tsconfig: 4.13.4 + get-tsconfig: 4.13.5 is-bun-module: 2.0.0 stable-hash: 0.0.5 tinyglobby: 0.2.15 @@ -8631,7 +8631,7 @@ packages: enhanced-resolve: 5.19.0 eslint: 8.57.1 eslint-plugin-es-x: 7.8.0_eslint@8.57.1 - get-tsconfig: 4.13.4 + get-tsconfig: 4.13.5 globals: 15.15.0 globrex: 0.1.2 ignore: 5.3.2 @@ -8651,7 +8651,7 @@ packages: enhanced-resolve: 5.19.0 eslint: 8.57.1 eslint-plugin-es-x: 7.8.0_eslint@8.57.1 - get-tsconfig: 4.13.4 + get-tsconfig: 4.13.5 globals: 15.15.0 globrex: 0.1.2 ignore: 5.3.2 @@ -8671,7 +8671,7 @@ packages: enhanced-resolve: 5.19.0 eslint: 8.57.1 eslint-plugin-es-x: 7.8.0_eslint@8.57.1 - get-tsconfig: 4.13.4 + get-tsconfig: 4.13.5 globals: 15.15.0 globrex: 0.1.2 ignore: 5.3.2 @@ -9668,8 +9668,8 @@ packages: es-errors: 1.3.0 get-intrinsic: 1.3.0 - /get-tsconfig/4.13.4: - resolution: {integrity: sha512-gKvvu/fh0hxWmR/Ty0Goc3u/GADL9IgyhNAPD8hElRVO9dTOawCuyGNURCjaSTB4ZNP/OAUaSXmR2LhitzkLug==} + /get-tsconfig/4.13.5: + resolution: {integrity: sha512-v4/4xAEpBRp6SvCkWhnGCaLkJf9IwWzrsygJPxD/+p2/xPE3C5m2fA9FD0Ry9tG+Rqqq3gBzHSl6y1/T9V/tMQ==} dependencies: resolve-pkg-maps: 1.0.0 dev: true @@ -14358,7 +14358,7 @@ packages: hasBin: true dependencies: esbuild: 0.27.3 - get-tsconfig: 4.13.4 + get-tsconfig: 4.13.5 optionalDependencies: fsevents: 2.3.3 dev: true