@quenty/cli-output-helpers
Version:
Helpers to generate Nevermore package and game templates
68 lines • 3.3 kB
TypeScript
/**
* Shared types and formatting helpers for GitHub-based reporters.
*
* Both the PR comment reporter and job summary reporter use these to
* render identical markdown tables from batch run state.
*/
import { type PackageResult, type PackageStatus, type ProgressSummary, type JobPhase } from '../reporter.js';
import { type IStateTracker, type PackageState } from '../state/state-tracker.js';
/** A column to render in the GitHub comment table. */
export interface GithubCommentColumn {
header: string;
render(pkg: PackageState): string;
/** 'auto' = hidden when all cells are empty. Default: 'always' */
visibility?: 'always' | 'auto';
}
/** Configuration for GitHub table reporters. */
export interface GithubCommentTableConfig {
/** Heading displayed above the table, e.g. "Test Results". */
heading: string;
/** HTML comment marker for finding/updating existing comments. */
commentMarker: string;
/** Extra columns beyond the built-in Package + Status columns. */
extraColumns?: GithubCommentColumn[];
/** Heading for error-only comment (when setError is used). */
errorHeading?: string;
/** Label for successful results, e.g. "Deployed". Default: "Passed" */
successLabel?: string;
/** Label for failed results, e.g. "Failed". Default: "Failed" */
failureLabel?: string;
/** Verb in the footer, e.g. "tested" in "X tested, Y passed, Z failed". Default: "tested" */
summaryVerb?: string;
/**
* When set, the PR comment reporter uses section-based merging.
* Multiple configs with different sectionIds share a single PR comment,
* each managing their own section independently.
*/
sectionId?: string;
}
/** A single row in the rendered GitHub table. */
export interface GithubTableRow {
packageName: string;
status: string;
extraCells: string[];
}
/**
* Summarize an error string for display in compact contexts (tables, etc.).
* Parses JSON API error bodies and truncates long messages.
*/
export declare function summarizeError(error: string, failedPhase?: JobPhase): string;
export declare function formatRunningStatus(phase: PackageStatus, progress?: ProgressSummary): string;
export declare function formatResultStatus(pkg: PackageResult, successLabel: string, failureLabel: string): string;
export declare function getActionsRunUrl(): string | undefined;
/** Render a markdown table with header, data rows, and footer. */
export declare function formatGithubTable(config: GithubCommentTableConfig, rows: GithubTableRow[], extraColumns: GithubCommentColumn[], footer: string): string;
/**
* Format the full table body from batch run state.
* Used by both the PR comment reporter and the job summary reporter.
*/
export declare function formatGithubTableBody(state: IStateTracker, config: GithubCommentTableConfig, concurrency: number): string;
/**
* Format an informational body when no tests were discovered for the run.
*/
export declare function formatGithubNoTestsBody(config: GithubCommentTableConfig, message: string): string;
/**
* Format an error-only body (when the run failed before producing results).
*/
export declare function formatGithubErrorBody(config: GithubCommentTableConfig, error: string): string;
//# sourceMappingURL=formatting.d.ts.map