From ac7f413c1578adbbc85dc096abf8d050fe12ba84 Mon Sep 17 00:00:00 2001 From: Maxime Huran Date: Wed, 4 Sep 2024 15:33:12 +0200 Subject: [PATCH 1/4] Add Sylius 1.13 compatibility --- .github/workflows/recipe.yaml | 35 +++++------ .github/workflows/security.yaml | 13 ++-- .github/workflows/tests.yaml | 27 ++++----- .php-cs-fixer.dist.php | 29 +++++---- Makefile | 24 ++++---- README.md | 20 ++++++- composer.json | 59 +++++-------------- dist/.env.local | 1 + dist/src/Entity/Customer/Customer.php | 2 + phpstan.neon | 18 +++--- recipes/1.0-dev | 1 - .../monsieurbiz_sylius_anti_spam_plugin.yaml | 7 --- .../monsieurbiz_sylius_anti_spam_plugin.yaml | 3 - recipes/dev/manifest.json | 10 ---- 14 files changed, 102 insertions(+), 147 deletions(-) create mode 100644 dist/.env.local delete mode 120000 recipes/1.0-dev delete mode 100644 recipes/dev/config/packages/monsieurbiz_sylius_anti_spam_plugin.yaml delete mode 100644 recipes/dev/config/routes/monsieurbiz_sylius_anti_spam_plugin.yaml delete mode 100644 recipes/dev/manifest.json diff --git a/.github/workflows/recipe.yaml b/.github/workflows/recipe.yaml index b290186..2ab8bac 100644 --- a/.github/workflows/recipe.yaml +++ b/.github/workflows/recipe.yaml @@ -9,24 +9,20 @@ jobs: recipe: - name: Flex recipe (PHP ${{ matrix.php }}, Sylius ${{ matrix.sylius }}) - runs-on: ubuntu-latest strategy: fail-fast: false matrix: - php: ['7.4' ,'8.0', '8.1'] - sylius: [ "~1.9.0", "~1.10.0", "~1.11.0", "~1.12.0"] + php: ['8.0', '8.1', '8.2'] + sylius: ["~1.11.0", "~1.12.0", "~1.13.0"] exclude: - - php: 8.1 - sylius: "~1.9.0" - - php: 8.0 - sylius: "~1.9.0" - - php: 7.4 - sylius: "~1.11.0" - - php: 7.4 - sylius: "~1.12.0" + - php: '8.2' + sylius: '~1.11.0' + - php: '8.0' + sylius: '~1.12.0' + - php: '8.0' + sylius: '~1.13.0' steps: - name: Setup PHP @@ -35,6 +31,7 @@ jobs: php-version: ${{ matrix.php }} extensions: gd, intl, json ini-values: date.timezone=UTC + tools: symfony-cli - name: Set project php-version run: | @@ -76,13 +73,13 @@ jobs: - name: Setup some requirements working-directory: ./sylius run: | - composer config --no-plugins allow-plugins true - composer config --no-plugins extra.symfony.allow-contrib true - composer config --no-plugins secure-http false - composer config --no-plugins --unset platform.php - composer config --no-plugins extra.symfony.docker false - composer config --no-plugins --json extra.symfony.endpoint '["https://api.github.com/repos/monsieurbiz/symfony-recipes/contents/index.json?ref=flex/master","flex://defaults"]' - composer config repositories.plugin '{"type": "path", "url": "../plugin/"}' + composer config --no-plugins allow-plugins true + composer config --no-plugins extra.symfony.allow-contrib true + composer config --no-plugins secure-http false + composer config --no-plugins --unset platform.php + composer config --no-plugins extra.symfony.docker false + composer config --no-plugins --json extra.symfony.endpoint '["https://api.github.com/repos/monsieurbiz/symfony-recipes/contents/index.json?ref=flex/master","flex://defaults"]' + composer config repositories.plugin '{"type": "path", "url": "../plugin/"}' - name: Require plugin & install all dependencies working-directory: ./sylius diff --git a/.github/workflows/security.yaml b/.github/workflows/security.yaml index 4e12805..c100cfa 100644 --- a/.github/workflows/security.yaml +++ b/.github/workflows/security.yaml @@ -8,14 +8,12 @@ jobs: security: - name: Security check (PHP ${{ matrix.php }}) - runs-on: ubuntu-latest strategy: fail-fast: false matrix: - php: ['7.4', '8.0', '8.1'] + php: ['8.1', '8.2'] steps: - uses: actions/checkout@v3 @@ -23,12 +21,12 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: ${{ matrix.php }} - ini-values: date.timezone=UTC + php-version: ${{ matrix.php }} + extensions: gd, intl, json - name: Set project php-version run: | - echo ${{ matrix.php }} > .php-version + echo "${{ matrix.php }}" > .php-version - name: Determine composer cache directory id: composer-cache-directory @@ -39,7 +37,7 @@ jobs: id: cache-composer with: path: ${{ steps.composer-cache-directory.outputs.directory }} - key: composer2-php:${{ matrix.php }}-${{ hashFiles('**/composer.json') }} + key: composer2-php:${{ matrix.php }}-${{ github.sha }} restore-keys: composer2-php:${{ matrix.php }}- - name: Ensure that composer cache directory exists @@ -52,3 +50,4 @@ jobs: run: composer update --prefer-dist - uses: symfonycorp/security-checker-action@v4 + diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 3e9a55e..877ce6a 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -9,14 +9,12 @@ jobs: php: - name: Quality tests (PHP ${{ matrix.php }}) - runs-on: ubuntu-latest strategy: fail-fast: false matrix: - php: ['8.0', '8.1'] + php: ['8.1', '8.2'] env: SYMFONY_ARGS: --no-tls @@ -24,26 +22,21 @@ jobs: DOCKER_INTERACTIVE_ARGS: -t steps: - - uses: actions/checkout@v3 - - - uses: actions/setup-node@v3 + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 with: - node-version: '16' - + node-version: '14' - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: ${{ matrix.php }} - ini-values: date.timezone=UTC + php-version: ${{ matrix.php }} + extensions: gd, intl, json + ini-values: date.timezone=UTC + tools: symfony-cli - name: Set project php-version run: | - echo ${{ matrix.php }} > .php-version - - - name: Install symfony CLI - run: | - curl -1sLf 'https://dl.cloudsmith.io/public/symfony/stable/setup.deb.sh' | sudo -E bash - sudo apt install symfony-cli + echo "${{ matrix.php }}" > .php-version - name: Determine composer cache directory id: composer-cache-directory @@ -54,7 +47,7 @@ jobs: id: cache-composer with: path: ${{ steps.composer-cache-directory.outputs.directory }} - key: composer2-php:${{ matrix.php }}-${{ hashFiles('**/composer.json') }} + key: composer2-php:${{ matrix.php }}-${{ github.sha }} restore-keys: composer2-php:${{ matrix.php }}- - name: Ensure that composer cache directory exists diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 587f54d..230fb7b 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -49,10 +49,8 @@ 'binary_operator_spaces' => true, 'blank_line_after_opening_tag' => true, 'blank_line_after_namespace' => true, + 'blank_lines_before_namespace' => true, 'blank_line_before_statement' => true, - 'braces' => [ - 'allow_single_line_closure' => true, - ], 'cast_spaces' => true, 'class_attributes_separation' => true, 'class_definition' => [ @@ -62,7 +60,7 @@ 'combine_consecutive_issets' => true, 'combine_consecutive_unsets' => true, 'comment_to_phpdoc' => true, - 'compact_nullable_typehint' => true, + 'compact_nullable_type_declaration' => true, 'concat_space' => [ 'spacing' => 'one', ], @@ -88,8 +86,12 @@ 'fully_qualified_strict_types' => true, 'function_declaration' => true, 'function_to_constant' => true, - 'function_typehint_space' => true, 'general_phpdoc_tag_rename' => true, + 'global_namespace_import' => [ + 'import_classes' => true, + 'import_constants' => false, + 'import_functions' => false, + ], 'header_comment' => [ 'header' => $header, 'location' => 'after_open', @@ -110,6 +112,7 @@ 'lowercase_static_reference' => true, 'magic_constant_casing' => true, 'method_argument_space' => true, + 'modernize_strpos' => false, 'modernize_types_casting' => true, 'multiline_comment_opening_closing' => true, 'multiline_whitespace_before_semicolons' => [ @@ -117,7 +120,7 @@ ], 'native_constant_invocation' => true, 'native_function_casing' => true, - 'new_with_braces' => true, + 'new_with_parentheses' => true, 'no_alias_functions' => true, 'no_alternative_syntax' => true, 'no_blank_lines_after_class_opening' => true, @@ -156,27 +159,27 @@ 'no_short_bool_cast' => true, 'no_spaces_after_function_name' => true, 'no_spaces_around_offset' => true, - 'no_spaces_inside_parenthesis' => true, + 'spaces_inside_parentheses' => true, 'no_superfluous_elseif' => true, 'no_superfluous_phpdoc_tags' => [ 'allow_mixed' => true, ], 'no_unset_cast' => true, 'no_unneeded_control_parentheses' => true, - 'no_unneeded_curly_braces' => true, + 'no_unneeded_braces' => true, 'no_unneeded_final_method' => true, 'no_unset_on_property' => true, 'no_unused_imports' => true, 'no_useless_else' => true, 'no_useless_return' => true, - 'no_trailing_comma_in_list_call' => true, - 'no_trailing_comma_in_singleline_array' => true, + 'no_trailing_comma_in_singleline' => true, 'no_trailing_whitespace' => true, 'no_trailing_whitespace_in_comment' => true, 'no_whitespace_before_comma_in_array' => true, 'no_whitespace_in_blank_line' => true, 'non_printable_character' => true, 'normalize_index_brace' => true, + 'nullable_type_declaration_for_default_null_value' => false, 'object_operator_without_whitespace' => true, 'ordered_imports' => [ 'imports_order' => [ @@ -211,7 +214,9 @@ 'phpdoc_order' => true, 'phpdoc_return_self_reference' => true, 'phpdoc_scalar' => true, - 'phpdoc_separation' => true, + 'phpdoc_separation' => ['groups' => [ + ['ORM\\*'], ['Assert\\*'], + ]], 'phpdoc_single_line_var_spacing' => true, 'phpdoc_tag_type' => true, 'phpdoc_to_comment' => false, @@ -231,7 +236,6 @@ 'self_accessor' => true, 'short_scalar_cast' => true, 'single_blank_line_at_eof' => true, - 'single_blank_line_before_namespace' => true, 'single_class_element_per_statement' => true, 'single_import_per_statement' => true, 'single_line_after_imports' => true, @@ -248,6 +252,7 @@ 'elements' => ['arrays'], ], 'trim_array_spaces' => true, + 'type_declaration_spaces' => true, 'unary_operator_spaces' => true, 'visibility_required' => [ 'elements' => [ diff --git a/Makefile b/Makefile index aae578a..264521c 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,16 @@ .DEFAULT_GOAL := help SHELL=/bin/bash APP_DIR=tests/Application -SYLIUS_VERSION=1.12.0 +SYLIUS_VERSION=1.13.0 SYMFONY=cd ${APP_DIR} && symfony COMPOSER=symfony composer CONSOLE=${SYMFONY} console export COMPOSE_PROJECT_NAME=anti-spam +export MIGRATIONS_NAMESPACE=MonsieurBiz\\SyliusAntiSpamPlugin\\Migrations +export USER_UID=$(shell id -u) PLUGIN_NAME=sylius-${COMPOSE_PROJECT_NAME}-plugin -COMPOSE=docker-compose +COMPOSE=docker compose YARN=yarn -DOCTRINE_MIGRATIONS_NAMESPACE=MonsieurBiz\SyliusAntiSpamPlugin\Migrations ### ### DEVELOPMENT @@ -77,13 +78,15 @@ setup_application: $(MAKE) ${APP_DIR}/php.ini (cd ${APP_DIR} && ${COMPOSER} install --no-interaction) $(MAKE) apply_dist - (cd ${APP_DIR} && ${COMPOSER} require --no-progress monsieurbiz/${PLUGIN_NAME}="*@dev") + (cd ${APP_DIR} && ${COMPOSER} require --no-progress --no-interaction monsieurbiz/${PLUGIN_NAME}="*@dev") rm -rf ${APP_DIR}/var/cache ${APP_DIR}/docker-compose.yaml: rm -f ${APP_DIR}/docker-compose.yml rm -f ${APP_DIR}/docker-compose.yaml + rm -f ${APP_DIR}/compose.yml # Remove Sylius file about Docker + rm -f ${APP_DIR}/compose.override.dist.yml # Remove Sylius file about Docker ln -s ../../docker-compose.yaml.dist ${APP_DIR}/docker-compose.yaml .PHONY: ${APP_DIR}/docker-compose.yaml @@ -135,7 +138,7 @@ test.container: ## Lint the symfony container ${CONSOLE} lint:container test.yaml: ## Lint the symfony Yaml files - ${CONSOLE} lint:yaml ../../recipes ../../src/Resources/config + ${CONSOLE} lint:yaml ../../src/Resources/config --parse-tags test.schema: ## Validate MySQL Schema ${CONSOLE} doctrine:schema:validate @@ -143,14 +146,6 @@ test.schema: ## Validate MySQL Schema test.twig: ## Validate Twig templates ${CONSOLE} lint:twig --no-debug templates/ ../../src/Resources/views/ -### -### MIGRATIONS -### ¯¯¯¯¯¯¯¯¯¯ - -doctrine.migration.diff: ## create a diff migration file for the plugin - ${CONSOLE} doctrine:migrations:diff --namespace="${DOCTRINE_MIGRATIONS_NAMESPACE}" -.PHONY: doctrine.migration.diff - ### ### SYLIUS ### ¯¯¯¯¯¯ @@ -174,6 +169,9 @@ sylius.assets: ## Install all assets with symlinks messenger.setup: ## Setup Messenger transports ${CONSOLE} messenger:setup-transports +doctrine.diff: ## Doctrine diff + ${CONSOLE} doctrine:migration:diff --namespace="${MIGRATIONS_NAMESPACE}" + ### ### PLATFORM ### ¯¯¯¯¯¯¯¯ diff --git a/README.md b/README.md index 00faad4..6fd9646 100644 --- a/README.md +++ b/README.md @@ -3,14 +3,28 @@

Anti Spam

[![Anti Spam Plugin license](https://img.shields.io/github/license/monsieurbiz/SyliusAntiSpamPlugin?public)](https://github.com/monsieurbiz/SyliusAntiSpamPlugin/blob/master/LICENSE.txt) -[![Tests](https://github.com/monsieurbiz/SyliusAntiSpamPlugin/actions/workflows/tests.yaml/badge.svg)](https://github.com/monsieurbiz/SyliusAntiSpamPlugin/actions/workflows/tests.yaml) -[![Security](https://github.com/monsieurbiz/SyliusAntiSpamPlugin/actions/workflows/security.yaml/badge.svg)](https://github.com/monsieurbiz/SyliusAntiSpamPlugin/actions/workflows/security.yaml) -[![Flex Recipe](https://github.com/monsieurbiz/SyliusAntiSpamPlugin/actions/workflows/recipe.yaml/badge.svg)](https://github.com/monsieurbiz/SyliusAntiSpamPlugin/actions/workflows/recipe.yaml) +[![Tests Status](https://img.shields.io/github/actions/workflow/status/monsieurbiz/SyliusAntiSpamPlugin/tests.yaml?branch=master&logo=github)](https://github.com/monsieurbiz/SyliusAntiSpamPlugin/actions?query=workflow%3ATests) +[![Recipe Status](https://img.shields.io/github/actions/workflow/status/monsieurbiz/SyliusAntiSpamPlugin/recipe.yaml?branch=master&label=recipes&logo=github)](https://github.com/monsieurbiz/SyliusAntiSpamPlugin/actions?query=workflow%3ASecurity) +[![Security Status](https://img.shields.io/github/actions/workflow/status/monsieurbiz/SyliusAntiSpamPlugin/security.yaml?branch=master&label=security&logo=github)](https://github.com/monsieurbiz/SyliusAntiSpamPlugin/actions?query=workflow%3ASecurity) This plugins adds captcha and allows you to manage your spams. +## Compatibility + +| Sylius Version | PHP Version | +|---|---| +| 1.11 | 8.0 - 8.1 | +| 1.12 | 8.1 - 8.2 | +| 1.13 | 8.1 - 8.2 | + ## Installation +If you want to use our recipes, you can configure your composer.json by running: + +```bash +composer config --no-plugins --json extra.symfony.endpoint '["https://api.github.com/repos/monsieurbiz/symfony-recipes/contents/index.json?ref=flex/master","flex://defaults"]' +``` + ⚙️ To Be Defined.