codemodctl
Version:
CLI tool and utilities for workflow engine operations, file sharding, and codeowner analysis
95 lines • 3.63 kB
TypeScript
//#region src/utils/codeowner-analysis.d.ts
/**
* Result for a single team-based shard
*/
interface ShardResult {
/** The team that owns these files */
team: string;
/** The shard identifier string (e.g., "1/3") */
shard: string;
/** The combined shard ID (e.g., "team-name 1/3") */
shardId: string;
/** Array of file paths in this shard */
_meta_files: string[];
}
/**
* Information about a team and their files
*/
interface TeamFileInfo {
/** Team name */
team: string;
/** Number of files owned by this team */
fileCount: number;
/** Array of file paths owned by this team */
files: string[];
}
/**
* Options for codeowner-based analysis
*/
interface CodeownerAnalysisOptions {
/** Target number of files per shard */
shardSize: number;
/** Optional path to CODEOWNERS file */
codeownersPath?: 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?: ShardResult[];
}
/**
* Result of codeowner-based analysis
*/
interface CodeownerAnalysisResult {
/** Array of team information */
teams: TeamFileInfo[];
/** Array of team-based shards with file assignments */
shards: ShardResult[];
/** Total number of files processed */
totalFiles: number;
}
/**
* Finds and resolves the CODEOWNERS file path
* Searches in common locations: root, .github/, docs/
* Returns null if no CODEOWNERS file is found
*/
declare function findCodeownersFile(projectRoot?: string, explicitPath?: string): Promise<string | null>;
/**
* Normalizes owner name by removing `@` prefix and converting to lowercase
*/
declare function normalizeOwnerName(owner: string): string;
/**
* Analyzes files and groups them by codeowner team
*/
declare function analyzeFilesByOwner(codeownersPath: string, language: string, rulePath: string, projectRoot?: string): Promise<Map<string, string[]>>;
/**
* Analyzes files without codeowner parsing - assigns all files to "unassigned"
*/
declare function analyzeFilesWithoutOwner(language: string, rulePath: string, projectRoot?: string): Promise<Map<string, string[]>>;
/**
* Generates shard configuration from team file analysis with actual file distribution.
* Maintains consistency with existing state when provided.
*
* @param filesByOwner - Map of team names to their file arrays
* @param shardSize - Target number of files per shard
* @param existingState - Optional existing state for consistency
* @returns Array of team-based shards with file assignments
*/
declare function generateShards(filesByOwner: Map<string, string[]>, shardSize: number, existingState?: ShardResult[]): ShardResult[];
/**
* Converts file ownership map to team info array
*/
declare function getTeamFileInfo(filesByOwner: Map<string, string[]>): TeamFileInfo[];
/**
* Main function to analyze codeowners and generate shard configuration.
* Maintains consistency with existing state when provided.
*
* @param options - Configuration options for codeowner analysis
* @returns Promise resolving to codeowner analysis result
*/
declare function analyzeCodeowners(options: CodeownerAnalysisOptions): Promise<CodeownerAnalysisResult>;
//#endregion
export { analyzeCodeowners as a, findCodeownersFile as c, normalizeOwnerName as d, TeamFileInfo as i, generateShards as l, CodeownerAnalysisResult as n, analyzeFilesByOwner as o, ShardResult as r, analyzeFilesWithoutOwner as s, CodeownerAnalysisOptions as t, getTeamFileInfo as u };