mirror of
https://github.com/donpat1to/Schichtenplaner.git
synced 2025-11-30 22:45:46 +01:00
fixed package.json executing seeding script
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -85,11 +85,30 @@ export async function seedTestData(): Promise<void> {
|
||||
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<void> {
|
||||
|
||||
// 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);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user