-
-
Notifications
You must be signed in to change notification settings - Fork 29
Fixed Tools discovery and width calculation for box() in installer. #1961
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -397,7 +397,7 @@ protected function header(): void { | |
| EOT; | ||
|
|
||
| $logo = Tui::terminalWidth() >= 80 ? $logo_large : $logo_small; | ||
| $logo = Tui::center($logo, min(Tui::terminalWidth(), 80), '─'); | ||
| $logo = Tui::center($logo, Tui::terminalWidth(), '─'); | ||
| $logo = Tui::cyan($logo); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Reuse computed terminal width and guard math Avoid multiple - $logo = Tui::center($logo, Tui::terminalWidth(), '─');
+ $tw = Tui::terminalWidth();
+ $logo = Tui::center($logo, $tw, '─');
@@
- $logo .= PHP_EOL . Tui::dim(str_pad(sprintf('Installer version: %s', $version), Tui::terminalWidth() - 2, ' ', STR_PAD_LEFT));
+ $logo .= PHP_EOL . Tui::dim(str_pad(sprintf('Installer version: %s', $version), max(0, $tw - 2), ' ', STR_PAD_LEFT));Also applies to: 413-414 🤖 Prompt for AI Agents |
||
|
|
||
| $version = $this->getApplication()->getVersion(); | ||
|
|
@@ -410,7 +410,7 @@ protected function header(): void { | |
| $version = str_replace('@vortex-installer-version@', 'development', $version); | ||
| } | ||
|
|
||
| $logo .= PHP_EOL . Tui::dim(str_pad(sprintf('Installer version: %s', $version), min(Tui::terminalWidth(), 80) - 2, ' ', STR_PAD_LEFT)); | ||
| $logo .= PHP_EOL . Tui::dim(str_pad(sprintf('Installer version: %s', $version), Tui::terminalWidth() - 2, ' ', STR_PAD_LEFT)); | ||
|
|
||
| Tui::note($logo); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -143,15 +143,15 @@ public static function list(array $values, ?string $title): void { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| table($header, $rows); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public static function box(string $content, ?string $title = NULL, int $width = 80): void { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public static function box(string $content, ?string $title = NULL, ?int $width = NULL): void { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $rows = []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $width = min($width, static::terminalWidth()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $width = $width ?? static::terminalWidth(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // 1 margin + 1 border + 1 padding + 1 padding + 1 border + 1 margin. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $offset = 6; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $content = wordwrap($content, $width - $offset, PHP_EOL, FALSE); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $content = wordwrap($content, $width - $offset, PHP_EOL, TRUE); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+146
to
155
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Clamp wrap width and guard against width ≤ offset If public static function box(string $content, ?string $title = NULL, ?int $width = NULL): void {
$rows = [];
- $width = $width ?? static::terminalWidth();
+ $width = $width ?? static::terminalWidth();
// 1 margin + 1 border + 1 padding + 1 padding + 1 border + 1 margin.
$offset = 6;
-
- $content = wordwrap($content, $width - $offset, PHP_EOL, TRUE);
+ // Use the smaller of requested width and actual terminal width; never below 1.
+ $wrapWidth = max(1, min($width, static::terminalWidth()) - $offset);
+ $content = wordwrap($content, $wrapWidth, PHP_EOL, TRUE);
if ($title) {
- $title = wordwrap($title, $width - $offset, PHP_EOL, FALSE);
+ $title = wordwrap($title, $wrapWidth, PHP_EOL, FALSE);
$rows[] = [static::green($title)];
$rows[] = [static::green(str_repeat('─', Strings::strlenPlain(explode(PHP_EOL, static::normalizeText($title))[0]))) . PHP_EOL];
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
Comment on lines
+154
to
155
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Consider grapheme-aware wrapping for Unicode
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if ($title) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $title = wordwrap($title, $width - $offset, PHP_EOL, FALSE); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -193,8 +193,8 @@ public static function center(string $text, int $width = 80, ?string $border = N | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return implode(PHP_EOL, $centered_lines); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public static function terminalWidth(): int { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return max(20, (new Terminal())->cols()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public static function terminalWidth(int $max = 100): int { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return min($max, max(20, (new Terminal())->cols())); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public static function normalizeText(string $text): string { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
Drop unnecessary quotes to satisfy dotenv-linter
The value has no spaces; quotes aren’t needed and trigger QuoteCharacter warning.
Apply:
📝 Committable suggestion
🧰 Tools
🪛 dotenv-linter (3.3.0)
[warning] 251-251: [QuoteCharacter] The value has quote characters (', ")
(QuoteCharacter)
🤖 Prompt for AI Agents