first commit

This commit is contained in:
2025-08-02 16:30:27 +02:00
commit 23646bfcee
14851 changed files with 1750626 additions and 0 deletions

47
bin/console Normal file
View File

@@ -0,0 +1,47 @@
#!/usr/bin/env php
<?php
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\ErrorHandler\Debug;
// if you don't want to setup permissions the proper way, just uncomment the following PHP line
// read http://symfony.com/doc/current/setup.html#checking-symfony-application-configuration-and-setup
// for more information
//umask(0000);
if (!file_exists('./include/config.php') && !file_exists('./config/config.php')) {
chdir('/vagrant/home/shop');
}
// Detect new components app - Symfony 6
if (file_exists('./config/config.yaml')) {
require_once './vendor/autoload_runtime.php';
return function (array $context): Application {
ini_set('memory_limit', '1G');
$kernel = new \Shop\Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
return new Application($kernel);
};
}
set_time_limit(0);
ini_set('memory_limit', '1G');
ini_set('output_buffering', 'Off');
/** @var Composer\Autoload\ClassLoader $loader */
$loader = require './app/autoload.php';
$input = new ArgvInput();
$env = $input->getParameterOption(['--env', '-e'], getenv('SYMFONY_ENV') ?: 'dev');
$debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption(['--no-debug', '']) && $env !== 'prod';
if ($debug) {
Debug::enable();
}
$kernel = new AppKernel($env, $debug);
$application = new Application($kernel);
$application->run($input);

View File

@@ -0,0 +1,53 @@
#!/usr/bin/env bash
[[ -z "$DEVELOPMENT" ]] && export DEVELOPMENT=1
[[ -z "$SYMFONY_ENV" ]] && export SYMFONY_ENV=prod
[[ -z "$CONTAINER_DIR" ]] && export CONTAINER_DIR=../cache
[[ -z "$VIRTUAL_HOST" ]] && export VIRTUAL_HOST=frontend
# Remove global $dbcfg loading -> do not depend on mariadb container
FILE_PATH=/var/www/engine/web/common.php
LINE=$(cat $FILE_PATH | grep -n '^\$dbcfg' | cut -d':' -f1)
sed -i "${LINE}d" $FILE_PATH
# Remove loading of $dbcfg in RequestListener::isShopClosed
FILE_PATH=/var/www/engine/bundles/KupShop/KupShopBundle/EventListener/RequestListener.php
LINE=$(cat $FILE_PATH | grep -n 'function checkShopClosed' | cut -d':' -f1)
LINE=$(($LINE + 1))
sed -i "${LINE}a return false\;" $FILE_PATH
# Remove request listeners touching database
rm /var/www/engine/bundles/KupShop/KupShopBundle/EventListener/BlackfireRequestSubscriber.php
rm /var/www/engine/bundles/KupShop/ProxyCacheBundle/EventListener/CacheKeyChangeListener.php
# Remove recaptcha module
FILE=/var/www/engine/web/config.php
echo "unset(\$cfg['Modules']['recaptcha']);" >> $FILE;
# URL from which the images are downloaded - set to $VIRTUAL_HOST (self)
FILE=/var/www/html/include/config.php
if [ -e /var/www/html/config/config.php ]; then
FILE=/var/www/html/config/config.php
fi
echo "\$cfg['Admin']['Login']['MasterPassword'] = '\$2y\$10\$zIqvTTBNbfNYm3UN48RREOcR8xH4x/WbKWyE5ptSTz2e9/GL62ou2';" >> $FILE
# Remove polyfills
FILE=/var/www/html/templates/base.tpl
touch $FILE
echo '{extends_parent} \
{block "js-polyfills"}{/block}' >> $FILE
# Remove Sentry and GTM
touch /var/www/html/templates/block.sentry.tpl
touch /var/www/html/templates/block.ga4.tpl
touch /var/www/html/templates/block.gtm.script.tpl
mkdir -p /var/www/cache
mkdir -p /var/www/html/data/tmp/sessions
chmod 777 -R /var/www/html/data /var/www/cache /var/www/html/data/tmp/sessions
/usr/local/uwsgi/uwsgi /var/www/ci/docker/files/fe-test-uwsgi.ini

22
bin/import_db.sh Normal file
View File

@@ -0,0 +1,22 @@
#!/bin/bash -xe
if [ "$#" == 0 ]; then
DUMP_BRANCH=${BRANCH}
else
DUMP_BRANCH=$1
fi
cd "$5"
export GITLAB_TOKEN=Pej7sZt-kvyD9xo94tTC
DUMP_BRANCH=$(php -r "echo urlencode(\"$DUMP_BRANCH\");")
curl -# -L -f --header "PRIVATE-TOKEN: ${GITLAB_TOKEN}" "https://gitlab.wpj.cz/api/v4/projects/2/jobs/artifacts/${DUMP_BRANCH}/download?job=dump-database" > data.zip
unzip -o data.zip
# Import database
bunzip2 -c database.sql.bz2 | mysql.php
rm data.zip database.sql.bz2

93
bin/import_demo.sh Normal file
View File

@@ -0,0 +1,93 @@
#!/bin/bash -xe
if [ "$#" == 0 ]; then
. ../utils/library.sh
DATABASE=$(get_current_database)
set -- root strongpassword mariadb "$DATABASE" "/vagrant/home/shop"
fi
cd "$5"
export GITLAB_TOKEN=Q7oFxHDwBqfB_1MaKZwb
BRANCH=$(php -r "echo urlencode(\"prod/komponenty-wpj\");")
# Pokus o stazeni artefaktu
if curl -# -L -f --header "PRIVATE-TOKEN: ${GITLAB_TOKEN}" \
"https://gitlab.wpj.cz/api/v4/projects/2/jobs/artifacts/${BRANCH}/download?job=dump-database" \
-o data.zip; then
echo "Artefakt uspesne stazen."
else
echo "Artefakt se nepodarilo stahnout, spoustim job..."
# Ziskani ID posledniho uspesneho pipeline
PIPELINE_ID=$(curl -s --header "PRIVATE-TOKEN: ${GITLAB_TOKEN}" \
"https://gitlab.wpj.cz/api/v4/projects/2/pipelines?status=success&ref=${BRANCH}" \
| jq -r '.[0].id')
# Ziskani informaci o jobu
JOB_INFO=$(curl -s --header "PRIVATE-TOKEN: ${GITLAB_TOKEN}" \
"https://gitlab.wpj.cz/api/v4/projects/2/pipelines/${PIPELINE_ID}/jobs" \
| jq -r '.[] | select(.name == "dump-database")')
JOB_ID=$(echo "$JOB_INFO" | jq -r '.id')
JOB_STATUS=$(echo "$JOB_INFO" | jq -r '.status')
echo "Job ID: $JOB_ID"
echo "Status: $JOB_STATUS"
# Rozhodnutí mezi play nebo retry
if [[ "$JOB_STATUS" == "manual" ]]; then
echo "Spoustim job"
curl -s --request POST --header "PRIVATE-TOKEN: ${GITLAB_TOKEN}" \
"https://gitlab.wpj.cz/api/v4/projects/2/jobs/${JOB_ID}/play"
elif [[ "$JOB_STATUS" == "failed" || "$JOB_STATUS" == "success" || "$JOB_STATUS" == "canceled" ]]; then
echo "Opakovane spoustim job"
curl -s --request POST --header "PRIVATE-TOKEN: ${GITLAB_TOKEN}" \
"https://gitlab.wpj.cz/api/v4/projects/2/jobs/${JOB_ID}/retry"
else
echo "Job nelze spustit (stav: $JOB_STATUS)"
fi
# Cekani na dokonceni jobu
JOB_STATE=""
while true; do
JOB_STATE=$(curl -s --header "PRIVATE-TOKEN: ${GITLAB_TOKEN}" \
"https://gitlab.wpj.cz/api/v4/projects/2/jobs/${JOB_ID}" \
| jq -r '.status')
echo -n "[$(date +%H:%M:%S)] Stav jobu: $JOB_STATE" >&2
if [[ "$JOB_STATE" == "success" ]]; then
echo " ✅"
break
elif [[ "$JOB_STATE" == "failed" || "$JOB_STATE" == "canceled" ]]; then
echo "Job selhal nebo byl zrusen. Ukoncuji."
exit 1
else
echo -n .
sleep 3
fi
done
# Druhy pokus o stazeni
curl -# -L -f --header "PRIVATE-TOKEN: ${GITLAB_TOKEN}" \
"https://gitlab.wpj.cz/api/v4/projects/2/jobs/artifacts/${BRANCH}/download?job=dump-database" \
-o data.zip
fi
# Pokud se podarilo stahnout ZIP, pokracuj s importem
if [ -e data.zip ]; then
unzip -o data.zip
# Import databaze
bunzip2 -c database.sql.bz2 | mysql -u "$1" -p"$2" -h"$3" "$4"
rm data.zip database.sql.bz2
else
echo "Chyba: ZIP soubor se nepodarilo ziskat."
exit 1
fi

24
bin/rector Normal file
View File

@@ -0,0 +1,24 @@
#!/usr/bin/env php
<?php
$target = __DIR__.'/../vendor/bin/rector';
// Get arguments from CLI
$args = $argv;
array_shift($args); // Remove script name
// Add --ansi to keep colored output
$args[] = '--ansi';
$hasConfigArg = (bool) array_filter($args, fn ($arg) => str_starts_with($arg, '--config=') || str_starts_with($arg, '--c'));
// Config option is not set, so use default rector config
if (!$hasConfigArg) {
$args[] = '--config="'.__DIR__.'/../rector.php'.'"';
}
// Build the final command
$command = escapeshellcmd($target) . ' ' . implode(' ', $args);
// Run the command and passthrough output
passthru($command, $exitCode);
exit($exitCode);

0
bin/symfony Normal file
View File