Skip to content

Commit

Permalink
Merge branch 'development' into fix/CS-41720
Browse files Browse the repository at this point in the history
  • Loading branch information
netrajpatel authored Oct 11, 2023
2 parents 0b16f42 + 87df268 commit 98246b4
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 28 deletions.
11 changes: 0 additions & 11 deletions packages/contentstack-auth/src/base-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,13 @@ export abstract class BaseCommand<T extends typeof Command> extends Command {
protected args!: Args<T>;
protected flags!: Flags<T>;

// NOTE define flags that can be inherited by any command that extends BaseCommand
static baseFlags: FlagInput = {};

/**
* The `init` function initializes the command by parsing arguments and flags, registering search
* plugins, registering the configuration, and initializing the logger.
*/
public async init(): Promise<void> {
await super.init();
const { args, flags } = await this.parse({
flags: this.ctor.flags,
baseFlags: (super.ctor as typeof BaseCommand).baseFlags,
args: this.ctor.args,
strict: this.ctor.strict,
});
this.flags = flags as Flags<T>;
this.args = args as Args<T>;

// Init logger
this.logger = new LoggerService(process.cwd(), 'cli-log');
}
Expand Down
10 changes: 0 additions & 10 deletions packages/contentstack-config/src/base-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,13 @@ export abstract class BaseCommand<T extends typeof Command> extends Command {
protected args!: Args<T>;
protected flags!: Flags<T>;

// NOTE define flags that canin be inherited by any command that extends BaseCommand
static baseFlags: FlagInput = {};
static args: ArgInput<{ [arg: string]: any; }>;
/**
* The `init` function initializes the command by parsing arguments and flags, registering search
* plugins, registering the configuration, and initializing the logger.
*/
public async init(): Promise<void> {
await super.init();
const { args, flags } = await this.parse({
flags: this.ctor.flags,
baseFlags: (super.ctor as typeof BaseCommand).baseFlags,
args: this.ctor.args,
strict: this.ctor.strict,
});
this.flags = flags as Flags<T>;
this.args = args as Args<T>;

// Init logger
this.logger = new LoggerService(process.cwd(), 'cli-log');
Expand Down
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 98246b4

Please sign in to comment.