From 6f31a2bd33a9682cb9b44d9f7b0b109fd8259e84 Mon Sep 17 00:00:00 2001 From: raj pandey Date: Tue, 20 Feb 2024 14:24:04 +0530 Subject: [PATCH 1/6] added stack name to the config --- packages/contentstack-import/src/commands/cm/stacks/import.ts | 2 +- packages/contentstack-import/src/import/module-importer.ts | 2 ++ packages/contentstack-import/src/types/import-config.ts | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/contentstack-import/src/commands/cm/stacks/import.ts b/packages/contentstack-import/src/commands/cm/stacks/import.ts index eba9275aff..e863ff3739 100644 --- a/packages/contentstack-import/src/commands/cm/stacks/import.ts +++ b/packages/contentstack-import/src/commands/cm/stacks/import.ts @@ -132,7 +132,7 @@ export default class ImportCommand extends Command { const result = await moduleImporter.start(); if (!result?.noSuccessMsg) { - log(importConfig, `The content has been imported to the stack ${importConfig.apiKey} successfully!`, 'success'); + log(importConfig, `The content has been imported to the stack named '${importConfig.stack_name}' having api_key '${importConfig.apiKey}' successfully!`, 'success'); } log( diff --git a/packages/contentstack-import/src/import/module-importer.ts b/packages/contentstack-import/src/import/module-importer.ts index d111df834c..2b05e4f838 100755 --- a/packages/contentstack-import/src/import/module-importer.ts +++ b/packages/contentstack-import/src/import/module-importer.ts @@ -23,6 +23,8 @@ class ModuleImporter { } async start(): Promise { + let stack_name:Record = await this.stackAPIClient.fetch(); + this.importConfig.stack_name = stack_name.name as string; if (this.importConfig.branchName) { await validateBranch(this.stackAPIClient, this.importConfig, this.importConfig.branchName); } diff --git a/packages/contentstack-import/src/types/import-config.ts b/packages/contentstack-import/src/types/import-config.ts index bdf75c4727..12c6d6d755 100644 --- a/packages/contentstack-import/src/types/import-config.ts +++ b/packages/contentstack-import/src/types/import-config.ts @@ -48,6 +48,7 @@ export default interface ImportConfig extends DefaultConfig, ExternalConfig { replaceExisting?: boolean; skipExisting?: boolean; skipAudit?: boolean; + stack_name: string; } type branch = { From 180f948cdcc77938ffed3092308e8643c9beda83 Mon Sep 17 00:00:00 2001 From: raj pandey Date: Tue, 20 Feb 2024 14:38:27 +0530 Subject: [PATCH 2/6] changed the name following the convention --- packages/contentstack-import/src/commands/cm/stacks/import.ts | 2 +- packages/contentstack-import/src/import/module-importer.ts | 2 +- packages/contentstack-import/src/types/import-config.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/contentstack-import/src/commands/cm/stacks/import.ts b/packages/contentstack-import/src/commands/cm/stacks/import.ts index e863ff3739..586fbacb1b 100644 --- a/packages/contentstack-import/src/commands/cm/stacks/import.ts +++ b/packages/contentstack-import/src/commands/cm/stacks/import.ts @@ -132,7 +132,7 @@ export default class ImportCommand extends Command { const result = await moduleImporter.start(); if (!result?.noSuccessMsg) { - log(importConfig, `The content has been imported to the stack named '${importConfig.stack_name}' having api_key '${importConfig.apiKey}' successfully!`, 'success'); + log(importConfig, `The content has been imported to the stack named '${importConfig.stackName}' having api_key '${importConfig.apiKey}' successfully!`, 'success'); } log( diff --git a/packages/contentstack-import/src/import/module-importer.ts b/packages/contentstack-import/src/import/module-importer.ts index 2b05e4f838..a08e4c8b1f 100755 --- a/packages/contentstack-import/src/import/module-importer.ts +++ b/packages/contentstack-import/src/import/module-importer.ts @@ -24,7 +24,7 @@ class ModuleImporter { async start(): Promise { let stack_name:Record = await this.stackAPIClient.fetch(); - this.importConfig.stack_name = stack_name.name as string; + this.importConfig.stackName = stack_name.name as string; if (this.importConfig.branchName) { await validateBranch(this.stackAPIClient, this.importConfig, this.importConfig.branchName); } diff --git a/packages/contentstack-import/src/types/import-config.ts b/packages/contentstack-import/src/types/import-config.ts index 12c6d6d755..bde4fa375f 100644 --- a/packages/contentstack-import/src/types/import-config.ts +++ b/packages/contentstack-import/src/types/import-config.ts @@ -48,7 +48,7 @@ export default interface ImportConfig extends DefaultConfig, ExternalConfig { replaceExisting?: boolean; skipExisting?: boolean; skipAudit?: boolean; - stack_name: string; + stackName: string; } type branch = { From c86512fcc80e4d389c029e334e59231f2cd446e2 Mon Sep 17 00:00:00 2001 From: raj pandey Date: Tue, 20 Feb 2024 16:58:51 +0530 Subject: [PATCH 3/6] ui text update --- packages/contentstack-import/src/commands/cm/stacks/import.ts | 2 +- packages/contentstack-import/src/import/module-importer.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/contentstack-import/src/commands/cm/stacks/import.ts b/packages/contentstack-import/src/commands/cm/stacks/import.ts index 586fbacb1b..18d14509f9 100644 --- a/packages/contentstack-import/src/commands/cm/stacks/import.ts +++ b/packages/contentstack-import/src/commands/cm/stacks/import.ts @@ -132,7 +132,7 @@ export default class ImportCommand extends Command { const result = await moduleImporter.start(); if (!result?.noSuccessMsg) { - log(importConfig, `The content has been imported to the stack named '${importConfig.stackName}' having api_key '${importConfig.apiKey}' successfully!`, 'success'); + log(importConfig, `Successfully imported the content to the stack named ${importConfig.stackName} with the API key ${importConfig.apiKey} .`, 'success'); } log( diff --git a/packages/contentstack-import/src/import/module-importer.ts b/packages/contentstack-import/src/import/module-importer.ts index a08e4c8b1f..48857b07ab 100755 --- a/packages/contentstack-import/src/import/module-importer.ts +++ b/packages/contentstack-import/src/import/module-importer.ts @@ -23,8 +23,8 @@ class ModuleImporter { } async start(): Promise { - let stack_name:Record = await this.stackAPIClient.fetch(); - this.importConfig.stackName = stack_name.name as string; + const stackName:Record = await this.stackAPIClient.fetch(); + this.importConfig.stackName = stackName.name as string; if (this.importConfig.branchName) { await validateBranch(this.stackAPIClient, this.importConfig, this.importConfig.branchName); } From a18cd1b28daae08d7c70b20e7ddebcdced3dd10a Mon Sep 17 00:00:00 2001 From: raj pandey Date: Tue, 20 Feb 2024 17:01:27 +0530 Subject: [PATCH 4/6] fromatting updated --- .../contentstack-import/src/commands/cm/stacks/import.ts | 6 +++++- packages/contentstack-import/src/import/module-importer.ts | 5 +++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/contentstack-import/src/commands/cm/stacks/import.ts b/packages/contentstack-import/src/commands/cm/stacks/import.ts index 18d14509f9..55a955fcb8 100644 --- a/packages/contentstack-import/src/commands/cm/stacks/import.ts +++ b/packages/contentstack-import/src/commands/cm/stacks/import.ts @@ -132,7 +132,11 @@ export default class ImportCommand extends Command { const result = await moduleImporter.start(); if (!result?.noSuccessMsg) { - log(importConfig, `Successfully imported the content to the stack named ${importConfig.stackName} with the API key ${importConfig.apiKey} .`, 'success'); + log( + importConfig, + `Successfully imported the content to the stack named ${importConfig.stackName} with the API key ${importConfig.apiKey} .`, + 'success', + ); } log( diff --git a/packages/contentstack-import/src/import/module-importer.ts b/packages/contentstack-import/src/import/module-importer.ts index 48857b07ab..0f5c27a1b7 100755 --- a/packages/contentstack-import/src/import/module-importer.ts +++ b/packages/contentstack-import/src/import/module-importer.ts @@ -23,7 +23,7 @@ class ModuleImporter { } async start(): Promise { - const stackName:Record = await this.stackAPIClient.fetch(); + const stackName: Record = await this.stackAPIClient.fetch(); this.importConfig.stackName = stackName.name as string; if (this.importConfig.branchName) { await validateBranch(this.stackAPIClient, this.importConfig, this.importConfig.branchName); @@ -155,7 +155,8 @@ class ModuleImporter { (await cliux.inquire({ type: 'confirm', name: 'confirmation', - message: 'Please review and confirm if we can proceed with implementing the fix mentioned in the provided path.?', + message: + 'Please review and confirm if we can proceed with implementing the fix mentioned in the provided path.?', })) ) { return true; From dec07e86401ee0c3697b0da97d97545c279d2d07 Mon Sep 17 00:00:00 2001 From: raj pandey Date: Wed, 21 Feb 2024 12:12:07 +0530 Subject: [PATCH 5/6] added two messages depending whether management token is used or not --- .../src/commands/cm/stacks/import.ts | 10 ++++++++-- .../contentstack-import/src/import/module-importer.ts | 6 ++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/contentstack-import/src/commands/cm/stacks/import.ts b/packages/contentstack-import/src/commands/cm/stacks/import.ts index 55a955fcb8..ab78459982 100644 --- a/packages/contentstack-import/src/commands/cm/stacks/import.ts +++ b/packages/contentstack-import/src/commands/cm/stacks/import.ts @@ -134,7 +134,9 @@ export default class ImportCommand extends Command { if (!result?.noSuccessMsg) { log( importConfig, - `Successfully imported the content to the stack named ${importConfig.stackName} with the API key ${importConfig.apiKey} .`, + importConfig.stackName + ? `Successfully imported the content to the stack named ${importConfig.stackName} with the API key ${importConfig.apiKey} .` + : `The content has been imported to the stack ${importConfig.apiKey} successfully!`, 'success', ); } @@ -145,7 +147,11 @@ export default class ImportCommand extends Command { 'success', ); } catch (error) { - log({ data: backupDir ?? path.join(backupDir || __dirname, 'logs', 'import') } as ImportConfig, `Failed to import stack content - ${formatError(error)}`, 'error'); + log( + { data: backupDir ?? path.join(backupDir || __dirname, 'logs', 'import') } as ImportConfig, + `Failed to import stack content - ${formatError(error)}`, + 'error', + ); log( { data: backupDir } as ImportConfig, `The log has been stored at ${ diff --git a/packages/contentstack-import/src/import/module-importer.ts b/packages/contentstack-import/src/import/module-importer.ts index 0f5c27a1b7..476d0949e8 100755 --- a/packages/contentstack-import/src/import/module-importer.ts +++ b/packages/contentstack-import/src/import/module-importer.ts @@ -23,8 +23,10 @@ class ModuleImporter { } async start(): Promise { - const stackName: Record = await this.stackAPIClient.fetch(); - this.importConfig.stackName = stackName.name as string; + if(!this.importConfig.management_token){ + const stackName: Record = await this.stackAPIClient.fetch(); + this.importConfig.stackName = stackName.name as string; + } if (this.importConfig.branchName) { await validateBranch(this.stackAPIClient, this.importConfig, this.importConfig.branchName); } From 1a63fe33bb63d6d7f28a228399111efb4ec5aa2b Mon Sep 17 00:00:00 2001 From: raj pandey Date: Wed, 21 Feb 2024 12:48:52 +0530 Subject: [PATCH 6/6] made stackName optional --- packages/contentstack-import/src/types/import-config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/contentstack-import/src/types/import-config.ts b/packages/contentstack-import/src/types/import-config.ts index bde4fa375f..667a53b53f 100644 --- a/packages/contentstack-import/src/types/import-config.ts +++ b/packages/contentstack-import/src/types/import-config.ts @@ -48,7 +48,7 @@ export default interface ImportConfig extends DefaultConfig, ExternalConfig { replaceExisting?: boolean; skipExisting?: boolean; skipAudit?: boolean; - stackName: string; + stackName?: string; } type branch = {