Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CS-43987-added stack name to the config #1304

Merged
merged 8 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Loading