Connect, collaborate, and grow with a community of TypeScript developers
chore: update prod seed scripts
bautistaaaee9229b7d3f4
diff --git a/package.json b/package.jsonindex 4e821e25..1816bd6b 100644--- a/package.json+++ b/package.json@@ -10,7 +10,7 @@"check:solutions": "tsx ./challenges/validate.ts","db:push": "turbo db:push","db:reset": "turbo db:reset",- "db:seed": "turbo db:seed",+ "db:seed": "turbo db:reset && turbo db:seed","db:prod:seed": "turbo db:reset && turbo db:prod:seed","db:studio": "turbo db:studio","dev": "turbo dev --concurrency=1000",diff --git a/packages/db/package.json b/packages/db/package.jsonindex cc43315e..eca570dc 100644--- a/packages/db/package.json+++ b/packages/db/package.json@@ -23,7 +23,7 @@"db:push": "dotenv -e ../../.env prisma db push","db:reset": "dotenv -e ../../.env prisma db push -- --force-reset","db:seed": "dotenv -e ../../.env tsx ./seed/dev.ts",- "db:prod:seed": "dotenv -e ../../.env tsx ./seed/prod.ts",+ "db:prod:seed": "dotenv -e ../../.env tsx ./temp/populate-aot-2023.ts && tsx ./seed/prod.ts ","db:studio": "dotenv -e ../../.env prisma studio","format": "prettier . --check --cache --cache-location=\"node_modules/.cache/prettiercache\"","format:fix": "prettier . --write --cache --cache-location=\"node_modules/.cache/prettiercache\" --log-level=warn",diff --git a/packages/db/seed/data/tracks.ts b/packages/db/seed/data/tracks.tsindex f1de029a..56e8ae04 100644--- a/packages/db/seed/data/tracks.ts+++ b/packages/db/seed/data/tracks.ts@@ -28,4 +28,8 @@ export const tracks = [name: 'Advent of TypeScript 2023',description: 'Explore and follow along with the community across Advent of TypeScript 2023.',},+ {+ name: 'Advent of TypeScript 2024',+ description: 'Explore and follow along with the community across Advent of TypeScript 2024.',+ },];diff --git a/packages/db/seed/prod.ts b/packages/db/seed/prod.tsindex 6645c213..7a55f4e8 100644--- a/packages/db/seed/prod.ts+++ b/packages/db/seed/prod.ts@@ -73,6 +73,49 @@ try {},});+ if (track.name === 'Advent of TypeScript 2023' || track.name === 'Advent of TypeScript 2024') {+ const challengesForTrack = await prisma.challenge.findMany({+ where: {+ slug: {+ in: [+ 'day-1',+ 'day-2',+ 'day-3',+ 'day-4',+ 'day-5',+ 'day-6',+ 'day-7',+ 'day-8',+ 'day-9',+ 'day-10',+ 'day-11',+ 'day-12',+ 'day-13',+ 'day-14',+ 'day-15',+ 'day-16',+ 'day-17',+ 'day-18',+ 'day-19',+ 'day-20',+ 'day-21',+ 'day-22',+ 'day-23',+ 'day-24',+ 'day-25',+ ],+ },+ },+ });+ await prisma.trackChallenge.createMany({+ data: challengesForTrack.map((challenge, index) => ({+ challengeId: challenge.id,+ trackId: createdTrack.id,+ orderId: index,+ })),+ });+ }+if (track.name === 'TypeScript Foundations') {const challengesForTrack = await prisma.challenge.findMany({where: {diff --git a/packages/db/temp/populate-aot-2023.ts b/packages/db/temp/populate-aot-2023.tsindex 81e769bc..9262b2ee 100644--- a/packages/db/temp/populate-aot-2023.ts+++ b/packages/db/temp/populate-aot-2023.ts@@ -1,4 +1,5 @@import path from 'node:path';+import uuidByString from 'uuid-by-string';import { fileURLToPath } from 'node:url';import { ingestChallenges } from '../seed/data/challenge-ingest';import { prisma } from '../src';@@ -11,7 +12,23 @@ const challengePath = path.join(__dirname, '../../../challenges/aot/2023');const excludes = ['blank', 'solutions'];export const slugify = (str: string) => str.toLowerCase().replace(/\s/g, '-');+const TYPEHERO_ID = uuidByString('typehero');+try {+ await prisma.user.upsert({+ where: { id: TYPEHERO_ID },+ update: {},+ create: {+ id: TYPEHERO_ID,+ email: '[email protected]',+ name: 'TypeHero',+ userLinks: {+ create: {+ url: 'https://typehero.dev',+ },+ },+ },+ });const challengesToUpdateOrCreate = await ingestChallenges(challengePath, excludes);const transactions = [];