Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add php scoper #249

Merged
merged 62 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
3464bee
feat: add php-scoper conf and make command
fox-john Feb 15, 2024
b6c4873
fix: edit some namespace for install
fox-john Feb 16, 2024
90e162f
fix: change global namespace for all occurence of prestashop with regex
fox-john Feb 16, 2024
16d8163
fix: change config of php-scoper
fox-john Feb 19, 2024
7dde35c
fix: add complete namespace for prestashop classes
fox-john Feb 19, 2024
b4e891c
chore: remove ps-account-installer and guzzle-adapter
fox-john Feb 20, 2024
2f5efb7
chore: save work
fox-john Feb 20, 2024
9631942
chore: update use
fox-john Feb 20, 2024
6e05e16
feat: add account service
fox-john Feb 21, 2024
4b27136
fix: error with service contrainer
fox-john Feb 21, 2024
cbea01b
fix: rework api and guzzle integration and add fix for php-scoper
fox-john Feb 22, 2024
10585bf
fix: refactor all use
fox-john Feb 22, 2024
bf185f4
fix: api's
fox-john Feb 22, 2024
a29486c
fix: api post
fox-john Feb 22, 2024
17bc55a
feat: update makefile
fox-john Feb 22, 2024
be60d8f
fix: presenter services
fox-john Feb 22, 2024
ad269e8
Merge branch 'main' into feature/add-php-scoper
fox-john Feb 22, 2024
fcb4162
fix: lint
fox-john Feb 22, 2024
fa8d61a
Merge branch 'feature/add-php-scoper' of https://github.com/PrestaSho…
fox-john Feb 22, 2024
50cd596
fix: some imports
fox-john Feb 23, 2024
5ee991c
fix: naming of ps-account-adapter
fox-john Feb 23, 2024
9ea6075
fix: implementation of psAccountsService
fox-john Feb 23, 2024
1d1eada
fix: rework module manager and account adapter
fox-john Feb 23, 2024
df63af4
feat: finish accounts adapter and add patcher for raven client
fox-john Feb 23, 2024
317e391
fix: php-cs-fixer
fox-john Feb 23, 2024
f23c98a
fix: accounts adapter doc
fox-john Feb 23, 2024
b21a521
fix: phpstan common problems
fox-john Feb 27, 2024
19c9ce0
Merge branch 'main' into feature/add-php-scoper
fox-john Feb 27, 2024
40f8eda
fix: php-cs-fixer
fox-john Feb 27, 2024
7f070ca
Merge branch 'feature/add-php-scoper' of https://github.com/PrestaSho…
fox-john Feb 27, 2024
6ad17dc
fix: phpstan for 8.0.2
fox-john Feb 27, 2024
b035594
fix: php-cs-fixer
fox-john Feb 27, 2024
af44f74
fix: phpstan
fox-john Feb 27, 2024
a707e2b
fix: php-cs-fixer
fox-john Feb 27, 2024
f8534cc
fix: phpstan
fox-john Feb 27, 2024
a079208
fix: phpstan
fox-john Feb 27, 2024
043a876
fix: php-cs-fixer
fox-john Feb 27, 2024
c614661
fix: phpstan
fox-john Feb 27, 2024
c5d366c
fix: makefile
fox-john Feb 27, 2024
a43b5e7
fix php-cs-fixer
fox-john Feb 27, 2024
e2ebee6
fix: error on install
fox-john Feb 29, 2024
5b16fac
Merge branch 'main' into feature/add-php-scoper
fox-john Mar 4, 2024
dea3d64
Merge branch 'main' into feature/add-php-scoper
fox-john Mar 20, 2024
a751358
Merge branch 'feature/add-php-scoper' of https://github.com/PrestaSho…
fox-john Mar 20, 2024
2fd429e
fix: update php-scoper config to match with ps-metrics config
fox-john Mar 20, 2024
741e335
fix: stay \Ps_Eventbus type
fox-john Mar 20, 2024
2753d9a
fix: exclude front controller for namespacing
fox-john Mar 20, 2024
21eabc1
Merge branch 'main' into feature/add-php-scoper
fox-john Mar 20, 2024
2254833
fix: revert remove of guzzle-adapter
fox-john Mar 20, 2024
70501c9
fix: phpcs
fox-john Mar 20, 2024
87c713c
fix: composer.lock
fox-john Mar 20, 2024
38df37c
fix: context error
fox-john Mar 20, 2024
2def7dd
fix: another context error
fox-john Mar 20, 2024
ba0fcee
Merge branch 'main' into feature/add-php-scoper
fox-john Mar 21, 2024
d8e4e2f
Merge branch 'main' into feature/add-php-scoper
fox-john Mar 21, 2024
7357fb2
Merge branch 'main' into feature/add-php-scoper
fox-john Mar 27, 2024
336d24a
fix: phpstan & php-cs-fixer
fox-john Mar 27, 2024
8c77a61
fix: php-cs-fixer
fox-john Mar 27, 2024
93d0498
fix: problem after group testing
fox-john Mar 28, 2024
8cb682d
Merge branch 'main' into feature/add-php-scoper
fox-john Mar 28, 2024
cd8a848
fix: update scoper config
fox-john Mar 29, 2024
4829d7b
fix: try to fix problem
fox-john Mar 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/quality-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
path: vendor
key: php-${{ hashFiles('composer.lock') }}
- name: PHPStan PrestaShop ${{ matrix.ps_version }}
run: PS_VERSION="${{ matrix.ps_version }}" make phpstan
run: PS_VERSION="${{ matrix.ps_version }}" make docker-phpstan

phpunit:
name: PHP Unit
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ composer.phar
.php_cs
install.lock
composer-setup.php
php-scoper.phar

# Mac OS
.DS_Store
Expand Down
2 changes: 2 additions & 0 deletions .zip-contents
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ logo.png
config.xml
LICENCE
README.md
composer.json
jokesterfr marked this conversation as resolved.
Show resolved Hide resolved
composer.lock
89 changes: 57 additions & 32 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,52 @@ MODULE_NAME = ps_eventbus
PACKAGE ?= ${MODULE_NAME}-${VERSION}
PHP_VERSION ?= 8.1
PS_VERSION ?= 8.1.3
TESTING_IMAGE ?= prestashop/prestashop-flashlight:${PS_VERSION}-${PHP_VERSION}
TESTING_IMAGE ?= prestashop/prestashop-flashlight:${PS_VERSION}
PS_ROOT_DIR ?= $(shell pwd)/prestashop/prestashop-${PS_VERSION}
PHP_SCOPER_DIR=php-scoper
export PATH := ./vendor/bin:./tools/vendor/bin:$(PATH)

define replace_version
sed -i.bak -e "s/\(VERSION = \).*/\1\'${2}\';/" ${1}/${MODULE_NAME}.php
sed -i.bak -e "s/\($this->version = \).*/\1\'${2}\';/" ${1}/${MODULE_NAME}.php
sed -i.bak -e "s|\(<version><!\[CDATA\[\)[0-9a-z.-]\{1,\}]]></version>|\1${2}]]></version>|" ${1}/config.xml
rm -f ${1}/${MODULE_NAME}.php.bak ${1}/config.xml.bak
sed -i.bak -e "s/\(VERSION = \).*/\1\'${2}\';/" ${1}/${MODULE_NAME}.php
sed -i.bak -e "s/\($this->version = \).*/\1\'${2}\';/" ${1}/${MODULE_NAME}.php
sed -i.bak -e "s|\(<version><!\[CDATA\[\)[0-9a-z.-]\{1,\}]]></version>|\1${2}]]></version>|" ${1}/config.xml
rm -f ${1}/${MODULE_NAME}.php.bak ${1}/config.xml.bak
endef

define create_module
$(eval TMP_DIR := $(shell mktemp -d))
mkdir -p ${TMP_DIR}/tmp;
cp -r $(shell cat .zip-contents) ${TMP_DIR}/tmp;
VERSION=${PACKAGE} TMP_FOLDER=${TMP_DIR}/tmp php php-scoper.phar add-prefix --output-dir=${TMP_DIR}/${MODULE_NAME} --force
$(call replace_version,${TMP_DIR}/${MODULE_NAME},${SEM_VERSION})
./tools/vendor/bin/autoindex prestashop:add:index ${TMP_DIR}
cp $1 ${TMP_DIR}/${MODULE_NAME}/config/parameters.yml
cd ${TMP_DIR}/${MODULE_NAME} && composer dump-autoload
SCOPER_FOLDER=${TMP_DIR}/${MODULE_NAME} php php-scoper-fix.php

echo ${TMP_DIR}
endef

define zip_it
$(eval TMP_DIR := $(shell mktemp -d))
mkdir -p ${TMP_DIR}/${MODULE_NAME};
cp -r $(shell cat .zip-contents) ${TMP_DIR}/${MODULE_NAME};
$(call replace_version,${TMP_DIR}/${MODULE_NAME},${SEM_VERSION})
./tools/vendor/bin/autoindex prestashop:add:index ${TMP_DIR}
cp $1 ${TMP_DIR}/${MODULE_NAME}/config/parameters.yml;
cd ${TMP_DIR} && zip -9 -r $2 ./${MODULE_NAME};
mv ${TMP_DIR}/$2 ./dist;
rm -rf ${TMP_DIR:-/dev/null};
TMP_DIR=$(call create_module,$1)
cd ${TMP_DIR} && zip -9 -r $2 ./${MODULE_NAME};
mv ${TMP_DIR}/$2 ./dist;
rm -rf ${TMP_DIR:-/dev/null};
endef

define no_zip_it
rm -rf ./dist/${MODULE_NAME}
TMP_DIR=$(call create_module,$1)
mv ${TMP_DIR}/${MODULE_NAME} ./dist;
rm -rf ${TMP_DIR:-/dev/null};
endef

define in_docker
docker run \
--env _PS_ROOT_DIR_=/var/www/html \
--workdir /var/www/html/modules/${MODULE_NAME} \
--volume $(shell pwd):/var/www/html/modules/${MODULE_NAME}:rw \
--entrypoint $1 ${TESTING_IMAGE} $2
docker run \
--env _PS_ROOT_DIR_=/var/www/html \
--workdir /var/www/html/modules/${MODULE_NAME} \
--volume $(shell pwd):/var/www/html/modules/${MODULE_NAME}:rw \
--entrypoint $1 ${TESTING_IMAGE} $2
endef

# target: default - Calling build by default
Expand All @@ -45,8 +62,8 @@ default: build
help:
@egrep "^#" Makefile

# target: clean
.PHONY: clean - Clean up the repository
# target: clean - Clean up the repository
.PHONY: clean
clean:
git -c core.excludesfile=/dev/null clean -X -d -f

Expand All @@ -63,19 +80,24 @@ dist:

# target: zip-e2e - Bundle a local E2E integrable zip
.PHONY: zip-e2e
zip-e2e: vendor tools/vendor dist
zip-e2e: php-scoper.phar vendor tools/vendor dist
@$(call zip_it,./config/parameters.yml,${PACKAGE}_e2e.zip)

# target: zip-inte - Bundle an integration zip
.PHONY: zip-inte
zip-inte: vendor tools/vendor dist
zip-inte: php-scoper.phar vendor tools/vendor dist
@$(call zip_it,.config.inte.yml,${PACKAGE}_integration.zip)

# target: zip-prod - Bundle a production zip
.PHONY: zip-prod
zip-prod: vendor tools/vendor dist
zip-prod: php-scoper.phar vendor tools/vendor dist
@$(call zip_it,.config.prod.yml,${PACKAGE}.zip)

# target: zip-unzipped - Bundle a production module, but without zip step (only to check sources)
.PHONY: zip-unzipped
zip-unzipped: php-scoper.phar vendor tools/vendor dist
@$(call no_zip_it,.config.prod.yml)

# target: build - Setup PHP & Node.js locally
.PHONY: build
build: vendor tools/vendor
Expand Down Expand Up @@ -181,14 +203,17 @@ phpstan-baseline: prestashop/prestashop-${PS_VERSION} phpstan
.PHONY: docker-test
docker-test: docker-lint docker-phpstan docker-phpunit

php-scoper.phar:
@php -r "copy('https://github.com/humbug/php-scoper/releases/latest/download/php-scoper.phar', 'php-scoper.phar');";

define COMMENT
Fixme: add "allure-framework/allure-phpunit" in composer.json to solve this.
Currently failing to resolve devDeps:
- allure-framework/allure-phpunit v2.1.0 requires phpunit/phpunit ^9 -> found phpunit/phpunit[9.0.0, ..., 9.6.4] but it conflicts with your root composer.json require (^10.0.14).
allure:
./node_modules/.bin/allure serve build/allure-results/

allure-report:
./node_modules/.bin/allure generate build/allure-results/
Fixme: add "allure-framework/allure-phpunit" in composer.json to solve this.
Currently failing to resolve devDeps:
- allure-framework/allure-phpunit v2.1.0 requires phpunit/phpunit ^9 -> found phpunit/phpunit[9.0.0, ..., 9.6.4] but it conflicts with your root composer.json require (^10.0.14).
allure:
./node_modules/.bin/allure serve build/allure-results/

allure-report:
./node_modules/.bin/allure generate build/allure-results/
endef

5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,13 @@
"ext-json": "*",
"monolog/monolog": "^1.27",
"prestashop/module-lib-service-container": "^2.0",
"prestashop/module-lib-guzzle-adapter": "v0.6",
"prestashop/prestashop-accounts-installer": "^1.0.0",
"sentry/sentry": "^1.11.0",
"php-http/message": "<1.15.0",
"psr/http-message": "<1.1",
"symfony/config": "^3.4",
"symfony/dependency-injection": "^3.4",
"symfony/yaml": "^3.4",
"prestashop/module-lib-mbo-installer": "^0.1.0"
"prestashop/module-lib-mbo-installer": "^0.1.0",
"guzzlehttp/guzzle": "^6.5"
}
}
Loading
Loading