Go to the vendor_name folder.
- Ex.: cd vendor/amasty
Create the file at that folder.
- Ex.: zip-all.sh
Call the file, and the .zip modules created at the same folder.
- Ex.: bash zip-all.sh
-- (vendor/amasty/<vendorname_modulename_1.7.1.zip>)
name = vendorname/modulename
version = 1.7.1
- The zip name is: vendorname_modulename_1.7.1.zip
#!/bin/bash
for file in $(find . -name "composer.json"); do
# DATA=grep -irw -m 2 "\"name\"\|\"version\"" ${file}
echo ${file}
# get data
NAME=$(grep -iw "\"name\"" ${file})
VERSION=$(grep -iw "\"version\"" ${file})
#remove all before first space
NAME="$(echo ${NAME} | cut -d' ' -f2)"
VERSION="$(echo ${VERSION} | cut -d' ' -f2)"
# remove first " and the last ",
NAME=${NAME#*\"}
VERSION=${VERSION#*\"}
NAME=${NAME%??}
VERSION=${VERSION%??}
# change the /
NAME=${NAME//\//_} #bash only
echo ${NAME}"_"${VERSION}".zip"
ZIPNAME=${NAME}"_"${VERSION}".zip"
ZIPDIR=${file%/*}
zip -r ${ZIPNAME} ${ZIPDIR}
done