Skip to content

Commit

Permalink
ADD: new cmds
Browse files Browse the repository at this point in the history
  • Loading branch information
GrimLink committed Oct 18, 2020
1 parent b528d11 commit c3eb47d
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 1.5.0 - (2020-10-18)
* ADD:
* new cmd `sample`, for adding sample data
* new cmd `replace`, for removing (optional) core module

## 1.4.0 - (2020-08-21)
* ADD:
* new cmd `new-module`
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ _Or download it via wget_
| new-admin | Create new admin user _(*)_ |
| new-theme | Create new theme in app _(*)_ |
| new-module | Create new module in app |
| sample | Add sample data |
| replace | Removal of (optional) core modules) |
| run | Run magerun2 (requires n98-magerun2) |

Any other command will run the same as `bin/magento`
Expand Down
40 changes: 40 additions & 0 deletions mage
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ help)
echo -e "- ${BLUE}new-admin${RESET} (Create new admin user)"
echo -e "- ${BLUE}new-theme${RESET} (Create new theme in app)"
echo -e "- ${BLUE}new-module${RESET} (Create new module in app)"
echo -e "- ${BLUE}sample${RESET} (Add sample data)"
echo -e "- ${BLUE}replace${RESET} (Removal of (optional) core modules)"
echo -e "- ${BLUE}run${RESET} (Run magerun2)"
echo -e "\n${ITALIC}Anything else will run ${BLUE}bin/magento${RESET}"
echo -e "${ITALIC}To see those cmd's just run ${BLUE}mage${RESET}"
Expand Down Expand Up @@ -229,6 +231,44 @@ ComponentRegistrar::register(
</config>" >> $MODULE/etc/module.xml
;;

sample)
if [[ ! -d app/etc ]]; then echo "This does not look like the Magento 2 root folder, aborting.." && exit 1; fi
read -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

if [[ ! -d "$HOME/.magento-sampledata/$MVERSION" ]]; then
git clone -b $MVERSION git@github.com:magento/magento2-sample-data.git $HOME/.magento-sampledata/$MVERSION
fi

echo -e "Installing $MVERSION sample data"
# Lets make sure these folder exist, to prevent them being made as a symlink
mkdir -p app/code/Magento
mkdir -p pub/media/catalog/product
mkdir -p pub/media/downloadable/files
mkdir -p pub/media/wysiwyg
touch README.md
# This will also run bin/magento s:up
php -f $HOME/.magento-sampledata/$MVERSION/dev/tools/build-sample-data.php -- --ce-source="$PWD"
;;

replace)
if [[ ! -f composer.json ]]; then echo "This does not look like the Magento 2 root folder, aborting.." && exit 1; fi
read -p "What is your Magento sub version (sample: 4.1): " MVERSION && echo ""
if [[ -z "$MVERSION" ]]; then echo "The Magento 2 version is empty, aborting.." && exit 1; fi
if [[ -z $2 ]]; then
echo "No options where given, next time you can also type 'mage replace {{OPTION}}'"
read -p "What (Yireo) replace packages do you want to use (empty: bundled,content-staging,core,inventory): " OPTIONS && echo ""
else
OPTIONS="$2"
fi
if [[ -z "$OPTIONS" ]]; then OPTIONS="bundled,content-staging,core,inventory"; fi
OPTIONS_ARRAY=($(echo $OPTIONS | tr "," "\n"))
for i in "${OPTIONS_ARRAY[@]}"; do
OPTION="$OPTION yireo/magento2-replace-${i}:^${MVERSION}"
done
composer require $OPTION
;;

run)
if command -v magerun2 &>/dev/null; then
magerun2 ${@:2}
Expand Down

0 comments on commit c3eb47d

Please sign in to comment.