From: Vincent Vanwaelscappel Date: Tue, 30 Jan 2024 13:00:00 +0000 (+0100) Subject: wait #6693 @0.75 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=5f77755060efc4a3f92ceb924602ea527728edc9;p=cubist_cms-back.git wait #6693 @0.75 --- diff --git a/src/app/Console/Commands/InstallCommand.php b/src/app/Console/Commands/InstallCommand.php index faeb3a9..2d6b268 100644 --- a/src/app/Console/Commands/InstallCommand.php +++ b/src/app/Console/Commands/InstallCommand.php @@ -2,6 +2,12 @@ namespace Cubist\Backpack\Console\Commands; +use Cubist\Backpack\Magic\Models\CubistMagicAbstractModel; +use Cubist\Util\Crypt; +use Cubist\Util\Text; +use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\Hash; + class InstallCommand extends CubistCommand { protected $signature = 'cubist:install'; @@ -15,10 +21,16 @@ class InstallCommand extends CubistCommand public function handle() { - $devPackages = ['barryvdh/laravel-ide-helper', 'filp/whoops', 'laravel/tinker:^2.1']; + $devPackages = ['barryvdh/laravel-ide-helper', 'filp/whoops', 'laravel/tinker']; $commands = [ 'Update Cubist' => ['php artisan cubist:update'], + 'Laravel media library' => [ + 'php artisan vendor:publish --provider="Spatie\MediaLibrary\MediaLibraryServiceProvider" --tag="migrations"', + 'php artisan vendor:publish --provider="Spatie\MediaLibrary\MediaLibraryServiceProvider" --tag="config"', + 'php artisan migrate --force', + 'php artisan cubist:magic:migrate', + ], 'Install backpack' => ['php artisan backpack:install'], 'Publish backpack assets' => ['php artisan vendor:publish --provider="Backpack\CRUD\BackpackServiceProvider" --tag="minimum"'], 'Install backpack addons' => [ @@ -34,22 +46,38 @@ class InstallCommand extends CubistCommand 'php artisan backpack:add-sidebar-content "
  • Authentication
  • "', // Revisions 'php artisan vendor:publish --provider="Venturecraft\Revisionable\RevisionableServiceProvider"', - 'php artisan migrate', + 'php artisan migrate --force', ], 'Install dev dependencies' => ['composer require --dev ' . implode(' ', $devPackages)], "Dropzone" => 'php artisan gaspertrix:backpack:dropzone:install', - 'Laravel media library' => [ - 'php artisan vendor:publish --provider="Spatie\MediaLibrary\MediaLibraryServiceProvider" --tag="migrations"', - 'php artisan vendor:publish --provider="Spatie\MediaLibrary\MediaLibraryServiceProvider" --tag="config"' - ], + 'Cubist code generation' => ['php artisan cubist:magic:generate'], 'Database migrations' => [ - 'php artisan migrate', + 'php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider"', + 'php artisan migrate --force', 'php artisan cubist:magic:migrate' ], 'Setup superadmin permission' => [ 'php artisan permission:create-role superadmin', ], + 'Create first users' => [ + function () { + $users = ['vincent@cubedesigners.com' => 'Vincent Vanwaelscappel', 'soufiane@cubedesigners.com'=> 'Soufiane Adili']; + foreach ($users as $email => $name) { + try { + /** @var CubistMagicAbstractModel $user */ + $user = new \App\Models\User(); + $user->password = Hash::make(Text::randText('60')); + $user->email = $email; + $user->name = $name; + $user->save(); + DB::table('model_has_roles')->insert(['role_id' => 1, 'model_id' => $user->id, 'model_type' => 'App\\Models\\AuthUser']); + } catch (\Exception $e) { + echo $e->getMessage(); + } + } + } + ], 'Clear caches' => ['php artisan optimize:clear'], ]; @@ -63,7 +91,15 @@ class InstallCommand extends CubistCommand $command = [$command]; } foreach ($command as $cmd) { - $this->executeProcess($cmd); + if ($cmd instanceof \Closure) { + $cmd->call($this); + } else { + try { + $this->executeProcess($cmd); + } catch (\Exception $e) { + echo $cmd . ' : ' . $e->getMessage() . "\n"; + } + } } $this->progressBar->advance(); diff --git a/src/app/Console/Commands/UpdateCommand.php b/src/app/Console/Commands/UpdateCommand.php index fef57c3..6d2a56a 100644 --- a/src/app/Console/Commands/UpdateCommand.php +++ b/src/app/Console/Commands/UpdateCommand.php @@ -17,8 +17,6 @@ class UpdateCommand extends CubistCommand { $commands = [ 'Update packages' => ['composer update -v --no-progress --profile --prefer-dist'], - 'Dump autoload' => ['composer dump-autoload'], - 'Clear cache' => ['php artisan optimize:clear'], 'Generate magic models' => ['php artisan cubist:magic:generate'], 'Clear caches' => ['php artisan optimize:clear'], ];