Files
Charon/frontend/src/hooks/useDocker.ts
GitHub Actions 0cd93ceb79 fix(frontend): remove test types from base tsconfig for CI build
The base tsconfig.json had types: ["vitest/globals", "@testing-library/jest-dom/vitest"]
which are devDependencies only installed during development. CI production
builds with npm ci --production don't include these, causing TS2688 errors.

Solution:

Remove types array from tsconfig.json (let TS auto-discover available types)
Simplify tsconfig.build.json to only exclude test files
Add triple-slash type references to test setup file
Add typecheck config to vitest.config.ts
This ensures:

Production builds work without devDependencies
Test files still have proper type definitions
No JSX.IntrinsicElements errors from missing React types
2026-01-25 21:26:47 +00:00

37 lines
1.1 KiB
TypeScript

import { useQuery } from '@tanstack/react-query'
import { dockerApi } from '../api/docker'
export function useDocker(host?: string | null, serverId?: string | null) {
const {
data: containers = [],
isLoading,
error,
refetch,
} = useQuery({
queryKey: ['docker-containers', host, serverId],
queryFn: async () => {
try {
return await dockerApi.listContainers(host || undefined, serverId || undefined)
} catch (err: unknown) {
// Extract helpful error message from response
const error = err as { response?: { status?: number; data?: { details?: string } } }
if (error.response?.status === 503) {
const details = error.response?.data?.details
const message = details || 'Docker service unavailable. Check that Docker is running.'
throw new Error(message)
}
throw err
}
},
enabled: Boolean(host) || Boolean(serverId),
retry: 1, // Don't retry too much if docker is not available
})
return {
containers,
isLoading,
error,
refetch,
}
}