@@ -3,7 +3,7 @@ import { intro, outro } from '@stacksjs/build'
3
3
import { log , runCommand , runCommandSync } from '@stacksjs/cli'
4
4
import { cloud } from '@stacksjs/config'
5
5
import { path } from '@stacksjs/path'
6
- import { fs , deleteFolder , glob } from '@stacksjs/storage'
6
+ import { fs , deleteFolder } from '@stacksjs/storage'
7
7
import { build } from 'bun'
8
8
import { buildDockerImage , useCustomOrDefaultServerConfig } from './src/utils'
9
9
@@ -61,10 +61,19 @@ async function main() {
61
61
pkgName : 'server' ,
62
62
} )
63
63
64
- const files = await glob ( [ path . appPath ( '*.ts' ) , path . appPath ( '**/*.ts' ) ] )
65
- console . log ( 'fillllles' , files )
66
- log . info ( `Found ${ files . length } files` )
64
+ const glob = new Bun . Glob ( '**/*.{ts,js}' )
65
+ const root = path . appPath ( )
66
+ const scanOptions = { cwd : root , onlyFiles : true }
67
+ const files : string [ ] = [ ]
68
+
69
+ for await ( const file of glob . scan ( scanOptions ) ) {
70
+ files . push ( file )
71
+ }
72
+
73
+ console . log ( 'asdasdass' , files )
74
+
67
75
const r2 = await build ( {
76
+ root,
68
77
entrypoints : files ,
69
78
outdir : path . frameworkPath ( 'server/dist/app' ) ,
70
79
format : 'esm' ,
@@ -80,8 +89,11 @@ async function main() {
80
89
// await runCommand(`rm -rf ${path.storagePath('app')}`)
81
90
82
91
// Process files in the ./app folder
83
- const appFiles = await glob ( [ path . userServerPath ( 'app/**/*.js' ) ] )
84
- for ( const file of appFiles ) {
92
+ // const appFiles = await glob([path.userServerPath('app/**/*.js')])
93
+ const glob2 = new Bun . Glob ( 'app/**/*.js' )
94
+ const scanOptions2 = { cwd : path . userServerPath ( 'app' ) , onlyFiles : true }
95
+
96
+ for await ( const file of glob2 . scan ( scanOptions2 ) ) {
85
97
let content = await fs . readFile ( file , 'utf-8' )
86
98
if ( content . includes ( 'storage/framework/server' ) ) {
87
99
content = content . replace ( / s t o r a g e \/ f r a m e w o r k \/ s e r v e r / g, 'dist' )
@@ -93,8 +105,11 @@ async function main() {
93
105
// Process files in the ./dist folder
94
106
// need to remove export `{ ENV_KEY, ENV_SECRET, fromEnv };` from whatever file that contains it in the dist/*
95
107
// TODO: test later, potentially a bundler issue
96
- const distFiles = await glob ( [ path . userServerPath ( 'dist/*.js' ) ] )
97
- for ( const file of distFiles ) {
108
+ // const distFiles = await glob([path.userServerPath('dist/*.js')])
109
+ const glob3 = new Bun . Glob ( 'dist/**/*.js' )
110
+ const scanOptions3 = { cwd : path . userServerPath ( 'dist' ) , onlyFiles : true }
111
+
112
+ for await ( const file of glob3 . scan ( scanOptions3 ) ) {
98
113
let content = await fs . readFile ( file , 'utf-8' )
99
114
if ( content . includes ( 'export { ENV_KEY, ENV_SECRET, fromEnv };' ) ) {
100
115
content = content . replace ( / e x p o r t { E N V _ K E Y , E N V _ S E C R E T , f r o m E n v } ; / g, '' )
@@ -105,11 +120,11 @@ async function main() {
105
120
}
106
121
107
122
// Process the storage folder and remove the .DS_Store files
108
- const storageFolder = path . storagePath ( )
109
- const storageFiles = await glob ( [ storageFolder , '**/*.DS_Store' ] )
123
+ const glob4 = new Bun . Glob ( '**/*.DS_Store' )
124
+ const scanOptions4 = { cwd : path . storagePath ( ) , onlyFiles : true }
110
125
111
- for ( const file of storageFiles ) {
112
- await fs . unlink ( file )
126
+ for await ( const file of glob4 . scan ( scanOptions4 ) ) {
127
+ fs . unlink ( file )
113
128
}
114
129
115
130
await outro ( {
0 commit comments