Adds consultation leads, section editors, and the one-time content reset for this release. Co-authored-by: Cursor <cursoragent@cursor.com>
128 lines
4.4 KiB
TypeScript
128 lines
4.4 KiB
TypeScript
import { PrismaClient } from "@prisma/client";
|
|
import * as bcrypt from "bcryptjs";
|
|
import { DEFAULT_SECTIONS, LEGACY_SECTION_KEYS } from "@montech/shared";
|
|
|
|
const prisma = new PrismaClient();
|
|
|
|
const contactDefaults = {
|
|
brandName: "منتک",
|
|
tagline: "هوشافزار منظر",
|
|
email: "info@montech.ir",
|
|
phone: "۰۹۱۲ ۳۴۵ ۶۷۸۹",
|
|
address: "تهران، ایران",
|
|
socials: [
|
|
{ label: "تلگرام", url: "#" },
|
|
{ label: "لینکدین", url: "#" },
|
|
{ label: "اینستاگرام", url: "#" },
|
|
],
|
|
};
|
|
|
|
const pages = [
|
|
{
|
|
key: "home",
|
|
title: "خانه",
|
|
seo: {
|
|
title: "منتک | هوشافزار منظر - پلتفرم راهکارهای نرمافزاری و هوش مصنوعی",
|
|
description:
|
|
"با کمک هوش مصنوعی منتک، بهترین نرمافزارها و خدمات متناسب با کسبوکار شما پیشنهاد میشود. نرمافزار اختصاصی، حسابداری، CRM، فروشگاه آنلاین و نرمافزار طلا و جواهر.",
|
|
canonical: "https://montech.ir/",
|
|
},
|
|
},
|
|
{
|
|
key: "blog",
|
|
title: "بلاگ",
|
|
seo: {
|
|
title: "بلاگ — منتک",
|
|
description: "یادداشتهایی درباره محصول، مهندسی و ساخت نرمافزار.",
|
|
canonical: "https://montech.ir/blog",
|
|
},
|
|
},
|
|
{
|
|
key: "gallery",
|
|
title: "گالری",
|
|
seo: {
|
|
title: "گالری — منتک",
|
|
description: "تصاویر منتخب از پروژهها و فضای استودیو منتک.",
|
|
canonical: "https://montech.ir/gallery",
|
|
},
|
|
},
|
|
];
|
|
|
|
/** Set SEED_RESET_CONTENT=1 to overwrite existing settings/sections/SEO with the defaults. */
|
|
const resetContent = process.env.SEED_RESET_CONTENT === "1";
|
|
|
|
async function main() {
|
|
const mobile = process.env.ADMIN_MOBILE || "09121234567";
|
|
const password = process.env.ADMIN_PASSWORD || "change-me-strong";
|
|
const name = process.env.ADMIN_NAME || "مدیر منتک";
|
|
const hash = await bcrypt.hash(password, 10);
|
|
|
|
await prisma.admin.upsert({
|
|
where: { mobile },
|
|
create: { mobile, passwordHash: hash, name, email: "admin@montech.ir" },
|
|
update: { passwordHash: hash, name },
|
|
});
|
|
|
|
await prisma.siteSettings.upsert({
|
|
where: { id: "default" },
|
|
create: { id: "default", timezone: "Asia/Tehran", ...contactDefaults },
|
|
update: resetContent ? contactDefaults : {},
|
|
});
|
|
|
|
for (const p of pages) {
|
|
const page = await prisma.page.upsert({
|
|
where: { key: p.key },
|
|
create: { key: p.key, title: p.title },
|
|
update: { title: p.title },
|
|
});
|
|
await prisma.pageSeo.upsert({
|
|
where: { pageId: page.id },
|
|
create: { pageId: page.id, ...p.seo },
|
|
update: resetContent ? { ...p.seo } : {},
|
|
});
|
|
}
|
|
|
|
await prisma.sectionContent.deleteMany({ where: { key: { in: [...LEGACY_SECTION_KEYS] } } });
|
|
|
|
for (const [key, data] of Object.entries(DEFAULT_SECTIONS)) {
|
|
const json = {
|
|
...data,
|
|
...(key === "footer"
|
|
? { email: contactDefaults.email, phone: contactDefaults.phone, address: contactDefaults.address }
|
|
: {}),
|
|
} as object;
|
|
await prisma.sectionContent.upsert({
|
|
where: { key },
|
|
create: { key, data: json },
|
|
update: resetContent ? { data: json } : {},
|
|
});
|
|
}
|
|
|
|
await prisma.blogPost.upsert({
|
|
where: { slug: "welcome-to-montech" },
|
|
create: {
|
|
slug: "welcome-to-montech",
|
|
title: "به منتک خوش آمدید",
|
|
excerpt: "ما نرمافزاری میسازیم که واقعاً کار میکند — و اینجا دربارهاش مینویسیم.",
|
|
content:
|
|
"منتک یک گروه توسعه نرمافزار است که پلتفرم وب، اپلیکیشن موبایل و زیرساخت ابری میسازد.\n\nدر این بلاگ درباره ساخت محصول، مهندسی و درسآموختههای استودیو مینویسیم.",
|
|
published: true,
|
|
publishedAt: new Date(),
|
|
seoTitle: "به منتک خوش آمدید — بلاگ",
|
|
seoDesc: "معرفی منتک و نحوه ساخت نرمافزار در تیم ما.",
|
|
},
|
|
update: {},
|
|
});
|
|
|
|
console.log(`Seed complete (${resetContent ? "content reset" : "missing rows only"}). Admin:`, mobile);
|
|
}
|
|
|
|
main()
|
|
.catch((e) => {
|
|
console.error(e);
|
|
process.exit(1);
|
|
})
|
|
.finally(async () => {
|
|
await prisma.$disconnect();
|
|
});
|