<commit_before><?php namespace Orchestra\Foundation\Console\Commands;

use Illuminate\Console\Command;
use Orchestra\Contracts\Memory\Provider;
use Orchestra\Contracts\Foundation\Foundation;
use Symfony\Component\Console\Input\InputOption;

class AssembleCommand extends Command
{
    /**
     * The console command name.
     *
     * @var string
     */
    protected $name = 'orchestra:assemble';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Refresh application setup (during composer install/update)';

    /**
     * The application foundation implementation.
     *
     * @var \Orchestra\Contracts\Foundation\Foundation
     */
    protected $foundation;

    /**
     * The memory provider implementation.
     *
     * @var \Orchestra\Contracts\Memory\Provider
     */
    protected $memory;

    /**
     * Construct a new command.
     *
     * @param  \Orchestra\Contracts\Foundation\Foundation  $foundation
     * @param  \Orchestra\Contracts\Memory\Provider  $memory
     */
    public function __construct(Foundation $foundation, Provider $memory)
    {
        $this->foundation = $foundation;
        $this->memory     = $memory;

        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return void
     */
    public function handle()
    {
        $this->setupApplication();

        $this->refreshApplication();

        $this->optimizeApplication();
    }

    /**
     * Refresh application for Orchestra Platform.
     *
     * @return void
     */
    protected function refreshApplication()
    {
        if (! $this->foundation->installed()) {
            return;
        }

        $extensions = $this->memory->get('extensions.active', []);

        foreach ($extensions as $extension => $config) {
            $this->call('extension:refresh', ['name' => $extension, '--force' => true]);
        }
    }

    /**
     * Setup application for Orchestra Platform.
     *
     * @return void
     */
    protected function setupApplication()
    {
        $this->call('publish:assets', ['package' => 'orchestra/foundation']);
    }

    /**
     * Optimize application for Orchestra Platform.
     *
     * @return void
     */
    protected function optimizeApplication()
    {
        if ($this->laravel->environment('production') || $this->option('no-cache')) {
            $this->call('config:cache');
            $this->call('route:cache');
        }

        if (! $this->option('no-optimize')) {
            $this->call('orchestra:optimize');
        }
    }

    /**
     * Get the console command options.
     *
     * @return array
     */
    protected function getOptions()
    {
        return [
            ['no-cache', null, InputOption::VALUE_NONE, 'Avoid running route and config caching.'],
            ['no-optimize', null, InputOption::VALUE_NONE, 'Avoid running class optimization.'],
        ];
    }
}
<commit_msg>Clear cache before doing anything compilation.<commit_after><?php namespace Orchestra\Foundation\Console\Commands;

use Illuminate\Console\Command;
use Orchestra\Contracts\Memory\Provider;
use Orchestra\Contracts\Foundation\Foundation;
use Symfony\Component\Console\Input\InputOption;

class AssembleCommand extends Command
{
    /**
     * The console command name.
     *
     * @var string
     */
    protected $name = 'orchestra:assemble';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Refresh application setup (during composer install/update)';

    /**
     * The application foundation implementation.
     *
     * @var \Orchestra\Contracts\Foundation\Foundation
     */
    protected $foundation;

    /**
     * The memory provider implementation.
     *
     * @var \Orchestra\Contracts\Memory\Provider
     */
    protected $memory;

    /**
     * Construct a new command.
     *
     * @param  \Orchestra\Contracts\Foundation\Foundation  $foundation
     * @param  \Orchestra\Contracts\Memory\Provider  $memory
     */
    public function __construct(Foundation $foundation, Provider $memory)
    {
        $this->foundation = $foundation;
        $this->memory     = $memory;

        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return void
     */
    public function handle()
    {
        $this->setupApplication();

        $this->refreshApplication();

        $this->optimizeApplication();
    }

    /**
     * Refresh application for Orchestra Platform.
     *
     * @return void
     */
    protected function refreshApplication()
    {
        if (! $this->foundation->installed()) {
            return;
        }

        $extensions = $this->memory->get('extensions.active', []);

        foreach ($extensions as $extension => $config) {
            $this->call('extension:refresh', ['name' => $extension, '--force' => true]);
        }
    }

    /**
     * Setup application for Orchestra Platform.
     *
     * @return void
     */
    protected function setupApplication()
    {
        $this->call('publish:assets', ['package' => 'orchestra/foundation']);
    }

    /**
     * Optimize application for Orchestra Platform.
     *
     * @return void
     */
    protected function optimizeApplication()
    {
        $this->call('config:clear');
        $this->call('route:clear');
        $this->call('clear-compiled');

        if ($this->laravel->environment('production') && ! $this->option('no-cache')) {
            $this->call('config:cache');
            $this->call('route:cache');
        }

        if (! $this->option('no-optimize')) {
            $this->call('orchestra:optimize');
        }
    }

    /**
     * Get the console command options.
     *
     * @return array
     */
    protected function getOptions()
    {
        return [
            ['no-cache', null, InputOption::VALUE_NONE, 'Avoid running route and config caching.'],
            ['no-optimize', null, InputOption::VALUE_NONE, 'Avoid running class optimization.'],
        ];
    }
}

{'fraction_non_alphanumeric': 0.1367816091954023, 'fraction_numerical': 0.0, 'mean_word_length': 2.192348008385744, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 50, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '118946', 'n_tokens_mistral': 1658, 'n_tokens_neox': 1637, 'n_words': 348}