UNPKG

ctrlshiftleft

Version:

AI-powered toolkit for embedding QA and security testing into development workflows

167 lines (166 loc) 5.64 kB
/** * Platform Utilities * * Utilities for cross-platform compatibility to ensure consistent behavior * across different operating systems (Windows, macOS, Linux). */ /** * Line ending types for file generation */ export type LineEnding = 'auto' | 'lf' | 'crlf'; /** * Line ending characters by type */ export declare const LINE_ENDINGS: { lf: string; crlf: string; auto: string; }; /** * Cross-platform file path separator functions */ export declare class PathUtils { /** * Normalize path separators for the current platform * @param filePath File path to normalize * @returns Normalized path */ static normalizePath(filePath: string): string; /** * Ensure a path uses forward slashes (useful for URL or config paths) * @param filePath File path to normalize * @returns Path with forward slashes */ static forwardSlashes(filePath: string): string; /** * Convert a path to an absolute path, handling both relative and absolute inputs * @param filePath File path to resolve * @param basePath Base path for resolving relative paths (defaults to current directory) * @returns Absolute path */ static toAbsolutePath(filePath: string, basePath?: string): string; /** * Get a relative path from one location to another, handling cross-platform differences * @param from Source path * @param to Destination path * @returns Relative path */ static getRelativePath(from: string, to: string): string; /** * Ensure a directory exists, creating it if necessary * @param dirPath Directory path to ensure * @returns True if directory exists or was created */ static ensureDir(dirPath: string): boolean; /** * Get a platform-appropriate temporary directory path * @param subdir Optional subdirectory name * @returns Path to temporary directory */ static getTempDir(subdir?: string): string; /** * Determine if a path exists and is a directory * @param dirPath Path to check * @returns True if path is a directory */ static isDirectory(dirPath: string): boolean; /** * Determine if a path exists and is a file * @param filePath Path to check * @returns True if path is a file */ static isFile(filePath: string): boolean; } /** * Cross-platform file content utilities */ export declare class FileUtils { /** * Ensure file content has consistent line endings * @param content File content to normalize * @param lineEnding Line ending type to use * @returns Normalized content */ static normalizeLineEndings(content: string, lineEnding?: LineEnding): string; /** * Write file with consistent line endings * @param filePath Path to write to * @param content Content to write * @param lineEnding Line ending type to use * @returns True if successful */ static writeFile(filePath: string, content: string, lineEnding?: LineEnding): boolean; /** * Read file and normalize line endings * @param filePath Path to read from * @param lineEnding Line ending type to use * @returns File content or null if error */ static readFile(filePath: string, lineEnding?: LineEnding): string | null; /** * Append to file with consistent line endings * @param filePath Path to append to * @param content Content to append * @param lineEnding Line ending type to use * @returns True if successful */ static appendFile(filePath: string, content: string, lineEnding?: LineEnding): boolean; } /** * Cross-platform test output generator */ export declare class TestOutputUtils { /** * Generate a platform-appropriate path for test outputs * @param componentPath Path to component being tested * @param outputBase Base directory for output * @param fileExtension File extension for output file * @returns Path to test output file */ static getTestOutputPath(componentPath: string, outputBase?: string, fileExtension?: string): string; /** * Generate configuration file with platform-appropriate paths * @param configType Type of configuration (playwright, jest) * @param outputDir Output directory * @param lineEnding Line ending type to use * @returns Generated configuration content */ static generateTestConfig(configType: 'playwright' | 'jest', outputDir: string, lineEnding?: LineEnding): string; } /** * Cross-platform shell command utilities */ export declare class ShellUtils { /** * Get platform-appropriate shell command * @param command Base command * @param args Command arguments * @returns Platform-specific command string */ static getCommand(command: string, args?: string[]): string; /** * Get platform-appropriate file path for a command * @param filePath File path to use in command * @returns Formatted file path string */ static getCommandPath(filePath: string): string; /** * Get platform-appropriate npm script command * @param scriptName NPM script name * @param args Script arguments * @returns Platform-specific npm command string */ static getNpmCommand(scriptName: string, args?: string[]): string; } /** * Detect the operating system and provide platform information */ export declare function getPlatformInfo(): { platform: string; isWindows: boolean; isMac: boolean; isLinux: boolean; arch: string; pathSeparator: string; lineEnding: string; };