From e5a458cd919a364b915fd5e0320fc595ef498d21 Mon Sep 17 00:00:00 2001 From: shafeeqd959 Date: Mon, 9 Oct 2023 17:44:54 +0530 Subject: [PATCH 1/2] fix export info in all branches --- packages/contentstack-export/src/commands/cm/stacks/export.ts | 4 +++- packages/contentstack-export/src/export/module-exporter.ts | 3 ++- packages/contentstack-export/src/utils/common-helper.ts | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/contentstack-export/src/commands/cm/stacks/export.ts b/packages/contentstack-export/src/commands/cm/stacks/export.ts index 24eb5cde66..eb6e3a51d9 100644 --- a/packages/contentstack-export/src/commands/cm/stacks/export.ts +++ b/packages/contentstack-export/src/commands/cm/stacks/export.ts @@ -110,7 +110,9 @@ export default class ExportCommand extends Command { const managementAPIClient: ContentstackClient = await managementSDKClient(exportConfig); const moduleExporter = new ModuleExporter(managementAPIClient, exportConfig); await moduleExporter.start(); - writeExportMetaFile(exportConfig); + if (!exportConfig.branches?.length) { + writeExportMetaFile(exportConfig); + } log(exportConfig, `The content of the stack ${exportConfig.apiKey} has been exported successfully!`, 'success'); log(exportConfig, `The log has been stored at '${path.join(exportDir, 'logs', 'export')}'`, 'success'); } catch (error) { diff --git a/packages/contentstack-export/src/export/module-exporter.ts b/packages/contentstack-export/src/export/module-exporter.ts index dacd48c639..cfda693b01 100644 --- a/packages/contentstack-export/src/export/module-exporter.ts +++ b/packages/contentstack-export/src/export/module-exporter.ts @@ -1,6 +1,6 @@ import * as path from 'path'; import { ContentstackClient } from '@contentstack/cli-utilities'; -import { setupBranches, setupExportDir, log, formatError } from '../utils'; +import { setupBranches, setupExportDir, log, formatError, writeExportMetaFile } from '../utils'; import startModuleExport from './modules'; import startJSModuleExport from './modules-js'; import { ExportConfig, Modules } from '../types'; @@ -37,6 +37,7 @@ class ModuleExporter { try { this.exportConfig.branchName = branch.uid; this.exportConfig.branchDir = path.join(this.exportConfig.exportDir, branch.uid); + writeExportMetaFile(this.exportConfig, this.exportConfig.branchDir); await this.export(); log(this.exportConfig, `The content of branch ${branch.uid} has been exported successfully!`, 'success'); } catch (error) { diff --git a/packages/contentstack-export/src/utils/common-helper.ts b/packages/contentstack-export/src/utils/common-helper.ts index 6d6baaaf8e..c0c45cc058 100644 --- a/packages/contentstack-export/src/utils/common-helper.ts +++ b/packages/contentstack-export/src/utils/common-helper.ts @@ -80,10 +80,10 @@ export const executeTask = function ( }; // Note: we can add more useful details in meta file -export const writeExportMetaFile = (exportConfig: ExportConfig) => { +export const writeExportMetaFile = (exportConfig: ExportConfig, metaFilePath?: string) => { const exportMeta = { contentVersion: exportConfig.contentVersion, logsPath: path.join(exportConfig.exportDir, 'logs', 'export'), }; - fsUtil.writeFile(path.join(exportConfig.exportDir, exportConfig.branchName || '', 'export-info.json'), exportMeta); + fsUtil.writeFile(path.join(metaFilePath || exportConfig.exportDir, 'export-info.json'), exportMeta); }; From 9d1e38800daca79a457c7719a71a06f45f4a399b Mon Sep 17 00:00:00 2001 From: shafeeqd959 Date: Wed, 11 Oct 2023 15:16:45 +0530 Subject: [PATCH 2/2] version bumped --- packages/contentstack-export/package.json | 4 ++-- packages/contentstack/package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/contentstack-export/package.json b/packages/contentstack-export/package.json index 51a6192c91..557b899cda 100644 --- a/packages/contentstack-export/package.json +++ b/packages/contentstack-export/package.json @@ -1,7 +1,7 @@ { "name": "@contentstack/cli-cm-export", "description": "Contentstack CLI plugin to export content from stack", - "version": "1.9.1", + "version": "1.9.2", "author": "Contentstack", "bugs": "https://github.com/contentstack/cli/issues", "dependencies": { @@ -98,4 +98,4 @@ } }, "repository": "https://github.com/contentstack/cli" -} +} \ No newline at end of file diff --git a/packages/contentstack/package.json b/packages/contentstack/package.json index 04c0a9b7a8..3b11528549 100755 --- a/packages/contentstack/package.json +++ b/packages/contentstack/package.json @@ -28,7 +28,7 @@ "@contentstack/cli-cm-branches": "~1.0.14", "@contentstack/cli-cm-bulk-publish": "~1.3.12", "@contentstack/cli-cm-clone": "~1.5.1", - "@contentstack/cli-cm-export": "~1.9.1", + "@contentstack/cli-cm-export": "~1.9.2", "@contentstack/cli-cm-export-to-csv": "~1.4.3", "@contentstack/cli-cm-import": "~1.9.2", "@contentstack/cli-cm-migrate-rte": "~1.4.12",