-
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 remote-tracking branch 'origin/main' into 20240212-fixes
- Loading branch information
Showing
42 changed files
with
1,926 additions
and
539 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,20 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use Illuminate\Console\Command as CommandBase; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
/** | ||
* @codeCoverageIgnore | ||
*/ | ||
abstract class Command extends CommandBase | ||
{ | ||
protected function artisan(string $message, string $command, array $options = []): void | ||
{ | ||
$this->info($message); | ||
$this->getOutput()->getOutput()->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE | ||
? $this->call($command, $options) | ||
: $this->callSilent($command, $options); | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use Illuminate\Console\ConfirmableTrait; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
/** | ||
* @codeCoverageIgnore | ||
*/ | ||
class SetupApplication extends Command | ||
{ | ||
use ConfirmableTrait; | ||
|
||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'setup | ||
{--force : Force the operation to run when in production.} | ||
{--skip-storage-link : Skip storage link create.}'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Install or update the application, and run migrations after a new release'; | ||
|
||
/** | ||
* Execute the console command. | ||
*/ | ||
public function handle(): void | ||
{ | ||
if ($this->confirmToProceed()) { | ||
$this->resetCache(); | ||
$this->clearConfig(); | ||
$this->symlink(); | ||
$this->migrate(); | ||
$this->cacheConfig(); | ||
$this->scout(); | ||
} | ||
} | ||
|
||
/** | ||
* Clear or rebuild all cache. | ||
*/ | ||
protected function resetCache(): void | ||
{ | ||
if (config('cache.default') != 'database' || Schema::hasTable(config('cache.stores.database.table'))) { | ||
$this->artisan('✓ Resetting application cache', 'cache:clear'); | ||
} | ||
} | ||
|
||
/** | ||
* Clear configuration. | ||
*/ | ||
protected function clearConfig(): void | ||
{ | ||
if ($this->getLaravel()->environment() == 'production') { | ||
$this->artisan('✓ Clear config cache', 'config:clear'); | ||
$this->artisan('✓ Resetting route cache', 'route:cache'); | ||
$this->artisan('✓ Resetting view cache', 'view:clear'); | ||
} else { | ||
$this->artisan('✓ Clear config cache', 'config:clear'); | ||
$this->artisan('✓ Clear route cache', 'route:clear'); | ||
$this->artisan('✓ Clear view cache', 'view:clear'); | ||
} | ||
} | ||
|
||
/** | ||
* Cache configuration. | ||
*/ | ||
protected function cacheConfig(): void | ||
{ | ||
// Cache config | ||
if ($this->getLaravel()->environment() == 'production' | ||
&& (config('cache.default') != 'database' || Schema::hasTable(config('cache.stores.database.table')))) { | ||
$this->artisan('✓ Cache configuraton', 'config:cache'); | ||
} | ||
} | ||
|
||
/** | ||
* Symlink storage to public. | ||
*/ | ||
protected function symlink(): void | ||
{ | ||
if ($this->option('skip-storage-link') !== true | ||
&& $this->getLaravel()->environment() != 'testing' | ||
&& ! file_exists(public_path('storage'))) { | ||
$this->artisan('✓ Symlink the storage folder', 'storage:link'); | ||
} | ||
} | ||
|
||
/** | ||
* Run migrations. | ||
*/ | ||
protected function migrate(): void | ||
{ | ||
$this->artisan('✓ Performing migrations', 'migrate', ['--force' => true]); | ||
} | ||
|
||
/** | ||
* Configure scout. | ||
*/ | ||
protected function scout(): void | ||
{ | ||
$this->artisan('✓ Setup scout', 'scout:setup', ['--force' => true]); | ||
} | ||
} |
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,82 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use Illuminate\Console\ConfirmableTrait; | ||
|
||
/** | ||
* @codeCoverageIgnore | ||
*/ | ||
class SetupScout extends Command | ||
{ | ||
use ConfirmableTrait; | ||
|
||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'scout:setup | ||
{--flush : Flush the indexes.} | ||
{--import : Import the models into the search index.} | ||
{--force : Force the operation to run when in production.}'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Setup scout indexes.'; | ||
|
||
/** | ||
* Execute the console command. | ||
*/ | ||
public function handle(): void | ||
{ | ||
if ($this->confirmToProceed()) { | ||
$this->scoutConfigure(); | ||
$this->scoutFlush(); | ||
$this->scoutImport(); | ||
} | ||
} | ||
|
||
/** | ||
* Configure scout. | ||
*/ | ||
protected function scoutConfigure(): void | ||
{ | ||
if (config('scout.driver') === 'meilisearch' && config('scout.meilisearch.host') !== '') { | ||
$this->artisan('☐ Updating indexes on Meilisearch', 'scout:sync-index-settings', ['--verbose' => true]); | ||
} | ||
} | ||
|
||
/** | ||
* Import models. | ||
*/ | ||
protected function scoutFlush(): void | ||
{ | ||
if (config('scout.driver') !== null && $this->option('flush')) { | ||
foreach (config('scout.meilisearch.index-settings') as $index => $settings) { | ||
$name = (new $index)->getTable(); | ||
$this->artisan("☐ Flush {$name} index", 'scout:flush', ['model' => $index, '--verbose' => true]); | ||
} | ||
|
||
$this->info('✓ Indexes flushed'); | ||
} | ||
} | ||
|
||
/** | ||
* Import models. | ||
*/ | ||
protected function scoutImport(): void | ||
{ | ||
if (config('scout.driver') !== null && $this->option('import')) { | ||
foreach (config('scout.meilisearch.index-settings') as $index => $settings) { | ||
$name = (new $index)->getTable(); | ||
$this->artisan("☐ Import {$name}", 'scout:import', ['model' => $index, '--verbose' => true]); | ||
} | ||
|
||
$this->info('✓ Indexes imported'); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.