Skip to content

Commit d8884e0

Browse files
committed
last changes
1 parent 8118ebf commit d8884e0

File tree

5 files changed

+54
-4
lines changed

5 files changed

+54
-4
lines changed

src/BoostServiceProvider.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ protected function registerCommands(): void
9191
$this->commands([
9292
Console\StartCommand::class,
9393
Console\InstallCommand::class,
94+
Console\UpdateCommand::class,
9495
Console\ExecuteToolCommand::class,
9596
]);
9697
}

src/Console/InstallCommand.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,10 @@ protected function outro(): void
194194
$text = 'Enjoy the boost 🚀 Next steps: ';
195195
$paddingLength = (int) (floor(($this->terminal->cols() - mb_strlen($text.$label)) / 2)) - 2;
196196

197-
echo "\033[42m\033[2K".str_repeat(' ', max(0, $paddingLength)); // Make the entire line have a green background
198-
echo $this->black($this->bold($text.$link)).$this->reset(PHP_EOL).$this->reset(PHP_EOL);
197+
$this->output->write([
198+
"\033[42m\033[2K".str_repeat(' ', max(0, $paddingLength)),
199+
$this->black($this->bold($text.$link)).$this->reset(PHP_EOL).$this->reset(PHP_EOL),
200+
]);
199201
}
200202

201203
protected function hyperlink(string $label, string $url): string

src/Console/UpdateCommand.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Laravel\Boost\Console;
6+
7+
use Exception;
8+
use Illuminate\Console\Command;
9+
use Illuminate\Support\Arr;
10+
use Illuminate\Support\Collection;
11+
use Illuminate\Support\Str;
12+
use InvalidArgumentException;
13+
use Laravel\Boost\Contracts\Agent;
14+
use Laravel\Boost\Contracts\McpClient;
15+
use Laravel\Boost\Install\Cli\DisplayHelper;
16+
use Laravel\Boost\Install\CodeEnvironment\CodeEnvironment;
17+
use Laravel\Boost\Install\CodeEnvironmentsDetector;
18+
use Laravel\Boost\Install\GuidelineComposer;
19+
use Laravel\Boost\Install\GuidelineConfig;
20+
use Laravel\Boost\Install\GuidelineWriter;
21+
use Laravel\Boost\Install\Herd;
22+
use Laravel\Boost\Support\Config;
23+
use Laravel\Prompts\Concerns\Colors;
24+
use Laravel\Prompts\Terminal;
25+
use Symfony\Component\Console\Attribute\AsCommand;
26+
use Symfony\Component\Finder\Finder;
27+
use Symfony\Component\Process\Process;
28+
29+
use function Laravel\Prompts\confirm;
30+
use function Laravel\Prompts\intro;
31+
use function Laravel\Prompts\multiselect;
32+
use function Laravel\Prompts\note;
33+
34+
#[AsCommand('boost:update', 'Updates Laravel Boost Guidelines to the latest version.')]
35+
class UpdateCommand extends Command
36+
{
37+
public function handle(): void
38+
{
39+
$this->callSilently(InstallCommand::class, [
40+
'--no-interaction' => true,
41+
]);
42+
43+
$this->components->info('Boost Guidelines have been updated successfully.');
44+
}
45+
}

src/Install/GuidelineComposer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ protected function guideline(string $path, bool $thirdParty = false): array
299299
'path' => $path,
300300
'custom' => str_contains($path, $this->customGuidelinePath()),
301301
'third_party' => $thirdParty,
302-
'tokens' => str_word_count($rendered) * 1.3, // Rough estimate of tokens based on word count
302+
'tokens' => round(str_word_count($rendered) * 1.3),
303303
];
304304
}
305305

src/Support/Config.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,12 @@ protected function get(string $key, mixed $default = null): mixed
8080

8181
protected function set(string $key, mixed $value): void
8282
{
83-
$config = $this->all();
83+
$config = array_filter($this->all());
8484

8585
data_set($config, $key, $value);
8686

87+
ksort($config);
88+
8789
$path = base_path(self::FILE);
8890

8991
file_put_contents($path, Str::of(json_encode($config, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES))->append(PHP_EOL));

0 commit comments

Comments
 (0)