@oclif/multi-stage-output 0.5.2 → 0.5.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/lib/components/stages.js +34 -6
- package/package.json +3 -3
package/lib/components/stages.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getLogger } from '@oclif/core/logger';
|
|
1
2
|
import { capitalCase } from 'change-case';
|
|
2
3
|
import { Box, Text, useStdout } from 'ink';
|
|
3
4
|
import React from 'react';
|
|
@@ -237,6 +238,28 @@ export function determineCompactionLevel({ design = constructDesignParams(), has
|
|
|
237
238
|
totalHeight,
|
|
238
239
|
};
|
|
239
240
|
}
|
|
241
|
+
class ErrorBoundary extends React.Component {
|
|
242
|
+
state = {
|
|
243
|
+
hasError: false,
|
|
244
|
+
};
|
|
245
|
+
static getDerivedStateFromError() {
|
|
246
|
+
// Update state so the next render will show the fallback UI.
|
|
247
|
+
return { hasError: true };
|
|
248
|
+
}
|
|
249
|
+
componentDidCatch(error, info) {
|
|
250
|
+
getLogger('multi-stage-output').debug(error);
|
|
251
|
+
getLogger('multi-stage-output').debug(info);
|
|
252
|
+
}
|
|
253
|
+
render() {
|
|
254
|
+
if (this.state.hasError) {
|
|
255
|
+
if (this.props.getFallbackText) {
|
|
256
|
+
return React.createElement(Text, null, this.props.getFallbackText());
|
|
257
|
+
}
|
|
258
|
+
return false;
|
|
259
|
+
}
|
|
260
|
+
return this.props.children;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
240
263
|
export function Stages({ compactionLevel, design = constructDesignParams(), error, hasElapsedTime = true, hasStageTime = true, postStagesBlock, preStagesBlock, stageSpecificBlock, stageTracker, timerUnit = 'ms', title, }) {
|
|
241
264
|
const { stdout } = useStdout();
|
|
242
265
|
const [levelOfCompaction, setLevelOfCompaction] = React.useState(determineCompactionLevel({
|
|
@@ -297,14 +320,19 @@ export function Stages({ compactionLevel, design = constructDesignParams(), erro
|
|
|
297
320
|
const padding = actualLevelOfCompaction >= 8 ? 0 : 1;
|
|
298
321
|
return (React.createElement(Box, { flexDirection: "column", marginTop: padding, marginBottom: padding },
|
|
299
322
|
actualLevelOfCompaction < 3 && title && (React.createElement(Box, { paddingBottom: padding },
|
|
300
|
-
React.createElement(
|
|
323
|
+
React.createElement(ErrorBoundary, { getFallbackText: () => title },
|
|
324
|
+
React.createElement(Divider, { title: title, ...design.title, terminalWidth: stdout.columns })))),
|
|
301
325
|
preStages && preStages.length > 0 && (React.createElement(Box, { flexDirection: "column", marginLeft: 1, paddingBottom: padding },
|
|
302
|
-
React.createElement(
|
|
326
|
+
React.createElement(ErrorBoundary, { getFallbackText: () => preStages.map((s) => (s.label ? `${s.label}: ${s.value}` : s.value)).join('\n') },
|
|
327
|
+
React.createElement(Infos, { design: design, error: error, keyValuePairs: preStages })))),
|
|
303
328
|
React.createElement(Box, { flexDirection: "column", marginLeft: 1, paddingBottom: padding },
|
|
304
|
-
React.createElement(
|
|
329
|
+
React.createElement(ErrorBoundary, { getFallbackText: () => stageTracker.current ?? 'unknown' },
|
|
330
|
+
React.createElement(StageEntries, { compactionLevel: actualLevelOfCompaction, design: design, error: error, hasStageTime: hasStageTime, stageSpecificBlock: stageSpecific, stageTracker: stageTracker, timerUnit: timerUnit }))),
|
|
305
331
|
postStages && postStages.length > 0 && (React.createElement(Box, { flexDirection: "column", marginLeft: 1 },
|
|
306
|
-
React.createElement(
|
|
332
|
+
React.createElement(ErrorBoundary, { getFallbackText: () => postStages.map((s) => (s.label ? `${s.label}: ${s.value}` : s.value)).join('\n') },
|
|
333
|
+
React.createElement(Infos, { design: design, error: error, keyValuePairs: postStages })))),
|
|
307
334
|
hasElapsedTime && (React.createElement(Box, { marginLeft: 1, display: actualLevelOfCompaction < 2 ? 'flex' : 'none', flexWrap: "wrap" },
|
|
308
|
-
React.createElement(
|
|
309
|
-
|
|
335
|
+
React.createElement(ErrorBoundary, null,
|
|
336
|
+
React.createElement(Text, null, "Elapsed Time: "),
|
|
337
|
+
React.createElement(Timer, { unit: timerUnit }))))));
|
|
310
338
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oclif/multi-stage-output",
|
|
3
3
|
"description": "Terminal output for oclif commands with multiple stages",
|
|
4
|
-
"version": "0.5.
|
|
4
|
+
"version": "0.5.3",
|
|
5
5
|
"author": "Salesforce",
|
|
6
6
|
"bugs": "https://github.com/oclif/multi-stage-output/issues",
|
|
7
7
|
"dependencies": {
|
|
@@ -24,11 +24,11 @@
|
|
|
24
24
|
"commitlint": "^19",
|
|
25
25
|
"eslint": "^8.57.0",
|
|
26
26
|
"eslint-config-oclif": "^5.2.0",
|
|
27
|
-
"eslint-config-oclif-typescript": "^3.1.
|
|
27
|
+
"eslint-config-oclif-typescript": "^3.1.10",
|
|
28
28
|
"eslint-config-prettier": "^9.1.0",
|
|
29
29
|
"eslint-config-xo": "^0.45.0",
|
|
30
30
|
"eslint-config-xo-react": "^0.27.0",
|
|
31
|
-
"eslint-plugin-react": "^7.
|
|
31
|
+
"eslint-plugin-react": "^7.35.2",
|
|
32
32
|
"eslint-plugin-react-hooks": "^4.6.2",
|
|
33
33
|
"husky": "^9.1.5",
|
|
34
34
|
"ink-testing-library": "^4.0.0",
|