From ef1a943067833e1b2ddf40becf18adc74fa6ff38 Mon Sep 17 00:00:00 2001 From: Joseph Richardson Date: Tue, 26 Mar 2024 04:57:38 -0400 Subject: [PATCH] Add proxy for Drush commands (#635) This will ensure that isolated sites use the correct version of php with Drush. User Login (ULI) has been improved with added uri which is known by Valet. This requires the added command which-uri to output the domain without any protocol. --- cli/valet.php | 7 +++++++ valet-plus | 14 ++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/cli/valet.php b/cli/valet.php index 9479e1d9..4ffa06ce 100755 --- a/cli/valet.php +++ b/cli/valet.php @@ -737,6 +737,13 @@ $app->command('configure', function () { DriverConfigurator::configure(); })->descriptions('Configure application with know framework settings'); + + /** + * Which-uri command which outputs the URL of the current site. + */ + $app->command('which-uri', function () { + output(Site::domain(null)); + })->descriptions('Displays the URL of the current site'); } /** diff --git a/valet-plus b/valet-plus index 042a99a7..ea25db90 100755 --- a/valet-plus +++ b/valet-plus @@ -182,6 +182,20 @@ then exit +# Proxy Drush commands with the "php" executable on the isolated site +elif [[ "$1" = "drush" ]] +then + if [[ $2 == *"--site="* ]]; then + SITE=${2#*=} + $(php "$DIR/cli/valet.php" which-php $SITE) $(which drush) "${@:3}" + elif [[ $2 == "uli" ]]; then + $(php "$DIR/cli/valet.php" which-php) $(which drush) uli --uri=$(php "$DIR/cli/valet.php" which-uri) "${@:3}" + else + $(php "$DIR/cli/valet.php" which-php) $(which drush) "${@:2}" + fi + + exit + # Finally, for every other command we will just proxy into the PHP tool # and let it handle the request. These are commands which can be run # without sudo and don't require taking over terminals like Ngrok.