mirror of
https://github.com/bitinflow/expose.git
synced 2026-03-15 06:25:56 +00:00
auto detect valet links
This commit is contained in:
@@ -8,12 +8,12 @@ class ShareCurrentWorkingDirectoryCommand extends ShareCommand
|
|||||||
|
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
$host = $this->prepareSharedHost(basename(getcwd()).'.'.$this->detectTld());
|
$subdomain = $this->detectName();
|
||||||
|
$host = $this->prepareSharedHost($subdomain.'.'.$this->detectTld());
|
||||||
|
|
||||||
$this->input->setArgument('host', $host);
|
$this->input->setArgument('host', $host);
|
||||||
|
|
||||||
if (! $this->option('subdomain')) {
|
if (! $this->option('subdomain')) {
|
||||||
$subdomain = str_replace('.', '-', basename(getcwd()));
|
|
||||||
$this->input->setOption('subdomain', $subdomain);
|
$this->input->setOption('subdomain', $subdomain);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,6 +33,30 @@ class ShareCurrentWorkingDirectoryCommand extends ShareCommand
|
|||||||
return config('expose.default_tld', 'test');
|
return config('expose.default_tld', 'test');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function detectName(): string
|
||||||
|
{
|
||||||
|
$projectPath = getcwd();
|
||||||
|
$valetSitesPath = ($_SERVER['HOME'] ?? $_SERVER['USERPROFILE']).DIRECTORY_SEPARATOR.'.config'.DIRECTORY_SEPARATOR.'valet'.DIRECTORY_SEPARATOR.'Sites';
|
||||||
|
|
||||||
|
if (is_dir($valetSitesPath)) {
|
||||||
|
$site = collect(scandir($valetSitesPath))
|
||||||
|
->skip(2)
|
||||||
|
->map(function($site) use($valetSitesPath) {
|
||||||
|
return $valetSitesPath.DIRECTORY_SEPARATOR.$site;
|
||||||
|
})->mapWithKeys(function($site){
|
||||||
|
return [$site => readlink($site)];
|
||||||
|
})->filter(function($sourcePath) use($projectPath) {
|
||||||
|
return $sourcePath === $projectPath;
|
||||||
|
})
|
||||||
|
->keys()
|
||||||
|
->first();
|
||||||
|
|
||||||
|
$projectPath = $site;
|
||||||
|
}
|
||||||
|
|
||||||
|
return str_replace('.', '-', basename($projectPath));
|
||||||
|
}
|
||||||
|
|
||||||
protected function prepareSharedHost($host): string
|
protected function prepareSharedHost($host): string
|
||||||
{
|
{
|
||||||
$certificateFile = ($_SERVER['HOME'] ?? $_SERVER['USERPROFILE']).DIRECTORY_SEPARATOR.'.config'.DIRECTORY_SEPARATOR.'valet'.DIRECTORY_SEPARATOR.'Certificates'.DIRECTORY_SEPARATOR.$host.'.crt';
|
$certificateFile = ($_SERVER['HOME'] ?? $_SERVER['USERPROFILE']).DIRECTORY_SEPARATOR.'.config'.DIRECTORY_SEPARATOR.'valet'.DIRECTORY_SEPARATOR.'Certificates'.DIRECTORY_SEPARATOR.$host.'.crt';
|
||||||
|
|||||||
Reference in New Issue
Block a user