mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-01-14 15:37:53 +00:00
feat: check recipe compatibility and min_version
Some checks failed
tests / ci (push) Has been cancelled
Some checks failed
tests / ci (push) Has been cancelled
This commit is contained in:
parent
4bb5723767
commit
770b511290
2 changed files with 40 additions and 15 deletions
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
use App\Services\PluginImportService;
|
use App\Services\PluginImportService;
|
||||||
use Livewire\Volt\Component;
|
use Livewire\Volt\Component;
|
||||||
|
use Illuminate\Support\Arr;
|
||||||
use Illuminate\Support\Facades\Cache;
|
use Illuminate\Support\Facades\Cache;
|
||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
@ -26,21 +27,40 @@ new class extends Component {
|
||||||
$catalogContent = $response->body();
|
$catalogContent = $response->body();
|
||||||
$catalog = Yaml::parse($catalogContent);
|
$catalog = Yaml::parse($catalogContent);
|
||||||
|
|
||||||
return collect($catalog)->map(function ($plugin, $key) {
|
$currentVersion = config('app.version');
|
||||||
|
|
||||||
|
return collect($catalog)
|
||||||
|
->filter(function ($plugin) use ($currentVersion) {
|
||||||
|
// Check if Laravel compatibility is true
|
||||||
|
if (!Arr::get($plugin, 'byos.byos_laravel.compatibility', false)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check minimum version if specified
|
||||||
|
$minVersion = Arr::get($plugin, 'byos.byos_laravel.min_version');
|
||||||
|
if ($minVersion && $currentVersion && version_compare($currentVersion, $minVersion, '<')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
})
|
||||||
|
->map(function ($plugin, $key) {
|
||||||
return [
|
return [
|
||||||
'id' => $key,
|
'id' => $key,
|
||||||
'name' => $plugin['name'] ?? 'Unknown Plugin',
|
'name' => Arr::get($plugin, 'name', 'Unknown Plugin'),
|
||||||
'description' => $plugin['author_bio']['description'] ?? '',
|
'description' => Arr::get($plugin, 'author_bio.description', ''),
|
||||||
'author' => $plugin['author']['name'] ?? 'Unknown Author',
|
'author' => Arr::get($plugin, 'author.name', 'Unknown Author'),
|
||||||
'github' => $plugin['author']['github'] ?? null,
|
'github' => Arr::get($plugin, 'author.github'),
|
||||||
'license' => $plugin['license'] ?? null,
|
'license' => Arr::get($plugin, 'license'),
|
||||||
'zip_url' => $plugin['trmnlp']['zip_url'] ?? null,
|
'zip_url' => Arr::get($plugin, 'trmnlp.zip_url'),
|
||||||
'repo_url' => $plugin['trmnlp']['repo'] ?? null,
|
'repo_url' => Arr::get($plugin, 'trmnlp.repo'),
|
||||||
'logo_url' => $plugin['logo_url'] ?? null,
|
'logo_url' => Arr::get($plugin, 'logo_url'),
|
||||||
'screenshot_url' => $plugin['screenshot_url'] ?? null,
|
'screenshot_url' => Arr::get($plugin, 'screenshot_url'),
|
||||||
'learn_more_url' => $plugin['author_bio']['learn_more_url'] ?? null,
|
'learn_more_url' => Arr::get($plugin, 'author_bio.learn_more_url'),
|
||||||
];
|
];
|
||||||
})->toArray();
|
})
|
||||||
|
->sortBy('name')
|
||||||
|
->toArray();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
Log::error('Failed to load catalog from URL: ' . $e->getMessage());
|
Log::error('Failed to load catalog from URL: ' . $e->getMessage());
|
||||||
return [];
|
return [];
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,11 @@ it('loads plugins from catalog URL', function () {
|
||||||
'trmnlp' => [
|
'trmnlp' => [
|
||||||
'zip_url' => 'https://example.com/plugin.zip',
|
'zip_url' => 'https://example.com/plugin.zip',
|
||||||
],
|
],
|
||||||
|
'byos' => [
|
||||||
|
'byos_laravel' => [
|
||||||
|
'compatibility' => true,
|
||||||
|
]
|
||||||
|
],
|
||||||
'logo_url' => 'https://example.com/logo.png',
|
'logo_url' => 'https://example.com/logo.png',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue