UNPKG

docker-pilot

Version:

A powerful, scalable Docker CLI library for managing containerized applications of any size

194 lines 5.46 kB
/** * File system utility functions * Provides file and directory operations with error handling */ import * as fs from 'fs-extra'; import * as yaml from 'yaml'; import { Logger } from './Logger'; export interface FileInfo { path: string; name: string; extension: string; size: number; isDirectory: boolean; isFile: boolean; created: Date; modified: Date; accessed: Date; } export interface DirectoryInfo { path: string; name: string; files: FileInfo[]; directories: DirectoryInfo[]; totalFiles: number; totalSize: number; } export declare class FileUtils { private logger; constructor(logger?: Logger); /** * Check if path exists */ exists(filePath: string): Promise<boolean>; /** * Read file content */ readFile(filePath: string, encoding?: BufferEncoding): Promise<string>; /** * Write file content */ writeFile(filePath: string, content: string, encoding?: BufferEncoding): Promise<void>; /** * Append to file */ appendFile(filePath: string, content: string, encoding?: BufferEncoding): Promise<void>; /** * Read JSON file */ readJson<T = any>(filePath: string): Promise<T>; /** * Write JSON file */ writeJson(filePath: string, data: any, options?: { spaces?: number; }): Promise<void>; /** * Read YAML file */ readYaml<T = any>(filePath: string): Promise<T>; /** * Write YAML file */ writeYaml(filePath: string, data: any, options?: yaml.ToStringOptions): Promise<void>; /** * Ensure directory exists */ ensureDir(dirPath: string): Promise<void>; /** * Remove file or directory */ remove(targetPath: string): Promise<void>; /** * Copy file or directory */ copy(src: string, dest: string, options?: fs.CopyOptions): Promise<void>; /** * Move file or directory */ move(src: string, dest: string): Promise<void>; /** * Get file information */ getFileInfo(filePath: string): Promise<FileInfo>; /** * List directory contents */ listDirectory(dirPath: string, recursive?: boolean): Promise<string[]>; /** * Get directory information with detailed file info */ getDirectoryInfo(dirPath: string): Promise<DirectoryInfo>; /** * Find files by pattern */ findFiles(pattern: string, options?: { cwd?: string; ignore?: string[]; }): Promise<string[]>; /** * Find Docker-related files */ findDockerFiles(baseDir?: string): Promise<{ dockerfiles: string[]; composeFiles: string[]; dockerignore: string[]; }>; /** * Find Docker Compose files recursively with enhanced search */ findDockerComposeFiles(startDir?: string, options?: { maxDepth?: number; includeVariants?: boolean; skipDirectories?: string[]; }): Promise<string[]>; /** * Check if directory should be skipped during Docker Compose search */ private shouldSkipDirectory; /** * Find all Docker Compose files with detailed information and enhanced search */ findDockerComposeFilesWithInfo(startDir?: string, options?: { maxDepth?: number; includeVariants?: boolean; skipDirectories?: string[]; includeEmptyFiles?: boolean; }): Promise<Array<{ path: string; relativePath: string; filename: string; directory: string; size: number; modified: Date; hasServices: boolean; serviceCount: number; services: string[]; depth: number; environment?: string | undefined; isMainFile: boolean; priority: number; }>>; /** * Extract environment type from compose filename */ private extractEnvironmentFromFilename; /** * Check if filename is a main compose file (not an environment variant) */ private isMainComposeFile; /** * Check if file is empty */ isEmpty(filePath: string): Promise<boolean>; /** * Get file size in human readable format */ formatFileSize(bytes: number): string; /** * Watch file or directory for changes */ watchPath(targetPath: string, callback: (eventType: string, filename: string | null) => void): fs.FSWatcher; /** * Create backup of file (maintains only one backup) */ backupFile(filePath: string, backupDir?: string): Promise<string>; /** * Clean old backup files with timestamp pattern */ cleanOldBackups(directory: string, pattern?: string): Promise<void>; /** * Clean directory (remove all contents) */ cleanDirectory(dirPath: string): Promise<void>; /** * Get temporary file path */ getTempPath(prefix?: string, extension?: string): string; /** * Resolve path relative to current working directory */ resolvePath(inputPath: string, basePath?: string): string; /** * Check if path is within base directory (security check) */ isPathSafe(targetPath: string, basePath: string): boolean; /** * Get relative path from base */ getRelativePath(targetPath: string, basePath?: string): string; /** * Normalize path separators */ normalizePath(inputPath: string): string; } //# sourceMappingURL=FileUtils.d.ts.map