diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2d5881f..0058baf 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,12 @@
+## [0.5.3](https://github.com/oclif/core/compare/0.5.2...0.5.3) (2024-09-11)
+
+
+### Bug Fixes
+
+* use ErrorBoundary to prevent stack traces ([6c405d0](https://github.com/oclif/core/commit/6c405d03a5c9db94d1aecc86c48b431d0c06717f))
+
+
+
## [0.5.2](https://github.com/oclif/core/compare/0.5.1...0.5.2) (2024-09-08)
diff --git a/package.json b/package.json
index 610447e..bd23e00 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "@oclif/multi-stage-output",
"description": "Terminal output for oclif commands with multiple stages",
- "version": "0.5.2-qa.0",
+ "version": "0.5.3",
"author": "Salesforce",
"bugs": "https://github.com/oclif/multi-stage-output/issues",
"dependencies": {
diff --git a/src/components/stages.tsx b/src/components/stages.tsx
index 7dc0088..8317472 100644
--- a/src/components/stages.tsx
+++ b/src/components/stages.tsx
@@ -1,6 +1,7 @@
+import {getLogger} from '@oclif/core/logger'
import {capitalCase} from 'change-case'
import {Box, Text, useStdout} from 'ink'
-import React from 'react'
+import React, {ErrorInfo} from 'react'
import {RequiredDesign, constructDesignParams} from '../design.js'
import {StageStatus, StageTracker} from '../stage-tracker.js'
@@ -531,6 +532,37 @@ export function determineCompactionLevel(
}
}
+class ErrorBoundary extends React.Component<{
+ children: React.ReactNode
+ getFallbackText?: () => string
+}> {
+ public state = {
+ hasError: false,
+ }
+
+ static getDerivedStateFromError() {
+ // Update state so the next render will show the fallback UI.
+ return {hasError: true}
+ }
+
+ componentDidCatch(error: Error, info: ErrorInfo) {
+ getLogger('multi-stage-output').debug(error)
+ getLogger('multi-stage-output').debug(info)
+ }
+
+ render() {
+ if (this.state.hasError) {
+ if (this.props.getFallbackText) {
+ return {this.props.getFallbackText()}
+ }
+
+ return false
+ }
+
+ return this.props.children
+ }
+}
+
export function Stages({
compactionLevel,
design = constructDesignParams(),
@@ -629,38 +661,52 @@ export function Stages({
{actualLevelOfCompaction < 3 && title && (
-
+ title}>
+
+
)}
{preStages && preStages.length > 0 && (
-
+ preStages.map((s) => (s.label ? `${s.label}: ${s.value}` : s.value)).join('\n')}
+ >
+
+
)}
-
+ stageTracker.current ?? 'unknown'}>
+
+
{postStages && postStages.length > 0 && (
-
+ postStages.map((s) => (s.label ? `${s.label}: ${s.value}` : s.value)).join('\n')}
+ >
+
+
)}
{hasElapsedTime && (
- Elapsed Time:
-
+
+ Elapsed Time:
+
+
)}