@contentstack/cli-utilities 1.17.3 → 1.18.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,544 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const chalk_1 = tslib_1.__importDefault(require("chalk"));
5
- const ora_1 = tslib_1.__importDefault(require("ora"));
6
- const cli_progress_1 = tslib_1.__importDefault(require("cli-progress"));
7
- const summary_manager_1 = tslib_1.__importDefault(require("./summary-manager"));
8
- const __1 = require("..");
9
- const progress_strategy_1 = require("./progress-strategy");
10
- class CLIProgressManager {
11
- constructor({ showConsoleLogs = false, total = 0, moduleName = 'Module', enableNestedProgress = false, } = {}) {
12
- this.showConsoleLogs = showConsoleLogs;
13
- this.total = total;
14
- this.moduleName = moduleName;
15
- this.enableNestedProgress = enableNestedProgress;
16
- this.successCount = 0;
17
- this.failureCount = 0;
18
- this.failures = [];
19
- this.spinner = null;
20
- this.progressBar = null;
21
- this.processes = new Map();
22
- this.multiBar = null;
23
- this.currentProcess = null;
24
- this.callbacks = {};
25
- this.branchName = '';
26
- this.initializeProgress();
27
- this.setupGlobalSummaryIntegration();
28
- }
29
- /**
30
- * Initialize global summary manager for the entire operation
31
- */
32
- static initializeGlobalSummary(operationName, branchName, headerTitle) {
33
- var _a;
34
- CLIProgressManager.globalSummary = new summary_manager_1.default({ operationName, context: { branchName } });
35
- // Only show header if console logs are disabled (progress UI mode)
36
- if (!((_a = __1.configHandler.get('log')) === null || _a === void 0 ? void 0 : _a.showConsoleLogs)) {
37
- CLIProgressManager.displayOperationHeader(branchName, headerTitle);
38
- }
39
- return CLIProgressManager.globalSummary;
40
- }
41
- /**
42
- * Display operation header with branch information
43
- */
44
- static displayOperationHeader(branchName, headerTitle) {
45
- if (!headerTitle)
46
- return;
47
- const safeBranchName = branchName || 'main';
48
- const branchInfo = headerTitle || `${safeBranchName === null || safeBranchName === void 0 ? void 0 : safeBranchName.toUpperCase()} CONTENT`;
49
- console.log('\n' + chalk_1.default.bold('='.repeat(80)));
50
- if (branchInfo) {
51
- console.log(chalk_1.default.bold.white(` ${branchInfo}`));
52
- }
53
- console.log(chalk_1.default.bold('='.repeat(80)) + '\n');
54
- }
55
- /**
56
- * Print the final summary for all modules using strategies
57
- */
58
- static printGlobalSummary() {
59
- if (!CLIProgressManager.globalSummary) {
60
- return;
61
- }
62
- // Apply strategy-based corrections before printing
63
- CLIProgressManager.applyStrategyCorrections();
64
- // Print the final summary
65
- CLIProgressManager.globalSummary.printFinalSummary();
66
- }
67
- /**
68
- * Check if there are any failures in the global summary
69
- */
70
- static hasFailures() {
71
- if (!CLIProgressManager.globalSummary) {
72
- return false;
73
- }
74
- return CLIProgressManager.globalSummary.hasFailures();
75
- }
76
- /**
77
- * Apply strategy-based corrections to module data
78
- */
79
- static applyStrategyCorrections() {
80
- if (!CLIProgressManager.globalSummary)
81
- return;
82
- const modules = Array.from(CLIProgressManager.globalSummary.getModules().values());
83
- modules.forEach((module) => {
84
- // Check if this module has a registered strategy
85
- if (progress_strategy_1.ProgressStrategyRegistry.has(module.name)) {
86
- const strategy = progress_strategy_1.ProgressStrategyRegistry.get(module.name);
87
- // Create a processes map from module data if available
88
- const processesMap = new Map();
89
- // If module has process data, populate the map
90
- if (module.processes && Array.isArray(module.processes)) {
91
- module.processes.forEach((processData) => {
92
- if (processData.processName) {
93
- processesMap.set(processData.processName, processData);
94
- }
95
- });
96
- }
97
- // Calculate corrected progress using strategy
98
- const correctedResult = strategy.calculate(processesMap);
99
- if (correctedResult) {
100
- // Update module with corrected counts
101
- module.totalItems = correctedResult.total;
102
- module.successCount = correctedResult.success;
103
- module.failureCount = correctedResult.failures;
104
- }
105
- }
106
- });
107
- }
108
- /**
109
- * Clear global summary (for cleanup)
110
- */
111
- static clearGlobalSummary() {
112
- CLIProgressManager.globalSummary = null;
113
- }
114
- /**
115
- * Create a simple progress manager (no nested processes)
116
- */
117
- static createSimple(moduleName, total, showConsoleLogs = false) {
118
- return new CLIProgressManager({
119
- moduleName: moduleName.toUpperCase(),
120
- total: total || 0,
121
- showConsoleLogs,
122
- enableNestedProgress: false,
123
- });
124
- }
125
- /**
126
- * Create a nested progress manager (with sub-processes)
127
- */
128
- static createNested(moduleName, showConsoleLogs = false) {
129
- return new CLIProgressManager({
130
- moduleName: moduleName.toUpperCase(),
131
- total: 0,
132
- showConsoleLogs,
133
- enableNestedProgress: true,
134
- });
135
- }
136
- /**
137
- * Show a loading spinner before initializing progress
138
- */
139
- static async withLoadingSpinner(message, asyncOperation) {
140
- const spinner = (0, ora_1.default)(message).start();
141
- try {
142
- const result = await asyncOperation();
143
- spinner.stop();
144
- return result;
145
- }
146
- catch (error) {
147
- spinner.stop();
148
- throw error;
149
- }
150
- }
151
- setupGlobalSummaryIntegration() {
152
- var _a, _b;
153
- // Auto-register with global summary if it exists
154
- if (CLIProgressManager.globalSummary) {
155
- this.setCallbacks({
156
- onModuleStart: (name) => {
157
- var _a, _b;
158
- (_a = CLIProgressManager.globalSummary) === null || _a === void 0 ? void 0 : _a.registerModule(name, this.total);
159
- (_b = CLIProgressManager.globalSummary) === null || _b === void 0 ? void 0 : _b.startModule(name);
160
- },
161
- onModuleComplete: (name, success, error) => {
162
- var _a;
163
- // Register process data with summary manager before completing
164
- this.registerProcessDataWithSummary(name);
165
- (_a = CLIProgressManager.globalSummary) === null || _a === void 0 ? void 0 : _a.completeModule(name, success, error);
166
- },
167
- onProgress: (name, success, itemName, error) => {
168
- var _a;
169
- (_a = CLIProgressManager.globalSummary) === null || _a === void 0 ? void 0 : _a.updateModuleProgress(name, success, itemName, error);
170
- },
171
- });
172
- // Trigger module start
173
- (_b = (_a = this.callbacks).onModuleStart) === null || _b === void 0 ? void 0 : _b.call(_a, this.moduleName);
174
- }
175
- }
176
- /**
177
- * Register process data with summary manager for strategy calculations
178
- */
179
- registerProcessDataWithSummary(moduleName) {
180
- if (!CLIProgressManager.globalSummary)
181
- return;
182
- // Register each process with the summary manager
183
- this.processes.forEach((processData, processName) => {
184
- var _a;
185
- (_a = CLIProgressManager.globalSummary) === null || _a === void 0 ? void 0 : _a.registerProcessData(moduleName, processName, {
186
- processName,
187
- total: processData.total,
188
- current: processData.current,
189
- successCount: processData.successCount,
190
- failureCount: processData.failureCount,
191
- status: processData.status,
192
- failures: processData.failures,
193
- });
194
- });
195
- }
196
- /**
197
- * Set callbacks for external integration
198
- */
199
- setCallbacks(callbacks) {
200
- this.callbacks = Object.assign(Object.assign({}, this.callbacks), callbacks);
201
- }
202
- /**
203
- * Convert module name from UPPERCASE to PascalCase
204
- */
205
- formatModuleName(name) {
206
- return name.charAt(0).toUpperCase() + name.slice(1).toLowerCase();
207
- }
208
- /**
209
- * Format process name with smart truncation (modules should use short names)
210
- */
211
- formatProcessName(processName) {
212
- const cleaned = processName.trim();
213
- if (cleaned.length <= 20) {
214
- return cleaned;
215
- }
216
- return cleaned.length <= 20 ? cleaned : cleaned.substring(0, 20) + '...';
217
- }
218
- /**
219
- * Format percentage for consistent alignment (always 3 characters)
220
- */
221
- formatPercentage(percentage) {
222
- if (percentage === 100) {
223
- return '100';
224
- }
225
- else if (percentage >= 10) {
226
- return ` ${percentage}`;
227
- }
228
- else {
229
- return ` ${percentage}`;
230
- }
231
- }
232
- initializeProgress() {
233
- if (this.showConsoleLogs) {
234
- return;
235
- }
236
- if (this.enableNestedProgress) {
237
- // Initialize multi-bar for nested progress tracking
238
- this.multiBar = new cli_progress_1.default.MultiBar({
239
- clearOnComplete: false,
240
- hideCursor: true,
241
- format: ' {label} |' + chalk_1.default.cyan('{bar}') + '| {percentage}% | {value}/{total} | {status}',
242
- barCompleteChar: '\u2588',
243
- barIncompleteChar: '\u2591',
244
- }, cli_progress_1.default.Presets.shades_classic);
245
- if (!this.showConsoleLogs) {
246
- console.log(chalk_1.default.bold.cyan(`\n${this.moduleName}:`));
247
- }
248
- }
249
- else if (this.total > 0) {
250
- if (!this.showConsoleLogs) {
251
- console.log(chalk_1.default.bold.cyan(`\n${this.moduleName}:`));
252
- }
253
- this.progressBar = new cli_progress_1.default.SingleBar({
254
- format: ' {label} |' + chalk_1.default.cyan('{bar}') + '| {percentage}% | {value}/{total} | {status}',
255
- barCompleteChar: '\u2588',
256
- barIncompleteChar: '\u2591',
257
- hideCursor: true,
258
- });
259
- const formattedName = this.formatModuleName(this.moduleName);
260
- const displayName = formattedName.length > 20 ? formattedName.substring(0, 17) + '...' : formattedName;
261
- this.progressBar.start(this.total, 0, {
262
- label: chalk_1.default.gray(` └─ ${displayName}`.padEnd(25)),
263
- status: chalk_1.default.gray('Starting...'),
264
- percentage: ' 0',
265
- });
266
- }
267
- else {
268
- this.spinner = (0, ora_1.default)(`${chalk_1.default.bold(this.moduleName)}: Processing...`).start();
269
- }
270
- }
271
- /**
272
- * Add a new process to track (for nested progress)
273
- */
274
- addProcess(processName, total) {
275
- if (!this.enableNestedProgress)
276
- return this;
277
- const process = {
278
- name: processName,
279
- total,
280
- current: 0,
281
- status: 'pending',
282
- successCount: 0,
283
- failureCount: 0,
284
- failures: [],
285
- };
286
- if (!this.showConsoleLogs && this.multiBar) {
287
- const displayName = this.formatProcessName(processName);
288
- const indentedLabel = ` ├─ ${displayName}`.padEnd(25);
289
- process.progressBar = this.multiBar.create(total, 0, {
290
- label: chalk_1.default.gray(indentedLabel),
291
- status: chalk_1.default.gray('Pending'),
292
- percentage: ' 0',
293
- });
294
- }
295
- this.processes.set(processName, process);
296
- return this;
297
- }
298
- /**
299
- * Update the total for a specific process (for dynamic totals after API calls)
300
- */
301
- updateProcessTotal(processName, newTotal) {
302
- if (!this.enableNestedProgress)
303
- return this;
304
- const process = this.processes.get(processName);
305
- if (process) {
306
- process.total = newTotal;
307
- if (process.progressBar && !this.showConsoleLogs) {
308
- // Update the progress bar with the new total
309
- process.progressBar.setTotal(newTotal);
310
- }
311
- }
312
- return this;
313
- }
314
- /**
315
- * Start a specific process
316
- */
317
- startProcess(processName) {
318
- if (!this.enableNestedProgress)
319
- return this;
320
- const process = this.processes.get(processName);
321
- if (process) {
322
- process.status = 'active';
323
- if (!this.showConsoleLogs && process.progressBar) {
324
- const displayName = this.formatProcessName(processName);
325
- const indentedLabel = ` ├─ ${displayName}`.padEnd(25);
326
- process.progressBar.update(0, {
327
- label: chalk_1.default.yellow(indentedLabel),
328
- status: chalk_1.default.yellow('Processing'),
329
- percentage: ' 0',
330
- });
331
- }
332
- this.currentProcess = processName;
333
- }
334
- return this;
335
- }
336
- /**
337
- * Complete a specific process
338
- */
339
- completeProcess(processName, success = true) {
340
- if (!this.enableNestedProgress)
341
- return this;
342
- const process = this.processes.get(processName);
343
- if (process) {
344
- process.status = success ? 'completed' : 'failed';
345
- // If process completed without ticks, update current to reflect completion
346
- if (process.current === 0 && process.total > 0) {
347
- process.current = process.total;
348
- if (process.status === 'completed') {
349
- process.successCount = process.total;
350
- }
351
- }
352
- if (!this.showConsoleLogs && process.progressBar) {
353
- const totalProcessed = process.current;
354
- const percentage = Math.round((totalProcessed / process.total) * 100);
355
- const formattedPercentage = this.formatPercentage(percentage);
356
- const statusText = success
357
- ? chalk_1.default.green(`✓ Complete (${process.successCount}/${process.current})`)
358
- : chalk_1.default.red(`✗ Failed (${process.successCount}/${process.current})`);
359
- const displayName = this.formatProcessName(processName);
360
- const indentedLabel = ` ├─ ${displayName}`.padEnd(25);
361
- process.progressBar.update(process.total, {
362
- label: success ? chalk_1.default.green(indentedLabel) : chalk_1.default.red(indentedLabel),
363
- status: statusText,
364
- percentage: formattedPercentage,
365
- });
366
- }
367
- }
368
- return this;
369
- }
370
- /**
371
- * Update status message
372
- */
373
- updateStatus(message, processName) {
374
- if (!this.showConsoleLogs) {
375
- if (this.enableNestedProgress && processName) {
376
- const process = this.processes.get(processName);
377
- if (process && process.progressBar) {
378
- const percentage = Math.round((process.current / process.total) * 100);
379
- const formattedPercentage = this.formatPercentage(percentage);
380
- const displayName = this.formatProcessName(processName);
381
- const indentedLabel = ` ├─ ${displayName}`.padEnd(25);
382
- process.progressBar.update(process.current, {
383
- label: chalk_1.default.yellow(indentedLabel),
384
- status: chalk_1.default.yellow(message),
385
- percentage: formattedPercentage,
386
- });
387
- }
388
- }
389
- else if (this.progressBar) {
390
- const percentage = Math.round(this.progressBar.getProgress() * 100);
391
- const formattedPercentage = this.formatPercentage(percentage);
392
- const formattedName = this.formatModuleName(this.moduleName);
393
- const displayName = formattedName.length > 20 ? formattedName.substring(0, 17) + '...' : formattedName;
394
- this.progressBar.update(this.progressBar.getProgress() * this.total, {
395
- label: chalk_1.default.yellow(` └─ ${displayName}`.padEnd(25)),
396
- status: chalk_1.default.yellow(message),
397
- percentage: formattedPercentage,
398
- });
399
- }
400
- else if (this.spinner) {
401
- this.spinner.text = `${chalk_1.default.bold(this.moduleName)}: ${message}`;
402
- }
403
- }
404
- return this;
405
- }
406
- /**
407
- * Update progress
408
- */
409
- tick(success = true, itemName = '', errorMessage = null, processName) {
410
- var _a, _b;
411
- const targetProcess = processName || this.currentProcess;
412
- if (success) {
413
- this.successCount++;
414
- }
415
- else {
416
- this.failureCount++;
417
- this.failures.push({
418
- item: itemName,
419
- error: errorMessage,
420
- process: targetProcess || undefined,
421
- });
422
- }
423
- // Trigger callback
424
- (_b = (_a = this.callbacks).onProgress) === null || _b === void 0 ? void 0 : _b.call(_a, this.moduleName, success, itemName, errorMessage || undefined);
425
- // Update nested progress if enabled and console logs are disabled
426
- if (this.enableNestedProgress && targetProcess) {
427
- const process = this.processes.get(targetProcess);
428
- if (process) {
429
- process.current++;
430
- if (success) {
431
- process.successCount++;
432
- }
433
- else {
434
- process.failureCount++;
435
- process.failures.push({ item: itemName, error: errorMessage });
436
- }
437
- // Only update progress bar if console logs are disabled
438
- if (!this.showConsoleLogs && process.progressBar) {
439
- const percentage = Math.round((process.current / process.total) * 100);
440
- const formattedPercentage = this.formatPercentage(percentage);
441
- const statusText = `${process.successCount}✓ ${process.failureCount}✗`;
442
- const displayName = this.formatProcessName(targetProcess);
443
- const indentedLabel = ` ├─ ${displayName}`.padEnd(25);
444
- process.progressBar.increment(1, {
445
- label: chalk_1.default.cyan(indentedLabel),
446
- status: chalk_1.default.cyan(statusText),
447
- percentage: formattedPercentage,
448
- });
449
- }
450
- }
451
- }
452
- else {
453
- // Update single progress bar or spinner only if console logs are disabled
454
- if (!this.showConsoleLogs) {
455
- if (this.progressBar) {
456
- const percentage = Math.round(((this.successCount + this.failureCount) / this.total) * 100);
457
- const formattedPercentage = this.formatPercentage(percentage);
458
- const totalProcessed = this.successCount + this.failureCount;
459
- // Show completion status when finished, otherwise show running count
460
- const statusText = totalProcessed >= this.total
461
- ? this.failureCount === 0
462
- ? chalk_1.default.green(`✓ Complete (${this.successCount}/${totalProcessed})`)
463
- : chalk_1.default.yellow(`✓ Complete (${this.successCount}/${totalProcessed})`)
464
- : chalk_1.default.cyan(`${this.successCount}✓ ${this.failureCount}✗`);
465
- const labelColor = totalProcessed >= this.total ? (this.failureCount === 0 ? chalk_1.default.green : chalk_1.default.yellow) : chalk_1.default.cyan;
466
- const formattedName = this.formatModuleName(this.moduleName);
467
- const displayName = formattedName.length > 20 ? formattedName.substring(0, 17) + '...' : formattedName;
468
- this.progressBar.increment(1, {
469
- label: labelColor(` └─ ${displayName}`.padEnd(25)),
470
- status: statusText,
471
- percentage: formattedPercentage,
472
- });
473
- }
474
- else if (this.spinner) {
475
- const total = this.successCount + this.failureCount;
476
- this.spinner.text = `${chalk_1.default.bold(this.moduleName)}: ${total} items (${this.successCount}✓ ${this.failureCount}✗)`;
477
- }
478
- }
479
- }
480
- return this;
481
- }
482
- /**
483
- * Complete the entire module
484
- */
485
- complete(success = true, error) {
486
- var _a, _b;
487
- this.stop();
488
- (_b = (_a = this.callbacks).onModuleComplete) === null || _b === void 0 ? void 0 : _b.call(_a, this.moduleName, success, error);
489
- return this;
490
- }
491
- /**
492
- * Log message (respects showConsoleLogs mode)
493
- */
494
- log(msg) {
495
- if (this.showConsoleLogs) {
496
- console.log(msg);
497
- }
498
- }
499
- /**
500
- * Stop all progress indicators
501
- */
502
- stop() {
503
- // Stop progress bars if they were initialized
504
- if (this.multiBar) {
505
- this.multiBar.stop();
506
- }
507
- if (this.progressBar) {
508
- this.progressBar.stop();
509
- }
510
- if (this.spinner) {
511
- this.spinner.stop();
512
- }
513
- }
514
- printSummary() {
515
- if (!this.enableNestedProgress) {
516
- // Simple summary for single progress
517
- this.log('\n' + chalk_1.default.bold(`${this.moduleName} Summary:`));
518
- this.log(`✓ Success: ${chalk_1.default.green(this.successCount)}`);
519
- this.log(`✗ Failures: ${chalk_1.default.red(this.failureCount)}`);
520
- return;
521
- }
522
- // Detailed summary for nested progress
523
- this.log('\n' + chalk_1.default.bold(`${this.moduleName} Detailed Summary:`));
524
- for (const [processName, process] of this.processes) {
525
- const status = process.status === 'completed'
526
- ? '✓'
527
- : process.status === 'failed'
528
- ? '✗'
529
- : process.status === 'active'
530
- ? '●'
531
- : '○';
532
- this.log(` ${status} ${processName}: ${process.successCount}✓ ${process.failureCount}✗ (${process.current}/${process.total})`);
533
- }
534
- this.log(`\nOverall: ${this.successCount}✓ ${this.failureCount}✗`);
535
- }
536
- /**
537
- * Get the current failure count
538
- */
539
- getFailureCount() {
540
- return this.failureCount;
541
- }
542
- }
543
- exports.default = CLIProgressManager;
544
- CLIProgressManager.globalSummary = null;
@@ -1,4 +0,0 @@
1
- import SummaryManager from './summary-manager';
2
- import CLIProgressManager from './cli-progress-manager';
3
- import { PrimaryProcessStrategy, CustomProgressStrategy, ProgressStrategyRegistry, DefaultProgressStrategy } from './progress-strategy';
4
- export { SummaryManager, CLIProgressManager, PrimaryProcessStrategy, CustomProgressStrategy, ProgressStrategyRegistry, DefaultProgressStrategy, };
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DefaultProgressStrategy = exports.ProgressStrategyRegistry = exports.CustomProgressStrategy = exports.PrimaryProcessStrategy = exports.CLIProgressManager = exports.SummaryManager = void 0;
4
- const tslib_1 = require("tslib");
5
- const summary_manager_1 = tslib_1.__importDefault(require("./summary-manager"));
6
- exports.SummaryManager = summary_manager_1.default;
7
- const cli_progress_manager_1 = tslib_1.__importDefault(require("./cli-progress-manager"));
8
- exports.CLIProgressManager = cli_progress_manager_1.default;
9
- const progress_strategy_1 = require("./progress-strategy");
10
- Object.defineProperty(exports, "PrimaryProcessStrategy", { enumerable: true, get: function () { return progress_strategy_1.PrimaryProcessStrategy; } });
11
- Object.defineProperty(exports, "CustomProgressStrategy", { enumerable: true, get: function () { return progress_strategy_1.CustomProgressStrategy; } });
12
- Object.defineProperty(exports, "ProgressStrategyRegistry", { enumerable: true, get: function () { return progress_strategy_1.ProgressStrategyRegistry; } });
13
- Object.defineProperty(exports, "DefaultProgressStrategy", { enumerable: true, get: function () { return progress_strategy_1.DefaultProgressStrategy; } });
@@ -1,25 +0,0 @@
1
- import { ProcessProgress, ProgressResult } from '../interfaces';
2
- export interface ProgressCalculationStrategy {
3
- calculate(processes: Map<string, ProcessProgress>): ProgressResult | null;
4
- }
5
- export declare class DefaultProgressStrategy implements ProgressCalculationStrategy {
6
- calculate(): ProgressResult | null;
7
- }
8
- export declare class PrimaryProcessStrategy implements ProgressCalculationStrategy {
9
- private primaryProcessName;
10
- constructor(primaryProcessName: string);
11
- calculate(processes: Map<string, ProcessProgress>): ProgressResult | null;
12
- }
13
- export declare class CustomProgressStrategy implements ProgressCalculationStrategy {
14
- private calculator;
15
- constructor(calculator: (processes: Map<string, ProcessProgress>) => ProgressResult | null);
16
- calculate(processes: Map<string, ProcessProgress>): ProgressResult | null;
17
- }
18
- export declare class ProgressStrategyRegistry {
19
- private static strategies;
20
- static register(moduleName: string, strategy: ProgressCalculationStrategy): void;
21
- static get(moduleName: string): ProgressCalculationStrategy;
22
- static clear(): void;
23
- static has(moduleName: string): boolean;
24
- static getAllRegistered(): string[];
25
- }
@@ -1,54 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ProgressStrategyRegistry = exports.CustomProgressStrategy = exports.PrimaryProcessStrategy = exports.DefaultProgressStrategy = void 0;
4
- class DefaultProgressStrategy {
5
- calculate() {
6
- return null; // Use default aggregated counting
7
- }
8
- }
9
- exports.DefaultProgressStrategy = DefaultProgressStrategy;
10
- class PrimaryProcessStrategy {
11
- constructor(primaryProcessName) {
12
- this.primaryProcessName = primaryProcessName;
13
- }
14
- calculate(processes) {
15
- const primaryProcess = processes.get(this.primaryProcessName);
16
- if (!primaryProcess)
17
- return null;
18
- return {
19
- total: primaryProcess.total,
20
- success: primaryProcess.successCount,
21
- failures: primaryProcess.failureCount
22
- };
23
- }
24
- }
25
- exports.PrimaryProcessStrategy = PrimaryProcessStrategy;
26
- class CustomProgressStrategy {
27
- constructor(calculator) {
28
- this.calculator = calculator;
29
- }
30
- calculate(processes) {
31
- return this.calculator(processes);
32
- }
33
- }
34
- exports.CustomProgressStrategy = CustomProgressStrategy;
35
- // Registry
36
- class ProgressStrategyRegistry {
37
- static register(moduleName, strategy) {
38
- this.strategies.set(moduleName.toUpperCase(), strategy);
39
- }
40
- static get(moduleName) {
41
- return this.strategies.get(moduleName.toUpperCase()) || new DefaultProgressStrategy();
42
- }
43
- static clear() {
44
- this.strategies.clear();
45
- }
46
- static has(moduleName) {
47
- return this.strategies.has(moduleName.toUpperCase());
48
- }
49
- static getAllRegistered() {
50
- return Array.from(this.strategies.keys());
51
- }
52
- }
53
- exports.ProgressStrategyRegistry = ProgressStrategyRegistry;
54
- ProgressStrategyRegistry.strategies = new Map();
@@ -1,28 +0,0 @@
1
- import { ModuleResult, SummaryOptions } from '../interfaces/index';
2
- export default class SummaryManager {
3
- private modules;
4
- private operationName;
5
- private context;
6
- private operationStartTime;
7
- private branchName;
8
- constructor({ operationName, context }: SummaryOptions);
9
- getModules(): Map<string, ModuleResult>;
10
- registerModule(moduleName: string, totalItems?: number): void;
11
- startModule(moduleName: string): void;
12
- completeModule(moduleName: string, success?: boolean, error?: string): void;
13
- /**
14
- * Register process data for strategy calculations
15
- */
16
- registerProcessData(moduleName: string, processName: string, processData: any): void;
17
- updateModuleProgress(moduleName: string, success: boolean, itemName: string, error?: string): void;
18
- printFinalSummary(): void;
19
- /**
20
- * Check if there are any failures across all modules
21
- */
22
- hasFailures(): boolean;
23
- private printFailureSummaryWithLogReference;
24
- private getStatusIcon;
25
- private formatDuration;
26
- private calculateSuccessRate;
27
- private formatSuccessRate;
28
- }