@sireai/optimus 0.1.23 → 0.1.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -151,6 +151,29 @@ function renderDoctorTextReport(doctor) {
151
151
  }
152
152
  return lines.join("\n");
153
153
  }
154
+ async function runWithTerminalLoading(message, action) {
155
+ if (!process.stderr.isTTY) {
156
+ return await action();
157
+ }
158
+ const frames = ["[ ]", "[. ]", "[.. ]", "[...]"];
159
+ let frameIndex = 0;
160
+ process.stderr.write(`\r${frames[frameIndex]} ${message}`);
161
+ const timer = setInterval(() => {
162
+ frameIndex = (frameIndex + 1) % frames.length;
163
+ process.stderr.write(`\r${frames[frameIndex]} ${message}`);
164
+ }, 160);
165
+ try {
166
+ const result = await action();
167
+ clearInterval(timer);
168
+ process.stderr.write(`\r[ok ] ${message}\n`);
169
+ return result;
170
+ }
171
+ catch (error) {
172
+ clearInterval(timer);
173
+ process.stderr.write(`\r[err] ${message}\n`);
174
+ throw error;
175
+ }
176
+ }
154
177
  function renderDoctorSection(title, section, extraLines = []) {
155
178
  const lines = [formatDoctorStatusHeading(title, section.status)];
156
179
  if (section.reason) {
@@ -2369,7 +2392,7 @@ async function main() {
2369
2392
  }
2370
2393
  const parsedCommandArgs = parseArgs(commandArgs);
2371
2394
  if (command === "doctor") {
2372
- const result = await runDoctor();
2395
+ const result = await runWithTerminalLoading("Running doctor checks", async () => await runDoctor());
2373
2396
  if (parsedCommandArgs.json === "true") {
2374
2397
  console.log(JSON.stringify(result, null, 2));
2375
2398
  }