From 8a0d032d3ff3bd0d6380ed7504e427deefb60739 Mon Sep 17 00:00:00 2001 From: raj pandey Date: Tue, 6 Feb 2024 17:29:13 +0530 Subject: [PATCH 1/3] handled why logs where not created in mentioned path --- .../contentstack-export/src/commands/cm/stacks/export.ts | 5 ++--- packages/contentstack-export/src/utils/logger.ts | 2 +- 2 files changed, 3 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 805a420f16..86b0f0ebf3 100644 --- a/packages/contentstack-export/src/commands/cm/stacks/export.ts +++ b/packages/contentstack-export/src/commands/cm/stacks/export.ts @@ -98,7 +98,7 @@ export default class ExportCommand extends Command { static aliases: string[] = ['cm:export']; async run(): Promise { - let exportDir: string; + let exportDir: string = path.join(__dirname, 'logs'); try { const { flags } = await this.parse(ExportCommand); let exportConfig = await setupExportConfig(flags); @@ -117,8 +117,7 @@ export default class ExportCommand extends Command { log({ data: exportDir } as ExportConfig, `Failed to export stack content - ${formatError(error)}`, 'error'); log( { data: exportDir } as ExportConfig, - `The log has been stored at ${ - exportDir ? path.join(exportDir, 'logs', 'export') : path.join(__dirname, 'logs') + `The log has been stored at ${exportDir }`, 'info', ); diff --git a/packages/contentstack-export/src/utils/logger.ts b/packages/contentstack-export/src/utils/logger.ts index c3edf2ce27..b2b8302622 100644 --- a/packages/contentstack-export/src/utils/logger.ts +++ b/packages/contentstack-export/src/utils/logger.ts @@ -134,7 +134,7 @@ function init(_logPath: string) { } export const log = async (config: ExportConfig, message: any, type: string) => { - const logsPath = config.data || __dirname; + const logsPath = config.data; // ignoring the type argument, as we are not using it to create a logfile anymore if (type !== 'error') { // removed type argument from init method From efa3dd912c51f5a6607d8be6663b126b3ccd9ed8 Mon Sep 17 00:00:00 2001 From: raj pandey Date: Wed, 7 Feb 2024 12:54:53 +0530 Subject: [PATCH 2/3] changed the logs location to present working directory --- packages/contentstack-export/src/commands/cm/stacks/export.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/contentstack-export/src/commands/cm/stacks/export.ts b/packages/contentstack-export/src/commands/cm/stacks/export.ts index 86b0f0ebf3..eee96bb61d 100644 --- a/packages/contentstack-export/src/commands/cm/stacks/export.ts +++ b/packages/contentstack-export/src/commands/cm/stacks/export.ts @@ -98,7 +98,7 @@ export default class ExportCommand extends Command { static aliases: string[] = ['cm:export']; async run(): Promise { - let exportDir: string = path.join(__dirname, 'logs'); + let exportDir: string = path.join(process.cwd(), 'logs'); try { const { flags } = await this.parse(ExportCommand); let exportConfig = await setupExportConfig(flags); From 6537f547897c1267c6dd4d61ff9052f76de4487c Mon Sep 17 00:00:00 2001 From: raj pandey Date: Wed, 7 Feb 2024 13:10:54 +0530 Subject: [PATCH 3/3] indentation --- .../contentstack-export/src/commands/cm/stacks/export.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/packages/contentstack-export/src/commands/cm/stacks/export.ts b/packages/contentstack-export/src/commands/cm/stacks/export.ts index eee96bb61d..620dc4c730 100644 --- a/packages/contentstack-export/src/commands/cm/stacks/export.ts +++ b/packages/contentstack-export/src/commands/cm/stacks/export.ts @@ -115,12 +115,7 @@ export default class ExportCommand extends Command { log(exportConfig, `The log has been stored at '${path.join(exportDir, 'logs', 'export')}'`, 'success'); } catch (error) { log({ data: exportDir } as ExportConfig, `Failed to export stack content - ${formatError(error)}`, 'error'); - log( - { data: exportDir } as ExportConfig, - `The log has been stored at ${exportDir - }`, - 'info', - ); + log({ data: exportDir } as ExportConfig, `The log has been stored at ${exportDir}`, 'info'); } } }