Commit ae5819b3 authored by Felix Herrmann's avatar Felix Herrmann
Browse files

Merge branch 'breaking/multilingual-frontend' into 'master'

Breaking/multilingual frontend

See merge request shopware/plugins/RicoDynamicFAQ!26
parents 59cc4f78 029b9e7f
version: '2.3'
services:
#======================================================
# Build
#======================================================
build-php:
image: edbizarro/gitlab-ci-pipeline-php:${PHP_VERSION}-alpine
volumes:
- ${ROOT_DIR}:${ROOT_DIR}
working_dir: ${ROOT_DIR}
command: >
/bin/sh -c "
composer install;
"
#======================================================
# Build
#======================================================
build-js:
image: node:alpine
volumes:
- ${ROOT_DIR}:${ROOT_DIR}
working_dir: ${ROOT_DIR}
command: >
/bin/sh -c "
npm i ./.ci
"
#======================================================
# Lint PHP
#======================================================
lint:
image: php:${PHP_VERSION}-alpine
volumes:
- ${ROOT_DIR}:${ROOT_DIR}
working_dir: ${ROOT_DIR}
command: >
/bin/sh -c "
if find ./src/ -type f -name '*.php' -exec php -l {} \; | grep \"Parsing error\"; then exit 1; fi
"
#======================================================
# Quality PHP
#======================================================
quality-php:
image: php:${PHP_VERSION}-alpine
volumes:
- ${ROOT_DIR}:${ROOT_DIR}
working_dir: ${ROOT_DIR}
command: >
/bin/sh -c "
echo \"Running php-cs-fixer...\";
vendor/bin/php-cs-fixer fix --dry-run --diff --allow-risky=yes
"
#======================================================
# Quality JS
#======================================================
quality-js:
image: node:alpine
volumes:
- ${ROOT_DIR}:${ROOT_DIR}
working_dir: ${ROOT_DIR}
command: >
/bin/sh -c "
echo \"Running eslint...\";
node_modules/eslint/bin/eslint.js .
echo \"Running jshint...\";
node_modules/jshint/bin/jshint --verbose .
"
......@@ -12,3 +12,4 @@
"less": "^3.9.0"
}
}
#!/usr/bin/env bash
# Function to write a .env file in Build/docker
# This is read by docker-compose and vars defined here are
# used in .ci/docker/docker-compose.yml
# Function to write a .env file in Build/testing-docker
setUpDockerComposeDotEnv() {
[ -e .env ] && rm .env
echo "TEST_FILE=${TEST_FILE}" >>.env
echo "ROOT_DIR=${ROOT_DIR}" >>.env
echo "PHP_VERSION=${PHP_VERSION}" >>.env
}
# Function to get the real path on mac os.
realpath() {
if ! pushd $1 &>/dev/null; then
pushd ${1##*/} &>/dev/null
echo $(pwd -P)/${1%/*}
else
pwd -P
fi
popd >/dev/null
}
# Load help text into $HELP
read -r -d '' HELP <<EOF
Extension test runner. Execute unit test suite and some other details.
Usage: $0 [options] [file]
Options:
-s <...>
Specifies which test suite to run
- build: Builds the project (composer)
- lint: Lints the php files
- quality-php: executes code quality checks (php-cs-fixer)
- quality-js: executes code quality checks (jshint, eslint)
-p <7.1>
Specifies the PHP minor version to be used
- 7.1 (default): use PHP 7.1
-h
Show this help.
Examples:
# Run unit tests
.ci/scripts/console.sh -s build
EOF
# Test if docker-compose exists, else exit out with error
if ! type "docker-compose" >/dev/null; then
echo "This script relies on docker and docker-compose. Please install" >&2
exit 1
fi
# Go to the directory this script is located, so everything else is relative
# to this dir, no matter from where this script is called.
THIS_SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
cd "$THIS_SCRIPT_DIR" || exit 1
# Go to directory that contains the local docker-compose.yml file
cd ../docker || exit 1
# Option defaults
ROOT_DIR=$(realpath $PWD"/../../")
TEST_SUITE="build"
PHP_VERSION="7.1"
# Option parsing
# Reset in case getopts has been used previously in the shell
OPTIND=1
# Array for invalid options
INVALID_OPTIONS=()
# Simple option parsing based on getopts (! not getopt)
while getopts ":s:d:p:e:xy:huv" OPT; do
case ${OPT} in
s)
TEST_SUITE=${OPTARG}
;;
p)
PHP_VERSION=${OPTARG}
;;
h)
echo "${HELP}"
exit 0
;;
\?)
INVALID_OPTIONS+=(${OPTARG})
;;
:)
INVALID_OPTIONS+=(${OPTARG})
;;
esac
done
# Exit on invalid options
if [ ${#INVALID_OPTIONS[@]} -ne 0 ]; then
echo "Invalid option(s):" >&2
for I in "${INVALID_OPTIONS[@]}"; do
echo "-"${I} >&2
done
echo >&2
echo "${HELP}" >&2
exit 1
fi
# Set $1 to first mass argument, this is the optional test file or test directory to execute
shift $((OPTIND - 1))
if [ -n "${1}" ]; then
TEST_FILE="${ROOT_DIR}/${1}"
fi
# Suite execution
case ${TEST_SUITE} in
build-php)
setUpDockerComposeDotEnv
docker-compose run build-php
SUITE_EXIT_CODE=$?
docker-compose down
;;
build-js)
setUpDockerComposeDotEnv
docker-compose run build-js
SUITE_EXIT_CODE=$?
docker-compose down
;;
lint)
setUpDockerComposeDotEnv
docker-compose run lint
SUITE_EXIT_CODE=$?
docker-compose down
;;
quality-php)
setUpDockerComposeDotEnv
docker-compose run quality-php
SUITE_EXIT_CODE=$?
docker-compose down
;;
quality-js)
setUpDockerComposeDotEnv
docker-compose run quality-js
SUITE_EXIT_CODE=$?
docker-compose down
;;
*)
echo "Invalid -s option argument ${TEST_SUITE}" >&2
echo >&2
echo "${HELP}" >&2
exit 1
;;
esac
exit $SUITE_EXIT_CODE
; top-most EditorConfig file
root = true
; Unix-style newlines
[*]
charset = utf-8
end_of_line = LF
insert_final_newline = true
trim_trailing_whitespace = true
[*.{php, html}]
indent_style = space
indent_size = 4
max_line_length = 120
[*.js]
indent_style = space
indent_size = 2
max_line_length = 120
[*.md]
max_line_length = 120
[COMMIT_EDITMSG]
max_line_length = 0
vendor/
node_modules/
......@@ -3,7 +3,7 @@ module.exports = {
'root': true,
'env': {
'browser': true,
'jquery': true,
'jquery': true
},
'globals': {
'jQuery': true,
......@@ -13,19 +13,19 @@ module.exports = {
'Modernizr': true,
'Overlay': true,
'Shopware': true,
'Ext': true,
'Ext': true
},
'rules': {
'arrow-parens': 0,
'space-before-function-paren': 0,
'keyword-spacing': [
'warn',
'warn'
],
'padded-blocks': [
'warn',
'warn'
],
'space-in-parens': [
'warn',
'warn'
],
'generator-star-spacing': 0,
'no-shadow-restricted-names': 0,
......@@ -33,14 +33,14 @@ module.exports = {
'no-debugger': 0,
'semi': [
'error',
'always',
'always'
],
'one-var': 0,
'indent': [
'error',
2,
{ 'SwitchCase': 1 },
{ 'SwitchCase': 1 }
],
'standard/no-callback-literal': 0,
},
}
'standard/no-callback-literal': 0
}
};
......@@ -4,4 +4,9 @@ composer.lock
Build/testing-docker/.env
Build/testing-docker/.database
.php_cs.cache
qs.sh
\ No newline at end of file
qs.sh
.database/
.env
vendor/
node_modules/
package-lock.json
#region templates
.debug: &debug
image: debian:jessie-slim
stage: debug
dependencies:
- composer-base
before_script:
- mkdir -p debug_logs
artifacts:
name: ${CI_COMMIT_REF_SLUG}-debug_check
expire_in: 2h
when: on_failure
paths:
- debug_logs
image: debian:jessie-slim
stage: debug
dependencies:
- composer-base
before_script:
- mkdir -p debug_logs
artifacts:
name: ${CI_COMMIT_REF_SLUG}-debug_check
expire_in: 2h
when: on_failure
paths:
- debug_logs
#endregion
stages:
- build
- debug
- lint
- quality
- build
- debug
- lint
- quality
#region base
composer-base:
stage: build
image: composer:latest
script:
- composer update --no-interaction --ignore-platform-reqs --no-scripts --with-dependencies
artifacts:
name: ${CI_COMMIT_REF_SLUG}-composer
expire_in: 2h
paths:
- vendor
- composer.lock
cache:
key: ${CI_COMMIT_REF_SLUG}-composer
paths:
- vendor
- composer.lock
stage: build
image: composer:latest
script:
- composer update --no-interaction --ignore-platform-reqs --no-scripts --with-dependencies
artifacts:
name: ${CI_COMMIT_REF_SLUG}-composer
expire_in: 2h
paths:
- vendor
- composer.lock
cache:
key: ${CI_COMMIT_REF_SLUG}-composer
paths:
- vendor
- composer.lock
node-base:
image: node:alpine
stage: build
script:
- npm i ./.ci
artifacts:
name: ${CI_COMMIT_REF_SLUG}-composer
expire_in: 2h
paths:
- node_modules
cache:
key: ${CI_COMMIT_REF_SLUG}-node
policy: push
paths:
- node_modules
- package-lock.json
image: node:alpine
stage: build
script:
- npm i ./.ci
artifacts:
name: ${CI_COMMIT_REF_SLUG}-composer
expire_in: 2h
paths:
- node_modules
cache:
key: ${CI_COMMIT_REF_SLUG}-node
policy: push
paths:
- node_modules
- package-lock.json
#endregion
#region DEBUG
smarty-debug:
<<: *debug
script:
- grep -r -i --include \*.tpl "{debug}" . > debug_logs/smarty_debug.txt || true
- cat debug_logs/smarty_debug.txt
- if (($(wc -l debug_logs/smarty_debug.txt | awk '{print $1}' ) > 0)); then exit "1"; fi
<<: *debug
script:
- grep -r -i --exclude-dir=vendor --include \*.tpl "{debug}" . > debug_logs/smarty_debug.txt || true
- cat debug_logs/smarty_debug.txt
- if (($(wc -l debug_logs/smarty_debug.txt | awk '{print $1}' ) > 0)); then exit "1"; fi
js-debug:
<<: *debug
script:
- grep -r -i --include \*.js "window.console.log" . > debug_logs/js_debug.txt || true
- cat debug_logs/js_debug.txt
- if (($(wc -l debug_logs/js_debug.txt | awk '{print $1}' ) > 0)); then exit "1"; fi
<<: *debug
script:
- grep -r -i --exclude-dir=vendor --include \*.js "window.console.log" . > debug_logs/js_debug.txt || true
- cat debug_logs/js_debug.txt
- if (($(wc -l debug_logs/js_debug.txt | awk '{print $1}' ) > 0)); then exit "1"; fi
php-debug:
<<: *debug
script:
- grep -r -i --include \*.php "var_dump" . > debug_logs/php_debug.txt || true
- grep -r -i --include \*.php "\\Kint::dump" . >> debug_logs/php_debug.txt || true
- cat debug_logs/php_debug.txt
- if (($(wc -l debug_logs/php_debug.txt | awk '{print $1}' ) > 0)); then exit "1"; fi
<<: *debug
script:
- grep -r -i --exclude-dir=vendor --include \*.php "var_dump" . > debug_logs/php_debug.txt || true
- grep -r -i --exclude-dir=vendor --include \*.php "\\Kint::dump" . >> debug_logs/php_debug.txt || true
- cat debug_logs/php_debug.txt
- if (($(wc -l debug_logs/php_debug.txt | awk '{print $1}' ) > 0)); then exit "1"; fi
#endregion
#region lint
js-hint:
image: node:alpine
stage: lint
dependencies:
- node-base
script:
- node_modules/jshint/bin/jshint --verbose custom/project
image: node:alpine
stage: lint
dependencies:
- node-base
script:
- node_modules/jshint/bin/jshint --verbose .
php-lint:
stage: lint
image: php:7.2-alpine
script:
- if find . -type f -name '*.php' -and -not -path vendor -exec php -l {} \; | grep "Parsing error"; then exit 1; fi
stage: lint
image: php:7.2-alpine
script:
- if find . -type f -name '*.php' -and -not -path vendor -exec php -l {} \; | grep "Parsing error"; then exit 1; fi
#endregion
#region codequality
js-lint:
image: node:alpine
stage: quality
dependencies:
- node-base
script:
- node_modules/eslint/bin/eslint.js .
image: node:alpine
stage: quality
dependencies:
- node-base
script:
- node_modules/eslint/bin/eslint.js .
php-cs:
stage: quality
image: ekreative/php-cs-fixer:2
dependencies:
- composer-base
script:
- php-cs-fixer fix --config=".php_cs" --format="json" --dry-run .
stage: quality
image: ekreative/php-cs-fixer:2
dependencies:
- composer-base
script:
- php-cs-fixer fix --config=".php_cs" --format="json" --dry-run --allow-risky=yes .
#endregion
vendor/
node_modules/
......@@ -2,24 +2,47 @@
$finder = PhpCsFixer\Finder::create()
->in(__DIR__)
->exclude(__DIR__. '/vendor/');
->exclude(__DIR__ . '/vendor/');
$header = <<<EOF
This file is part of the "RicoDynamicFaq" plugin for shopware.
@package: RicoDynamicFaq
@copyright: (c) 2019 Wolf Utz <utz@riconet.de>, Hees riconet GmbH
@license: For the full copyright and license information,
please read the LICENSE.txt file that was distributed with this source code.
MIT License
Copyright (c) 2020 PSVneo
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
EOF;
return PhpCsFixer\Config::create()
->setUsingCache(false)
->setRules([
'@PSR1' => true,
'@PSR2' => true,
'@Symfony' => true,
'header_comment' => ['header' => $header, 'separate' => 'bottom', 'commentType' => 'PHPDoc'],
'header_comment' => [
'header' => $header,
'location' => 'after_open',
'separate' => 'both',
'commentType' => 'PHPDoc',
],
'no_useless_else' => true,
'no_useless_return' => true,
'no_unused_imports' => true,
'ordered_class_elements' => true,
'ordered_imports' => true,
'phpdoc_order' => true,
......@@ -28,6 +51,13 @@ return PhpCsFixer\Config::create()
'concat_space' => ['spacing' => 'one'],
'array_syntax' => ['syntax' => 'short'],
'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false],
'declare_strict_types' => true,
'psr4' => true,
'no_php4_constructor' => true,
'no_short_echo_tag' => true,
'semicolon_after_instruction' => true,
'align_multiline_comment' => true,
'general_phpdoc_annotation_remove' => ['annotations' => ["author", "package"]],
'phpdoc_add_missing_param_annotation' => ['only_untyped' => false],
])
->setFinder($finder)
;
->setFinder($finder);
\ No newline at end of file
<?php
/**
* This file is part of the "RicoDynamicFaq" plugin for shopware.
* @package: RicoDynamicFaq
* @copyright: (c) 2019 Wolf Utz <utz@riconet.de>, Hees riconet GmbH
* @license: For the full copyright and license information,
* please read the LICENSE.txt file that was distributed with this source code.
* MIT License
*
* Copyright (c) 2020 PSVneo
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
declare(strict_types=1);
namespace RicoDynamicFaq\Components\Forms;
use RicoDynamicFaq\Models\Question;
......@@ -60,7 +79,7 @@ class QuestionForm extends AbstractType
],
'required' => true,
]);
$builder->add('body', TextType::class, [
$builder->add('questionText', TextType::class, [
'constraints' => [
new NotBlank(['message' => $this->getSnippet('QuestionFormErrorEmptyBody')]),
],
......