From 6d88d7ea5295cbbdaaf8f80becd74398470855f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Thu, 14 Feb 2019 15:14:24 +0100 Subject: [PATCH 1/4] Limit number of screenshots to 10 for a single job (#358) --- behat.yml.dist | 3 +++ 1 file changed, 3 insertions(+) diff --git a/behat.yml.dist b/behat.yml.dist index 9b4701b408..c1bf520d62 100644 --- a/behat.yml.dist +++ b/behat.yml.dist @@ -30,8 +30,11 @@ default: active_image_drivers: cloudinary image_drivers: cloudinary: + screenshot_directory: /tmp/behat-screenshot/ cloud_name: ezplatformtravis preset: ezplatform + mode: normal + limit: 10 suites: ~ From 0ebec465311f011bdcb0c82afa59b6b43547585c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Thu, 14 Feb 2019 21:18:03 +0100 Subject: [PATCH 2/4] [Composer] Increae Behat Cloudinary Screenshot version (#359) --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index a80b586dc0..2d8ec4bb30 100644 --- a/composer.json +++ b/composer.json @@ -62,7 +62,7 @@ "behat/mink-selenium2-driver": "^1.3.1", "behat/symfony2-extension": "^2.1.5", "bex/behat-screenshot": "^1.2.7", - "ezsystems/behat-screenshot-image-driver-cloudinary": "~1.0.0@dev", + "ezsystems/behat-screenshot-image-driver-cloudinary": "^1.1.0@dev", "ezsystems/behatbundle": "~6.5.4@dev", "phpunit/phpunit": "^6.5.13", "sensio/generator-bundle": "^3.1.7", From 72cde200a8a837d9b16597f9dfd4aceed7bdebf9 Mon Sep 17 00:00:00 2001 From: dew326 Date: Wed, 20 Feb 2019 11:31:19 +0100 Subject: [PATCH 3/4] EZP-30035: Install Webpack Encore (#345) * Webpack Encore * change path web/js to web/assets/build * update to new approach with preloading configs from bundle * changed root_dir to project_dir * added json_manifest * changed externals * added ez entrypoint * fixed multiple configuration * renamed ez to ezplatform * keep build folders, ignore compiled files * fix extra line in gitignore * added node_modules and yarn.lock to .gitignore * EZP-30035: Install eZ Platform encore bundle from ezplatform-core * Add Node to Docker images. Cache Yarn * Use node in app-dev container * [Docker] Simply set PHP_IMAGE to Node * [Docker] Specify Node flavour where needed * moved translations to assets/translation --- .gitignore | 7 ++++++ .travis.yml | 1 + app/AppKernel.php | 2 ++ app/config/config.yml | 11 ++++++++- composer.json | 8 +++++-- doc/docker/Dockerfile-app | 2 +- doc/docker/Dockerfile-nginx | 2 +- doc/docker/base-dev.yml | 2 +- ez.webpack.config.js | 31 ++++++++++++++++++++++++ ez.webpack.config.manager.js | 35 ++++++++++++++++++++++++++++ package.json | 8 +++++++ web/assets/build/.gitkeep | 0 web/assets/ezplatform/build/.gitkeep | 0 webpack.config.js | 21 +++++++++++++++++ 14 files changed, 124 insertions(+), 6 deletions(-) create mode 100644 ez.webpack.config.js create mode 100644 ez.webpack.config.manager.js create mode 100644 package.json create mode 100644 web/assets/build/.gitkeep create mode 100644 web/assets/ezplatform/build/.gitkeep create mode 100644 webpack.config.js diff --git a/.gitignore b/.gitignore index e117bf5e4b..ea2671ccd9 100644 --- a/.gitignore +++ b/.gitignore @@ -34,6 +34,12 @@ !var/SymfonyRequirements.php /vendor/ /web/bundles/ +/web/assets/translations/* +/web/assets/build/* +!web/assets/build/.gitkeep +/web/assets/ezplatform/build/* +!/web/assets/ezplatform/build/.gitkeep +/node_modules/ .php~ @@ -57,6 +63,7 @@ web/fonts/ composer.phar composer.lock +yarn.lock .buildpath .project .settings/ diff --git a/.travis.yml b/.travis.yml index e701ebc5bc..e5a46f8dd9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,7 @@ services: - docker cache: + yarn: true directories: - $HOME/.composer/cache/files diff --git a/app/AppKernel.php b/app/AppKernel.php index 3aece1af48..ec07f05591 100644 --- a/app/AppKernel.php +++ b/app/AppKernel.php @@ -15,6 +15,7 @@ public function registerBundles() new Symfony\Bundle\MonologBundle\MonologBundle(), new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(), new Symfony\Bundle\AsseticBundle\AsseticBundle(), + new Symfony\WebpackEncoreBundle\WebpackEncoreBundle(), new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(), new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(), // Dependencies @@ -45,6 +46,7 @@ public function registerBundles() new EzSystems\EzPlatformAdminUiModulesBundle\EzPlatformAdminUiModulesBundle(), new EzSystems\EzPlatformAdminUiAssetsBundle\EzPlatformAdminUiAssetsBundle(), new EzSystems\EzPlatformCronBundle\EzPlatformCronBundle(), + new EzSystems\EzPlatformEncoreBundle\EzSystemsEzPlatformEncoreBundle(), // Application new AppBundle\AppBundle(), ]; diff --git a/app/config/config.yml b/app/config/config.yml index 287839f80d..425eb75bdf 100644 --- a/app/config/config.yml +++ b/app/config/config.yml @@ -72,7 +72,10 @@ framework: # Further reading on sessions: http://doc.ezplatform.com/en/latest/guide/sessions/ fragments: ~ http_method_override: true - assets: true + assets: + packages: + ezplatform: + json_manifest_path: '%kernel.project_dir%/web/assets/ezplatform/build/manifest.json' php_errors: log: true @@ -93,6 +96,12 @@ assetic: formatter: 'Leafo\ScssPhp\Formatter\Crunched' import_paths: ['%kernel.project_dir%/web/'] +# Webpack Encore Configuration +webpack_encore: + output_path: "%kernel.project_dir%/web/assets/build" + builds: + ezplatform: "%kernel.project_dir%/web/assets/ezplatform/build" + # Swiftmailer Configuration swiftmailer: transport: '%mailer_transport%' diff --git a/composer.json b/composer.json index 51cfdad107..713db61a16 100644 --- a/composer.json +++ b/composer.json @@ -31,6 +31,7 @@ "ezsystems/ezplatform-admin-ui": "^1.5@dev", "ezsystems/ezplatform-admin-ui-assets": "^3.1@dev", "ezsystems/ezplatform-admin-ui-modules": "^1.5@dev", + "ezsystems/ezplatform-core": "^1.0@dev", "ezsystems/ezplatform-cron": "^2.0@dev", "ezsystems/ezplatform-design-engine": "^2.0@dev", "ezsystems/ezplatform-http-cache": "~0.8@dev", @@ -50,6 +51,7 @@ "symfony/swiftmailer-bundle": "^3.2.4", "symfony/symfony": "^3.4.18", "symfony/thanks": "^1.1.0", + "symfony/webpack-encore-bundle": "^1.0.0", "twig/extensions": "^1.5.3", "twig/twig": "^2.5", "white-october/pagerfanta-bundle": "^1.2.2", @@ -79,9 +81,11 @@ "eZ\\Bundle\\EzPublishCoreBundle\\Composer\\ScriptHandler::clearCache", "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets", "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile", - "@php bin/console bazinga:js-translation:dump --merge-domains", + "@php bin/console bazinga:js-translation:dump 'web/assets' --merge-domains", "@php bin/console assetic:dump", - "@php bin/security-checker security:check" + "@php bin/security-checker security:check", + "yarn install", + "yarn encore dev" ], "post-install-cmd": [ "@symfony-scripts" diff --git a/doc/docker/Dockerfile-app b/doc/docker/Dockerfile-app index ffad4f590d..e2303bff43 100644 --- a/doc/docker/Dockerfile-app +++ b/doc/docker/Dockerfile-app @@ -1,5 +1,5 @@ ARG PHP_IMAGE=ezsystems/php:7.2-v1 -FROM ${PHP_IMAGE} as builder +FROM ${PHP_IMAGE}-node as builder # This is prod image (for dev use just mount your application as host volume into php image we extend here) ENV SYMFONY_ENV=prod diff --git a/doc/docker/Dockerfile-nginx b/doc/docker/Dockerfile-nginx index 181fc10d13..e40a2ce136 100644 --- a/doc/docker/Dockerfile-nginx +++ b/doc/docker/Dockerfile-nginx @@ -1,5 +1,5 @@ ARG PHP_IMAGE=ezsystems/php:7.2-v1 -FROM ${PHP_IMAGE} as web-build +FROM ${PHP_IMAGE}-node as web-build ENV SYMFONY_ENV=prod diff --git a/doc/docker/base-dev.yml b/doc/docker/base-dev.yml index 3b910a1ee4..8aa0b523ec 100644 --- a/doc/docker/base-dev.yml +++ b/doc/docker/base-dev.yml @@ -3,7 +3,7 @@ version: '3.3' services: app: - image: ${PHP_IMAGE} + image: ${PHP_IMAGE}-node volumes: - ${COMPOSE_DIR}/../../:/var/www:cached - ${COMPOSER_HOME}:/root/.composer:cached diff --git a/ez.webpack.config.js b/ez.webpack.config.js new file mode 100644 index 0000000000..0dea31f8d2 --- /dev/null +++ b/ez.webpack.config.js @@ -0,0 +1,31 @@ +const path = require('path'); +const bundles = require('./var/encore/ez.config.js'); + +module.exports = (Encore) => { + Encore.setOutputPath('web/assets/ezplatform/build') + .setPublicPath('/assets/ezplatform/build') + .addExternals({ + react: 'React', + 'react-dom': 'ReactDOM', + jquery: 'jQuery', + moment: 'moment', + 'popper.js': 'Popper', + alloyeditor: 'AlloyEditor', + 'prop-types': 'PropTypes', + }) + .enableSassLoader() + .enableReactPreset() + .enableSingleRuntimeChunk(); + + bundles.forEach((configPath) => { + const addEntries = require(configPath); + + addEntries(Encore); + }); + + const eZConfig = Encore.getWebpackConfig(); + + eZConfig.name = 'ezplatform'; + + return eZConfig; +}; diff --git a/ez.webpack.config.manager.js b/ez.webpack.config.manager.js new file mode 100644 index 0000000000..e22e522f10 --- /dev/null +++ b/ez.webpack.config.manager.js @@ -0,0 +1,35 @@ +const findItems = (eZConfig, entryName) => { + const items = eZConfig.entry[entryName]; + + if (!items) { + throw new Error(`Couldn't find entry with name: "${entryName}". Please check if there is a typo in the name.`); + } + + return items; +}; +const replace = ({ eZConfig, entryName, itemToReplace, newItem }) => { + const items = findItems(eZConfig, entryName); + const indexToReplace = items.indexOf(itemToReplace); + + if (indexToReplace < 0) { + throw new Error(`Couldn't find item "${itemToReplace}" in entry "${entryName}". Please check if there is a typo in the name.`); + } + + items[indexToReplace] = newItem; +}; +const remove = ({ eZConfig, entryName, itemsToRemove }) => { + const items = findItems(eZConfig, entryName); + + eZConfig.entry[entryName] = items.filter((item) => !itemsToRemove.includes(item)); +}; +const add = ({ eZConfig, entryName, newItems }) => { + const items = findItems(eZConfig, entryName); + + eZConfig.entry[entryName] = [...items, ...newItems]; +}; + +module.exports = { + replace, + remove, + add +}; diff --git a/package.json b/package.json new file mode 100644 index 0000000000..ea661ba4fe --- /dev/null +++ b/package.json @@ -0,0 +1,8 @@ +{ + "devDependencies": { + "@babel/preset-react": "^7.0.0", + "@symfony/webpack-encore": "^0.22.4", + "node-sass": "^4.11.0", + "sass-loader": "^7.0.1" + } +} diff --git a/web/assets/build/.gitkeep b/web/assets/build/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/web/assets/ezplatform/build/.gitkeep b/web/assets/ezplatform/build/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 0000000000..63d44ae9a0 --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,21 @@ +const Encore = require('@symfony/webpack-encore'); +const path = require('path'); +const getEzConfig = require('./ez.webpack.config.js'); +const eZConfigManager = require('./ez.webpack.config.manager.js'); +const eZConfig = getEzConfig(Encore); + +Encore.reset(); +Encore.setOutputPath('web/assets/build') + .setPublicPath('/assets/build') + .enableSassLoader() + .enableReactPreset() + .enableSingleRuntimeChunk(); + +// Put your config here. + +// uncomment the two lines below, if you have your own Encore configuration for your project +// const projectConfig = Encore.getWebpackConfig(); +// module.exports = [ eZConfig, projectConfig ]; + +// comment-out this line if you've uncommented the above lines +module.exports = eZConfig; From f3e880102847bd68b8e948cc9c9fd0c4f0d63c5a Mon Sep 17 00:00:00 2001 From: sunpietro Date: Wed, 20 Feb 2019 21:18:25 +0100 Subject: [PATCH 4/4] Update composer.json (#355) --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 713db61a16..938fce94cf 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,7 @@ "doctrine/orm": "^2.6.3", "ezsystems/ez-support-tools": "^0.2@dev", "ezsystems/ezplatform-admin-ui": "^1.5@dev", - "ezsystems/ezplatform-admin-ui-assets": "^3.1@dev", + "ezsystems/ezplatform-admin-ui-assets": "^4.0", "ezsystems/ezplatform-admin-ui-modules": "^1.5@dev", "ezsystems/ezplatform-core": "^1.0@dev", "ezsystems/ezplatform-cron": "^2.0@dev",