Skip to content

Commit

Permalink
Merge pull request #1304 from contentstack/fix/CS-43987
Browse files Browse the repository at this point in the history
CS-43987-added stack name to the config
  • Loading branch information
cs-raj authored Feb 21, 2024
2 parents ad79fd2 + 0841800 commit 91100e0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
14 changes: 12 additions & 2 deletions packages/contentstack-import/src/commands/cm/stacks/import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,13 @@ 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,
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',
);
}

log(
Expand All @@ -141,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 ${
Expand Down
7 changes: 6 additions & 1 deletion packages/contentstack-import/src/import/module-importer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ class ModuleImporter {
}

async start(): Promise<any> {
if(!this.importConfig.management_token){
const stackName: Record<string, unknown> = await this.stackAPIClient.fetch();
this.importConfig.stackName = stackName.name as string;
}
if (this.importConfig.branchName) {
await validateBranch(this.stackAPIClient, this.importConfig, this.importConfig.branchName);
}
Expand Down Expand Up @@ -153,7 +157,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;
Expand Down
1 change: 1 addition & 0 deletions packages/contentstack-import/src/types/import-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export default interface ImportConfig extends DefaultConfig, ExternalConfig {
replaceExisting?: boolean;
skipExisting?: boolean;
skipAudit?: boolean;
stackName?: string;
}

type branch = {
Expand Down

0 comments on commit 91100e0

Please sign in to comment.