11import type { Subprocess } from '@stacksjs/types'
22import process from 'node:process'
3- import { log , runCommand } from '@stacksjs/cli'
3+ import { log , runCommand , spinner } from '@stacksjs/cli'
44import { config } from '@stacksjs/config'
55import { path as p } from '@stacksjs/path'
66import { storage } from '@stacksjs/storage'
77import { ExitCode } from '@stacksjs/types'
88
9- log . info ( 'Building the framework...' )
9+ // Check if verbose mode is enabled via CLI args
10+ const isVerbose = process . argv . includes ( '--verbose' ) || process . argv . includes ( '-v' )
11+
12+ // Build framework with spinner (quiet unless verbose)
13+ const buildSpinner = spinner ( 'Building framework...' )
14+ buildSpinner . start ( )
1015await runCommand ( 'bun run build' , {
1116 cwd : p . frameworkPath ( ) ,
17+ quiet : ! isVerbose ,
1218} )
13- log . success ( 'Framework built' )
19+ buildSpinner . succeed ( 'Framework built' )
1420
1521// Skip docs build for now - demo components have missing dependencies
1622// TODO: Fix demo components to use actual installed packages
1723// if (storage.hasFiles(p.projectPath('docs'))) {
18- // log.info('Building the documentation...')
24+ // const docsSpinner = spinner('Building documentation...')
25+ // docsSpinner.start()
1926// await runCommand('bun run build', {
2027// cwd: p.frameworkPath('docs'),
28+ // quiet: !isVerbose,
2129// })
22- // log.success ('Documentation built')
30+ // docsSpinner.succeed ('Documentation built')
2331// }
24- log . info ( 'Skipping documentation build (demo components need updates)' )
32+ if ( isVerbose ) log . debug ( 'Skipping documentation build (demo components need updates)' )
2533
2634// Skip views build for now - vite-config is not set up
2735// TODO: Set up vite-config for views build
2836// if (config.app.docMode !== true) {
29- // log.info('Building the views...')
37+ // const viewsSpinner = spinner('Building views...')
38+ // viewsSpinner.start()
3039// await runCommand('bun run build', {
3140// cwd: p.frameworkPath('views/web'),
41+ // quiet: !isVerbose,
3242// })
33- // log.success ('Views built')
43+ // viewsSpinner.succeed ('Views built')
3444// }
35- log . info ( 'Skipping views build (vite-config not configured)' )
45+ if ( isVerbose ) log . debug ( 'Skipping views build (vite-config not configured)' )
3646
3747// await runCommand('bun run build-edge', {
3848// cwd: p.corePath('cloud'),
3949// })
4050
41- log . info ( 'Building the server...' )
51+ // Build server
52+ const serverSpinner = spinner ( 'Building server...' )
53+ serverSpinner . start ( )
4254await runCommand ( 'bun build.ts' , {
4355 cwd : p . frameworkPath ( 'server' ) ,
56+ quiet : ! isVerbose ,
4457} )
45- log . success ( 'Server built' )
58+ serverSpinner . succeed ( 'Server built' )
4659
60+ // Package for deployment
61+ const packageSpinner = spinner ( 'Packaging for deployment...' )
62+ packageSpinner . start ( )
4763await runCommand ( 'bun zip.ts' , {
4864 cwd : p . corePath ( 'cloud' ) ,
65+ quiet : ! isVerbose ,
4966} )
50-
51- log . info ( 'Deploying using ts-cloud...' )
67+ packageSpinner . succeed ( 'Package ready' )
5268
5369// Load AWS credentials from .env.production if not already set
5470if ( ! process . env . AWS_ACCESS_KEY_ID || ! process . env . AWS_SECRET_ACCESS_KEY ) {
@@ -66,7 +82,7 @@ if (!process.env.AWS_ACCESS_KEY_ID || !process.env.AWS_SECRET_ACCESS_KEY) {
6682 else if ( key === 'AWS_SECRET_ACCESS_KEY' && value ) process . env . AWS_SECRET_ACCESS_KEY = value
6783 else if ( key === 'AWS_REGION' && value && ! process . env . AWS_REGION ) process . env . AWS_REGION = value
6884 }
69- log . success ( 'Loaded AWS credentials from .env.production' )
85+ if ( isVerbose ) log . debug ( 'Loaded AWS credentials from .env.production' )
7086 }
7187}
7288
@@ -78,27 +94,31 @@ try {
7894 const region = process . env . AWS_REGION || 'us-east-1'
7995
8096 // Step 1: Deploy infrastructure stack
81- log . info ( 'Deploying infrastructure stack...' )
97+ const deploySpinner = spinner ( 'Deploying infrastructure...' )
98+ deploySpinner . start ( )
8299 await deployStack ( {
83100 environment,
84101 region,
85102 waitForCompletion : true ,
103+ verbose : isVerbose ,
86104 } )
87- log . success ( 'Infrastructure stack deployed' )
105+ deploySpinner . succeed ( 'Infrastructure deployed' )
88106
89107 // Skip frontend deployment for now - views build is disabled
90108 // TODO: Enable frontend deployment when vite-config is set up
91109 // if (config.app.docMode !== true) {
92- // log.info('Deploying frontend...')
110+ // const frontendSpinner = spinner('Deploying frontend...')
111+ // frontendSpinner.start()
93112 // await deployFrontend({
94113 // environment,
95114 // region,
96115 // buildDir: p.frameworkPath('views/web/dist'),
97116 // })
98- // log.success ('Frontend deployed')
117+ // frontendSpinner.succeed ('Frontend deployed')
99118 // }
100- log . info ( 'Skipping frontend deployment (views build is disabled)' )
119+ if ( isVerbose ) log . debug ( 'Skipping frontend deployment (views build is disabled)' )
101120
121+ console . log ( '' )
102122 log . success ( 'Deployment completed successfully!' )
103123} catch ( error ) {
104124 log . error ( 'Deployment failed:' , error )
0 commit comments