UNPKG

@hashgraph/solo

Version:

An opinionated CLI tool to deploy and manage private Hedera Networks.

85 lines (84 loc) 4.05 kB
import { type SpawnSyncReturns } from 'node:child_process'; import { type SoloLogger } from '../../core/logging/solo-logger.js'; /** Options for building a GitHub issue body from diagnostic information. */ export type DiagnosticsIssueBodyOptions = { soloVersion: string; deployment: string; timestamp: string; /** Directory where diagnostics-analysis.txt was written by DiagnosticsAnalyzer. */ analysisDirectory: string; /** Absolute path to the debug zip archive, if one was created. */ zipFilePath?: string; }; export type DiagnosticsReportRunOptions = { logger: SoloLogger; deployment: string; outputDirectory: string; soloVersion: string; isQuiet: boolean; collectDebug: () => Promise<void>; }; /** * Utility class for the `deployment diagnostics report` command. * Handles gh CLI availability checks, issue body assembly, and issue creation. */ export declare class DiagnosticsReporter { /** * Orchestrates `deployment diagnostics report` flow: * 1) collect debug archive, 2) build issue payload, 3) optionally prompt, 4) create GitHub issue. */ static runDiagnosticsReport(options: DiagnosticsReportRunOptions): Promise<void>; /** * Checks whether the GitHub CLI (`gh`) is available on the system PATH. * @returns true if `gh` is installed and reachable, false otherwise */ static isGhCliAvailable(logger: SoloLogger): Promise<boolean>; /** * Searches for the most recently modified debug zip archive that was created * at or after `afterTimestampMs` in the given directory. * * The `deployment diagnostics debug` command writes files named * `solo-debug-<deployment>-<timestamp>.zip` one level above the logs directory. * * @param searchDirectory Directory to search (typically `~/.solo`). * @param deployment Deployment name used as part of the filename prefix. * @param afterTimestampMs Milliseconds epoch; only files modified at or after * this time are considered. * @returns The absolute path to the found zip, or `undefined` if none matched. */ static findLatestDebugZip(searchDirectory: string, deployment: string, afterTimestampMs: number): string | undefined; /** * Reads the diagnostics-analysis.txt file from the logs directory, if present. * @param logsDirectory Directory where the analysis file is expected. * @returns File contents, or an empty string if the file does not exist. */ static readAnalysisContent(logsDirectory: string): string; /** * Assembles the Markdown body for a GitHub issue from the provided diagnostic * information. */ static buildIssueBody(options: DiagnosticsIssueBodyOptions): string; /** * Executes `gh issue create` with the provided args using `spawnSync` (without a shell) * so that space-containing arguments such as the issue title are passed verbatim. * * Extracted as a public static method so that unit tests can stub it without invoking * the real `gh` CLI. * * @param arguments_ Arguments to pass to the `gh` CLI. * @returns The `SpawnSyncReturns` result from the `gh` process. */ static executeGhCommand(arguments_: string[]): SpawnSyncReturns<string>; /** * Creates a GitHub issue using the `gh` CLI with the supplied title and body. * If a zip archive path is provided, the user is reminded to attach it manually * since the GitHub Issues API does not support binary attachments. * * @param logger Logger for user-facing output. * @param title Issue title. * @param body Issue body in Markdown. * @param zipFilePath Optional path to the debug zip archive to mention. * @returns The URL of the newly created issue, or an empty string if not found. */ static createGitHubIssue(logger: SoloLogger, title: string, body: string, analysisDirectory: string, zipFilePath?: string): Promise<string>; }