96 lines
3.5 KiB
Makefile
Raw Normal View History

2020-03-03 17:50:26 +03:00
ROOT_DIR=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
PRESTASHOP_DIR=$(ROOT_DIR)/../PrestaShop
2021-01-21 14:39:32 +03:00
FILE = $(ROOT_DIR)/VERSION
2018-05-28 17:09:31 +03:00
VERSION = `cat $(FILE)`
2018-06-14 13:15:12 +03:00
ARCHIVE_NAME = '/tmp/retailcrm-'$(VERSION)'.zip'
2018-05-28 17:09:31 +03:00
2020-03-05 10:41:50 +03:00
.PHONY: build_archive delete_archive
2018-05-28 17:09:31 +03:00
build_archive:
zip -r $(ARCHIVE_NAME) ./retailcrm/*
2018-10-05 17:50:20 +03:00
zip -r /tmp/retailcrm.zip ./retailcrm/*
2018-05-28 17:09:31 +03:00
delete_archive:
rm -f $(ARCHIVE_NAME)
2018-10-05 17:50:20 +03:00
rm -f /tmp/retailcrm.zip
2020-03-03 17:50:26 +03:00
composer: clone_prestashop clone_composer fix-version-lang-bugs
2021-01-21 14:39:32 +03:00
ifeq ($(COMPOSERV1),1)
2022-09-30 11:48:25 +03:00
cd $(PRESTASHOP_DIR) && php composer.phar install --prefer-dist --no-interaction --no-progress
2020-03-03 17:50:26 +03:00
else
2021-01-21 14:39:32 +03:00
cd $(PRESTASHOP_DIR)/tests && composer install
2020-03-03 17:50:26 +03:00
endif
clone_prestashop:
2020-03-04 17:01:50 +03:00
cd $(ROOT_DIR)/../ && git clone https://github.com/PrestaShop/PrestaShop
2022-09-30 11:48:25 +03:00
cd $(PRESTASHOP_DIR) && git checkout $(BRANCH)
clone_composer:
ifeq ($(COMPOSERV1),1)
cd $(PRESTASHOP_DIR) \
&& php -r "copy('https://getcomposer.org/download/1.10.17/composer.phar', 'composer.phar');"
endif
2020-03-03 17:50:26 +03:00
2020-03-04 23:30:02 +03:00
before_script: composer
2022-09-30 11:48:25 +03:00
ifneq ("$(wildcard $(PRESTASHOP_DIR)/travis-scripts/install-prestashop)","")
ifeq ($(COMPOSERV1),1)
cd $(PRESTASHOP_DIR) \
&& sed -i 's/mysql -u root/mysql -u root --port $(MYSQL_PORT)/g' travis-scripts/install-prestashop \
&& sed -i 's/--db_server=127.0.0.1 --db_name=prestashop/--db_server=127.0.0.1:$(MYSQL_PORT) --db_name=prestashop --db_user=root/g' travis-scripts/install-prestashop \
&& bash travis-scripts/install-prestashop
else
cd $(PRESTASHOP_DIR) \
&& sed -i 's/mysql -u root/mysql -u root -proot --port $(MYSQL_PORT)/g' travis-scripts/install-prestashop.sh \
&& sed -i 's/--db_server=127.0.0.1 --db_name=prestashop/--db_server=127.0.0.1:$(MYSQL_PORT) --db_name=prestashop --db_user=root/g' travis-scripts/install-prestashop.sh \
&& bash travis-scripts/install-prestashop.sh
endif
else
rm -rf var/cache/*
echo "* Installing PrestaShop, this may take a while ...";
ifeq ($(LOCAL_TEST),1)
cd $(PRESTASHOP_DIR) && php install-dev/index_cli.php --db_server=db --db_user=root --db_create=1
else
mkdir coverage
cd $(PRESTASHOP_DIR) && php install-dev/index_cli.php --db_server=127.0.0.1:$(MYSQL_PORT) --db_user=root --db_create=1
endif
2022-09-30 11:48:25 +03:00
endif
# Required for versions 1.7.7.x
fix-version-lang-bugs:
2021-01-21 14:39:32 +03:00
ifeq ($(COMPOSERV1),1)
2021-04-05 13:40:43 +03:00
cd $(PRESTASHOP_DIR) \
2022-09-30 11:48:25 +03:00
&& sed -i 's/throw new Exception/#throw new Exception/g' src/PrestaShopBundle/Install/DatabaseDump.php
endif
2022-09-30 11:48:25 +03:00
cd $(PRESTASHOP_DIR) \
&& sed -i "s/SymfonyContainer::getInstance()->get('translator')/\\\\Context::getContext()->getTranslator()/g" classes/lang/DataLang.php
cat $(PRESTASHOP_DIR)/classes/lang/DataLang.php | grep -A 3 -B 3 'this->translator = '
2021-04-05 13:40:43 +03:00
cd $(PRESTASHOP_DIR) \
2022-09-30 11:48:25 +03:00
&& sed -i "s/SymfonyContainer::getInstance()->get('translator')/\\\\Context::getContext()->getTranslator()/g" classes/Language.php
cat $(PRESTASHOP_DIR)/classes/Language.php | grep -A 3 -B 3 'translator = '
2020-03-03 17:50:26 +03:00
2021-11-03 16:19:39 +07:00
lint:
php-cs-fixer fix --config=$(ROOT_DIR)/.php-cs-fixer.php -v
2022-09-09 12:47:47 +03:00
lint-docker:
docker run --rm -it -w=/app -v ${PWD}:/app oskarstark/php-cs-fixer-ga:latest --config=.php-cs-fixer.php -v
2021-11-03 16:19:39 +07:00
2022-09-30 11:48:25 +03:00
# todo moveto version
2020-03-03 17:50:26 +03:00
test:
2021-01-21 14:39:32 +03:00
ifeq ($(COMPOSERV1),1)
2022-09-30 11:48:25 +03:00
cd $(PRESTASHOP_DIR) && php composer.phar run-script create-test-db --timeout=0
2020-03-04 17:01:50 +03:00
cd $(PRESTASHOP_DIR) && php vendor/bin/phpunit -c $(ROOT_DIR)/phpunit.xml.dist
2021-01-21 14:39:32 +03:00
else
phpunit -c phpunit.xml.dist
endif
coverage:
wget https://phar.phpunit.de/phpcov-2.0.2.phar && php phpcov-2.0.2.phar merge coverage/ --clover coverage.xml
run_local_tests:
docker-compose up -d --build
docker exec app_test make before_script test
docker-compose down