Skip to content

Commit 69e5fdf

Browse files
committed
chore: wip
1 parent b85eb59 commit 69e5fdf

File tree

2 files changed

+32
-17
lines changed

2 files changed

+32
-17
lines changed

storage/framework/core/build/src/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import process from 'node:process'
2-
import { bold, dim, green, italic } from '@stacksjs/cli'
2+
import { bold, dim, green, italic, log } from '@stacksjs/cli'
33
import { path as p } from '@stacksjs/path'
44
import { fs, glob } from '@stacksjs/storage'
55

@@ -39,13 +39,13 @@ export async function outro(options: {
3939
console.log(`${bold(dim(`[${timeTaken}ms]`))} Built ${italic(bold(green(pkgName)))}`)
4040
}
4141

42-
export async function intro(options: { dir: string; pkgName?: string }) {
42+
export async function intro(options: { dir: string; pkgName?: string; styled?: boolean }) {
4343
const pkgName = options.pkgName ?? `@stacksjs/${p.basename(options.dir)}`
4444

45-
console.log(`Building ${italic(pkgName)}...`)
46-
const startTime = Date.now()
45+
if (options.styled === false) console.log(`Building ${pkgName}...`)
46+
else log.info(`Building ${italic(pkgName)}...`)
4747

48-
return { startTime }
48+
return { startTime: Date.now() }
4949
}
5050

5151
export * from './utils'

storage/framework/server/build.ts

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { intro, outro } from '@stacksjs/build'
33
import { log, runCommand, runCommandSync } from '@stacksjs/cli'
44
import { cloud } from '@stacksjs/config'
55
import { path } from '@stacksjs/path'
6-
import { fs, deleteFolder, glob } from '@stacksjs/storage'
6+
import { fs, deleteFolder } from '@stacksjs/storage'
77
import { build } from 'bun'
88
import { buildDockerImage, useCustomOrDefaultServerConfig } from './src/utils'
99

@@ -61,10 +61,19 @@ async function main() {
6161
pkgName: 'server',
6262
})
6363

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+
6775
const r2 = await build({
76+
root,
6877
entrypoints: files,
6978
outdir: path.frameworkPath('server/dist/app'),
7079
format: 'esm',
@@ -80,8 +89,11 @@ async function main() {
8089
// await runCommand(`rm -rf ${path.storagePath('app')}`)
8190

8291
// 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)) {
8597
let content = await fs.readFile(file, 'utf-8')
8698
if (content.includes('storage/framework/server')) {
8799
content = content.replace(/storage\/framework\/server/g, 'dist')
@@ -93,8 +105,11 @@ async function main() {
93105
// Process files in the ./dist folder
94106
// need to remove export `{ ENV_KEY, ENV_SECRET, fromEnv };` from whatever file that contains it in the dist/*
95107
// 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)) {
98113
let content = await fs.readFile(file, 'utf-8')
99114
if (content.includes('export { ENV_KEY, ENV_SECRET, fromEnv };')) {
100115
content = content.replace(/export { ENV_KEY, ENV_SECRET, fromEnv };/g, '')
@@ -105,11 +120,11 @@ async function main() {
105120
}
106121

107122
// 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 }
110125

111-
for (const file of storageFiles) {
112-
await fs.unlink(file)
126+
for await (const file of glob4.scan(scanOptions4)) {
127+
fs.unlink(file)
113128
}
114129

115130
await outro({

0 commit comments

Comments
 (0)