Skip to content

Commit 32b55cc

Browse files
Revert "Revert "fix: inconsistent log messages in case of failures""
1 parent b0d20fa commit 32b55cc

File tree

3 files changed

+24
-12
lines changed

3 files changed

+24
-12
lines changed

packages/contentstack-import/src/commands/cm/stacks/import.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,7 @@ export default class ImportCommand extends Command {
148148
const moduleImporter = new ModuleImporter(managementAPIClient, importConfig);
149149
const result = await moduleImporter.start();
150150
backupDir = importConfig.backupDir;
151-
152-
if (!result?.noSuccessMsg) {
153-
const successMessage = importConfig.stackName
154-
? `Successfully imported the content to the stack named ${importConfig.stackName} with the API key ${importConfig.apiKey} .`
155-
: `The content has been imported to the stack ${importConfig.apiKey} successfully!`;
156-
log.success(successMessage, importConfig.context);
157-
}
158-
151+
//Note: Final summary is now handled by summary manager
159152
CLIProgressManager.printGlobalSummary();
160153
this.logSuccessAndBackupMessages(backupDir, importConfig);
161154
// Clear progress module setting now that import is complete

packages/contentstack-utilities/src/progress-summary/cli-progress-manager.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,16 @@ export default class CLIProgressManager {
108108
CLIProgressManager.globalSummary.printFinalSummary();
109109
}
110110

111+
/**
112+
* Check if there are any failures in the global summary
113+
*/
114+
static hasFailures(): boolean {
115+
if (!CLIProgressManager.globalSummary) {
116+
return false;
117+
}
118+
return CLIProgressManager.globalSummary.hasFailures();
119+
}
120+
111121
/**
112122
* Apply strategy-based corrections to module data
113123
*/

packages/contentstack-utilities/src/progress-summary/summary-manager.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,12 @@ export default class SummaryManager {
131131

132132
// Final Status
133133
console.log('\n' + chalk.bold('Final Status:'));
134-
if (failedModules === 0) {
135-
console.log(chalk.bold.green(`🎉 ${this.operationName} completed successfully!`));
136-
} else if (completedModules > 0) {
137-
console.log(chalk.bold.yellow(`⚠️ ${this.operationName} completed with ${failedModules} failed modules`));
134+
if (!this.hasFailures() && failedModules === 0) {
135+
console.log(chalk.bold.green(`✅ ${this.operationName} completed successfully!`));
136+
} else if (this.hasFailures() || failedModules > 0) {
137+
console.log(
138+
chalk.bold.yellow(`⚠️ ${this.operationName} completed with failures, see the logs for more details.`),
139+
);
138140
} else {
139141
console.log(chalk.bold.red(`❌ ${this.operationName} failed`));
140142
}
@@ -146,6 +148,13 @@ export default class SummaryManager {
146148
this.printFailureSummaryWithLogReference();
147149
}
148150

151+
/**
152+
* Check if there are any failures across all modules
153+
*/
154+
hasFailures(): boolean {
155+
return Array.from(this.modules.values()).some((m) => m.failures.length > 0 || m.failureCount > 0);
156+
}
157+
149158
private printFailureSummaryWithLogReference(): void {
150159
const modulesWithFailures = Array.from(this.modules.values()).filter((m) => m.failures.length > 0);
151160

0 commit comments

Comments
 (0)