/
Packages.php
46 lines (34 loc) · 1.07 KB
/
Packages.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
namespace LaravelLang\Lang\Processors;
use Helldar\Support\Facades\Helpers\Arr;
use LaravelLang\Lang\Facades\Package;
final class Packages extends Processor
{
protected array $packages = [
'laravel/fortify' => 'packages/fortify.json',
'laravel/jetstream' => 'packages/jetstream.json',
];
public function run(): void
{
foreach ($this->packages as $package => $filename) {
$items = $this->files($package);
$path = $this->getSourcePath($filename);
$content = $this->map($items);
$this->sort($content);
$this->store($path, $content);
}
}
protected function map(array $items): array
{
return Arr::renameKeys($items, static fn ($key, $value) => $value);
}
protected function files(string $package): array
{
$path = $this->vendorPath($package);
return Package::some()->path($path)->content();
}
protected function vendorPath(string $package): string
{
return $this->app->path('vendor/' . $package);
}
}