11import path from "node:path" ;
2- import { cancel , isCancel , log , select , spinner , text } from "@clack/prompts" ;
2+ import { cancel , isCancel , log , select , text } from "@clack/prompts" ;
33import consola from "consola" ;
44import { execa } from "execa" ;
55import fs from "fs-extra" ;
@@ -14,19 +14,16 @@ type MongoDBConfig = {
1414} ;
1515
1616async function checkAtlasCLI ( ) {
17- const s = spinner ( ) ;
18- s . start ( "Checking for MongoDB Atlas CLI..." ) ;
19-
2017 try {
2118 const exists = await commandExists ( "atlas" ) ;
22- s . stop (
23- exists
24- ? "MongoDB Atlas CLI found"
25- : pc . yellow ( "MongoDB Atlas CLI not found" ) ,
26- ) ;
19+ if ( exists ) {
20+ log . info ( "MongoDB Atlas CLI found" ) ;
21+ } else {
22+ log . warn ( pc . yellow ( "MongoDB Atlas CLI not found" ) ) ;
23+ }
2724 return exists ;
2825 } catch ( _error ) {
29- s . stop ( pc . red ( "Error checking MongoDB Atlas CLI" ) ) ;
26+ log . error ( pc . red ( "Error checking MongoDB Atlas CLI" ) ) ;
3027 return false ;
3128 }
3229}
@@ -45,14 +42,15 @@ async function initMongoDBAtlas(serverDir: string) {
4542 return null ;
4643 }
4744
48- log . info ( pc . blue ( "Running MongoDB Atlas setup..." ) ) ;
45+ log . info ( "Running MongoDB Atlas setup..." ) ;
4946
5047 await execa ( "atlas" , [ "deployments" , "setup" ] , {
5148 cwd : serverDir ,
49+ shell : true ,
5250 stdio : "inherit" ,
5351 } ) ;
5452
55- log . info ( pc . green ( "MongoDB Atlas deployment ready" ) ) ;
53+ log . success ( "MongoDB Atlas deployment ready" ) ;
5654
5755 const connectionString = await text ( {
5856 message : "Enter your MongoDB connection string:" ,
@@ -126,15 +124,13 @@ export async function setupMongoDBAtlas(
126124) {
127125 const { projectDir } = config ;
128126 const manualDb = cliInput ?. manualDb ?? false ;
129- const mainSpinner = spinner ( ) ;
130- mainSpinner . start ( "Setting up MongoDB Atlas..." ) ;
131127
132128 const serverDir = path . join ( projectDir , "apps/server" ) ;
133129 try {
134130 await fs . ensureDir ( serverDir ) ;
135131
136132 if ( manualDb ) {
137- mainSpinner . stop ( "MongoDB Atlas manual setup selected" ) ;
133+ log . info ( "MongoDB Atlas manual setup selected" ) ;
138134 await writeEnvFile ( projectDir ) ;
139135 displayManualSetupInstructions ( ) ;
140136 return ;
@@ -160,18 +156,16 @@ export async function setupMongoDBAtlas(
160156 if ( isCancel ( mode ) ) return exitCancelled ( "Operation cancelled" ) ;
161157
162158 if ( mode === "manual" ) {
163- mainSpinner . stop ( "MongoDB Atlas manual setup selected" ) ;
159+ log . info ( "MongoDB Atlas manual setup selected" ) ;
164160 await writeEnvFile ( projectDir ) ;
165161 displayManualSetupInstructions ( ) ;
166162 return ;
167163 }
168164
169- mainSpinner . stop ( "MongoDB Atlas setup ready" ) ;
170-
171- const config = await initMongoDBAtlas ( serverDir ) ;
165+ const atlasConfig = await initMongoDBAtlas ( serverDir ) ;
172166
173- if ( config ) {
174- await writeEnvFile ( projectDir , config ) ;
167+ if ( atlasConfig ) {
168+ await writeEnvFile ( projectDir , atlasConfig ) ;
175169 log . success (
176170 pc . green (
177171 "MongoDB Atlas setup complete! Connection saved to .env file." ,
@@ -183,7 +177,6 @@ export async function setupMongoDBAtlas(
183177 displayManualSetupInstructions ( ) ;
184178 }
185179 } catch ( error ) {
186- mainSpinner . stop ( pc . red ( "MongoDB Atlas setup failed" ) ) ;
187180 consola . error (
188181 pc . red (
189182 `Error during MongoDB Atlas setup: ${
0 commit comments