From 2f31609f6ae0bf058be8c0f034c609b12affc7f1 Mon Sep 17 00:00:00 2001 From: Samuel Reina Date: Fri, 6 Mar 2026 11:23:55 +0100 Subject: [PATCH 01/12] Fix shell quoting in 1x-playwright test command so user args and --ui flags are passed as separate arguments instead of one concatenated string --- commands/host/1x-playwright | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/host/1x-playwright b/commands/host/1x-playwright index 59a349f..67b9e81 100755 --- a/commands/host/1x-playwright +++ b/commands/host/1x-playwright @@ -35,7 +35,7 @@ else playwright_report_url="https://${host}:9324" # Note: playwright "report server" hangs. sleep 1 && open_compat $playwright_report_url & jobs - ddev playwright test "${@:2} --ui-host=0.0.0.0 --ui-port=9323" + ddev playwright test "${@:2}" --ui-host=0.0.0.0 --ui-port=9323 ;; "codegen") From 7c735e57a44056e959c61e74a0383dc687f279f6 Mon Sep 17 00:00:00 2001 From: Samuel Reina Date: Fri, 6 Mar 2026 13:41:18 +0100 Subject: [PATCH 02/12] Fix test assertion for auth token path to match the broader scope (//git.1xinternet.de/:_authToken=) that the script has been writing since commit 6f42954 --- tests/test.bats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test.bats b/tests/test.bats index d12855b..106842f 100644 --- a/tests/test.bats +++ b/tests/test.bats @@ -46,5 +46,5 @@ teardown() { [ "$output" = "https://git.1xinternet.de/api/v4/projects/1121/packages/npm/" ] run ddev exec "grep '=123' ~/.npmrc" [ "$status" -eq 0 ] - [ "$output" = "//git.1xinternet.de/api/v4/packages/npm/:_authToken=123" ] + [ "$output" = "//git.1xinternet.de/:_authToken=123" ] } \ No newline at end of file From bc70234002a3583fc5b4e60393af32d99907ed73 Mon Sep 17 00:00:00 2001 From: Samuel Reina Date: Fri, 6 Mar 2026 13:41:23 +0100 Subject: [PATCH 03/12] Make 1x-token-setup executable (100755) to match all other ddev host commands --- commands/host/1x-token-setup | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 commands/host/1x-token-setup diff --git a/commands/host/1x-token-setup b/commands/host/1x-token-setup old mode 100644 new mode 100755 From 4d43d1fccf3c4e40ea6c9a3bdf386d7360ad7db2 Mon Sep 17 00:00:00 2001 From: Samuel Reina Date: Fri, 6 Mar 2026 13:41:32 +0100 Subject: [PATCH 04/12] Replace redundant ddev stop + ddev start with single ddev restart at end of 1x-token-setup --- commands/host/1x-token-setup | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/commands/host/1x-token-setup b/commands/host/1x-token-setup index 08f3337..266b399 100755 --- a/commands/host/1x-token-setup +++ b/commands/host/1x-token-setup @@ -161,7 +161,6 @@ else fi # Restart so everything is fully synced. -ddev stop -ddev start +ddev restart echo "Setup complete!" From ad46a40b439da74eccdbd72978cbf902301e6efb Mon Sep 17 00:00:00 2001 From: Samuel Reina Date: Fri, 6 Mar 2026 13:47:26 +0100 Subject: [PATCH 05/12] Add preflight check in 1x-playwright to verify npm token is configured and guide developers to run 1x-token-setup if missing --- commands/host/1x-playwright | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/commands/host/1x-playwright b/commands/host/1x-playwright index 67b9e81..193ca58 100755 --- a/commands/host/1x-playwright +++ b/commands/host/1x-playwright @@ -29,6 +29,12 @@ if [ -z "${playwright_installed_inside_ddev}" ]; then npx playwright "${@:1}" else echo "Note: Using playwright inside ddev container!" + DXP_REGISTRY=$(ddev exec "npm config get @dxp:registry") + if [ -z "$DXP_REGISTRY" ] || [ "$DXP_REGISTRY" = "undefined" ]; then + echo "Error: The @dxp npm scope is not configured inside the container." + echo "Please run 'ddev 1x-token-setup' first to configure your GitLab token." + exit 1 + fi case "$1" in "ui") host=$(ddev_hostname) From 448253687d987d0e91892285546a405313fc9303 Mon Sep 17 00:00:00 2001 From: Samuel Reina Date: Fri, 6 Mar 2026 14:04:53 +0100 Subject: [PATCH 06/12] Replace grep-guard with sed-remove-then-append for npm scoped registries to clean up duplicates and stale URLs on re-runs --- commands/host/1x-token-setup | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/commands/host/1x-token-setup b/commands/host/1x-token-setup index 266b399..99546ea 100755 --- a/commands/host/1x-token-setup +++ b/commands/host/1x-token-setup @@ -79,17 +79,13 @@ fi 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/" ~/.npmrc; then - echo "@dxp:registry=https://git.1xinternet.de/api/v4/groups/392/-/packages/npm/" >> ~/.npmrc -fi +# Configure NPM scoped registries. +# Remove any existing entries for these scopes first to avoid duplicates and stale URLs. +sed_compat -i '/@dxp:registry=/d' ~/.npmrc +echo "@dxp:registry=https://git.1xinternet.de/api/v4/groups/392/-/packages/npm/" >> ~/.npmrc -# 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/projects/1121/packages/npm/" ~/.npmrc; then - echo "@1xINTERNET:registry=https://git.1xinternet.de/api/v4/projects/1121/packages/npm/" >> ~/.npmrc -fi +sed_compat -i '/@1xINTERNET:registry=/d' ~/.npmrc +echo "@1xINTERNET:registry=https://git.1xinternet.de/api/v4/projects/1121/packages/npm/" >> ~/.npmrc # Start the DDEV project (so containers run). ddev start From 9f4f3a5ef418b0ac05ce91aa4cfbd4227f07f674 Mon Sep 17 00:00:00 2001 From: Samuel Reina Date: Fri, 6 Mar 2026 15:40:46 +0100 Subject: [PATCH 07/12] Fix non-interactive mode hanging on read when no token is found, and fix .composer symlink failing when homeadditions/.composer is a real directory --- commands/host/1x-token-setup | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/commands/host/1x-token-setup b/commands/host/1x-token-setup index 99546ea..ec307fd 100755 --- a/commands/host/1x-token-setup +++ b/commands/host/1x-token-setup @@ -23,11 +23,19 @@ fi touch ~/.npmrc # Symlink your local config into DDEV's homeadditions -# Using -f to force overwrite if symlink exists -# Symlink directory: -ln -sf "$(realpath ~/.composer)" ~/.ddev/homeadditions -# Symlink file: -ln -sf "$(realpath ~/.npmrc)" ~/.ddev/homeadditions/.npmrc +# Only replace if it's not already a symlink pointing to the right target. +COMPOSER_TARGET="$(realpath ~/.composer)" +if [ "$(readlink ~/.ddev/homeadditions/.composer 2>/dev/null)" != "$COMPOSER_TARGET" ]; then + if [ -e ~/.ddev/homeadditions/.composer ]; then + echo "Warning: replacing existing ~/.ddev/homeadditions/.composer with symlink to $COMPOSER_TARGET" + fi + rm -rf ~/.ddev/homeadditions/.composer + ln -s "$COMPOSER_TARGET" ~/.ddev/homeadditions/.composer +fi +NPMRC_TARGET="$(realpath ~/.npmrc)" +if [ "$(readlink ~/.ddev/homeadditions/.npmrc 2>/dev/null)" != "$NPMRC_TARGET" ]; then + ln -sf "$NPMRC_TARGET" ~/.ddev/homeadditions/.npmrc +fi # Set your personal access token # Check if PERSONAL_ACCESS_TOKEN is set, otherwise try to get it from composer @@ -62,8 +70,12 @@ if [ ! -z "$PERSONAL_ACCESS_TOKEN" ]; then fi fi -# If still not set, prompt the user +# If still not set, prompt the user (only in interactive mode) if [ -z "$PERSONAL_ACCESS_TOKEN" ]; then + if [ -n "$DDEV_NON_INTERACTIVE" ] && [ "$DDEV_NON_INTERACTIVE" != "0" ]; then + echo "Error: PERSONAL_ACCESS_TOKEN is required. Pass it as an environment variable in non-interactive mode." + exit 1 + fi echo "Please enter your GitLab Personal Access Token (must have read_api & read_repository):" read -s PERSONAL_ACCESS_TOKEN fi From 59a76e038ade793ad7c80e60901fd73c98552d7f Mon Sep 17 00:00:00 2001 From: Samuel Reina Date: Fri, 6 Mar 2026 17:28:30 +0100 Subject: [PATCH 08/12] Remove unnecessary npmrc persist-back-to-host prompt since the script already writes directly to ~/.npmrc before ddev starts --- commands/host/1x-token-setup | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/commands/host/1x-token-setup b/commands/host/1x-token-setup index ec307fd..dfc9393 100755 --- a/commands/host/1x-token-setup +++ b/commands/host/1x-token-setup @@ -141,32 +141,9 @@ else echo "NOTE: Skipping host Composer config update (non-interactive mode)." fi -# Verify it directly from your host using ddev exec: +# Verify .npmrc in container (already written to host directly, no need to persist back). echo "Verifying .npmrc" ddev exec "cat \$HOME/.npmrc" -if [ -z "$DDEV_NON_INTERACTIVE" ] || [ "$DDEV_NON_INTERACTIVE" = "0" ]; then - echo - echo "We can now update the NPM config on your host machine" - echo "to make this change persistent." - echo - echo "Note:" - echo "This will replace your existing NPM config file" - echo "(~/.npmrc)." - echo "Any custom settings in that file" - echo "will be overwritten." - echo - read -p "Update the NPM config on your host machine? (Y/n): " -n 1 -r REPLY - echo - REPLY=${REPLY:-Y} - if [[ $REPLY =~ ^[Yy]$ ]]; then - ddev exec "cat \$HOME/.npmrc" > ~/.npmrc - echo "Host NPM config updated." - else - echo "Host NPM config was not changed." - fi -else - echo "NOTE: Skipping host NPM config update (non-interactive mode)." -fi # Restart so everything is fully synced. ddev restart From 7e607c09b20e8e65e34e774c3ad9a474ee19e350 Mon Sep 17 00:00:00 2001 From: Samuel Reina Date: Fri, 6 Mar 2026 17:33:25 +0100 Subject: [PATCH 09/12] Add missing 'undefined' check for npm config get in 1x-playwright-install so it correctly detects when @dxp registry is not configured --- commands/host/1x-playwright-install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/host/1x-playwright-install b/commands/host/1x-playwright-install index 01289d4..5ef5cb5 100755 --- a/commands/host/1x-playwright-install +++ b/commands/host/1x-playwright-install @@ -14,7 +14,7 @@ ddev start # Let's make sure @dxp-scoped package registry is defined as it required in the starterkit below. DXP_REGISTRY=$(ddev exec "npm config get @dxp:registry") -if [ -z "$DXP_REGISTRY" ] ; then +if [ -z "$DXP_REGISTRY" ] || [ "$DXP_REGISTRY" = "undefined" ]; then echo "The @dxp-scope is not configured inside the container aborting. Consider running the command 'ddev 1x-token-setup'!" exit 1 fi From 2ae565f9680213d9098204f21e7be14c267414c1 Mon Sep 17 00:00:00 2001 From: Samuel Reina Date: Fri, 6 Mar 2026 17:33:30 +0100 Subject: [PATCH 10/12] Mask personal access token in stdout output to prevent accidental exposure in screen sharing or logs --- commands/host/1x-token-setup | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/commands/host/1x-token-setup b/commands/host/1x-token-setup index dfc9393..4835ae1 100755 --- a/commands/host/1x-token-setup +++ b/commands/host/1x-token-setup @@ -59,7 +59,8 @@ fi # If it is set now, prompt the user to confirm. if [ ! -z "$PERSONAL_ACCESS_TOKEN" ]; then - echo "Please note we've determined your 1xinternet gitlab token is: $PERSONAL_ACCESS_TOKEN" + MASKED_TOKEN="...${PERSONAL_ACCESS_TOKEN: -4}" + echo "Please note we've determined your 1xinternet gitlab token is: $MASKED_TOKEN" if [ -z "$DDEV_NON_INTERACTIVE" ] || [ "$DDEV_NON_INTERACTIVE" = "0" ]; then read -p "Please confirm to proceed with this token (Y/n): " -n 1 -r REPLY REPLY=${REPLY:-Y} From 490544e54986cb66367ea996258340bbea5f8235 Mon Sep 17 00:00:00 2001 From: Samuel Reina Date: Fri, 6 Mar 2026 17:33:35 +0100 Subject: [PATCH 11/12] Use -e instead of -f test for .gitconfig symlink check so broken symlinks are detected and not attempted to be recreated --- commands/host/1x-start | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/host/1x-start b/commands/host/1x-start index 3570885..2609e9c 100755 --- a/commands/host/1x-start +++ b/commands/host/1x-start @@ -2,7 +2,7 @@ #ddev-generated ## Description: Starts the ddev project, runs auth and makes sure the .gitconfig is present. ## Usage: 1x-start -if [ ! -f $DDEV_APPROOT/.ddev/homeadditions/.gitconfig ] +if [ ! -e $DDEV_APPROOT/.ddev/homeadditions/.gitconfig ] then if [ -f ~/.gitconfig ] then From 109607c7590180e5d2538ae8072779ab5c98a77d Mon Sep 17 00:00:00 2001 From: Samuel Reina Date: Fri, 6 Mar 2026 18:10:28 +0100 Subject: [PATCH 12/12] Add missing @1xinternet npm scope (group 4) to match the intranet setup guide and add test assertion for it --- commands/host/1x-token-setup | 3 +++ tests/test.bats | 3 +++ 2 files changed, 6 insertions(+) diff --git a/commands/host/1x-token-setup b/commands/host/1x-token-setup index 4835ae1..230750d 100755 --- a/commands/host/1x-token-setup +++ b/commands/host/1x-token-setup @@ -100,6 +100,9 @@ echo "@dxp:registry=https://git.1xinternet.de/api/v4/groups/392/-/packages/npm/" sed_compat -i '/@1xINTERNET:registry=/d' ~/.npmrc echo "@1xINTERNET:registry=https://git.1xinternet.de/api/v4/projects/1121/packages/npm/" >> ~/.npmrc +sed_compat -i '/@1xinternet:registry=/d' ~/.npmrc +echo "@1xinternet:registry=https://git.1xinternet.de/api/v4/groups/4/-/packages/npm/" >> ~/.npmrc + # Start the DDEV project (so containers run). ddev start diff --git a/tests/test.bats b/tests/test.bats index 106842f..5f58ef7 100644 --- a/tests/test.bats +++ b/tests/test.bats @@ -44,6 +44,9 @@ teardown() { run ddev exec "npm config get @1xINTERNET:registry" [ "$status" -eq 0 ] [ "$output" = "https://git.1xinternet.de/api/v4/projects/1121/packages/npm/" ] + run ddev exec "npm config get @1xinternet:registry" + [ "$status" -eq 0 ] + [ "$output" = "https://git.1xinternet.de/api/v4/groups/4/-/packages/npm/" ] run ddev exec "grep '=123' ~/.npmrc" [ "$status" -eq 0 ] [ "$output" = "//git.1xinternet.de/:_authToken=123" ]