Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save CharlieEtienne/5062b950d828e5d437175d4149cf2e57 to your computer and use it in GitHub Desktop.
Save CharlieEtienne/5062b950d828e5d437175d4149cf2e57 to your computer and use it in GitHub Desktop.
php artisan tinker --execute '
$composer = json_decode(file_get_contents(base_path("composer.json")), true);
$deps = $composer["require"] ?? [];
$allPackages = collect($deps)->keys();
// Filter packages to only those that require filament/filament
$filamentPlugins = $allPackages->filter(function ($package) {
// Skip filament/filament itself
if ($package === "filament/filament") {
return true;
}
// Skip filament/* packages as they are part of the Filament ecosystem
if (str_starts_with($package, "filament/")) {
return true;
}
try {
// Check regular releases
$url = "https://repo.packagist.org/p2/{$package}.json";
$json = @file_get_contents($url);
if ($json) {
$data = json_decode($json, true);
$versions = $data["packages"][$package] ?? [];
// Check all versions, not just the latest
foreach ($versions as $version) {
$requires = $version["require"] ?? [];
if (isset($requires["filament/filament"])) {
return true;
}
}
}
// If not found in regular releases, check dev versions
$devUrl = "https://repo.packagist.org/p2/{$package}~dev.json";
$devJson = @file_get_contents($devUrl);
if ($devJson) {
$devData = json_decode($devJson, true);
$devVersions = $devData["packages"][$package] ?? [];
foreach ($devVersions as $version) {
$requires = $version["require"] ?? [];
if (isset($requires["filament/filament"])) {
return true;
}
}
}
} catch (Exception $e) {
echo "Error checking if {$package} requires filament/filament: " . $e->getMessage() . "\n";
}
return false;
});
echo "πŸ“¦ Filament plugin compatibility with v4\n\n";
echo "Found " . $filamentPlugins->count() . " packages that require filament/filament\n\n";
printf("%-40s %-20s %-15s %-20s\n", "Package", "Installed", "Compatible", "Latest v4");
echo str_repeat("-", 100) . "\n";
foreach ($filamentPlugins as $pkg) {
$version = $deps[$pkg];
$compatibility = null;
// First check regular releases
$url = "https://repo.packagist.org/p2/{$pkg}.json";
try {
$json = @file_get_contents($url);
if ($json) {
$data = json_decode($json, true);
$versions = $data["packages"][$pkg] ?? [];
foreach ($versions as $v) {
$requires = $v["require"] ?? [];
if (isset($requires["filament/filament"])) {
$constraint = $requires["filament/filament"];
// Match common constraint patterns for v4
if (preg_match("/\^4\.|~4\.|>=4\./", $constraint)) {
$compatibility = [
"version" => $v["version"],
"isPrerelease" => false
];
break;
}
}
}
}
// If no compatible version found, check dev versions
if ($compatibility === null) {
$devUrl = "https://repo.packagist.org/p2/{$pkg}~dev.json";
$devJson = @file_get_contents($devUrl);
if ($devJson) {
$devData = json_decode($devJson, true);
$devVersions = $devData["packages"][$pkg] ?? [];
foreach ($devVersions as $v) {
$requires = $v["require"] ?? [];
if (isset($requires["filament/filament"])) {
$constraint = $requires["filament/filament"];
// Match common constraint patterns for v4
if (preg_match("/\^4\.|~4\.|>=4\./", $constraint)) {
$compatibility = [
"version" => $v["version"],
"isPrerelease" => true
];
break;
}
}
}
}
}
$versionDisplay = "–";
if ($compatibility !== null) {
$versionDisplay = $compatibility["version"];
if ($compatibility["isPrerelease"]) {
$versionDisplay .= " (prerelease)";
}
}
printf("%-40s %-20s %-15s %-20s\n", $pkg, $version, $compatibility ? "βœ…" : "❌", $versionDisplay);
} catch (Exception $e) {
printf("%-40s %-20s %-15s %-20s\n", $pkg, $version, "❌", "Error: " . $e->getMessage());
}
}
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment