@poppinss/cliui
Advanced tools
Comparing version 6.0.0-0 to 6.1.0-0
@@ -14,3 +14,4 @@ import type { Colors } from '@poppinss/colors/types'; | ||
add(text: string): this; | ||
prepare(): string; | ||
render(): void; | ||
} |
@@ -5,2 +5,3 @@ import boxes from 'cli-boxes'; | ||
import { useColors } from './colors.js'; | ||
import { TERMINAL_SIZE } from './helpers.js'; | ||
import { ConsoleRenderer } from './renderers/console.js'; | ||
@@ -101,4 +102,3 @@ const BOX = boxes.round; | ||
const borderWidth = 2; | ||
this.#widestLineLength = | ||
process.stdout.columns - (this.#leftPadding + this.#rightPadding) - borderWidth; | ||
this.#widestLineLength = TERMINAL_SIZE - (this.#leftPadding + this.#rightPadding) - borderWidth; | ||
return this; | ||
@@ -127,8 +127,10 @@ } | ||
} | ||
render() { | ||
const renderer = this.getRenderer(); | ||
prepare() { | ||
if (this.#options.raw) { | ||
this.#state.heading && renderer.log(this.#state.heading.text); | ||
this.#state.content.forEach(({ text }) => renderer.log(text)); | ||
return; | ||
let output = []; | ||
if (this.#state.heading) { | ||
output.push(this.#state.heading.text); | ||
} | ||
output = output.concat(this.#state.content.map(({ text }) => text)); | ||
return output.join('\n'); | ||
} | ||
@@ -150,4 +152,7 @@ const top = this.#getTopLine(); | ||
} | ||
renderer.log(`${output}\n${bottom}`); | ||
return `${output}\n${bottom}`; | ||
} | ||
render() { | ||
this.getRenderer().log(this.prepare()); | ||
} | ||
} |
import CliTable from 'cli-table3'; | ||
import stringWidth from 'string-width'; | ||
import { useColors } from './colors.js'; | ||
import { TERMINAL_SIZE } from './helpers.js'; | ||
import { ConsoleRenderer } from './renderers/console.js'; | ||
@@ -36,3 +37,3 @@ export class Table { | ||
} | ||
let columns = process.stdout.columns - (this.#columnSizes.length + 1); | ||
let columns = TERMINAL_SIZE - (this.#columnSizes.length + 1); | ||
this.#state.colWidths = this.#state.colWidths || []; | ||
@@ -39,0 +40,0 @@ this.#columnSizes.forEach((column, index) => { |
{ | ||
"name": "@poppinss/cliui", | ||
"version": "6.0.0-0", | ||
"version": "6.1.0-0", | ||
"description": "Opinionated UI KIT for Command Line apps", | ||
@@ -47,2 +47,3 @@ "main": "build/index.js", | ||
"@types/pretty-hrtime": "^1.0.1", | ||
"@types/wordwrap": "^1.0.1", | ||
"cross-env": "^7.0.3", | ||
@@ -63,9 +64,12 @@ "del-cli": "^5.0.0", | ||
"dependencies": { | ||
"@poppinss/colors": "^4.0.0-1", | ||
"@poppinss/colors": "^4.1.0-0", | ||
"cli-boxes": "^3.0.0", | ||
"cli-table3": "^0.6.3", | ||
"cli-truncate": "^3.1.0", | ||
"log-update": "^5.0.1", | ||
"pretty-hrtime": "^1.0.3", | ||
"string-width": "^5.1.2", | ||
"supports-color": "^9.3.1" | ||
"supports-color": "^9.3.1", | ||
"term-size": "^3.0.2", | ||
"wordwrap": "^1.0.0" | ||
}, | ||
@@ -72,0 +76,0 @@ "repository": { |
@@ -387,3 +387,3 @@ # @poppinss/cliui | ||
[gh-workflow-image]: https://img.shields.io/github/workflow/status/poppinss/cliui/test?style=for-the-badge | ||
[gh-workflow-image]: https://img.shields.io/github/actions/workflow/status/poppinss/cliui/test.yml?style=for-the-badge | ||
[gh-workflow-url]: https://github.com/poppinss/cliui/actions/workflows/test.yml "Github action" | ||
@@ -390,0 +390,0 @@ |
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
68265
37
1613
10
23
+ Addedcli-truncate@^3.1.0
+ Addedterm-size@^3.0.2
+ Addedwordwrap@^1.0.0
+ Addedcli-truncate@3.1.0(transitive)
+ Addedterm-size@3.0.2(transitive)
+ Addedwordwrap@1.0.0(transitive)
Updated@poppinss/colors@^4.1.0-0