Skip to content

Annertech/annertech-ddev

Repository files navigation

DDEV Annertech Tools

Highly opinionated set of configs and commands used by Annertech in our DDEV workflow.

Note

This is an Annertech tool!
3rd party developers and agencies are encouraged to take what they need and re-use rather than using the add-on directly.
Rapid prototyping and our workflows will not be compatible with yours.
Feature requests that you consider important might not be accepted.

Installation and Updating

  1. ddev add-on get annertech/annertech-ddev
  2. git commit -m 'Add annertech/annertech-ddev addon'

Features

Automatically disabled

are automatically disabled in the local environment to facilitate development.

Automatically identified and configured

If your Drupal projects depend on ImageMagick then DDEV will be automatically configured to compile and use ImageMagick v7 in DDEV. See scripts/ddev/web-build for details.

Upsun is using v7 while DDEV is still running v6 by default.

package-checker

ddev package-checker (alias ddev wtfiow) scans every project under a GitLab group, reads each project's composer-manifest.yaml over the API (no clone, no composer), and reports which projects require a given package.

ddev package-checker drupal/token         # list every project using it
ddev package-checker drupal/token 1.6.0   # highlights projects using drupal/token <= 1.6.0
DEBUG=1 ddev package-checker drupal/token # debug mode, ultra verbose

It is a host command with two backends, auto-selected:

  • glab (preferred): used when glab is installed. Auth and host come from glab itself, run glab auth login once. No tokens or URLs needed. The host is auto-detected from the project's git remote; set GITLAB_HOST to override.
  • curl (fallback): used when glab is absent. Needs GITLAB_TOKEN and GITLAB_URL.

Force a backend with PACKAGE_CHECKER_BACKEND=glab|curl.

Variable Used by Required Default Notes
GITLAB_GROUP both no clients Group path to scan (subgroups included)
GITLAB_HOST glab no - Force glab host instead of git-remote auto-detect
GITLAB_TOKEN curl yes (curl mode) - Token with read_api scope, member of the group
GITLAB_URL curl yes (curl mode) - GitLab base URL
DEBUG both no - Log every scanned project and every missing manifest
PACKAGE_CHECKER_BACKEND both no auto Force glab or curl

Deps: jq, plus either glab or curl. The scan reads each project's default branch, so a manifest change must be pushed/merged before it shows up.

Automated Tests for a Project

Use ddev tests to see what test suites are available for each project.

Environment Indicators

Environment indicators in the Drupal Toolbar are tricky because we need to ensure that colors don't conflict with each other and also work with white text.

The following colors should be used:

Color HEX Contrast Environment
local #4A0080 13:1 local, ddev
dev #005B94 7:1 dev
stage #59590D 7:1 stage
live #8B0000 10:1 production

This is what people with color vision deficiency see when using the above colors:

Environment Indicator color palette

Note

Please note that the add-on only controls the local environment color. You must fix the rest yourself!

Upsun config for SimpleI environment indicator

// Per environment settings:
// Configure environment indicator (simplei)
if (isset($platformsh->branch)) {
  // Production type environment.
  if ($platformsh->branch == 'main' || $platformsh->onDedicated()) {
    $settings['simple_environment_indicator'] = '#8B0000 LIVE';
  }
  // Staging type environment
  else if ($platformsh->branch == 'stage' || $platformsh->branch == 'staging') {
    $settings['simple_environment_indicator'] = '#59590D STAGE';
  }
  // Development type environment.
  else {
    $settings['simple_environment_indicator'] = '#005B94 DEV';
  }
}
    

External Service Integration

Teamwork Integration

Several commands integrate with Teamwork (tw-comment, tw-timelog, open-issue, timew, tw-description). These require the following environment variables to be set on your host machine:

export TEAMWORK_DOMAIN="projects.yourcompany.com"
export TEAMWORK_API_KEY="your_api_key_here"

Add these to your ~/.bashrc or ~/.zshrc file.

IP Reputation Checking

The check-ip command uses AbuseIPDB API and requires:

export ABUSEIPDB_API_KEY="your_api_key_here"

Add this to your ~/.bashrc or ~/.zshrc file.

AI Prompts

The ai-prompts command provides interactive AI-powered workflows and requires at least one of:

Install at least one of these tools on your host machine. The command will prompt you to select which AI agent to use when run.

Tricks

Handy shell aliases to add to your host machine:

# DDEV
alias composer='ddev composer'
alias behat='ddev behat'
alias drush='ddev drush'
alias platform='ddev platform'
alias upsun='ddev upsun'
alias upsunactlog='ddev exec upsun act:log --state=in_progress'
alias robo='ddev robo'

alias xe='ddev xdebug enable'
alias xd='ddev xdebug disable'
alias xt='status=$(ddev xdebug status) &&  if [ "$status" == "xdebug enabled" ]; then ddev xdebug off; else ddev xdebug on; fi'

# Tailscale
alias exit-node-on='tailscale set --exit-node="your.exit.node.ts.net"'
alias exit-node-off='tailscale set --exit-node=""'

# TeamWork
export TEAMWORK_DOMAIN=_DOMAIN_
export TEAMWORK_API_KEY=_KEY_
alias t-snt='/path/to/annertech-ddev/commands/host/timelog -u -t _TICKET_ID_ 15 "SNT"'
alias t-scrum='/path/to/annertech-ddev/commands/host/timelog -u -t _TICKET_ID_ 15 "Scrum"'
alias t-retro='/path/to/annertech-ddev/commands/host/timelog -u -t _TICKET_ID_ 60 "Retro"'

git and tig

git

linked-log (git llog): Link git log commits to teamwork cards:

git config --global alias.llog '!f() { git log --color=always --pretty=format:"%Cred%h%Creset %Creset%s%Creset %Cgreen(%cr) %C(bold blue)<%an>%Creset" "$@" | sed -E "s|T-([0-9]+)|\x1b[36mT-\1\x1b[0m (\x1b[37mhttps://projects.annertech.com/app/tasks/\1\x1b[0m)|g" | less -FRX; }; f'

tig

  • Link commits to cards: Open card of selected commit by pressing o in your keyboard:
  • Copy commit hash with y (yank)

~/.tigrc

# Open ticket in browser (cross-platform)
bind main o @sh -c "git log -1 --format='%s' '%(commit)' | grep -oP 'T-\\d+' | sed 's/T-//' | xargs -I{} sh -c 'xdg-open \"https://projects.annertech.com/app/tasks/{}\" 2>/dev/null || open \"https://projects.annertech.com/app/tasks/{}\" 2>/dev/null || start \"https://projects.annertech.com/app/tasks/{}\"'"
bind diff o @sh -c "git log -1 --format='%s' '%(commit)' | grep -oP 'T-\\d+' | sed 's/T-//' | xargs -I{} sh -c 'xdg-open \"https://projects.annertech.com/app/tasks/{}\" 2>/dev/null || open \"https://projects.annertech.com/app/tasks/{}\" 2>/dev/null || start \"https://projects.annertech.com/app/tasks/{}\"'"

# Copy commit hash to clipboard (cross-platform)
bind main y @sh -c "echo -n '%(commit)' | xclip -selection clipboard 2>/dev/null || echo -n '%(commit)' | pbcopy 2>/dev/null || echo -n '%(commit)' | clip.exe 2>/dev/null

Common Problems and How-To Fix Them

commit-msg hook is ignored

Check git config -l for the value of core.hooksPath and can change it to the local path with

git config --local core.hooksPath .git/hooks

About

A set of opinionated tools and configurations for DDEV

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Generated from ddev/ddev-addon-template