-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from wunderio/feature/9-Create-wrapper-for-pmu…
…-to-be-able-to-uninstall-modules-that-dont-exist-in-code #9 Create pmu tooling (drush pmu) wrapper initial script.
- Loading branch information
Showing
2 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env bash | ||
|
||
## Description: Runs drush pmu commands but also creates dummy module folder if it does not exist. | ||
## Usage: pmu | ||
## Example: "ddev pmu module1 module2 ..." | ||
|
||
/var/www/html/.ddev/wunderio/core/_run-scripts.sh tooling-pmu.sh "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/bin/bash | ||
|
||
# | ||
# Helper script to run pmu, but also create temporary module directory if it doesn't exist. | ||
# | ||
|
||
set -u | ||
if [[ -n "${WUNDERIO_DEBUG:-}" ]]; then | ||
set -x | ||
fi | ||
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/var/www/html/vendor/bin | ||
|
||
if [[ "$#" -lt 1 ]]; then | ||
echo "Usage: ddev pmu <module1> <module2> ..." | ||
exit 0 | ||
fi | ||
|
||
modules="$1" | ||
|
||
cd /var/www/html | ||
|
||
disable_module() { | ||
local module_name="$1" | ||
|
||
local module_path="web/modules/custom/$module_name" | ||
|
||
# Check if the module directory exists. | ||
local module_exists=0 | ||
if [ -d "web/modules/contrib/$module_name" ] || [ -d "$module_path" ] || [ -d "web/core/modules/$module_name" ]; then | ||
module_exists=1 | ||
fi | ||
|
||
# Create dummy module if the module directory doesn't exist. | ||
if [ $module_exists -eq 0 ]; then | ||
mkdir -p "$module_path" | ||
echo "name: 'Dummy module created by ddev pmu'" > "$module_path/$module_name.info.yml" | ||
echo "type: module" >> "$module_path/$module_name.info.yml" | ||
echo "core_version_requirement: ^9 || ^10 || ^11" >> "$module_path/$module_name.info.yml" | ||
|
||
# Clear caches to make the module available. | ||
drush cr | ||
fi | ||
|
||
# Run "drush pmu" command. | ||
echo "Disabling module $module_name..." | ||
drush pmu -y "$module_name" | ||
|
||
# Remove dummy module if it was created. | ||
if [ $module_exists -eq 0 ]; then | ||
rm -rf "$module_path" | ||
fi | ||
} | ||
|
||
for module in $* | ||
do | ||
disable_module "$module" | ||
done |