Last active
June 20, 2025 16:32
-
-
Save CharlieEtienne/3418f407ec4af40c6de3ee0ae27c4623 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Temporary Artisan command runner | |
TMP_FILE="app/Console/Commands/__TempCheckFilamentCompat.php" | |
# Check if it's already installed | |
if [ ! -f artisan ]; then | |
echo "β This is not a Laravel project (no artisan file found)." | |
exit 1 | |
fi | |
# Write the temporary command | |
cat > $TMP_FILE <<'PHP' | |
<?php | |
namespace App\Console\Commands; | |
use Illuminate\Console\Command; | |
use Illuminate\Support\Facades\Http; | |
class __TempCheckFilamentCompat extends Command | |
{ | |
protected $signature = 'temp:check-filament-compat'; | |
protected $description = 'Check Filament plugins for v4 compatibility'; | |
public function handle() | |
{ | |
$composer = json_decode(file_get_contents(base_path('composer.json')), true); | |
$deps = $composer['require'] ?? []; | |
$plugins = collect($deps)->keys(); | |
$this->info("π¦ Checking Filament plugin compatibility with v4\n"); | |
$this->table( | |
['Package', 'Installed', 'v4 Compatible?', 'Latest v4 Version'], | |
$plugins->map(function ($pkg) use ($deps) { | |
$compat = $this->checkV4($pkg); | |
return [ | |
$pkg, | |
$deps[$pkg], | |
$compat ? 'β ' : 'β', | |
$compat ?: 'β', | |
]; | |
}) | |
); | |
unlink(__FILE__); // Clean up after running | |
} | |
protected function checkV4(string $pkg): ?string | |
{ | |
$res = @file_get_contents("https://repo.packagist.org/p2/{$pkg}.json"); | |
if (!$res) return null; | |
$data = json_decode($res, true); | |
foreach ($data['packages'][$pkg] ?? [] as $v) { | |
$req = $v['require']['filament/filament'] ?? null; | |
if ($req && preg_match('/\^4\.|~4\.|>=4\./', $req)) { | |
return $v['version']; | |
} | |
} | |
return null; | |
} | |
} | |
PHP | |
# Run the command | |
php artisan temp:check-filament-compat | |
# Remove the temp command file | |
[ -f "$TMP_FILE" ] && rm "$TMP_FILE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment