File tree Expand file tree Collapse file tree 2 files changed +41
-1
lines changed
Expand file tree Collapse file tree 2 files changed +41
-1
lines changed Original file line number Diff line number Diff line change 88 "dtos" : " npx get-dtos ts" ,
99 "build" : " tsc && vite build" ,
1010 "lint" : " eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0" ,
11- "preview" : " vite preview"
11+ "preview" : " vite preview" ,
12+ "postinstall" : " node ./postinstall.mjs"
1213 },
1314 "dependencies" : {
1415 "@radix-ui/react-dialog" : " ^1.1.13" ,
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env node
2+
3+ // Run database migrations on first install
4+
5+ import { execSync } from 'child_process'
6+ import { join , dirname } from 'path'
7+ import { fileURLToPath } from 'url'
8+
9+ const __filename = fileURLToPath ( import . meta. url )
10+ const __dirname = dirname ( __filename )
11+
12+ function isDotnetInstalled ( ) {
13+ try {
14+ execSync ( 'dotnet --version' , { stdio : 'ignore' } )
15+ return true
16+ } catch ( error ) {
17+ return false
18+ }
19+ }
20+
21+ function runMigration ( ) {
22+ const myAppPath = join ( __dirname , '..' , 'MyApp' )
23+
24+ try {
25+ console . log ( 'Running database migration...' )
26+ execSync ( 'dotnet run --AppTasks=migrate' , {
27+ cwd : myAppPath ,
28+ stdio : 'inherit'
29+ } )
30+ console . log ( 'Migration completed successfully.' )
31+ } catch ( error ) {
32+ console . error ( 'Migration failed:' , error . message )
33+ process . exit ( 1 )
34+ }
35+ }
36+
37+ if ( isDotnetInstalled ( ) ) {
38+ runMigration ( )
39+ }
You can’t perform that action at this time.
0 commit comments