From ebfd1fbff6cf42f1b5ccd7adf4cf0939cfb162fd Mon Sep 17 00:00:00 2001 From: MarioRadu Date: Thu, 12 Dec 2024 11:46:36 +0200 Subject: [PATCH 01/32] ignore development files on production env Signed-off-by: MarioRadu --- bin/composer-post-install-script.php | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/bin/composer-post-install-script.php b/bin/composer-post-install-script.php index af2e8a9..66bd803 100644 --- a/bin/composer-post-install-script.php +++ b/bin/composer-post-install-script.php @@ -2,6 +2,9 @@ declare(strict_types=1); +const ENVIRONMENT_DEVELOPMENT = 'development'; +const ENVIRONMENT_PRODUCTION = 'production'; + // phpcs:disable PSR1.Files.SideEffects.FoundWithSymbols function copyFile(array $file): void @@ -9,26 +12,40 @@ function copyFile(array $file): void if (is_readable($file['destination'])) { echo "File {$file['destination']} already exists." . PHP_EOL; } else { - if (! copy($file['source'], $file['destination'])) { - echo "Cannot copy {$file['source']} file to {$file['destination']}" . PHP_EOL; + if (! in_array(getEnvironment(), $file['environment'])) { + echo "Skipping the copy of {$file['source']} due to environment settings." . PHP_EOL; } else { - echo "File {$file['source']} copied successfully to {$file['destination']}." . PHP_EOL; + if (! copy($file['source'], $file['destination'])) { + echo "Cannot copy {$file['source']} file to {$file['destination']}" . PHP_EOL; + } else { + echo "File {$file['source']} copied successfully to {$file['destination']}." . PHP_EOL; + } } } } +function getEnvironment(): string +{ + return file_exists('config/autoload/development.local.php') ? ENVIRONMENT_DEVELOPMENT : ENVIRONMENT_PRODUCTION; +} + +// when adding files to the below array the `source` and `destination` paths must be relative to the project root folder +// the `environment` key will indicate on what environments the file will be copied, $files = [ [ 'source' => 'config/autoload/local.php.dist', 'destination' => 'config/autoload/local.php', + 'environment' => [ENVIRONMENT_DEVELOPMENT, ENVIRONMENT_PRODUCTION], ], [ 'source' => 'config/autoload/local.test.php.dist', 'destination' => 'config/autoload/local.test.php', + 'environment' => [ENVIRONMENT_DEVELOPMENT], ], [ 'source' => 'vendor/dotkernel/dot-mail/config/mail.global.php.dist', 'destination' => 'config/autoload/mail.global.php', + 'environment' => [ENVIRONMENT_DEVELOPMENT, ENVIRONMENT_PRODUCTION], ], ]; From bd1e88dcd89efc280c4c973e51c97ac5e802b44e Mon Sep 17 00:00:00 2001 From: MarioRadu Date: Thu, 12 Dec 2024 11:52:29 +0200 Subject: [PATCH 02/32] ignore development files on production env Signed-off-by: MarioRadu --- .laminas-ci/pre-run.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/.laminas-ci/pre-run.sh b/.laminas-ci/pre-run.sh index 3a38c16..18fd755 100755 --- a/.laminas-ci/pre-run.sh +++ b/.laminas-ci/pre-run.sh @@ -9,7 +9,6 @@ if [[ ${COMMAND} =~ phpunit ]];then apt-get install php"${PHP_VERSION}"-sqlite3 cp config/autoload/local.php.dist config/autoload/local.php - cp config/autoload/mail.global.php.dist config/autoload/mail.global.php cp config/autoload/local.test.php.dist config/autoload/local.test.php fi From 20d24c44970a7d09a564d13b7a06b6af7f77eed4 Mon Sep 17 00:00:00 2001 From: MarioRadu Date: Thu, 12 Dec 2024 12:24:23 +0200 Subject: [PATCH 03/32] ignore development files on production env Signed-off-by: MarioRadu --- bin/composer-post-install-script.php | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/composer-post-install-script.php b/bin/composer-post-install-script.php index 66bd803..c43fcec 100644 --- a/bin/composer-post-install-script.php +++ b/bin/composer-post-install-script.php @@ -14,6 +14,7 @@ function copyFile(array $file): void } else { if (! in_array(getEnvironment(), $file['environment'])) { echo "Skipping the copy of {$file['source']} due to environment settings." . PHP_EOL; + echo "ENV SETTING : " . getEnvironment() . PHP_EOL; } else { if (! copy($file['source'], $file['destination'])) { echo "Cannot copy {$file['source']} file to {$file['destination']}" . PHP_EOL; From 62e6193cce7f0dacca05af2c182b5f9222eccb84 Mon Sep 17 00:00:00 2001 From: MarioRadu Date: Thu, 12 Dec 2024 12:36:26 +0200 Subject: [PATCH 04/32] ignore development files on production env Signed-off-by: MarioRadu --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index 5bdc09c..6bf76dc 100644 --- a/composer.json +++ b/composer.json @@ -107,6 +107,7 @@ "@development-enable" ], "post-update-cmd": [ + "composer development-enable", "php bin/composer-post-install-script.php" ], "development-disable": "laminas-development-mode disable", From a58181b12e39b9d5c2c839f6868b07988731530b Mon Sep 17 00:00:00 2001 From: MarioRadu Date: Thu, 12 Dec 2024 12:50:46 +0200 Subject: [PATCH 05/32] ignore development files on production env Signed-off-by: MarioRadu --- .github/workflows/codecov.yml | 2 +- composer.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 59c4b08..ba61231 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -42,7 +42,7 @@ jobs: php${{ matrix.php }}-composer- - name: Install dependencies with composer - run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi + run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi --dev - name: Collect code coverage with PHPUnit run: vendor/bin/phpunit --colors=always --coverage-clover clover.xml diff --git a/composer.json b/composer.json index 6bf76dc..5bdc09c 100644 --- a/composer.json +++ b/composer.json @@ -107,7 +107,6 @@ "@development-enable" ], "post-update-cmd": [ - "composer development-enable", "php bin/composer-post-install-script.php" ], "development-disable": "laminas-development-mode disable", From d715ee12de31743f5fa7f51ca6ee1873c283bc91 Mon Sep 17 00:00:00 2001 From: MarioRadu Date: Thu, 12 Dec 2024 12:56:37 +0200 Subject: [PATCH 06/32] ignore development files on production env Signed-off-by: MarioRadu --- .github/workflows/codecov.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index ba61231..5a9bb85 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -42,7 +42,7 @@ jobs: php${{ matrix.php }}-composer- - name: Install dependencies with composer - run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi --dev + run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --no-cache - name: Collect code coverage with PHPUnit run: vendor/bin/phpunit --colors=always --coverage-clover clover.xml From abf732235af49cb47706e7ce62b01d325afb91dd Mon Sep 17 00:00:00 2001 From: MarioRadu Date: Thu, 12 Dec 2024 13:35:19 +0200 Subject: [PATCH 07/32] ignore development files on production env Signed-off-by: MarioRadu --- .github/workflows/codecov.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 5a9bb85..0df5f9e 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -42,7 +42,9 @@ jobs: php${{ matrix.php }}-composer- - name: Install dependencies with composer - run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --no-cache + run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi + env: + COMPOSER_DEV_MODE: 1 - name: Collect code coverage with PHPUnit run: vendor/bin/phpunit --colors=always --coverage-clover clover.xml From f2cae4f05c1ea865aaa9079ca3517375282321a8 Mon Sep 17 00:00:00 2001 From: MarioRadu Date: Thu, 12 Dec 2024 13:43:48 +0200 Subject: [PATCH 08/32] ignore development files on production env Signed-off-by: MarioRadu --- .github/workflows/codecov.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 0df5f9e..875e607 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -42,9 +42,9 @@ jobs: php${{ matrix.php }}-composer- - name: Install dependencies with composer - run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi - env: - COMPOSER_DEV_MODE: 1 + run: | + unset COMPOSER_NO_DEV + composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi - name: Collect code coverage with PHPUnit run: vendor/bin/phpunit --colors=always --coverage-clover clover.xml From 4d7bae9c16c256f42712a2c7a6c697ee5e6ff588 Mon Sep 17 00:00:00 2001 From: MarioRadu Date: Thu, 12 Dec 2024 13:46:21 +0200 Subject: [PATCH 09/32] ignore development files on production env Signed-off-by: MarioRadu --- .github/workflows/codecov.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 875e607..b317089 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -42,9 +42,9 @@ jobs: php${{ matrix.php }}-composer- - name: Install dependencies with composer - run: | - unset COMPOSER_NO_DEV - composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi + env: + COMPOSER_DEV_MODE: 1 + run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi - name: Collect code coverage with PHPUnit run: vendor/bin/phpunit --colors=always --coverage-clover clover.xml From 2e59e46b08357932a9efb5c95d79796ddeea2e6f Mon Sep 17 00:00:00 2001 From: MarioRadu Date: Thu, 12 Dec 2024 13:51:14 +0200 Subject: [PATCH 10/32] ignore development files on production env Signed-off-by: MarioRadu --- .github/workflows/codecov.yml | 2 -- .laminas-ci/pre-run.sh | 2 +- bin/composer-post-install-script.php | 1 - 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index b317089..59c4b08 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -42,8 +42,6 @@ jobs: php${{ matrix.php }}-composer- - name: Install dependencies with composer - env: - COMPOSER_DEV_MODE: 1 run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi - name: Collect code coverage with PHPUnit diff --git a/.laminas-ci/pre-run.sh b/.laminas-ci/pre-run.sh index 18fd755..34626d5 100755 --- a/.laminas-ci/pre-run.sh +++ b/.laminas-ci/pre-run.sh @@ -2,7 +2,7 @@ JOB=$3 PHP_VERSION=$4 COMMAND=$(echo "${JOB}" | jq -r '.command') -echo "Running $COMMAND" +echo "Running pre-run $COMMAND" if [[ ${COMMAND} =~ phpunit ]];then diff --git a/bin/composer-post-install-script.php b/bin/composer-post-install-script.php index c43fcec..66bd803 100644 --- a/bin/composer-post-install-script.php +++ b/bin/composer-post-install-script.php @@ -14,7 +14,6 @@ function copyFile(array $file): void } else { if (! in_array(getEnvironment(), $file['environment'])) { echo "Skipping the copy of {$file['source']} due to environment settings." . PHP_EOL; - echo "ENV SETTING : " . getEnvironment() . PHP_EOL; } else { if (! copy($file['source'], $file['destination'])) { echo "Cannot copy {$file['source']} file to {$file['destination']}" . PHP_EOL; From dfce5a54ccd7e1351c48da4a53119f9b12c358b9 Mon Sep 17 00:00:00 2001 From: MarioRadu Date: Thu, 12 Dec 2024 13:55:01 +0200 Subject: [PATCH 11/32] ignore development files on production env Signed-off-by: MarioRadu --- .github/workflows/codecov.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 59c4b08..63c9ee9 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -44,6 +44,10 @@ jobs: - name: Install dependencies with composer run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi + - name: Setup project + run: | + mv config/autoload/local.test.php.dist config/autoload/local.test.php + - name: Collect code coverage with PHPUnit run: vendor/bin/phpunit --colors=always --coverage-clover clover.xml From 2b3fb461dce61cfc0e41afa0d16ddfb3b0c1c07a Mon Sep 17 00:00:00 2001 From: MarioRadu Date: Thu, 12 Dec 2024 14:04:34 +0200 Subject: [PATCH 12/32] ignore development files on production env Signed-off-by: MarioRadu --- bin/composer-post-install-script.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/composer-post-install-script.php b/bin/composer-post-install-script.php index 66bd803..b45e84e 100644 --- a/bin/composer-post-install-script.php +++ b/bin/composer-post-install-script.php @@ -26,7 +26,7 @@ function copyFile(array $file): void function getEnvironment(): string { - return file_exists('config/autoload/development.local.php') ? ENVIRONMENT_DEVELOPMENT : ENVIRONMENT_PRODUCTION; + return file_exists('config/development.local.php') ? ENVIRONMENT_DEVELOPMENT : ENVIRONMENT_PRODUCTION; } // when adding files to the below array the `source` and `destination` paths must be relative to the project root folder From e2ebd6e9592b4408735d78fe36a8aeeb812c3e60 Mon Sep 17 00:00:00 2001 From: MarioRadu Date: Thu, 12 Dec 2024 15:45:35 +0200 Subject: [PATCH 13/32] ignore development files on production env Signed-off-by: MarioRadu --- .github/workflows/codecov.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 63c9ee9..77d3bf7 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -44,9 +44,9 @@ jobs: - name: Install dependencies with composer run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi - - name: Setup project - run: | - mv config/autoload/local.test.php.dist config/autoload/local.test.php +# - name: Setup project +# run: | +# mv config/autoload/local.test.php.dist config/autoload/local.test.php - name: Collect code coverage with PHPUnit run: vendor/bin/phpunit --colors=always --coverage-clover clover.xml From e18b11f4e7baa8ec2ea547c60b060cf510e4a51c Mon Sep 17 00:00:00 2001 From: MarioRadu Date: Thu, 12 Dec 2024 15:50:56 +0200 Subject: [PATCH 14/32] ignore development files on production env Signed-off-by: MarioRadu --- bin/composer-post-install-script.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/composer-post-install-script.php b/bin/composer-post-install-script.php index b45e84e..2531315 100644 --- a/bin/composer-post-install-script.php +++ b/bin/composer-post-install-script.php @@ -26,7 +26,7 @@ function copyFile(array $file): void function getEnvironment(): string { - return file_exists('config/development.local.php') ? ENVIRONMENT_DEVELOPMENT : ENVIRONMENT_PRODUCTION; + return file_exists('config/development.config.php') ? ENVIRONMENT_DEVELOPMENT : ENVIRONMENT_PRODUCTION; } // when adding files to the below array the `source` and `destination` paths must be relative to the project root folder @@ -49,4 +49,7 @@ function getEnvironment(): string ], ]; + +var_dump(getEnvironment()); exit; + array_walk($files, 'copyFile'); From 94511b88116b3970a73964e64a6d5dd79f8c3415 Mon Sep 17 00:00:00 2001 From: MarioRadu Date: Thu, 12 Dec 2024 15:52:52 +0200 Subject: [PATCH 15/32] ignore development files on production env Signed-off-by: MarioRadu --- bin/composer-post-install-script.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/bin/composer-post-install-script.php b/bin/composer-post-install-script.php index 2531315..e147a42 100644 --- a/bin/composer-post-install-script.php +++ b/bin/composer-post-install-script.php @@ -49,7 +49,4 @@ function getEnvironment(): string ], ]; - -var_dump(getEnvironment()); exit; - array_walk($files, 'copyFile'); From d45b2e0336611098731dda33ad0d998d5b0a4624 Mon Sep 17 00:00:00 2001 From: MarioRadu Date: Thu, 12 Dec 2024 16:00:34 +0200 Subject: [PATCH 16/32] ignore development files on production env Signed-off-by: MarioRadu --- bin/composer-post-install-script.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bin/composer-post-install-script.php b/bin/composer-post-install-script.php index e147a42..89c3bcd 100644 --- a/bin/composer-post-install-script.php +++ b/bin/composer-post-install-script.php @@ -49,4 +49,6 @@ function getEnvironment(): string ], ]; +echo "Using environment setting : " . getEnvironment() . PHP_EOL; + array_walk($files, 'copyFile'); From 385b7468e0006e986894adb933d507a7210f348f Mon Sep 17 00:00:00 2001 From: MarioRadu Date: Thu, 12 Dec 2024 16:16:16 +0200 Subject: [PATCH 17/32] ignore development files on production env Signed-off-by: MarioRadu --- .github/workflows/codecov.yml | 4 ---- bin/composer-post-install-script.php | 16 ++++++++++++++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 77d3bf7..59c4b08 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -44,10 +44,6 @@ jobs: - name: Install dependencies with composer run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi -# - name: Setup project -# run: | -# mv config/autoload/local.test.php.dist config/autoload/local.test.php - - name: Collect code coverage with PHPUnit run: vendor/bin/phpunit --colors=always --coverage-clover clover.xml diff --git a/bin/composer-post-install-script.php b/bin/composer-post-install-script.php index 89c3bcd..2c86d7b 100644 --- a/bin/composer-post-install-script.php +++ b/bin/composer-post-install-script.php @@ -26,7 +26,19 @@ function copyFile(array $file): void function getEnvironment(): string { - return file_exists('config/development.config.php') ? ENVIRONMENT_DEVELOPMENT : ENVIRONMENT_PRODUCTION; + $composerInstalledJson = 'vendor/composer/installed.json'; + if (! file_exists($composerInstalledJson)) { + throw new RuntimeException('Composer installed JSON file not found.'); + } + + $data = json_decode(file_get_contents($composerInstalledJson), true); + foreach ($data as $package) { + if (! empty($package['dev'])) { + return ENVIRONMENT_DEVELOPMENT; + } + } + + return ENVIRONMENT_PRODUCTION; } // when adding files to the below array the `source` and `destination` paths must be relative to the project root folder @@ -49,6 +61,6 @@ function getEnvironment(): string ], ]; -echo "Using environment setting : " . getEnvironment() . PHP_EOL; +echo "Using environment setting: " . getEnvironment() . PHP_EOL; array_walk($files, 'copyFile'); From e2d7f5043361c803053c9a6c31654c08ea1f4500 Mon Sep 17 00:00:00 2001 From: MarioRadu Date: Thu, 12 Dec 2024 16:37:40 +0200 Subject: [PATCH 18/32] ignore development files on production env Signed-off-by: MarioRadu --- .github/workflows/codecov.yml | 4 ++++ bin/composer-post-install-script.php | 14 +------------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 59c4b08..77d3bf7 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -44,6 +44,10 @@ jobs: - name: Install dependencies with composer run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi +# - name: Setup project +# run: | +# mv config/autoload/local.test.php.dist config/autoload/local.test.php + - name: Collect code coverage with PHPUnit run: vendor/bin/phpunit --colors=always --coverage-clover clover.xml diff --git a/bin/composer-post-install-script.php b/bin/composer-post-install-script.php index 2c86d7b..60c5683 100644 --- a/bin/composer-post-install-script.php +++ b/bin/composer-post-install-script.php @@ -26,19 +26,7 @@ function copyFile(array $file): void function getEnvironment(): string { - $composerInstalledJson = 'vendor/composer/installed.json'; - if (! file_exists($composerInstalledJson)) { - throw new RuntimeException('Composer installed JSON file not found.'); - } - - $data = json_decode(file_get_contents($composerInstalledJson), true); - foreach ($data as $package) { - if (! empty($package['dev'])) { - return ENVIRONMENT_DEVELOPMENT; - } - } - - return ENVIRONMENT_PRODUCTION; + return file_exists('config/development.config.php') ? ENVIRONMENT_DEVELOPMENT : ENVIRONMENT_PRODUCTION; } // when adding files to the below array the `source` and `destination` paths must be relative to the project root folder From a9905adf6cd68995429a41bcb3141ae7b8658505 Mon Sep 17 00:00:00 2001 From: MarioRadu Date: Thu, 12 Dec 2024 16:41:50 +0200 Subject: [PATCH 19/32] ignore development files on production env Signed-off-by: MarioRadu --- bin/composer-post-install-script.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/composer-post-install-script.php b/bin/composer-post-install-script.php index 60c5683..7d68892 100644 --- a/bin/composer-post-install-script.php +++ b/bin/composer-post-install-script.php @@ -26,7 +26,7 @@ function copyFile(array $file): void function getEnvironment(): string { - return file_exists('config/development.config.php') ? ENVIRONMENT_DEVELOPMENT : ENVIRONMENT_PRODUCTION; + return file_exists(realpath(__DIR__ . '/../config/development.config.php')) ? ENVIRONMENT_DEVELOPMENT : ENVIRONMENT_PRODUCTION; } // when adding files to the below array the `source` and `destination` paths must be relative to the project root folder @@ -51,4 +51,6 @@ function getEnvironment(): string echo "Using environment setting: " . getEnvironment() . PHP_EOL; +var_dump("File exists " . file_exists(realpath(__DIR__ . '/../config/development.config.php'))); + array_walk($files, 'copyFile'); From 84043db3f0759160beaf9b323e63c31b19532bfd Mon Sep 17 00:00:00 2001 From: MarioRadu Date: Thu, 12 Dec 2024 16:42:51 +0200 Subject: [PATCH 20/32] ignore development files on production env Signed-off-by: MarioRadu --- bin/composer-post-install-script.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/composer-post-install-script.php b/bin/composer-post-install-script.php index 7d68892..685d88d 100644 --- a/bin/composer-post-install-script.php +++ b/bin/composer-post-install-script.php @@ -51,6 +51,6 @@ function getEnvironment(): string echo "Using environment setting: " . getEnvironment() . PHP_EOL; -var_dump("File exists " . file_exists(realpath(__DIR__ . '/../config/development.config.php'))); +var_dump("File exists " , file_exists(realpath(__DIR__ . '/../config/development.config.php'))); array_walk($files, 'copyFile'); From 64d5e827fac3ea0f7d3afda1b16ad705a4b730dd Mon Sep 17 00:00:00 2001 From: MarioRadu Date: Thu, 12 Dec 2024 22:21:52 +0200 Subject: [PATCH 21/32] ignore development files on production env Signed-off-by: MarioRadu --- bin/composer-post-install-script.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/composer-post-install-script.php b/bin/composer-post-install-script.php index 685d88d..e9b0113 100644 --- a/bin/composer-post-install-script.php +++ b/bin/composer-post-install-script.php @@ -2,6 +2,8 @@ declare(strict_types=1); +require_once 'vendor/autoload.php'; + const ENVIRONMENT_DEVELOPMENT = 'development'; const ENVIRONMENT_PRODUCTION = 'production'; @@ -26,7 +28,7 @@ function copyFile(array $file): void function getEnvironment(): string { - return file_exists(realpath(__DIR__ . '/../config/development.config.php')) ? ENVIRONMENT_DEVELOPMENT : ENVIRONMENT_PRODUCTION; + return file_exists(\Laminas\DevelopmentMode\Status::DEVEL_CONFIG) ? ENVIRONMENT_DEVELOPMENT : ENVIRONMENT_PRODUCTION; } // when adding files to the below array the `source` and `destination` paths must be relative to the project root folder @@ -51,6 +53,6 @@ function getEnvironment(): string echo "Using environment setting: " . getEnvironment() . PHP_EOL; -var_dump("File exists " , file_exists(realpath(__DIR__ . '/../config/development.config.php'))); +var_dump(file_exists(\Laminas\DevelopmentMode\Status::DEVEL_CONFIG)); array_walk($files, 'copyFile'); From a1671b823ea2c673146be626e1ccad6f58ea7359 Mon Sep 17 00:00:00 2001 From: MarioRadu Date: Thu, 12 Dec 2024 22:25:56 +0200 Subject: [PATCH 22/32] ignore development files on production env Signed-off-by: MarioRadu --- bin/composer-post-install-script.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bin/composer-post-install-script.php b/bin/composer-post-install-script.php index e9b0113..834a2c6 100644 --- a/bin/composer-post-install-script.php +++ b/bin/composer-post-install-script.php @@ -51,6 +51,12 @@ function getEnvironment(): string ], ]; +chdir(dirname(__DIR__)); + +echo __DIR__ . \Laminas\DevelopmentMode\Status::DEVEL_CONFIG . PHP_EOL; + +//echo realpath(__DIR__ . ) + echo "Using environment setting: " . getEnvironment() . PHP_EOL; var_dump(file_exists(\Laminas\DevelopmentMode\Status::DEVEL_CONFIG)); From 67f686c32388478719a6f1e6e728c4736239df80 Mon Sep 17 00:00:00 2001 From: MarioRadu Date: Thu, 12 Dec 2024 22:31:08 +0200 Subject: [PATCH 23/32] ignore development files on production env Signed-off-by: MarioRadu --- bin/composer-post-install-script.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/composer-post-install-script.php b/bin/composer-post-install-script.php index 834a2c6..21faae7 100644 --- a/bin/composer-post-install-script.php +++ b/bin/composer-post-install-script.php @@ -53,9 +53,10 @@ function getEnvironment(): string chdir(dirname(__DIR__)); -echo __DIR__ . \Laminas\DevelopmentMode\Status::DEVEL_CONFIG . PHP_EOL; +echo __DIR__ . DIRECTORY_SEPARATOR . \Laminas\DevelopmentMode\Status::DEVEL_CONFIG . PHP_EOL; +echo __DIR__ . DIRECTORY_SEPARATOR . \Laminas\DevelopmentMode\Status::DEVEL_CONFIG . '.dist'. PHP_EOL; -//echo realpath(__DIR__ . ) +echo realpath(__DIR__ . DIRECTORY_SEPARATOR . \Laminas\DevelopmentMode\Status::DEVEL_CONFIG . '.dist'); echo "Using environment setting: " . getEnvironment() . PHP_EOL; From 644710cab89df11f5b58c20ba4953abce721ce95 Mon Sep 17 00:00:00 2001 From: MarioRadu Date: Thu, 12 Dec 2024 22:35:03 +0200 Subject: [PATCH 24/32] ignore development files on production env Signed-off-by: MarioRadu --- bin/composer-post-install-script.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/bin/composer-post-install-script.php b/bin/composer-post-install-script.php index 21faae7..ad88535 100644 --- a/bin/composer-post-install-script.php +++ b/bin/composer-post-install-script.php @@ -51,15 +51,9 @@ function getEnvironment(): string ], ]; -chdir(dirname(__DIR__)); - -echo __DIR__ . DIRECTORY_SEPARATOR . \Laminas\DevelopmentMode\Status::DEVEL_CONFIG . PHP_EOL; -echo __DIR__ . DIRECTORY_SEPARATOR . \Laminas\DevelopmentMode\Status::DEVEL_CONFIG . '.dist'. PHP_EOL; - -echo realpath(__DIR__ . DIRECTORY_SEPARATOR . \Laminas\DevelopmentMode\Status::DEVEL_CONFIG . '.dist'); - echo "Using environment setting: " . getEnvironment() . PHP_EOL; var_dump(file_exists(\Laminas\DevelopmentMode\Status::DEVEL_CONFIG)); +var_dump(file_exists(\Laminas\DevelopmentMode\Status::DEVEL_CONFIG . '.dist')); array_walk($files, 'copyFile'); From 71ebe0e85991c81541880bea43d20091713b27d0 Mon Sep 17 00:00:00 2001 From: MarioRadu Date: Thu, 12 Dec 2024 22:36:51 +0200 Subject: [PATCH 25/32] ignore development files on production env Signed-off-by: MarioRadu --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 5bdc09c..3f9c051 100644 --- a/composer.json +++ b/composer.json @@ -103,7 +103,7 @@ } }, "scripts": { - "post-install-cmd": [ + "post-create-project-cmd": [ "@development-enable" ], "post-update-cmd": [ From a7fb0cd823c3124f649ca7bb6e100dc723361bda Mon Sep 17 00:00:00 2001 From: MarioRadu Date: Thu, 12 Dec 2024 22:40:41 +0200 Subject: [PATCH 26/32] ignore development files on production env Signed-off-by: MarioRadu --- bin/composer-post-install-script.php | 3 --- composer.json | 3 ++- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/bin/composer-post-install-script.php b/bin/composer-post-install-script.php index ad88535..1a07012 100644 --- a/bin/composer-post-install-script.php +++ b/bin/composer-post-install-script.php @@ -53,7 +53,4 @@ function getEnvironment(): string echo "Using environment setting: " . getEnvironment() . PHP_EOL; -var_dump(file_exists(\Laminas\DevelopmentMode\Status::DEVEL_CONFIG)); -var_dump(file_exists(\Laminas\DevelopmentMode\Status::DEVEL_CONFIG . '.dist')); - array_walk($files, 'copyFile'); diff --git a/composer.json b/composer.json index 3f9c051..50514d2 100644 --- a/composer.json +++ b/composer.json @@ -104,7 +104,8 @@ }, "scripts": { "post-create-project-cmd": [ - "@development-enable" + "@development-enable", + "echo Running post-create-project-cmd commands" ], "post-update-cmd": [ "php bin/composer-post-install-script.php" From e035b67f205a2c38c2470b2f4149bea6260c1937 Mon Sep 17 00:00:00 2001 From: MarioRadu Date: Thu, 12 Dec 2024 22:42:17 +0200 Subject: [PATCH 27/32] ignore development files on production env Signed-off-by: MarioRadu --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 50514d2..71a1ffe 100644 --- a/composer.json +++ b/composer.json @@ -108,7 +108,8 @@ "echo Running post-create-project-cmd commands" ], "post-update-cmd": [ - "php bin/composer-post-install-script.php" + "php bin/composer-post-install-script.php", + "echo Running post-update-cmd commands" ], "development-disable": "laminas-development-mode disable", "development-enable": "laminas-development-mode enable", From 81a3b7124826bc221b96735d9762cb2f92a57ea4 Mon Sep 17 00:00:00 2001 From: MarioRadu Date: Thu, 12 Dec 2024 22:50:34 +0200 Subject: [PATCH 28/32] ignore development files on production env Signed-off-by: MarioRadu --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 71a1ffe..ee94f26 100644 --- a/composer.json +++ b/composer.json @@ -104,12 +104,12 @@ }, "scripts": { "post-create-project-cmd": [ - "@development-enable", - "echo Running post-create-project-cmd commands" + "@development-enable" ], "post-update-cmd": [ + "laminas-development-mode status", "php bin/composer-post-install-script.php", - "echo Running post-update-cmd commands" + "laminas-development-mode status" ], "development-disable": "laminas-development-mode disable", "development-enable": "laminas-development-mode enable", From 8b694107150b5bc250125615bfae33f53df44419 Mon Sep 17 00:00:00 2001 From: MarioRadu Date: Thu, 12 Dec 2024 22:58:19 +0200 Subject: [PATCH 29/32] ignore development files on production env Signed-off-by: MarioRadu --- .github/workflows/codecov.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 77d3bf7..294782d 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -42,6 +42,8 @@ jobs: php${{ matrix.php }}-composer- - name: Install dependencies with composer + env: + COMPOSER_DEV_MODE=1 run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi # - name: Setup project From f55d182bb77b273529b3898ed84182c0957d3757 Mon Sep 17 00:00:00 2001 From: MarioRadu Date: Thu, 12 Dec 2024 23:08:39 +0200 Subject: [PATCH 30/32] ignore development files on production env Signed-off-by: MarioRadu --- bin/composer-post-install-script.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bin/composer-post-install-script.php b/bin/composer-post-install-script.php index 1a07012..5d5b92c 100644 --- a/bin/composer-post-install-script.php +++ b/bin/composer-post-install-script.php @@ -53,4 +53,6 @@ function getEnvironment(): string echo "Using environment setting: " . getEnvironment() . PHP_EOL; +var_dump(getenv('COMPOSER_DEV_MODE')); + array_walk($files, 'copyFile'); From fbfae3c5208c61cfab76a5740467cfe23a112830 Mon Sep 17 00:00:00 2001 From: MarioRadu Date: Thu, 12 Dec 2024 23:13:34 +0200 Subject: [PATCH 31/32] ignore development files on production env Signed-off-by: MarioRadu --- .github/workflows/codecov.yml | 4 ---- bin/composer-post-install-script.php | 5 ++--- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 294782d..f1b9163 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -46,10 +46,6 @@ jobs: COMPOSER_DEV_MODE=1 run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi -# - name: Setup project -# run: | -# mv config/autoload/local.test.php.dist config/autoload/local.test.php - - name: Collect code coverage with PHPUnit run: vendor/bin/phpunit --colors=always --coverage-clover clover.xml diff --git a/bin/composer-post-install-script.php b/bin/composer-post-install-script.php index 5d5b92c..93db277 100644 --- a/bin/composer-post-install-script.php +++ b/bin/composer-post-install-script.php @@ -28,7 +28,7 @@ function copyFile(array $file): void function getEnvironment(): string { - return file_exists(\Laminas\DevelopmentMode\Status::DEVEL_CONFIG) ? ENVIRONMENT_DEVELOPMENT : ENVIRONMENT_PRODUCTION; + return getenv('COMPOSER_DEV_MODE') === '1' ? ENVIRONMENT_DEVELOPMENT : ENVIRONMENT_PRODUCTION; } // when adding files to the below array the `source` and `destination` paths must be relative to the project root folder @@ -52,7 +52,6 @@ function getEnvironment(): string ]; echo "Using environment setting: " . getEnvironment() . PHP_EOL; - -var_dump(getenv('COMPOSER_DEV_MODE')); +var_dump("getenv('COMPOSER_DEV_MODE')", getenv('COMPOSER_DEV_MODE')); array_walk($files, 'copyFile'); From 5e687541bb49e5e9d84e1dddfc8cc4e97591e9f7 Mon Sep 17 00:00:00 2001 From: MarioRadu Date: Thu, 12 Dec 2024 23:21:08 +0200 Subject: [PATCH 32/32] ignore development files on production env Signed-off-by: MarioRadu --- bin/composer-post-install-script.php | 23 ++++++++++++----------- composer.json | 4 +--- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/bin/composer-post-install-script.php b/bin/composer-post-install-script.php index 93db277..c453f96 100644 --- a/bin/composer-post-install-script.php +++ b/bin/composer-post-install-script.php @@ -11,18 +11,20 @@ function copyFile(array $file): void { + if (! in_array(getEnvironment(), $file['environment'])) { + echo "Skipping the copy of {$file['source']} due to environment settings." . PHP_EOL; + return; + } + if (is_readable($file['destination'])) { - echo "File {$file['destination']} already exists." . PHP_EOL; + echo "File {$file['destination']} already exists. Skipping..." . PHP_EOL; + return; + } + + if (! copy($file['source'], $file['destination'])) { + echo "Cannot copy {$file['source']} file to {$file['destination']}" . PHP_EOL; } else { - if (! in_array(getEnvironment(), $file['environment'])) { - echo "Skipping the copy of {$file['source']} due to environment settings." . PHP_EOL; - } else { - if (! copy($file['source'], $file['destination'])) { - echo "Cannot copy {$file['source']} file to {$file['destination']}" . PHP_EOL; - } else { - echo "File {$file['source']} copied successfully to {$file['destination']}." . PHP_EOL; - } - } + echo "File {$file['source']} copied successfully to {$file['destination']}." . PHP_EOL; } } @@ -52,6 +54,5 @@ function getEnvironment(): string ]; echo "Using environment setting: " . getEnvironment() . PHP_EOL; -var_dump("getenv('COMPOSER_DEV_MODE')", getenv('COMPOSER_DEV_MODE')); array_walk($files, 'copyFile'); diff --git a/composer.json b/composer.json index ee94f26..3f9c051 100644 --- a/composer.json +++ b/composer.json @@ -107,9 +107,7 @@ "@development-enable" ], "post-update-cmd": [ - "laminas-development-mode status", - "php bin/composer-post-install-script.php", - "laminas-development-mode status" + "php bin/composer-post-install-script.php" ], "development-disable": "laminas-development-mode disable", "development-enable": "laminas-development-mode enable",