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 1111 "typecheck" : " tsc" ,
1212 "test" : " vitest" ,
1313 "test:ui" : " vitest --ui" ,
14- "test:run" : " vitest run"
14+ "test:run" : " vitest run" ,
15+ "postinstall" : " node ./postinstall.mjs"
1516 },
1617 "dependencies" : {
1718 "@mdx-js/loader" : " ^3.1.1" ,
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