Dump installed plugins to composer.json?

Sometimes I install + activate plugins using WordPress, trying out good combinations quickly.
It would be great if there is a way to dump all these plugins into the composer.json (wpackagist + version).

Only thing I’ve come across that says it does this is https://github.com/tomjn/composerpress — more than likely doesn’t support a Bedrock based site

1 Like

Maybe something like this:

$ wp plugin list --format=csv --fields=name,version | awk '{if ($1 != "name,version") print $1;}' | awk -F',' '{system("composer require wpackagist-plugins/" $1 ":" $2)}'

Note: It actually run $ composer require for each plugin

Update:
maybe this version, copy and paste the console output to composer.json

$ wp plugin list --format=csv --fields=name,version | awk '{if ($1 != "name,version") print $1;}' | awk -F',' '{print "\"wpackagist-plugins/" $1 "\":" " \"" $2 "\","}'
2 Likes