Skip to content

Commit

Permalink
Refactor xhgui launch command (#31)
Browse files Browse the repository at this point in the history
* refactor xhgui launch command

* restrict to DDEV 1.23+

---------

Co-authored-by: tyler36 <[email protected]>
  • Loading branch information
tyler36 and tyler36 authored Jun 4, 2024
1 parent 4069fa6 commit 1d9310b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 39 deletions.
42 changes: 3 additions & 39 deletions commands/host/xhgui
Original file line number Diff line number Diff line change
Expand Up @@ -8,44 +8,8 @@
DDEV_XHGUI_PORT=8143
DDEV_XHGUI_HTTPS_PORT=8142

FULLURL=${DDEV_PRIMARY_URL}
HTTPS=""
if [ ${DDEV_PRIMARY_URL%://*} = "https" ]; then HTTPS=true; fi

if [[ ! -z "${GITPOD_INSTANCE_ID}" ]] || [[ "${CODESPACES}" == "true" ]]; then
FULLURL="${FULLURL/-${DDEV_HOST_WEBSERVER_PORT}/-${DDEV_XHGUI_PORT}}"
if [ ${DDEV_PRIMARY_URL%://*} = "https" ]; then
ddev launch $DDEV_PRIMARY_URL:$DDEV_XHGUI_HTTPS_PORT
else
if [ "${HTTPS}" = "" ]; then
FULLURL="${FULLURL%:[0-9]*}:${DDEV_XHGUI_PORT}"
else
FULLURL="${FULLURL%:[0-9]*}:${DDEV_XHGUI_HTTPS_PORT}"
fi
fi

if [ -n "${1:-}" ]; then
if [[ ${1::1} != "/" ]]; then
FULLURL="${FULLURL}/"
fi

FULLURL="${FULLURL}${1}"
ddev launch $DDEV_PRIMARY_URL::$DDEV_XHGUI_PORT
fi

if [ "${DDEV_DEBUG:-}" = "true" ]; then
printf "FULLURL $FULLURL\n" && exit 0
fi

case $OSTYPE in
linux-gnu)
if [[ ! -z "${GITPOD_INSTANCE_ID}" ]]; then
gp preview ${FULLURL}
else
xdg-open ${FULLURL}
fi
;;
"darwin"*)
open ${FULLURL}
;;
"win*"* | "msys"*)
start ${FULLURL}
;;
esac
7 changes: 7 additions & 0 deletions install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ project_files:
- xhgui/collector/xhgui.collector.php
- xhgui/nginx.conf

pre_install_actions:
# Ensure we're on DDEV 1.23+. It's need for the `xhgui` command (launch by port).
- |
#ddev-nodisplay
#ddev-description:Checking DDEV version
(ddev debug capabilities | grep corepack >/dev/null) || (echo "Please upgrade DDEV to v1.23+ to enable launching." && false)
removal_actions:
- if [[ "$DDEV_DATABASE_FAMILY" == "postgres" ]]; then ddev psql -U db -c "drop database xhgui"; fi
- if [[ "$DDEV_DATABASE_FAMILY" != "postgres" ]]; then ddev mysql -uroot -proot -e "DROP DATABASE IF EXISTS xhgui"; fi

0 comments on commit 1d9310b

Please sign in to comment.