-
Notifications
You must be signed in to change notification settings - Fork 705
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move upgrade calls into Upgrader class, and add upgrade to check for …
…old custom drivers
- Loading branch information
1 parent
ab8c4e8
commit 9b09621
Showing
4 changed files
with
77 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
namespace Valet; | ||
|
||
use Configuration; | ||
use Site; | ||
|
||
class Upgrader | ||
{ | ||
public function __construct(public Filesystem $files) | ||
{ | ||
} | ||
|
||
/** | ||
* Relocate config dir to ~/.config/valet/ if found in old location. | ||
* | ||
* @return void | ||
*/ | ||
public function relocateOldConfig() | ||
{ | ||
if (is_dir(VALET_LEGACY_HOME_PATH) && ! is_dir(VALET_HOME_PATH)) { | ||
Configuration::createConfigurationDirectory(); | ||
} | ||
} | ||
|
||
public function pruneMissingDirectories() | ||
{ | ||
Configuration::prune(); | ||
} | ||
|
||
public function pruneSymbolicLinks() | ||
{ | ||
Site::pruneLinks(); | ||
} | ||
|
||
public function fixOldSampleValetDriver() | ||
{ | ||
$samplePath = VALET_HOME_PATH.'/Drivers/SampleValetDriver.php'; | ||
|
||
if ($this->files->exists($samplePath)) { | ||
if (! str_contains($this->files->get($samplePath), 'namespace')) { | ||
$this->files->putAsUser( | ||
VALET_HOME_PATH.'/Drivers/SampleValetDriver.php', | ||
$this->files->getStub('SampleValetDriver.php') | ||
); | ||
} | ||
} | ||
} | ||
|
||
public function errorIfOldCustomDrivers() | ||
{ | ||
$driversPath = VALET_HOME_PATH.'/Drivers'; | ||
|
||
foreach ($this->files->scanDir($driversPath) as $driver) { | ||
if (! str_contains($this->files->get($driversPath.'/'.$driver), 'namespace')) { | ||
warning('Please make sure all custom drivers have been upgraded for Valet 4.'); | ||
exit; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters