Skip to content

Commit

Permalink
fix migration process
Browse files Browse the repository at this point in the history
fix update command
  • Loading branch information
uttamrabadiya committed Jun 29, 2024
1 parent df1348a commit c85a180
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 9 deletions.
14 changes: 9 additions & 5 deletions cli/Valet/PhpFpm.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,14 @@ public function fpmSocketFile(string $version): string
public function updateHomePath(string $oldHomePath, string $newHomePath): void
{
foreach (self::ISOLATION_SUPPORTED_PHP_VERSIONS as $version) {
$confPath = $this->fpmConfigPath($version) . '/' . self::FPM_CONFIG_FILE_NAME;
if ($this->files->exists($confPath)) {
$valetConf = $this->files->get($confPath);
$valetConf = str_replace($oldHomePath, $newHomePath, $valetConf);
$this->files->put($confPath, $valetConf);
try {
$confPath = $this->fpmConfigPath($version) . '/' . self::FPM_CONFIG_FILE_NAME;
if ($this->files->exists($confPath)) {
$valetConf = $this->files->get($confPath);
$valetConf = str_replace($oldHomePath, $newHomePath, $valetConf);
$this->files->put($confPath, $valetConf);
}
} catch (\DomainException $domainException) {
}
}
}
Expand Down Expand Up @@ -350,6 +353,7 @@ private function utilizedPhpVersions(): array

/**
* Get the path to the FPM configuration file for the current PHP version.
* @throws \DomainException
*/
private function fpmConfigPath(string $version = null): string
{
Expand Down
6 changes: 6 additions & 0 deletions cli/Valet/Valet.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ public function migrateConfig(): void
// Replace $oldHomePath to $newHomePath in Certificates, Valet.conf file
$this->updateNginxConfFiles();

// Fix SampleValetDriver
$this->files->putAsUser(
$newHomePath . '/Drivers/SampleValetDriver.php',
$this->files->get(VALET_ROOT_PATH . '/cli/stubs/SampleValetDriver.php')
);

// Update phpfpm's socket file path in config
PhpFpmFacade::updateHomePath($oldHomePath, $newHomePath);

Expand Down
2 changes: 1 addition & 1 deletion cli/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* Create the application.
*/
Container::setInstance(new Container());
$version = '2.0.0';
$version = '2.0.1';

$app = new Application('ValetLinux+', $version);

Expand Down
2 changes: 1 addition & 1 deletion cli/scripts/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ if [[ "$1" = "update" ]]
then
if [[ "$2" ]]
then
composer global update "genesisweb/valet-linux-plus:$2"
composer global require "genesisweb/valet-linux-plus:$2" -W
else
composer global update "genesisweb/valet-linux-plus"
fi
Expand Down
4 changes: 2 additions & 2 deletions cli/stubs/SampleValetDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function serves(string $sitePath, string $siteName, string $uri): bool
*/
public function isStaticFile(string $sitePath, string $siteName, string $uri)
{
if (file_exists($staticFilePath = $sitePath.'/public/'.$uri)) {
if (file_exists($staticFilePath = $sitePath . '/public/' . $uri)) {
return $staticFilePath;
}

Expand All @@ -36,6 +36,6 @@ public function isStaticFile(string $sitePath, string $siteName, string $uri)
*/
public function frontControllerPath(string $sitePath, string $siteName, string $uri): string
{
return $sitePath.'/public/index.php';
return $sitePath . '/public/index.php';
}
}

0 comments on commit c85a180

Please sign in to comment.