From cccb919cbb59332f131b26c4d8c0c721cd865aba Mon Sep 17 00:00:00 2001 From: Lorenzo Ruozzi Date: Mon, 20 Feb 2023 10:55:30 +0100 Subject: [PATCH] Upgrade for Sylius 1.12 --- .docker/nginx/nginx.conf | 48 +++++++++++ .docker/php/php.ini | 5 ++ .editorconfig | 82 ++++++++++++++++++ .github/workflows/build.yml | 25 ++++-- .gitignore | 1 + Makefile | 36 ++++++++ composer.json | 49 ++++++----- docker-compose.yml | 42 ++++++++++ e2e-test-server.sh | 5 ++ ecs.php | 19 +++-- phpstan.neon | 4 + .../AddCurrencySubscriberSpec.php | 2 + ...griffeSyliusTableRateShippingExtension.php | 10 ++- .../EventSubscriber/AddCurrencySubscriber.php | 2 + src/Resolver/TableRateResolver.php | 4 +- .../_weightLimitToRateTheme.html.twig | 83 +++++++++--------- ...WebgriffeSyliusTableRateShippingPlugin.php | 5 ++ tests/Application/.babelrc | 15 ---- tests/Application/.env | 9 +- tests/Application/.gitignore | 1 + tests/Application/Kernel.php | 40 ++------- tests/Application/assets/admin/entry.js | 1 + tests/Application/assets/shop/entry.js | 1 + tests/Application/config/bootstrap.php | 4 + tests/Application/config/bundles.php | 3 +- tests/Application/config/packages/assets.yaml | 7 ++ .../config/packages/dev/swiftmailer.yaml | 2 - tests/Application/config/packages/mailer.yaml | 3 + .../Application/config/packages/security.yaml | 44 +++++----- .../config/packages/security_checker.yaml | 9 -- .../config/packages/staging/swiftmailer.yaml | 2 - .../config/packages/swiftmailer.yaml | 2 - .../config/packages/test/framework.yaml | 2 +- .../config/packages/test/mailer.yaml | 5 ++ .../config/packages/test/security.yaml | 7 +- .../config/packages/test/swiftmailer.yaml | 6 -- .../packages/test_cached/framework.yaml | 6 +- .../config/packages/test_cached/mailer.yaml | 2 + .../config/packages/test_cached/security.yaml | 5 +- .../packages/test_cached/swiftmailer.yaml | 6 -- .../config/packages/webpack_encore.yaml | 5 ++ tests/Application/config/routes.yaml | 0 tests/Application/gulpfile.babel.js | 60 ------------- tests/Application/package.json | 84 +++++++++++-------- .../Application/public/media/image/.gitignore | 0 .../SyliusAdminBundle/Layout/_logo.html.twig | 5 ++ .../Security/_content.html.twig | 6 ++ .../SyliusAdminBundle/_scripts.html.twig | 1 + .../SyliusAdminBundle/_styles.html.twig | 1 + .../Homepage/_banner.html.twig | 9 ++ .../Layout/Header/_logo.html.twig | 5 ++ .../SyliusShopBundle/_scripts.html.twig | 1 + .../SyliusShopBundle/_styles.html.twig | 1 + tests/Application/webpack.config.js | 36 ++++---- 54 files changed, 504 insertions(+), 314 deletions(-) create mode 100644 .docker/nginx/nginx.conf create mode 100644 .docker/php/php.ini create mode 100644 .editorconfig create mode 100644 Makefile create mode 100644 docker-compose.yml create mode 100755 e2e-test-server.sh delete mode 100644 tests/Application/.babelrc create mode 100644 tests/Application/assets/admin/entry.js create mode 100644 tests/Application/assets/shop/entry.js create mode 100644 tests/Application/config/packages/assets.yaml delete mode 100644 tests/Application/config/packages/dev/swiftmailer.yaml create mode 100644 tests/Application/config/packages/mailer.yaml delete mode 100644 tests/Application/config/packages/security_checker.yaml delete mode 100644 tests/Application/config/packages/staging/swiftmailer.yaml delete mode 100644 tests/Application/config/packages/swiftmailer.yaml create mode 100644 tests/Application/config/packages/test/mailer.yaml delete mode 100644 tests/Application/config/packages/test/swiftmailer.yaml create mode 100644 tests/Application/config/packages/test_cached/mailer.yaml delete mode 100644 tests/Application/config/packages/test_cached/swiftmailer.yaml create mode 100644 tests/Application/config/packages/webpack_encore.yaml delete mode 100644 tests/Application/config/routes.yaml delete mode 100644 tests/Application/gulpfile.babel.js delete mode 100644 tests/Application/public/media/image/.gitignore create mode 100644 tests/Application/templates/bundles/SyliusAdminBundle/Layout/_logo.html.twig create mode 100644 tests/Application/templates/bundles/SyliusAdminBundle/Security/_content.html.twig create mode 100644 tests/Application/templates/bundles/SyliusAdminBundle/_scripts.html.twig create mode 100644 tests/Application/templates/bundles/SyliusAdminBundle/_styles.html.twig create mode 100644 tests/Application/templates/bundles/SyliusShopBundle/Homepage/_banner.html.twig create mode 100644 tests/Application/templates/bundles/SyliusShopBundle/Layout/Header/_logo.html.twig create mode 100644 tests/Application/templates/bundles/SyliusShopBundle/_scripts.html.twig create mode 100644 tests/Application/templates/bundles/SyliusShopBundle/_styles.html.twig diff --git a/.docker/nginx/nginx.conf b/.docker/nginx/nginx.conf new file mode 100644 index 0000000..6bfbd29 --- /dev/null +++ b/.docker/nginx/nginx.conf @@ -0,0 +1,48 @@ +user www-data; +worker_processes auto; +daemon off; +pid /run/nginx.pid; + +include /etc/nginx/modules-enabled/*.conf; + +events { + worker_connections 1024; +} + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + server_tokens off; + + client_max_body_size 64m; + sendfile on; + tcp_nodelay on; + tcp_nopush on; + + gzip_vary on; + + access_log /var/log/nginx/access.log; + error_log /var/log/nginx/error.log; + + server { + listen 80; + + root /app/tests/Application/public; + index index.php; + + location / { + try_files $uri /index.php$is_args$args; + } + + location ~ \.php$ { + include fastcgi_params; + + fastcgi_pass unix:/var/run/php8-fpm.sock; + fastcgi_split_path_info ^(.+\.php)(/.*)$; + + fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; + fastcgi_param DOCUMENT_ROOT $realpath_root; + } + } +} diff --git a/.docker/php/php.ini b/.docker/php/php.ini new file mode 100644 index 0000000..13f0abe --- /dev/null +++ b/.docker/php/php.ini @@ -0,0 +1,5 @@ +[PHP] +memory_limit=512M + +[date] +date.timezone=${PHP_DATE_TIMEZONE} diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..b5f72a5 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,82 @@ +# EditorConfig helps developers define and maintain consistent +# coding styles between different editors and IDEs +# editorconfig.org + +root = true + +[*] +# Change these settings to your own preference +indent_style = space +indent_size = 4 + +# We recommend you to keep these unchanged +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.feature] +indent_style = space +indent_size = 4 + +[*.js] +indent_style = space +indent_size = 2 + +[*.json] +indent_style = space +indent_size = 2 + +[*.md] +indent_style = space +indent_size = 4 +trim_trailing_whitespace = false + +[*.neon] +indent_style = space +indent_size = 4 + +[*.php] +indent_style = space +indent_size = 4 + +[*.sh] +indent_style = space +indent_size = 4 + +[*.{yaml,yml}] +indent_style = space +indent_size = 4 +trim_trailing_whitespace = false + +[.babelrc] +indent_style = space +indent_size = 2 + +[.gitmodules] +indent_style = tab +indent_size = 4 + +[.php_cs{,.dist}] +indent_style = space +indent_size = 4 + +[composer.json] +indent_style = space +indent_size = 4 + +[package.json] +indent_style = space +indent_size = 2 + +[phpspec.yml{,.dist}] +indent_style = space +indent_size = 4 + +[phpstan.neon] +indent_style = space +indent_size = 4 + +[phpunit.xml{,.dist}] +indent_style = space +indent_size = 4 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 47b617c..ee87291 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,18 +14,18 @@ on: jobs: tests: - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest name: "Sylius ${{ matrix.sylius }}, PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}, MySQL ${{ matrix.mysql }}" strategy: fail-fast: false matrix: - php: ["8.0"] - symfony: ["5.4.*"] - sylius: ["^1.11.2"] - node: ["14.x"] - mysql: ["8.0"] + php: ["8.0", "8.1"] + symfony: ["5.4.*", "^6.0"] + sylius: ["^1.12"] + node: ["18.x"] + mysql: ["5.7", "8.0"] env: APP_ENV: test @@ -41,7 +41,7 @@ jobs: with: php-version: "${{ matrix.php }}" extensions: intl - tools: symfony + tools: flex,symfony coverage: none - @@ -91,11 +91,16 @@ jobs: restore-keys: | ${{ runner.os }}-php-${{ matrix.php }}-composer- + - + name: Configure global composer + run: | + composer global config --no-plugins allow-plugins.symfony/flex true + composer global require --no-progress --no-scripts --no-plugins "symfony/flex:^2.2.2" + - name: Restrict Symfony version if: matrix.symfony != '' run: | - composer global require --no-progress --no-scripts --no-plugins "symfony/flex:^1.10" composer config extra.symfony.require "${{ matrix.symfony }}" - @@ -106,6 +111,8 @@ jobs: - name: Install PHP dependencies run: composer install --no-interaction + env: + SYMFONY_REQUIRE: ${{ matrix.symfony }} - name: Get Yarn cache directory @@ -135,7 +142,7 @@ jobs: name: Prepare test application assets run: | (cd tests/Application && bin/console assets:install public -vvv) - (cd tests/Application && yarn build) + (cd tests/Application && yarn build:prod) - name: Prepare test application cache diff --git a/.gitignore b/.gitignore index 29046b9..95d212b 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ # Symfony CLI https://symfony.com/doc/current/setup/symfony_server.html#different-php-settings-per-project /.php-version /php.ini +docker-compose.override.yml diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..01d9607 --- /dev/null +++ b/Makefile @@ -0,0 +1,36 @@ +phpunit: + vendor/bin/phpunit + +phpspec: + vendor/bin/phpspec run --ansi --no-interaction -f dot + +phpstan: + vendor/bin/phpstan analyse + +psalm: + vendor/bin/psalm + +behat-js: + APP_ENV=test vendor/bin/behat --colors --strict --no-interaction -vvv -f progress + +install: + composer install --no-interaction --no-scripts + +backend: + tests/Application/bin/console sylius:install --no-interaction + tests/Application/bin/console sylius:fixtures:load default --no-interaction + +frontend: + (cd tests/Application && yarn install --pure-lockfile) + (cd tests/Application && GULP_ENV=prod yarn build) + +behat: + APP_ENV=test vendor/bin/behat --colors --strict --no-interaction -vvv -f progress + +init: install backend frontend + +ci: init phpstan psalm phpunit phpspec behat + +integration: init phpunit behat + +static: install phpspec phpstan psalm diff --git a/composer.json b/composer.json index bee9255..1e9af79 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,9 @@ "license": "MIT", "require": { "php": "^8.0", - "sylius/sylius": "^1.11" + "sylius/sylius": "^1.12", + "sylius/mailer-bundle": "^1.8 || ^2.0", + "symfony/webpack-encore-bundle": "^1.15" }, "require-dev": { "behat/behat": "^3.6.1", @@ -24,35 +26,35 @@ "friends-of-behat/suite-settings-extension": "^1.0", "friends-of-behat/symfony-extension": "^2.1", "friends-of-behat/variadic-extension": "^1.3", - "friendsofsymfony/oauth-server-bundle": "^1.6 || >2.0.0-alpha.0 ^2.0@dev", - "phpspec/phpspec": "^7.0", + "phpspec/phpspec": "^7.2", "phpstan/extension-installer": "^1.0", - "phpstan/phpstan": "0.12.99", - "phpstan/phpstan-doctrine": "0.12.33", - "phpstan/phpstan-strict-rules": "^0.12.0", - "phpstan/phpstan-webmozart-assert": "0.12.12", + "phpstan/phpstan": "^1.8.1", + "phpstan/phpstan-doctrine": "1.3.16", + "phpstan/phpstan-strict-rules": "^1.3.0", + "phpstan/phpstan-webmozart-assert": "^1.2.0", "phpunit/phpunit": "^9.5", - "sensiolabs/security-checker": "^6.0", - "sylius-labs/coding-standard": "^4.0", - "symfony/browser-kit": "^5.4", - "symfony/debug-bundle": "^5.4", - "symfony/dotenv": "^5.4", - "symfony/intl": "^5.4", - "symfony/web-profiler-bundle": "^5.4", - "vimeo/psalm": "4.7.1", - "polishsymfonycommunity/symfony-mocker-container": "^1.0" + "polishsymfonycommunity/symfony-mocker-container": "^1.0", + "sylius-labs/coding-standard": "^4.2", + "symfony/browser-kit": "^5.4 || ^6.0", + "symfony/debug-bundle": "^5.4 || ^6.0", + "symfony/dotenv": "^5.4 || ^6.0", + "symfony/flex": "^2.2.2", + "symfony/intl": "^5.4 || ^6.0", + "symfony/web-profiler-bundle": "^5.4 || ^6.0", + "vimeo/psalm": "4.27.0" }, "config": { "sort-packages": true, "allow-plugins": { - "symfony/thanks": true, - "dealerdirect/phpcodesniffer-composer-installer": true, - "phpstan/extension-installer": true + "dealerdirect/phpcodesniffer-composer-installer": false, + "phpstan/extension-installer": true, + "symfony/flex": true, + "symfony/thanks": true } }, "extra": { "branch-alias": { - "dev-master": "1.11-dev" + "dev-master": "1.12-dev" } }, "autoload": { @@ -87,6 +89,11 @@ "@phpunit", "@phpspec", "@behat" - ] + ], + "auto-scripts": { + "cache:clear": "symfony-cmd", + "assets:install %PUBLIC_DIR%": "symfony-cmd", + "security-checker security:check": "script" + } } } diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..a3e00ab --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,42 @@ +services: + app: + image: sylius/standard:1.11-traditional-alpine + environment: + APP_ENV: "dev" + DATABASE_URL: "mysql://root:mysql@mysql/sylius_%kernel.environment%?charset=utf8mb4" +# DATABASE_URL: "pgsql://root:postgres@postgres/sylius_%kernel.environment%?charset=utf8" # When using postgres + PHP_DATE_TIMEZONE: "Europe/Warsaw" + volumes: + - ./:/app:delegated + - ./.docker/php/php.ini:/etc/php8/php.ini:delegated + - ./.docker/nginx/nginx.conf:/etc/nginx/nginx.conf:delegated + ports: + - 80:80 + depends_on: + - mysql + networks: + - sylius + + mysql: + image: mysql:8.0 + platform: linux/amd64 + environment: + MYSQL_ROOT_PASSWORD: mysql + ports: + - ${MYSQL_PORT:-3306}:3306 + networks: + - sylius + +# postgres: +# image: postgres:14-alpine +# environment: +# POSTGRES_USER: root +# POSTGRES_PASSWORD: postgres +# ports: +# - ${POSTGRES_PORT:-5432}:5432 +# networks: +# - sylius + +networks: + sylius: + driver: bridge diff --git a/e2e-test-server.sh b/e2e-test-server.sh new file mode 100755 index 0000000..b03e8de --- /dev/null +++ b/e2e-test-server.sh @@ -0,0 +1,5 @@ +# Make sure to set GOOGLE_CHROME env variable pointing to your Google Chrome binary. For example on macOS: +# GOOGLE_CHROME="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" ./e2e-test-server.sh + +trap 'kill %1; kill %2' SIGINT +cd tests/Application && APP_ENV=test symfony server:start --port=8080 --dir=public & "${GOOGLE_CHROME}" --enable-automation --disable-background-networking --no-default-browser-check --no-first-run --disable-popup-blocking --disable-default-apps --allow-insecure-localhost --disable-translate --disable-extensions --no-sandbox --enable-features=Metal --headless --remote-debugging-port=9222 --disable-gpu --window-size=2880,1800 --proxy-server='direct://' --proxy-bypass-list='*' --crash-dumps-dir=/tmp https://127.0.0.1 & tee diff --git a/ecs.php b/ecs.php index bf40cc9..3cf43de 100644 --- a/ecs.php +++ b/ecs.php @@ -1,14 +1,21 @@ paths([ + __DIR__ . '/src', + __DIR__ . '/tests/Behat', + __DIR__ . '/ecs.php', + ]); -return static function (ContainerConfigurator $containerConfigurator): void { - $containerConfigurator->import('vendor/sylius-labs/coding-standard/ecs.php'); + $ecsConfig->import('vendor/sylius-labs/coding-standard/ecs.php'); - $containerConfigurator->parameters()->set(Option::SKIP, [ + $ecsConfig->skip([ VisibilityRequiredFixer::class => ['*Spec.php'], ]); }; + diff --git a/phpstan.neon b/phpstan.neon index 2d625f6..2235744 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,6 +1,10 @@ parameters: + level: max reportUnmatchedIgnoredErrors: false checkMissingIterableValueType: false + paths: + - src + - tests/Behat excludes_analyse: # Makes PHPStan crash diff --git a/spec/Form/EventSubscriber/AddCurrencySubscriberSpec.php b/spec/Form/EventSubscriber/AddCurrencySubscriberSpec.php index 386497e..3017d13 100644 --- a/spec/Form/EventSubscriber/AddCurrencySubscriberSpec.php +++ b/spec/Form/EventSubscriber/AddCurrencySubscriberSpec.php @@ -36,6 +36,7 @@ function it_sets_currency_as_disabled_when_table_rate_is_not_new( $form ->add('currency', Argument::type('string'), Argument::withEntry('disabled', true)) ->shouldBeCalled() + ->willReturn($form) ; $this->preSetData($event); @@ -54,6 +55,7 @@ function it_does_not_set_currency_as_disabled_when_table_rate_is_new( $form ->add('currency', Argument::type('string'), Argument::withEntry('disabled', false)) ->shouldBeCalled() + ->willReturn($form) ; $this->preSetData($event); diff --git a/src/DependencyInjection/WebgriffeSyliusTableRateShippingExtension.php b/src/DependencyInjection/WebgriffeSyliusTableRateShippingExtension.php index 5e34556..715d63f 100644 --- a/src/DependencyInjection/WebgriffeSyliusTableRateShippingExtension.php +++ b/src/DependencyInjection/WebgriffeSyliusTableRateShippingExtension.php @@ -4,6 +4,7 @@ namespace Webgriffe\SyliusTableRateShippingPlugin\DependencyInjection; +use Symfony\Component\Config\Definition\ConfigurationInterface; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Extension\Extension; @@ -11,11 +12,16 @@ final class WebgriffeSyliusTableRateShippingExtension extends Extension { - public function load(array $config, ContainerBuilder $container): void + public function load(array $configs, ContainerBuilder $container): void { - $this->processConfiguration($this->getConfiguration([], $container), $config); + $this->processConfiguration($this->getConfiguration([], $container), $configs); $loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); $loader->load('services.yml'); } + + public function getConfiguration(array $config, ContainerBuilder $container): ConfigurationInterface + { + return new Configuration(); + } } diff --git a/src/Form/EventSubscriber/AddCurrencySubscriber.php b/src/Form/EventSubscriber/AddCurrencySubscriber.php index fe9be17..4e39e62 100644 --- a/src/Form/EventSubscriber/AddCurrencySubscriber.php +++ b/src/Form/EventSubscriber/AddCurrencySubscriber.php @@ -9,6 +9,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\Form\FormEvent; use Symfony\Component\Form\FormEvents; +use Webmozart\Assert\Assert; class AddCurrencySubscriber implements EventSubscriberInterface { @@ -22,6 +23,7 @@ public function preSetData(FormEvent $event): void $messagesNamespace = 'webgriffe_sylius_table_rate_plugin.ui.shipping_table_rate.'; $form = $event->getForm(); $resource = $event->getData(); + Assert::nullOrIsInstanceOf($resource, ResourceInterface::class); $form->add( 'currency', diff --git a/src/Resolver/TableRateResolver.php b/src/Resolver/TableRateResolver.php index ac719e9..28af63f 100644 --- a/src/Resolver/TableRateResolver.php +++ b/src/Resolver/TableRateResolver.php @@ -13,6 +13,9 @@ final class TableRateResolver implements TableRateResolverInterface { + /** + * @param RepositoryInterface $tableRateRepository + */ public function __construct(private RepositoryInterface $tableRateRepository) { } @@ -53,7 +56,6 @@ public function resolve(ShipmentInterface $shipment, array $calculatorConfig): S /** @var ShippingTableRate $tableRate */ $tableRate = $calculatorConfig[$channelCode][TableRateConfigurationType::TABLE_RATE_FIELD_NAME]; - /** @var ShippingTableRate|null $tableRate */ $tableRate = $this->tableRateRepository->findOneBy(['code' => $tableRate->getCode()]); Assert::isInstanceOf($tableRate, ShippingTableRate::class); diff --git a/src/Resources/views/TableRateCrud/_weightLimitToRateTheme.html.twig b/src/Resources/views/TableRateCrud/_weightLimitToRateTheme.html.twig index 02e273d..61a7556 100644 --- a/src/Resources/views/TableRateCrud/_weightLimitToRateTheme.html.twig +++ b/src/Resources/views/TableRateCrud/_weightLimitToRateTheme.html.twig @@ -5,57 +5,54 @@ {% import _self as self %} {% set attr = attr|merge({'class': attr.class|default ~ ' controls collection-widget'}) %} - {% spaceless %} - +
-
-
+ +
- {{ error(form.vars.errors) }} + {{ error(form.vars.errors) }} - {% if prototypes|default is iterable %} - {% for key, subPrototype in prototypes %} - - {% endfor %} - {% endif %} + {% if prototypes|default is iterable %} + {% for key, subPrototype in prototypes %} + + {% endfor %} + {% endif %} -
- {% for child in form %} - {{ _self.collectionItem(child, allow_delete, button_delete_label, loop.index0) }} - {% endfor %} -
- - {% if prototype is defined and allow_add %} - - - {{ button_add_label|trans }} - - {% endif %} +
+ {% for child in form %} + {{ _self.collectionItem(child, allow_delete, button_delete_label, loop.index0) }} + {% endfor %}
- {% endspaceless %} + + {% if prototype is defined and allow_add %} + + + {{ button_add_label|trans }} + + {% endif %} +
{% endblock %} {% macro collectionItem(form, allow_delete, button_delete_label, index) %} - {% spaceless %} -
- {{ form_widget(form) }} - {% if allow_delete %} - - {% endif %} -
- {% endspaceless %} +
+ {{ form_widget(form) }} + {% if allow_delete %} + + {% endif %} +
{% endmacro %} {% block _webgriffe_sylius_table_rate_plugin_shipping_table_rate_weightLimitToRate_entry_widget %} diff --git a/src/WebgriffeSyliusTableRateShippingPlugin.php b/src/WebgriffeSyliusTableRateShippingPlugin.php index 7cd1d02..acce111 100644 --- a/src/WebgriffeSyliusTableRateShippingPlugin.php +++ b/src/WebgriffeSyliusTableRateShippingPlugin.php @@ -10,4 +10,9 @@ final class WebgriffeSyliusTableRateShippingPlugin extends Bundle { use SyliusPluginTrait; + + public function getPath(): string + { + return __DIR__; + } } diff --git a/tests/Application/.babelrc b/tests/Application/.babelrc deleted file mode 100644 index e563a62..0000000 --- a/tests/Application/.babelrc +++ /dev/null @@ -1,15 +0,0 @@ -{ - "presets": [ - ["env", { - "targets": { - "node": "6" - }, - "useBuiltIns": true - }] - ], - "plugins": [ - ["transform-object-rest-spread", { - "useBuiltIns": true - }] - ] -} diff --git a/tests/Application/.env b/tests/Application/.env index bdb3c6a..658c1e0 100644 --- a/tests/Application/.env +++ b/tests/Application/.env @@ -21,12 +21,9 @@ JWT_PUBLIC_KEY=%kernel.project_dir%/config/jwt/public.pem JWT_PASSPHRASE=acme_plugin_development ###< lexik/jwt-authentication-bundle ### -###> symfony/swiftmailer-bundle ### -# For Gmail as a transport, use: "gmail://username:password@localhost" -# For a generic SMTP server, use: "smtp://localhost:25?encryption=&auth_mode=" -# Delivery is disabled by default via "null://localhost" -MAILER_URL=smtp://localhost -###< symfony/swiftmailer-bundle ### +###> symfony/mailer ### +MAILER_DSN=null://null +###< symfony/mailer ### ###> symfony/messenger ### # Choose one of the transports below diff --git a/tests/Application/.gitignore b/tests/Application/.gitignore index 8ad1225..bc600a8 100644 --- a/tests/Application/.gitignore +++ b/tests/Application/.gitignore @@ -1,4 +1,5 @@ /public/assets +/public/build /public/css /public/js /public/media/* diff --git a/tests/Application/Kernel.php b/tests/Application/Kernel.php index bfc1b08..a1d69dc 100644 --- a/tests/Application/Kernel.php +++ b/tests/Application/Kernel.php @@ -7,12 +7,9 @@ use PSS\SymfonyMockerContainer\DependencyInjection\MockerContainer; use Sylius\Bundle\CoreBundle\Application\Kernel as SyliusKernel; use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; -use Symfony\Component\Config\Loader\LoaderInterface; -use Symfony\Component\Config\Resource\FileResource; -use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Bundle\BundleInterface; use Symfony\Component\HttpKernel\Kernel as BaseKernel; -use Symfony\Component\Routing\RouteCollectionBuilder; +use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; final class Kernel extends BaseKernel { @@ -41,24 +38,7 @@ public function registerBundles(): iterable } } - protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void - { - foreach ($this->getConfigurationDirectories() as $confDir) { - $bundlesFile = $confDir . '/bundles.php'; - if (false === is_file($bundlesFile)) { - continue; - } - $container->addResource(new FileResource($bundlesFile)); - } - - $container->setParameter('container.dumper.inline_class_loader', true); - - foreach ($this->getConfigurationDirectories() as $confDir) { - $this->loadContainerConfiguration($loader, $confDir); - } - } - - protected function configureRoutes(RouteCollectionBuilder $routes): void + protected function configureRoutes(RoutingConfigurator $routes): void { foreach ($this->getConfigurationDirectories() as $confDir) { $this->loadRoutesConfiguration($routes, $confDir); @@ -79,19 +59,11 @@ private function isTestEnvironment(): bool return 0 === strpos($this->getEnvironment(), 'test'); } - private function loadContainerConfiguration(LoaderInterface $loader, string $confDir): void - { - $loader->load($confDir . '/{packages}/*' . self::CONFIG_EXTS, 'glob'); - $loader->load($confDir . '/{packages}/' . $this->environment . '/**/*' . self::CONFIG_EXTS, 'glob'); - $loader->load($confDir . '/{services}' . self::CONFIG_EXTS, 'glob'); - $loader->load($confDir . '/{services}_' . $this->environment . self::CONFIG_EXTS, 'glob'); - } - - private function loadRoutesConfiguration(RouteCollectionBuilder $routes, string $confDir): void + private function loadRoutesConfiguration(RoutingConfigurator $routes, string $confDir): void { - $routes->import($confDir . '/{routes}/*' . self::CONFIG_EXTS, '/', 'glob'); - $routes->import($confDir . '/{routes}/' . $this->environment . '/**/*' . self::CONFIG_EXTS, '/', 'glob'); - $routes->import($confDir . '/{routes}' . self::CONFIG_EXTS, '/', 'glob'); + $routes->import($confDir . '/{routes}/*' . self::CONFIG_EXTS); + $routes->import($confDir . '/{routes}/' . $this->environment . '/**/*' . self::CONFIG_EXTS); + $routes->import($confDir . '/{routes}' . self::CONFIG_EXTS); } /** diff --git a/tests/Application/assets/admin/entry.js b/tests/Application/assets/admin/entry.js new file mode 100644 index 0000000..635f5ac --- /dev/null +++ b/tests/Application/assets/admin/entry.js @@ -0,0 +1 @@ +import 'sylius/bundle/AdminBundle/Resources/private/entry'; diff --git a/tests/Application/assets/shop/entry.js b/tests/Application/assets/shop/entry.js new file mode 100644 index 0000000..aadc317 --- /dev/null +++ b/tests/Application/assets/shop/entry.js @@ -0,0 +1 @@ +import 'sylius/bundle/ShopBundle/Resources/private/entry'; diff --git a/tests/Application/config/bootstrap.php b/tests/Application/config/bootstrap.php index e23eca0..c9951a7 100644 --- a/tests/Application/config/bootstrap.php +++ b/tests/Application/config/bootstrap.php @@ -13,6 +13,10 @@ $_ENV += $env; } elseif (!class_exists(Dotenv::class)) { throw new RuntimeException('Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.'); +} elseif (method_exists(Dotenv::class, 'bootEnv')) { + (new Dotenv())->bootEnv(dirname(__DIR__) . '/.env'); + + return; } else { // load all the .env files (new Dotenv(true))->loadEnv(dirname(__DIR__) . '/.env'); diff --git a/tests/Application/config/bundles.php b/tests/Application/config/bundles.php index 5a05b41..c02b9a3 100644 --- a/tests/Application/config/bundles.php +++ b/tests/Application/config/bundles.php @@ -4,7 +4,6 @@ Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true], Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true], Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true], - Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle::class => ['all' => true], Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true], Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true], Sylius\Bundle\OrderBundle\SyliusOrderBundle::class => ['all' => true], @@ -57,4 +56,6 @@ BabDev\PagerfantaBundle\BabDevPagerfantaBundle::class => ['all' => true], SyliusLabs\Polyfill\Symfony\Security\Bundle\SyliusLabsPolyfillSymfonySecurityBundle::class => ['all' => true], Sylius\Calendar\SyliusCalendarBundle::class => ['all' => true], + Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true], + League\FlysystemBundle\FlysystemBundle::class => ['all' => true], ]; diff --git a/tests/Application/config/packages/assets.yaml b/tests/Application/config/packages/assets.yaml new file mode 100644 index 0000000..2468901 --- /dev/null +++ b/tests/Application/config/packages/assets.yaml @@ -0,0 +1,7 @@ +framework: + assets: + packages: + shop: + json_manifest_path: '%kernel.project_dir%/public/build/shop/manifest.json' + admin: + json_manifest_path: '%kernel.project_dir%/public/build/admin/manifest.json' diff --git a/tests/Application/config/packages/dev/swiftmailer.yaml b/tests/Application/config/packages/dev/swiftmailer.yaml deleted file mode 100644 index f438078..0000000 --- a/tests/Application/config/packages/dev/swiftmailer.yaml +++ /dev/null @@ -1,2 +0,0 @@ -swiftmailer: - disable_delivery: true diff --git a/tests/Application/config/packages/mailer.yaml b/tests/Application/config/packages/mailer.yaml new file mode 100644 index 0000000..56a650d --- /dev/null +++ b/tests/Application/config/packages/mailer.yaml @@ -0,0 +1,3 @@ +framework: + mailer: + dsn: '%env(MAILER_DSN)%' diff --git a/tests/Application/config/packages/security.yaml b/tests/Application/config/packages/security.yaml index 5101dde..4ed342f 100644 --- a/tests/Application/config/packages/security.yaml +++ b/tests/Application/config/packages/security.yaml @@ -1,5 +1,5 @@ security: - always_authenticate_before_granting: true + enable_authenticator_manager: true providers: sylius_admin_user_provider: id: sylius.admin_user_provider.email_or_name_based @@ -10,7 +10,7 @@ security: sylius_api_shop_user_provider: id: sylius.shop_user_provider.email_or_name_based - encoders: + password_hashers: Sylius\Component\User\Model\UserInterface: argon2i firewalls: admin: @@ -26,7 +26,7 @@ security: default_target_path: sylius_admin_dashboard use_forward: false use_referer: true - csrf_token_generator: security.csrf.token_manager + enable_csrf: true csrf_parameter: _csrf_admin_security_token csrf_token_id: admin_authenticate remember_me: @@ -38,37 +38,32 @@ security: logout: path: sylius_admin_logout target: sylius_admin_login - anonymous: true new_api_admin_user: pattern: "%sylius.security.new_api_admin_regex%/.*" provider: sylius_api_admin_user_provider stateless: true - anonymous: true + entry_point: jwt json_login: check_path: "%sylius.security.new_api_admin_route%/authentication-token" username_path: email password_path: password success_handler: lexik_jwt_authentication.handler.authentication_success failure_handler: lexik_jwt_authentication.handler.authentication_failure - guard: - authenticators: - - lexik_jwt_authentication.jwt_token_authenticator + jwt: true new_api_shop_user: pattern: "%sylius.security.new_api_shop_regex%/.*" provider: sylius_api_shop_user_provider stateless: true - anonymous: true + entry_point: jwt json_login: check_path: "%sylius.security.new_api_shop_route%/authentication-token" username_path: email password_path: password success_handler: lexik_jwt_authentication.handler.authentication_success failure_handler: lexik_jwt_authentication.handler.authentication_failure - guard: - authenticators: - - lexik_jwt_authentication.jwt_token_authenticator + jwt: true shop: switch_user: { role: ROLE_ALLOWED_TO_SWITCH } @@ -85,7 +80,7 @@ security: default_target_path: sylius_shop_homepage use_forward: false use_referer: true - csrf_token_generator: security.csrf.token_manager + enable_csrf: true csrf_parameter: _csrf_shop_security_token csrf_token_id: shop_authenticate remember_me: @@ -95,10 +90,8 @@ security: remember_me_parameter: _remember_me logout: path: sylius_shop_logout - target: sylius_shop_login + target: sylius_shop_homepage invalidate_session: false - success_handler: sylius.handler.shop_user_logout - anonymous: true dev: pattern: ^/(_(profiler|wdt)|css|images|js)/ @@ -109,22 +102,23 @@ security: security: false access_control: - - { path: "%sylius.security.admin_regex%/_partial", role: IS_AUTHENTICATED_ANONYMOUSLY, ips: [127.0.0.1, ::1] } + - { path: "%sylius.security.admin_regex%/_partial", role: PUBLIC_ACCESS, ips: [127.0.0.1, ::1] } - { path: "%sylius.security.admin_regex%/_partial", role: ROLE_NO_ACCESS } - - { path: "%sylius.security.shop_regex%/_partial", role: IS_AUTHENTICATED_ANONYMOUSLY, ips: [127.0.0.1, ::1] } + - { path: "%sylius.security.shop_regex%/_partial", role: PUBLIC_ACCESS, ips: [127.0.0.1, ::1] } - { path: "%sylius.security.shop_regex%/_partial", role: ROLE_NO_ACCESS } - - { path: "%sylius.security.admin_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY } - - { path: "%sylius.security.shop_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY } + - { path: "%sylius.security.admin_regex%/login", role: PUBLIC_ACCESS } + - { path: "%sylius.security.shop_regex%/login", role: PUBLIC_ACCESS } - - { path: "%sylius.security.shop_regex%/register", role: IS_AUTHENTICATED_ANONYMOUSLY } - - { path: "%sylius.security.shop_regex%/verify", role: IS_AUTHENTICATED_ANONYMOUSLY } + - { path: "%sylius.security.shop_regex%/register", role: PUBLIC_ACCESS } + - { path: "%sylius.security.shop_regex%/verify", role: PUBLIC_ACCESS } - { path: "%sylius.security.admin_regex%", role: ROLE_ADMINISTRATION_ACCESS } - { path: "%sylius.security.shop_regex%/account", role: ROLE_USER } + - { path: "%sylius.security.new_api_admin_route%/reset-password-requests", role: PUBLIC_ACCESS } - { path: "%sylius.security.new_api_admin_regex%/.*", role: ROLE_API_ACCESS } - - { path: "%sylius.security.new_api_admin_route%/authentication-token", role: IS_AUTHENTICATED_ANONYMOUSLY } + - { path: "%sylius.security.new_api_admin_route%/authentication-token", role: PUBLIC_ACCESS } - { path: "%sylius.security.new_api_user_account_regex%/.*", role: ROLE_USER } - - { path: "%sylius.security.new_api_shop_route%/authentication-token", role: IS_AUTHENTICATED_ANONYMOUSLY } - - { path: "%sylius.security.new_api_shop_regex%/.*", role: IS_AUTHENTICATED_ANONYMOUSLY } + - { path: "%sylius.security.new_api_shop_route%/authentication-token", role: PUBLIC_ACCESS } + - { path: "%sylius.security.new_api_shop_regex%/.*", role: PUBLIC_ACCESS } diff --git a/tests/Application/config/packages/security_checker.yaml b/tests/Application/config/packages/security_checker.yaml deleted file mode 100644 index 0f9cf00..0000000 --- a/tests/Application/config/packages/security_checker.yaml +++ /dev/null @@ -1,9 +0,0 @@ -services: - SensioLabs\Security\SecurityChecker: - public: false - - SensioLabs\Security\Command\SecurityCheckerCommand: - arguments: ['@SensioLabs\Security\SecurityChecker'] - public: false - tags: - - { name: console.command, command: 'security:check' } diff --git a/tests/Application/config/packages/staging/swiftmailer.yaml b/tests/Application/config/packages/staging/swiftmailer.yaml deleted file mode 100644 index f438078..0000000 --- a/tests/Application/config/packages/staging/swiftmailer.yaml +++ /dev/null @@ -1,2 +0,0 @@ -swiftmailer: - disable_delivery: true diff --git a/tests/Application/config/packages/swiftmailer.yaml b/tests/Application/config/packages/swiftmailer.yaml deleted file mode 100644 index 3bab0d3..0000000 --- a/tests/Application/config/packages/swiftmailer.yaml +++ /dev/null @@ -1,2 +0,0 @@ -swiftmailer: - url: '%env(MAILER_URL)%' diff --git a/tests/Application/config/packages/test/framework.yaml b/tests/Application/config/packages/test/framework.yaml index 76d7e5e..fc1d3c1 100644 --- a/tests/Application/config/packages/test/framework.yaml +++ b/tests/Application/config/packages/test/framework.yaml @@ -1,4 +1,4 @@ framework: test: ~ session: - storage_id: session.storage.mock_file + storage_factory_id: session.storage.factory.mock_file diff --git a/tests/Application/config/packages/test/mailer.yaml b/tests/Application/config/packages/test/mailer.yaml new file mode 100644 index 0000000..52610d6 --- /dev/null +++ b/tests/Application/config/packages/test/mailer.yaml @@ -0,0 +1,5 @@ +framework: + cache: + pools: + test.mailer_pool: + adapter: cache.adapter.filesystem diff --git a/tests/Application/config/packages/test/security.yaml b/tests/Application/config/packages/test/security.yaml index 21cc377..4071d31 100644 --- a/tests/Application/config/packages/test/security.yaml +++ b/tests/Application/config/packages/test/security.yaml @@ -1,3 +1,6 @@ security: - encoders: - sha512: sha512 + password_hashers: + Sylius\Component\User\Model\UserInterface: + algorithm: argon2i + time_cost: 3 + memory_cost: 10 diff --git a/tests/Application/config/packages/test/swiftmailer.yaml b/tests/Application/config/packages/test/swiftmailer.yaml deleted file mode 100644 index c438f4b..0000000 --- a/tests/Application/config/packages/test/swiftmailer.yaml +++ /dev/null @@ -1,6 +0,0 @@ -swiftmailer: - disable_delivery: true - logging: true - spool: - type: file - path: "%kernel.cache_dir%/spool" diff --git a/tests/Application/config/packages/test_cached/framework.yaml b/tests/Application/config/packages/test_cached/framework.yaml index 76d7e5e..e9dd6ee 100644 --- a/tests/Application/config/packages/test_cached/framework.yaml +++ b/tests/Application/config/packages/test_cached/framework.yaml @@ -1,4 +1,2 @@ -framework: - test: ~ - session: - storage_id: session.storage.mock_file +imports: + - { resource: ../test/framework.yaml } diff --git a/tests/Application/config/packages/test_cached/mailer.yaml b/tests/Application/config/packages/test_cached/mailer.yaml new file mode 100644 index 0000000..16f3170 --- /dev/null +++ b/tests/Application/config/packages/test_cached/mailer.yaml @@ -0,0 +1,2 @@ +imports: + - { resource: "../test/mailer.yaml" } diff --git a/tests/Application/config/packages/test_cached/security.yaml b/tests/Application/config/packages/test_cached/security.yaml index 21cc377..76e9273 100644 --- a/tests/Application/config/packages/test_cached/security.yaml +++ b/tests/Application/config/packages/test_cached/security.yaml @@ -1,3 +1,2 @@ -security: - encoders: - sha512: sha512 +imports: + - { resource: ../test/security.yaml } diff --git a/tests/Application/config/packages/test_cached/swiftmailer.yaml b/tests/Application/config/packages/test_cached/swiftmailer.yaml deleted file mode 100644 index c438f4b..0000000 --- a/tests/Application/config/packages/test_cached/swiftmailer.yaml +++ /dev/null @@ -1,6 +0,0 @@ -swiftmailer: - disable_delivery: true - logging: true - spool: - type: file - path: "%kernel.cache_dir%/spool" diff --git a/tests/Application/config/packages/webpack_encore.yaml b/tests/Application/config/packages/webpack_encore.yaml new file mode 100644 index 0000000..9bee248 --- /dev/null +++ b/tests/Application/config/packages/webpack_encore.yaml @@ -0,0 +1,5 @@ +webpack_encore: + output_path: '%kernel.project_dir%/public/build/default' + builds: + shop: '%kernel.project_dir%/public/build/shop' + admin: '%kernel.project_dir%/public/build/admin' diff --git a/tests/Application/config/routes.yaml b/tests/Application/config/routes.yaml deleted file mode 100644 index e69de29..0000000 diff --git a/tests/Application/gulpfile.babel.js b/tests/Application/gulpfile.babel.js deleted file mode 100644 index 5920316..0000000 --- a/tests/Application/gulpfile.babel.js +++ /dev/null @@ -1,60 +0,0 @@ -import chug from 'gulp-chug'; -import gulp from 'gulp'; -import yargs from 'yargs'; - -const { argv } = yargs - .options({ - rootPath: { - description: ' path to public assets directory', - type: 'string', - requiresArg: true, - required: false, - }, - nodeModulesPath: { - description: ' path to node_modules directory', - type: 'string', - requiresArg: true, - required: false, - }, - }); - -const config = [ - '--rootPath', - argv.rootPath || '../../../../../../../tests/Application/public/assets', - '--nodeModulesPath', - argv.nodeModulesPath || '../../../../../../../tests/Application/node_modules', -]; - -export const buildAdmin = function buildAdmin() { - return gulp.src('../../vendor/sylius/sylius/src/Sylius/Bundle/AdminBundle/gulpfile.babel.js', { read: false }) - .pipe(chug({ args: config, tasks: 'build' })); -}; -buildAdmin.description = 'Build admin assets.'; - -export const watchAdmin = function watchAdmin() { - return gulp.src('../../vendor/sylius/sylius/src/Sylius/Bundle/AdminBundle/gulpfile.babel.js', { read: false }) - .pipe(chug({ args: config, tasks: 'watch' })); -}; -watchAdmin.description = 'Watch admin asset sources and rebuild on changes.'; - -export const buildShop = function buildShop() { - return gulp.src('../../vendor/sylius/sylius/src/Sylius/Bundle/ShopBundle/gulpfile.babel.js', { read: false }) - .pipe(chug({ args: config, tasks: 'build' })); -}; -buildShop.description = 'Build shop assets.'; - -export const watchShop = function watchShop() { - return gulp.src('../../vendor/sylius/sylius/src/Sylius/Bundle/ShopBundle/gulpfile.babel.js', { read: false }) - .pipe(chug({ args: config, tasks: 'watch' })); -}; -watchShop.description = 'Watch shop asset sources and rebuild on changes.'; - -export const build = gulp.parallel(buildAdmin, buildShop); -build.description = 'Build assets.'; - -gulp.task('admin', buildAdmin); -gulp.task('admin-watch', watchAdmin); -gulp.task('shop', buildShop); -gulp.task('shop-watch', watchShop); - -export default build; diff --git a/tests/Application/package.json b/tests/Application/package.json index b27949d..32ccdc4 100644 --- a/tests/Application/package.json +++ b/tests/Application/package.json @@ -1,53 +1,63 @@ { "dependencies": { - "babel-polyfill": "^6.26.0", - "chart.js": "^2.9.3", - "jquery": "^3.4.0", + "@babel/polyfill": "^7.0.0", + "chart.js": "^3.7.1", + "jquery": "^3.5.0", "jquery.dirtyforms": "^2.0.0", "lightbox2": "^2.9.0", "semantic-ui-css": "^2.2.0", "slick-carousel": "^1.8.1" }, "devDependencies": { - "@symfony/webpack-encore": "^0.28.0", - "babel-core": "^6.26.3", - "babel-plugin-external-helpers": "^6.22.0", - "babel-plugin-module-resolver": "^3.1.1", - "babel-plugin-transform-object-rest-spread": "^6.26.0", - "babel-preset-env": "^1.7.0", - "babel-register": "^6.26.0", + "@babel/core": "^7.0.0", + "@babel/plugin-external-helpers": "^7.0.0", + "@babel/plugin-proposal-object-rest-spread": "^7.18.9", + "@babel/preset-env": "^7.18.10", + "@babel/register": "^7.0.0", + "@rollup/plugin-babel": "^5.3.1", + "@rollup/plugin-commonjs": "^22.0.2", + "@rollup/plugin-inject": "^4.0.4", + "@rollup/plugin-node-resolve": "^13.3.0", + "@semantic-ui-react/css-patch": "^1.1.2", + "@symfony/webpack-encore": "^3.1.0", + "babel-plugin-fast-async": "^6.1.2", + "babel-plugin-module-resolver": "^4.1.0", "dedent": "^0.7.0", - "eslint": "^4.19.1", - "eslint-config-airbnb-base": "^12.1.0", - "eslint-import-resolver-babel-module": "^4.0.0", - "eslint-plugin-import": "^2.11.0", - "fast-async": "^6.3.7", - "gulp": "^4.0.0", - "gulp-chug": "^0.5", - "gulp-concat": "^2.6.0", - "gulp-debug": "^2.1.2", - "gulp-if": "^2.0.0", - "gulp-livereload": "^4.0.1", - "gulp-order": "^1.1.1", - "gulp-sass": "^4.0.1", - "gulp-sourcemaps": "^1.6.0", - "gulp-uglifycss": "^1.0.5", - "merge-stream": "^1.0.0", - "rollup": "^0.60.2", - "rollup-plugin-babel": "^3.0.4", - "rollup-plugin-commonjs": "^9.1.3", - "rollup-plugin-inject": "^2.0.0", - "rollup-plugin-node-resolve": "^3.3.0", - "rollup-plugin-uglify": "^4.0.0", - "sass-loader": "^7.0.1", - "upath": "^1.1.0", - "yargs": "^6.4.0" + "eslint": "^8.23.0", + "eslint-config-airbnb-base": "^15.0.0", + "eslint-import-resolver-babel-module": "^5.3.1", + "eslint-plugin-import": "^2.26.0", + "fast-async": "^6.3.8", + "gulp": "^4.0.2", + "gulp-chug": "^0.5.1", + "gulp-concat": "^2.6.1", + "gulp-debug": "^4.0.0", + "gulp-if": "^3.0.0", + "gulp-livereload": "^4.0.2", + "gulp-order": "^1.2.0", + "gulp-sass": "^5.1.0", + "gulp-sourcemaps": "^3.0.0", + "gulp-uglifycss": "^1.1.0", + "merge-stream": "^2.0.0", + "rollup": "^2.79.0", + "rollup-plugin-terser": "^7.0.2", + "sass": "^1.54.8", + "sass-loader": "^13.0.0", + "upath": "^2.0.1", + "yargs": "^17.5.1" }, + "engines": { + "node": "^14 || ^16 || ^18" + }, + "engineStrict": true, "scripts": { - "build": "gulp build", + "watch": "encore dev --watch", + "build": "encore dev", + "build:prod": "encore production", "gulp": "gulp build", "lint": "yarn lint:js", - "lint:js": "eslint gulpfile.babel.js" + "lint:js": "eslint gulpfile.babel.js src/Sylius/Bundle/AdminBundle/gulpfile.babel.js src/Sylius/Bundle/ShopBundle/gulpfile.babel.js src/Sylius/Bundle/UiBundle/Resources/private/js src/Sylius/Bundle/AdminBundle/Resources/private/js src/Sylius/Bundle/ShopBundle/Resources/private/js", + "postinstall": "semantic-ui-css-patch" }, "repository": { "type": "git", diff --git a/tests/Application/public/media/image/.gitignore b/tests/Application/public/media/image/.gitignore deleted file mode 100644 index e69de29..0000000 diff --git a/tests/Application/templates/bundles/SyliusAdminBundle/Layout/_logo.html.twig b/tests/Application/templates/bundles/SyliusAdminBundle/Layout/_logo.html.twig new file mode 100644 index 0000000..1d9fa7d --- /dev/null +++ b/tests/Application/templates/bundles/SyliusAdminBundle/Layout/_logo.html.twig @@ -0,0 +1,5 @@ + +
+ +
+
diff --git a/tests/Application/templates/bundles/SyliusAdminBundle/Security/_content.html.twig b/tests/Application/templates/bundles/SyliusAdminBundle/Security/_content.html.twig new file mode 100644 index 0000000..ce17621 --- /dev/null +++ b/tests/Application/templates/bundles/SyliusAdminBundle/Security/_content.html.twig @@ -0,0 +1,6 @@ +{% include '@SyliusUi/Security/_login.html.twig' + with { + 'action': path('sylius_admin_login_check'), + 'paths': {'logo': asset('build/admin/images/logo.png', 'admin')} +} +%} diff --git a/tests/Application/templates/bundles/SyliusAdminBundle/_scripts.html.twig b/tests/Application/templates/bundles/SyliusAdminBundle/_scripts.html.twig new file mode 100644 index 0000000..f5f9835 --- /dev/null +++ b/tests/Application/templates/bundles/SyliusAdminBundle/_scripts.html.twig @@ -0,0 +1 @@ +{{ encore_entry_script_tags('admin-entry', null, 'admin') }} diff --git a/tests/Application/templates/bundles/SyliusAdminBundle/_styles.html.twig b/tests/Application/templates/bundles/SyliusAdminBundle/_styles.html.twig new file mode 100644 index 0000000..a96144c --- /dev/null +++ b/tests/Application/templates/bundles/SyliusAdminBundle/_styles.html.twig @@ -0,0 +1 @@ +{{ encore_entry_link_tags('admin-entry', null, 'admin') }} diff --git a/tests/Application/templates/bundles/SyliusShopBundle/Homepage/_banner.html.twig b/tests/Application/templates/bundles/SyliusShopBundle/Homepage/_banner.html.twig new file mode 100644 index 0000000..8486493 --- /dev/null +++ b/tests/Application/templates/bundles/SyliusShopBundle/Homepage/_banner.html.twig @@ -0,0 +1,9 @@ +
+
+ {{ 'sylius.homepage.banner_content'|trans }} +
+
+
{{ 'sylius.homepage.banner_content'|trans }}
+ {{ 'sylius.homepage.banner_button'|trans }} +
+
diff --git a/tests/Application/templates/bundles/SyliusShopBundle/Layout/Header/_logo.html.twig b/tests/Application/templates/bundles/SyliusShopBundle/Layout/Header/_logo.html.twig new file mode 100644 index 0000000..84b8df5 --- /dev/null +++ b/tests/Application/templates/bundles/SyliusShopBundle/Layout/Header/_logo.html.twig @@ -0,0 +1,5 @@ + diff --git a/tests/Application/templates/bundles/SyliusShopBundle/_scripts.html.twig b/tests/Application/templates/bundles/SyliusShopBundle/_scripts.html.twig new file mode 100644 index 0000000..d1655bb --- /dev/null +++ b/tests/Application/templates/bundles/SyliusShopBundle/_scripts.html.twig @@ -0,0 +1 @@ +{{ encore_entry_script_tags('shop-entry', null, 'shop') }} diff --git a/tests/Application/templates/bundles/SyliusShopBundle/_styles.html.twig b/tests/Application/templates/bundles/SyliusShopBundle/_styles.html.twig new file mode 100644 index 0000000..fd2c7cb --- /dev/null +++ b/tests/Application/templates/bundles/SyliusShopBundle/_styles.html.twig @@ -0,0 +1 @@ +{{ encore_entry_link_tags('shop-entry', null, 'shop') }} diff --git a/tests/Application/webpack.config.js b/tests/Application/webpack.config.js index ba0308f..599e371 100644 --- a/tests/Application/webpack.config.js +++ b/tests/Application/webpack.config.js @@ -1,46 +1,48 @@ const path = require('path'); const Encore = require('@symfony/webpack-encore'); -const syliusBundles = path.resolve(__dirname, 'vendor/sylius/sylius/src/Sylius/Bundle/'); +const syliusBundles = path.resolve(__dirname, '../../vendor/sylius/sylius/src/Sylius/Bundle/'); const uiBundleScripts = path.resolve(syliusBundles, 'UiBundle/Resources/private/js/'); const uiBundleResources = path.resolve(syliusBundles, 'UiBundle/Resources/private/'); // Shop config Encore - .setOutputPath('public/build/shop/') - .setPublicPath('/build/shop') - .addEntry('shop-entry', './assets/shop/entry.js') - .disableSingleRuntimeChunk() - .cleanupOutputBeforeBuild() - .enableSourceMaps(!Encore.isProduction()) - .enableVersioning(Encore.isProduction()) - .enableSassLoader(); + .setOutputPath('public/build/shop/') + .setPublicPath('/build/shop') + .addEntry('shop-entry', './assets/shop/entry.js') + .disableSingleRuntimeChunk() + .cleanupOutputBeforeBuild() + .enableSourceMaps(!Encore.isProduction()) + .enableVersioning(Encore.isProduction()) + .enableSassLoader(); const shopConfig = Encore.getWebpackConfig(); shopConfig.resolve.alias['sylius/ui'] = uiBundleScripts; shopConfig.resolve.alias['sylius/ui-resources'] = uiBundleResources; shopConfig.resolve.alias['sylius/bundle'] = syliusBundles; +shopConfig.resolve.alias['chart.js/dist/Chart.min'] = path.resolve(__dirname, 'node_modules/chart.js/dist/chart.min.js'); shopConfig.name = 'shop'; Encore.reset(); // Admin config Encore - .setOutputPath('public/build/admin/') - .setPublicPath('/build/admin') - .addEntry('admin-entry', './assets/admin/entry.js') - .disableSingleRuntimeChunk() - .cleanupOutputBeforeBuild() - .enableSourceMaps(!Encore.isProduction()) - .enableVersioning(Encore.isProduction()) - .enableSassLoader(); + .setOutputPath('public/build/admin/') + .setPublicPath('/build/admin') + .addEntry('admin-entry', './assets/admin/entry.js') + .disableSingleRuntimeChunk() + .cleanupOutputBeforeBuild() + .enableSourceMaps(!Encore.isProduction()) + .enableVersioning(Encore.isProduction()) + .enableSassLoader(); const adminConfig = Encore.getWebpackConfig(); adminConfig.resolve.alias['sylius/ui'] = uiBundleScripts; adminConfig.resolve.alias['sylius/ui-resources'] = uiBundleResources; adminConfig.resolve.alias['sylius/bundle'] = syliusBundles; +adminConfig.resolve.alias['chart.js/dist/Chart.min'] = path.resolve(__dirname, 'node_modules/chart.js/dist/chart.min.js'); adminConfig.externals = Object.assign({}, adminConfig.externals, { window: 'window', document: 'document' }); adminConfig.name = 'admin';