Skip to content

Commit 46eabe9

Browse files
committed
chore: wip
1 parent 17a9ade commit 46eabe9

File tree

10 files changed

+89
-108
lines changed

10 files changed

+89
-108
lines changed

routes/api.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,22 @@ await route.get('/welcome', () => {
1818
}
1919
})
2020

21-
route.get('/hello/world', () => 'hello world, buddy') // stacksjs.org/api/hello/world
21+
await route.get('/hello/world', () => 'hello world, buddy') // stacksjs.org/api/hello/world
22+
await route.get('/buddy/versions', 'Actions/Buddy/VersionsAction')
23+
await route.get('/buddy/commands', 'Actions/Buddy/CommandsAction')
2224

23-
// route.group('/buddy', () => { // you may group your routes in a few different ways
24-
// route.get('/commands', 'Actions/Buddy/CommandsAction')
25+
// await route.group('/buddy', async () => { // you may group your routes in a few different ways
26+
// await route.get('/commands', 'Actions/Buddy/CommandsAction')
2527

2628
// // nested groups are also supported
27-
// route.group({ prefix: 'commands' }, () => {
28-
// route.get('/example-two', import('Actions/Buddy/CommandsAction')) // or import the action directly
29+
// await route.group({ prefix: 'commands' }, async () => {
30+
// await route.get('/example-two', import('Actions/Buddy/CommandsAction')) // or import the action directly
2931
// })
3032

31-
// route.get('/versions', '../app/Actions/Buddy/VersionsAction') // a relative path is accepted as well
33+
// await route.get('/versions', '../app/Actions/Buddy/VersionsAction') // a relative path is accepted as well
3234
// })
3335

34-
// route.action('/example') // the equivalent of route.get('/example', 'ExampleAction')
35-
// route.job('/example-two') // the equivalent of route.get('/example-two', 'ExampleTwoJob')
36+
// await route.action('/example') // the equivalent of route.get('/example', 'ExampleAction')
37+
// await route.job('/example-two') // the equivalent of route.get('/example-two', 'ExampleTwoJob')
3638

37-
route.health() // adds an `/api/health` route
39+
await route.health() // adds an `/api/health` route

storage/framework/core/api/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
"@stacksjs/utils": "workspace:*"
5353
},
5454
"dependencies": {
55-
"@flareapp/flare-client": "^3.0.5",
5655
"@stacksjs/utils": "workspace:*",
5756
"ofetch": "^1.3.3"
5857
},

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { ofetch } from 'ofetch'
22
import type { FetchOptions } from 'ofetch'
3+
34
interface Params {
45
[key: string]: any // Replace 'any' with more specific types if possible
56
}

storage/framework/core/router/src/router.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ export class Router implements RouterInterface {
141141
}
142142

143143
public group(options: string | RouteGroupOptions, callback?: () => void): this {
144+
if (typeof options === 'string')
145+
options = options.startsWith('/') ? options.slice(1) : options
146+
144147
let cb: () => void
145148

146149
this.prepareGroupPrefix(options)
@@ -149,14 +152,13 @@ export class Router implements RouterInterface {
149152
cb = options
150153
options = {}
151154
}
152-
else {
153-
if (!callback)
154-
throw new Error('Missing callback function for your route group.')
155155

156-
cb = callback
157-
}
156+
if (!callback)
157+
throw new Error('Missing callback function for your route group.')
158+
159+
cb = callback
158160

159-
const { prefix = '', middleware = [] } = options as RouteGroupOptions
161+
const { prefix, middleware = [] } = options as RouteGroupOptions
160162

161163
// Save a reference to the original routes array
162164
const originalRoutes = this.routes

storage/framework/core/types/src/ui.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import type { UserShortcuts } from 'unocss'
2+
import type { UserConfig } from '@unocss/core'
23

34
export type Font = 'inter' | 'mona' | 'hubot'
45
export type Icon = 'heroicons'
56
export type WebFontsProviders = 'google' | 'bunny' | 'fontshare'
7+
export type Shortcuts = UserShortcuts
68

79
export interface FontInfo {
810
title: string
@@ -161,17 +163,21 @@ export interface UiOptions {
161163
icons: Icon | Icon[]
162164
// icons: Record<string, () => Promise<any>>
163165

164-
theme: {
165-
colors: Record<string, string>
166-
fontSize: Record<string, string>
167-
spacing: Record<string, string>
168-
}
166+
theme: UserConfig['theme']
167+
// plugins: UserConfig['plugins']
168+
// corePlugins: UserConfig['corePlugins']
169+
variants: UserConfig['variants']
170+
layers: UserConfig['layers']
171+
// darkMode: UserConfig['darkMode']
172+
// extend: UserConfig['extend']
173+
// screens: UserConfig['screens']
174+
// spacing: UserConfig['spacing']
175+
// backgroundColor: UserConfig['backgroundColor']
176+
// backgroundImage: UserConfig['backgroundImage']
169177
}
170178

171179
export type UiConfig = Partial<UiOptions>
172180

173-
export type Shortcuts = UserShortcuts
174-
175181
/**
176182
* **Style Reset — Preset**
177183
*

storage/framework/server/.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ helm-charts
1313
.editorconfig
1414
.idea
1515
coverage*
16+
core/*/cdk.out/

storage/framework/server/Dockerfile

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ RUN mkdir -p /temp/dev
1414
COPY package.json /temp/dev/
1515
COPY tsconfig.json /temp/dev/
1616
COPY core/ /temp/dev/core/
17+
1718
RUN cd /temp/dev && bun install
18-
# RUN cd /temp/dev && bun install --frozen-lockfile
1919

2020
# install with --production (exclude devDependencies)
2121
RUN mkdir -p /temp/prod
@@ -30,16 +30,7 @@ RUN cd /temp/prod && bun install
3030
# then copy all (non-ignored) project files into the image
3131
FROM base AS prerelease
3232
COPY --from=install /temp/dev/node_modules ./node_modules
33-
COPY ./Actions ./Actions
34-
COPY ./app ./app
35-
COPY ./config ./config
36-
COPY ./core ./core
37-
COPY ./docs ./docs
38-
COPY ./routes ./routes
39-
COPY ./storage ./storage
40-
COPY ./index.ts ./index.ts
41-
COPY ./package.json ./package.json
42-
COPY ./tsconfig.json ./tsconfig.json
33+
COPY . .
4334

4435
# [optional] tests & build
4536
# ENV NODE_ENV=production
@@ -49,16 +40,15 @@ COPY ./tsconfig.json ./tsconfig.json
4940
# copy production dependencies and source code into final image
5041
FROM base AS release
5142
COPY --from=install /temp/prod/node_modules ./node_modules
52-
COPY --from=prerelease /usr/src/app/index.ts ./index.ts
53-
COPY --from=prerelease /usr/src/app/tsconfig.json ./tsconfig.json
54-
COPY --from=prerelease /usr/src/app/package.json ./package.json
55-
COPY --from=prerelease /usr/src/app/Actions ./Actions
5643
COPY --from=prerelease /usr/src/app/app ./app
5744
COPY --from=prerelease /usr/src/app/config ./config
5845
COPY --from=prerelease /usr/src/app/core ./core
5946
COPY --from=prerelease /usr/src/app/docs ./docs
6047
COPY --from=prerelease /usr/src/app/routes ./routes
6148
COPY --from=prerelease /usr/src/app/storage ./storage
49+
COPY --from=prerelease /usr/src/app/index.ts ./index.ts
50+
COPY --from=prerelease /usr/src/app/tsconfig.json ./tsconfig.json
51+
COPY --from=prerelease /usr/src/app/package.json ./package.json
6252

6353
# run the app
6454
USER bun

storage/framework/server/build.ts

Lines changed: 42 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -5,81 +5,60 @@ import { log, runCommand } from '@stacksjs/cli'
55
import { app } from '@stacksjs/config'
66
import { slug } from '@stacksjs/strings'
77

8-
// TODO: we cannot use Bun Shell scripts here yet because we need to use 1.0.8 for deployments, and Shell scripts were introduced after 1.0.8
9-
// this allows for a custom "server configuration" by the user
10-
if (hasFiles(projectPath('server'))) {
11-
await runCommand(`rm -rf ../../../server/build.ts`, {
12-
cwd: projectPath('server'),
13-
})
14-
await runCommand(`cp -r ../../../server .`, {
15-
cwd: projectPath('server'),
8+
async function cleanAndCopy(sourcePath: string, targetPath: string) {
9+
await runCommand(`rm -rf ${targetPath}`, {
10+
cwd: frameworkPath('server'),
1611
})
1712

18-
log.info('Using custom server configuration')
19-
}
20-
else {
21-
log.info('Using default server configuration')
13+
await runCommand(`cp -r ${sourcePath} ${targetPath}`, {
14+
cwd: frameworkPath('server'),
15+
})
2216
}
2317

24-
log.info('Building server...')
18+
async function useCustomOrDefaultServerConfig() {
19+
if (hasFiles(projectPath('server'))) {
20+
await runCommand(`rm -rf ../../../server/build.ts`, {
21+
cwd: projectPath('server'),
22+
})
23+
await runCommand(`cp -r ../../../server .`, {
24+
cwd: projectPath('server'),
25+
})
2526

26-
await runCommand(`rm -rf ${frameworkPath('server/core')}`, {
27-
cwd: frameworkPath('server'),
28-
})
29-
await runCommand(`cp -r ${frameworkPath('core')} ${frameworkPath('server/core')}`, {
30-
cwd: frameworkPath('server'),
31-
})
27+
return log.info('Using custom server configuration')
28+
}
3229

33-
await runCommand(`rm -rf ${frameworkPath('server/config')}`, {
34-
cwd: frameworkPath('server'),
35-
})
36-
await runCommand(`cp -r ${projectPath('config')} ${frameworkPath('server/config')}`, {
37-
cwd: frameworkPath('server'),
38-
})
30+
log.info('Using default server configuration')
31+
}
3932

40-
await runCommand(`rm -rf ${frameworkPath('server/routes')}`, {
41-
cwd: frameworkPath('server'),
42-
})
43-
await runCommand(`cp -r ${projectPath('routes')} ${frameworkPath('server/routes')}`, {
44-
cwd: frameworkPath('server'),
45-
})
33+
async function buildServer() {
34+
log.info('Building server...')
4635

47-
await runCommand(`rm -rf ${frameworkPath('server/app')}`, {
48-
cwd: frameworkPath('server'),
49-
})
50-
await runCommand(`cp -r ${projectPath('app')} ${frameworkPath('server/app')}`, {
51-
cwd: frameworkPath('server'),
52-
})
36+
await cleanAndCopy(frameworkPath('core'), frameworkPath('server/core'))
37+
await cleanAndCopy(projectPath('config'), frameworkPath('server/config'))
38+
await cleanAndCopy(projectPath('routes'), frameworkPath('server/routes'))
39+
await cleanAndCopy(projectPath('app'), frameworkPath('server/app'))
40+
await cleanAndCopy(projectPath('docs'), frameworkPath('server/docs'))
41+
await cleanAndCopy(projectPath('storage'), frameworkPath('server/storage'))
5342

54-
await runCommand(`rm -rf ${frameworkPath('server/docs')}`, {
55-
cwd: frameworkPath('server'),
56-
})
57-
await runCommand(`cp -r ${projectPath('docs')} ${frameworkPath('server/docs')}`, {
58-
cwd: frameworkPath('server'),
59-
})
43+
if (!app.name) {
44+
log.error('Please provide a name for your app in your config file')
45+
process.exit(1)
46+
}
6047

61-
await runCommand(`rm -rf ${frameworkPath('server/Actions')}`, {
62-
cwd: frameworkPath('server'),
63-
})
64-
await runCommand(`cp -r ${projectPath('app/Actions')} ${frameworkPath('server/Actions')}`, {
65-
cwd: frameworkPath('server'),
66-
})
48+
// TODO: also allow for a custom container name via a config option
49+
await runCommand(`docker build --pull -t ${slug(app.name)} .`, {
50+
cwd: frameworkPath('server'),
51+
})
6752

68-
await runCommand(`rm -rf ${frameworkPath('server/storage')}`, {
69-
cwd: frameworkPath('server'),
70-
})
71-
await runCommand(`cp -r ${projectPath('storage')} ${frameworkPath('server/storage')}`, {
72-
cwd: frameworkPath('server'),
73-
})
53+
log.success('Server built')
54+
}
7455

75-
if (!app.name) {
76-
log.error('Please provide a name for your app in your config file')
77-
process.exit(1)
56+
async function main() {
57+
useCustomOrDefaultServerConfig()
58+
await buildServer()
7859
}
7960

80-
// TODO: also allow for a custom container name via a config option
81-
await runCommand(`docker build --pull -t ${slug(app.name)} .`, {
82-
cwd: frameworkPath('server'),
61+
main().catch((error) => {
62+
log.error(`Build failed: ${error}`)
63+
process.exit(1)
8364
})
84-
85-
log.success('Server built')

storage/framework/server/dev

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
77
PROJECT_ROOT=$(cd "$SCRIPT_DIR/../../../" && pwd)
88

99
# Construct the absolute paths
10-
ACTIONS_DIR="$PROJECT_ROOT/app/Actions"
1110
APP_DIR="$PROJECT_ROOT/app"
1211
CONFIG_DIR="$PROJECT_ROOT/config"
1312
DOCS_DIR="$PROJECT_ROOT/docs"
@@ -26,7 +25,6 @@ else # Local environment
2625
fi
2726

2827
docker run -p 3000:3000 \
29-
-v "$ACTIONS_DIR:/usr/src/app/Actions" \
3028
-v "$APP_DIR:/usr/src/app/app" \
3129
-v "$CONFIG_DIR:/usr/src/app/config" \
3230
-v "$DOCS_DIR:/usr/src/app/docs" \

storage/framework/server/tsconfig.json

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@
1111
"module": "esnext",
1212
"moduleResolution": "bundler",
1313
"paths": {
14-
"@stacksjs/*": ["./core/*/src"],
15-
"stacks/*": ["./core/*/src"],
16-
"buddy": ["./core/buddy/src/index.ts"],
17-
"buddy/*": ["./core/buddy/src/*"],
18-
"../../../env": ["./env.ts"]
14+
"@stacksjs/*": ["./storage/framework/core/*/src"],
15+
"stacks/*": ["./storage/framework/core/*/src"],
16+
"buddy": ["./storage/framework/core/buddy/src/index.ts"],
17+
"buddy/*": ["./storage/framework/core/buddy/src/*"],
18+
"Actions/*": ["./app/Actions/*"],
19+
"Jobs/*": ["./app/Jobs/*"],
20+
"~/*": ["./*"],
21+
"../../../env": ["./storage/framework/env.ts"]
1922
},
2023
"resolveJsonModule": true,
2124
"types": [

0 commit comments

Comments
 (0)