Skip to content

Commit

Permalink
Feature: Remove Composer 1 support
Browse files Browse the repository at this point in the history
  • Loading branch information
michielgerritsen committed Nov 25, 2024
1 parent 4780aee commit 1a2aafb
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 3 deletions.
10 changes: 9 additions & 1 deletion magento/Dockerfile-2.3
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,28 @@ ARG SAMPLE_DATA=false
ENV CI=true
ENV URL=http://localhost/
ENV FLAT_TABLES=false
ENV COMPOSER_VERSION=1

COPY scripts/retry retry
COPY scripts/install-phpstan.php scripts/install-phpstan.php
COPY scripts/upgrade-to-composer-2.php scripts/upgrade-to-composer-2.php
COPY scripts/allow-composer-plugins.php scripts/allow-composer-plugins.php
COPY patches/vertex-compilation-issue.patch vertex-compilation-issue.patch
COPY patches/APSB22-12/MDVA-43395_EE_2.4.3-p1_COMPOSER_v1.patch MDVA-43395_EE_2.4.3-p1_COMPOSER_v1.patch
COPY patches/APSB22-12/MDVA-43443_EE_2.3.4_COMPOSER_v1.patch MDVA-43443_EE_2.3.4_COMPOSER_v1.patch
COPY patches/APSB22-12/MDVA-43443_EE_2.4.2-p2_COMPOSER_v1.patch MDVA-43443_EE_2.4.2-p2_COMPOSER_v1.patch
COPY templates/memory-limit-php.ini /usr/local/etc/php/conf.d/memory-limit-php.ini

RUN ./start-services && \
composer self-update --2 && \
echo "Composer version:" && \
composer --version && \
curl -o magento.zip https://repo-magento-mirror.fooman.co.nz/dist/magento/$MAGENTO_TYPE/magento-$MAGENTO_TYPE-$MAGENTO_VERSION.zip && \
unzip -q magento.zip -d . && \
rm magento.zip && \
php scripts/allow-composer-plugins.php && \
rm scripts/allow-composer-plugins.php && \
php scripts/upgrade-to-composer-2.php && \
rm scripts/upgrade-to-composer-2.php && \
composer config --unset repositories.0 && \
composer config repositories.fooman composer https://repo-magento-mirror.fooman.co.nz/ && \
./retry "composer install" && \
Expand Down
8 changes: 6 additions & 2 deletions magento/Dockerfile-2.4
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,23 @@ COPY scripts/retry retry
COPY patches/ patches/
COPY scripts/apply-2.4-patches.php scripts/apply-2.4-patches.php
COPY scripts/downgrade-monolog.php scripts/downgrade-monolog.php
COPY scripts/upgrade-to-composer-2.php scripts/upgrade-to-composer-2.php
COPY scripts/allow-composer-plugins.php scripts/allow-composer-plugins.php
COPY scripts/remove-paypal-braintree.php scripts/remove-paypal-braintree.php
COPY scripts/patch-AC2855.php scripts/patch-AC2855.php
COPY templates/memory-limit-php.ini /usr/local/etc/php/conf.d/memory-limit-php.ini

RUN ./start-services && \
if (( $(php -r 'echo version_compare(getenv("MAGENTO_VERSION"), "2.4.2", "<=") ? "true" : "false";') = "true" )); then composer self-update --1; else composer self-update --2; fi && \
composer self-update --2 && \
echo "Composer version:" && \
composer --version && \
curl -o magento.zip https://repo-magento-mirror.fooman.co.nz/dist/magento/$MAGENTO_TYPE/magento-$MAGENTO_TYPE-$MAGENTO_VERSION.zip && \
unzip -q magento.zip -d . && \
rm magento.zip && \
if (( $(php -r 'echo version_compare(getenv("MAGENTO_VERSION"), "2.4.2", "<=") ? "true" : "false";') = "true" )); then echo "Using Composer version 1 so skipping allow-plugins"; else php scripts/allow-composer-plugins.php rm scripts/allow-composer-plugins.php; fi && \
php scripts/allow-composer-plugins.php && \
rm scripts/allow-composer-plugins.php && \
php scripts/upgrade-to-composer-2.php && \
rm scripts/upgrade-to-composer-2.php && \
composer config --unset repositories.0 && \
composer config repositories.fooman composer https://repo-magento-mirror.fooman.co.nz/ && \
if [ "$MAGENTO_VERSION" = "2.4.4" ]; then composer require "magento/security-package:1.1.3-p1 as 1.1.3" --no-update; fi && \
Expand Down
51 changes: 51 additions & 0 deletions magento/scripts/upgrade-to-composer-2.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

$isPhp72OrLower = version_compare(PHP_VERSION, '7.2', '<');

$version = getenv('MAGENTO_VERSION');
$is230 = substr($version, 0, 5) == '2.3.0';
$is231 = substr($version, 0, 5) == '2.3.1';
$is232 = substr($version, 0, 5) == '2.3.2';
$is233 = substr($version, 0, 5) == '2.3.3';
$is234 = substr($version, 0, 5) == '2.3.4';
$is235 = substr($version, 0, 5) == '2.3.5';
$is236 = substr($version, 0, 5) == '2.3.6';
$is237 = substr($version, 0, 5) == '2.3.7';
$is240 = substr($version, 0, 5) == '2.4.0';
$is241 = substr($version, 0, 5) == '2.4.1';
$is242 = substr($version, 0, 5) == '2.4.2';
$is243 = substr($version, 0, 5) == '2.4.3';
$is244 = substr($version, 0, 5) == '2.4.4';
$is245 = substr($version, 0, 5) == '2.4.5';
$is246 = substr($version, 0, 5) == '2.4.6';
$is247 = substr($version, 0, 5) == '2.4.7';

if ($is230 || $is231 || $is232 || $is233 || $is234) {
run('composer require magento/inventory-composer-installer:"1.2.0 as 1.1.0" --no-update');
return;
}

$laminasDependencyPluginVersion = "2.1.2 as 1.0.4";
if ($isPhp72OrLower) {
$laminasDependencyPluginVersion = "2.0.0 as 1.0.4";
}

if ($is234 || $is235 || $is236 || $is240 || $is241) {
run('composer require laminas/laminas-dependency-plugin:"' . $laminasDependencyPluginVersion . '" --no-update');
run('composer require magento/inventory-composer-installer:"1.2.0 as 1.1.0" --no-update');
run('composer require --dev dealerdirect/phpcodesniffer-composer-installer:^0.7.0 --no-update');
return;
}

function run(string $command) {
echo 'Running command ' . $command . PHP_EOL;

$output = null;
$code = null;
exec($command, $output, $code);

if ($code !== 0) {
echo 'Error while running "' . $command . '"' . PHP_EOL;
die($code);
}
}

0 comments on commit 1a2aafb

Please sign in to comment.