Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions wordpress/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

<details><summary>Prerequisites</summary>
<p>

- Unix

</p></details>

<details><summary>What does this do?</summary>

<p>

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

</p></details>

### 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
```
27 changes: 27 additions & 0 deletions wordpress/bedrock-migrate-plugins-to-composer.sh
Original file line number Diff line number Diff line change
@@ -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 <pluginlist.txt

rm pluginlist.txt
echo "STEP 3/3. Plugin installation complete."