|
1 | 1 | import process from 'node:process'
|
2 | 2 | import { log } from '@stacksjs/cli'
|
3 |
| -import { app, cloud as cloudConfig } from '@stacksjs/config' |
4 |
| -import { frameworkCloudPath, frameworkPath, projectPath } from '@stacksjs/path' |
5 |
| -import { hasFiles } from '@stacksjs/storage' |
6 |
| -import { $ } from 'bun' |
7 |
| - |
8 |
| -// import { slug } from '@stacksjs/strings' |
9 |
| - |
10 |
| -async function cleanAndCopy(sourcePath: string, targetPath: string) { |
11 |
| - $.cwd(frameworkPath('cloud')) |
12 |
| - await $`rm -rf ${targetPath}` |
13 |
| - await $`cp -r ${sourcePath} ${targetPath}` |
14 |
| -} |
15 |
| - |
16 |
| -async function useCustomOrDefaultServerConfig() { |
17 |
| - if (hasFiles(projectPath('server'))) { |
18 |
| - $.cwd(frameworkPath('cloud')) |
19 |
| - |
20 |
| - // if we have a custom server configuration, use it by copying it to the server directory |
21 |
| - await $`cp -r ../../../server .` |
22 |
| - |
23 |
| - return log.info('Using custom server configuration') |
24 |
| - } |
25 |
| - |
26 |
| - log.info('Using default server configuration') |
27 |
| -} |
28 |
| - |
29 |
| -async function buildServer() { |
30 |
| - log.info('Preparing server...') |
31 |
| - |
32 |
| - await cleanAndCopy(frameworkPath('core'), frameworkCloudPath('core')) |
33 |
| - await cleanAndCopy(projectPath('config'), frameworkCloudPath('config')) |
34 |
| - await cleanAndCopy(projectPath('routes'), frameworkCloudPath('routes')) |
35 |
| - await cleanAndCopy(projectPath('app'), frameworkCloudPath('app')) |
36 |
| - await cleanAndCopy(projectPath('docs'), frameworkCloudPath('docs')) |
37 |
| - await cleanAndCopy(projectPath('storage'), frameworkCloudPath('storage')) |
38 |
| - |
39 |
| - if (!app.name) { |
40 |
| - log.error('Please provide a name for your app in your config file') |
41 |
| - process.exit(1) |
42 |
| - } |
43 |
| - |
44 |
| - // TODO: also allow for a custom container name via a config option |
45 |
| - // this currently does not need to be enabled because our CDK deployment handles the docker build process |
46 |
| - // await runCommand(`docker build --pull -t ${slug(app.name)} .`, { |
47 |
| - // cwd: frameworkPath('cloud'), |
48 |
| - // }) |
49 |
| - |
50 |
| - log.success('Server ready to be built') |
51 |
| -} |
| 3 | +import { cloud } from '@stacksjs/config' |
| 4 | +import { buildServer, useCustomOrDefaultServerConfig } from './src/build' |
52 | 5 |
|
53 | 6 | async function main() {
|
54 | 7 | await useCustomOrDefaultServerConfig()
|
55 |
| - if (cloudConfig.api?.deploy) await buildServer() |
| 8 | + |
| 9 | + if (cloud.api?.deploy) |
| 10 | + await buildServer() |
56 | 11 | }
|
57 | 12 |
|
58 | 13 | main().catch((error) => {
|
|
0 commit comments