// Link existing client folders to their Facebook Page / Instagram account (client.json), // and to their Odoo " - Social Media Handling" project when one exists. import { autoLink, listClients, saveLink } from "../clients.js"; import * as odoo from "../odoo.js"; const results = await autoLink(); for (const r of results) console.log(r.page ? `linked ${r.slug} → ${r.page}${r.ig ? ` (@${r.ig})` : ""}` : `no match ${r.slug} (link it from the dashboard)`); if (odoo.configured()) { const projects = await odoo.projects(); const norm = (s) => s.toLowerCase().replace(/[^a-z0-9]/g, ""); for (const c of listClients()) { if (c.odooProject) continue; const key = norm(c.name); const match = projects.find((p) => norm(p.name).startsWith(key) && /social media/i.test(p.name)) || projects.find((p) => norm(p.name) === key) || projects.find((p) => norm(p.name).startsWith(key)); if (match) { saveLink(c.slug, { odooProject: { id: match.id, name: match.name } }); console.log(`odoo ${c.slug} → ${match.name}`); } } }