<commit_before><?php

namespace luya\commands;

use yii\helpers\FileHelper;

class HealthController extends \luya\base\Command
{
    public $folders = [
        'public_html/assets' => true,
        'public_html/storage' => true,
        'migrations' => false,
        'vendor' => false,
    ];

    public $files = [
        'configs/server.php',
        'public_html/index.php',
    ];

    public function actionIndex()
    {
        $error = false;

        foreach ($this->folders as $folder => $writable) {
            if (!file_exists($folder)) {
                $mode = ($writable) ? 0777 : 0775;
                if (FileHelper::createDirectory($folder, $mode)) {
                    $this->outputSuccess("$folder: successfully created directory");
                } else {
                    $error = true;
                    $this->outputError("$folder: unable to create directory");
                }
            } else {
                $this->outputSuccess("$folder: directory exists");
            }
            
            if ($writable) {
                if (!is_writable($folder)) {
                    $error = true;
                    $this->outputError("$folder: is not writable.");
                }
            }
        }

        foreach ($this->files as $file) {
            if (file_exists($file)) {
                $this->outputSuccess("$file: file exists.");
            } else {
                $error = true;
                $this->outputError("$file: file does not exists!");
            }
        }

        return ($error) ? $this->outputError('Health check found errors!') : $this->outputSuccess('O.K.');
    }
}<commit_msg>change to base dir before exec<commit_after><?php

namespace luya\commands;

use Yii;
use yii\helpers\FileHelper;

class HealthController extends \luya\base\Command
{
    public $folders = [
        'public_html/assets' => true,
        'public_html/storage' => true,
        'migrations' => false,
        'vendor' => false,
        'runtime' => true,
    ];

    public $files = [
        'configs/server.php',
        'public_html/index.php',
    ];

    public function actionIndex()
    {
        $error = false;

        @chdir(Yii::getAlias('@app'));
        
        foreach ($this->folders as $folder => $writable) {
            if (!file_exists($folder)) {
                $mode = ($writable) ? 0777 : 0775;
                if (FileHelper::createDirectory($folder, $mode)) {
                    $this->outputSuccess("$folder: successfully created directory");
                } else {
                    $error = true;
                    $this->outputError("$folder: unable to create directory");
                }
            } else {
                $this->outputSuccess("$folder: directory exists");
            }
            
            if ($writable) {
                if (!is_writable($folder)) {
                    $error = true;
                    $this->outputError("$folder: is not writable, please change permissions.");
                }
            }
        }

        foreach ($this->files as $file) {
            if (file_exists($file)) {
                $this->outputSuccess("$file: file exists.");
            } else {
                $error = true;
                $this->outputError("$file: file does not exists!");
            }
        }

        return ($error) ? $this->outputError('Health check found errors!') : $this->outputSuccess('O.K.');
    }
}
{'fraction_non_alphanumeric': 0.13904982618771727, 'fraction_numerical': 0.004634994206257242, 'mean_word_length': 1.531524926686217, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 34, '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': '5196132', 'n_tokens_mistral': 958, 'n_tokens_neox': 908, 'n_words': 197}