Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion commands/host/1x-granite
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
## #ddev-generated
## Description: Build granite
## Usage: granite 1x-granite
Expand Down
77 changes: 77 additions & 0 deletions commands/host/1x-lib.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/usr/bin/env bash
#
# Shared helper library for 1x DDEV host commands.
# Source this from any 1x-* command with:
# source "${BASH_SOURCE%/*}/1x-lib.sh"
#
# No ## Usage: header, so DDEV will not register this as a command.

# Colors for printing messages.
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
CYAN='\033[0;36m'
BROWN='\033[0;33m'
NC='\033[0m' # No Color

# Cross-platform "sed"
sed_compat() {
case "$OSTYPE" in
darwin*)
# BSD sed (macOS) needs '' after -i
local args=()
for arg in "$@"; do
if [[ "$arg" == "-i" ]]; then
args+=("-i" "")
else
args+=("$arg")
fi
done
sed "${args[@]}"
;;
linux*)
sed "$@"
;;
*)
echo "sed_compat: unsupported platform: $OSTYPE" >&2
return 1
;;
esac
}

# Cross-platform "date"
date_compat() {
case "$OSTYPE" in
darwin*)
# BSD date (macOS) lacks GNU extensions
if command -v gdate >/dev/null 2>&1; then
gdate "$@"
else
date "$@"
fi
;;
linux*)
date "$@"
;;
*)
echo "date_compat: unsupported platform: $OSTYPE" >&2
return 1
;;
esac
}

# Cross-platform "open"
open_compat() {
case "$OSTYPE" in
darwin*)
open "$@"
;;
linux*)
xdg-open "$@"
;;
*)
echo "open_compat: unsupported platform: $OSTYPE" >&2
return 1
;;
esac
}
25 changes: 10 additions & 15 deletions commands/host/1x-playwright
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
#!/bin/bash
#!/usr/bin/env bash

## #ddev-generated
## Description: Run lullabot/ddev-playwright commands in a slightly more sane way :)
##
## Usage: 1x-playwright
## OSTypes: darwin,linux

start=`date +%s`
source "${BASH_SOURCE%/*}/1x-lib.sh"

# Colors for printing messages.
RED='\033[0;31m'
CYAN='\033[0;36m'
GREEN='\033[0;32m'
BROWN='\033[0;33m'
NC='\033[0m' # No Color
start=`date_compat +%s`

if ! command -v jq 2>&1 >/dev/null
then
Expand All @@ -39,15 +34,15 @@ else
host=$(ddev_hostname)
playwright_report_url="https://${host}:9324"
# Note: playwright "report server" hangs.
sleep 1 && open $playwright_report_url & jobs
sleep 1 && open_compat $playwright_report_url & jobs
ddev playwright test "${@:2} --ui-host=0.0.0.0 --ui-port=9323"
;;

"codegen")
host=$(ddev_hostname)
kasmvnc_url="https://${host}:8444"
echo "Please note - if asked for authentication login is your username on the host (`whoami`) and the password is 'secret' (without the ')"
sleep 1 && open $kasmvnc_url & jobs
sleep 1 && open_compat $kasmvnc_url & jobs
ddev playwright codegen "${@:2}"
;;

Expand All @@ -62,15 +57,15 @@ else
host=$(ddev_hostname)
playwright_report_url="https://${host}:9324"
# Note: playwright "report server" hangs.
sleep 1 && open $playwright_report_url & jobs
sleep 1 && open_compat $playwright_report_url & jobs
ddev playwright show-report --host=0.0.0.0
;;

"cr")
host=$(ddev_hostname)
kasmvnc_url="https://${host}:8444"
# Note: playwright "ff|cr|wk" hangs.
sleep 1 && open $kasmvnc_url & jobs
sleep 1 && open_compat $kasmvnc_url & jobs
echo "Please note - if asked for authentication login is your username on the host (`whoami`) and the password is 'secret' (without the ')"
ddev playwright "$1" "${@:2}"
;;
Expand All @@ -79,7 +74,7 @@ else
host=$(ddev_hostname)
kasmvnc_url="https://${host}:8444"
# Note: playwright "ff|cr|wk" hangs.
sleep 1 && open $kasmvnc_url & jobs
sleep 1 && open_compat $kasmvnc_url & jobs
echo "Please note - if asked for authentication login is your username on the host (`whoami`) and the password is 'secret' (without the ')"
ddev playwright "$1" "${@:2}"
;;
Expand All @@ -88,7 +83,7 @@ else
host=$(ddev_hostname)
kasmvnc_url="https://${host}:8444"
# Note: playwright "ff|cr|wk" hangs.
sleep 1 && open $kasmvnc_url & jobs
sleep 1 && open_compat $kasmvnc_url & jobs
echo "Please note - if asked for authentication login is your username on the host (`whoami`) and the password is 'secret' (without the ')"
ddev playwright "$1" "${@:2}"
;;
Expand All @@ -97,7 +92,7 @@ else
host=$(ddev_hostname)
kasmvnc_url="https://${host}:8444"
echo "Please note - if asked for authentication login is your username on the host (`whoami`) and the password is 'secret' (without the ')"
open $kasmvnc_url
open_compat $kasmvnc_url
;;

*)
Expand Down
8 changes: 3 additions & 5 deletions commands/host/1x-playwright-install
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
#!/bin/bash
#!/usr/bin/env bash

## #ddev-generated
## Description: Install the lullabot/ddev-playwright addon and does some basic onex config.
## Usage: 1x-playwright-install

start=`date +%s`
source "${BASH_SOURCE%/*}/1x-lib.sh"

# Colors for printing messages.
GREEN='\033[0;32m'
NC='\033[0m' # No Color
start=`date_compat +%s`

# Make sure the container is alive.
ddev start
Expand Down
2 changes: 1 addition & 1 deletion commands/host/1x-start
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
#ddev-generated
## Description: Starts the ddev project, runs auth and makes sure the .gitconfig is present.
## Usage: 1x-start
Expand Down
16 changes: 5 additions & 11 deletions commands/host/1x-theme-debug
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#!/bin/bash
#!/usr/bin/env bash
## #ddev-generated
## Description: manage php config options
## Usage: 1x-theme-debug
## Example: "ddev 1x-theme-debug (enable|disable)"

source "${BASH_SOURCE%/*}/1x-lib.sh"

settings_dir="${DDEV_APPROOT}/${DDEV_DOCROOT}/sites/default"
settings_local="settings.local.php"
debug_services="services.theme_debug.yml"
Expand Down Expand Up @@ -49,11 +51,7 @@ preflight() {
fi

# Delete the config always, so that enabling twice doesn't add it multiple times.
if [[ $OSTYPE == darwin* ]]; then
sed -i '' '/^#.*DO NOT WRITE ANYTHING BELOW THIS LINE/,$d' "${settings_dir}/${settings_local}"
else
sed -i '/^#.*DO NOT WRITE ANYTHING BELOW THIS LINE/,$d' "${settings_dir}/${settings_local}"
fi
sed_compat -i '/^#.*DO NOT WRITE ANYTHING BELOW THIS LINE/,$d' "${settings_dir}/${settings_local}"
}

enable_debug() {
Expand All @@ -64,11 +62,7 @@ enable_debug() {
echo "${debug_settings_php}" > "${settings_dir}/${debug_settings}"

# Make sure the file ends with a new line
if [[ $OSTYPE == darwin* ]]; then
sed -i '' '$a\' "${settings_dir}/${settings_local}"
else
sed -i '$a\' "${settings_dir}/${settings_local}"
fi
sed_compat -i '$a\' "${settings_dir}/${settings_local}"
echo -e "${debug_config_php}" >> "${settings_dir}/${settings_local}"
}

Expand Down
23 changes: 9 additions & 14 deletions commands/host/1x-token-setup
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#!/bin/bash
#!/usr/bin/env bash
## #ddev-generated
# Description: Setup GitLab tokens, composer gitlab tokens as well as npm gitlab tokens and npm scoped packages.
# Usage: 1x-token-setup

set -e

source "${BASH_SOURCE%/*}/1x-lib.sh"

# Stop the current DDEV project (if running).
if ddev describe > /dev/null 2>&1; then
ddev stop
Expand Down Expand Up @@ -74,26 +76,19 @@ fi
# Setup token for NPM
# Remove old token if exists to replace with new one, or just append
# A simple append might create duplicates, so let's try to be a bit smarter or just append as requested
# Make this work on MacOS and Linux >.<
if [[ $OSTYPE == darwin* ]]; then
# "in-place editing only works for regular files" thus change directly ~/.npmrc
sed -i '' '/\/\/git.1xinternet.de\/:_authToken=/d' ~/.npmrc
else
# "In-place editing" works also for symlinks on Linux, but for consistency's sake.
sed -i '/\/\/git.1xinternet.de\/:_authToken=/d' ~/.npmrc
fi
echo "//git.1xinternet.de/:_authToken=${PERSONAL_ACCESS_TOKEN}" >> ~/.ddev/homeadditions/.npmrc
sed_compat -i '/\/\/git.1xinternet.de\/.*:_authToken=/d' ~/.npmrc
echo "//git.1xinternet.de/:_authToken=${PERSONAL_ACCESS_TOKEN}" >> ~/.npmrc

# Configure NPM in homeadditions so the container picks it up.
# We append if not already present to avoid duplication
if ! grep -q "@dxp:registry=https://git.1xinternet.de/api/v4/groups/392/-/packages/npm/" ~/.ddev/homeadditions/.npmrc; then
echo "@dxp:registry=https://git.1xinternet.de/api/v4/groups/392/-/packages/npm/" >> ~/.ddev/homeadditions/.npmrc
if ! grep -q "@dxp:registry=https://git.1xinternet.de/api/v4/groups/392/-/packages/npm/" ~/.npmrc; then
echo "@dxp:registry=https://git.1xinternet.de/api/v4/groups/392/-/packages/npm/" >> ~/.npmrc
fi

# Configure NPM in homeadditions so the container picks it up.
# We append if not already present to avoid duplication
if ! grep -q "@1xINTERNET:registry=https://git.1xinternet.de/api/v4/group/1121/-/packages/npm/" ~/.ddev/homeadditions/.npmrc; then
echo "@1xINTERNET:registry=https://git.1xinternet.de/api/v4/projects/1121/packages/npm/" >> ~/.ddev/homeadditions/.npmrc
if ! grep -q "@1xINTERNET:registry=https://git.1xinternet.de/api/v4/projects/1121/packages/npm/" ~/.npmrc; then
echo "@1xINTERNET:registry=https://git.1xinternet.de/api/v4/projects/1121/packages/npm/" >> ~/.npmrc
fi

# Start the DDEV project (so containers run).
Expand Down
2 changes: 1 addition & 1 deletion commands/host/1x-twig-debug
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
## #ddev-generated
## Description: Enables or disables Twig debugging for Drupal 10 installations
## Usage: 1x-twig-debug
Expand Down
2 changes: 1 addition & 1 deletion commands/web/1x-phpcs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
## #ddev-generated
## Description: Run phpcs within the web container
## Usage: 1x-phpcs
Expand Down