Skip to content

Commit

Permalink
Release v2.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
GrimLink committed May 29, 2024
1 parent a29aa75 commit 50a6e95
Showing 1 changed file with 52 additions and 1 deletion.
53 changes: 52 additions & 1 deletion mage
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ function mage_add_hyva() {
'hyva-themes/magento2-theme-module'
'hyva-themes/magento2-reset-theme'
'hyva-themes/magento2-email-module'
'hyva-themes/magento2-order-cancellation-webapi'
'hyva-themes/magento2-default-theme'
'hyva-themes/magento2-compat-module-fallback'
'hyva-themes/magento2-theme-fallback'
Expand Down Expand Up @@ -230,7 +231,7 @@ function mage_add_checkout() {
fi
}

MAGE_VERSION="2.1.0"
MAGE_VERSION="2.1.1"

function mage_version() {
echo -e "\n${BOLD}Mage ${GREEN}${MAGE_VERSION}${RESET}"
Expand Down Expand Up @@ -259,6 +260,7 @@ function mage_help() {
mage_help_cmd "new customer" "Create new customer"
mage_help_cmd "new theme" "Create new theme"
mage_help_cmd "new module" "Create new module"
mage_help_cmd "new patch" "Create new patch"
mage_help_cmd "new i18n | new translate [src]" "Create new translations"
mage_help_cmd "add sample" "Add sample data"
mage_help_cmd "add hyva" "Add Hyva Theme"
Expand Down Expand Up @@ -364,6 +366,51 @@ function mage_new_module() {
mage_make_file $dest_path/etc/module.xml "${file_xml}"
}

function mage_new_patch_file() {
src=${1}

# Remove leading slash
if [[ $src == /* ]]; then src="${src:1}"; fi

# Add vendor to path if omitted
if [[ $src != vendor/* ]]; then src="vendor/${src}"; fi

if [[ ! -f "$src" ]]; then
echo "Can not find $src make sure this is the right path" && exit 1;
fi

# Get the module src for the temp git dir
module_src=$(echo "$src" | cut -d '/' -f -3)
file_src=$(echo "$src" | cut -d '/' -f 4-)
patched_file_src="${src%.*}.patch"

cd $module_src
git init &> /dev/null
git add $file_src

patch_file_dir=$(dirname "patches/$patched_file_src")

read -rsn1 -p "Make your changes in $src when ready, press any key to continue";
echo "";

mkdir -p "../../../$patch_file_dir"
touch "../../../patches/$patched_file_src"
git diff > "../../../patches/$patched_file_src"

# Cleanup
git checkout . &> /dev/null
rm -rf .git
cd - &> /dev/null

# Add composer patch setting
vendor_folder_name=$(echo "$module_src" | sed 's/^vendor\///')
composer config extra.patches.$vendor_folder_name -j "{ \"Patch: $file_src\": \"patches/$patched_file_src\" }"

echo -e "Patch created in $patched_file_src".
echo -e "Patch added to to composer in extra.patches.$vendor_folder_name"
echo "Make sure the patch and settings in composer.json are correct before running composer install"
}

function mage_add_sample() {
read -e -p "What is your Magento base version (sample: 2.4): " mversion && echo ""
if [[ -z "$mversion" ]]; then echo "The Magento 2 version is empty, aborting.." && exit 1; fi
Expand Down Expand Up @@ -542,6 +589,10 @@ case "${@}" in
mage_new_module
;;

"new patch"*)
mage_new_patch_file ${3}
;;

"new i18n"* | "new translate"*)
src=${3:-.}

Expand Down

0 comments on commit 50a6e95

Please sign in to comment.