diff --git a/app/Console/Commands/CheckRelease.php b/app/Console/Commands/CheckRelease.php new file mode 100644 index 0000000..390201f --- /dev/null +++ b/app/Console/Commands/CheckRelease.php @@ -0,0 +1,71 @@ +newLine(); + if (! $xml = @simplexml_load_file('https://github.com/axeloz/filesharing/releases.atom')) { + $this->error(' Unable to fetch the releases '); + } + else { + foreach ($xml->entry as $e) { + // Title must be a version + if (! preg_match('~^[0-9]+\.[0-9]+~', $e->title)) { + continue; + } + + // Looking for the release link + foreach ($e->link->attributes() as $k => $a) { + if ($k == 'href') { + $href = $a; + } + } + + // Adding the info + array_push($releases, [ + 'version' => $e->title, + 'updated_at' => (new Carbon($e->updated))->diffForHumans(), + 'link' => $href ?? null + ]); + } + + // Displaying the releases + if (count($releases) > 0) { + $this->table([ + 'Version', 'Updated', 'Link' + ], $releases + ); + } + else { + $this->error(' No release found '); + } + } + + $this->newLine(); + } +}