mirror of
https://github.com/laravel/valet.git
synced 2026-02-05 00:20:08 +01:00
load extensions
This commit is contained in:
@@ -26,6 +26,7 @@ function install()
|
||||
{
|
||||
$this->createConfigurationDirectory();
|
||||
$this->createDriversDirectory();
|
||||
$this->createExtensionsDirectory();
|
||||
$this->writeBaseConfiguration();
|
||||
|
||||
$this->files->chown($this->path(), user());
|
||||
@@ -38,9 +39,7 @@ function install()
|
||||
*/
|
||||
function createConfigurationDirectory()
|
||||
{
|
||||
if (! $this->files->isDir(VALET_HOME_PATH)) {
|
||||
$this->files->mkdirAsUser(VALET_HOME_PATH);
|
||||
}
|
||||
$this->files->ensureDirExists(VALET_HOME_PATH, user());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -62,6 +61,16 @@ function createDriversDirectory()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the directory for the Valet extensions.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function createExtensionsDirectory()
|
||||
{
|
||||
$this->files->ensureDirExists(VALET_HOME_PATH.'/Extensions', user());
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the base, initial configuration for Valet.
|
||||
*/
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace Valet;
|
||||
|
||||
use CommandLine as CommandLineFacade;
|
||||
|
||||
class Filesystem
|
||||
{
|
||||
/**
|
||||
@@ -199,20 +201,33 @@ function copyAsUser($from, $to)
|
||||
*
|
||||
* @param string $target
|
||||
* @param string $link
|
||||
* @param string|null $owner
|
||||
* @return void
|
||||
*/
|
||||
function symlink($target, $link, $owner = null)
|
||||
function symlink($target, $link)
|
||||
{
|
||||
if ($this->exists($link)) {
|
||||
$this->unlink($link);
|
||||
}
|
||||
|
||||
symlink($target, $link);
|
||||
}
|
||||
|
||||
if ($owner) {
|
||||
$this->chown($link, $owner);
|
||||
/**
|
||||
* Create a symlink to the given target for the non-root user.
|
||||
*
|
||||
* This uses the command line as PHP can't change symlink permissions.
|
||||
*
|
||||
* @param string $target
|
||||
* @param string $link
|
||||
* @return void
|
||||
*/
|
||||
function symlinkAsUser($target, $link)
|
||||
{
|
||||
if ($this->exists($link)) {
|
||||
$this->unlink($link);
|
||||
}
|
||||
|
||||
CommandLineFacade::runAsUser('ln -s '.$target.' '.$link);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -223,7 +238,7 @@ function symlink($target, $link, $owner = null)
|
||||
*/
|
||||
function unlink($path)
|
||||
{
|
||||
if ($this->exists($path)) {
|
||||
if (file_exists($path) || is_link($path)) {
|
||||
@unlink($path);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ function link($target, $link)
|
||||
|
||||
$this->config->prependPath($linkPath);
|
||||
|
||||
$this->cli->runAsUser('ln -s '.$target.' '.$linkPath.'/'.$link);
|
||||
$this->files->symlinkAsUser($target, $linkPath.'/'.$link);
|
||||
|
||||
return $linkPath.'/'.$link;
|
||||
}
|
||||
|
||||
@@ -46,13 +46,30 @@ function createSudoersEntry()
|
||||
%admin ALL=(root) NOPASSWD: VALET'.PHP_EOL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the paths to all of the Valet extensions.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function extensions()
|
||||
{
|
||||
if (! $this->files->isDir(VALET_HOME_PATH.'/Extensions')) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return collect($this->files->scandir(VALET_HOME_PATH.'/Extensions'))
|
||||
->reject(function ($file) {
|
||||
return is_dir($file);
|
||||
})->values()->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if this is the latest version of Valet.
|
||||
*
|
||||
* @param string $currentVersion
|
||||
* @return bool
|
||||
*/
|
||||
public function onLatestVersion($currentVersion)
|
||||
function onLatestVersion($currentVersion)
|
||||
{
|
||||
$response = \Httpful\Request::get('https://api.github.com/repos/laravel/valet/releases/latest')->send();
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace Valet\Facades;
|
||||
|
||||
class Facade
|
||||
{
|
||||
/**
|
||||
|
||||
@@ -11,16 +11,6 @@
|
||||
}
|
||||
|
||||
use Silly\Application;
|
||||
use Valet\Facades\Brew;
|
||||
use Valet\Facades\Site;
|
||||
use Valet\Facades\Valet;
|
||||
use Valet\Facades\Caddy;
|
||||
use Valet\Facades\Ngrok;
|
||||
use Valet\Facades\PhpFpm;
|
||||
use Valet\Facades\DnsMasq;
|
||||
use Valet\Facades\Filesystem;
|
||||
use Valet\Facades\CommandLine;
|
||||
use Valet\Facades\Configuration;
|
||||
use Illuminate\Container\Container;
|
||||
|
||||
/**
|
||||
@@ -227,6 +217,13 @@
|
||||
}
|
||||
})->descriptions('Determine if this is the latest version of Valet');
|
||||
|
||||
/**
|
||||
* Load all of the Valet extensions.
|
||||
*/
|
||||
foreach (Valet::extensions() as $extension) {
|
||||
include $extension;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the application.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user