<?php

namespace Maestro\Core\Console\Commands;

use Illuminate\Console\Command;

class InstallCommand extends Command
{
    protected $signature   = 'maestro:install';
    protected $description = 'Install Maestro into this project';

    public function handle(): void
    {
        $this->info('Installing Maestro...');

        $this->info('→ Publishing config');
        $this->callSilent('vendor:publish', ['--tag' => 'maestro-config', '--force' => false]);

        $this->info('→ Running migrations');
        $this->call('migrate');

        $this->info('→ Seeding base data');
        $this->call('db:seed', ['--class' => 'Maestro\\Core\\Database\\Seeders\\MaestroSeeder']);

        $this->newLine();
        $this->info('✓ Maestro installed successfully.');
        $this->line('  Login: admin@example.com / password');

        $this->info('→ Publishing Spatie migrations');
        $this->call('vendor:publish', [
         '--provider' => 'Spatie\\Permission\\PermissionServiceProvider',
        '--force'    => false,
    ]);
    }
}
