feat: adap release and init commands to new workflow

This commit is contained in:
Phan An 2022-07-29 12:49:55 +02:00
parent 721c0d2573
commit b12e0c14a7
No known key found for this signature in database
GPG key ID: A81E4477F0BB6FDC
3 changed files with 9 additions and 45 deletions

View file

@ -17,9 +17,9 @@ jobs:
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
php-version: 8.0
tools: composer:v2
extensions: pdo_sqlite
extensions: pdo_sqlite, zip, gd
- name: Install PHP dependencies
uses: ramsey/composer-install@v2
with:

View file

@ -94,10 +94,8 @@ class InitCommand extends Command
private function setUpDatabase(): void
{
$config = [
'DB_CONNECTION' => '',
'DB_HOST' => '',
'DB_PORT' => '',
'DB_DATABASE' => '',
'DB_USERNAME' => '',
'DB_PASSWORD' => '',
];
@ -185,7 +183,7 @@ class InitCommand extends Command
return;
}
if ($this->isValidMediaPath($path)) {
if (self::isValidMediaPath($path)) {
Setting::set('media_path', $path);
return;
@ -276,32 +274,16 @@ class InitCommand extends Command
$this->info('Now to front-end stuff');
// We need to run several yarn commands:
// - The first to install node_modules in the resources/assets submodule
// - The second and third for the root folder, to build Koel's front-end assets with Mix.
chdir('./resources/assets');
$this->info('├── Installing Node modules in resources/assets directory');
$runOkOrThrow = static function (string $command): void {
passthru($command, $status);
throw_if((bool) $status, InstallationFailedException::class);
};
$runOkOrThrow('yarn install --colors');
chdir('../..');
$this->info('└── Compiling assets');
$runOkOrThrow('yarn install --colors');
$runOkOrThrow('yarn build --colors');
}
private function isValidMediaPath(string $path): bool
{
return is_dir($path) && is_readable($path);
}
private function setMediaPathFromEnvFile(): void
{
with(config('koel.media_path'), function (?string $path): void {
@ -309,11 +291,16 @@ class InitCommand extends Command
return;
}
if ($this->isValidMediaPath($path)) {
if (static::isValidMediaPath($path)) {
Setting::set('media_path', $path);
} else {
$this->warn(sprintf('The path %s does not exist or not readable. Skipping.', $path));
}
});
}
private static function isValidMediaPath(string $path): bool
{
return is_dir($path) && is_readable($path);
}
}

View file

@ -1,23 +0,0 @@
<?php
namespace App\Values;
use Illuminate\Support\Collection;
final class SyncResult
{
private function __construct(public Collection $success, public Collection $bad, public Collection $unmodified)
{
}
public static function init(): self
{
return new self(collect(), collect(), collect());
}
/** @return Collection|array<string> */
public function validEntries(): Collection
{
return $this->success->merge($this->unmodified);
}
}