MCPcopy Create free account
hub / github.com/afar1/fieldtheory-cli / formatWorkflowState

Function formatWorkflowState

src/workflow-state.ts:322–360  ·  view source on GitHub ↗
(state: WorkflowState)

Source from the content-addressed store, hash-verified

320}
321
322export function formatWorkflowState(state: WorkflowState): string {
323 const headers = ['Active', 'Plain English', 'Included In Root', 'In Origin?', 'State', 'Next'];
324 const widths = headers.map((header, index) => Math.max(
325 header.length,
326 ...state.rows.map((row) => [row.active, row.plainEnglish, row.includedInRoot, row.inOrigin, row.state, row.next][index].length),
327 ));
328
329 const lines = ['FT state', ''];
330 lines.push(`| ${headers.map((header, index) => pad(header, widths[index])).join(' | ')} |`);
331 lines.push(`| ${widths.map((width) => '-'.repeat(width)).join(' | ')} |`);
332 for (const row of state.rows) {
333 lines.push(`| ${[
334 row.active,
335 row.plainEnglish,
336 row.includedInRoot,
337 row.inOrigin,
338 row.state,
339 row.next,
340 ].map((value, index) => pad(value, widths[index])).join(' | ')} |`);
341 }
342
343 lines.push('');
344 if (state.openPullRequests.length === 0) {
345 lines.push('Open PRs: none');
346 } else {
347 lines.push('Open PRs (merge sequentially):', '');
348 state.openPullRequests.forEach((pr, index) => {
349 const conflict = pr.mergeStateStatus === 'DIRTY' ? 'conflicts' : 'no conflicts';
350 const draft = pr.isDraft ? 'draft, ' : '';
351 lines.push(`${index + 1}. ${pr.title} - ${pr.url} - ${draft}${conflict}`);
352 });
353 }
354
355 lines.push('', `Verdict: ${state.verdict}.`, state.summary);
356 if (state.root && !fs.existsSync(path.join(state.root, '.git'))) {
357 lines.push(`Repo root: ${state.root}`);
358 }
359 return `${lines.join('\n')}\n`;
360}

Callers 1

buildCliFunction · 0.85

Calls 1

padFunction · 0.85

Tested by

no test coverage detected