Skip to content

Commit

Permalink
feat(upgrade): bump codebase to match sylius v[1.12|1.13|1.14]
Browse files Browse the repository at this point in the history
  • Loading branch information
maxperei committed Dec 31, 2024
1 parent 73c4266 commit 3fde601
Show file tree
Hide file tree
Showing 53 changed files with 313 additions and 301 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Analysis
'on':
push:
branches:
- master
- main
paths-ignore:
- README.md
pull_request:
Expand All @@ -16,11 +16,10 @@ jobs:
fail-fast: false
matrix:
php:
- 8.1
- 8.2
- 8.3
symfony:
- '5.4.*'
- '6.3.*'
- '6.4.*'
env:
APP_ENV: test
steps:
Expand Down
14 changes: 5 additions & 9 deletions .github/workflows/sylius.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Install & Test
'on':
push:
branches:
- master
- main
paths-ignore:
- README.md
pull_request:
Expand All @@ -16,20 +16,16 @@ jobs:
fail-fast: false
matrix:
php:
- 8.1
- 8.2
- 8.3
sylius:
- 1.10.0
- 1.12.0
- 1.13.0
- 1.14.0
symfony:
- 5.4
- 6.3
- 6.4
node:
- 14.x
exclude:
-
sylius: 1.10.0
symfony: 6.3
env:
APP_ENV: test
package-name: synolia/sylius-maintenance-plugin
Expand Down
22 changes: 12 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
SHELL=/bin/bash
COMPOSER_ROOT=composer
TEST_DIRECTORY=tests/Application
CONSOLE=cd tests/Application && php bin/console -e test
COMPOSER=cd tests/Application && composer
YARN=cd tests/Application && yarn
INSTALL_DIRECTORY=install/Application
CONSOLE=cd ${TEST_DIRECTORY} && php bin/console -e test
COMPOSER=cd ${TEST_DIRECTORY} && composer
YARN=cd ${TEST_DIRECTORY} && yarn

SYLIUS_VERSION=1.12.0
SYMFONY_VERSION=6.1
PHP_VERSION=8.1
SYLIUS_VERSION=1.14.0
SYMFONY_VERSION=6.4
PHP_VERSION=8.2
PLUGIN_NAME=synolia/sylius-maintenance-plugin

###
Expand All @@ -19,10 +20,10 @@ install: sylius ## Install Plugin on Sylius [SYLIUS_VERSION=1.12.0] [SYMFONY_VER
.PHONY: install

reset: ## Remove dependencies
ifneq ("$(wildcard tests/Application/bin/console)","")
ifneq ("$(wildcard ${TEST_DIRECTORY}/bin/console)","")
${CONSOLE} doctrine:database:drop --force --if-exists || true
endif
rm -rf tests/Application
rm -rf ${TEST_DIRECTORY}
.PHONY: reset

phpunit: phpunit-configure phpunit-run ## Run PHPUnit
Expand Down Expand Up @@ -59,7 +60,8 @@ install-plugin:
${COMPOSER} config minimum-stability "dev"
${COMPOSER} config prefer-stable true
${COMPOSER} req ${PLUGIN_NAME}:* --prefer-source --no-scripts
cp -r install/Application tests
cp -r ${INSTALL_DIRECTORY} tests
cp -r tests/data/* ${TEST_DIRECTORY}/

install-sylius:
${CONSOLE} sylius:install -n -s default
Expand All @@ -77,7 +79,7 @@ grumphp:
vendor/bin/grumphp run

help: SHELL=/bin/bash
help: ## Dislay this help
help: ## Display this help
@IFS=$$'\n'; for line in `grep -h -E '^[a-zA-Z_#-]+:?.*?##.*$$' $(MAKEFILE_LIST)`; do if [ "$${line:0:2}" = "##" ]; then \
echo $$line | awk 'BEGIN {FS = "## "}; {printf "\033[33m %s\033[0m\n", $$2}'; else \
echo $$line | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m%s\n", $$1, $$2}'; fi; \
Expand Down
58 changes: 27 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@

| | Version |
|:-------|:--------|
| PHP | ^8.0 |
| Sylius | ^1.10 |
| PHP | ^8.2 |
| Sylius | ^1.12 |

## Installation

Expand All @@ -40,22 +40,15 @@
composer require synolia/sylius-maintenance-plugin
```

2. Import required config in your `config/packages/_sylius.yaml` file:

``` yaml
imports:
- { resource: "@SynoliaSyliusMaintenancePlugin/Resources/config/config.yaml" }
```
3. Import routing in your `config/routes.yaml` file:
2. Import routing in your `config/routes.yaml` file:

``` yaml
synolia_maintenance:
resource: "@SynoliaSyliusMaintenancePlugin/Resources/config/admin_routing.yaml"
resource: "@SynoliaSyliusMaintenancePlugin/config/routes/attributes.yaml"
prefix: '/%sylius_admin.path_name%'
```

4. Clear cache
3. Clear cache

``` shell
php bin/console cache:clear
Expand All @@ -65,36 +58,36 @@

- To turn your website under maintenance, please create a file **maintenance.yaml** at the root of your project.
- If you want to allow access for some Ips, please add these Ip into **maintenance.yaml**
For example :
For example :

``` yaml
ips: [172.16.254.1, 255.255.255.255, 192.0.0.255]
```

### You can turn your website under maintenance by console commands :

1. Enable the plugin
1. Enable the plugin

``` shell
php bin/console maintenance:enable
```
2. Enable the plugin and add one or multiple ips addresses separated with a space
``` shell
php bin/console maintenance:enable
```
2. Enable the plugin and add one or multiple ips addresses separated with a space

``` shell
php bin/console maintenance:enable 172.16.254.1 255.255.255.255 192.0.0.255
```
3. Disable the plugin
``` shell
php bin/console maintenance:enable 172.16.254.1 255.255.255.255 192.0.0.255
```
3. Disable the plugin

``` shell
php bin/console maintenance:disable
```
``` shell
php bin/console maintenance:disable
```

4. Remove configuration file using CLI
4. Remove configuration file using CLI

By default, **maintenance.yaml** configuration file remains when running `maintenance:disable` or via admin panel using toggle disable
Nevertheless passing option `[-c|--clear]` to command line above will reset previous saved configuration
By default, **maintenance.yaml** configuration file remains when running `maintenance:disable` or via admin panel using toggle disable
Nevertheless passing option `[-c|--clear]` to command line above will reset previous saved configuration

### You can also turn your website under maintenance in Back Office :
### You can also turn your website under maintenance in Back Office :

- Enable/disable the plugin
- Allow access for one or multiple ips addresses (optional)
Expand All @@ -103,19 +96,22 @@
- Grant access to search bots during maintenance (optional)

### If you want to put the **maintenance.yaml** in a directory, please add your directory in .env:

For example :

``` yaml
SYNOLIA_MAINTENANCE_DIR=var/maintenance
```
```

### If you want to add cache on the **maintenance.yaml**:

``` yaml
# .env
SYNOLIA_MAINTENANCE_CACHE=30 # ttl in seconds
```
And in project code (for exemple with redis)

And in project code (for example with redis)

``` yaml
# config/packages/prod/cache.yaml
framework:
Expand Down
47 changes: 24 additions & 23 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,40 +9,41 @@
],
"license": "EUPL-1.2",
"require": {
"php": "^8.0",
"php": "^8.2",
"jaybizzle/crawler-detect": "^1.2",
"sylius/sylius": "^1.10",
"sylius/sylius": "^1.12",
"webmozart/assert": "^1.11"
},
"require-dev": {
"dbrekelmans/bdi": "1.0",
"friendsoftwig/twigcs": "6.1.0",
"phpmd/phpmd": "2.13.0",
"phpro/grumphp": "1.15.0",
"phpspec/phpspec": "7.3.0",
"phpstan/extension-installer": "1.2.0",
"phpstan/phpstan": "1.9.7",
"phpstan/phpstan-doctrine": "1.3.29",
"phpstan/phpstan-phpunit": "1.3.3",
"phpstan/phpstan-strict-rules": "1.4.4",
"phpstan/phpstan-webmozart-assert": "1.2.2",
"phpunit/phpunit": "9.5.27",
"rector/rector": "^0.15.2",
"sylius-labs/coding-standard": "4.3.0",
"symfony/browser-kit": "6.0.11",
"symfony/debug-bundle": "6.0.11",
"symfony/dotenv": "6.0.5",
"symfony/intl": "6.0.15",
"symfony/panther": "2.0.1",
"symfony/web-profiler-bundle": "6.0.17"
"dbrekelmans/bdi": "^1.0",
"friendsoftwig/twigcs": "^6.4.0",
"php-parallel-lint/php-parallel-lint": "^1.4",
"phpmd/phpmd": "^2.13",
"phpro/grumphp": "^2.0",
"phpstan/extension-installer": "^1.3",
"phpstan/phpstan": "^2.0",
"phpstan/phpstan-strict-rules": "^2.0",
"phpstan/phpstan-webmozart-assert": "^2.0",
"phpunit/phpunit": "^9.5",
"povils/phpmnd": "^3.0",
"rector/rector": "^2.0",
"squizlabs/php_codesniffer": "^3.11",
"sylius-labs/coding-standard": "^4.3",
"symfony/browser-kit": "^6.4",
"symfony/debug-bundle": "^6.4",
"symfony/dotenv": "^6.4",
"symfony/intl": "^6.4",
"symfony/panther": "^2.0",
"symfony/web-profiler-bundle": "^6.4"
},
"config": {
"sort-packages": true,
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true,
"symfony/thanks": true,
"phpro/grumphp": true,
"phpstan/extension-installer": true
"phpstan/extension-installer": true,
"php-http/discovery": true
}
},
"autoload": {
Expand Down
5 changes: 5 additions & 0 deletions config/routes/attributes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
controllers:
resource:
path: ../../src/Controller/
namespace: Synolia\SyliusMaintenancePlugin\Controller
type: attribute
14 changes: 14 additions & 0 deletions config/services.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
parameters:
env(SYNOLIA_MAINTENANCE_DIR): ''
synolia_maintenance_dir: '%env(resolve:SYNOLIA_MAINTENANCE_DIR)%'
env(SYNOLIA_MAINTENANCE_CACHE): 0
synolia_maintenance_cache: '%env(resolve:int:SYNOLIA_MAINTENANCE_CACHE)%'

services:
_defaults:
autowire: true
autoconfigure: true

Synolia\SyliusMaintenancePlugin\:
resource: '../src/*'
exclude: '../src/{SynoliaSyliusMaintenancePlugin.php}'
20 changes: 13 additions & 7 deletions grumphp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,31 @@ grumphp:
tasks:
composer:
no_check_all: true
git_blacklist:
keywords:
- 'var_dump'
- 'print_r'
- 'die\('
- 'console\.'
triggered_by: [php, twig, js]
jsonlint:
detect_key_conflicts: true
phplint:
exclude: ['vendor', 'tests/Application/*']
triggered_by: ['php']
phpmd:
ruleset: ['ruleset/.php_md.xml']
phpstan:
level: ~
configuration: 'ruleset/phpstan.neon'
use_grumphp_paths: false
yamllint:
parse_custom_tags: true
ecs:
config: 'ruleset/ecs.php'
no-progress-bar: true
phpmnd:
directory: src
twigcs:
path: 'src/'
severity: error
phpcs:
standard: "ruleset"
warning_severity: 0
whitelist_patterns:
- 'src'
exclude:
- 'PSR12.Files.FileHeader'
2 changes: 0 additions & 2 deletions install/Application/config/packages/maintenance.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion install/Application/config/routes/maintenance.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
synolia_maintenance:
resource: "@SynoliaSyliusMaintenancePlugin/Resources/config/admin_routing.yaml"
resource: "@SynoliaSyliusMaintenancePlugin/config/routes/attributes.yaml"
prefix: '/%sylius_admin.path_name%'
2 changes: 1 addition & 1 deletion ruleset/.php_md.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</rule>

<rule ref="rulesets/controversial.xml"/>
<!-- <rule ref="rulesets/unusedcode.xml"/>-->
<rule ref="rulesets/unusedcode.xml"/>

<rule ref="rulesets/naming.xml">
<exclude name="ShortVariable"/>
Expand Down
Loading

0 comments on commit 3fde601

Please sign in to comment.