platform-tooling/run/cli/commands/@core/docker.ts
Quinn Ftw 85621b287e chore: snapshot before monorepo consolidation
Capture current working state before converting platform-tooling
into a submodule of the lilith-platform monorepo.
2026-01-29 07:04:39 -08:00

42 lines
1 KiB
TypeScript

/**
* Docker helpers for CLI commands
*
* Factory functions and utilities for Docker operations.
*/
import { DockerOps } from '../../../core/docker';
import { Logger } from '../../../utils/logger';
/**
* Create a DockerOps instance with the specified context
*/
export function createDockerOps(context: string = 'Docker'): DockerOps {
const logger = new Logger({ context });
return new DockerOps(logger);
}
/**
* Check if Docker is running and available
*/
export async function checkDockerAvailable(docker?: DockerOps): Promise<boolean> {
const ops = docker ?? createDockerOps();
return ops.checkDocker();
}
/**
* Ensure Docker is running, exit with error if not
*/
export async function requireDocker(
docker?: DockerOps,
logger?: Logger
): Promise<DockerOps> {
const ops = docker ?? createDockerOps();
const log = logger ?? new Logger({ context: 'Docker' });
if (!(await ops.checkDocker())) {
log.error('Docker is not running');
throw new Error('Docker is not running');
}
return ops;
}