-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added version into the codebase
- Loading branch information
1 parent
23fd861
commit bd8dbcb
Showing
4 changed files
with
58 additions
and
5 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 @@ | ||
1.0.2 |
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,29 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use File; | ||
use Illuminate\Console\Command; | ||
|
||
class CheckVersion extends Command | ||
{ | ||
protected $signature = 'vanguard:version'; | ||
|
||
protected $description = 'Check the current version of Vanguard.'; | ||
|
||
public function handle(): void | ||
{ | ||
|
||
$versionFile = base_path('VERSION'); | ||
|
||
if (!File::exists($versionFile)) { | ||
$this->components->error("Unable to determine the current version. The version file is missing."); | ||
|
||
return; | ||
} | ||
|
||
$version = str_replace("\n", '', File::get($versionFile)); | ||
|
||
$this->components->info("The current version of Vanguard is: {$version}."); | ||
} | ||
} |
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,22 @@ | ||
<?php | ||
|
||
use App\Console\Commands\CheckVersion; | ||
use Illuminate\Support\Facades\File; | ||
|
||
it('fails if it cannot find the version file', function () { | ||
File::shouldReceive('exists')->with(base_path('VERSION'))->andReturn(false); | ||
|
||
$this->artisan(CheckVersion::class) | ||
->expectsOutputToContain('The version file is missing.') | ||
->assertExitCode(0); | ||
}); | ||
|
||
|
||
it('returns the current version number from the file', function () { | ||
File::shouldReceive('exists')->with(base_path('VERSION'))->andReturn(true); | ||
File::shouldReceive('get')->with(base_path('VERSION'))->andReturn('1.0.0'); | ||
|
||
$this->artisan(CheckVersion::class) | ||
->expectsOutputToContain('The current version of Vanguard is: 1.0.0.') | ||
->assertExitCode(0); | ||
}); |