Skip to content

Commit ac06387

Browse files
fix(cli): remove spinner from mongodb atlas setup
1 parent 19f155d commit ac06387

File tree

2 files changed

+16
-23
lines changed

2 files changed

+16
-23
lines changed

apps/cli/src/helpers/database-providers/mongodb-atlas-setup.ts

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import 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";
33
import consola from "consola";
44
import { execa } from "execa";
55
import fs from "fs-extra";
@@ -14,19 +14,16 @@ type MongoDBConfig = {
1414
};
1515

1616
async 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: ${

biome.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "https://biomejs.dev/schemas/2.2.4/schema.json",
2+
"$schema": "https://biomejs.dev/schemas/2.2.5/schema.json",
33
"vcs": {
44
"enabled": false,
55
"clientKind": "git",

0 commit comments

Comments
 (0)