@b64hub/sfpm-cli 0.1.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.
- package/README.md +915 -0
- package/bin/debug.sh +14 -0
- package/bin/dev.cmd +3 -0
- package/bin/dev.js +5 -0
- package/bin/run.cmd +3 -0
- package/bin/run.js +5 -0
- package/dist/commands/bootstrap.d.ts +19 -0
- package/dist/commands/bootstrap.js +279 -0
- package/dist/commands/bootstrap.js.map +1 -0
- package/dist/commands/build/status.d.ts +14 -0
- package/dist/commands/build/status.js +177 -0
- package/dist/commands/build/status.js.map +1 -0
- package/dist/commands/build.d.ts +30 -0
- package/dist/commands/build.js +228 -0
- package/dist/commands/build.js.map +1 -0
- package/dist/commands/deploy/artifact.d.ts +19 -0
- package/dist/commands/deploy/artifact.js +96 -0
- package/dist/commands/deploy/artifact.js.map +1 -0
- package/dist/commands/deploy.d.ts +20 -0
- package/dist/commands/deploy.js +141 -0
- package/dist/commands/deploy.js.map +1 -0
- package/dist/commands/hello/index.d.ts +12 -0
- package/dist/commands/hello/index.js +20 -0
- package/dist/commands/hello/index.js.map +1 -0
- package/dist/commands/hello/world.d.ts +8 -0
- package/dist/commands/hello/world.js +15 -0
- package/dist/commands/hello/world.js.map +1 -0
- package/dist/commands/install.d.ts +21 -0
- package/dist/commands/install.js +141 -0
- package/dist/commands/install.js.map +1 -0
- package/dist/commands/pool/delete.d.ts +15 -0
- package/dist/commands/pool/delete.js +80 -0
- package/dist/commands/pool/delete.js.map +1 -0
- package/dist/commands/pool/fetch.d.ts +16 -0
- package/dist/commands/pool/fetch.js +89 -0
- package/dist/commands/pool/fetch.js.map +1 -0
- package/dist/commands/pool/list.d.ts +15 -0
- package/dist/commands/pool/list.js +84 -0
- package/dist/commands/pool/list.js.map +1 -0
- package/dist/commands/pool/provision.d.ts +22 -0
- package/dist/commands/pool/provision.js +115 -0
- package/dist/commands/pool/provision.js.map +1 -0
- package/dist/commands/project/init/index.d.ts +15 -0
- package/dist/commands/project/init/index.js +156 -0
- package/dist/commands/project/init/index.js.map +1 -0
- package/dist/commands/project/init/turbo.d.ts +22 -0
- package/dist/commands/project/init/turbo.js +272 -0
- package/dist/commands/project/init/turbo.js.map +1 -0
- package/dist/commands/project/sync.d.ts +10 -0
- package/dist/commands/project/sync.js +74 -0
- package/dist/commands/project/sync.js.map +1 -0
- package/dist/commands/project/version/bump.d.ts +22 -0
- package/dist/commands/project/version/bump.js +187 -0
- package/dist/commands/project/version/bump.js.map +1 -0
- package/dist/commands/project.d.ts +13 -0
- package/dist/commands/project.js +105 -0
- package/dist/commands/project.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/sfpm-command.d.ts +15 -0
- package/dist/sfpm-command.js +34 -0
- package/dist/sfpm-command.js.map +1 -0
- package/dist/ui/boxes.d.ts +4 -0
- package/dist/ui/boxes.js +34 -0
- package/dist/ui/boxes.js.map +1 -0
- package/dist/ui/build-progress-renderer.d.ts +98 -0
- package/dist/ui/build-progress-renderer.js +684 -0
- package/dist/ui/build-progress-renderer.js.map +1 -0
- package/dist/ui/install-progress-renderer.d.ts +112 -0
- package/dist/ui/install-progress-renderer.js +443 -0
- package/dist/ui/install-progress-renderer.js.map +1 -0
- package/dist/ui/orchestration-listr.d.ts +211 -0
- package/dist/ui/orchestration-listr.js +391 -0
- package/dist/ui/orchestration-listr.js.map +1 -0
- package/dist/ui/pool-progress-renderer.d.ts +68 -0
- package/dist/ui/pool-progress-renderer.js +298 -0
- package/dist/ui/pool-progress-renderer.js.map +1 -0
- package/dist/ui/renderer-utils.d.ts +68 -0
- package/dist/ui/renderer-utils.js +66 -0
- package/dist/ui/renderer-utils.js.map +1 -0
- package/dist/utils/notifier.d.ts +12 -0
- package/dist/utils/notifier.js +73 -0
- package/dist/utils/notifier.js.map +1 -0
- package/dist/utils/validation-watcher.d.ts +1 -0
- package/dist/utils/validation-watcher.js +114 -0
- package/dist/utils/validation-watcher.js.map +1 -0
- package/oclif.manifest.json +1294 -0
- package/package.json +89 -0
- package/theme.json +26 -0
|
@@ -0,0 +1,684 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import ora from 'ora';
|
|
3
|
+
import { infoBox, successBox, warningBox } from './boxes.js';
|
|
4
|
+
import { OrchestrationListrManager } from './orchestration-listr.js';
|
|
5
|
+
import { calculateDuration, formatDuration, NameAligner } from './renderer-utils.js';
|
|
6
|
+
/**
|
|
7
|
+
* Renders build progress in different output modes
|
|
8
|
+
*/
|
|
9
|
+
export class BuildProgressRenderer {
|
|
10
|
+
analyzerNameAligner = new NameAligner();
|
|
11
|
+
buildResult;
|
|
12
|
+
/**
|
|
13
|
+
* Event configuration mapping events to handlers
|
|
14
|
+
*/
|
|
15
|
+
eventConfigs = {
|
|
16
|
+
'analyzer:complete': { description: 'Analyzer complete', handler: this.handleAnalyzerComplete.bind(this) },
|
|
17
|
+
'analyzer:start': { description: 'Analyzer started', handler: this.handleAnalyzerStart.bind(this) },
|
|
18
|
+
'analyzers:complete': { description: 'All analyzers complete', handler: this.handleAnalyzersComplete.bind(this) },
|
|
19
|
+
'analyzers:start': { description: 'Analyzers started', handler: this.handleAnalyzersStart.bind(this) },
|
|
20
|
+
'build:complete': { description: 'Build completed', handler: this.handleBuildComplete.bind(this) },
|
|
21
|
+
'build:error': { description: 'Build failed', handler: this.handleBuildError.bind(this) },
|
|
22
|
+
'build:skipped': { description: 'Build skipped', handler: this.handleBuildSkipped.bind(this) },
|
|
23
|
+
'build:start': { description: 'Build started', handler: this.handleBuildStart.bind(this) },
|
|
24
|
+
'builder:complete': { description: 'Builder complete', handler: this.handleBuilderComplete.bind(this) },
|
|
25
|
+
'builder:start': { description: 'Builder started', handler: this.handleBuilderStart.bind(this) },
|
|
26
|
+
'connection:complete': { description: 'Connection complete', handler: this.handleConnectionComplete.bind(this) },
|
|
27
|
+
'connection:start': { description: 'Connection started', handler: this.handleConnectionStart.bind(this) },
|
|
28
|
+
'stage:complete': { description: 'Staging complete', handler: this.handleStageComplete.bind(this) },
|
|
29
|
+
'stage:start': { description: 'Staging package', handler: this.handleStageStart.bind(this) },
|
|
30
|
+
'task:complete': { description: 'Task complete', handler: this.handleTaskComplete.bind(this) },
|
|
31
|
+
'task:start': { description: 'Task started', handler: this.handleTaskStart.bind(this) },
|
|
32
|
+
'unlocked:create:complete': { description: 'Package creation complete', handler: this.handleCreateComplete.bind(this) },
|
|
33
|
+
'unlocked:create:progress': { description: 'Package creation progress', handler: this.handleCreateProgress.bind(this) },
|
|
34
|
+
'unlocked:create:start': { description: 'Package creation started', handler: this.handleCreateStart.bind(this) },
|
|
35
|
+
};
|
|
36
|
+
events = [];
|
|
37
|
+
listr;
|
|
38
|
+
logger;
|
|
39
|
+
mode;
|
|
40
|
+
/**
|
|
41
|
+
* Event configuration for orchestration-level events
|
|
42
|
+
*/
|
|
43
|
+
orchestrationEventConfigs = {
|
|
44
|
+
'orchestration:complete': { description: 'Orchestration complete', handler: this.handleOrchestrationComplete.bind(this) },
|
|
45
|
+
'orchestration:level:complete': { description: 'Level complete', handler: this.handleOrchestrationLevelComplete.bind(this) },
|
|
46
|
+
'orchestration:level:start': { description: 'Level started', handler: this.handleOrchestrationLevelStart.bind(this) },
|
|
47
|
+
'orchestration:package:complete': { description: 'Package complete', handler: this.handleOrchestrationPackageComplete.bind(this) },
|
|
48
|
+
'orchestration:start': { description: 'Orchestration started', handler: this.handleOrchestrationStart.bind(this) },
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Tracks pending analyzer names during collection.
|
|
52
|
+
* Once all `analyzer:start` events arrive, subtasks are created.
|
|
53
|
+
*/
|
|
54
|
+
pendingAnalyzers = new Map();
|
|
55
|
+
/**
|
|
56
|
+
* Tracks skip reasons per package so they survive across event handlers.
|
|
57
|
+
* Populated by `build:skipped`, consumed by `orchestration:package:complete`.
|
|
58
|
+
*/
|
|
59
|
+
skippedReasons = new Map();
|
|
60
|
+
spinner;
|
|
61
|
+
timings = {
|
|
62
|
+
analyzerStarts: new Map(),
|
|
63
|
+
};
|
|
64
|
+
constructor(options) {
|
|
65
|
+
this.logger = options.logger;
|
|
66
|
+
this.mode = options.mode;
|
|
67
|
+
this.listr = new OrchestrationListrManager(event => {
|
|
68
|
+
const count = event.packages.length;
|
|
69
|
+
const pkgText = count === 1 ? 'package' : 'packages';
|
|
70
|
+
return `Building ${chalk.cyan(String(count))} ${pkgText}`;
|
|
71
|
+
}, { enableSubtasks: true });
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Attach this renderer to a PackageBuilder or BuildOrchestrator instance
|
|
75
|
+
*/
|
|
76
|
+
attachTo(emitter) {
|
|
77
|
+
// Attach all configured build event handlers
|
|
78
|
+
for (const [eventName, config] of Object.entries(this.eventConfigs)) {
|
|
79
|
+
emitter.on(eventName, (data) => {
|
|
80
|
+
this.logEvent(eventName, data);
|
|
81
|
+
config.handler(data);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
// Attach orchestration event handlers (no-ops if emitter is a plain PackageBuilder)
|
|
85
|
+
for (const [eventName, config] of Object.entries(this.orchestrationEventConfigs)) {
|
|
86
|
+
emitter.on(eventName, (data) => {
|
|
87
|
+
config.handler(data);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
// ========================================================================
|
|
92
|
+
// Spinner Management
|
|
93
|
+
// ========================================================================
|
|
94
|
+
/**
|
|
95
|
+
* Get JSON output for --json flag
|
|
96
|
+
*/
|
|
97
|
+
getJsonOutput() {
|
|
98
|
+
const duration = this.timings.buildStart && this.events.length > 0
|
|
99
|
+
? this.events.at(-1).timestamp.getTime() - this.timings.buildStart.getTime()
|
|
100
|
+
: 0;
|
|
101
|
+
return {
|
|
102
|
+
duration,
|
|
103
|
+
events: this.events,
|
|
104
|
+
result: this.buildResult,
|
|
105
|
+
status: this.buildResult?.success ? 'success' : 'error',
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Handle error display
|
|
110
|
+
*/
|
|
111
|
+
handleError(error) {
|
|
112
|
+
if (!this.isInteractive())
|
|
113
|
+
return;
|
|
114
|
+
this.stopSpinner(false);
|
|
115
|
+
}
|
|
116
|
+
// ========================================================================
|
|
117
|
+
// Event Handlers
|
|
118
|
+
// ========================================================================
|
|
119
|
+
/**
|
|
120
|
+
* Look up the Listr sub-task for a package within the active orchestration level.
|
|
121
|
+
* Returns undefined when running in standalone (non-orchestration) mode.
|
|
122
|
+
*/
|
|
123
|
+
getPackageTask(packageName) {
|
|
124
|
+
return this.listr.getPackageTask(packageName);
|
|
125
|
+
}
|
|
126
|
+
handleAnalyzerComplete(event) {
|
|
127
|
+
if (!this.isInteractive())
|
|
128
|
+
return;
|
|
129
|
+
const startTime = this.timings.analyzerStarts.get(event.analyzerName);
|
|
130
|
+
const duration = calculateDuration(startTime, event.timestamp);
|
|
131
|
+
const task = this.getPackageTask(event.packageName);
|
|
132
|
+
if (task) {
|
|
133
|
+
if (this.listr.hasSubtasks(event.packageName)) {
|
|
134
|
+
// Build findings suffix for the subtask title
|
|
135
|
+
let findingsSuffix = '';
|
|
136
|
+
if (event.findings && Object.keys(event.findings).length > 0) {
|
|
137
|
+
const findings = Object.entries(event.findings)
|
|
138
|
+
.filter(([_, value]) => value && (Array.isArray(value) ? value.length > 0 : true))
|
|
139
|
+
.map(([key, value]) => (Array.isArray(value) ? `${key}: ${value.length}` : key))
|
|
140
|
+
.join(', ');
|
|
141
|
+
if (findings)
|
|
142
|
+
findingsSuffix = ` ${chalk.gray(`- ${findings}`)}`;
|
|
143
|
+
}
|
|
144
|
+
this.listr.updateSubtaskTitle(event.packageName, event.analyzerName, `${chalk.green(event.analyzerName)} ${chalk.gray(`(${duration})`)}${findingsSuffix}`);
|
|
145
|
+
this.listr.resolveSubtask(event.packageName, event.analyzerName);
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
this.listr.updatePackageTitle(event.packageName, `${chalk.cyan(event.packageName)} - Analyzer: ${event.analyzerName} ${chalk.gray(`(${duration})`)}`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
else if (!this.isOrchestrating()) {
|
|
152
|
+
// Build findings summary
|
|
153
|
+
let findingsSummary = '';
|
|
154
|
+
if (event.findings && Object.keys(event.findings).length > 0) {
|
|
155
|
+
const findings = Object.entries(event.findings)
|
|
156
|
+
.filter(([_, value]) => value && (Array.isArray(value) ? value.length > 0 : true))
|
|
157
|
+
.map(([key, value]) => {
|
|
158
|
+
if (Array.isArray(value)) {
|
|
159
|
+
return `${key}: ${value.length}`;
|
|
160
|
+
}
|
|
161
|
+
return key;
|
|
162
|
+
})
|
|
163
|
+
.join(', ');
|
|
164
|
+
if (findings) {
|
|
165
|
+
findingsSummary = `: ${findings}`;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
// Pad duration and analyzer name for alignment
|
|
169
|
+
const paddedDuration = duration.padStart(6);
|
|
170
|
+
const paddedName = this.analyzerNameAligner.pad(event.analyzerName);
|
|
171
|
+
// Log completion with aligned duration and analyzer name
|
|
172
|
+
console.log(` ${chalk.green('✓')} ${chalk.gray(paddedDuration)} - ${chalk.cyan(paddedName)}${chalk.gray(findingsSummary)}`);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
handleAnalyzersComplete(event) {
|
|
176
|
+
if (!this.isInteractive() || event.completedCount === 0)
|
|
177
|
+
return;
|
|
178
|
+
const task = this.getPackageTask(event.packageName);
|
|
179
|
+
if (task) {
|
|
180
|
+
// With subtasks the individual analyzer tasks already show completion;
|
|
181
|
+
// only update the parent title when NOT using subtask mode.
|
|
182
|
+
if (!this.listr.hasSubtasks(event.packageName)) {
|
|
183
|
+
this.listr.updatePackageTitle(event.packageName, `${chalk.cyan(event.packageName)} - Analyzed (${event.completedCount} analyzers)`);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
else if (!this.isOrchestrating()) {
|
|
187
|
+
// Show completion summary
|
|
188
|
+
const duration = calculateDuration(this.timings.analyzersStart, event.timestamp);
|
|
189
|
+
const analyzerText = event.completedCount === 1 ? 'analyzer' : 'analyzers';
|
|
190
|
+
this.logger.log(chalk.green(`✔ Completed ${event.completedCount} ${analyzerText} in ${duration}`));
|
|
191
|
+
this.logger.log('');
|
|
192
|
+
}
|
|
193
|
+
// Reset analyzer tracking for next build
|
|
194
|
+
this.analyzerNameAligner.reset();
|
|
195
|
+
}
|
|
196
|
+
handleAnalyzersStart(event) {
|
|
197
|
+
this.timings.analyzersStart = event.timestamp;
|
|
198
|
+
if (!this.isInteractive())
|
|
199
|
+
return;
|
|
200
|
+
// In orchestration mode, set up subtask collection or skip
|
|
201
|
+
if (this.isOrchestrating()) {
|
|
202
|
+
if (event.analyzerCount === 0) {
|
|
203
|
+
this.listr.skipPackageSubtasks(event.packageName);
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
this.pendingAnalyzers.set(event.packageName, { count: event.analyzerCount, names: [] });
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
if (event.analyzerCount === 0)
|
|
210
|
+
return;
|
|
211
|
+
const task = this.getPackageTask(event.packageName);
|
|
212
|
+
if (task) {
|
|
213
|
+
// Package title is not updated here — subtasks will show analyzer detail.
|
|
214
|
+
// For packages without subtasks (0 analyzers), this block is not reached
|
|
215
|
+
// because we return early above.
|
|
216
|
+
}
|
|
217
|
+
else if (!this.isOrchestrating()) {
|
|
218
|
+
// Log a static message instead of spinner for parallel analyzers
|
|
219
|
+
const analyzerText = event.analyzerCount === 1 ? 'analyzer' : 'analyzers';
|
|
220
|
+
this.logger.log(chalk.dim(`Running ${event.analyzerCount} ${analyzerText}...`));
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
handleAnalyzerStart(event) {
|
|
224
|
+
this.timings.analyzerStarts.set(event.analyzerName, event.timestamp);
|
|
225
|
+
// Track analyzer names for alignment
|
|
226
|
+
this.analyzerNameAligner.add(event.analyzerName);
|
|
227
|
+
// In orchestration mode, collect names then create subtasks
|
|
228
|
+
if (this.isOrchestrating()) {
|
|
229
|
+
const pending = this.pendingAnalyzers.get(event.packageName);
|
|
230
|
+
if (pending) {
|
|
231
|
+
pending.names.push(event.analyzerName);
|
|
232
|
+
if (pending.names.length === pending.count) {
|
|
233
|
+
// All analyzer names collected — declare subtask structure
|
|
234
|
+
this.listr.setPackageSubtasks(event.packageName, pending.names.map(name => ({ name, title: chalk.cyan(name) })));
|
|
235
|
+
this.pendingAnalyzers.delete(event.packageName);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
handleBuildComplete(event) {
|
|
241
|
+
this.buildResult = {
|
|
242
|
+
packageVersionId: event.packageVersionId,
|
|
243
|
+
success: true,
|
|
244
|
+
};
|
|
245
|
+
if (!this.isInteractive())
|
|
246
|
+
return;
|
|
247
|
+
const duration = calculateDuration(this.timings.buildStart, event.timestamp);
|
|
248
|
+
const task = this.getPackageTask(event.packageName);
|
|
249
|
+
if (task) {
|
|
250
|
+
this.listr.updatePackageTitle(event.packageName, `${chalk.green('Built')} ${chalk.cyan(event.packageName)} ${chalk.gray(`(${duration})`)}`);
|
|
251
|
+
}
|
|
252
|
+
else if (!this.isOrchestrating()) {
|
|
253
|
+
this.logger.log(chalk.green.bold('\n✓ Build complete!') + chalk.gray(` (${duration})`));
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
handleBuilderComplete(event) {
|
|
257
|
+
// No UI update needed — subsequent events (build:complete, etc.) handle display
|
|
258
|
+
}
|
|
259
|
+
handleBuildError(event) {
|
|
260
|
+
this.buildResult = {
|
|
261
|
+
error: event.error,
|
|
262
|
+
success: false,
|
|
263
|
+
};
|
|
264
|
+
const task = this.getPackageTask(event.packageName);
|
|
265
|
+
if (task) {
|
|
266
|
+
this.listr.updatePackageTitle(event.packageName, `${chalk.red('Failed')} ${chalk.cyan(event.packageName)} - ${event.phase}`);
|
|
267
|
+
}
|
|
268
|
+
else if (this.isOrchestrating()) {
|
|
269
|
+
// During orchestration, error display is handled by orchestration:package:complete
|
|
270
|
+
}
|
|
271
|
+
else {
|
|
272
|
+
// Stop any active spinner
|
|
273
|
+
if (this.isInteractive()) {
|
|
274
|
+
this.stopSpinner(false);
|
|
275
|
+
}
|
|
276
|
+
// Always show errors, even in quiet mode
|
|
277
|
+
this.logger.error(chalk.red.bold(`✗ Build failed in ${event.phase} phase: `) + event.error.message);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
handleBuilderStart(event) {
|
|
281
|
+
this.timings.builderStart = event.timestamp;
|
|
282
|
+
if (!this.isInteractive())
|
|
283
|
+
return;
|
|
284
|
+
// If subtasks haven't been set for this package yet (e.g. Data packages
|
|
285
|
+
// that skip analyzers entirely), resolve with empty subtasks now.
|
|
286
|
+
if (this.isOrchestrating()) {
|
|
287
|
+
this.listr.skipPackageSubtasks(event.packageName);
|
|
288
|
+
}
|
|
289
|
+
const task = this.getPackageTask(event.packageName);
|
|
290
|
+
if (task) {
|
|
291
|
+
const statusText = `Executing ${event.packageType} builder...`;
|
|
292
|
+
if (this.listr.hasSubtasks(event.packageName)) {
|
|
293
|
+
this.listr.updateSentinelTitle(event.packageName, statusText);
|
|
294
|
+
}
|
|
295
|
+
else {
|
|
296
|
+
this.listr.updatePackageTitle(event.packageName, `${chalk.cyan(event.packageName)} - ${statusText}`);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
else if (!this.isOrchestrating()) {
|
|
300
|
+
this.startSpinner(`Executing ${event.packageType} package builder...`);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
handleBuildSkipped(event) {
|
|
304
|
+
this.buildResult = {
|
|
305
|
+
success: true,
|
|
306
|
+
};
|
|
307
|
+
if (!this.isInteractive())
|
|
308
|
+
return;
|
|
309
|
+
const reasonLabels = {
|
|
310
|
+
'empty-package': 'package contains no deployable components',
|
|
311
|
+
'no-changes': 'no source changes detected',
|
|
312
|
+
};
|
|
313
|
+
const reasonLabel = reasonLabels[event.reason] ?? event.reason;
|
|
314
|
+
// Store the reason so orchestration:package:complete can use it
|
|
315
|
+
this.skippedReasons.set(event.packageName, reasonLabel);
|
|
316
|
+
const task = this.getPackageTask(event.packageName);
|
|
317
|
+
if (task) {
|
|
318
|
+
this.listr.updatePackageTitle(event.packageName, `${chalk.yellow('Skipped')} ${chalk.cyan(event.packageName)} - ${reasonLabel}`);
|
|
319
|
+
}
|
|
320
|
+
else if (!this.isOrchestrating()) {
|
|
321
|
+
// Stop any active spinner before showing the box
|
|
322
|
+
this.stopSpinner(true, chalk.yellow('Build skipped'));
|
|
323
|
+
const duration = calculateDuration(this.timings.buildStart, event.timestamp);
|
|
324
|
+
const entries = {
|
|
325
|
+
Package: chalk.cyan(event.packageName),
|
|
326
|
+
Type: event.packageType,
|
|
327
|
+
};
|
|
328
|
+
if (event.version) {
|
|
329
|
+
entries.Version = event.version;
|
|
330
|
+
}
|
|
331
|
+
if (event.latestVersion) {
|
|
332
|
+
entries['Latest Build'] = event.latestVersion;
|
|
333
|
+
}
|
|
334
|
+
if (event.sourceHash) {
|
|
335
|
+
entries['Source Hash'] = chalk.dim(event.sourceHash);
|
|
336
|
+
}
|
|
337
|
+
if (event.artifactPath) {
|
|
338
|
+
entries.Artifact = chalk.dim(event.artifactPath);
|
|
339
|
+
}
|
|
340
|
+
entries.Reason = chalk.yellow(reasonLabel.charAt(0).toUpperCase() + reasonLabel.slice(1));
|
|
341
|
+
entries.Duration = duration;
|
|
342
|
+
this.logger.log(infoBox('Build Skipped', entries));
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
handleBuildStart(event) {
|
|
346
|
+
this.timings.buildStart = event.timestamp;
|
|
347
|
+
if (!this.isInteractive())
|
|
348
|
+
return;
|
|
349
|
+
const task = this.getPackageTask(event.packageName);
|
|
350
|
+
if (task) {
|
|
351
|
+
if (this.listr.hasSubtasks(event.packageName)) {
|
|
352
|
+
this.listr.updateSentinelTitle(event.packageName, `Building (${event.packageType})...`);
|
|
353
|
+
}
|
|
354
|
+
else {
|
|
355
|
+
this.listr.updatePackageTitle(event.packageName, `${chalk.cyan(event.packageName)} - Building (${event.packageType})...`);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
else if (!this.isOrchestrating()) {
|
|
359
|
+
this.logger.log(chalk.bold(`\nBuilding package: ${chalk.cyan(event.packageName)} (${event.packageType})\n`));
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
handleConnectionComplete(event) {
|
|
363
|
+
if (!this.isInteractive())
|
|
364
|
+
return;
|
|
365
|
+
const duration = calculateDuration(this.timings.connectionStart, event.timestamp);
|
|
366
|
+
const task = this.getPackageTask(event.packageName);
|
|
367
|
+
if (task) {
|
|
368
|
+
const statusText = `Connected to ${chalk.yellow(event.username)} ${chalk.gray(`(${duration})`)}`;
|
|
369
|
+
if (this.listr.hasSubtasks(event.packageName)) {
|
|
370
|
+
this.listr.updateSentinelTitle(event.packageName, statusText);
|
|
371
|
+
}
|
|
372
|
+
else {
|
|
373
|
+
this.listr.updatePackageTitle(event.packageName, `${chalk.cyan(event.packageName)} - ${statusText}`);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
else if (!this.isOrchestrating()) {
|
|
377
|
+
this.stopSpinner(true, chalk.gray(`Successfully connected to: ${event.username} (${duration})`));
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
handleConnectionStart(event) {
|
|
381
|
+
this.timings.connectionStart = event.timestamp;
|
|
382
|
+
if (!this.isInteractive())
|
|
383
|
+
return;
|
|
384
|
+
const task = this.getPackageTask(event.packageName);
|
|
385
|
+
if (task) {
|
|
386
|
+
const statusText = `Connecting to ${event.orgType}: ${chalk.yellow(event.username)}...`;
|
|
387
|
+
if (this.listr.hasSubtasks(event.packageName)) {
|
|
388
|
+
this.listr.updateSentinelTitle(event.packageName, statusText);
|
|
389
|
+
}
|
|
390
|
+
else {
|
|
391
|
+
this.listr.updatePackageTitle(event.packageName, `${chalk.cyan(event.packageName)} - ${statusText}`);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
else if (!this.isOrchestrating()) {
|
|
395
|
+
this.startSpinner(`Connecting to ${event.orgType}: ${event.username}`);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
handleCreateComplete(event) {
|
|
399
|
+
if (!this.isInteractive())
|
|
400
|
+
return;
|
|
401
|
+
const elapsed = this.timings.createStart
|
|
402
|
+
? formatDuration(Date.now() - this.timings.createStart.getTime())
|
|
403
|
+
: '';
|
|
404
|
+
const elapsedSuffix = elapsed ? chalk.dim(` (${elapsed})`) : '';
|
|
405
|
+
const task = this.getPackageTask(event.packageName);
|
|
406
|
+
if (task) {
|
|
407
|
+
const statusText = `Created ${event.versionNumber}${elapsedSuffix}`;
|
|
408
|
+
if (this.listr.hasSubtasks(event.packageName)) {
|
|
409
|
+
this.listr.updateSentinelTitle(event.packageName, statusText);
|
|
410
|
+
}
|
|
411
|
+
else {
|
|
412
|
+
this.listr.updatePackageTitle(event.packageName, `${chalk.cyan(event.packageName)} - ${statusText}`);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
else if (!this.isOrchestrating()) {
|
|
416
|
+
this.stopSpinner(true, chalk.green(`Package ${event.packageName}@${event.versionNumber} successfully created with Id: ${event.packageVersionId}`) + elapsedSuffix);
|
|
417
|
+
// Build package details entries
|
|
418
|
+
const entries = {
|
|
419
|
+
'Package Name': event.packageName,
|
|
420
|
+
'Version ID': event.packageVersionId,
|
|
421
|
+
'Version Number': event.versionNumber,
|
|
422
|
+
};
|
|
423
|
+
if (event.packageId) {
|
|
424
|
+
entries['Package ID'] = event.packageId;
|
|
425
|
+
}
|
|
426
|
+
if (event.status) {
|
|
427
|
+
entries.Status = event.status;
|
|
428
|
+
}
|
|
429
|
+
if (event.totalNumberOfMetadataFiles !== undefined) {
|
|
430
|
+
entries['Metadata Files'] = String(event.totalNumberOfMetadataFiles);
|
|
431
|
+
}
|
|
432
|
+
if (event.codeCoverage !== null && event.codeCoverage !== undefined) {
|
|
433
|
+
const coverageColor = event.hasPassedCodeCoverageCheck ? chalk.green : chalk.yellow;
|
|
434
|
+
entries['Code Coverage'] = coverageColor(`${event.codeCoverage}%`);
|
|
435
|
+
}
|
|
436
|
+
if (event.createdDate) {
|
|
437
|
+
entries.Created = event.createdDate;
|
|
438
|
+
}
|
|
439
|
+
// Display the box
|
|
440
|
+
this.logger.log('');
|
|
441
|
+
this.logger.log(infoBox('Package Version Details', entries));
|
|
442
|
+
this.logger.log('');
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
handleCreateProgress(event) {
|
|
446
|
+
if (!this.isInteractive() || !event.message)
|
|
447
|
+
return;
|
|
448
|
+
const elapsed = this.timings.createStart
|
|
449
|
+
? formatDuration(Date.now() - this.timings.createStart.getTime())
|
|
450
|
+
: '';
|
|
451
|
+
const elapsedSuffix = elapsed ? chalk.dim(` (${elapsed})`) : '';
|
|
452
|
+
const task = this.getPackageTask(event.packageName);
|
|
453
|
+
if (task) {
|
|
454
|
+
const statusText = `Creating: ${event.message}${elapsedSuffix}`;
|
|
455
|
+
if (this.listr.hasSubtasks(event.packageName)) {
|
|
456
|
+
this.listr.updateSentinelTitle(event.packageName, statusText);
|
|
457
|
+
}
|
|
458
|
+
else {
|
|
459
|
+
this.listr.updatePackageTitle(event.packageName, `${chalk.cyan(event.packageName)} - ${statusText}`);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
else if (!this.isOrchestrating() && this.spinner) {
|
|
463
|
+
this.spinner.text = `Creating package version: ${event.message}${elapsedSuffix}`;
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
handleCreateStart(event) {
|
|
467
|
+
if (!this.isInteractive())
|
|
468
|
+
return;
|
|
469
|
+
this.timings.createStart = event.timestamp;
|
|
470
|
+
const task = this.getPackageTask(event.packageName);
|
|
471
|
+
if (task) {
|
|
472
|
+
const statusText = `Creating version ${event.versionNumber}...`;
|
|
473
|
+
if (this.listr.hasSubtasks(event.packageName)) {
|
|
474
|
+
this.listr.updateSentinelTitle(event.packageName, statusText);
|
|
475
|
+
}
|
|
476
|
+
else {
|
|
477
|
+
this.listr.updatePackageTitle(event.packageName, `${chalk.cyan(event.packageName)} - ${statusText}`);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
else if (!this.isOrchestrating()) {
|
|
481
|
+
this.startSpinner(`Creating package version ${event.packageName}@${event.versionNumber}`);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
handleOrchestrationComplete(event) {
|
|
485
|
+
this.logEvent('orchestration:complete', event);
|
|
486
|
+
if (!this.isInteractive())
|
|
487
|
+
return;
|
|
488
|
+
// Cleanup — Listr rendering is done
|
|
489
|
+
this.listr.destroy();
|
|
490
|
+
this.logger.log('');
|
|
491
|
+
const succeeded = event.results.filter(r => r.success && !r.skipped).length;
|
|
492
|
+
const failed = event.results.filter(r => !r.success && !r.skipped).length;
|
|
493
|
+
const skipped = event.results.filter(r => r.skipped).length;
|
|
494
|
+
const duration = formatDuration(event.totalDuration);
|
|
495
|
+
const entries = {
|
|
496
|
+
Succeeded: String(succeeded),
|
|
497
|
+
'Total Packages': String(event.results.length),
|
|
498
|
+
};
|
|
499
|
+
if (failed > 0)
|
|
500
|
+
entries.Failed = chalk.red(String(failed));
|
|
501
|
+
if (skipped > 0)
|
|
502
|
+
entries.Skipped = chalk.yellow(String(skipped));
|
|
503
|
+
entries.Duration = duration;
|
|
504
|
+
const allSucceeded = failed === 0;
|
|
505
|
+
const title = allSucceeded ? 'Build Orchestration Complete' : 'Build Orchestration Complete (with failures)';
|
|
506
|
+
if (allSucceeded) {
|
|
507
|
+
this.logger.log(successBox(title, entries));
|
|
508
|
+
}
|
|
509
|
+
else {
|
|
510
|
+
this.logger.log(warningBox(title, entries));
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
handleOrchestrationLevelComplete(event) {
|
|
514
|
+
this.logEvent('orchestration:level:complete', event);
|
|
515
|
+
// No cleanup needed — Listr keeps completed level tasks visible
|
|
516
|
+
// and the next level task starts automatically (sequential root).
|
|
517
|
+
}
|
|
518
|
+
handleOrchestrationLevelStart(event) {
|
|
519
|
+
this.logEvent('orchestration:level:start', event);
|
|
520
|
+
if (!this.isInteractive())
|
|
521
|
+
return;
|
|
522
|
+
this.listr.onLevelStart(event);
|
|
523
|
+
}
|
|
524
|
+
// ========================================================================
|
|
525
|
+
// Orchestration Event Handlers
|
|
526
|
+
// ========================================================================
|
|
527
|
+
handleOrchestrationPackageComplete(event) {
|
|
528
|
+
this.logEvent('orchestration:package:complete', event);
|
|
529
|
+
if (!this.isInteractive())
|
|
530
|
+
return;
|
|
531
|
+
const duration = formatDuration(event.duration);
|
|
532
|
+
if (event.skipped) {
|
|
533
|
+
const reason = this.skippedReasons.get(event.packageName);
|
|
534
|
+
const reasonSuffix = reason ? ` - ${reason}` : '';
|
|
535
|
+
this.listr.updatePackageTitle(event.packageName, `${chalk.yellow('Skipped')} ${chalk.cyan(event.packageName)}${reasonSuffix} ${chalk.gray(`(${duration})`)}`);
|
|
536
|
+
this.listr.resolvePackage(event.packageName);
|
|
537
|
+
}
|
|
538
|
+
else if (event.success) {
|
|
539
|
+
// Title may already be set by build:complete — update with duration if not
|
|
540
|
+
const task = this.getPackageTask(event.packageName);
|
|
541
|
+
if (task && !task.title?.startsWith(chalk.green('Built'))) {
|
|
542
|
+
this.listr.updatePackageTitle(event.packageName, `${chalk.green('Built')} ${chalk.cyan(event.packageName)} ${chalk.gray(`(${duration})`)}`);
|
|
543
|
+
}
|
|
544
|
+
this.listr.resolvePackage(event.packageName);
|
|
545
|
+
}
|
|
546
|
+
else {
|
|
547
|
+
const errorMsg = event.error || 'Build failed';
|
|
548
|
+
this.listr.rejectPackage(event.packageName, errorMsg);
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
handleOrchestrationStart(event) {
|
|
552
|
+
this.logEvent('orchestration:start', event);
|
|
553
|
+
if (!this.isInteractive())
|
|
554
|
+
return;
|
|
555
|
+
const levelText = event.totalLevels === 1 ? 'level' : 'levels';
|
|
556
|
+
const pkgText = event.totalPackages === 1 ? 'package' : 'packages';
|
|
557
|
+
this.logger.log(chalk.bold(`\nBuilding ${chalk.cyan(String(event.totalPackages))} ${pkgText} in ${chalk.cyan(String(event.totalLevels))} ${levelText}`));
|
|
558
|
+
if (event.includeDependencies) {
|
|
559
|
+
this.logger.log(chalk.dim(' Dependencies auto-included'));
|
|
560
|
+
}
|
|
561
|
+
this.logger.log('');
|
|
562
|
+
this.listr.start(event.totalLevels);
|
|
563
|
+
}
|
|
564
|
+
handleStageComplete(event) {
|
|
565
|
+
if (!this.isInteractive())
|
|
566
|
+
return;
|
|
567
|
+
const duration = calculateDuration(this.timings.stageStart, event.timestamp);
|
|
568
|
+
const task = this.getPackageTask(event.packageName);
|
|
569
|
+
if (task) {
|
|
570
|
+
const statusText = `Staged ${event.componentCount} components ${chalk.gray(`(${duration})`)}`;
|
|
571
|
+
if (this.listr.hasSubtasks(event.packageName)) {
|
|
572
|
+
this.listr.updateSentinelTitle(event.packageName, statusText);
|
|
573
|
+
}
|
|
574
|
+
else {
|
|
575
|
+
this.listr.updatePackageTitle(event.packageName, `${chalk.cyan(event.packageName)} - ${statusText}`);
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
else if (!this.isOrchestrating()) {
|
|
579
|
+
this.stopSpinner(true, chalk.gray(`Successfully staged ${event.packageName} with ${event.componentCount} component(s) (${duration})`));
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
handleStageStart(event) {
|
|
583
|
+
this.timings.stageStart = event.timestamp;
|
|
584
|
+
if (!this.isInteractive())
|
|
585
|
+
return;
|
|
586
|
+
const task = this.getPackageTask(event.packageName);
|
|
587
|
+
if (task) {
|
|
588
|
+
const statusText = 'Staging...';
|
|
589
|
+
if (this.listr.hasSubtasks(event.packageName)) {
|
|
590
|
+
this.listr.updateSentinelTitle(event.packageName, statusText);
|
|
591
|
+
}
|
|
592
|
+
else {
|
|
593
|
+
this.listr.updatePackageTitle(event.packageName, `${chalk.cyan(event.packageName)} - ${statusText}`);
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
else if (!this.isOrchestrating()) {
|
|
597
|
+
this.startSpinner('Staging package');
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
handleTaskComplete(event) {
|
|
601
|
+
if (!this.isInteractive())
|
|
602
|
+
return;
|
|
603
|
+
const task = this.getPackageTask(event.packageName);
|
|
604
|
+
if (task) {
|
|
605
|
+
const status = event.success ? chalk.green('✓') : chalk.red('✗');
|
|
606
|
+
const statusText = `${status} ${event.taskName}`;
|
|
607
|
+
if (this.listr.hasSubtasks(event.packageName)) {
|
|
608
|
+
this.listr.updateSentinelTitle(event.packageName, statusText);
|
|
609
|
+
}
|
|
610
|
+
else {
|
|
611
|
+
this.listr.updatePackageTitle(event.packageName, `${chalk.cyan(event.packageName)} - ${statusText}`);
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
else if (!this.isOrchestrating()) {
|
|
615
|
+
if (event.success) {
|
|
616
|
+
this.stopSpinner(true, chalk.gray(event.taskName));
|
|
617
|
+
}
|
|
618
|
+
else {
|
|
619
|
+
this.stopSpinner(false, chalk.red(`${event.taskName} failed`));
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
// ========================================================================
|
|
624
|
+
// Utility Methods
|
|
625
|
+
// ========================================================================
|
|
626
|
+
handleTaskStart(event) {
|
|
627
|
+
if (!this.isInteractive())
|
|
628
|
+
return;
|
|
629
|
+
const task = this.getPackageTask(event.packageName);
|
|
630
|
+
if (task) {
|
|
631
|
+
const statusText = `${event.taskType}: ${event.taskName}`;
|
|
632
|
+
if (this.listr.hasSubtasks(event.packageName)) {
|
|
633
|
+
this.listr.updateSentinelTitle(event.packageName, statusText);
|
|
634
|
+
}
|
|
635
|
+
else {
|
|
636
|
+
this.listr.updatePackageTitle(event.packageName, `${chalk.cyan(event.packageName)} - ${statusText}`);
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
else if (!this.isOrchestrating()) {
|
|
640
|
+
this.startSpinner(` ${chalk.cyan(event.taskType)}: ${event.taskName}`);
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
/**
|
|
644
|
+
* Check if renderer is in interactive mode
|
|
645
|
+
*/
|
|
646
|
+
isInteractive() {
|
|
647
|
+
return this.mode === 'interactive';
|
|
648
|
+
}
|
|
649
|
+
/**
|
|
650
|
+
* Check if an orchestration level is currently active.
|
|
651
|
+
* Used to prevent standalone spinner creation during orchestration —
|
|
652
|
+
* all output should flow through Listr sub-tasks instead.
|
|
653
|
+
*/
|
|
654
|
+
isOrchestrating() {
|
|
655
|
+
return this.listr.isActive();
|
|
656
|
+
}
|
|
657
|
+
logEvent(type, data) {
|
|
658
|
+
this.events.push({ data, timestamp: data.timestamp ?? new Date(), type });
|
|
659
|
+
}
|
|
660
|
+
/**
|
|
661
|
+
* Start a spinner with the given text
|
|
662
|
+
*/
|
|
663
|
+
startSpinner(text) {
|
|
664
|
+
if (this.spinner) {
|
|
665
|
+
this.spinner.stop();
|
|
666
|
+
}
|
|
667
|
+
this.spinner = ora(text).start();
|
|
668
|
+
}
|
|
669
|
+
/**
|
|
670
|
+
* Stop the active spinner
|
|
671
|
+
*/
|
|
672
|
+
stopSpinner(success, text) {
|
|
673
|
+
if (this.spinner) {
|
|
674
|
+
if (success) {
|
|
675
|
+
this.spinner.succeed(text);
|
|
676
|
+
}
|
|
677
|
+
else {
|
|
678
|
+
this.spinner.fail(text);
|
|
679
|
+
}
|
|
680
|
+
this.spinner = undefined;
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
//# sourceMappingURL=build-progress-renderer.js.map
|