feat: store Koel version in a .version config file instead

This commit is contained in:
Phan An 2021-01-10 23:17:37 +01:00
parent 2e5b9b642e
commit e284a40d0d
5 changed files with 9 additions and 23 deletions

1
.version Normal file
View file

@ -0,0 +1 @@
v5.0.1

View file

@ -1,18 +0,0 @@
<?php
namespace App;
use Illuminate\Foundation\Application as IlluminateApplication;
/**
* Extends \Illuminate\Foundation\Application to override some defaults.
*/
class Application extends IlluminateApplication
{
/**
* Current Koel version. Must start with a v, and is synced with git tags/releases.
*
* @see https://github.com/koel/koel/releases
*/
public const KOEL_VERSION = 'v5.0.1';
}

View file

@ -65,3 +65,8 @@ function artist_image_url(string $fileName): string
{
return static_url(config('koel.artist_image_dir') . $fileName);
}
function koel_version(): string
{
return trim(file_get_contents(base_path('.version')));
}

View file

@ -2,7 +2,6 @@
namespace App\Http\Controllers\API;
use App\Application;
use App\Models\User;
use App\Repositories\InteractionRepository;
use App\Repositories\PlaylistRepository;
@ -75,10 +74,10 @@ class DataController extends Controller
'supportsTranscoding' => config('koel.streaming.ffmpeg_path')
&& is_executable(config('koel.streaming.ffmpeg_path')),
'cdnUrl' => static_url(),
'currentVersion' => Application::KOEL_VERSION,
'currentVersion' => koel_version(),
'latestVersion' => $this->currentUser->is_admin
? $this->applicationInformationService->getLatestVersionNumber()
: Application::KOEL_VERSION,
: koel_version(),
]);
}
}

View file

@ -2,7 +2,6 @@
namespace App\Services;
use App\Application;
use GuzzleHttp\Client;
use Illuminate\Contracts\Cache\Repository as Cache;
use Illuminate\Log\Logger;
@ -36,7 +35,7 @@ class ApplicationInformationService
} catch (Throwable $e) {
$this->logger->error($e);
return Application::KOEL_VERSION;
return koel_version();
}
});
}