@oclif/multi-stage-output
Advanced tools
Comparing version 0.5.4 to 0.5.5
@@ -5,2 +5,3 @@ import { getLogger } from '@oclif/core/logger'; | ||
import React from 'react'; | ||
import wrapAnsi from 'wrap-ansi'; | ||
import { constructDesignParams } from '../design.js'; | ||
@@ -126,7 +127,5 @@ import { Divider } from './divider.js'; | ||
const estimatedTimeLength = 11; | ||
const calculateWrappedHeight = (length) => { | ||
if (length > columns) { | ||
return Math.ceil(length / columns); | ||
} | ||
return 1; | ||
const calculateWrappedHeight = (text) => { | ||
const wrapped = wrapAnsi(text, columns, { hard: true, trim: false, wordWrap: true }); | ||
return wrapped.split('\n').length; | ||
}; | ||
@@ -142,3 +141,3 @@ const calculateHeightOfBlock = (block) => { | ||
// if the message is longer than the terminal width, add the number of lines | ||
return acc + calculateWrappedHeight(info.value.length); | ||
return acc + calculateWrappedHeight(info.value); | ||
} | ||
@@ -155,3 +154,3 @@ // if the message is multiline, add the number of lines | ||
// if the value is longer than the terminal width, add the number of lines | ||
return acc + calculateWrappedHeight(totalLength); | ||
return acc + calculateWrappedHeight(`${label}: ${value}`); | ||
} | ||
@@ -165,9 +164,11 @@ return acc + value.split('\n').length; | ||
const stageTimeLength = hasStageTime ? estimatedTimeLength : 0; | ||
const totalLength = design.icons[status].paddingLeft + | ||
design.icons[status].figure.length + | ||
design.icons[status].paddingRight + | ||
stage.length + | ||
skipped.length + | ||
stageTimeLength; | ||
return calculateWrappedHeight(totalLength); | ||
const parts = [ | ||
' '.repeat(design.icons[status].paddingLeft), | ||
design.icons[status].figure, | ||
' '.repeat(design.icons[status].paddingRight), | ||
stage, | ||
skipped, | ||
'0'.repeat(stageTimeLength), | ||
]; | ||
return calculateWrappedHeight(parts.join('')); | ||
}; | ||
@@ -201,4 +202,6 @@ const calculateWidthOfCompactStage = (stage) => { | ||
const paddings = 3 + (preStagesBlock ? 1 : 0) + (postStagesBlock ? 1 : 0) + (title ? 1 : 0); | ||
const elapsedTimeHeight = hasElapsedTime ? calculateWrappedHeight('Elapsed Time:'.length + estimatedTimeLength) : 0; | ||
const titleHeight = title ? calculateWrappedHeight(title.length) : 0; | ||
const elapsedTimeHeight = hasElapsedTime | ||
? calculateWrappedHeight(`Elapsed Time:${'0'.repeat(estimatedTimeLength)}`) | ||
: 0; | ||
const titleHeight = title ? calculateWrappedHeight(title) : 0; | ||
const totalHeight = stagesHeight + | ||
@@ -205,0 +208,0 @@ preStagesBlockHeight + |
{ | ||
"name": "@oclif/multi-stage-output", | ||
"description": "Terminal output for oclif commands with multiple stages", | ||
"version": "0.5.4", | ||
"version": "0.5.5", | ||
"author": "Salesforce", | ||
@@ -14,3 +14,4 @@ "bugs": "https://github.com/oclif/multi-stage-output/issues", | ||
"ink": "^5.0.1", | ||
"react": "^18.3.1" | ||
"react": "^18.3.1", | ||
"wrap-ansi": "^9.0.0" | ||
}, | ||
@@ -17,0 +18,0 @@ "devDependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
66580
1415
8
+ Addedwrap-ansi@^9.0.0