11import { PrismaPg } from '@prisma/adapter-pg' ;
22import 'dotenv/config' ;
33import { PrismaClient } from '../generated/prisma/client.js' ;
4+ import fs from 'node:fs' ;
5+ import path from 'node:path' ;
46
57const adapter = new PrismaPg ( { connectionString : process . env [ 'DATABASE_URL' ] ! } ) ;
68const prisma = new PrismaClient ( { adapter } ) ;
9+ const seedFilesPath = path . join ( import . meta. dirname , 'seed-files' ) ;
710
811const ids = {
912 // Users
@@ -108,7 +111,7 @@ async function main() {
108111 const users = [
109112 {
110113 id : ids . alice ,
111- name : 'Alice Wilensky ' ,
114+ name : 'Alice Bob ' ,
112115 email : 'alice@example.com' ,
113116 emailVerified : true ,
114117 systemRole : 'user' as const ,
@@ -232,20 +235,21 @@ async function main() {
232235 console . log ( ` ✓ ${ tags . length } tags` ) ;
233236
234237 // 5. Files (nlogox files + supplementary)
238+
235239 const files = [
236240 {
237241 id : ids . wolfSheepNlogox1 ,
238242 filename : 'wolf-sheep-v1.nlogox' ,
239243 contentType : 'application/xml' ,
240- sizeBytes : BigInt ( 420 ) ,
241- blob : fakeNlogox ( 'Wolf Sheep Predation v1' ) ,
244+ sizeBytes : fs . statSync ( path . join ( seedFilesPath , 'wolf-sheep-predation.nlogox' ) ) . size ,
245+ blob : fs . readFileSync ( path . join ( seedFilesPath , 'wolf-sheep-predation.nlogox' ) ) ,
242246 } ,
243247 {
244248 id : ids . wolfSheepNlogox2 ,
245249 filename : 'wolf-sheep-v2.nlogox' ,
246250 contentType : 'application/xml' ,
247- sizeBytes : BigInt ( 440 ) ,
248- blob : fakeNlogox ( 'Wolf Sheep Predation v2' ) ,
251+ sizeBytes : fs . statSync ( path . join ( seedFilesPath , 'wolf-sheep-predation-v2.nlogox' ) ) . size ,
252+ blob : fs . readFileSync ( path . join ( seedFilesPath , 'wolf-sheep-predation-v2.nlogox' ) ) ,
249253 } ,
250254 {
251255 id : ids . fireSpreadNlogox ,
@@ -272,8 +276,8 @@ async function main() {
272276 id : ids . wolfSheepForkNlogox ,
273277 filename : 'wolf-sheep-fork.nlogox' ,
274278 contentType : 'application/xml' ,
275- sizeBytes : BigInt ( 450 ) ,
276- blob : fakeNlogox ( 'Wolf Sheep Fork' ) ,
279+ sizeBytes : fs . statSync ( path . join ( seedFilesPath , 'wolf-sheep-predation.nlogox' ) ) . size ,
280+ blob : fs . readFileSync ( path . join ( seedFilesPath , 'wolf-sheep-predation.nlogox' ) ) ,
277281 } ,
278282 {
279283 id : ids . wolfSheepReadme ,
@@ -347,6 +351,7 @@ async function main() {
347351 infoTab : '## WHAT IS IT?\n\nThis model explores the stability of predator-prey ecosystems.' ,
348352 createdAt : oneWeekAgo ,
349353 finalizedAt : now ,
354+ previewImage : fs . readFileSync ( path . join ( seedFilesPath , 'wolf-sheep-preview.png' ) ) ,
350355 } ,
351356 {
352357 id : ids . wolfSheepV2 ,
@@ -358,6 +363,7 @@ async function main() {
358363 netlogoVersion : '6.4.0' ,
359364 infoTab :
360365 "## WHAT IS IT?\n\nThis model explores the stability of predator-prey ecosystems.\n\n## WHAT'S NEW\n\nEnergy-based movement added in v2." ,
366+ previewImage : fs . readFileSync ( path . join ( seedFilesPath , 'wolf-sheep-preview.png' ) ) ,
361367 } ,
362368 {
363369 id : ids . fireSpreadV1 ,
@@ -402,6 +408,7 @@ async function main() {
402408 nlogoxFileId : ids . wolfSheepForkNlogox ,
403409 netlogoVersion : '6.4.0' ,
404410 infoTab : '## WHAT IS IT?\n\nA seasonal variant of the classic Wolf Sheep Predation model.' ,
411+ previewImage : fs . readFileSync ( path . join ( seedFilesPath , 'wolf-sheep-preview.png' ) ) ,
405412 } ,
406413 ] ;
407414
0 commit comments