UNPKG

codemodctl

Version:

CLI tool and utilities for workflow engine operations, file sharding, and codeowner analysis

72 lines 2.83 kB
//#region src/utils/directory-analysis.d.ts /** * Result for a single directory-based shard */ interface DirectoryShardResult { /** The directory path this shard belongs to */ directory: string; /** The shard number (1-based) within this directory */ shard: number; /** Total number of shards for this directory */ shardCount: number; /** Array of file paths in this shard */ _meta_files: string[]; /** The name of the shard */ name: string; } /** * Options for directory-based analysis */ interface DirectoryAnalysisOptions { /** Target number of files per shard */ shardSize: number; /** Target directory to analyze subdirectories within */ target: string; /** Path to the codemod rule file */ rulePath: string; /** Programming language for the codemod */ language: string; /** Project root directory (defaults to process.cwd()) */ projectRoot?: string; /** Existing state for consistency (optional) */ existingState?: DirectoryShardResult[]; } /** * Result of directory-based analysis */ interface DirectoryAnalysisResult { /** Array of directory-based shards */ shards: DirectoryShardResult[]; /** Total number of files processed */ totalFiles: number; } /** * Groups files by their immediate subdirectory within the target directory * * @param files - Array of file paths to group * @param target - Target directory to analyze subdirectories within * @param projectRoot - Root directory of the project for resolving relative paths * @returns Map of subdirectory paths to their file lists */ declare function groupFilesByDirectory(files: string[], target: string, projectRoot: string): Map<string, string[]>; /** * Creates directory-based shards using consistent hashing within each directory group. * Maintains consistency with existing state when provided. * * @param filesByDirectory - Map of directory paths to their file lists * @param shardSize - Target number of files per shard * @param existingState - Optional existing state for consistency * @returns Array of directory-based shards */ declare function createDirectoryShards(filesByDirectory: Map<string, string[]>, shardSize: number, existingState?: DirectoryShardResult[]): DirectoryShardResult[]; /** * Main function to analyze directories and generate shard configuration. * Maintains consistency with existing state when provided. * * @param options - Configuration options for directory analysis * @returns Promise resolving to directory analysis result * @throws Error if no files found in target subdirectories */ declare function analyzeDirectories(options: DirectoryAnalysisOptions): Promise<DirectoryAnalysisResult>; //#endregion export { DirectoryAnalysisOptions, DirectoryAnalysisResult, DirectoryShardResult, analyzeDirectories, createDirectoryShards, groupFilesByDirectory };