diff --git a/.bash_xp b/.bash_xp index 0f9640f..9aa57c5 100644 --- a/.bash_xp +++ b/.bash_xp @@ -1,9 +1,5 @@ XP_TOOLS_DIR=~/tools/Magento-2-Bash-Localhost-Installation-Script -function phpswitch() { - bash "$XP_TOOLS_DIR/phpswitch.sh" $1 -} - function create_website() { bash "$XP_TOOLS_DIR/install.sh" $1 $2 $3 $4 } @@ -28,10 +24,6 @@ function update_modules() { bash "$XP_TOOLS_DIR/update_modules.sh" } -function code_quality() { - bash "$XP_TOOLS_DIR/code_quality.sh" $1 $2 $3 -} - function import_website() { bash "$XP_TOOLS_DIR/import.sh" $1 } @@ -40,116 +32,6 @@ function update_website() { bash "$XP_TOOLS_DIR/update.sh" $1 } -function git_import_website() { - bash "$XP_TOOLS_DIR/git_import.sh" $1 $2 -} - function replace_images() { bash "$XP_TOOLS_DIR/replace_images.sh" $1 } - -#source "$XP_TOOLS_DIR/environment_tools.sh" - -_site () -{ - local cur=${COMP_WORDS[COMP_CWORD]}; - COMPREPLY=($(compgen -W "$(ls ~/domains)" -- $cur)) -} - -site () -{ - if [ $# -eq 0 ]; then - DOMAIN=`pwd | cut --delimiter="/" -f 5`; - else - DOMAIN="$@"; - fi; - if [ -d ~/domains/$DOMAIN ]; then - cd ~/domains/$DOMAIN; - else - echo "Given website does not exists"; - fi -} -complete -F _site site - -bind '"\e[A": history-search-backward' -bind '"\e[B": history-search-forward' - -# Magerun aliasses -alias m='magerun' -alias m2='magerun2' -alias mc='magento-cloud' -alias c='php bin/connector' -alias cf='$COMPOSER_HOME/vendor/bin/cache-clean.js' -alias b='php bin/magento' -alias s='php bin/console' - -# PHP aliasses -alias php7='php7.0' -alias composer7='php7 /usr/bin/composer' -alias php71='php7.1' -alias composer71='php71 /usr/bin/composer' - -# PhpStorm aliasses -alias p='phpstorm' - -# PHPX - Xdebug -alias phpx='XDEBUG_CONFIG="idekey=PHPSTORM" php -dxdebug.remote_enable=on -f' -alias xphp='XDEBUG_CONFIG="idekey=PHPSTORM" php -dxdebug.remote_enable=on -f' -alias phpx7='XDEBUG_CONFIG="idekey=PHPSTORM" php7.0 -dxdebug.remote_enable=on -f' -alias xphp7='XDEBUG_CONFIG="idekey=PHPSTORM" php7.0 -dxdebug.remote_enable=on -f' -alias xb='phpx bin/magento' -alias bx='phpx bin/magento' -alias xc='phpx bin/connector' -alias cx='phpx bin/connector' -alias sx='phpx bin/console' -alias xs='phpx bin/console' - -# Git aliasses -alias gs='git status' -alias gc='git commit' -alias ga='git add' -alias gb='git branch' -alias gl='git log' -alias gco='git checkout' -alias gcom='git checkout master' -alias gam='git commit --amend --no-edit' -alias gp='git push' -alias gpom='git push origin master' -alias gm='git merge' -alias gd='git diff' - -# Composer Lib Development alias -alias cld='composer_lib_development' - -# Update Developer Programs Linux -alias update_postman='sudo rm -rf /opt/Postman/; wget https://dl.pstmn.io/download/latest/linux64 -O postman.tar.gz; sudo tar -xzf postman.tar.gz -C /opt; rm postman.tar.gz' - -# Environment tools -alias emnt=mount_site -alias eumnt=umount_site -alias edbg=debug_site - -# Custom prompt -function parse_git_branch() { # Git Branch - BRANCH=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'` - if [ ! "${BRANCH}" == "" ] - then - echo "[${BRANCH}]" - else - echo "" - fi -} - -function parse_git_tag() { # Git Tag - TAG=`git describe --abbrev=0 --tags 2> /dev/null` - if [ ! "${TAG}" == "" ] - then - echo "[${TAG}]" - else - echo "" - fi -} - -# PS1 Line -PS1="\[\e[00;33m\]\u\[\e[0m\]\[\e[00;37m\]@\h:\[\e[0m\]\[\e[0;31m\]\`parse_git_branch\`\[\e[m\]\[\e[0m\]\[\e[0;38m\]\`parse_git_tag\`\[\e[m\]\[\e[00;36m\][\w]\[\e[0m\]\[\e[00;32m\]\nbash> \[\e[0m\]" -export COMPOSER_HOME=~/.composer diff --git a/README.md b/README.md index 5324ee8..0852e7d 100644 --- a/README.md +++ b/README.md @@ -15,23 +15,7 @@ Make a copy of the config.sample.sh file, rename it to config.sh and update acco ### Different PHP Versions Support -Magento 2.1 requires php7.0 but Magento 2.3 requires php7.1. To run both environments you have to create a switch in your NGINX but also in the installation. - -Set the PHP7 and COMPOSER_PHP7 variables in the config.sh. - -Additional information: - - - Install Different PHP Versions see for Example for Ubuntu: - https://www.tecmint.com/install-different-php-versions-in-ubuntu/ - - Alternative switch PHP version for Linux users: - - after installing different versions of php-fpm use the following command to switch php-version: - ```phpswitch 7.0``` - - Make a manual switch in NGINX - - Set the fastcgi_pass for Magento 2.1 - - fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; - - Set the fastcgi_pass for Magento 2.3 - - fastcgi_pass unix:/var/run/php/php7.1-fpm.sock; - - **IMPORTANT: Magento 2.2 can fun on both php versions** +**Deprecated: just use `valet use 7.2`** ### Use the simplified aliases Include .bash_xp in .bashrc or .bash_aliases, include example: @@ -48,11 +32,6 @@ fi - [Create Website](#create-website) - [Add Module](#add-module) - [Update Modules](#update-modules) - - [Code Quality Scan](#code-quality-scan) - - [Site Search Command](#site-search-command) - - [Composer Lib Development](#composer-lib-development) - - [Aliases](#aliases) - - [Githooks](#githooks) @@ -131,29 +110,6 @@ usage (run in Magento 2 Root): update_modules ``` - -### Code Quality Scan - -``` -$1 = path -$2 = severity -$3 = mode ('fix' will run phpcbf) -``` - -``` -code_quality $1 $2 $3 -``` - -usage (run in Magento 2 Root): - -``` -code_quality app/code/MyModule/Helloworld 7 -``` - -``` -code_quality app/code/MyModule/Helloworld 7 fix -``` - ### Import Website from Backup **This feature also supports import for a Magento 1 Webshop** @@ -172,95 +128,12 @@ Requires the following files to be in the destination domain folder: structure.s update_website name ``` -### Site Search Command -When you have installed your websites in ~/domains you can search through them with the following command. This functionality also supports autofill. - -``` -site -``` - -### Composer Lib Development - -If you want to use the composer_lib_development command to make symbolic links for vendor modules follow the following steps: - -``` -1. sudo ln -s ~/tools/Magento-2-Bash-Localhost-Installation-Script/composer_lib_development /usr/local/bin/composer_lib_development -2. sudo chmod +x /usr/local/bin/composer_lib_development - -``` - -Now run the command from the Magento root: - -``` -composer_lib_development -``` - -*Additional Alias is `cld` - - -### Aliases -#### Magerun aliasses -``` -alias m='magerun' -alias m2='magerun2' -``` - -#### PHP aliases -``` -alias php7='php7.0' -alias composer7='php7 /usr/bin/composer' -alias php71='php7.1' -alias composer71='php71 /usr/bin/composer' -``` - -#### PhpStorm aliasses -``` -alias p='phpstorm' -``` - -#### PHPX - Xdebug -``` -alias phpx='XDEBUG_CONFIG="idekey=PHPSTORM" php -dxdebug.remote_enable=on -f' -alias xphp='XDEBUG_CONFIG="idekey=PHPSTORM" php -dxdebug.remote_enable=on -f' -alias phpx7='XDEBUG_CONFIG="idekey=PHPSTORM" php7.0 -dxdebug.remote_enable=on -f' -alias xphp7='XDEBUG_CONFIG="idekey=PHPSTORM" php7.0 -dxdebug.remote_enable=on -f' -``` - -#### Git aliasses -``` -alias gs='git status' -alias gc='git commit' -alias ga='git add' -alias gb='git branch' -alias gl='git log' -alias gco='git checkout' -alias gcom='git checkout master' -alias gam='git commit --amend --no-edit' -alias gp='git push' -alias gpom='git push origin master' -alias gm='git merge' -alias gd='git diff' -``` - -#### Composer Lib Development alias -``` -alias cld='composer_lib_development' -``` - #### Update Developer Programs Linux ``` alias update_postman='sudo rm -rf /opt/Postman/; wget https://dl.pstmn.io/download/latest/linux64 -O postman.tar.gz; sudo tar -xzf postman.tar.gz -C /opt; rm postman.tar.gz' ``` -### Githooks -Added a simple pre-push githook to generate a CHANGELOG.md based on git version tags. - -Start using the githooks of this repository by running the following command: -``` -git config --global core.hooksPath ~/tools/Magento-2-Bash-Localhost-Installation-Script/githooks -``` - ### NFS Please install mage2tv/magento-cache-clean globally with composer so you can enable all cache and just run cf -w diff --git a/code_quality.sh b/code_quality.sh deleted file mode 100644 index 7661498..0000000 --- a/code_quality.sh +++ /dev/null @@ -1,31 +0,0 @@ -if [ ! -f app/etc/env.php ]; then - echo "This is command has to be executed from the root of your Magento 2 Installation" - exit; -fi - -SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )" - -CONFIGPATH=$SCRIPTPATH/config.sh -if [ -e $CONFIGPATH ] -then - . $CONFIGPATH -else - . $SCRIPTPATH/config.sample.sh -fi - -CURRENT_PATH="$(pwd -P)" -SCAN_FOLDER=$1 -SEVERITY=$2 -MODE=$3 -FULL_PATH="$CURRENT_PATH/$SCAN_FOLDER" - -if [ ! -d "$FULL_PATH" ]; then - echo "Folder does not exists." - exit; -fi - -if [ "$MODE" = "fix" ]; then - $PHPCBF_PATH $FULL_PATH --standard=MEQP2 --extensions=php,phtml --severity=$SEVERITY -else - $PHPCS_PATH $FULL_PATH --standard=MEQP2 --extensions=php,phtml --severity=$SEVERITY -fi diff --git a/composer_lib_development b/composer_lib_development deleted file mode 100755 index b5d2a47..0000000 --- a/composer_lib_development +++ /dev/null @@ -1,177 +0,0 @@ -#!/usr/bin/env python3 -import argparse -import sys -import os -import json -import subprocess -import shutil -import collections - -class Command: - - def __init__(self): - parser = argparse.ArgumentParser( - description="Command for developing composer pacakges in lib folder", - usage="""composer_lib_development [] - -Available commands: - init Clone missing packages in lib folder - link Symlink lib folder to composer - unlink Remove symlink from composer and run composer install - status Show GIT status for changed packages - versions Show latest version - no_versions Show packages that has commits with no version - -composer_development.json: - { - "": "", - - # Example - "experius/module-missingtranslations": "git@github.com:experius/Magento-2-Module-Experius-MissingTranslations.git" - } - """) - - parser.add_argument('command', help="Subcommand to run") - - args = parser.parse_args(sys.argv[1:2]) - if not hasattr(self, args.command): - print("Unrecognized command") - parser.print_help() - sys.exit(1) - - try: - getattr(self, args.command)() - except Exception as e: - print('ERROR: {}'.format(e)) - sys.exit(1) - - def init(self): - # Clone missing packages - lib_path = os.path.join(os.getcwd(), 'lib') - - if not os.path.isdir(lib_path): - raise Exception('Could not find lib folder') - - for name, giturl in self.get_packages().items(): - namespace, folder = name.split('/') - package_libpath = os.path.join(lib_path, namespace, folder) - - if os.path.isdir(package_libpath): - print('- Skipping {}, lib folder already exists'.format(name)) - continue - - try: - os.makedirs(package_libpath) - self.run_command(['git', 'clone', giturl, package_libpath]) - print('- Cloned {} to {}'.format(name, package_libpath)) - except Exception as e: - print('- ERROR initing ({}): {}'.format(name, e)) - - def link(self): - # Symlink pacakges to composer folder - lib_path = os.path.join(os.getcwd(), 'lib') - vendor_path = os.path.join(os.getcwd(), 'vendor') - - if not os.path.isdir(lib_path): - raise Exception('Could not find lib folder') - - if not os.path.isdir(vendor_path): - raise Exception('Could not find vendor folder') - - for name, giturl in self.get_packages().items(): - namespace, folder = name.split('/') - package_libpath = os.path.join(lib_path, namespace, folder) - package_vendor_path = os.path.join(vendor_path, namespace, folder) - - if not os.path.isdir(package_libpath): - print("- Skipping {}, lib folder doesn't exists (run init first)".format(name)) - continue - - if not os.path.isdir(package_vendor_path): - print("- Skipping {}, vendor folder doesn't exists (Add {} to compser and run composer update)".format(name, name)) - continue - - try: - shutil.rmtree(package_vendor_path) - except: - pass - - try: - os.unlink(package_vendor_path) - except: - pass - - try: - os.symlink(package_libpath, package_vendor_path) - print('- {} is linked to {}'.format(name, package_vendor_path)) - except Exception as e: - print('- ERROR symlinking ({}): {}'.format(name, e)) - - def unlink(self): - # Remove symlinks from compser and run composer install - vendor_path = os.path.join(os.getcwd(), 'vendor') - - for name, giturl in self.get_packages().items(): - namespace, folder = name.split('/') - package_vendor_path = os.path.join(vendor_path, namespace, folder) - - try: - os.unlink(package_vendor_path) - print('- Unlink {}'.format(name)) - except: - pass - - print('\nRun Composer install\n') - self.run_command(['composer', 'install']) - self.run_command(['rm', 'var/.regenerate']) - - def status(self): - for name, lib_path in self.get_lib_packages(): - status = self.run_command(['git', '-C', lib_path, 'status']) - - if 'nothing to commit' not in status: - print() - print('#' * 80) - print(name) - print('-' * 80) - print(status) - - def versions(self): - for name, lib_path in self.get_lib_packages(): - version = self.run_command(['git', '-C', lib_path, 'describe', '--abbrev=0', '--tags']).strip() - print("{}: {}".format(name, version)) - - def no_versions(self): - for name, lib_path in self.get_lib_packages(): - tags = self.run_command(['git', '-C', lib_path, 'tag', '--contains', 'HEAD']).strip() - if not tags: - print(name) - - def get_packages(self): - config_path = os.path.join(os.getcwd(), 'composer_development.json') - with open(config_path, encoding='utf-8') as config_file: - data = json.load(config_file) - if isinstance(data, dict): - return collections.OrderedDict(sorted(data.items())) - else: - raise Exception('Could not load (composer_development.json), because json data is not of type `dict`') - - def get_lib_packages(self): - lib_path = os.path.join(os.getcwd(), 'lib') - - for name, giturl in self.get_packages().items(): - namespace, folder = name.split('/') - yield name, os.path.join(lib_path, namespace, folder) - - def run_command(self, command): - process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - out, err = process.communicate() - - if process.returncode: - raise Exception(err.decode('utf-8')) - return out.decode('utf-8') - - -if __name__ == "__main__": - Command() - diff --git a/environment_tools.sh b/environment_tools.sh deleted file mode 100644 index a7d218b..0000000 --- a/environment_tools.sh +++ /dev/null @@ -1,91 +0,0 @@ -#!/bin/bash - -SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )" -CONFIGPATH=$SCRIPTPATH/config.sh -if [ -e $CONFIGPATH ] -then - . $CONFIGPATH -else - . $SCRIPTPATH/config.sample.sh -fi - -EMNT_DEFAULT_SITE_CONFIG="$SCRIPTPATH/site_domain_aliases.txt" - -get_site_config_part() { - echo $(echo "$1" | cut -d$'\t' -f$2 ||) -} - -get_site_config() { - CONFIG_FILE=$1 - QUERY=$2 - DEFAULT_ENV=$3 - - # Read configuration - CONFIG_LINE="$(grep -w "^$QUERY" "$CONFIG_FILE")" - - # Clear current loaded config - export SITE_DOMAIN="" - export SITE_ENV="" - export SITE_EXTRA="" - - SITE_DOMAIN="$(get_site_config_part "$CONFIG_LINE" 2)" - SITE_ENV="$(get_site_config_part "$CONFIG_LINE" 3)" - SITE_EXTRA="$(get_site_config_part "$CONFIG_LINE" 4)" - - # Export current site info - export SITE_DOMAIN="${SITE_DOMAIN:-$QUERY}" - export SITE_ENV="${DEFAULT_ENV:-$SITE_ENV}" - export SITE_EXTRA="$SITE_EXTRA" -} - -get_env_ssh_config() { - SITE_ENV=$1 - export SITE_ENV_HOST="$(grep $SITE_ENV ~/.ssh/config -A 3 | grep '^.*HostName' | sed 's/HostName//' | tr -cd '[[:alnum:]]._-' | xargs)" -} - -# Mount a remote website -# mount_site alias/domain [ssh_alias] [mounting_dir] -mount_site() { - # Get site config - get_site_config $EMNT_DEFAULT_SITE_CONFIG $1 $2 - - # Check site vars - if [ -z "$SITE_ENV" ]; then - echo "Could not find configuration for \"$SITE_DOMAIN\". Please check your config: $EMNT_DEFAULT_SITE_CONFIG." - return - fi - - # If provided use given mount directory. Otherwise use default mount dir + domain name - MNT_DIR="$3" - if [ -z "$MNT_DIR" ]; then - MNT_DIR="$SITE_DOMAIN" - fi - - get_env_ssh_config "$SITE_ENV" - - SITE_REMOTE_LOCATION="$(echo "$EMNT_DEFAULT_SITE_REMOTE_LOCATION_FORMAT" | envsubst)" - if [ -z "$3" ]; then - SITE_LOCAL_LOCATION="$EMNT_DEFAULT_SITE_MOUNT_DIR/$(echo "$EMNT_DEFAULT_SITE_LOCAL_LOCATION_FORMAT" | envsubst)" - else - SITE_LOCAL_LOCATION=$3 - fi - - echo "Mounting: $SITE_DOMAIN on ENV: $SITE_ENV. $SITE_EXTRA" - echo "From $SITE_REMOTE_LOCATION to $SITE_LOCAL_LOCATION" - - mkdir -p $SITE_LOCAL_LOCATION - fusermount3 -u $SITE_LOCAL_LOCATION - sshfs -C $SITE_ENV:$SITE_REMOTE_LOCATION $SITE_LOCAL_LOCATION -} - -umount_site() { - get_site_config $EMNT_DEFAULT_SITE_CONFIG $1 - SITE_LOCAL_LOCATION="$EMNT_DEFAULT_SITE_MOUNT_DIR/$(echo "$EMNT_DEFAULT_SITE_LOCAL_LOCATION_FORMAT" | envsubst)" - fusermount -u $SITE_LOCAL_LOCATION -} - -debug_site() { - get_site_config $EMNT_DEFAULT_SITE_CONFIG $1 - ssh -R 9000:localhost:9000 "${SITE_ENV:-$1}" -v -} - diff --git a/git_import.sh b/git_import.sh deleted file mode 100644 index b619336..0000000 --- a/git_import.sh +++ /dev/null @@ -1,101 +0,0 @@ -#!/usr/bin/env bash - -SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )" -CONFIGPATH=$SCRIPTPATH/config.sh -if [ -e $CONFIGPATH ] -then - . $CONFIGPATH -else - . $SCRIPTPATH/config.sample.sh -fi - -NAME=$1 - -if [ -z "$NAME" ]; then - echo "enter name. Will be used as $DOMAIN_PREFIX$DOMAIN_SUFFIX" - exit; -fi - -GITREPONAME=$2 - -if [ -z "$GITREPONAME" ]; then - echo "enter git repository name. This will be used for cloning." - exit; -fi - -VALET_DOMAIN=$DOMAIN_PREFIX$NAME -DIRECTORY=$DOMAINS_PATH/$VALET_DOMAIN$FOLDER_SUFFIX -DOMAIN=$VALET_DOMAIN$DOMAIN_SUFFIX -MYSQL_DATABASE_NAME=$MYSQL_DATABASE_PREFIX$NAME -MYSQL_DATABASE_NAME="${MYSQL_DATABASE_NAME//./_}" - -URL="http://$DOMAIN" -if [ "$secure" = "true" ]; then - URL="https://$DOMAIN" -fi -if [ ! -d "$DIRECTORY" ]; then - echo "Directory not found" - exit; -fi - -## Clone git repo and deploy it. -mv $DIRECTORY/structure.sql $DIRECTORY/../structure.sql -mv $DIRECTORY/data.sql $DIRECTORY/../data.sql -git clone git@bitbucket.org:$GIT_REPO_VENDOR/$GITREPONAME.git $DIRECTORY -mv $DIRECTORY/../structure.sql $DIRECTORY/structure.sql -mv $DIRECTORY/../data.sql $DIRECTORY/data.sql - -## Check if we are installing Magento 1 or 2 -if [ -f "$DIRECTORY/app/Mage.php" ]; then - VERSION="m1" - MAGERUN_COMMAND=$MAGERUN1_COMMAND -else - VERSION="m2" - MAGERUN_COMMAND=$MAGERUN2_COMMAND -fi - -## Create and import DB -mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -e "CREATE DATABASE IF NOT EXISTS \`$MYSQL_DATABASE_NAME\`" -mysql -u$MYSQL_USER -p$MYSQL_PASSWORD $MYSQL_DATABASE_NAME < $DIRECTORY/structure.sql -mysql -u$MYSQL_USER -p$MYSQL_PASSWORD $MYSQL_DATABASE_NAME < $DIRECTORY/data.sql - -if [ "$VERSION" = "m2" ]; then - ## Create new env.php - mkdir -p $DIRECTORY/app/etc - cp $SCRIPTPATH/Helper/Placeholder/env.php $DIRECTORY/app/etc - composer install -d$DIRECTORY - rm $DIRECTORY/var/.regenerate - $PHP $SCRIPTPATH/Helper/updateEnv.php -f$DIRECTORY -d$MYSQL_DATABASE_NAME -u$MYSQL_USER -p$MYSQL_PASSWORD - $MAGERUN_COMMAND --root-dir=$DIRECTORY module:enable --all -else - ## Create new local.xml - cp $SCRIPTPATH/Helper/Placeholder/local.xml $DIRECTORY/app/etc/local.xml - $PHP $SCRIPTPATH/Helper/updateLocal.php -f$DIRECTORY -d$MYSQL_DATABASE_NAME -u$MYSQL_USER -p$MYSQL_PASSWORD -fi - -## Set correct base urls -for CONFIG_PATH in 'web/unsecure/base_url' 'web/secure/base_url' 'web/unsecure/base_link_url' 'web/secure/base_link_url' -do - mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -D $MYSQL_DATABASE_NAME -e "UPDATE \`core_config_data\` SET \`value\`='$URL/' WHERE \`path\`='$CONFIG_PATH'" -done - -## Developer Settings -$PHP $DIRECTORY/bin/magento deploy:mode:set developer -$PHP $DIRECTORY/bin/magento cache:enable -$PHP $DIRECTORY/bin/magento cache:disable layout block_html collections full_page - -### Generated PhpStorm XML Schema Validation -mkdir -p $DIRECTORY/.idea -$PHP $DIRECTORY/bin/magento dev:urn-catalog:generate $DIRECTORY/.idea/misc.xml - -. $SCRIPTPATH/src/update_settings.sh - -## Remove the import files -rm $DIRECTORY/structure.sql -rm $DIRECTORY/data.sql - -. $SCRIPTPATH/src/create_admin_user.sh - -. $SCRIPTPATH/src/secure_domain.sh - -. $SCRIPTPATH/src/nfs.sh diff --git a/githooks/pre-push b/githooks/pre-push deleted file mode 100755 index 678a07b..0000000 --- a/githooks/pre-push +++ /dev/null @@ -1,95 +0,0 @@ -#!/bin/bash -YELLOW='\033[0;33m' -GREEN='\033[0;32m' -BLUE='\033[0;36m' -RED='\033[0;31m' -NC='\033[0m' -branch="$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')" - -if [ $branch != 'master' ]; then - if [ $branch != 'production' ]; then - exit 0; - fi -fi -# If we have a STDIN, use it, otherwise get one -if tty >/dev/null 2>&1; then - TTY=$(tty) -else - TTY=/dev/tty -fi - -IFS=$'\n' - -remote="$1" - -# http://djm.me/ask -ask() { - while true; do - - if [ "${2:-}" = "Y" ]; then - prompt="Y/n" - default=Y - elif [ "${2:-}" = "N" ]; then - prompt="y/N" - default=N - else - prompt="y/n" - default= - fi - - # Ask the question (not using "read -p" as it uses stderr not stdout) - printf "${BLUE}$1${NC} [$prompt]" - - # Read the answer - read REPLY < "$TTY" - - # Default? - if [ -z "$REPLY" ]; then - REPLY=$default - fi - - # Check if the reply is valid - case "$REPLY" in - Y*|y*) return 0 ;; - N*|n*) return 1 ;; - esac - - done -} - -{ bitbucket_url=$(git remote get-url --push ${remote}); bitbucket_url="${bitbucket_url/git\@bitbucket\.org\:$GIT_REPO_VENDOR/https://bitbucket.org/$GIT_REPO_VENDOR}"; previous_tag=0 ; for current_tag in $(git tag --sort=-creatordate); do if [ "$previous_tag" != 0 ]; then tag_date=$(git log -1 --pretty=format:'%ad' --date=short ${previous_tag}); printf "## ${previous_tag} (${tag_date})\n\n[View Release](${bitbucket_url}/commits/tag/${previous_tag})\n\n"; git log ${current_tag}...${previous_tag} --pretty=format:"* %s *(%an)*" --reverse | grep -v Merge; printf "\n\n"; fi; previous_tag=${current_tag}; done ; previous_tag=$(git tag --sort=-creatordate | tail -n 1); tag_date=$(git log -1 --pretty=format:'%ad' --date=short ${previous_tag}); printf "## ${previous_tag} (${tag_date})\n\n[View Release](${bitbucket_url}/commits/tag/${previous_tag})\n\n"; git log ${previous_tag} --pretty=format:"* %s *(%an)*" --reverse | grep -v Merge; printf "\n\n"; } > CHANGELOG.md -if [ $(git status --porcelain | grep CHANGELOG.md | wc -l) -gt 0 ]; then - latest_tag=$(git tag --sort=creatordate | tail -n 1); - if ask "Do want to update the CHANGELOG.md according to version ${latest_tag}?" Y; then - git add CHANGELOG.md; - git log ${remote}/${branch}..${branch} > /dev/null 2>&1; - if [ $? -ne 0 ] && [ "$(git ls-remote ${remote} refs/heads/${branch})" != "" ]; then - git fetch ${remote} ${branch} - STATUS="$(git log ${remote}/${branch}..${branch})" - else - STATUS="new-branch" - fi - - if [ "$(git ls-remote ${remote} refs/tags/${latest_tag})" == "" ] && [ $STATUS != "" ]; then - git tag -d $latest_tag > /dev/null 2>&1; - git commit --amend --no-edit > /dev/null 2>&1; - git tag $latest_tag; - printf "${YELLOW}NOTICE${NC} - The update of the CHANGELOG.md has been added to your commit.\n"; - else - git commit -m "[DOCS] Updated the CHANGELOG.md" > /dev/null 2>&1; - printf "${YELLOW}NOTICE${NC} - The update of the CHANGELOG.md has been added to a separate commit.\n"; - fi - git push ${remote} ${branch} --tags; - if [ $? -eq 0 ] - then - printf "${GREEN}SUCCESS${NC} - The CHANGELOG.md has been updated and pushed to the remote.\n"; - printf "${YELLOW}NOTICE${NC} - Please ignore the error below.\n"; - else - printf "${RED}ERROR${NC} - Something went wrong while updating the CHANGELOG.md\n" - fi - exit 1; - else - printf "${YELLOW}NOTICE${NC} - Skip updating the CHANGELOG.md\n"; - git checkout CHANGELOG.md; - fi -fi diff --git a/phpswitch.sh b/phpswitch.sh deleted file mode 100644 index 50c8c43..0000000 --- a/phpswitch.sh +++ /dev/null @@ -1,74 +0,0 @@ -PHPVERSION=$1 - -# Function to install given php version -function installPhpVersion -{ - # add repository for php7.0-fpm as it is not available by default anymore - if [[ "$PHPVERSION" =~ "7.0" ]]; then - echo 'Add extra repository for php7.0' - sudo apt-add-repository ppa:ondrej/php - fi - - INSTALL_PHP_VERSION="php${PHPVERSION}-fpm" - echo "Install php: ${INSTALL_PHP_VERSION}" - sudo apt install -y $INSTALL_PHP_VERSION - - installMagento2PhpModules -} - -function installMagento2PhpModules -{ - echo "Install php modules: ..." - MAGENTO2_PHP_EXTENSIONS=("bcmath" "mcrypt" "ctype" "curl" "dom" "gd" "hash" "iconv" "intl" "mbstring" "mysql" "simplexml" "soap" "xsl" "zip" "libxml") - for EXTENSION in "${MAGENTO2_PHP_EXTENSIONS[@]}" - do - PHP_EXTENSION="php${PHPVERSION}-${EXTENSION}" - sudo apt install -y $PHP_EXTENSION - done - - MAGENTO2_EXTENSIONS=("openssl" "libxml2") - for EXTENSION in "${MAGENTO2_EXTENSIONS[@]}" - do - sudo apt install -y $EXTENSION - done -} - -if [ -z "$PHPVERSION" ]; then - echo "enter a php version number. for example: 7.2" - exit; -fi - -# Find out which php-fpm versions are installed en echo them -INSTALLED_PHP_VERSIONS=$(apt list --installed | grep --only-matching --perl-regexp "php7\.\\d+-fpm") -echo "php-fpm versions installed: " -for VERSION in "${INSTALLED_PHP_VERSIONS[@]}" -do - echo "$VERSION" -done - -# Check if php version the user likes to switch to is installed and ask to install it otherwise -MATCH_PHP_VALUE="php${PHPVERSION}-fpm" -if [[ ! " ${INSTALLED_PHP_VERSIONS[@]} " =~ ${MATCH_PHP_VALUE} ]]; then - echo "${MATCH_PHP_VALUE} is not installed. Would you like to install ${MATCH_PHP_VALUE}?" - read -p "Y/n: " -n 1 -r - if [[ $REPLY =~ ^[Yy]$ ]] - then - installPhpVersion - fi -fi - -echo "stopping valet..." -valet stop - -echo "update-alternatives of Linux to point 'php' alias to the new php version..." -echo "update-alternatives --set php /usr/bin/php$PHPVERSION" -sudo update-alternatives --set php /usr/bin/php$PHPVERSION - -echo "Update composer config to the new php version and update all global packages to be compatible with this php version..." -composer global config platform.php $PHPVERSION - -echo "restarting valet..." -valet restart - -CURRENT_PHP_VERSION=$(php -v) -echo "Currently running on PHP: ${CURRENT_PHP_VERSION}" diff --git a/site_domain_aliases.txt b/site_domain_aliases.txt deleted file mode 100644 index afb7980..0000000 --- a/site_domain_aliases.txt +++ /dev/null @@ -1 +0,0 @@ -example example.com example Visit example.com