From c0e8ab593c6a5f7a3ef143024f9ce1655436a439 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 03925293520b1c27fbcc98b4f9cb9388b4444ab0 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 e9c90b2f54d70e36b7e3baef75c22bcec854300a 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 0746ca832a0f6ef9442210702befd0608f648152 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 7f43290a88723be5ec4a734910e4051ab02beb20 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 084180089ba850135a7ce6cbcc385a11a62244ac 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 = {