improved deply-drupal.sh: pmu module not in the lock before composer install
This commit is contained in:
+48
-1
@@ -15,13 +15,60 @@ step "Updating Drupal 8"
|
|||||||
echo "Switching to project docroot."
|
echo "Switching to project docroot."
|
||||||
cd ./public_html
|
cd ./public_html
|
||||||
|
|
||||||
|
# Snapshot of the lock as currently deployed, taken BEFORE the pull.
|
||||||
|
# Used below to detect modules removed from the lock by this deploy.
|
||||||
|
git show HEAD:composer.lock > /tmp/deploy-lock-old 2>/dev/null || echo "WARN: no previous composer.lock found"
|
||||||
|
|
||||||
step "Pulling down latest code"
|
step "Pulling down latest code"
|
||||||
git pull --ff-only origin prod
|
git pull --ff-only origin prod
|
||||||
git submodule update --init --recursive
|
git submodule update --init --recursive
|
||||||
|
cp composer.lock /tmp/deploy-lock-new
|
||||||
|
|
||||||
step "Clearing drush caches"
|
step "Clearing drush caches"
|
||||||
vendor/bin/drush cache-clear drush --ansi
|
vendor/bin/drush cache-clear drush --ansi
|
||||||
|
|
||||||
|
step "Uninstalling extensions removed from the lock"
|
||||||
|
# Must run BEFORE composer install: the obsolete code is still on disk,
|
||||||
|
# so drush can uninstall cleanly. Without this, an extension still enabled
|
||||||
|
# in the DB whose package disappears from the lock crashes the bootstrap.
|
||||||
|
if [ -s /tmp/deploy-lock-old ] && [ -s /tmp/deploy-lock-new ]; then
|
||||||
|
grep -o '"name": "drupal/[^"]*"' /tmp/deploy-lock-old | sed 's/.*"drupal\///;s/"//' | sort -u > /tmp/deploy-pkgs-old
|
||||||
|
grep -o '"name": "drupal/[^"]*"' /tmp/deploy-lock-new | sed 's/.*"drupal\///;s/"//' | sort -u > /tmp/deploy-pkgs-new
|
||||||
|
ENABLED_MODS=$(vendor/bin/drush php:eval 'echo implode(" ", array_keys(\Drupal::config("core.extension")->get("module")));' 2>/dev/null)
|
||||||
|
ENABLED_THEMES=$(vendor/bin/drush php:eval 'echo implode(" ", array_keys(\Drupal::config("core.extension")->get("theme")));' 2>/dev/null)
|
||||||
|
TO_UNINSTALL_MODS=""
|
||||||
|
TO_UNINSTALL_THEMES=""
|
||||||
|
for pkg in $(comm -23 /tmp/deploy-pkgs-old /tmp/deploy-pkgs-new); do
|
||||||
|
for dir in web/modules/contrib/$pkg web/themes/contrib/$pkg; do
|
||||||
|
[ -d "$dir" ] || continue
|
||||||
|
case "$dir" in
|
||||||
|
web/modules/*)
|
||||||
|
for mod in $ENABLED_MODS; do
|
||||||
|
find "$dir" -name "$mod.info.yml" 2>/dev/null | grep -q . && TO_UNINSTALL_MODS="$TO_UNINSTALL_MODS $mod"
|
||||||
|
done
|
||||||
|
;;
|
||||||
|
web/themes/*)
|
||||||
|
for th in $ENABLED_THEMES; do
|
||||||
|
find "$dir" -name "$th.info.yml" 2>/dev/null | grep -q . && TO_UNINSTALL_THEMES="$TO_UNINSTALL_THEMES $th"
|
||||||
|
done
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
done
|
||||||
|
if [ -n "$TO_UNINSTALL_MODS" ]; then
|
||||||
|
TO_UNINSTALL_MODS=$(echo $TO_UNINSTALL_MODS | tr ' ' '\n' | sort -u | tr '\n' ' ')
|
||||||
|
echo "pm:uninstall$TO_UNINSTALL_MODS"
|
||||||
|
vendor/bin/drush pmu $TO_UNINSTALL_MODS -y --ansi || echo "WARN: module uninstall incomplete"
|
||||||
|
fi
|
||||||
|
if [ -n "$TO_UNINSTALL_THEMES" ]; then
|
||||||
|
TO_UNINSTALL_THEMES=$(echo $TO_UNINSTALL_THEMES | tr ' ' '\n' | sort -u | tr '\n' ' ')
|
||||||
|
echo "theme:uninstall$TO_UNINSTALL_THEMES"
|
||||||
|
vendor/bin/drush theme:uninstall $TO_UNINSTALL_THEMES -y --ansi || echo "WARN: theme uninstall incomplete"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Lock diff unavailable, skipping obsolete extension detection."
|
||||||
|
fi
|
||||||
|
|
||||||
step "Composer install"
|
step "Composer install"
|
||||||
composer install --no-dev -n --ansi
|
composer install --no-dev -n --ansi
|
||||||
|
|
||||||
@@ -34,7 +81,7 @@ vendor/bin/drush config-import -y --ansi
|
|||||||
vendor/bin/drush im --choice safe --ansi
|
vendor/bin/drush im --choice safe --ansi
|
||||||
vendor/bin/drush ib --choice full --ansi
|
vendor/bin/drush ib --choice full --ansi
|
||||||
|
|
||||||
step "Regen path aliases"
|
# step "Regen path aliases"
|
||||||
#drush pag all canonical_entities:node
|
#drush pag all canonical_entities:node
|
||||||
#drush pag all canonical_entities:taxonomy_term
|
#drush pag all canonical_entities:taxonomy_term
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user