Skip to content

Commit

Permalink
The input device is not a TTY (#353)
Browse files Browse the repository at this point in the history
* Add failing test for TTY issue

* Fix TTY issue in console

* Clean up unneeded variable

* Move test script to a gist

* Update sail

Co-authored-by: Breno Ribeiro <[email protected]>
Co-authored-by: Taylor Otwell <[email protected]>
  • Loading branch information
3 people authored Mar 8, 2022
1 parent 3f4ee92 commit effd276
Showing 1 changed file with 81 additions and 87 deletions.
168 changes: 81 additions & 87 deletions bin/sail
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,17 @@ else
EXEC="yes"
fi

ARGS=(-f "$SAIL_FILE")

if [ $# -gt 0 ]; then
# Proxy PHP commands to the "php" binary on the application container...
if [ "$1" == "php" ]; then
shift 1

if [ "$EXEC" == "yes" ]; then
docker-compose -f $SAIL_FILE exec \
-u sail \
"$APP_SERVICE" \
php "$@"
ARGS+=(exec -u sail)
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" "php" "$@")
else
sail_is_not_running
fi
Expand All @@ -94,10 +95,9 @@ if [ $# -gt 0 ]; then
shift 1

if [ "$EXEC" == "yes" ]; then
docker-compose -f $SAIL_FILE exec \
-u sail \
"$APP_SERVICE" \
./vendor/bin/"$@"
ARGS+=(exec -u sail)
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" ./vendor/bin/"$@")
else
sail_is_not_running
fi
Expand All @@ -107,10 +107,9 @@ if [ $# -gt 0 ]; then
shift 1

if [ "$EXEC" == "yes" ]; then
docker-compose -f $SAIL_FILE exec \
-u sail \
"$APP_SERVICE" \
composer "$@"
ARGS+=(exec -u sail)
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" "composer" "$@")
else
sail_is_not_running
fi
Expand All @@ -120,10 +119,9 @@ if [ $# -gt 0 ]; then
shift 1

if [ "$EXEC" == "yes" ]; then
docker-compose -f $SAIL_FILE exec \
-u sail \
"$APP_SERVICE" \
php artisan "$@"
ARGS+=(exec -u sail)
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" php artisan "$@")
else
sail_is_not_running
fi
Expand All @@ -133,11 +131,9 @@ if [ $# -gt 0 ]; then
shift 1

if [ "$EXEC" == "yes" ]; then
docker-compose -f $SAIL_FILE exec \
-u sail \
-e XDEBUG_SESSION=1 \
"$APP_SERVICE" \
php artisan "$@"
ARGS+=(exec -u sail -e XDEBUG_SESSION=1)
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" php artisan "$@")
else
sail_is_not_running
fi
Expand All @@ -147,10 +143,9 @@ if [ $# -gt 0 ]; then
shift 1

if [ "$EXEC" == "yes" ]; then
docker-compose -f $SAIL_FILE exec \
-u sail \
"$APP_SERVICE" \
php artisan test "$@"
ARGS+=(exec -u sail)
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" php artisan test "$@")
else
sail_is_not_running
fi
Expand All @@ -160,10 +155,9 @@ if [ $# -gt 0 ]; then
shift 1

if [ "$EXEC" == "yes" ]; then
docker-compose -f $SAIL_FILE exec \
-u sail \
"$APP_SERVICE" \
php vendor/bin/phpunit "$@"
ARGS+=(exec -u sail)
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" php vendor/bin/phpunit "$@")
else
sail_is_not_running
fi
Expand All @@ -173,12 +167,11 @@ if [ $# -gt 0 ]; then
shift 1

if [ "$EXEC" == "yes" ]; then
docker-compose -f $SAIL_FILE exec \
-u sail \
-e "APP_URL=http://${APP_SERVICE}" \
-e "DUSK_DRIVER_URL=http://selenium:4444/wd/hub" \
"$APP_SERVICE" \
php artisan dusk "$@"
ARGS+=(exec -u sail)
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=(-e "APP_URL=http://${APP_SERVICE}")
ARGS+=(-e "DUSK_DRIVER_URL=http://selenium:4444/wd/hub")
ARGS+=("$APP_SERVICE" php artisan dusk "$@")
else
sail_is_not_running
fi
Expand All @@ -188,12 +181,11 @@ if [ $# -gt 0 ]; then
shift 1

if [ "$EXEC" == "yes" ]; then
docker-compose -f $SAIL_FILE exec \
-u sail \
-e "APP_URL=http://${APP_SERVICE}" \
-e "DUSK_DRIVER_URL=http://selenium:4444/wd/hub" \
"$APP_SERVICE" \
php artisan dusk:fails "$@"
ARGS+=(exec -u sail)
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=(-e "APP_URL=http://${APP_SERVICE}")
ARGS+=(-e "DUSK_DRIVER_URL=http://selenium:4444/wd/hub")
ARGS+=("$APP_SERVICE" php artisan dusk:fails "$@")
else
sail_is_not_running
fi
Expand All @@ -203,10 +195,9 @@ if [ $# -gt 0 ]; then
shift 1

if [ "$EXEC" == "yes" ]; then
docker-compose -f $SAIL_FILE exec \
-u sail \
"$APP_SERVICE" \
php artisan tinker
ARGS+=(exec -u sail)
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" php artisan tinker)
else
sail_is_not_running
fi
Expand All @@ -216,10 +207,9 @@ if [ $# -gt 0 ]; then
shift 1

if [ "$EXEC" == "yes" ]; then
docker-compose -f $SAIL_FILE exec \
-u sail \
"$APP_SERVICE" \
node "$@"
ARGS+=(exec -u sail)
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" node "$@")
else
sail_is_not_running
fi
Expand All @@ -229,10 +219,9 @@ if [ $# -gt 0 ]; then
shift 1

if [ "$EXEC" == "yes" ]; then
docker-compose -f $SAIL_FILE exec \
-u sail \
"$APP_SERVICE" \
npm "$@"
ARGS+=(exec -u sail)
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" npm "$@")
else
sail_is_not_running
fi
Expand All @@ -242,10 +231,9 @@ if [ $# -gt 0 ]; then
shift 1

if [ "$EXEC" == "yes" ]; then
docker-compose -f $SAIL_FILE exec \
-u sail \
"$APP_SERVICE" \
npx "$@"
ARGS+=(exec -u sail)
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" npx "$@")
else
sail_is_not_running
fi
Expand All @@ -255,10 +243,9 @@ if [ $# -gt 0 ]; then
shift 1

if [ "$EXEC" == "yes" ]; then
docker-compose -f $SAIL_FILE exec \
-u sail \
"$APP_SERVICE" \
yarn "$@"
ARGS+=(exec -u sail)
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" yarn "$@")
else
sail_is_not_running
fi
Expand All @@ -268,9 +255,10 @@ if [ $# -gt 0 ]; then
shift 1

if [ "$EXEC" == "yes" ]; then
docker-compose -f $SAIL_FILE exec \
mysql \
bash -c 'MYSQL_PWD=${MYSQL_PASSWORD} mysql -u ${MYSQL_USER} ${MYSQL_DATABASE}'
ARGS+=(exec)
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=(mysql bash -c)
ARGS+=('MYSQL_PWD=${MYSQL_PASSWORD} mysql -u ${MYSQL_USER} ${MYSQL_DATABASE}')
else
sail_is_not_running
fi
Expand All @@ -280,9 +268,10 @@ if [ $# -gt 0 ]; then
shift 1

if [ "$EXEC" == "yes" ]; then
docker-compose -f $SAIL_FILE exec \
mariadb \
bash -c 'MYSQL_PWD=${MYSQL_PASSWORD} mysql -u ${MYSQL_USER} ${MYSQL_DATABASE}'
ARGS+=(exec)
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=(mariadb bash -c)
ARGS+=('MYSQL_PWD=${MYSQL_PASSWORD} mysql -u ${MYSQL_USER} ${MYSQL_DATABASE}')
else
sail_is_not_running
fi
Expand All @@ -292,9 +281,10 @@ if [ $# -gt 0 ]; then
shift 1

if [ "$EXEC" == "yes" ]; then
docker-compose -f $SAIL_FILE exec \
pgsql \
bash -c 'PGPASSWORD=${PGPASSWORD} psql -U ${POSTGRES_USER} ${POSTGRES_DB}'
ARGS+=(exec)
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=(pgsql bash -c)
ARGS+=('PGPASSWORD=${PGPASSWORD} psql -U ${POSTGRES_USER} ${POSTGRES_DB}')
else
sail_is_not_running
fi
Expand All @@ -304,10 +294,9 @@ if [ $# -gt 0 ]; then
shift 1

if [ "$EXEC" == "yes" ]; then
docker-compose -f $SAIL_FILE exec \
-u sail \
"$APP_SERVICE" \
bash "$@"
ARGS+=(exec -u sail)
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" bash "$@")
else
sail_is_not_running
fi
Expand All @@ -317,9 +306,9 @@ if [ $# -gt 0 ]; then
shift 1

if [ "$EXEC" == "yes" ]; then
docker-compose -f $SAIL_FILE exec \
"$APP_SERVICE" \
bash "$@"
ARGS+=(exec)
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" bash "$@")
else
sail_is_not_running
fi
Expand All @@ -329,9 +318,9 @@ if [ $# -gt 0 ]; then
shift 1

if [ "$EXEC" == "yes" ]; then
docker-compose -f $SAIL_FILE exec \
redis \
redis-cli
ARGS+=(exec)
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=(redis redis-cli)
else
sail_is_not_running
fi
Expand All @@ -342,19 +331,24 @@ if [ $# -gt 0 ]; then

if [ "$EXEC" == "yes" ]; then
docker run --init --rm -p $SAIL_SHARE_DASHBOARD:4040 -t beyondcodegmbh/expose-server:latest share http://host.docker.internal:"$APP_PORT" \
--server-host="$SAIL_SHARE_SERVER_HOST" \
--server-port="$SAIL_SHARE_SERVER_PORT" \
--auth="$SAIL_SHARE_TOKEN" \
--subdomain="$SAIL_SHARE_SUBDOMAIN" \
"$@"
--server-host="$SAIL_SHARE_SERVER_HOST" \
--server-port="$SAIL_SHARE_SERVER_PORT" \
--auth="$SAIL_SHARE_TOKEN" \
--subdomain="$SAIL_SHARE_SUBDOMAIN" \
"$@"

exit
else
sail_is_not_running
fi

# Pass unknown commands to the "docker-compose" binary...
else
docker-compose -f $SAIL_FILE "$@"
ARGS+=("$@")
fi
else
docker-compose -f $SAIL_FILE ps
ARGS+=(ps)
fi

# Run Docker Compose with the defined arguments...
docker-compose "${ARGS[@]}"

0 comments on commit effd276

Please sign in to comment.