From b40ae3a4e5dc09faa6a5e2b49ef54897682fa429 Mon Sep 17 00:00:00 2001 From: WA11AX Date: Wed, 13 Aug 2025 21:33:21 +0300 Subject: [PATCH 1/2] feat(server): add seeding script --- README.md | 9 ++++++++- package.json | 1 + server/README.md | 3 +++ server/seed.ts | 14 ++++++++++++++ server/storage.ts | 3 --- 5 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 server/seed.ts diff --git a/README.md b/README.md index 655f510..eb145d2 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,13 @@ cp .env.example .env npm run db:push ``` -5. Start the development server: +5. (Optional) Seed demo tournaments: + +```bash +npm run seed +``` + +6. Start the development server: ```bash npm run dev @@ -99,6 +105,7 @@ The application will be available at `http://localhost:5173` - `npm run start` - Start production server - `npm run check` - Type check with TypeScript - `npm run db:push` - Push database schema changes +- `npm run seed` - Seed demo tournaments with sample data ## 🏆 Tournament Features diff --git a/package.json b/package.json index f3baa9b..f7104c2 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "lint:check": "eslint . --max-warnings=0", "prepare": "if [ -z \"$CI\" ]; then npm run validate; fi", "start": "NODE_ENV=production node dist/index.js", + "seed": "NODE_ENV=development tsx server/seed.ts", "test": "echo \"Add test script here\"", "test:coverage": "echo \"Add test coverage script here\"", "type-check": "tsc --noEmit", diff --git a/server/README.md b/server/README.md index e132fbc..bb14bb2 100644 --- a/server/README.md +++ b/server/README.md @@ -52,6 +52,9 @@ npm run start # Push schema changes to database npm run db:push +# Seed demo tournaments (optional) +npm run seed + # View database configuration cat drizzle.config.ts ``` diff --git a/server/seed.ts b/server/seed.ts new file mode 100644 index 0000000..381a513 --- /dev/null +++ b/server/seed.ts @@ -0,0 +1,14 @@ +import { storage } from './storage'; + +async function seed() { + try { + await storage.initializeData(); + console.log('Demo tournaments seeded successfully.'); + process.exit(0); + } catch (error) { + console.error('Failed to seed demo tournaments:', error); + process.exit(1); + } +} + +seed(); diff --git a/server/storage.ts b/server/storage.ts index 5b14801..a10264a 100644 --- a/server/storage.ts +++ b/server/storage.ts @@ -258,6 +258,3 @@ export class DatabaseStorage implements IStorage { } export const storage = new DatabaseStorage(); - -// Initialize sample data on startup -storage.initializeData().catch(console.error); From 9ca9b2bbd2213f2a7923fd48983b4777d54a5295 Mon Sep 17 00:00:00 2001 From: WA11AX Date: Wed, 13 Aug 2025 21:35:39 +0300 Subject: [PATCH 2/2] Update server/seed.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- server/seed.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/seed.ts b/server/seed.ts index 381a513..d7b6acc 100644 --- a/server/seed.ts +++ b/server/seed.ts @@ -3,7 +3,7 @@ import { storage } from './storage'; async function seed() { try { await storage.initializeData(); - console.log('Demo tournaments seeded successfully.'); + console.log('Sample tournaments seeded successfully.'); process.exit(0); } catch (error) { console.error('Failed to seed demo tournaments:', error);