mirror of
https://github.com/laravel/valet.git
synced 2026-02-06 08:40:09 +01:00
Replace some \n with PHP_EOL; move custom drivers into Custom namespace
This commit is contained in:
@@ -182,7 +182,8 @@ public function prependPath(string $path): void
|
|||||||
public function removePath(string $path): void
|
public function removePath(string $path): void
|
||||||
{
|
{
|
||||||
if ($path == VALET_HOME_PATH.'/Sites') {
|
if ($path == VALET_HOME_PATH.'/Sites') {
|
||||||
info("Cannot remove this directory because this is where Valet stores its site definitions.\nRun [valet paths] for a list of parked paths.");
|
info("Cannot remove this directory because this is where Valet stores its site definitions.");
|
||||||
|
info("Run [valet paths] for a list of parked paths.");
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public static function assign(string $sitePath, string $siteName, string $uri):
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Queue custom drivers for this environment
|
// Queue custom drivers for this environment
|
||||||
$drivers = array_merge($drivers, static::driversIn(VALET_HOME_PATH.'/Drivers'));
|
$drivers = array_merge($drivers, static::customDrivers());
|
||||||
|
|
||||||
// Queue Valet-shipped drivers
|
// Queue Valet-shipped drivers
|
||||||
$drivers[] = 'LaravelValetDriver';
|
$drivers[] = 'LaravelValetDriver';
|
||||||
@@ -126,6 +126,13 @@ public static function specificDrivers(): array
|
|||||||
}, static::driversIn(__DIR__.'/Specific'));
|
}, static::driversIn(__DIR__.'/Specific'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function customDrivers(): array
|
||||||
|
{
|
||||||
|
return array_map(function ($item) {
|
||||||
|
return 'Custom\\' . $item;
|
||||||
|
}, static::driversIn(VALET_HOME_PATH.'/Drivers'));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Take any steps necessary before loading the front controller for this driver.
|
* Take any steps necessary before loading the front controller for this driver.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ public function installNginxDirectory(): void
|
|||||||
$this->files->mkdirAsUser($nginxDirectory);
|
$this->files->mkdirAsUser($nginxDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->files->putAsUser($nginxDirectory.'/.keep', "\n");
|
$this->files->putAsUser($nginxDirectory.'/.keep', PHP_EOL);
|
||||||
|
|
||||||
$this->rewriteSecureNginxFiles();
|
$this->rewriteSecureNginxFiles();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ public static function showDirectoryListing(string $valetSitePath, string $uri)
|
|||||||
// Output the HTML for the directory listing
|
// Output the HTML for the directory listing
|
||||||
echo "<h1>Index of $uri</h1>";
|
echo "<h1>Index of $uri</h1>";
|
||||||
echo '<hr>';
|
echo '<hr>';
|
||||||
echo implode("<br>\n", array_map(function ($path) use ($uri, $is_root) {
|
echo implode("<br>".PHP_EOL, array_map(function ($path) use ($uri, $is_root) {
|
||||||
$file = basename($path);
|
$file = basename($path);
|
||||||
|
|
||||||
return ($is_root) ? "<a href='/$file'>/$file</a>" : "<a href='$uri/$file'>$uri/$file/</a>";
|
return ($is_root) ? "<a href='/$file'>/$file</a>" : "<a href='$uri/$file'>$uri/$file/</a>";
|
||||||
|
|||||||
@@ -11,6 +11,20 @@ public function __construct(public Filesystem $files)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run all the upgrades that should be run every time Valet commands are run.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function onEveryRun(): void
|
||||||
|
{
|
||||||
|
$this->relocateOldConfig();
|
||||||
|
$this->pruneMissingDirectories();
|
||||||
|
$this->pruneSymbolicLinks();
|
||||||
|
$this->fixOldSampleValetDriver();
|
||||||
|
$this->errorIfOldCustomDrivers();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Relocate config dir to ~/.config/valet/ if found in old location.
|
* Relocate config dir to ~/.config/valet/ if found in old location.
|
||||||
*
|
*
|
||||||
@@ -23,17 +37,33 @@ public function relocateOldConfig()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function pruneMissingDirectories()
|
/**
|
||||||
|
* Prune all non-existent paths from the configuration.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function pruneMissingDirectories(): void
|
||||||
{
|
{
|
||||||
Configuration::prune();
|
Configuration::prune();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function pruneSymbolicLinks()
|
/**
|
||||||
|
* Remove all broken symbolic links in the Valet config Sites diretory.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function pruneSymbolicLinks(): void
|
||||||
{
|
{
|
||||||
Site::pruneLinks();
|
Site::pruneLinks();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function fixOldSampleValetDriver()
|
/**
|
||||||
|
* If the user has the old `SampleValetDriver` without the Valet namespace,
|
||||||
|
* replace it with the new `SampleValetDriver` that uses the namespace.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function fixOldSampleValetDriver(): void
|
||||||
{
|
{
|
||||||
$samplePath = VALET_HOME_PATH.'/Drivers/SampleValetDriver.php';
|
$samplePath = VALET_HOME_PATH.'/Drivers/SampleValetDriver.php';
|
||||||
|
|
||||||
@@ -47,7 +77,12 @@ public function fixOldSampleValetDriver()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function errorIfOldCustomDrivers()
|
/**
|
||||||
|
* Throw an exception if the user has old (non-namespaced) custom drivers.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function errorIfOldCustomDrivers(): void
|
||||||
{
|
{
|
||||||
$driversPath = VALET_HOME_PATH.'/Drivers';
|
$driversPath = VALET_HOME_PATH.'/Drivers';
|
||||||
|
|
||||||
|
|||||||
@@ -43,11 +43,7 @@ function (ConsoleCommandEvent $event) {
|
|||||||
writer($event->getOutput());
|
writer($event->getOutput());
|
||||||
});
|
});
|
||||||
|
|
||||||
Upgrader::relocateOldConfig();
|
Upgrader::onEveryRun();
|
||||||
Upgrader::pruneMissingDirectories();
|
|
||||||
Upgrader::pruneSymbolicLinks();
|
|
||||||
Upgrader::fixOldSampleValetDriver();
|
|
||||||
Upgrader::errorIfOldCustomDrivers();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Install Valet and any required services.
|
* Install Valet and any required services.
|
||||||
@@ -556,7 +552,7 @@ function (ConsoleCommandEvent $event) {
|
|||||||
if ($phpVersion = Site::phpRcVersion($site)) {
|
if ($phpVersion = Site::phpRcVersion($site)) {
|
||||||
info("Found '{$site}/.valetphprc' specifying version: {$phpVersion}");
|
info("Found '{$site}/.valetphprc' specifying version: {$phpVersion}");
|
||||||
} else {
|
} else {
|
||||||
info("\nPlease provide a version number. E.g.:");
|
info(PHP_EOL."Please provide a version number. E.g.:");
|
||||||
info('valet isolate php@8.2');
|
info('valet isolate php@8.2');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Valet\Drivers\Specific;
|
namespace Valet\Drivers\Custom;
|
||||||
|
|
||||||
use Valet\Drivers\ValetDriver;
|
use Valet\Drivers\ValetDriver;
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ public function prepTestConfig()
|
|||||||
}
|
}
|
||||||
|
|
||||||
Configuration::createConfigurationDirectory();
|
Configuration::createConfigurationDirectory();
|
||||||
|
Configuration::createDriversDirectory();
|
||||||
Configuration::writeBaseConfiguration();
|
Configuration::writeBaseConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,9 +42,9 @@ public function test_fpm_is_configured_with_the_correct_user_group_and_port()
|
|||||||
|
|
||||||
resolve(StubForUpdatingFpmConfigFiles::class)->createConfigurationFiles('php@7.2');
|
resolve(StubForUpdatingFpmConfigFiles::class)->createConfigurationFiles('php@7.2');
|
||||||
$contents = file_get_contents(__DIR__.'/output/fpm.conf');
|
$contents = file_get_contents(__DIR__.'/output/fpm.conf');
|
||||||
$this->assertStringContainsString(sprintf("\nuser = %s", user()), $contents);
|
$this->assertStringContainsString(sprintf(PHP_EOL."user = %s", user()), $contents);
|
||||||
$this->assertStringContainsString("\ngroup = staff", $contents);
|
$this->assertStringContainsString(PHP_EOL."group = staff", $contents);
|
||||||
$this->assertStringContainsString("\nlisten = ".VALET_HOME_PATH.'/valet72.sock', $contents);
|
$this->assertStringContainsString(PHP_EOL."listen = ".VALET_HOME_PATH.'/valet72.sock', $contents);
|
||||||
|
|
||||||
// It should disable old or default FPM Pool configuration
|
// It should disable old or default FPM Pool configuration
|
||||||
$this->assertFileDoesNotExist(__DIR__.'/output/www.conf');
|
$this->assertFileDoesNotExist(__DIR__.'/output/www.conf');
|
||||||
|
|||||||
Reference in New Issue
Block a user