UNPKG

hackages

Version:

CLI tool for learning software development concepts through test-driven development

107 lines (106 loc) 5.04 kB
import { TechnologyConfig, ExerciseFiles, LearningGoal } from "../types/index.js"; export declare function createDirectories(): void; export declare function generateImplementationTemplate(tech: string, goal: string): string; export declare function createExerciseFiles(goal: string, exerciseContent: { testContent: string; srcContent: string; }, techConfig: TechnologyConfig): ExerciseFiles; export declare function getImplementationFile(): string | null; /** * Gets the absolute path to the latest (highest numbered) exercise source file * @returns Object containing the file path and filename, or null if no files found */ export declare function getLatestSourceFilePath(): { filePath: string; fileName: string; } | null; /** * Gets the latest (highest numbered) exercise file from the src directory for code review * @returns Object containing the latest exercise file with its content, or null if no files found */ export declare function getAllSourceFiles(): { [filename: string]: string; } | null; /** * Extracts the exercise number from a filename * @param filename The filename (e.g., "exercise-3.ts", "exercise.js") * @returns The exercise number if found, or 1 as default */ export declare function getExerciseNumberFromFilename(filename: string): number; export declare function exerciseFilesExist(): boolean; /** * Elegantly displays feedback in the terminal, supporting markdown-like headers, code blocks, and lists. * @param feedback The feedback string to display */ export declare function displayFeedback(feedback: string): void; /** * Saves feedback to a markdown file in the user's ~/.hackages directory. * The file is unique per learning session (by identifier). * Code blocks in the feedback are tagged with the technology for syntax highlighting. * * @param feedback The feedback string to save * @param technology The technology name (e.g., 'typescript', 'javascript') for code block highlighting * @param identifier A unique identifier for the learning session (e.g., exercise name, timestamp, or hash) * @returns The path to the saved markdown file */ export declare function saveFeedbackToMarkdown(feedback: string, technology: string, identifier: string): string; /** * Clones a repository template for the given technology * @param techConfig Technology configuration with repository URLs * @param exerciseName Name for the exercise directory * @returns Path to the cloned repository */ export declare function cloneRepositoryTemplate(techConfig: TechnologyConfig, exerciseName: string): string; /** * Creates exercise files in a cloned repository template * @param goal Learning goal * @param exerciseContent Generated exercise content * @param techConfig Technology configuration * @param repoPath Path to the cloned repository * @returns Exercise files information */ export declare function createExerciseFilesInRepository(goal: string, exerciseContent: { testContent: string; srcContent: string; }, techConfig: TechnologyConfig, repoPath: string, exerciseNumber: number): ExerciseFiles; export declare function getLearningInformation(): LearningGoal; /** * Find the directory containing exercise files (either current directory or a subdirectory) * @returns Path to the directory containing exercise files, or current directory if not found */ export declare function findExerciseDirectory(): string; /** * Saves feedback to the template folder's feedback directory * @param feedback The feedback string to save * @param exerciseNumber The exercise number (default: 1) * @returns Path to the saved feedback file */ export declare function saveFeedbackToTemplate(feedback: string, exerciseNumber: number | undefined, selectedTech: string): string | null; /** * Opens the feedback HTML page in the default browser * @param htmlFilePath Path to the HTML file */ export declare function openFeedbackHTML(htmlFilePath: string): void; /** * Finds the next available exercise number by scanning existing exercise files * @param exerciseDir Directory containing exercise files * @param techConfig Technology configuration to determine file extensions * @returns Next available exercise number */ export declare function getNextExerciseNumber(exerciseDir: string, techConfig: TechnologyConfig): number; /** * Creates the next exercise in the same repository * @param learningGoal The learning goal for the next exercise * @param exerciseNumber The exercise number to create */ export declare function createNextExercise(learningGoal: LearningGoal, exerciseNumber: number): Promise<void>; /** * Checks if there's previous feedback available for the current exercise * @returns Array of learning suggestions if feedback exists, null otherwise */ export declare function getPreviousLearningSuggestions(): string[] | null; /** * Handles the next learning flow with prompts and exercise generation * @param suggestions Array of learning suggestions */ export declare function handleNextLearning(suggestions: string[]): Promise<void>;