diff --git a/commands/host/1x-lib.sh b/commands/host/1x-lib.sh index df96548..f5c09b0 100644 --- a/commands/host/1x-lib.sh +++ b/commands/host/1x-lib.sh @@ -88,4 +88,18 @@ jq_compat() { echo "Error: jq not found and docker is not available. Please install jq or docker." >&2 return 1 fi -} \ No newline at end of file +} + +# Exit with an error if the token in ~/.npmrc can't pull @dxp or @1xinternet packages. +check_registry_auth() { + local token group + token=$(grep -im1 '^//git\.1xinternet\.de.*:_authToken=' ~/.npmrc 2>/dev/null | cut -d= -f2- | tr -d '[:space:]"') + # 392 = @dxp, 4 = @1xinternet + for group in 392 4; do + curl -fsS --max-time 5 -H "PRIVATE-TOKEN: $token" -o /dev/null \ + "https://git.1xinternet.de/api/v4/groups/$group/packages?package_type=npm&per_page=1" \ + && continue + echo "Error: GitLab token can't pull @dxp or @1xinternet packages." >&2 + exit 1 + done +} diff --git a/commands/host/1x-playwright-install b/commands/host/1x-playwright-install index ba6b2ac..f5c24e5 100755 --- a/commands/host/1x-playwright-install +++ b/commands/host/1x-playwright-install @@ -59,6 +59,8 @@ if [ -z "$DXP_REGISTRY" ] || [ "$DXP_REGISTRY" = "undefined" ]; then exit 1 fi +check_registry_auth + echo -e "${GREEN}Installing playwright (within DDEV):${NC}" if [ ! -f "${DDEV_APPROOT}/.ddev/web-build/disabled.Dockerfile.playwright" ]; then diff --git a/commands/host/1x-token-setup b/commands/host/1x-token-setup index 230750d..a33e777 100755 --- a/commands/host/1x-token-setup +++ b/commands/host/1x-token-setup @@ -152,4 +152,6 @@ ddev exec "cat \$HOME/.npmrc" # Restart so everything is fully synced. ddev restart +check_registry_auth + echo "Setup complete!"