Last active
January 17, 2018 19:08
-
-
Save aleron75/b7ffa24054636a3d5701 to your computer and use it in GitHub Desktop.
Shell script to "composerize" a Magento module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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