@@ -10,7 +10,9 @@ console.log('📦 Copying pre-built backend executable...')
1010const backendDir = path . join ( __dirname , '..' , 'backend' )
1111const sourceDir = path . join ( __dirname , '..' , '..' )
1212const executableName = process . platform === 'win32' ? 'main.exe' : 'main'
13- const sourceExecutablePath = path . join ( sourceDir , 'dist' , executableName )
13+ const sourceDistDir = path . join ( sourceDir , 'dist' )
14+ const sourceOnedirPath = path . join ( sourceDistDir , 'main' )
15+ const sourceOnedirExecutablePath = path . join ( sourceOnedirPath , executableName )
1416const destExecutablePath = path . join ( backendDir , executableName )
1517
1618// Clean up existing backend directory
@@ -22,9 +24,8 @@ if (fs.existsSync(backendDir)) {
2224// Ensure backend directory exists
2325fs . mkdirSync ( backendDir , { recursive : true } )
2426
25- // Check if pre-built executable exists
26- if ( ! fs . existsSync ( sourceExecutablePath ) ) {
27- console . error ( `❌ Pre-built executable not found at: ${ sourceExecutablePath } ` )
27+ if ( ! fs . existsSync ( sourceOnedirExecutablePath ) ) {
28+ console . error ( `❌ Pre-built onedir executable not found at: ${ sourceOnedirExecutablePath } ` )
2829 console . log ( '' )
2930 console . log ( '🔧 Please build the backend first by running `build.sh` in the project root directory:' )
3031 console . log ( ' cd ../..' )
@@ -33,8 +34,18 @@ if (!fs.existsSync(sourceExecutablePath)) {
3334 process . exit ( 1 )
3435}
3536
36- // Copy the executable
37- fs . copyFileSync ( sourceExecutablePath , destExecutablePath )
37+ console . log ( `📁 Detected onedir backend build at: ${ sourceOnedirPath } ` )
38+ const entries = fs . readdirSync ( sourceOnedirPath )
39+ entries . forEach ( ( entry ) => {
40+ const src = path . join ( sourceOnedirPath , entry )
41+ const dest = path . join ( backendDir , entry )
42+ fs . cpSync ( src , dest , { recursive : true , force : true } )
43+ } )
44+
45+ if ( ! fs . existsSync ( destExecutablePath ) ) {
46+ console . error ( `❌ Backend executable missing after copy: ${ destExecutablePath } ` )
47+ process . exit ( 1 )
48+ }
3849
3950// Make executable on Unix systems
4051if ( process . platform !== 'win32' ) {
@@ -49,7 +60,7 @@ console.log(`✅ Copied executable (${fileSizeInMB} MB)`)
4960
5061// Copy config files
5162const configDir = path . join ( backendDir , 'config' )
52- const sourceConfigDir = path . join ( sourceDir , 'dist' , 'config' )
63+ const sourceConfigDir = path . join ( sourceDistDir , 'config' )
5364
5465if ( fs . existsSync ( sourceConfigDir ) ) {
5566 // Create config directory
0 commit comments