diff --git a/apps/web/migrate-docs.ts b/apps/web/migrate-docs.ts
deleted file mode 100644
index e8c8705..0000000
--- a/apps/web/migrate-docs.ts
+++ /dev/null
@@ -1,54 +0,0 @@
-import { getPayload } from "payload";
-import configPromise from "./payload.config";
-import fs from "fs";
-import path from "path";
-
-async function run() {
- try {
- const payload = await getPayload({ config: configPromise });
- console.log("Payload initialized.");
-
- const docsDir = path.resolve(process.cwd(), "docs");
-
- if (!fs.existsSync(docsDir)) {
- console.log(`Docs directory not found at ${docsDir}`);
- process.exit(0);
- }
-
- const files = fs.readdirSync(docsDir);
- let count = 0;
-
- for (const file of files) {
- if (file.endsWith(".md")) {
- const content = fs.readFileSync(path.join(docsDir, file), "utf8");
-
- // Check if already exists
- const existing = await payload.find({
- collection: "context-files",
- where: { filename: { equals: file } },
- });
-
- if (existing.totalDocs === 0) {
- await payload.create({
- collection: "context-files",
- data: {
- filename: file,
- content: content,
- },
- });
- count++;
- }
- }
- }
-
- console.log(
- `Migration successful! Added ${count} new context files to the database.`,
- );
- process.exit(0);
- } catch (e) {
- console.error("Migration failed:", e);
- process.exit(1);
- }
-}
-
-run();
diff --git a/apps/web/migrate-drafts.ts b/apps/web/migrate-drafts.ts
deleted file mode 100644
index f83a479..0000000
--- a/apps/web/migrate-drafts.ts
+++ /dev/null
@@ -1,34 +0,0 @@
-import { getPayload } from "payload";
-import configPromise from "./payload.config";
-
-async function run() {
- const payload = await getPayload({ config: configPromise });
- const { docs } = await payload.find({
- collection: "posts",
- limit: 1000,
- });
-
- console.log(`Found ${docs.length} posts. Checking status...`);
-
- for (const doc of docs) {
- if (doc._status !== "published") {
- try {
- await payload.update({
- collection: "posts",
- id: doc.id,
- data: {
- _status: "published",
- },
- });
- console.log(`Updated "${doc.title}" to published.`);
- } catch (e) {
- console.error(`Failed to update ${doc.title}:`, e.message);
- }
- }
- }
-
- console.log("Migration complete.");
- process.exit(0);
-}
-
-run();
diff --git a/apps/web/remove-toc.ts b/apps/web/remove-toc.ts
deleted file mode 100644
index eb44f0d..0000000
--- a/apps/web/remove-toc.ts
+++ /dev/null
@@ -1,87 +0,0 @@
-import { getPayload } from "payload";
-import configPromise from "./payload.config";
-
-async function run() {
- const payload = await getPayload({ config: configPromise });
- const { docs } = await payload.find({
- collection: "posts",
- limit: 1000,
- });
-
- console.log(
- `Found ${docs.length} posts. Checking for ...`,
- );
-
- let updatedCount = 0;
-
- const removeTOC = (node: any): boolean => {
- let modified = false;
- if (node.children && Array.isArray(node.children)) {
- // Filter out raw text nodes or paragraph nodes that are exactly TableOfContents
- const originalLength = node.children.length;
- node.children = node.children.filter((child: any) => {
- if (
- child.type === "text" &&
- child.text &&
- child.text.includes("")
- ) {
- return false;
- }
- if (
- child.type === "paragraph" &&
- child.children &&
- child.children.length === 1 &&
- child.children[0].text === ""
- ) {
- return false;
- }
- return true;
- });
- if (node.children.length !== originalLength) {
- modified = true;
- }
-
- // Also clean up any substrings in remaining text nodes
- for (const child of node.children) {
- if (
- child.type === "text" &&
- child.text &&
- child.text.includes("")
- ) {
- child.text = child.text.replace("", "").trim();
- modified = true;
- }
- if (removeTOC(child)) {
- modified = true;
- }
- }
- }
- return modified;
- };
-
- for (const doc of docs) {
- if (doc.content?.root) {
- const isModified = removeTOC(doc.content.root);
- if (isModified) {
- try {
- await payload.update({
- collection: "posts",
- id: doc.id,
- data: {
- content: doc.content,
- },
- });
- console.log(`Cleaned up TOC in "${doc.title}".`);
- updatedCount++;
- } catch (e) {
- console.error(`Failed to update ${doc.title}:`, e.message);
- }
- }
- }
- }
-
- console.log(`Cleanup complete. Modified ${updatedCount} posts.`);
- process.exit(0);
-}
-
-run();
diff --git a/apps/web/scripts/create-user.ts b/apps/web/scripts/create-user.ts
deleted file mode 100644
index f6954b8..0000000
--- a/apps/web/scripts/create-user.ts
+++ /dev/null
@@ -1,41 +0,0 @@
-import { getPayload } from "payload";
-import configPromise from "../payload.config";
-
-async function run() {
- try {
- const payload = await getPayload({ config: configPromise });
-
- const existing = await payload.find({
- collection: "users",
- where: { email: { equals: "marc@mintel.me" } },
- });
-
- if (existing.totalDocs > 0) {
- console.log("User already exists, updating password...");
- await payload.update({
- collection: "users",
- where: { email: { equals: "marc@mintel.me" } },
- data: {
- password: "Tim300493.",
- },
- });
- console.log("Password updated.");
- } else {
- console.log("Creating user...");
- await payload.create({
- collection: "users",
- data: {
- email: "marc@mintel.me",
- password: "Tim300493.",
- },
- });
- console.log("User marc@mintel.me created.");
- }
- process.exit(0);
- } catch (err) {
- console.error("Failed to create user:", err);
- process.exit(1);
- }
-}
-
-run();
diff --git a/apps/web/scripts/import-leads.ts b/apps/web/scripts/import-leads.ts
deleted file mode 100644
index c757fd4..0000000
--- a/apps/web/scripts/import-leads.ts
+++ /dev/null
@@ -1,168 +0,0 @@
-import fs from "node:fs";
-import * as xlsxImport from "xlsx";
-const xlsx = (xlsxImport as any).default || xlsxImport;
-import { getPayload } from "payload";
-import configPromise from "../payload.config";
-
-async function run() {
- try {
- console.log("Initializing Payload...");
- const payload = await getPayload({ config: configPromise });
-
- const filePath = "/Users/marcmintel/Downloads/Akquise_Branchen.xlsx";
- if (!fs.existsSync(filePath)) {
- console.error("File not found:", filePath);
- process.exit(1);
- }
-
- console.log(`Reading Excel file: ${filePath}`);
- const wb = xlsx.readFile(filePath);
-
- let accountsCreated = 0;
- let contactsCreated = 0;
-
- for (const sheetName of wb.SheetNames) {
- if (
- sheetName === "Weitere Kundenideen" ||
- sheetName.includes("BKF Firmen")
- )
- continue;
-
- let industry = sheetName
- .replace(/^\d+_/, "")
- .replace(/^\d+\.\s*/, "")
- .replace(/_/g, " ");
- console.log(
- `\n--- Importing Sheet: ${sheetName} -> Industry: ${industry} ---`,
- );
- const rows = xlsx.utils.sheet_to_json(wb.Sheets[sheetName]);
-
- for (const row of rows) {
- const companyName = row["Unternehmen"]?.trim();
- const website = row["Webseitenlink"]?.trim();
- let email = row["Emailadresse"]?.trim();
- const contactName = row["Ansprechpartner"]?.trim();
- const position = row["Position"]?.trim();
- const statusRaw = row["Webseiten-Status (alt/gut/schlecht)"]
- ?.trim()
- ?.toLowerCase();
- const notes = row["Notizen"]?.trim();
-
- if (!companyName) continue;
-
- let websiteStatus = "unknown";
- if (statusRaw === "gut") websiteStatus = "gut";
- else if (statusRaw === "ok" || statusRaw === "okay")
- websiteStatus = "ok";
- else if (
- statusRaw === "schlecht" ||
- statusRaw === "alt" ||
- statusRaw === "veraltet"
- )
- websiteStatus = "schlecht";
-
- // Find or create account
- let accountId;
- const whereClause = website
- ? { website: { equals: website } }
- : { name: { equals: companyName } };
-
- const existingAccounts = await payload.find({
- collection: "crm-accounts",
- where: whereClause,
- });
-
- if (existingAccounts.docs.length > 0) {
- accountId = existingAccounts.docs[0].id;
- console.log(`[SKIP] Account exists: ${companyName}`);
- } else {
- try {
- const newAccount = await payload.create({
- collection: "crm-accounts",
- data: {
- name: companyName,
- website: website || "",
- status: "lead",
- leadTemperature: "cold",
- industry,
- websiteStatus,
- notes,
- } as any,
- });
- accountId = newAccount.id;
- accountsCreated++;
- console.log(`[OK] Created account: ${companyName}`);
- } catch (err: any) {
- console.error(
- `[ERROR] Failed to create account ${companyName}:`,
- err.message,
- );
- continue; // Skip contact creation if account failed
- }
- }
-
- // Handle contact
- if (email) {
- // Some rows have multiple emails or contacts. Let's just pick the first email if there are commas.
- if (email.includes(",")) email = email.split(",")[0].trim();
-
- const existingContacts = await payload.find({
- collection: "crm-contacts",
- where: { email: { equals: email } },
- });
-
- if (existingContacts.docs.length === 0) {
- let firstName = "Team";
- let lastName = companyName; // fallback
-
- if (contactName) {
- // If multiple contacts are listed, just take the first one
- const firstContact = contactName.split(",")[0].trim();
- const parts = firstContact.split(" ");
- if (parts.length > 1) {
- lastName = parts.pop();
- firstName = parts.join(" ");
- } else {
- firstName = firstContact;
- lastName = "Contact";
- }
- }
-
- try {
- await payload.create({
- collection: "crm-contacts",
- data: {
- email,
- firstName,
- lastName,
- role: position,
- account: accountId as any,
- },
- });
- contactsCreated++;
- console.log(` -> [OK] Created contact: ${email}`);
- } catch (err: any) {
- console.error(
- ` -> [ERROR] Failed to create contact ${email}:`,
- err.message,
- );
- }
- } else {
- console.log(` -> [SKIP] Contact exists: ${email}`);
- }
- }
- }
- }
-
- console.log(`\nMigration completed successfully!`);
- console.log(
- `Created ${accountsCreated} Accounts and ${contactsCreated} Contacts.`,
- );
- process.exit(0);
- } catch (e) {
- console.error("Migration failed:", e);
- process.exit(1);
- }
-}
-
-run();
diff --git a/apps/web/seed-context.ts b/apps/web/seed-context.ts
deleted file mode 100644
index b9c7008..0000000
--- a/apps/web/seed-context.ts
+++ /dev/null
@@ -1,89 +0,0 @@
-import { getPayload } from "payload";
-import configPromise from "./payload.config";
-import fs from "fs";
-import path from "path";
-import { fileURLToPath } from "url";
-
-const __filename = fileURLToPath(import.meta.url);
-const __dirname = path.dirname(__filename);
-
-async function run() {
- try {
- let payload;
- let retries = 5;
- while (retries > 0) {
- try {
- console.log(
- `Connecting to database (URI: ${process.env.DATABASE_URI || "default"})...`,
- );
- payload = await getPayload({ config: configPromise });
- break;
- } catch (e: any) {
- if (
- e.code === "ECONNREFUSED" ||
- e.code === "ENOTFOUND" ||
- e.message?.includes("ECONNREFUSED") ||
- e.message?.includes("ENOTFOUND") ||
- e.message?.includes("cannot connect to Postgres")
- ) {
- console.log(
- `Database not ready (${e.code || "UNKNOWN"}), retrying in 3 seconds... (${retries} retries left)`,
- );
- retries--;
- await new Promise((res) => setTimeout(res, 3000));
- } else {
- console.error("Fatal connection error:", e);
- throw e;
- }
- }
- }
-
- if (!payload) {
- throw new Error(
- "Failed to connect to the database after multiple retries.",
- );
- }
-
- const existing = await payload.find({
- collection: "context-files",
- limit: 0,
- });
-
- if (existing.totalDocs > 0) {
- console.log("Context collection already populated. Skipping seed.");
- process.exit(0);
- }
-
- const seedDir = path.resolve(
- __dirname,
- "src/payload/collections/ContextFiles/seed",
- );
- if (!fs.existsSync(seedDir)) {
- console.log(`Seed directory not found at ${seedDir}`);
- process.exit(0);
- }
-
- const files = fs.readdirSync(seedDir).filter((f) => f.endsWith(".md"));
- let count = 0;
-
- for (const file of files) {
- const content = fs.readFileSync(path.join(seedDir, file), "utf8");
- await payload.create({
- collection: "context-files",
- data: {
- filename: file,
- content: content,
- },
- });
- count++;
- }
-
- console.log(`Seeded ${count} context files.`);
- process.exit(0);
- } catch (e) {
- console.error("Seeding failed:", e);
- process.exit(1);
- }
-}
-
-run();