Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #183 from laravel-enso/feature/version-upgrade
Feature/version upgrade
- Loading branch information
Showing
4 changed files
with
63 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace LaravelEnso\Core\Commands; | ||
|
||
use Illuminate\Console\Command; | ||
use LaravelEnso\Core\Services\Version as Service; | ||
|
||
class Version extends Command | ||
{ | ||
protected $signature = 'enso:version'; | ||
|
||
protected $description = 'Display framework version'; | ||
|
||
public function handle() | ||
{ | ||
$version = (new Service()); | ||
$this->info("Current version is {$version->current()}"); | ||
|
||
if ($version->isOutdated()) { | ||
$this->warn("Latest version is {$version->latest()}"); | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace LaravelEnso\Core\Services; | ||
|
||
use Illuminate\Support\Collection; | ||
use Illuminate\Support\Facades\Config; | ||
use Illuminate\Support\Facades\Http; | ||
|
||
class Version | ||
{ | ||
private const Endpoint = 'https://api.github.com/repos/laravel-enso/enso/releases/latest'; | ||
|
||
private $release; | ||
|
||
public function __construct() | ||
{ | ||
$this->channels = new Collection(); | ||
} | ||
|
||
public function latest() | ||
{ | ||
$this->release ??= Http::get(self::Endpoint)->json(); | ||
|
||
return $this->release['tag_name'] ?? null; | ||
} | ||
|
||
public function current() | ||
{ | ||
return Config::get('enso.config.version'); | ||
} | ||
|
||
public function isOutdated() | ||
{ | ||
return $this->current() !== $this->latest(); | ||
} | ||
} |