From c249fc067e167093243e793922406231d3bf39fb Mon Sep 17 00:00:00 2001 From: Adi Naidu Date: Fri, 3 Sep 2021 15:22:57 +1000 Subject: [PATCH] * Added a script that cans the Bedrock plugins directory and automatically migrates applicable plugins to Composer via WPackagist, or git-ignores them if their not available on Composer. * Updated Readme --- wordpress/README.md | 25 +++++++++++++++++ .../bedrock-migrate-plugins-to-composer.sh | 27 +++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 wordpress/bedrock-migrate-plugins-to-composer.sh diff --git a/wordpress/README.md b/wordpress/README.md index 5d40a09..0c97359 100644 --- a/wordpress/README.md +++ b/wordpress/README.md @@ -233,3 +233,28 @@ Whilst SSH'd into the Docker `php80` container (`docker exec -it php80 bash`), b ```bash bash <(curl -s https://raw.githubusercontent.com/pvtl/scripts/master/wordpress/git-conversion.sh -L) -s ``` + +## ⛵ Automatically migrating vanilla plugins to Composer for Bedrock Conversions + +
Prerequisites +

+ +- Unix + +

+ +
What does this do? + +

+ +Scans the Bedrock plugins directory and automatically migrates applicable plugins to Composer via WPackagist, or git-ignores them if their not available on Composer. + +

+ +### Usage + +Whilst SSH'd into the Docker `php80` container (`docker exec -it php80 bash`), browsed to `/var/www/html`, simply run: + +```bash +bash <(curl -s https://raw.githubusercontent.com/pvtl/scripts/master/wordpress/bedrock-migrate-plugins-to-composer.sh -L) -s +``` diff --git a/wordpress/bedrock-migrate-plugins-to-composer.sh b/wordpress/bedrock-migrate-plugins-to-composer.sh new file mode 100644 index 0000000..240d3fa --- /dev/null +++ b/wordpress/bedrock-migrate-plugins-to-composer.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +# Create a list of current plugin folder names +find "web/app/plugins" -mindepth 1 -maxdepth 1 -type d -printf '%f\n' > pluginlist.txt +echo "STEP 1/3. $(wc -l pluginlist.txt | awk '{ print $1 }') plugins found in the web/app/plugins directory." + +# Loop through the plugin list +echo "STEP 2/3. Beginning plugin installation via Composer" +printf "\n\n# Manually Installed Plugins\n" >> .gitignore +count=1 +while read plugin; do + composer_include_succeeded=1 + composer require "wpackagist-plugin/$plugin" >> composerlog.txt 2>&1 + grep -q "InvalidArgumentException" composerlog.txt && composer_include_succeeded=0 + if [ $composer_include_succeeded -eq 1 ] + then + echo "$count. $plugin - Added via Composer" + else + echo "!web/app/plugins/$plugin" >> .gitignore; + echo "$count. $plugin - Added manually" + fi + rm composerlog.txt + count=$((count+1)) +done