@@ -405,9 +405,57 @@ func tsunamiBuildInternal(opts BuildOpts) (*BuildEnv, error) {
405405 return buildEnv , fmt .Errorf ("failed to build application: %w" , err )
406406 }
407407
408+ // Move generated files back to original directory
409+ if err := moveFilesBack (tempDir , opts .Dir , opts .Verbose ); err != nil {
410+ return buildEnv , fmt .Errorf ("failed to move files back: %w" , err )
411+ }
412+
408413 return buildEnv , nil
409414}
410415
416+ func moveFilesBack (tempDir , originalDir string , verbose bool ) error {
417+ // Move go.mod back to original directory
418+ goModSrc := filepath .Join (tempDir , "go.mod" )
419+ goModDest := filepath .Join (originalDir , "go.mod" )
420+ if err := copyFile (goModSrc , goModDest ); err != nil {
421+ return fmt .Errorf ("failed to copy go.mod back: %w" , err )
422+ }
423+ if verbose {
424+ log .Printf ("Moved go.mod back to %s" , goModDest )
425+ }
426+
427+ // Move go.sum back to original directory
428+ goSumSrc := filepath .Join (tempDir , "go.sum" )
429+ goSumDest := filepath .Join (originalDir , "go.sum" )
430+ if err := copyFile (goSumSrc , goSumDest ); err != nil {
431+ return fmt .Errorf ("failed to copy go.sum back: %w" , err )
432+ }
433+ if verbose {
434+ log .Printf ("Moved go.sum back to %s" , goSumDest )
435+ }
436+
437+ // Ensure static directory exists in original directory
438+ staticDir := filepath .Join (originalDir , "static" )
439+ if err := os .MkdirAll (staticDir , 0755 ); err != nil {
440+ return fmt .Errorf ("failed to create static directory: %w" , err )
441+ }
442+ if verbose {
443+ log .Printf ("Ensured static directory exists at %s" , staticDir )
444+ }
445+
446+ // Move tw.css back to original directory
447+ twCssSrc := filepath .Join (tempDir , "static" , "tw.css" )
448+ twCssDest := filepath .Join (originalDir , "static" , "tw.css" )
449+ if err := copyFile (twCssSrc , twCssDest ); err != nil {
450+ return fmt .Errorf ("failed to copy tw.css back: %w" , err )
451+ }
452+ if verbose {
453+ log .Printf ("Moved tw.css back to %s" , twCssDest )
454+ }
455+
456+ return nil
457+ }
458+
411459func runGoBuild (tempDir string , opts BuildOpts ) error {
412460 var outputPath string
413461 if opts .OutputFile != "" {
0 commit comments