@@ -180,26 +180,49 @@ async function setupDeployment({ rootDirectory }) {
180180
181181 const { app : APP_NAME } = flyConfig
182182
183- console . log ( `🥪 Creating app ${ APP_NAME } and ${ APP_NAME } -staging...` )
184- await $I `fly apps create ${ APP_NAME } -staging`
183+ const { shouldSetupStaging } = await inquirer . prompt ( [
184+ {
185+ name : 'shouldSetupStaging' ,
186+ type : 'confirm' ,
187+ default : true ,
188+ message : 'Would you like to set up a staging environment?' ,
189+ } ,
190+ ] )
191+
192+ console . log (
193+ `🥪 Creating app ${ APP_NAME } ${ shouldSetupStaging ? ' and staging...' : '...' } ` ,
194+ )
195+ if ( shouldSetupStaging ) {
196+ await $I `fly apps create ${ APP_NAME } -staging`
197+ }
185198 await $I `fly apps create ${ APP_NAME } `
186199
187200 console . log ( `🤫 Setting secrets in apps` )
188- await $I `fly secrets set SESSION_SECRET=${ getRandomString32 ( ) } INTERNAL_COMMAND_TOKEN=${ getRandomString32 ( ) } HONEYPOT_SECRET=${ getRandomString32 ( ) } ALLOW_INDEXING=false --app ${ APP_NAME } -staging`
201+ if ( shouldSetupStaging ) {
202+ await $I `fly secrets set SESSION_SECRET=${ getRandomString32 ( ) } INTERNAL_COMMAND_TOKEN=${ getRandomString32 ( ) } HONEYPOT_SECRET=${ getRandomString32 ( ) } ALLOW_INDEXING=false --app ${ APP_NAME } -staging`
203+ }
189204 await $I `fly secrets set SESSION_SECRET=${ getRandomString32 ( ) } INTERNAL_COMMAND_TOKEN=${ getRandomString32 ( ) } HONEYPOT_SECRET=${ getRandomString32 ( ) } --app ${ APP_NAME } `
190205
191206 console . log ( `🔊 Creating volumes.` )
192- await $I `fly volumes create data --region ${ primaryRegion } --size 1 --yes --app ${ APP_NAME } -staging`
207+ if ( shouldSetupStaging ) {
208+ await $I `fly volumes create data --region ${ primaryRegion } --size 1 --yes --app ${ APP_NAME } -staging`
209+ }
193210 await $I `fly volumes create data --region ${ primaryRegion } --size 1 --yes --app ${ APP_NAME } `
194211
195- // attach consul
196212 console . log ( `🔗 Attaching consul` )
197- await $I `fly consul attach --app ${ APP_NAME } -staging`
213+ if ( shouldSetupStaging ) {
214+ await $I `fly consul attach --app ${ APP_NAME } -staging`
215+ }
198216 await $I `fly consul attach --app ${ APP_NAME } `
199217
200218 console . log ( `🗄️ Setting up Tigris object storage` )
201- await $I `fly storage create --yes --app ${ APP_NAME } -staging`
202- await $I `fly storage create --yes --app ${ APP_NAME } `
219+ const $S = $ ( { stdio : [ 'inherit' , 'ignore' , 'inherit' ] , cwd : rootDirectory } )
220+ if ( shouldSetupStaging ) {
221+ await $S `fly storage create --yes --app ${ APP_NAME } -staging`
222+ console . log ( ` ✅ Created storage for staging` )
223+ }
224+ await $S `fly storage create --yes --app ${ APP_NAME } `
225+ console . log ( ` ✅ Created storage for production` )
203226
204227 const { shouldDeploy } = await inquirer . prompt ( [
205228 {
@@ -212,11 +235,12 @@ async function setupDeployment({ rootDirectory }) {
212235 ] )
213236 if ( shouldDeploy ) {
214237 console . log ( `🚀 Deploying apps...` )
215- console . log ( ` Starting with staging` )
216- await $I `fly deploy --app ${ APP_NAME } -staging`
217- await open ( `https://${ APP_NAME } -staging.fly.dev/` )
218-
219- console . log ( ` Staging deployed... Deploying production...` )
238+ if ( shouldSetupStaging ) {
239+ console . log ( ` Starting with staging` )
240+ await $I `fly deploy --app ${ APP_NAME } -staging`
241+ await open ( `https://${ APP_NAME } -staging.fly.dev/` )
242+ console . log ( ` Staging deployed... Deploying production...` )
243+ }
220244 await $I `fly deploy --app ${ APP_NAME } `
221245 await open ( `https://${ APP_NAME } .fly.dev/` )
222246 console . log ( ` Production deployed...` )
0 commit comments