Files
mintel.me/apps/web/seed-context.ts
Marc Mintel 6864903cff
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 10s
Build & Deploy / 🧪 QA (push) Failing after 2m24s
Build & Deploy / 🏗️ Build (push) Failing after 3m40s
Build & Deploy / 🚀 Deploy (push) Has been skipped
Build & Deploy / 🩺 Health Check (push) Has been skipped
Build & Deploy / 🔔 Notify (push) Successful in 3s
fix(web): remove redundant prop-types and unblock lint pipeline
2026-02-24 11:38:43 +01:00

57 lines
1.3 KiB
TypeScript

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 {
const payload = await getPayload({ config: configPromise });
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();