1
1
import process from 'node:process'
2
2
import { log , runCommand } from '@stacksjs/cli'
3
3
import { app } from '@stacksjs/config'
4
- import { frameworkCloudPath , frameworkPath , projectPath } from '@stacksjs/path'
5
- import { hasFiles } from '@stacksjs/storage'
4
+ import { path , frameworkCloudPath , frameworkPath , projectPath } from '@stacksjs/path'
5
+ import { fs , hasFiles } from '@stacksjs/storage'
6
6
import { slug } from '@stacksjs/strings'
7
7
import { $ } from 'bun'
8
8
@@ -36,12 +36,15 @@ export async function buildDockerImage() {
36
36
37
37
// delete old CDK relating files, to always build fresh
38
38
log . info ( 'Deleting old CDK files...' )
39
- log . debug ( 'Deleting old cdk.out ...' )
39
+ log . info ( 'Deleting old cdk.out ...' )
40
40
await runCommand ( `rm -rf ${ frameworkCloudPath ( 'cdk.out/' ) } ` )
41
- log . debug ( 'Deleting old CDK context file...' )
41
+ log . success ( 'Deleted old cdk.out' )
42
+ log . info ( 'Deleting old CDK context file...' )
42
43
await runCommand ( `rm -rf ${ frameworkCloudPath ( 'cdk.context.json' ) } ` )
43
- log . debug ( 'Deleting old dist.zip file...' )
44
+ log . success ( 'Deleted old cdk.context.json' )
45
+ log . info ( 'Deleting old dist.zip file...' )
44
46
await runCommand ( `rm -rf ${ frameworkCloudPath ( 'dist.zip' ) } ` )
47
+ log . success ( 'Deleted old dist.zip' )
45
48
46
49
log . info ( 'Copying project files...' )
47
50
log . info ( 'Copying config files...' )
@@ -53,6 +56,28 @@ export async function buildDockerImage() {
53
56
log . info ( 'Copying storage files...' )
54
57
await cleanCopy ( projectPath ( 'storage' ) , frameworkPath ( 'server/storage' ) )
55
58
log . success ( 'Copied storage files' )
59
+
60
+ // move files out of the frameworkPath('server/storage/dist') folder to the frameworkPath('server/storage') folder
61
+ if ( fs . existsSync ( frameworkPath ( 'server/storage/dist' ) ) ) {
62
+ log . info ( 'Moving files...' )
63
+ const sourceDir = frameworkPath ( 'server/storage/dist' )
64
+ const targetDir = frameworkPath ( 'server/storage' )
65
+
66
+ // Read all items in the source directory
67
+ const items = await fs . readdir ( sourceDir )
68
+
69
+ // Move each item to the target directory
70
+ for ( const item of items ) {
71
+ const srcPath = path . join ( sourceDir , item )
72
+ const destPath = path . join ( targetDir , item )
73
+ await fs . move ( srcPath , destPath , { overwrite : true } )
74
+ }
75
+
76
+ // Remove the now-empty dist folder
77
+ await fs . remove ( sourceDir )
78
+ log . success ( 'Moved files' )
79
+ }
80
+
56
81
log . info ( 'Copying .env file...' )
57
82
await cleanCopy ( projectPath ( '.env' ) , frameworkPath ( 'server/.env' ) )
58
83
log . success ( 'Copied .env file' )
0 commit comments