Skip to content

Commit 762c709

Browse files
author
Alexander Paliarush
committed
Added host scripts for routine flows
1 parent f62c113 commit 762c709

13 files changed

+162
-36
lines changed

README.md

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
* [Day-to-day development scenarios](#day-to-day-development-scenarios)
1414
* [Reinstall Magento](#reinstall-magento)
1515
* [Clear magento cache](#clear-magento-cache)
16+
* [Update composer dependencies](#update-composer-dependencies)
17+
* [Switch between CE and EE](#switch-between-ce-and-ee)
1618
* [Debugging with XDebug](#debugging-with-xdebug)
1719
* [Multiple Magento instances](#multiple-magento-instances)
1820

@@ -52,7 +54,7 @@ Software listed below should be available in [PATH](https://en.wikipedia.org/wik
5254
git config --global core.eol LF
5355
git config --global diff.renamelimit 5000
5456
```
55-
- ![](docs/images/linux-icon.png)![](docs/images/osx-icon.png) [PHP](http://php.net/manual/en/install.php) to allow Magento dependency management with [Composer](https://getcomposer.org/doc/00-intro.md)
57+
- ![](docs/images/linux-icon.png)![](docs/images/osx-icon.png) [PHP](http://php.net/manual/en/install.php) (any version) to allow Magento dependency management with [Composer](https://getcomposer.org/doc/00-intro.md)
5658
- [PHP Storm](https://www.jetbrains.com/phpstorm) is optional but recommended.
5759
- ![](docs/images/linux-icon.png)![](docs/images/osx-icon.png) [NFS server](https://en.wikipedia.org/wiki/Network_File_System) must be installed and running on \*nix and OSX hosts. Is usually available, so just try to follow [installation steps](#how-to-install) first.
5860

@@ -126,15 +128,35 @@ The following command will clear Magento DB, Magento caches and reinstall Magent
126128
Go to 'vagrant-magento' created earlier and run in command line:
127129

128130
```
129-
vagrant provision --provision-with install_magento
131+
bash m-reinstall
130132
```
131133

132134
### Clear magento cache
133135

134136
Go to 'vagrant-magento' created earlier and run in command line:
135137

136138
```
137-
vagrant ssh -c 'magento_clear_cache'
139+
bash m-clear-cache
140+
```
141+
142+
### Switch between CE and EE
143+
144+
Assume, that EE codebase is available in `vagrant_project_root/magento2ce/magento2ee`.
145+
The following commands will link/unlink EE codebase, clear cache, update composer dependencies and reinstall Magento.
146+
Go to 'vagrant-magento' created earlier and run in command line:
147+
148+
```
149+
bash m-switch-to-ce
150+
OR
151+
bash m-switch-to-ee
152+
```
153+
154+
### Update composer dependencies
155+
156+
Go to 'vagrant-magento' created earlier and run in command line:
157+
158+
```
159+
bash m-composer-install
138160
```
139161

140162
### Debugging with XDebug

Vagrantfile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,7 @@ Vagrant.configure(VAGRANT_API_VERSION) do |config|
8282
config.vm.provision "guest_remove_compressed_code", type: "shell", inline: "rm -f /vagrant/scripts/host/magento2ce.tar"
8383
end
8484

85-
config.vm.provision "install_magento", type: "shell" do |s|
86-
s.path = "scripts/provision/install_magento.sh"
87-
s.args = shell_script_args
88-
end
85+
config.vm.provision "install_magento", type: "shell", inline: "m-reinstall"
8986

9087
# Host manager plugin configuration
9188
config.hostmanager.enabled = true

init_project.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ if [ ! -d ${magento_ce_dir} ]; then
5454
git config --global diff.renamelimit 5000
5555
fi
5656
# Check out CE repository
57-
repository_url_ce=$(bash "${vagrant_dir}/scripts/host/get_variable_value.sh" "repository_url_ce")
57+
repository_url_ce=$(bash "${vagrant_dir}/scripts/get_config_value.sh" "repository_url_ce")
5858
git clone ${repository_url_ce} ${magento_ce_dir}
5959
# Check out EE repository
6060
# By default EE repository is not specified and EE project is not checked out
61-
repository_url_ee=$(bash "${vagrant_dir}/scripts/host/get_variable_value.sh" "repository_url_ee")
61+
repository_url_ee=$(bash "${vagrant_dir}/scripts/get_config_value.sh" "repository_url_ee")
6262
if [ -n "${repository_url_ee}" ]; then
6363
git clone ${repository_url_ee} ${magento_ee_dir}
6464
fi

m-clear-cache

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
3+
vagrant_dir=$(cd "$(dirname "$0")"; pwd)
4+
5+
# Enable trace printing and exit on the first error
6+
set -ex
7+
8+
cd ${vagrant_dir}
9+
vagrant ssh -c "m-clear-cache"

m-composer-install

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
3+
vagrant_dir=$(cd "$(dirname "$0")"; pwd)
4+
magento_ce_dir="${vagrant_dir}/magento2ce"
5+
6+
# Enable trace printing and exit on the first error
7+
set -ex
8+
9+
cd ${magento_ce_dir}
10+
bash "${vagrant_dir}/scripts/host/composer.sh" install

m-reinstall

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
3+
vagrant_dir=$(cd "$(dirname "$0")"; pwd)
4+
5+
# Enable trace printing and exit on the first error
6+
set -ex
7+
8+
cd ${vagrant_dir}
9+
vagrant ssh -c "m-reinstall"

m-switch-to-ce

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env bash
2+
3+
vagrant_dir=$(cd "$(dirname "$0")"; pwd)
4+
magento_ce_dir="${vagrant_dir}/magento2ce"
5+
magento_ee_dir="${magento_ce_dir}/magento2ee"
6+
host_os=$(bash "${vagrant_dir}/scripts/host/get_host_os.sh")
7+
php_executable=$(bash "${vagrant_dir}/scripts/host/get_path_to_php.sh")
8+
9+
# Enable trace printing and exit on the first error
10+
set -ex
11+
12+
if [ ! -f ${magento_ee_dir}/app/etc/aliases_to_classes_map.json ]; then
13+
echo "EE codebase is not available"
14+
exit 0
15+
fi
16+
17+
if [ ! -f ${magento_ce_dir}/app/etc/aliases_to_classes_map.json ]; then
18+
echo "Already switched to CE"
19+
exit 0
20+
fi
21+
22+
${php_executable} -f ${magento_ee_dir}/dev/tools/build-ee.php -- --command=unlink --ee-source="${magento_ee_dir}" --ce-source="${magento_ce_dir}"
23+
24+
cd ${magento_ce_dir}
25+
git checkout composer.json
26+
git checkout composer.lock
27+
28+
if [[ ${host_os} == "Windows" || $(bash "${vagrant_dir}/scripts/get_config_value.sh" "guest_use_nfs") == 0 ]]; then
29+
# Prevent issues on Windows with incorrect symlinks to files
30+
if [ -f ${magento_ce_dir}/app/etc/aliases_to_classes_map.json ]; then
31+
rm ${magento_ce_dir}/app/etc/aliases_to_classes_map.json
32+
fi
33+
if [ -f ${magento_ce_dir}/app/etc/enterprise/di.xml ]; then
34+
rm ${magento_ce_dir}/app/etc/enterprise/di.xml
35+
fi
36+
fi
37+
38+
bash "${vagrant_dir}/m-clear-cache"
39+
bash "${vagrant_dir}/m-composer-install"
40+
bash "${vagrant_dir}/m-reinstall"

m-switch-to-ee

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env bash
2+
3+
vagrant_dir=$(cd "$(dirname "$0")"; pwd)
4+
magento_ce_dir="${vagrant_dir}/magento2ce"
5+
magento_ee_dir="${magento_ce_dir}/magento2ee"
6+
host_os=$(bash "${vagrant_dir}/scripts/host/get_host_os.sh")
7+
php_executable=$(bash "${vagrant_dir}/scripts/host/get_path_to_php.sh")
8+
9+
# Enable trace printing and exit on the first error
10+
set -ex
11+
12+
if [ ! -f ${magento_ee_dir}/app/etc/aliases_to_classes_map.json ]; then
13+
echo "EE codebase is not available"
14+
exit 0
15+
fi
16+
17+
if [ -f ${magento_ce_dir}/app/etc/aliases_to_classes_map.json ]; then
18+
echo "Already switched to EE"
19+
exit 0
20+
fi
21+
22+
${php_executable} -f ${magento_ee_dir}/dev/tools/build-ee.php -- --command=link --ee-source="${magento_ee_dir}" --ce-source="${magento_ce_dir}"
23+
24+
cp ${magento_ee_dir}/composer.json ${magento_ce_dir}/composer.json
25+
cp ${magento_ee_dir}/composer.lock ${magento_ce_dir}/composer.lock
26+
27+
if [[ ${host_os} == "Windows" || $(bash "${vagrant_dir}/scripts/get_config_value.sh" "guest_use_nfs") == 0 ]]; then
28+
# Prevent issues on Windows with incorrect symlinks to files
29+
if [ -f ${magento_ee_dir}/app/etc/aliases_to_classes_map.json ]; then
30+
rm ${magento_ce_dir}/app/etc/aliases_to_classes_map.json
31+
cp ${magento_ee_dir}/app/etc/aliases_to_classes_map.json ${magento_ce_dir}/app/etc/aliases_to_classes_map.json
32+
fi
33+
if [ -f ${magento_ee_dir}/app/etc/enterprise/di.xml ]; then
34+
rm ${magento_ce_dir}/app/etc/enterprise/di.xml
35+
cp ${magento_ee_dir}/app/etc/enterprise/di.xml ${magento_ce_dir}/app/etc/enterprise/di.xml
36+
fi
37+
fi
38+
39+
bash "${vagrant_dir}/m-clear-cache"
40+
bash "${vagrant_dir}/m-composer-install"
41+
bash "${vagrant_dir}/m-reinstall"

scripts/host/get_variable_value.sh renamed to scripts/get_config_value.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ parse_yaml() {
1717
}'
1818
}
1919

20-
vagrant_dir=$(cd "$(dirname "$0")/../.."; pwd)
20+
vagrant_dir=$(cd "$(dirname "$0")/.."; pwd)
2121
variable_name=$1
2222

2323
# Read configs
File renamed without changes.

0 commit comments

Comments
 (0)