Shell script to "composerize" a Magento module
#!/bin/bash | |
function help { | |
echo "Arguments:" | |
echo " package name" | |
echo " package description" | |
} | |
dir=$(pwd) | |
if [ $# -ne 2 ] | |
then | |
echo "Wrong number of arguments supplied" | |
help | |
exit | |
fi | |
package_name="$1" | |
package_description="$2" | |
if [ -f composer.json ] | |
then | |
if [ -f composer.json.bak ] | |
then | |
rm composer.json.bak | |
fi | |
echo "Backing up existing composer.json..." | |
mv composer.json composer.json.bak | |
fi | |
echo "Creating composer.json..." | |
printf '{\n\t"name": "%s",\n\t"description": "%s",\n\t"type": "magento-module",\n\t"require": {\n\t\t"magento-hackathon/magento-composer-installer":"*"\n\t}\n}\n' "$package_name" "$package_description" >> composer.json | |
if [ -f modman ] | |
then | |
if [ -f modman.bak ] | |
then | |
rm modman.bak | |
fi | |
echo "Backing up existing modman file..." | |
mv modman modman.bak | |
fi | |
echo "Creating modman file..." | |
find * -type f -not -iwholename 'modman' -not -iwholename "modman.bak" ! -name 'README*' ! -name 'composer*' -exec echo {} {} >> modman \; | |
echo "Finished: check and eventually adjust composer.json and modman files" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment