-
Notifications
You must be signed in to change notification settings - Fork 0
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 #23 from artemeon/feat/improve-update
Feat/improve update
- Loading branch information
Showing
6 changed files
with
50 additions
and
54 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
namespace Artemeon\M2G\Command; | ||
|
||
use Artemeon\M2G\Helper\VersionHelper; | ||
|
||
use function Termwind\{render}; | ||
|
||
class CheckUpdateCommand extends Command | ||
{ | ||
protected function configure() | ||
{ | ||
$this->setName('check_update') | ||
->setDescription('Checks whether a new version is available'); | ||
} | ||
|
||
protected function handle(): int | ||
{ | ||
$currentVersion = VersionHelper::fetchVersion(); | ||
$latestVersion = VersionHelper::latestVersion(); | ||
$updateAvailable = VersionHelper::checkForUpdates(); | ||
$name = VersionHelper::getPackageName(); | ||
|
||
if ($updateAvailable) { | ||
render(<<<HTML | ||
<table> | ||
<thead> | ||
<tr> | ||
<th>Update available! $currentVersion -> $latestVersion</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td><br>Please run:<br><br><code class="font-bold">composer global update $name</code><br></td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
HTML); | ||
} | ||
|
||
return 0; | ||
} | ||
} |
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
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