Skip to content

Instantly share code, notes, and snippets.

@aleron75
Last active January 17, 2018 19:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aleron75/b7ffa24054636a3d5701 to your computer and use it in GitHub Desktop.
Save aleron75/b7ffa24054636a3d5701 to your computer and use it in GitHub Desktop.
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