@grada-run/grada 0.41.2 → 0.41.3

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grada-run/grada",
3
- "version": "0.41.2",
3
+ "version": "0.41.3",
4
4
  "description": "Provision production-ready AWS infrastructure and CI/CD pipelines in seconds.",
5
5
  "engines": {
6
6
  "node": ">=18.0.0"
@@ -43,8 +43,11 @@ function exitZeroForCli() {
43
43
  // Manual adopt equivalent, safe to re-run: strip any existing line
44
44
  // for the key (indented or not, present or not), then append exactly
45
45
  // one copy. A bare `echo … >>` duplicates the key on re-run and
46
- // Terraform fails hard on the redefinition.
47
- export const OIDC_ADOPT_MANUAL_COMMAND = `grep -v "^[[:space:]]*create_oidc_provider[[:space:]]*=" terraform/grada.auto.tfvars 2>/dev/null > terraform/grada.auto.tfvars.tmp; mv terraform/grada.auto.tfvars.tmp terraform/grada.auto.tfvars; echo 'create_oidc_provider = false' >> terraform/grada.auto.tfvars`;
46
+ // Terraform fails hard on the redefinition. The `|| true` keeps the
47
+ // paste alive under `set -e`: grep -v exits 1 when it selects
48
+ // nothing (single-key file), which would otherwise stop the chain
49
+ // before the move and append.
50
+ export const OIDC_ADOPT_MANUAL_COMMAND = `grep -v "^[[:space:]]*create_oidc_provider[[:space:]]*=" terraform/grada.auto.tfvars 2>/dev/null > terraform/grada.auto.tfvars.tmp || true; mv terraform/grada.auto.tfvars.tmp terraform/grada.auto.tfvars; echo 'create_oidc_provider = false' >> terraform/grada.auto.tfvars`;
48
51
 
49
52
  // Offline reconcile: an `init --offline` tree carries
50
53
  // YOUR_AWS_ACCOUNT_ID placeholders instead of an account id and has no
@@ -8,6 +8,7 @@ import { isAuthError, handleAuthErrorBranch, resolveClient } from '../../utils/a
8
8
  import { resolveRegion, resolveProjectName, resolveAppName, resolveCwd } from '../../utils/resolvers.js';
9
9
  import { findDbTarget, generateSnapshotId, isValidSnapshotId, resolveDbIdentifier, resolveDbClusterIdentifier } from '../../utils/rds.js';
10
10
  import { pollUntil, parseTimeoutSeconds } from '../../utils/system.js';
11
+ import { truncateSpinnerText } from '../../utils/spinner-text.js';
11
12
 
12
13
  export const DEFAULT_BACKUP_TIMEOUT_SECONDS = 900;
13
14
  export const DEFAULT_BACKUP_POLL_INTERVAL_MS = 5000;
@@ -137,7 +138,7 @@ async function runDbBackupMain(input = {}) {
137
138
  ? options.snapshotId.trim()
138
139
  : generateSnapshotId(target.id);
139
140
 
140
- s.message(`Creating snapshot ${snapshotId}...`);
141
+ s.message(truncateSpinnerText(`Creating snapshot ${snapshotId}...`));
141
142
  const snapshotTags = [
142
143
  { Key: 'ManagedBy', Value: 'grada' },
143
144
  { Key: 'Project', Value: projectName },
@@ -165,7 +166,7 @@ async function runDbBackupMain(input = {}) {
165
166
  return { ok: true, snapshotId, status: 'creating' };
166
167
  }
167
168
 
168
- s.message(`Waiting for snapshot ${snapshotId} to become available...`);
169
+ s.message(truncateSpinnerText(`Waiting for snapshot ${snapshotId} to become available...`));
169
170
  const outcome = await pollUntil({
170
171
  intervalMs: pollIntervalMs,
171
172
  timeoutMs,
@@ -188,7 +189,7 @@ async function runDbBackupMain(input = {}) {
188
189
  // creation (eventual consistency), so keep polling.
189
190
  const notFoundNames = isCluster ? CLUSTER_SNAPSHOT_NOT_FOUND_NAMES : SNAPSHOT_NOT_FOUND_NAMES;
190
191
  if (error && notFoundNames.has(error.name)) {
191
- s.message(`Waiting for snapshot ${snapshotId}... [${Math.floor(elapsedMs / 1000)}s]`);
192
+ s.message(truncateSpinnerText(`Waiting for snapshot ${snapshotId}... [${Math.floor(elapsedMs / 1000)}s]`));
192
193
  return { done: false };
193
194
  }
194
195
  throw error;
@@ -203,7 +204,7 @@ async function runDbBackupMain(input = {}) {
203
204
  if (snapshot && TERMINAL_SNAPSHOT_STATUSES.has(String(snapshot.Status || '').toLowerCase())) {
204
205
  return { done: true, value: { terminalFailure: true, status: snapshot.Status } };
205
206
  }
206
- s.message(`Waiting for snapshot ${snapshotId}... [${Math.floor(elapsedMs / 1000)}s]`);
207
+ s.message(truncateSpinnerText(`Waiting for snapshot ${snapshotId}... [${Math.floor(elapsedMs / 1000)}s]`));
207
208
  return { done: false };
208
209
  },
209
210
  });
@@ -14,6 +14,7 @@ import { findDbTarget, dbStatusOf, resolveDbIdentifier, resolveDbClusterIdentifi
14
14
  import { requireManagedTree, parseStateBucketBackend } from '../utils/terraform-metadata.js';
15
15
  import { guardSleepingEnv } from '../utils/sleep-state.js';
16
16
  import { normalizeOptions, parseFlags, normalizeArgv } from '../utils/args.js';
17
+ import { truncateSpinnerText } from '../utils/spinner-text.js';
17
18
 
18
19
  export const DEFAULT_DESTROY_DB_TIMEOUT_MS = 600000;
19
20
  export const DEFAULT_DESTROY_DB_SETTLE_TIMEOUT_MS = 1800000;
@@ -323,7 +324,7 @@ async function destroyStackMain(input = {}) {
323
324
  if (status === 'stopped' || status === 'available' || status === null) {
324
325
  return { done: true, value: status };
325
326
  }
326
- s.message(`Waiting for ${dbTarget.id} to settle (${status})... [${Math.floor(elapsedMs / 1000)}s]`);
327
+ s.message(truncateSpinnerText(`Waiting for ${dbTarget.id} to settle (${status})... [${Math.floor(elapsedMs / 1000)}s]`));
327
328
  return { done: false };
328
329
  },
329
330
  });
@@ -334,7 +335,7 @@ async function destroyStackMain(input = {}) {
334
335
  onTick: async ({ elapsedMs }) => {
335
336
  const status = await readStatus();
336
337
  if (status === 'available' || status === null) return { done: true, value: status };
337
- s.message(`Waiting for ${dbTarget.id} to become available... [${Math.floor(elapsedMs / 1000)}s]`);
338
+ s.message(truncateSpinnerText(`Waiting for ${dbTarget.id} to become available... [${Math.floor(elapsedMs / 1000)}s]`));
338
339
  return { done: false };
339
340
  },
340
341
  });
@@ -404,7 +405,7 @@ async function destroyStackMain(input = {}) {
404
405
  // (nothing left to protect).
405
406
  if (dbNeedsProtection) {
406
407
  const snapshotId = generateSnapshotId(dbTarget.id);
407
- s.start(`Snapshotting database ${dbTarget.id} before destruction...`);
408
+ s.start(truncateSpinnerText(`Snapshotting database ${dbTarget.id} before destruction...`));
408
409
  try {
409
410
  if (dbTarget.kind === 'cluster') {
410
411
  await rdsClient.send(new CreateDBClusterSnapshotCommand({ DBClusterSnapshotIdentifier: snapshotId, DBClusterIdentifier: dbTarget.id }));
@@ -441,7 +442,7 @@ async function destroyStackMain(input = {}) {
441
442
  // warns and proceeds — terraform reports the authoritative outcome.
442
443
  if (dbTarget && dbTarget.status !== 'deleting') {
443
444
  const isCluster = dbTarget.kind === 'cluster';
444
- s.start(`Lifting RDS deletion protection on ${dbTarget.id}...`);
445
+ s.start(truncateSpinnerText(`Lifting RDS deletion protection on ${dbTarget.id}...`));
445
446
  let lifted = false;
446
447
  try {
447
448
  if (isCluster) {
@@ -474,7 +475,7 @@ async function destroyStackMain(input = {}) {
474
475
  status = null;
475
476
  }
476
477
  if (status === 'available' || status === null || status === 'deleting') return { done: true, value: status };
477
- s.message(`Waiting for ${dbTarget.id} after lifting protection (${status})... [${Math.floor(elapsedMs / 1000)}s]`);
478
+ s.message(truncateSpinnerText(`Waiting for ${dbTarget.id} after lifting protection (${status})... [${Math.floor(elapsedMs / 1000)}s]`));
478
479
  return { done: false };
479
480
  },
480
481
  });
@@ -585,7 +586,7 @@ async function destroyStackMain(input = {}) {
585
586
  });
586
587
 
587
588
  if (deleteS3Bucket && typeof deleteS3Bucket !== 'symbol') {
588
- s.start(`Emptying and deleting S3 state bucket: ${bucketName}...`);
589
+ s.start(truncateSpinnerText(`Emptying and deleting S3 state bucket: ${bucketName}...`));
589
590
  try {
590
591
  const bucketResult = await teardownStateBucket(region, bucketName);
591
592
  const remaining = bucketResult && typeof bucketResult === 'object' && Array.isArray(bucketResult.remaining)
@@ -6,6 +6,7 @@ import { intro, outro, spinner } from '@clack/prompts';
6
6
  import { trackEvent, flushTelemetry, trackSuccess, trackFailure, setActiveCommandName, resetActiveCommandName } from '../core/telemetry.js';
7
7
  import { failCommand, failAwsError, trackAwsFailure, failProjectNotInitialized, isProgrammaticCall } from '../utils/command.js';
8
8
  import { normalizeOptions } from '../utils/args.js';
9
+ import { truncateSpinnerText } from '../utils/spinner-text.js';
9
10
  import { isAuthError, handleAuthErrorBranch, resolveClient } from '../utils/aws.js';
10
11
  import { resolveRegion, resolveProjectName, resolveCluster, resolveLogGroup, resolveCwd, readTerraformComputeTarget, guardComputeTarget, readResourceSuffix } from '../utils/resolvers.js';
11
12
  import { pickNewestRunningTask } from '../utils/ecs.js';
@@ -173,7 +174,7 @@ export async function runLambdaDiagnose(input = {}) {
173
174
  const lastUpdateStatus = configuration.LastUpdateStatus || 'UNKNOWN';
174
175
  const configUnhealthy = state !== 'Active' || lastUpdateStatus === 'Failed';
175
176
 
176
- s.message(`Fetching last ${LOG_FETCH_LIMIT} log lines for "${functionName}"...`);
177
+ s.message(truncateSpinnerText(`Fetching last ${LOG_FETCH_LIMIT} log lines for "${functionName}"...`));
177
178
  let logs = [];
178
179
  let logGroupMissing = false;
179
180
  let logFetchFailed = false;
@@ -400,7 +401,7 @@ async function runDiagnoseMain(input = {}) {
400
401
  };
401
402
  }
402
403
 
403
- s.message(`Fetching last ${LOG_FETCH_LIMIT} log lines for "${containerName}"...`);
404
+ s.message(truncateSpinnerText(`Fetching last ${LOG_FETCH_LIMIT} log lines for "${containerName}"...`));
404
405
 
405
406
  // CloudWatch stream names follow `ecs/<containerName>/<taskId>`.
406
407
  const taskId = extractTaskIdFromArn(failedTask.taskArn);
@@ -13,6 +13,7 @@ import { parseFlags, normalizeOptions, normalizeArgv } from '../utils/args.js';
13
13
  import { isAuthError, handleAwsAuthError, resolveClient } from '../utils/aws.js';
14
14
  import { resolveRegion, resolveProjectName, resolveCluster, resolveService, readFileSafe, resolveWorkspaceSuffix, resolveCwd, guardComputeTarget, readResourceSuffix } from '../utils/resolvers.js';
15
15
  import { requireManagedTree } from '../utils/terraform-metadata.js';
16
+ import { truncateSpinnerText } from '../utils/spinner-text.js';
16
17
  import { guardSleepingEnv, resolveSleepTarget } from '../utils/sleep-state.js';
17
18
  import {
18
19
  discoverEligibleRevisions as discoverWithAdapter,
@@ -301,7 +302,7 @@ async function runRollbackMain(input = {}) {
301
302
  }
302
303
 
303
304
  // 2. Trigger the rollback.
304
- s.start(`Rolling back ${service} to revision ${targetRevisionNum}...`);
305
+ s.start(truncateSpinnerText(`Rolling back ${service} to revision ${targetRevisionNum}...`));
305
306
  await ecsClient.send(new UpdateServiceCommand({
306
307
  cluster,
307
308
  service,
@@ -353,19 +354,23 @@ async function runRollbackMain(input = {}) {
353
354
  }
354
355
 
355
356
  const elapsedSec = Math.floor((Date.now() - startTime) / 1000);
357
+ // Every poll frame goes through the width budget: the
358
+ // crashing-container variant walls past 131 columns on long
359
+ // service names without it.
360
+ const progressStem = `Rolling back ${service} to revision ${targetRevisionNum}... [${elapsedSec}s]`;
356
361
  if (!primary) {
357
- s.message(`Rolling back ${service} to revision ${targetRevisionNum}... [${elapsedSec}s] (registering deployment...)`);
362
+ s.message(truncateSpinnerText(`${progressStem} (registering deployment...)`));
358
363
  } else {
359
364
  const runningCount = primary.runningCount ?? 0;
360
365
  const desiredCount = primary.desiredCount ?? 0;
361
366
  const pendingCount = primary.pendingCount ?? 0;
362
367
  const failedTasks = primary.failedTasks ?? 0;
363
368
  if (failedTasks > 0) {
364
- s.message(`Rolling back ${service} to revision ${targetRevisionNum}... [${elapsedSec}s] (${runningCount}/${desiredCount} running, ${pendingCount} pending, ${failedTasks} failed ⚠️ — container crashing)`);
369
+ s.message(truncateSpinnerText(`${progressStem} (${runningCount}/${desiredCount} running, ${pendingCount} pending, ${failedTasks} failed ⚠️ — container crashing)`));
365
370
  } else if (runningCount >= desiredCount && desiredCount > 0 && pendingCount === 0) {
366
- s.message(`Rolling back ${service} to revision ${targetRevisionNum}... [${elapsedSec}s] (${runningCount}/${desiredCount} running — draining previous tasks)`);
371
+ s.message(truncateSpinnerText(`${progressStem} (${runningCount}/${desiredCount} running — draining previous tasks)`));
367
372
  } else {
368
- s.message(`Rolling back ${service} to revision ${targetRevisionNum}... [${elapsedSec}s] (${runningCount}/${desiredCount} running, ${pendingCount} pending)`);
373
+ s.message(truncateSpinnerText(`${progressStem} (${runningCount}/${desiredCount} running, ${pendingCount} pending)`));
369
374
  }
370
375
  }
371
376
 
@@ -11,6 +11,7 @@ import { atomicWriteFile } from '../utils/atomic-write.js';
11
11
  import { handleAuthErrorBranch, resolveClient } from '../utils/aws.js';
12
12
  import { readTerraformComputeTarget, guardComputeTarget, readResourceSuffix } from '../utils/resolvers.js';
13
13
  import { requireManagedTree } from '../utils/terraform-metadata.js';
14
+ import { truncateSpinnerText } from '../utils/spinner-text.js';
14
15
 
15
16
  // Static sites provision no secrets vault, so push/pull/audit would fail
16
17
  // obscurely against a Secrets Manager secret that can never exist. One
@@ -242,7 +243,7 @@ async function pushSecretsMain(envFilePath, projectName, options = {}) {
242
243
  : path.basename(process.cwd());
243
244
 
244
245
  const s = spinner();
245
- s.start(`Reading ${envFilePath} and pushing to AWS Secrets Manager...`);
246
+ s.start(truncateSpinnerText(`Reading ${envFilePath} and pushing to AWS Secrets Manager...`));
246
247
 
247
248
  try {
248
249
  // 1. Read and parse the local .env file
@@ -7,6 +7,7 @@ import { intro, outro, spinner, confirm, cancel } from '@clack/prompts';
7
7
  import { trackEvent, trackSuccess, setActiveCommandName, resetActiveCommandName } from '../core/telemetry.js';
8
8
  import { failCommand, failAwsError, trackAwsFailure, failProjectNotInitialized, refuseIfNonInteractive, refuseUnknownFlags, shouldAutoApprove } from '../utils/command.js';
9
9
  import { parseFlags, normalizeOptions, normalizeArgv } from '../utils/args.js';
10
+ import { truncateSpinnerText } from '../utils/spinner-text.js';
10
11
  import { isAuthError, handleAuthErrorBranch, resolveClient } from '../utils/aws.js';
11
12
  import { resolveRegion, resolveProjectName, resolveCwd, readTerraformComputeTarget } from '../utils/resolvers.js';
12
13
  import { requireManagedTree } from '../utils/terraform-metadata.js';
@@ -219,7 +220,7 @@ async function runSleepMain(input = {}) {
219
220
  const runSync = options.spawnSyncImpl || spawnSync;
220
221
 
221
222
  const s = spinner();
222
- s.start(`Putting ${target.envKey} to sleep...`);
223
+ s.start(truncateSpinnerText(`Putting ${target.envKey} to sleep...`));
223
224
 
224
225
  try {
225
226
  // Read-only probes first: the fast-path check below must see live
@@ -13,6 +13,7 @@ import { requireManagedTree } from '../utils/terraform-metadata.js';
13
13
  import { findDbTarget, dbStatusOf } from '../utils/rds.js';
14
14
  import { fetchActiveService, detectTaskFailure } from '../utils/ecs.js';
15
15
  import { pollUntil } from '../utils/system.js';
16
+ import { truncateSpinnerText } from '../utils/spinner-text.js';
16
17
  import {
17
18
  resolveSleepTarget,
18
19
  readSleepState,
@@ -231,7 +232,7 @@ async function runWakeMain(input = {}) {
231
232
  }
232
233
 
233
234
  const s = spinner();
234
- s.start(`Waking ${target.envKey}...`);
235
+ s.start(truncateSpinnerText(`Waking ${target.envKey}...`));
235
236
 
236
237
  try {
237
238
  // 1. Start the database first so booting containers never
@@ -261,7 +262,7 @@ async function runWakeMain(input = {}) {
261
262
 
262
263
  if (!noWait && dbTarget && dbStarted) {
263
264
  const isCluster = dbTarget.kind === 'cluster';
264
- s.message(`Waiting for ${dbTarget.id} to become available...`);
265
+ s.message(truncateSpinnerText(`Waiting for ${dbTarget.id} to become available...`));
265
266
  const outcome = await pollUntil({
266
267
  intervalMs: pollIntervalMs,
267
268
  timeoutMs,
@@ -275,7 +276,7 @@ async function runWakeMain(input = {}) {
275
276
  ? (resp.DBClusters || [])[0] || null
276
277
  : (resp.DBInstances || [])[0] || null;
277
278
  if (dbStatusOf(current, isCluster ? 'cluster' : 'instance') === 'available') return { done: true, value: current };
278
- s.message(`Waiting for ${dbTarget.id}... [${Math.floor(elapsedMs / 1000)}s]`);
279
+ s.message(truncateSpinnerText(`Waiting for ${dbTarget.id}... [${Math.floor(elapsedMs / 1000)}s]`));
279
280
  return { done: false };
280
281
  },
281
282
  });
@@ -8,6 +8,7 @@ import { FilterLogEventsCommand, GetLogEventsCommand } from '@aws-sdk/client-clo
8
8
  import color from 'picocolors';
9
9
  import { fetchActiveService, pickRuntimeContainer } from './ecs.js';
10
10
  import { sleep, pollUntil } from './system.js';
11
+ import { truncateSpinnerText } from './spinner-text.js';
11
12
  import { isNotFoundError, buildLogStreamName } from '../commands/logs.js';
12
13
 
13
14
  export const DEFAULT_RUNNER_POLL_INTERVAL_MS = 2000;
@@ -259,7 +260,7 @@ export async function runEphemeralEcsTask({
259
260
  console.log(color.dim(` task ${taskId} — press Ctrl+C to abort and stop the remote task.\n`));
260
261
  } else if (!streaming && status && status !== lastPhase) {
261
262
  lastPhase = status;
262
- spinner?.message(phaseMessage(status));
263
+ spinner?.message(truncateSpinnerText(phaseMessage(status)));
263
264
  }
264
265
  return { done: false };
265
266
  },
@@ -0,0 +1,30 @@
1
+ // Terminal-width truncation for spinner frames. Clack re-renders the
2
+ // current frame every ~80ms, and any frame wider than the terminal
3
+ // wraps — on viewers that split frames into lines (harness PTYs, log
4
+ // capture) each wrapped frame fossilizes as extra scrollback lines.
5
+ // Every dynamic spinner message goes through here so over-width
6
+ // frames can never wall, on any terminal width.
7
+
8
+ // Spinner chrome around the message: glyph + animated dots + padding.
9
+ export const SPINNER_FRAME_OVERHEAD = 9;
10
+
11
+ // Wide terminals keep the historical 120-column cap.
12
+ export const SPINNER_TEXT_MAX = 120;
13
+
14
+ // Visible columns available for spinner text: the terminal width
15
+ // minus caller-reserved fixed text (e.g. a `Prefix - ` stem, counted
16
+ // via fixedOverhead) and spinner chrome. Floored so tiny terminals
17
+ // still show something; falls back to 80 when piped.
18
+ export function spinnerTextBudget({ columns = process.stdout?.columns ?? 80, fixedOverhead = SPINNER_FRAME_OVERHEAD } = {}) {
19
+ return Math.max(20, Math.min(SPINNER_TEXT_MAX, columns - fixedOverhead));
20
+ }
21
+
22
+ // Cuts text to the spinner budget (with `...`), code-point safe so
23
+ // emoji survive. Pass uncolored text and color after: ANSI escapes
24
+ // would count as visible columns and slicing could split them.
25
+ export function truncateSpinnerText(text, options = {}) {
26
+ const chars = Array.from(String(text ?? ''));
27
+ const budget = spinnerTextBudget(options);
28
+ if (chars.length <= budget) return chars.join('');
29
+ return `${chars.slice(0, budget - 3).join('')}...`;
30
+ }
@@ -155,11 +155,20 @@ export function upsertAutoTfvar(tfDir, key, value) {
155
155
  const created = content === '';
156
156
  const line = `${key} = ${value ? 'true' : 'false'}`;
157
157
  const pattern = new RegExp(`^[ \\t]*${key}\\s*=.*$`, 'm');
158
+ const matches = content.match(new RegExp(`^[ \\t]*${key}\\s*=.*$`, 'gm')) || [];
158
159
  let changed;
159
- if (pattern.test(content)) {
160
+ if (matches.length === 1) {
160
161
  const next = content.replace(pattern, line);
161
162
  changed = next !== content;
162
163
  content = next;
164
+ } else if (matches.length > 1) {
165
+ // Pre-existing duplicates (the old single-echo guidance ran
166
+ // twice): first-match replace would keep the dup and report
167
+ // unchanged while Terraform fails hard. Collapse to one copy.
168
+ const stripped = content.replace(new RegExp(`^[ \\t]*${key}\\s*=.*$\\n?`, 'gm'), '');
169
+ const next = `${stripped === '' ? '' : stripped.replace(/\n*$/, '\n')}${line}\n`;
170
+ changed = next !== content;
171
+ content = next;
163
172
  } else {
164
173
  const header = '# Managed by grada: machine-written variable overrides. Safe to delete an entry to restore its default.\n';
165
174
  content = `${created ? header : content.replace(/\n*$/, '\n')}${line}\n`;
@@ -5,6 +5,7 @@ import color from 'picocolors';
5
5
  import { classifyTerraformError } from './terraform-errors.js';
6
6
  import { SLEEP_STATE_DIRNAME } from './sleep-state.js';
7
7
  import { isActiveEnvValue } from '../core/telemetry.js';
8
+ import { truncateSpinnerText, SPINNER_FRAME_OVERHEAD } from './spinner-text.js';
8
9
 
9
10
  export const LAST_RUN_FILENAME = 'last-run.json';
10
11
  // Generous per-phase ceiling: CloudFront teardown and Aurora provisioning
@@ -223,16 +224,18 @@ export function runTerraformCommand(args, cwd, spin, loadingPrefix, options = {}
223
224
  if (typeof onStdoutLine === 'function') {
224
225
  for (const line of lines) onStdoutLine(line);
225
226
  }
227
+ // Both emits cut the line to the terminal budget (truncate
228
+ // before coloring so ANSI escapes never count as columns).
229
+ const lineOverhead = `${loadingPrefix} - `.length + SPINNER_FRAME_OVERHEAD;
226
230
  for (const line of lines) {
227
231
  const trimmed = line.trim();
228
232
  if (SUMMARY_LINE_RE.test(trimmed)) {
229
- emit(`${loadingPrefix} - ${color.dim(trimmed)}`);
233
+ emit(`${loadingPrefix} - ${color.dim(truncateSpinnerText(trimmed, { fixedOverhead: lineOverhead }))}`);
230
234
  }
231
235
  }
232
236
  if (lines.length > 0) {
233
237
  const latestLine = lines[lines.length - 1].trim();
234
- const display = latestLine.length > 120 ? latestLine.substring(0, 117) + '...' : latestLine;
235
- emit(`${loadingPrefix} - ${color.dim(display)}`);
238
+ emit(`${loadingPrefix} - ${color.dim(truncateSpinnerText(latestLine, { fixedOverhead: lineOverhead }))}`);
236
239
  }
237
240
  });
238
241