mirror of
https://github.com/laravel/valet.git
synced 2026-02-07 01:00:09 +01:00
Add the ability for drivers to check Composer dependencies (#1345)
This commit is contained in:
@@ -15,34 +15,18 @@ public function serves(string $sitePath, string $siteName, string $uri): bool
|
||||
$this->isLegacySculpinProject($sitePath);
|
||||
}
|
||||
|
||||
private function isModernSculpinProject($sitePath): bool
|
||||
private function isModernSculpinProject(string $sitePath): bool
|
||||
{
|
||||
return is_dir($sitePath.'/source') &&
|
||||
is_dir($sitePath.'/output_dev') &&
|
||||
$this->composerRequiresSculpin($sitePath);
|
||||
$this->composerRequires($sitePath, 'sculpin/sculpin');
|
||||
}
|
||||
|
||||
private function isLegacySculpinProject($sitePath): bool
|
||||
private function isLegacySculpinProject(string $sitePath): bool
|
||||
{
|
||||
return is_dir($sitePath.'/.sculpin');
|
||||
}
|
||||
|
||||
private function composerRequiresSculpin($sitePath): bool
|
||||
{
|
||||
if (! file_exists($sitePath.'/composer.json')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$composer_json_source = file_get_contents($sitePath.'/composer.json');
|
||||
$composer_json = json_decode($composer_json_source, true);
|
||||
|
||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return isset($composer_json['require']['sculpin/sculpin']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mutate the incoming URI.
|
||||
*/
|
||||
|
||||
@@ -196,4 +196,20 @@ public function loadServerEnvironmentVariables(string $sitePath, string $siteNam
|
||||
putenv($key.'='.$value);
|
||||
}
|
||||
}
|
||||
|
||||
public function composerRequires(string $sitePath, string $namespacedPackage): bool
|
||||
{
|
||||
if (! file_exists($sitePath.'/composer.json')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$composer_json_source = file_get_contents($sitePath.'/composer.json');
|
||||
$composer_json = json_decode($composer_json_source, true);
|
||||
|
||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return isset($composer_json['require'][$namespacedPackage]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user