<commit_before>#!/usr/bin/env php
<?php

/**
 * Load correct autoloader depending on install location.
 */
if (file_exists(__DIR__.'/../vendor/autoload.php')) {
    require __DIR__.'/../vendor/autoload.php';
} else {
    require __DIR__.'/../../../autoload.php';
}

use Silly\Application;
use Illuminate\Container\Container;

/**
 * Create the application.
 */
Container::setInstance(new Container);

$version = '1.1.11';

$app = new Application('Laravel Valet', $version);

/**
 * Prune missing directories and symbolic links on every command.
 */
if (is_dir(VALET_HOME_PATH)) {
    Configuration::prune();

    Site::pruneLinks();
}

/**
 * Allow Valet to be run more conveniently by allowing the Node proxy to run password-less sudo.
 */
$app->command('install', function () {
    Caddy::stop();

    Configuration::install();
    Caddy::install();
    PhpFpm::install();
    DnsMasq::install();
    Caddy::restart();
    Valet::symlinkToUsersBin();
    Brew::createSudoersEntry();
    Valet::createSudoersEntry();

    output(PHP_EOL.'<info>Valet installed successfully!</info>');
})->descriptions('Install the Valet services');

/**
 * Get or set the domain currently being used by Valet.
 */
$app->command('domain [domain]', function ($domain = null) {
    if ($domain === null) {
        return info(Configuration::read()['domain']);
    }

    DnsMasq::updateDomain(
        $oldDomain = Configuration::read()['domain'], $domain = trim($domain, '.')
    );

    Configuration::updateKey('domain', $domain);

    Site::resecureForNewDomain($oldDomain, $domain);
    PhpFpm::restart();
    Caddy::restart();

    info('Your Valet domain has been updated to ['.$domain.'].');
})->descriptions('Get or set the domain used for Valet sites');

/**
 * Add the current working directory to the paths configuration.
 */
$app->command('park', function () {
    Configuration::addPath(getcwd());

    info("This directory has been added to Valet's paths.");
})->descriptions('Register the current working directory with Valet');

/**
 * Remove the current working directory to the paths configuration.
 */
$app->command('forget', function () {
    Configuration::removePath(getcwd());

    info("This directory has been removed from Valet's paths.");
})->descriptions('Remove the current working directory from Valet\'s list of paths');

/**
 * Register a symbolic link with Valet.
 */
$app->command('link [name]', function ($name) {
    $linkPath = Site::link(getcwd(), $name = $name ?: basename(getcwd()));

    info('A ['.$name.'] symbolic link has been created in ['.$linkPath.'].');
})->descriptions('Link the current working directory to Valet');

/**
 * Display all of the registered symbolic links.
 */
$app->command('links', function () {
    passthru('ls -la '.VALET_HOME_PATH.'/Sites');
})->descriptions('Display all of the registered Valet links');

/**
 * Unlink a link from the Valet links directory.
 */
$app->command('unlink [name]', function ($name) {
    Site::unlink($name ?: basename(getcwd()));

    info('The ['.$name.'] symbolic link has been removed.');
})->descriptions('Remove the specified Valet link');

/**
 * Secure the given domain with a trusted TLS certificate.
 */
$app->command('secure [domain]', function ($domain = null) {
    $url = ($domain ?: Site::host(getcwd())).'.'.Configuration::read()['domain'];

    Site::secure($url);

    PhpFpm::restart();

    Caddy::restart();

    info('The ['.$url.'] site has been secured with a fresh TLS certificate.');
});

$app->command('unsecure [domain]', function ($domain = null) {
    $url = ($domain ?: Site::host(getcwd())).'.'.Configuration::read()['domain'];

    Site::unsecure($url);

    PhpFpm::restart();

    Caddy::restart();

    info('The ['.$url.'] site will now serve traffic over HTTP.');
});

/**
 * Determine which Valet driver the current directory is using.
 */
$app->command('which', function () {
    require __DIR__.'/drivers/require.php';

    $driver = ValetDriver::assign(getcwd(), basename(getcwd()), '/');

    if ($driver) {
        info('This site is served by ['.get_class($driver).'].');
    } else {
        warning('Valet could not determine which driver to use for this site.');
    }
})->descriptions('Determine which Valet driver serves the current workign directory');

/**
 * Stream all of the logs for all sites.
 */
$app->command('logs', function () {
    $files = Site::logs(Configuration::read()['paths']);

    $files = collect($files)->transform(function ($file) {
        return escapeshellarg($file);
    })->all();

    if (count($files) > 0) {
        passthru('tail -f '.implode(' ', $files));
    } else {
        warning('No log files were found.');
    }
})->descriptions('Stream all of the logs for all Laravel sites registered with Valet');

/**
 * Display all of the registered paths.
 */
$app->command('paths', function () {
    $paths = Configuration::read()['paths'];

    if (count($paths) > 0) {
        output(json_encode($paths, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
    } else {
        info('No paths have been registered.');
    }
})->descriptions('Get all of the paths registered with Valet');<commit_msg>fixed wrong spelling for the word "working" under the "which" command<commit_after>#!/usr/bin/env php
<?php

/**
 * Load correct autoloader depending on install location.
 */
if (file_exists(__DIR__.'/../vendor/autoload.php')) {
    require __DIR__.'/../vendor/autoload.php';
} else {
    require __DIR__.'/../../../autoload.php';
}

use Silly\Application;
use Illuminate\Container\Container;

/**
 * Create the application.
 */
Container::setInstance(new Container);

$version = '1.1.11';

$app = new Application('Laravel Valet', $version);

/**
 * Prune missing directories and symbolic links on every command.
 */
if (is_dir(VALET_HOME_PATH)) {
    Configuration::prune();

    Site::pruneLinks();
}

/**
 * Allow Valet to be run more conveniently by allowing the Node proxy to run password-less sudo.
 */
$app->command('install', function () {
    Caddy::stop();

    Configuration::install();
    Caddy::install();
    PhpFpm::install();
    DnsMasq::install();
    Caddy::restart();
    Valet::symlinkToUsersBin();
    Brew::createSudoersEntry();
    Valet::createSudoersEntry();

    output(PHP_EOL.'<info>Valet installed successfully!</info>');
})->descriptions('Install the Valet services');

/**
 * Get or set the domain currently being used by Valet.
 */
$app->command('domain [domain]', function ($domain = null) {
    if ($domain === null) {
        return info(Configuration::read()['domain']);
    }

    DnsMasq::updateDomain(
        $oldDomain = Configuration::read()['domain'], $domain = trim($domain, '.')
    );

    Configuration::updateKey('domain', $domain);

    Site::resecureForNewDomain($oldDomain, $domain);
    PhpFpm::restart();
    Caddy::restart();

    info('Your Valet domain has been updated to ['.$domain.'].');
})->descriptions('Get or set the domain used for Valet sites');

/**
 * Add the current working directory to the paths configuration.
 */
$app->command('park', function () {
    Configuration::addPath(getcwd());

    info("This directory has been added to Valet's paths.");
})->descriptions('Register the current working directory with Valet');

/**
 * Remove the current working directory to the paths configuration.
 */
$app->command('forget', function () {
    Configuration::removePath(getcwd());

    info("This directory has been removed from Valet's paths.");
})->descriptions('Remove the current working directory from Valet\'s list of paths');

/**
 * Register a symbolic link with Valet.
 */
$app->command('link [name]', function ($name) {
    $linkPath = Site::link(getcwd(), $name = $name ?: basename(getcwd()));

    info('A ['.$name.'] symbolic link has been created in ['.$linkPath.'].');
})->descriptions('Link the current working directory to Valet');

/**
 * Display all of the registered symbolic links.
 */
$app->command('links', function () {
    passthru('ls -la '.VALET_HOME_PATH.'/Sites');
})->descriptions('Display all of the registered Valet links');

/**
 * Unlink a link from the Valet links directory.
 */
$app->command('unlink [name]', function ($name) {
    Site::unlink($name ?: basename(getcwd()));

    info('The ['.$name.'] symbolic link has been removed.');
})->descriptions('Remove the specified Valet link');

/**
 * Secure the given domain with a trusted TLS certificate.
 */
$app->command('secure [domain]', function ($domain = null) {
    $url = ($domain ?: Site::host(getcwd())).'.'.Configuration::read()['domain'];

    Site::secure($url);

    PhpFpm::restart();

    Caddy::restart();

    info('The ['.$url.'] site has been secured with a fresh TLS certificate.');
});

$app->command('unsecure [domain]', function ($domain = null) {
    $url = ($domain ?: Site::host(getcwd())).'.'.Configuration::read()['domain'];

    Site::unsecure($url);

    PhpFpm::restart();

    Caddy::restart();

    info('The ['.$url.'] site will now serve traffic over HTTP.');
});

/**
 * Determine which Valet driver the current directory is using.
 */
$app->command('which', function () {
    require __DIR__.'/drivers/require.php';

    $driver = ValetDriver::assign(getcwd(), basename(getcwd()), '/');

    if ($driver) {
        info('This site is served by ['.get_class($driver).'].');
    } else {
        warning('Valet could not determine which driver to use for this site.');
    }
})->descriptions('Determine which Valet driver serves the current working directory');

/**
 * Stream all of the logs for all sites.
 */
$app->command('logs', function () {
    $files = Site::logs(Configuration::read()['paths']);

    $files = collect($files)->transform(function ($file) {
        return escapeshellarg($file);
    })->all();

    if (count($files) > 0) {
        passthru('tail -f '.implode(' ', $files));
    } else {
        warning('No log files were found.');
    }
})->descriptions('Stream all of the logs for all Laravel sites registered with Valet');

/**
 * Display all of the registered paths.
 */
$app->command('paths', function () {
    $paths = Configuration::read()['paths'];

    if (count($paths) > 0) {
        output(json_encode($paths, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
    } else {
        info('No paths have been registered.');
    }
})->descriptions('Get all of the paths registered with Valet');
{'fraction_non_alphanumeric': 0.18160786581839214, 'fraction_numerical': 0.001156737998843262, 'mean_word_length': 3.8823529411764706, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 59, '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': '4573328', 'n_tokens_mistral': 3157, 'n_tokens_neox': 3085, 'n_words': 869}