1
0
mirror of https://github.com/laravel/valet.git synced 2026-02-05 00:20:08 +01:00

Clean up DX for fetch-share-url

This commit is contained in:
Matt Stauffer
2022-12-25 23:59:25 -05:00
parent 5988c4f881
commit f13be53b9f
4 changed files with 29 additions and 7 deletions

View File

@@ -52,7 +52,7 @@ public function currentTunnelUrl(?string $domain = null): string
}
}
throw new DomainException('Tunnel not established.');
throw new DomainException('There is no Ngrok tunnel established for '.$domain.'.');
}
/**
@@ -72,6 +72,8 @@ public function findHttpTunnelUrl(array $tunnels, string $domain): ?string
return $tunnel->public_url;
}
}
return null;
}
/**

View File

@@ -1109,6 +1109,12 @@ public function domain(?string $domain): string
// return $parked['site'];
// }
// Don't add .TLD if user already passed the string in with the TLD on the end
if ($domain && str_contains($domain, '.'.$this->config->read()['tld'])) {
return $domain;
}
// Return either the passed domain, or the current folder name, with .TLD appended
return ($domain ?: $this->host(getcwd())).'.'.$this->config->read()['tld'];
}

View File

@@ -303,7 +303,14 @@ function (ConsoleCommandEvent $event) {
* Echo the currently tunneled URL.
*/
$app->command('fetch-share-url [domain]', function (OutputInterface $output, $domain = null) {
output(Ngrok::currentTunnelUrl(Site::domain($domain)));
try {
output(Ngrok::currentTunnelUrl(Site::domain($domain)));
} catch (\Throwable $e) {
warning($e->getMessage());
if ($domain) {
warning("Make sure to leave out the TLD; `valet fetch-share-url project-name`");
}
}
})->descriptions('Get the URL to the current Ngrok tunnel');
/**
@@ -463,11 +470,6 @@ function (ConsoleCommandEvent $event) {
<error>BEWARE:</error> Uninstalling PHP via Homebrew will leave your Mac with its original PHP version, which may not be compatible with other Composer dependencies you have installed. Thus you may get unexpected errors.
Some additional services which you may have installed (but which Valet does not directly configure or manage) include: <comment>mariadb mysql mailhog</comment>.
If you wish to also remove them, you may manually run <comment>brew uninstall SERVICENAME</comment> and clean up their configurations in '.BREW_PREFIX.'/etc if necessary.
You can discover more Homebrew services by running: <comment>brew services list</comment> and <comment>brew list --formula</comment>
<fg=red>If you have customized your Mac DNS settings in System Preferences->Network, you may need to add or remove 127.0.0.1 from the top of that list.</>
<info>5. GENERAL TROUBLESHOOTING</info>