import type { PathLike } from 'node:fs'; /** * Attempts to read a file from multiple sources and returns the contents * of the first matching one. `null` is returned when file does not * exist in any of the sources. * * @param fileName - The name of the file to search for * @param sources - Array of directory paths to search in * @returns Promise resolving to file info object or null if not found * * @example * const result = await readFileFromSources('config.ts', ['./config', './defaults']) * if (result) { * console.log(result.contents) // File contents * console.log(result.filePath) // Full path to found file * console.log(result.source) // Source directory where file was found * } */ export declare function readFileFromSources(fileName: string, sources: string[]): Promise<{ contents: string; filePath: string; fileName: string; source: string; } | null>; /** * Optionally read the contents of a file. * Returns null if the file doesn't exist instead of throwing an error. * * @param filePath - The path to the file to read (URL or string) * @returns Promise resolving to file contents or null if file doesn't exist * * @example * const content = await readFileOptional('./optional-config.ts') * if (content) { * console.log('Config found:', content) * } else { * console.log('Using default config') * } */ export declare function readFileOptional(filePath: URL | string): Promise; /** * Check if a file or directory exists at the given path. * This is a safe wrapper around fs.access that returns a boolean. * * @param path - The path to check for existence * @returns Promise resolving to true if path exists, false otherwise * * @example * if (await pathExists('./config.ts')) { * console.log('Config file exists') * } */ export declare function pathExists(path: PathLike): Promise; /** * Parses exports from a stub file by extracting metadata between * and markers. * These exports contain configuration for stub generation. * * @param contents - The stub file contents to parse * @returns Object containing parsed attributes and cleaned body content * * @example * const stub = ` * // Some template code * {"to": "./app/models/user.ts"} * export class {{ name }} {} * ` * const result = parseStubExports(stub) * // result.attributes = { to: './app/models/user.ts' } * // result.body = cleaned template without export markers */ export declare function parseStubExports(contents: string): { attributes: Record; body: string; };