From 0756bf12d10cf1b7f78c571de0a9ad69cbaeb7ca Mon Sep 17 00:00:00 2001
From: curtis <curtis@i-mps.com>
Date: 星期一, 30 三月 2026 14:24:17 +0800
Subject: [PATCH] fix: 更新內部引用方法參照
---
scripts/batch_dfm_to_web.js | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 52 insertions(+), 0 deletions(-)
diff --git a/scripts/batch_dfm_to_web.js b/scripts/batch_dfm_to_web.js
new file mode 100644
index 0000000..1e1a5dd
--- /dev/null
+++ b/scripts/batch_dfm_to_web.js
@@ -0,0 +1,52 @@
+const fs = require('fs');
+const path = require('path');
+
+// 讀取設定檔與樣板
+const configPath = path.join(__dirname, '../doc/curtis/prompt/dfm_to_web/dfm_to_web_requirement.json');
+const templatePath = path.join(__dirname, '../doc/curtis/prompt/dfm_to_web/dfm_to_web_prompt_template.md');
+
+const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
+const template = fs.readFileSync(templatePath, 'utf8');
+
+// 產生每個檔案的專屬 prompt
+const outputDir = path.join(__dirname, '../doc/curtis/prompt/dfm_to_web');
+if (!fs.existsSync(outputDir)) {
+ fs.mkdirSync(outputDir, { recursive: true });
+}
+
+console.log('Generating individual prompts based on requirement.json...');
+
+config.forEach(item => {
+ // 從路徑中萃取檔名
+ const dfm_filename = path.basename(item.dfm);
+ const pas_filename = path.basename(item.pas);
+ const png_filename = path.basename(item.png);
+ const vue_filename = path.basename(item.vue);
+ const ts_filename = path.basename(item.ts);
+
+ // 取得元件名稱 (不含副檔名)
+ const componentName = path.parse(item.vue).name;
+
+ // 取代樣板中的佔位符
+ let promptContent = template
+ .replace(/\{\{dfm\}\}/g, item.dfm)
+ .replace(/\{\{pas\}\}/g, item.pas)
+ .replace(/\{\{png\}\}/g, item.png)
+ .replace(/\{\{vue\}\}/g, item.vue)
+ .replace(/\{\{ts\}\}/g, item.ts)
+ .replace(/\{\{dfm_filename\}\}/g, dfm_filename)
+ .replace(/\{\{pas_filename\}\}/g, pas_filename)
+ .replace(/\{\{png_filename\}\}/g, png_filename)
+ .replace(/\{\{vue_filename\}\}/g, vue_filename)
+ .replace(/\{\{ts_filename\}\}/g, ts_filename);
+
+ // 寫入專屬的 prompt 檔案
+ const promptFilePath = path.join(outputDir, `dfm_to_web_prompt_${componentName}.md`);
+ fs.writeFileSync(promptFilePath, promptContent, 'utf8');
+
+ console.log(`Created: ${promptFilePath}`);
+});
+
+console.log('\n--- Usage ---');
+console.log('You can now ask the AI:');
+console.log('"Please execute the conversion based on the requirements in @/doc/curtis/prompt/dfm_to_web/generated_prompts/prompt_PatchFom.md"');
--
Gitblit v1.8.0