diff --git a/.gitignore b/.gitignore index 19dac96..c4fbc99 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,7 @@ .scannerwork sonar-project.properties -PrestaShop/ \ No newline at end of file +PrestaShop/ +vendor/ +.prestashop-tags +.prestashop-minor-tags diff --git a/README.md b/README.md index 9160127..4182084 100644 --- a/README.md +++ b/README.md @@ -106,6 +106,10 @@ On error, PrestaShop Flashlight can quit with these exit codes: Partially yes. As there is no console within the sources, the modules cannot be automatically installed right now. Feel free to contribute! +## Developing a module with RW (known Linux issue) + +The [develop-a-module](https://github.com/PrestaShop/prestashop-flashlight/tree/main/examples/develop-a-module) example is provided as a local environment for a developer. At PrestaShop we could successfully use it with Mac OSx and Windows, but due to the nature of the Docker implementation on Linux (no virtualization), we could not yet allow the module to write content from PrestaShop to the host. Will keep you posted here, feel free to suggest your ideas in this project issues. + ## Api calls within a docker network **Disclaimer**: PrestaShop is sensitive to the `Host` header of your client, and can behave surprisingly. In fact, since the Multi-shop feature is available, you cannot just call any front controller from any endpoint unless you set the `Host` or the `id_shop` you are targeting. diff --git a/assets/nginx.conf b/assets/nginx.conf index 7edb17c..bcca95b 100644 --- a/assets/nginx.conf +++ b/assets/nginx.conf @@ -52,7 +52,7 @@ http { index index.php; # This should match the `post_max_size` and/or `upload_max_filesize` in your php.ini. - client_max_body_size 8M; + client_max_body_size 40M; # Uploaded files temporary dir client_body_temp_path /tmp/client_body; diff --git a/assets/php-configuration.sh b/assets/php-configuration.sh new file mode 100755 index 0000000..438df13 --- /dev/null +++ b/assets/php-configuration.sh @@ -0,0 +1,46 @@ +#!/bin/sh +set -eu + +# Install PHP extensions +# @see https://olvlvl.com/2019-06-install-php-ext-source +# @see https://stackoverflow.com/a/73834081 +# @see https://packages.sury.org/php/dists/ + +error() { + printf "\e[1;31m%s\e[0m" "${1:-Unknown error}" + exit "${2:-1}" +} + +[ -z "$PHP_ENV" ] && error "PHP_ENV is not set" 2 +[ -z "$PHP_VERSION" ] && error "PHP_VERSION is not set" 3 + +PS_PHP_EXT="gd pdo_mysql zip intl fileinfo mbstring simplexml soap bcmath" +PHP_GD_CONFIG="--with-jpeg --with-freetype"; + +if [ "7.1" = "$PHP_VERSION" ]; then + PS_PHP_EXT="$PS_PHP_EXT mcrypt"; + PHP_GD_CONFIG="--with-gd --with-jpeg --with-jpeg-dir --with-zlib-dir --with-freetype-dir"; +elif [ "7.2" = "$PHP_VERSION" ] || [ "7.3" = "$PHP_VERSION" ]; then + PHP_GD_CONFIG="--with-jpeg-dir --with-zlib-dir --with-freetype-dir"; +fi + +# shellcheck disable=SC2086 +docker-php-ext-configure gd $PHP_GD_CONFIG +# shellcheck disable=SC2086 +docker-php-ext-install $PS_PHP_EXT; + +if [ "production" = "$PHP_ENV" ]; then + mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" + rm -f "$PHP_INI_DIR/php.ini-development"; +else + mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini" + rm -f "$PHP_INI_DIR/php.ini-production"; +fi + +# Flashlight is a testinf platform, keep things simple +sed -i 's/memory_limit = .*/memory_limit = -1/' "$PHP_INI_DIR/php.ini" +sed -i 's/upload_max_filesize = .*/upload_max_filesize = 40M/' "$PHP_INI_DIR/php.ini" +sed -i 's/post_max_size = .*/post_max_size = 40M/' "$PHP_INI_DIR/php.ini" + +# Remove php assets that might have been installed by package unaware of $PHP_INI_DIR +rm -rf /etc/php* /usr/lib/php* diff --git a/docker/alpine.Dockerfile b/docker/alpine.Dockerfile index 7307096..2856dc1 100644 --- a/docker/alpine.Dockerfile +++ b/docker/alpine.Dockerfile @@ -17,28 +17,16 @@ ENV PHP_INI_DIR=/usr/local/etc/php ENV COMPOSER_HOME=/var/composer # Install base tools, PHP requirements and dev-tools -# see: https://olvlvl.com/2019-06-install-php-ext-source +ENV PHP_ENV=development +COPY ./assets/php-configuration.sh /tmp/ RUN apk --no-cache add -U \ bash less vim geoip git tzdata zip curl jq make \ nginx nginx-mod-http-headers-more nginx-mod-http-geoip \ nginx-mod-stream nginx-mod-stream-geoip ca-certificates \ - gnu-libiconv php-common mariadb-client sudo \ - zlib-dev libjpeg-turbo-dev libpng-dev \ + gnu-libiconv php-common mariadb-client sudo freetype-dev \ + zlib-dev libjpeg-turbo-dev libpng-dev oniguruma-dev \ libzip-dev icu-dev libmcrypt-dev libxml2 libxml2-dev \ - && export PS_PHP_EXT="gd pdo_mysql zip intl fileinfo simplexml" \ - && if [ "7.1" = "$PHP_VERSION" ]; \ - then docker-php-ext-configure gd --with-gd --with-jpeg --with-jpeg-dir --with-zlib-dir \ - && docker-php-ext-install $PS_PHP_EXT mcrypt; \ - elif [ "7.2" = "$PHP_VERSION" ] || [ "7.3" = "$PHP_VERSION" ]; \ - then docker-php-ext-configure gd --with-jpeg-dir --with-zlib-dir \ - && docker-php-ext-install $PS_PHP_EXT; \ - else \ - docker-php-ext-configure gd --with-jpeg \ - && docker-php-ext-install $PS_PHP_EXT; \ - fi \ - && mv $PHP_INI_DIR/php.ini-development $PHP_INI_DIR/php.ini \ - && sed -i 's/memory_limit = .*/memory_limit = -1/' $PHP_INI_DIR/php.ini \ - && rm -rf /etc/php* /usr/lib/php* + && /tmp/php-configuration.sh # Configure php-fpm and nginx RUN rm -rf /var/log/php* /etc/php*/php-fpm.conf /etc/php*/php-fpm.d \ @@ -88,10 +76,12 @@ ARG ZIP_SOURCE ADD ${ZIP_SOURCE} /tmp/prestashop.zip # Extract the souces -RUN mkdir -p $PS_FOLDER /tmp/unzip-ps \ +RUN mkdir -p "$PS_FOLDER" /tmp/unzip-ps \ && unzip -n -q /tmp/prestashop.zip -d /tmp/unzip-ps \ - && ([ -f /tmp/unzip-ps/prestashop.zip ] && unzip -n -q /tmp/unzip-ps/prestashop.zip -d $PS_FOLDER || mv /tmp/unzip-ps/prestashop/* $PS_FOLDER) \ - && chown -R www-data:www-data $PS_FOLDER \ + && ([ -f /tmp/unzip-ps/prestashop.zip ] \ + && unzip -n -q /tmp/unzip-ps/prestashop.zip -d "$PS_FOLDER" \ + || mv /tmp/unzip-ps/prestashop/* "$PS_FOLDER") \ + && chown -R www-data:www-data "$PS_FOLDER" \ && rm -rf /tmp/prestashop.zip /tmp/unzip-ps # Install and configure MariaDB diff --git a/docker/debian.Dockerfile b/docker/debian.Dockerfile index 61c966d..2af7a27 100644 --- a/docker/debian.Dockerfile +++ b/docker/debian.Dockerfile @@ -16,42 +16,41 @@ ARG NODE_VERSION ENV PS_FOLDER=/var/www/html ENV COMPOSER_HOME=/var/composer -# Update certificates +# Update certificates and install base deps RUN export DEBIAN_FRONTEND=noninteractive \ + && curl -s -L -H "Content-Type: application/octet-stream" --data-binary "@/etc/apt/trusted.gpg.d/php.gpg" "https://packages.sury.org/php/apt.gpg" \ && apt-get update \ - && apt-get install --no-install-recommends -qqy \ - ca-certificates bash less vim git tzdata zip unzip curl wget make jq netcat-traditional \ - lsb-release libgnutls30 gnupg libiconv-hook1 \ + && apt-get install --no-install-recommends -qqy ca-certificates \ + && apt-get install --no-install-recommends -qqy bash less vim git \ + tzdata zip unzip curl wget make jq netcat-traditional \ + lsb-release libgnutls30 gnupg libiconv-hook1 libonig-dev \ nginx libnginx-mod-http-headers-more-filter libnginx-mod-http-geoip \ - libnginx-mod-http-geoip libnginx-mod-stream mariadb-client sudo + libnginx-mod-http-geoip libnginx-mod-stream mariadb-client sudo \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* # PHP requirements and dev-tools -# see: https://olvlvl.com/2019-06-install-php-ext-source -# see: https://stackoverflow.com/a/73834081 -# see: https://packages.sury.org/php/dists/ +ENV PHP_ENV=development + +COPY ./assets/php-configuration.sh /tmp/ RUN . /etc/os-release \ && echo "deb [trusted=yes] https://packages.sury.org/php/ ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/php.list \ && rm /etc/apt/preferences.d/no-debian-php \ && export DEBIAN_FRONTEND=noninteractive \ && apt-get update \ && apt-get install --no-install-recommends -qqy \ - php-gd libghc-zlib-dev libjpeg-dev libpng-dev libzip-dev libicu-dev libmcrypt-dev libxml2-dev \ + php-gd \ + libfreetype-dev \ + libghc-zlib-dev \ + libjpeg-dev \ + libpng-dev \ + libzip-dev \ + libicu-dev \ + libmcrypt-dev \ + libxml2-dev \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* \ - && export PS_PHP_EXT="gd pdo_mysql zip intl fileinfo simplexml" \ - && if [ "7.1" = "$PHP_VERSION" ]; \ - then docker-php-ext-configure gd --with-gd --with-jpeg --with-jpeg-dir --with-zlib-dir \ - && docker-php-ext-install $PS_PHP_EXT mcrypt; \ - elif [ "7.2" = "$PHP_VERSION" ] || [ "7.3" = "$PHP_VERSION" ]; \ - then docker-php-ext-configure gd --with-jpeg-dir --with-zlib-dir \ - && docker-php-ext-install $PS_PHP_EXT; \ - else \ - docker-php-ext-configure gd --with-jpeg \ - && docker-php-ext-install $PS_PHP_EXT; \ - fi \ - && mv $PHP_INI_DIR/php.ini-development $PHP_INI_DIR/php.ini \ - && sed -i 's/memory_limit = .*/memory_limit = -1/' $PHP_INI_DIR/php.ini \ - && rm -rf /etc/php* /usr/lib/php* + && /tmp/php-configuration.sh # Configure php-fpm and nginx RUN rm -rf /var/log/php* /etc/php*/php-fpm.conf /etc/php*/php-fpm.d \ @@ -85,7 +84,7 @@ RUN PHP_CS_FIXER=$(jq -r '."'"${PHP_VERSION}"'".php_cs_fixer' < /tmp/php-flavour # Install Node.js and pnpm (yarn and npm are included) RUN if [ "0.0.0" = "$NODE_VERSION" ]; then exit 0; fi \ - && export DEBIAN_FRONTEND=noninteractive \ + && export DEBIAN_FRONTEND=noninteractive \ && apt-get update \ && apt-get install --no-install-recommends -qqy nodejs python3 npm \ && apt-get clean \ @@ -107,10 +106,12 @@ ARG ZIP_SOURCE ADD ${ZIP_SOURCE} /tmp/prestashop.zip # Extract the souces -RUN mkdir -p $PS_FOLDER /tmp/unzip-ps \ +RUN mkdir -p "$PS_FOLDER" /tmp/unzip-ps \ && unzip -n -q /tmp/prestashop.zip -d /tmp/unzip-ps \ - && ([ -f /tmp/unzip-ps/prestashop.zip ] && unzip -n -q /tmp/unzip-ps/prestashop.zip -d $PS_FOLDER || mv /tmp/unzip-ps/prestashop/* $PS_FOLDER) \ - && chown -R www-data:www-data $PS_FOLDER \ + && ([ -f /tmp/unzip-ps/prestashop.zip ] \ + && unzip -n -q /tmp/unzip-ps/prestashop.zip -d "$PS_FOLDER" \ + || mv /tmp/unzip-ps/prestashop/* "$PS_FOLDER") \ + && chown -R www-data:www-data "$PS_FOLDER" \ && rm -rf /tmp/prestashop.zip /tmp/unzip-ps # Install and configure MariaDB diff --git a/examples/basic-example/README.md b/examples/basic-example/README.md index 5860718..b0bdf90 100644 --- a/examples/basic-example/README.md +++ b/examples/basic-example/README.md @@ -7,7 +7,7 @@ This example runs the latest available image of PrestaShop Flashlight, which is The expected output of this example is: ```sh -docker compose up prestashop +docker compose up prestashop --force-recreate [+] Building 0.0s (0/0) docker-container:thirsty_khorana [+] Running 3/3 ✔ Network basic-example_default Created 0.0s diff --git a/examples/basic-example/docker-compose.yml b/examples/basic-example/docker-compose.yml index 45759b4..0a7d9ba 100644 --- a/examples/basic-example/docker-compose.yml +++ b/examples/basic-example/docker-compose.yml @@ -7,6 +7,7 @@ services: condition: service_healthy environment: - PS_DOMAIN=localhost:8000 + # - DEBUG_MODE=true ports: - 8000:80 diff --git a/examples/develop-a-module/README.md b/examples/develop-a-module/README.md index 0461b4f..69e068a 100644 --- a/examples/develop-a-module/README.md +++ b/examples/develop-a-module/README.md @@ -4,25 +4,20 @@ This example demonstrates how a local module can be mounted in your PrestaShop F ## Bind a local module to your instance in your manifest -Let's consider we have a `testmodule` PrestaShop Module. - -Create a `modules/` directory, and drop in your `testmodule` directory. - -Create a bind mount in your docker-compose.yml: - -```yaml -... - prestashop: - container_name: prestashop - ... - volumes: - - type: bind - source: ./modules/testmodule # local path to the module - target: /var/www/html/modules/testmodule # path to be mounted in the container -... +Install the module's dependencies: + +``` +cd ./modules/testmodule +composer install ``` -And that's it: your module is available on the `prestashop` Docker container, and changes made in the local directory of the module are automatically synchronized on the `prestashop` Docker container. +Run flashlight with a RW bind mount (see ./docker-compose.yml) + +``` +docker compose up prestashop --force-recreate +``` + +And that's it: your module is available on the `prestashop` Docker container, and changes made in the local directory of the module are automatically synchronized on the `prestashop` Docker container. ## Install / test the module @@ -31,16 +26,16 @@ You can access to PrestaShop in your browser: - http://localhost:8000 - http://localhost:8000/admin-dev/ (back office, login/password described [here](../../README.md)) -You can go to modules > install and install your module, or install it with cli: +You can go to modules > install and install your module, or install it with cli: -1. obtain container name: +1. obtain container name: ```sh docker ps ``` -2. execute the install module command in the container: +2. execute the install module command in the container: ```sh docker exec -ti container_name php /var/www/html/bin/console prestashop:module install testmodule -``` \ No newline at end of file +``` diff --git a/examples/develop-a-module/docker-compose.yml b/examples/develop-a-module/docker-compose.yml index d3fbc72..b16d3f8 100644 --- a/examples/develop-a-module/docker-compose.yml +++ b/examples/develop-a-module/docker-compose.yml @@ -7,9 +7,11 @@ services: condition: service_healthy environment: - PS_DOMAIN=localhost:8000 + - INIT_SCRIPTS_DIR=/tmp/init-scripts ports: - 8000:80 volumes: + - ./init-scripts:/tmp/init-scripts:ro - type: bind source: ./modules/testmodule # local path to the module target: /var/www/html/modules/testmodule # path to be mounted in the container diff --git a/examples/develop-a-module/init-scripts/module-install.sh b/examples/develop-a-module/init-scripts/module-install.sh new file mode 100755 index 0000000..0ca1cf9 --- /dev/null +++ b/examples/develop-a-module/init-scripts/module-install.sh @@ -0,0 +1,12 @@ +#!/bin/sh +# +# This is an init-script for prestashop-flashlight. +# +# Storing a folder in /var/www/html/modules is not enough to register the module +# into PrestaShop, hence why we have to call the console install CLI. +# +set -eu + +cd "$PS_FOLDER" +echo "* [testmodule] installing the module..." +php -d memory_limit=-1 bin/console prestashop:module --no-interaction install "testmodule" diff --git a/examples/develop-a-module/modules/testmodule/composer.json b/examples/develop-a-module/modules/testmodule/composer.json new file mode 100644 index 0000000..7c47e39 --- /dev/null +++ b/examples/develop-a-module/modules/testmodule/composer.json @@ -0,0 +1,32 @@ +{ + "name": "prestashopcorp/testmodule", + "description": "a simple module example", + "type": "prestashop-module", + "authors": [ + { + "name": "Clément Désiles", + "email": "main@jokester.fr" + } + ], + "license": "AFL-3.0", + "autoload": { + "classmap": [ + "testmodule.php" + ], + "psr-4": { + "PrestaShop\\Module\\TestModule\\": "src/" + } + }, + "config": { + "preferred-install": "dist", + "platform": { + "php": "7.2.5" + }, + "optimize-autoloader": true, + "prepend-autoloader": false, + "platform-check": false + }, + "require": { + "php": ">=7.2.5" + } +} diff --git a/examples/develop-a-module/modules/testmodule/composer.lock b/examples/develop-a-module/modules/testmodule/composer.lock new file mode 100644 index 0000000..7bf10fd --- /dev/null +++ b/examples/develop-a-module/modules/testmodule/composer.lock @@ -0,0 +1,23 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "d83faa5d1a944883237c68fe94a80cd9", + "packages": [], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": ">=7.2.5" + }, + "platform-dev": [], + "platform-overrides": { + "php": "7.2.5" + }, + "plugin-api-version": "2.6.0" +} diff --git a/examples/develop-a-module/modules/testmodule/config.xml b/examples/develop-a-module/modules/testmodule/config.xml index 92bb5c9..eb5552d 100644 --- a/examples/develop-a-module/modules/testmodule/config.xml +++ b/examples/develop-a-module/modules/testmodule/config.xml @@ -1,9 +1,9 @@ - testmodule - + modulea + - + 0 diff --git a/examples/develop-a-module/modules/testmodule/index.php b/examples/develop-a-module/modules/testmodule/index.php deleted file mode 100644 index 0daf2f2..0000000 --- a/examples/develop-a-module/modules/testmodule/index.php +++ /dev/null @@ -1,8 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ - -declare(strict_types=1); if (!defined('_PS_VERSION_')) { exit; } -class TestModule extends Module +class Testmodule extends Module { + /** + * @var string + */ + const VERSION = '1.0.0'; + public function __construct() { $this->name = 'testmodule'; $this->author = 'PrestaShop'; $this->version = '1.0.0'; - $this->ps_versions_compliancy = ['min' => '1.7.0', 'max' => _PS_VERSION_]; + $this->ps_versions_compliancy = [ + 'min' => '1.7.0', + 'max' => '99.99.99', + ]; + $this->bootstrap = false; parent::__construct(); + $this->displayName = $this->trans('Test Module', [], 'Modules.Mymodule.Admin'); + $this->description = $this->trans('Test Module', [], 'Modules.Mymodule.Admin'); + $this->confirmUninstall = $this->trans('Are you sure you want to quit ModuleA?', [], 'Modules.Mymodule.Admin'); - $this->displayName = $this->trans('TestModule', [], 'Modules.TestModule.Config'); - $this->description = $this->trans('TestModule module description', [], 'Modules.TestModule.Config'); + require_once __DIR__ . '/vendor/autoload.php'; } - /** - * @return bool - */ public function install() { - if (!parent::install()) { - return false; - } - - $this->registerHook('displayProductExtraContent'); + return true; } - /** - * @return bool - */ public function uninstall() { - if (!parent::uninstall()) { - return false; - } + return true; } - /** - * Add extra content to the product page - */ - public function hookDisplayProductExtraContent($params) { - return [ - (new PrestaShop\PrestaShop\Core\Product\ProductExtraContent()) - ->setTitle('my first field') - ->setContent('my first content') - ]; - } - + public function getFilePath() + { + return __FILE__; + } } diff --git a/examples/develop-prestashop/README.md b/examples/develop-prestashop/README.md index 8fc704d..98caf68 100644 --- a/examples/develop-prestashop/README.md +++ b/examples/develop-prestashop/README.md @@ -23,7 +23,7 @@ You are now ready to run PrestaShop within your Flashlight environment: ``` cd e2e-env -docker compose up prestashop +docker compose up prestashop --force-recreate [+] Building 0.0s (0/0) docker-container:thirsty_khorana [+] Running 3/3 ✔ Network e2e-env_default Created 0.1s diff --git a/examples/ngrok-tunnel/README.md b/examples/ngrok-tunnel/README.md index 276a543..56ef461 100644 --- a/examples/ngrok-tunnel/README.md +++ b/examples/ngrok-tunnel/README.md @@ -6,12 +6,12 @@ 1. First you will have to Sign up to your ngrok account. For this simple use case the free plan is sufficient. Once it's done, on the left menu clic on "Getting Started > Your Authtoken". -3. Copy this token to the your own .env file (`mv .env.dist .env`) +2. Copy this token to the your own .env file (`mv .env.dist .env`) -4. Run PrestaShop Flashlight alongside with an Ngrok agent: +3. Run PrestaShop Flashlight alongside with an Ngrok agent: ```sh -docker compose up prestashop +docker compose up prestashop --force-recreate ngrok-tunnel-prestashop-1 | * Auto-detecting domain with ngrok client api on http://ngrok:4040... ngrok-tunnel-prestashop-1 | * ngrok tunnel found running on 4452-37-170-242-21.ngrok.app ngrok-tunnel-prestashop-1 | * Applying PS_DOMAIN (4452-37-170-242-21.ngrok.app) to the dump... diff --git a/examples/with-init-scripts/README.md b/examples/with-init-scripts/README.md index bdfa4ca..d34e1e1 100644 --- a/examples/with-init-scripts/README.md +++ b/examples/with-init-scripts/README.md @@ -10,7 +10,7 @@ See [./init-scripts](./init-scripts). The expected output of this example is: ```sh -docker compose up prestashop +docker compose up prestashop --force-recreate [+] Building 0.0s (0/0) [+] Running 3/2 ✔ Network with-init-scripts_default Created 0.0s diff --git a/examples/with-post-scripts/README.md b/examples/with-post-scripts/README.md index 0cbe813..0e04bb2 100644 --- a/examples/with-post-scripts/README.md +++ b/examples/with-post-scripts/README.md @@ -10,7 +10,7 @@ See [./post-scripts](./post-scripts). The expected output of this example is: ```sh -docker compose up prestashop +docker compose up prestashop --force-recreate [+] Building 0.0s (0/0) [+] Running 2/2 ✔ Container with-post-scripts-mysql-1 Running 0.0s diff --git a/release.sh b/release.sh index 1de7230..651bd05 100755 --- a/release.sh +++ b/release.sh @@ -1,27 +1,67 @@ #!/bin/sh +set -eu +PRESTASHOP_TAGS=.prestashop-tags +PRESTASHOP_MINOR_TAGS=.prestashop-minor-tags + +get_prestashop_tags() { + git ls-remote --tags git@github.com:PrestaShop/PrestaShop.git \ + | cut -f2 \ + | grep -Ev '\/1.5|\/1.6.0|beta|rc|RC|\^' \ + | cut -d '/' -f3 \ + | sort -r -V > "$PRESTASHOP_TAGS" +} + +get_prestashop_minor_tags() { + printf "" > "$PRESTASHOP_MINOR_TAGS" + while IFS= read -r version; do + major_minor=$(echo "$version" | cut -d. -f1-2) + major_minor_patch=$(echo "$version" | cut -d. -f1-3) + criteria=$major_minor + # shellcheck disable=SC3010 + [[ "$major_minor" == 1* ]] && criteria=$major_minor_patch + if ! grep -q "^$criteria" "$PRESTASHOP_MINOR_TAGS"; then + echo "$version" >> "$PRESTASHOP_MINOR_TAGS" + fi + done < "$PRESTASHOP_TAGS" +} + +get_compatible_php_version() { + REGEXP_LIST=$(jq -r 'keys_unsorted | .[]'