From 3dc73400dc3cb7b3a57ccdfa44cfe424f6b2240c Mon Sep 17 00:00:00 2001
From: Oliver Davies <oliver@oliverdavies.uk>
Date: Mon, 20 Jun 2022 22:36:16 +0100
Subject: [PATCH] feat(role): add debugger

Add `vscode-php-debug` for working with Xdebug and debugging PHP code.
---
 group_vars/all                 |  1 +
 roles/debugger/tasks/main.yaml |  4 ++++
 roles/debugger/tasks/php.yaml  | 20 ++++++++++++++++++++
 3 files changed, 25 insertions(+)
 create mode 100644 roles/debugger/tasks/main.yaml
 create mode 100644 roles/debugger/tasks/php.yaml

diff --git a/group_vars/all b/group_vars/all
index 5c3d04d5..14adbde3 100644
--- a/group_vars/all
+++ b/group_vars/all
@@ -27,3 +27,4 @@ default_roles:
   - tmuxinator
   - zsh
   - zsh-antigen
+  - debugger
diff --git a/roles/debugger/tasks/main.yaml b/roles/debugger/tasks/main.yaml
new file mode 100644
index 00000000..59cc5b72
--- /dev/null
+++ b/roles/debugger/tasks/main.yaml
@@ -0,0 +1,4 @@
+---
+- include_tasks: php.yaml
+  tags:
+    - debugger
diff --git a/roles/debugger/tasks/php.yaml b/roles/debugger/tasks/php.yaml
new file mode 100644
index 00000000..dade7b55
--- /dev/null
+++ b/roles/debugger/tasks/php.yaml
@@ -0,0 +1,20 @@
+---
+- name: Clone
+  ansible.builtin.git:
+    depth: 1
+    dest: "{{ ansible_user_dir }}/build/vscode-php-debug"
+    repo: https://github.com/xdebug/vscode-php-debug.git
+    single_branch: yes
+  register: clone
+  tags:
+    - debugger
+
+- name: Install
+  ansible.builtin.command: |
+    npm install
+    npm run build
+  args:
+    chdir: "{{ ansible_user_dir }}/build/vscode-php-debug"
+  when: clone.changed
+  tags:
+    - debugger