import { normalizeIrMobile } from "@imen/shared"; import { hashPassword } from "../auth/auth.service.js"; import { createPrismaClient } from "../prisma/prisma.service.js"; const prisma = createPrismaClient(); async function main() { const phone = normalizeIrMobile("09128081392"); const password = "09128081392"; const name = "مدیر سایت"; const role = "ADMIN"; const passwordHash = await hashPassword(password); const existing = await prisma.adminUser.findUnique({ where: { phone } }); if (existing) { const updated = await prisma.adminUser.update({ where: { id: existing.id }, data: { passwordHash, name, role, }, }); console.log(`User already existed, password updated for: ${updated.phone} (ID: ${updated.id})`); } else { const user = await prisma.adminUser.create({ data: { phone, passwordHash, name, role, }, }); console.log(`User successfully created: ${user.phone} (ID: ${user.id}, Role: ${user.role})`); } } try { await main(); } catch (e) { console.error("Error creating user:", e); process.exitCode = 1; } finally { await prisma.$disconnect(); } //# sourceMappingURL=create-admin.js.map