Remove unused loadRecipe function (#4599)
This commit is contained in:
@@ -51,37 +51,6 @@ function getRecipeFilePath(recipeName: string, isGlobal: boolean): string {
|
|||||||
return `${dir}/${recipeName}.yaml`;
|
return `${dir}/${recipeName}.yaml`;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Load recipe from file
|
|
||||||
*/
|
|
||||||
async function loadRecipeFromFile(
|
|
||||||
recipeName: string,
|
|
||||||
isGlobal: boolean
|
|
||||||
): Promise<SavedRecipe | null> {
|
|
||||||
const filePath = getRecipeFilePath(recipeName, isGlobal);
|
|
||||||
|
|
||||||
try {
|
|
||||||
const result = await window.electron.readFile(filePath);
|
|
||||||
if (!result.found || result.error) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const recipeData = yaml.parse(result.file) as SavedRecipe;
|
|
||||||
|
|
||||||
// Convert lastModified string to Date if needed
|
|
||||||
recipeData.lastModified = parseLastModified(recipeData.lastModified);
|
|
||||||
|
|
||||||
return {
|
|
||||||
...recipeData,
|
|
||||||
isGlobal: isGlobal,
|
|
||||||
filename: recipeName,
|
|
||||||
};
|
|
||||||
} catch (error) {
|
|
||||||
console.warn(`Failed to load recipe from ${filePath}:`, error);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save recipe to file
|
* Save recipe to file
|
||||||
*/
|
*/
|
||||||
@@ -144,34 +113,6 @@ export async function saveRecipe(recipe: Recipe, options: SaveRecipeOptions): Pr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Load a recipe by name from file.
|
|
||||||
*/
|
|
||||||
export async function loadRecipe(recipeName: string, isGlobal: boolean): Promise<Recipe> {
|
|
||||||
try {
|
|
||||||
const savedRecipe = await loadRecipeFromFile(recipeName, isGlobal);
|
|
||||||
|
|
||||||
if (!savedRecipe) {
|
|
||||||
throw new Error('Recipe not found');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validate the loaded recipe has required fields
|
|
||||||
if (!savedRecipe.recipe.title || !savedRecipe.recipe.description) {
|
|
||||||
throw new Error('Loaded recipe is missing required fields');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!savedRecipe.recipe.instructions && !savedRecipe.recipe.prompt) {
|
|
||||||
throw new Error('Loaded recipe must have either instructions or prompt');
|
|
||||||
}
|
|
||||||
|
|
||||||
return savedRecipe.recipe;
|
|
||||||
} catch (error) {
|
|
||||||
throw new Error(
|
|
||||||
`Failed to load recipe: ${error instanceof Error ? error.message : 'Unknown error'}`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function listSavedRecipes(): Promise<RecipeManifestResponse[]> {
|
export async function listSavedRecipes(): Promise<RecipeManifestResponse[]> {
|
||||||
try {
|
try {
|
||||||
const listRecipeResponse = await listRecipes();
|
const listRecipeResponse = await listRecipes();
|
||||||
|
|||||||
Reference in New Issue
Block a user