diff --git a/plugins/gitea-sync/index.js b/plugins/gitea-sync/index.js index b21776d..a6aed23 100644 --- a/plugins/gitea-sync/index.js +++ b/plugins/gitea-sync/index.js @@ -87,6 +87,34 @@ async function fetchReleases(url, repoFullName, token) { })); } +const DEFAULT_TEMPLATES = [ + { + name: "Bug Report", isDefault: true, position: 0, + fields: [ + { key: "steps_to_reproduce", label: "Steps to reproduce", type: "textarea", required: true, placeholder: "1. Go to...\n2. Click on...\n3. See error" }, + { key: "expected_behavior", label: "Expected behavior", type: "textarea", required: true }, + { key: "actual_behavior", label: "Actual behavior", type: "textarea", required: true }, + ], + }, + { + name: "Feature Request", isDefault: false, position: 1, + fields: [ + { key: "use_case", label: "Use case", type: "textarea", required: true, placeholder: "What problem would this solve?" }, + { key: "proposed_solution", label: "Proposed solution", type: "textarea", required: true }, + ], + }, +]; + +async function seedTemplates(prisma, boardId) { + const existing = await prisma.boardTemplate.count({ where: { boardId } }); + if (existing > 0) return; + await prisma.boardTemplate.createMany({ + data: DEFAULT_TEMPLATES.map((t) => ({ + boardId, name: t.name, fields: t.fields, isDefault: t.isDefault, position: t.position, + })), + }).catch(() => {}); +} + function parseProfileUrl(raw) { const clean = String(raw).replace(/\/+$/, ""); const parts = clean.split("/"); @@ -127,6 +155,7 @@ async function syncRepos(ctx) { where: { slug }, data: { externalUrl: repo.htmlUrl, description: repo.description || board.description }, }); + await seedTemplates(ctx.prisma, board.id); updated++; } else { const name = titleCase(repo.name); @@ -143,6 +172,7 @@ async function syncRepos(ctx) { iconColor, }, }); + await seedTemplates(ctx.prisma, board.id); created++; }