Skip to content

Commit 7ca9324

Browse files
author
Alexander Paliarush
committed
- On Windows use m-reinstall instead of m-switch-to-* in init_project.sh
- Improved stability of m-clear-cache and m-reinstall scripts - Fixed debugginfor web API functional tests (#12)
1 parent 32c98b6 commit 7ca9324

9 files changed

+68
-35
lines changed

Diff for: CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
1414
- Removed requirement for public github token due to Composer limitations (issue is fixed on Composer side)
1515
- Changed requirement for minimum box version from 1.0 to 1.1
1616
- Upgraded PHP 5.5.9 to PHP 5.6
17-
- When [init_project.sh](init_project.sh) is executed, EE will be installed by default, if EE repository is specified in [etc/config.yaml.dist](etc/config.yaml.dist)
17+
- When [init_project.sh](init_project.sh) is executed, EE will be installed by default, if EE repository is specified in [etc/config.yaml.dist](etc/config.yaml.dist). Not supported on Windows hosts
1818

1919
### Fixed
2020

Diff for: CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Everyone is welcome to contribute improvements and fixes to this project. There are no specific requirements, just create a pull request with proposed modifications.
1+
Everyone is welcome to contribute improvements and fixes to this project. There are no specific requirements, just create a pull request with proposed modifications and try to run [tests](https://github.com/paliarush/magento2-vagrant-for-developers-tests) on your local environment.

Diff for: init_project.sh

+12-7
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ magento_ce_dir="${vagrant_dir}/magento2ce"
55
magento_ee_dir="${magento_ce_dir}/magento2ee"
66
config_path="${vagrant_dir}/etc/config.yaml"
77
host_os=$(bash "${vagrant_dir}/scripts/host/get_host_os.sh")
8+
use_nfs=$(bash "${vagrant_dir}/scripts/get_config_value.sh" "guest_use_nfs")
9+
repository_url_ce=$(bash "${vagrant_dir}/scripts/get_config_value.sh" "repository_url_ce")
10+
repository_url_ee=$(bash "${vagrant_dir}/scripts/get_config_value.sh" "repository_url_ee")
811

912
# Enable trace printing and exit on the first error
1013
set -ex
@@ -65,11 +68,9 @@ if [[ ! -d ${magento_ce_dir} ]]; then
6568
git config --global diff.renamelimit 5000
6669
fi
6770
# Check out CE repository
68-
repository_url_ce=$(bash "${vagrant_dir}/scripts/get_config_value.sh" "repository_url_ce")
6971
git clone ${repository_url_ce} "${magento_ce_dir}"
7072
# Check out EE repository
7173
# By default EE repository is not specified and EE project is not checked out
72-
repository_url_ee=$(bash "${vagrant_dir}/scripts/get_config_value.sh" "repository_url_ee")
7374
if [[ -n "${repository_url_ee}" ]]; then
7475
git clone ${repository_url_ee} "${magento_ee_dir}"
7576
fi
@@ -83,10 +84,15 @@ bash "${vagrant_dir}/scripts/host/composer.sh" install
8384
cd "${vagrant_dir}"
8485
vagrant up
8586

86-
if [[ -n "${repository_url_ee}" ]]; then
87-
bash "${vagrant_dir}/m-switch-to-ee" -f
87+
if [[ ${host_os} == "Windows" ]] || [[ ${use_nfs} == 0 ]]; then
88+
# Automatic switch to EE during project initialization cannot be supported on Windows
89+
bash "${vagrant_dir}/m-reinstall"
8890
else
89-
bash "${vagrant_dir}/m-switch-to-ce" -f
91+
if [[ -n "${repository_url_ee}" ]]; then
92+
bash "${vagrant_dir}/m-switch-to-ee" -f
93+
else
94+
bash "${vagrant_dir}/m-switch-to-ce" -f
95+
fi
9096
fi
9197

9298
set +x
@@ -104,8 +110,7 @@ echo "
104110
${bold}[Important]${regular}
105111
Please use ${bold}${vagrant_dir}${regular} directory as PhpStorm project root, NOT ${bold}${magento_ce_dir}${regular}."
106112

107-
use_nfs=$(bash "${vagrant_dir}/scripts/get_config_value.sh" "guest_use_nfs")
108-
if [[ ${host_os} == "Windows" || ${use_nfs} == 0 ]]; then
113+
if [[ ${host_os} == "Windows" ]] || [[ ${use_nfs} == 0 ]]; then
109114
echo "
110115
${bold}[Optional]${regular}
111116
To verify that deployment configuration for ${bold}${magento_ce_dir}${regular} in PhpStorm is correct,

Diff for: m-switch-to-ce

+12-8
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@ php_executable=$(bash "${vagrant_dir}/scripts/host/get_path_to_php.sh")
99
# Enable trace printing and exit on the first error
1010
set -ex
1111

12-
if [[ ! -f ${magento_ee_dir}/app/etc/aliases_to_classes_map.json ]]; then
13-
set +x
14-
echo "EE codebase is not available"
15-
exit 0
16-
fi
17-
1812
force_switch=0
1913
while getopts 'f' flag; do
2014
case "${flag}" in
@@ -23,6 +17,16 @@ while getopts 'f' flag; do
2317
esac
2418
done
2519

20+
if [[ ! -f ${magento_ee_dir}/app/etc/aliases_to_classes_map.json ]]; then
21+
set +x
22+
echo "EE codebase is not available"
23+
set -x
24+
if [[ ${force_switch} -eq 1 ]]; then
25+
bash "${vagrant_dir}/m-reinstall"
26+
fi
27+
exit 0
28+
fi
29+
2630
if [[ ! -f ${magento_ce_dir}/app/etc/aliases_to_classes_map.json ]] && [[ ${force_switch} -eq 0 ]]; then
2731
set +x
2832
echo "Already switched to CE. Use 'm-switch-to-ce -f' to switch anyway."
@@ -35,7 +39,7 @@ cd ${magento_ce_dir}
3539
git checkout composer.json
3640
git checkout composer.lock
3741

38-
if [[ ${host_os} == "Windows" || $(bash "${vagrant_dir}/scripts/get_config_value.sh" "guest_use_nfs") == 0 ]]; then
42+
if [[ ${host_os} == "Windows" ]] || [[ $(bash "${vagrant_dir}/scripts/get_config_value.sh" "guest_use_nfs") == 0 ]]; then
3943
# Prevent issues on Windows with incorrect symlinks to files
4044
if [[ -f ${magento_ce_dir}/app/etc/aliases_to_classes_map.json ]]; then
4145
rm ${magento_ce_dir}/app/etc/aliases_to_classes_map.json
@@ -50,7 +54,7 @@ bash "${vagrant_dir}/m-clear-cache"
5054
bash -c "${vagrant_dir}/m-composer install"
5155

5256
echo "Magento installation..."
53-
if [[ ${host_os} == "Windows" || $(bash "${vagrant_dir}/scripts/get_config_value.sh" "guest_use_nfs") == 0 ]]; then
57+
if [[ ${host_os} == "Windows" ]] || [[ $(bash "${vagrant_dir}/scripts/get_config_value.sh" "guest_use_nfs") == 0 ]]; then
5458
read -p "Wait while Magento2 code is uploaded in PhpStorm and press any key to continue..." -n1 -s
5559
fi
5660

Diff for: m-switch-to-ee

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ ${php_executable} -f ${magento_ee_dir}/dev/tools/build-ee.php -- --command=link
3434
cp ${magento_ee_dir}/composer.json ${magento_ce_dir}/composer.json
3535
cp ${magento_ee_dir}/composer.lock ${magento_ce_dir}/composer.lock
3636

37-
if [[ ${host_os} == "Windows" || $(bash "${vagrant_dir}/scripts/get_config_value.sh" "guest_use_nfs") == 0 ]]; then
37+
if [[ ${host_os} == "Windows" ]] || [[ $(bash "${vagrant_dir}/scripts/get_config_value.sh" "guest_use_nfs") == 0 ]]; then
3838
# Prevent issues on Windows with incorrect symlinks to files
3939
if [[ -f ${magento_ee_dir}/app/etc/aliases_to_classes_map.json ]] && [[ -L ${magento_ce_dir}/app/etc/aliases_to_classes_map.json ]]; then
4040
rm ${magento_ce_dir}/app/etc/aliases_to_classes_map.json
@@ -51,7 +51,7 @@ bash "${vagrant_dir}/m-clear-cache"
5151
bash -c "${vagrant_dir}/m-composer install"
5252

5353
echo "Magento installation..."
54-
if [[ ${host_os} == "Windows" || $(bash "${vagrant_dir}/scripts/get_config_value.sh" "guest_use_nfs") == 0 ]]; then
54+
if [[ ${host_os} == "Windows" ]] || [[ $(bash "${vagrant_dir}/scripts/get_config_value.sh" "guest_use_nfs") == 0 ]]; then
5555
read -p "Wait while Magento2 code is uploaded in PhpStorm and press any key to continue..." -n1 -s
5656
fi
5757

Diff for: scripts/guest/m-clear-cache

+27-9
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,32 @@
22

33
echo "Clearing Magento cache..."
44

5-
rm -f ${MAGENTO_ROOT}/app/etc/paths.php
6-
#clear var
7-
cd ${MAGENTO_ROOT} && mv var/.htaccess var_htaccess.back && rm -rf var/* var/.[^.]* && mv var_htaccess.back var/.htaccess
8-
#clear pub/statics
9-
cd ${MAGENTO_ROOT}/pub && mv static/.htaccess static_htaccess.back && rm -rf static && mkdir static && mv static_htaccess.back static/.htaccess
10-
#clear integration tests tmp
11-
cd ${MAGENTO_ROOT}/dev/tests/integration && mv tmp/.gitignore tmp_gitignore.back && rm -rf tmp && mkdir tmp && mv tmp_gitignore.back tmp/.gitignore
12-
#clear unit tests tmp
13-
cd ${MAGENTO_ROOT}/dev/tests/unit && mv tmp/.gitignore tmp_gitignore.back && rm -rf tmp && mkdir tmp && mv tmp_gitignore.back tmp/.gitignore
5+
rm -f "${MAGENTO_ROOT}/app/etc/paths.php"
6+
if [[ -d "${MAGENTO_ROOT}/var" ]]; then
7+
#clear var
8+
cd "${MAGENTO_ROOT}" && mv var/.htaccess var_htaccess.back && rm -rf var/* var/.[^.]*
9+
if [[ -f var_htaccess.back ]]; then
10+
mv var_htaccess.back var/.htaccess
11+
fi
12+
fi
13+
if [[ -d "${MAGENTO_ROOT}/pub" ]]; then
14+
#clear pub/statics
15+
cd "${MAGENTO_ROOT}/pub" && mv static/.htaccess static_htaccess.back && rm -rf static && mkdir static
16+
if [[ -f static_htaccess.back ]]; then
17+
mv static_htaccess.back static/.htaccess
18+
fi
19+
fi
20+
if [[ -d "${MAGENTO_ROOT}/dev" ]]; then
21+
#clear integration tests tmp
22+
cd "${MAGENTO_ROOT}/dev/tests/integration" && mv tmp/.gitignore tmp_gitignore.back && rm -rf tmp && mkdir tmp
23+
if [[ -f tmp_gitignore.back ]]; then
24+
mv tmp_gitignore.back tmp/.gitignore
25+
fi
26+
#clear unit tests tmp
27+
cd "${MAGENTO_ROOT}/dev/tests/unit" && mv tmp/.gitignore tmp_gitignore.back && rm -rf tmp && mkdir tmp
28+
if [[ -f tmp_gitignore.back ]]; then
29+
mv tmp_gitignore.back tmp/.gitignore
30+
fi
31+
fi
1432

1533
echo "Magento cache cleared."

Diff for: scripts/guest/m-reinstall

+9-5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ set -ex
66
get_config_value="/vagrant/scripts/get_config_value.sh"
77
magento_host_name=$(bash ${get_config_value} "magento_host_name")
88
vagrant_dir="/vagrant"
9+
use_nfs=$(bash "${vagrant_dir}/scripts/get_config_value.sh" "guest_use_nfs")
10+
is_windows_host=${IS_WINDOWS_HOST}
911

1012
declare -A setupOptions
1113
setupOptions[admin_frontname]=$(bash ${get_config_value} "magento_admin_frontname")
@@ -27,6 +29,10 @@ setupOptions[amqp_user]='guest'
2729
setupOptions[amqp_password]='guest'
2830
setupOptions[amqp_virtualhost]='/'
2931

32+
if [[ ${is_windows_host} == 1 ]] || [[ ${use_nfs} == 0 ]]; then
33+
sudo chown -R vagrant:vagrant ${MAGENTO_ROOT}
34+
fi
35+
3036
cd ${MAGENTO_ROOT}
3137

3238
# Clear cache
@@ -72,7 +78,7 @@ if [[ -f "${MAGENTO_ROOT}/app/etc/enterprise/di.xml" ]]; then
7278
--amqp-password=${setupOptions[amqp_password]}"
7379
fi
7480

75-
chmod +x bin/magento
81+
sudo chmod +x bin/magento
7682
php ${install_cmd}
7783
# Comment out the line above and uncomment the one below to debug Magento Setup script
7884
# php -d xdebug.remote_host=192.168.10.1 -d xdebug.idekey=PHPSTORM -d xdebug.remote_connect_back=0 -d xdebug.remote_autostart=1 ${install_cmd}
@@ -82,10 +88,8 @@ echo "* * * * * php ${MAGENTO_ROOT}/bin/magento cron:run &
8288
* * * * * php ${MAGENTO_ROOT}/update/cron.php &
8389
* * * * * php ${MAGENTO_ROOT}/bin/magento setup:cron:run &" | crontab -u vagrant -
8490

85-
use_nfs=$(bash "${vagrant_dir}/scripts/get_config_value.sh" "guest_use_nfs")
86-
is_windows_host=${IS_WINDOWS_HOST}
87-
if [[ ${is_windows_host} == 1 || ${use_nfs} == 0 ]]; then
88-
chown -R vagrant:vagrant ${MAGENTO_ROOT}
91+
if [[ ${is_windows_host} == 1 ]] || [[ ${use_nfs} == 0 ]]; then
92+
sudo chown -R vagrant:vagrant ${MAGENTO_ROOT}
8993
fi
9094

9195
# Generate XSD references for PHP Storm

Diff for: scripts/host/configure_php_storm.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ cp -R "${vagrant_dir}/scripts/host/php-storm-configs/." "${vagrant_dir}/.idea/"
1414
enabled_virtual_host_config="/etc/apache2/sites-available/magento2.conf"
1515

1616
host_os=$(bash "${vagrant_dir}/scripts/host/get_host_os.sh")
17-
if [[ ${host_os} == "Windows" || $(bash "${vagrant_dir}/scripts/get_config_value.sh" "guest_use_nfs") == 0 ]]; then
17+
if [[ ${host_os} == "Windows" ]] || [[ $(bash "${vagrant_dir}/scripts/get_config_value.sh" "guest_use_nfs") == 0 ]]; then
1818
sed -i.back "s|<magento_guest_path>|/var/www/magento2ce|g" "${vagrant_dir}/.idea/deployment.xml"
1919
sed -i.back 's|<auto_upload_attributes>| autoUpload="Always" autoUploadExternalChanges="true"|g' "${vagrant_dir}/.idea/deployment.xml"
2020
sed -i.back 's|<auto_upload_option>|<option name="myAutoUpload" value="ALWAYS" />|g' "${vagrant_dir}/.idea/deployment.xml"

Diff for: scripts/provision/configure_environment_recurring.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function init_php56 () {
2525
echo '
2626
xdebug.max_nesting_level=200
2727
xdebug.remote_enable=1
28-
xdebug.remote_connect_back=1' >> /etc/php/5.6/mods-available/xdebug.ini
28+
xdebug.remote_host=192.168.10.1' >> /etc/php/5.6/mods-available/xdebug.ini
2929
}
3030

3131
# Enable trace printing and exit on the first error
@@ -78,6 +78,7 @@ if [[ ${use_php7} -eq 1 ]]; then
7878
if [[ -d "/etc/php/5.6" ]]; then
7979
a2dismod php5.6
8080
fi
81+
sed -i "s|xdebug.remote_connect_back=1|xdebug.remote_host=192.168.10.1|g" /etc/php/7.0/cli/conf.d/20-xdebug.ini
8182
a2enmod php7.0
8283
else
8384
if [[ ! -d "/etc/php/5.6" ]]; then
@@ -86,6 +87,7 @@ else
8687
update-alternatives --set php /usr/bin/php5.6 && a2dismod php7.0 && a2enmod php5.6
8788
rm -f /etc/php/5.6/apache2/php.ini
8889
ln -s /etc/php/5.6/cli/php.ini /etc/php/5.6/apache2/php.ini
90+
sed -i "s|xdebug.remote_connect_back=1|xdebug.remote_host=192.168.10.1|g" /etc/php/5.6/mods-available/xdebug.ini
8991
fi
9092
service apache2 restart
9193
#end Setup PHP

0 commit comments

Comments
 (0)