|
2 | 2 |
|
3 | 3 | namespace EragPermission\Commands;
|
4 | 4 |
|
| 5 | +namespace EragPermission\Commands; |
| 6 | + |
5 | 7 | use Illuminate\Console\Command;
|
6 | 8 | use Illuminate\Support\Facades\File;
|
| 9 | +use Symfony\Component\Process\Process; |
7 | 10 |
|
8 | 11 | class UpgradeVersions extends Command
|
9 | 12 | {
|
10 | 13 | protected $signature = 'erag:upgrade-version';
|
11 | 14 |
|
12 |
| - protected $description = 'Upgrades the version by publishing migration files.'; |
| 15 | + protected $description = 'Upgrades the version by publishing migration files and updating the package.'; |
13 | 16 |
|
14 | 17 | public function __construct()
|
15 | 18 | {
|
16 | 19 | parent::__construct();
|
17 | 20 | }
|
18 | 21 |
|
19 | 22 | public function handle(): void
|
| 23 | + { |
| 24 | + $this->info('Starting the upgrade process for the Erag Laravel Role Permission package...'); |
| 25 | + |
| 26 | + $this->updatePackage(); |
| 27 | + |
| 28 | + $this->publishMigrations(); |
| 29 | + |
| 30 | + $this->info('Upgrade process completed.'); |
| 31 | + } |
| 32 | + |
| 33 | + protected function updatePackage(): void |
| 34 | + { |
| 35 | + $this->info('Updating the erag/laravel-role-permission package...'); |
| 36 | + |
| 37 | + $process = new Process(['composer', 'update', 'erag/laravel-role-permission']); |
| 38 | + |
| 39 | + $process->run(); |
| 40 | + |
| 41 | + if (! $process->isSuccessful()) { |
| 42 | + $this->error('Failed to update the package. Please check your Composer configuration.'); |
| 43 | + } else { |
| 44 | + $this->info('Package updated successfully.'); |
| 45 | + } |
| 46 | + } |
| 47 | + |
| 48 | + protected function publishMigrations(): void |
20 | 49 | {
|
21 | 50 | $migrationFile = database_path('migrations/06_users_permissions_add_column.php');
|
22 | 51 |
|
23 | 52 | if (file_exists($migrationFile)) {
|
24 | 53 | $this->info('✅ The system is up to date.');
|
25 | 54 | } else {
|
| 55 | + $this->info('Publishing migration files...'); |
| 56 | + |
26 | 57 | $this->info('🔄 Upgrading the version by publishing new migration files...');
|
27 | 58 |
|
28 | 59 | $stubPath = __DIR__.'/../database/06_users_permissions_add_column.php.stub';
|
|
0 commit comments