Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 50 additions & 3 deletions src/diagnostics/docker.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
classifyCommandResult,
runCommand,
type CommandOutcome,
type RunCommand,
} from './process.js';
import type {
Expand All @@ -23,6 +24,27 @@ function parseDockerVersion(output: string): string | null {
return match?.[1] ?? null;
}

function timeoutMessage(required: boolean): string {
return required
? 'Docker is required but the Docker CLI timed out.'
: 'Docker CLI timed out; container-based workflows may be unavailable.';
}

function timeoutRemediation(): string {
return 'Check that `docker --version` responds promptly and retry the diagnostic.';
}

function classifiedMessage(outcome: CommandOutcome): string {
switch (outcome) {
case 'missing-executable':
return 'Docker CLI is not available; container-based workflows may be unavailable.';
case 'timed-out':
return timeoutMessage(false);
default:
return 'Docker CLI could not be executed; container-based workflows may be unavailable.';
}
}

export function createDockerDiagnostic(
options: DockerDiagnosticOptions = {},
): DiagnosticCheck {
Expand All @@ -34,15 +56,26 @@ export function createDockerDiagnostic(
label: 'Docker',
run(): DiagnosticResult {
const client = execute('docker', ['--version']);
const clientOutcome = classifyCommandResult(client);

if (clientOutcome === 'timed-out') {
return {
id: 'docker',
label: 'Docker',
status: unavailableStatus(required),
message: timeoutMessage(required),
remediation: timeoutRemediation(),
};
}

if (classifyCommandResult(client) !== 'ok') {
if (clientOutcome !== 'ok') {
return {
id: 'docker',
label: 'Docker',
status: unavailableStatus(required),
message: required
? 'Docker is required but the Docker CLI is unavailable.'
: 'Docker CLI is not available; container-based workflows may be unavailable.',
: classifiedMessage(clientOutcome),
remediation:
'Install Docker and ensure `docker` is available on PATH if your selected workflow requires containers.',
};
Expand All @@ -66,8 +99,22 @@ export function createDockerDiagnostic(
'--format',
'{{.ServerVersion}}',
]);
const daemonOutcome = classifyCommandResult(daemon);

if (daemonOutcome === 'timed-out') {
return {
id: 'docker',
label: 'Docker',
status: unavailableStatus(required),
message: required
? `Docker ${version} is installed, but the Docker daemon timed out.`
: `Docker ${version} is installed, but the daemon timed out; container-based workflows may not run.`,
remediation:
'Check that `docker info` responds promptly and retry the diagnostic.',
};
}

if (daemon.error || daemon.status !== 0 || daemon.stdout.trim() === '') {
if (daemonOutcome !== 'ok' || daemon.stdout.trim() === '') {
return {
id: 'docker',
label: 'Docker',
Expand Down
16 changes: 14 additions & 2 deletions src/diagnostics/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,20 @@ export function createGitDiagnostic(
label: 'Git',
run(): DiagnosticResult {
const result = execute('git', ['--version']);
const outcome = classifyCommandResult(result);

if (classifyCommandResult(result) !== 'ok') {
if (outcome === 'timeout') {
return {
id: 'git',
label: 'Git',
status: 'fail',
message: 'Git timed out while reporting its version.',
remediation:
'Check that `git --version` responds promptly and retry the diagnostic.',
};
}

if (outcome !== 'ok') {
return {
id: 'git',
label: 'Git',
Expand All @@ -36,7 +48,7 @@ export function createGitDiagnostic(
id: 'git',
label: 'Git',
status: 'fail',
message: 'Git returned an unrecognized version.',
message: 'Git returned an unecognized version.',
remediation:
'Verify `git --version` works and reinstall Git if necessary.',
};
Expand Down
28 changes: 26 additions & 2 deletions src/diagnostics/rust.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,20 @@ export function createRustDiagnostic(
label: 'Rust',
run(): DiagnosticResult {
const result = execute('rustc', ['--version']);
const outcome = classifyCommandResult(result);

if (classifyCommandResult(result) !== 'ok') {
if (outcome === 'timed-out') {
return {
id: 'rust',
label: 'Rust',
status: 'fail',
message: 'Rust timed out while reporting its version.',
remediation:
'Check that `rustc --version` responds promptly and retry the diagnostic.',
};
}

if (outcome !== 'ok') {
return {
id: 'rust',
label: 'Rust',
Expand Down Expand Up @@ -81,8 +93,20 @@ export function createCargoDiagnostic(
label: 'Cargo',
run(): DiagnosticResult {
const result = execute('cargo', ['--version']);
const outcome = classifyCommandResult(result);

if (outcome === 'timed-out') {
return {
id: 'cargo',
label: 'Cargo',
status: 'fail',
message: 'Cargo timed out while reporting its version.',
remediation:
'Check that `cargo --version` responds promptly and retry the diagnostic.',
};
}

if (classifyCommandResult(result) !== 'ok') {
if (outcome !== 'ok') {
return {
id: 'cargo',
label: 'Cargo',
Expand Down