diff --git a/design/prototype.ts b/design/prototype.ts index 74b9ec497..b59db3019 100644 --- a/design/prototype.ts +++ b/design/prototype.ts @@ -9,8 +9,7 @@ import fs from "fs"; import path from "path"; -const API_KEY = process.env.OPENAI_API_KEY - || JSON.parse(fs.readFileSync(path.join(process.env.HOME!, ".gstack/openai.json"), "utf-8")).api_key; +const API_KEY = process.env.OPENAI_API_KEY; if (!API_KEY) { console.error("No API key found. Set OPENAI_API_KEY or save to ~/.gstack/openai.json"); @@ -85,7 +84,8 @@ async function generateMockup(brief: { name: string; prompt: string }) { return null; } - const outputPath = path.join(OUTPUT_DIR, `${brief.name}.png`); + const safeName = brief.name.replace(/[^a-zA-Z0-9_-]/g, "_"); + const outputPath = OUTPUT_DIR + "/" + safeName + ".png"; const imageBuffer = Buffer.from(imageItem.result, "base64"); fs.writeFileSync(outputPath, imageBuffer); @@ -109,7 +109,7 @@ async function main() { const resultPath = await generateMockup(brief); results.push({ name: brief.name, path: resultPath }); } catch (err) { - console.error(`ERROR generating ${brief.name}:`, err); + console.error("ERROR generating:", brief.name, err); results.push({ name: brief.name, path: null }); } } @@ -124,7 +124,7 @@ async function main() { console.log(`${succeeded.length}/${results.length} generated successfully`); if (failed.length > 0) { - console.log(`Failed: ${failed.map(f => f.name).join(", ")}`); + console.log("Failed:", failed.map(f => f.name).join(", ")); } if (succeeded.length > 0) {