Page MenuHomeDevCentral

D2676.id.diff
No OneTemporary

D2676.id.diff

diff --git a/roles/devserver/userland-software/dev.sls b/roles/devserver/userland-software/dev.sls
--- a/roles/devserver/userland-software/dev.sls
+++ b/roles/devserver/userland-software/dev.sls
@@ -75,6 +75,21 @@
- {{ packages.phpunit }}
- {{ packages_prefixes.pecl }}ast
+{{ dirs.bin }}/run-php-script:
+ file.managed:
+ - source: salt://roles/devserver/userland-software/files/run-php-script.sh
+ - mode: 755
+
+{% for command in ["phan", "phpmd", "phpstan", "psalm", "rector"] %}
+{{ dirs.bin }}/{{ command }}:
+ file.managed:
+ - source: salt://roles/devserver/userland-software/files/run-php-script-alias.sh.jinja
+ - mode: 755
+ - template: jinja
+ - context:
+ command: {{ command }}
+{% endfor %}
+
# -------------------------------------------------------------
# Python
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/roles/devserver/userland-software/files/run-php-script-alias.sh.jinja b/roles/devserver/userland-software/files/run-php-script-alias.sh.jinja
new file mode 100644
--- /dev/null
+++ b/roles/devserver/userland-software/files/run-php-script-alias.sh.jinja
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# -------------------------------------------------------------
+# Run Composer version if found, or find a system one if not
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# Source: roles/devserver/userland-software/files/run-php-script-alias.sh
+# License: Trivial work, not eligible to copyright
+# -------------------------------------------------------------
+
+run-php-script {{ command }} "$@"
diff --git a/roles/devserver/userland-software/files/run-php-script.sh b/roles/devserver/userland-software/files/run-php-script.sh
new file mode 100755
--- /dev/null
+++ b/roles/devserver/userland-software/files/run-php-script.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+# -------------------------------------------------------------
+# Wrapper to launch PHP command from known places
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# Source: roles/devserver/userland-software/files/run-php-script.sh
+# License: Trivial work, not eligible to copyright
+# -------------------------------------------------------------
+
+COMMAND=$1
+shift
+
+if [ -f "vendor/bin/$COMMAND" ]; then
+ echo "Switching to Composer $COMMAND:"
+ SCRIPT="vendor/bin/$COMMAND"
+elif [ -f "/opt/$COMMAND.phar" ]; then
+ SCRIPT="/opt/$COMMAND.phar"
+elif [ -f "/opt/$COMMAND" ]; then
+ SCRIPT="/opt/$COMMAND"
+else
+ echo "No $COMMAND has been found."
+ exit 1
+fi
+
+php "$SCRIPT" "$@"

File Metadata

Mime Type
text/plain
Expires
Wed, Dec 18, 22:03 (2 h, 4 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2305474
Default Alt Text
D2676.id.diff (2 KB)

Event Timeline