From ec86290d72286bae289bababd764e9026375fe57 Mon Sep 17 00:00:00 2001 From: donpat1to Date: Wed, 5 Nov 2025 15:22:29 +0100 Subject: [PATCH] fixed package.json executing seeding script --- backend/package.json | 6 +++--- backend/src/scripts/seedTestData.ts | 33 ++++++++++++++++++++++++++--- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/backend/package.json b/backend/package.json index 33dc4d1..220af2e 100644 --- a/backend/package.json +++ b/backend/package.json @@ -4,9 +4,9 @@ "type": "module", "scripts": { "dev": "npm run build && npx tsx src/server.ts", - "dev:single": "cross-env NODE_ENV=development TRUST_PROXY_ENABLED=false npx tsx src/server.ts", - "seed:test-data": "node --loader ts-node/esm src/scripts/seedTestData.ts", - "dev:all": "concurrently \"npm run dev:single\" \"npm run seed:test-data\"", + "dev:single": "cross-env NODE_ENV=development TRUST_PROXY_ENABLED=false SEED_TEST_DATA=true npx tsx src/server.ts", + "seed:test-data": "npx tsx src/scripts/seedTestData.ts", + "dev:all": "npm run dev:single", "build": "tsc", "start": "node dist/server.js", "prestart": "npm run build", diff --git a/backend/src/scripts/seedTestData.ts b/backend/src/scripts/seedTestData.ts index afe855d..046435b 100644 --- a/backend/src/scripts/seedTestData.ts +++ b/backend/src/scripts/seedTestData.ts @@ -85,11 +85,30 @@ export async function seedTestData(): Promise { try { console.log('🌱 Starting test data seeding...'); - // Read test.json file - const testDataPath = path.resolve(__dirname, '../../test.json'); + // Read test.json file - adjust path to be relative to project root + const testDataPath = path.resolve(process.cwd(), 'test.json'); + + console.log('🔍 Looking for test.json at:', testDataPath); if (!fs.existsSync(testDataPath)) { console.log('❌ test.json file not found at:', testDataPath); + + // Try alternative paths + const alternativePaths = [ + path.resolve(__dirname, '../../../test.json'), + path.resolve(process.cwd(), '../test.json'), + path.resolve(__dirname, '../../test.json') + ]; + + for (const altPath of alternativePaths) { + console.log('🔍 Trying alternative path:', altPath); + if (fs.existsSync(altPath)) { + console.log('✅ Found test.json at:', altPath); + // Continue with the found path + break; + } + } + return; } @@ -314,5 +333,13 @@ export async function seedTestData(): Promise { // Run if called directly if (import.meta.url === `file://${process.argv[1]}`) { - seedTestData().catch(console.error); + seedTestData() + .then(() => { + console.log('✅ Seed script completed'); + process.exit(0); + }) + .catch((error) => { + console.error('❌ Seed script failed:', error); + process.exit(1); + }); } \ No newline at end of file