Skip to content

Commit

Permalink
feat: added version into the codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
lewislarsen committed Jun 14, 2024
1 parent 23fd861 commit bd8dbcb
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 5 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,12 @@ Vanguard uses Duster by Tighten to ensure a consistent code style across the pro

Vanguard has a few artisan commands that are specific to the project that can be run. Here is a list of the commands and what they do:

| Command | Description |
|-----------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------|
| `vanguard:generate-ssh-key` | Generates an SSH key required for backup operations. |
| `vanguard:validate-s3-connection {id}` | Able to check whether a backup destination that uses S3 can be reached. This takes the primary key of the backup destination as an id. |
| `vanguard:encrypt-database-passwords` | Used to convert any previously non-encrypted database passwords to encrypted. This was only necessary once. |
| Command | Description |
|----------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------|
| `vanguard:generate-ssh-key` | Generates an SSH key required for backup operations. |
| `vanguard:version` | Checks the version of Vanguard. |
| `vanguard:validate-s3-connection {id}` | Able to check whether a backup destination that uses S3 can be reached. This takes the primary key of the backup destination as an id. |
| `vanguard:encrypt-database-passwords` | Used to convert any previously non-encrypted database passwords to encrypted. This was only necessary once. |

**Note:** There are other commands, but they are not intended to be run manually and are used internally by Vanguard's scheduler.

Expand Down
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.0.2
29 changes: 29 additions & 0 deletions app/Console/Commands/CheckVersion.php
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}.");
}
}
22 changes: 22 additions & 0 deletions tests/Feature/Console/Commands/CheckVersionTest.php
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);
});

0 comments on commit bd8dbcb

Please sign in to comment.