import fs from "fs"; import path from "path"; import { fileURLToPath } from "url"; const __dirname = path.dirname(fileURLToPath(import.meta.url)); const root = path.join(__dirname, ".."); const boldDir = path.join(root, "public/images/icons/vuesax/bold"); const iconsDir = path.join(root, "public/images/icons"); /** legacy filename -> vuesax bold filename (same folder) */ const LEGACY_MAP = { "search-normal.svg": "search-normal.svg", "candle.svg": "candle.svg", "grid-3.svg": "grid-3.svg", "sms.svg": "sms.svg", "notification.svg": "notification.svg", "send-msg.svg": "send-2.svg", "select-img.svg": "gallery-add.svg", "ruler&pen.svg": "ruler&pen.svg", "weight.svg": "weight.svg", "timer.svg": "timer.svg", "location.svg": "location.svg", "close-circle.svg": "close-circle.svg", "gallery-add.svg": "gallery-add.svg", "gallery-edit.svg": "gallery-edit.svg", "medal-star.svg": "medal-star.svg", "star1.svg": "star.svg", "woman.svg": "woman.svg", "man.svg": "man.svg", "logout.svg": "logout.svg", "copy.svg": "copy.svg", "judge.svg": "judge.svg", "danger.svg": "danger.svg", "message-text.svg": "message-text.svg", "share.svg": "share.svg", "heart.svg": "heart.svg", "sun.svg": "sun.svg", "moon.svg": "moon.svg", "edit.svg": "edit.svg", "eye.svg": "eye.svg", "add.svg": "add.svg", "submit.svg": "tick-circle.svg", "success.svg": "tick-circle.svg", "failed.svg": "close-circle.svg", "contact.svg": "call.svg", "calendar.svg": "calendar.svg", "arrow-down.svg": "arrow-down.svg", "clock.svg": "clock.svg", "verify.svg": "verify.svg", "verify2.svg": "verify.svg", "verify3.svg": "verify.svg", "not-verify.svg": "info-circle.svg", "academy.svg": "teacher.svg", "services.svg": "box.svg", "offer.svg": "ticket-star.svg", "people.svg": "people.svg", "phone.svg": "call.svg", "mobile.svg": "mobile.svg", "key.svg": "key.svg", "flash-circle.svg": "flash.svg", "shop-add.svg": "shop-add.svg", "box.svg": "box.svg", "wallet.svg": "wallet.svg", "lifebuoy.svg": "lifebuoy.svg", "teacher.svg": "teacher.svg", "courthouse.svg": "building.svg", "block-red.svg": "close-circle.svg", "block-green.svg": "tick-circle.svg", }; const CHAT_MAP = { "timer.svg": "timer.svg", "eye.svg": "eye.svg", "attachment.svg": "link.svg", "microphone-2.svg": "microphone-2.svg", "send-2.svg": "send-2.svg", "search-normal.svg": "search-normal.svg", "trash.svg": "trash.svg", "attachment-menu/camera.svg": "camera.svg", "attachment-menu/gallery.svg": "gallery.svg", "attachment-menu/video.svg": "video.svg", "attachment-menu/file.svg": "folder-2.svg", "attachment-menu/location.svg": "location.svg", }; function normalizeSvg(content, fillOverride) { let svg = content.replace(/#292D32/gi, fillOverride || "#292D32"); svg = svg.replace(/fill="#9A9A9A"/gi, `fill="${fillOverride || "#292D32"}"`); svg = svg.replace(/stroke="#9A9A9A"/gi, `stroke="${fillOverride || "#292D32"}"`); return svg; } function copyIcon(srcName, destPath, fillOverride) { const srcPath = path.join(boldDir, srcName); if (!fs.existsSync(srcPath)) { console.warn(`SKIP missing: ${srcName} -> ${destPath}`); return false; } const content = normalizeSvg(fs.readFileSync(srcPath, "utf8"), fillOverride); fs.mkdirSync(path.dirname(destPath), { recursive: true }); fs.writeFileSync(destPath, content, "utf8"); return true; } let count = 0; for (const [legacy, vuesax] of Object.entries(LEGACY_MAP)) { const dest = path.join(iconsDir, legacy); if (copyIcon(vuesax, dest)) count++; } // red heart variant copyIcon("heart.svg", path.join(iconsDir, "red-heart.svg"), "#EF4444"); // auth password eye png replacements -> svg copyIcon("eye.svg", path.join(iconsDir, "eye-open.svg")); copyIcon("eye-slash.svg", path.join(iconsDir, "eye-slash.svg")); for (const [rel, vuesax] of Object.entries(CHAT_MAP)) { const dest = path.join(iconsDir, "chat", rel); if (copyIcon(vuesax, dest)) count++; } console.log(`Synced ${count} icon files to legacy paths.`);