fix(seed): resolve CSV path for Docker and mount import in stack compose; deleted plans; adds extra files to gitignore
Some checks failed
CI / build-and-test (pull_request) Has been cancelled

This commit is contained in:
Vaka.pro
2026-04-08 00:22:11 +03:00
parent ef423b322f
commit 0f0c7c2607
5 changed files with 21 additions and 167 deletions

View File

@@ -24,10 +24,24 @@ function makeId(date: string, title: string): string {
return `${date}-${slugify(title)}`;
}
const CSV_NAME = "races_2026_calendar.csv";
function resolveCsvPath(): string | null {
// Docker image: /app/dist/*.js → ../import = /app/import (matches Dockerfile COPY import ./import)
// Local monorepo: backend/dist/*.js → ../../import = repo root import/
const candidates = [
path.resolve(__dirname, "../import", CSV_NAME),
path.resolve(__dirname, "../../import", CSV_NAME),
];
return candidates.find((p) => fs.existsSync(p)) ?? null;
}
async function seed() {
const csvPath = path.resolve(__dirname, "../../import/races_2026_calendar.csv");
if (!fs.existsSync(csvPath)) {
console.error(`[seed] CSV not found: ${csvPath}`);
const csvPath = resolveCsvPath();
if (!csvPath) {
console.error(
`[seed] CSV not found: ${CSV_NAME}. Tried:\n - ${path.resolve(__dirname, "../import", CSV_NAME)}\n - ${path.resolve(__dirname, "../../import", CSV_NAME)}`,
);
process.exit(1);
}