Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix export info in all branches #1094

Merged
merged 3 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
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
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);
};
Loading