Skip to content

Commit

Permalink
Merge pull request #1094 from contentstack/fix/CS-41661
Browse files Browse the repository at this point in the history
fix export info in all branches
  • Loading branch information
shafeeqd959 authored Oct 11, 2023
2 parents 27886e7 + d2a3170 commit e8a8500
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions packages/contentstack-export/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down Expand Up @@ -98,4 +98,4 @@
}
},
"repository": "https://github.com/contentstack/cli"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion packages/contentstack-export/src/export/module-exporter.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions packages/contentstack-export/src/utils/common-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
2 changes: 1 addition & 1 deletion packages/contentstack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit e8a8500

Please sign in to comment.