From 29a174767ad052c6e84a8f18691a88dc765376da Mon Sep 17 00:00:00 2001 From: Denis Smet Date: Sun, 9 Jul 2023 17:04:55 +0400 Subject: [PATCH 01/14] New autoload method with $_composer_autoload_path --- composer-diff.php | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/composer-diff.php b/composer-diff.php index e7c116c..d9e05bc 100644 --- a/composer-diff.php +++ b/composer-diff.php @@ -20,17 +20,17 @@ const PATH_ROOT = __DIR__; -$vendorPaths = [ - __DIR__ . '/../../autoload.php', - __DIR__ . '/../vendor/autoload.php', - __DIR__ . '/vendor/autoload.php', -]; - -foreach ($vendorPaths as $file) { - if (\file_exists($file)) { - \define('JBZOO_AUTOLOAD_FILE', $file); - break; - } +$cwd = isset($_SERVER['PWD']) && \is_dir($_SERVER['PWD']) ? $_SERVER['PWD'] : \getcwd(); + +// See https://getcomposer.org/doc/articles/vendor-binaries.md#finding-the-composer-autoloader-from-a-binary +if ((isset($_composer_autoload_path) && \file_exists($autoloadFile = $_composer_autoload_path)) + || \file_exists($autoloadFile = __DIR__ . '/../../autoload.php') + || \file_exists($autoloadFile = __DIR__ . '/../autoload.php') + || \file_exists($autoloadFile = __DIR__ . '/vendor/autoload.php') +) { + \define('JBZOO_AUTOLOAD_FILE', $autoloadFile); +} else { + throw new \RuntimeException("Could not locate autoload.php. cwd is {$cwd}; __DIR__ is " . __DIR__); } require_once JBZOO_AUTOLOAD_FILE; @@ -38,4 +38,5 @@ $application = new CliApplication('JBZoo/Composer-Diff', '@git-version@'); $application->registerCommandsByPath(__DIR__ . '/src/Commands', __NAMESPACE__); $application->setDefaultCommand('diff'); + $application->run(); From e05c0e6604f5685ec415664a42d30b2ffb0c6653 Mon Sep 17 00:00:00 2001 From: Denis Smet Date: Sun, 9 Jul 2023 17:21:29 +0400 Subject: [PATCH 02/14] New autoload method with $_composer_autoload_path --- .github/workflows/box-project-issue.yml | 60 +++++++++++++++++++++++++ Makefile | 8 ++++ composer-diff.php | 2 - 3 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/box-project-issue.yml diff --git a/.github/workflows/box-project-issue.yml b/.github/workflows/box-project-issue.yml new file mode 100644 index 0000000..3818570 --- /dev/null +++ b/.github/workflows/box-project-issue.yml @@ -0,0 +1,60 @@ +# +# JBZoo Toolbox - Composer-Diff. +# +# This file is part of the JBZoo Toolbox project. +# For the full copyright and license information, please view the LICENSE +# file that was distributed with this source code. +# +# @license MIT +# @copyright Copyright (C) JBZoo.com, All rights reserved. +# @see https://github.com/JBZoo/Composer-Diff +# + +name: CI + +on: + pull_request: + branches: + - "*" + push: + branches: + - 'master' + schedule: + - cron: '39 */8 * * *' + +env: + COLUMNS: 120 + TERM_PROGRAM: Hyper + +jobs: + phar: + name: Phar + runs-on: ubuntu-latest + strategy: + matrix: + php-version: [ 8.1, 8.2 ] + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + coverage: none + tools: composer + + - name: Build the project + run: make build-phar-issue + + - name: Trying to use the phar file + run: ./build/composer-diff.phar diff --help + + - name: Upload Artifacts + uses: actions/upload-artifact@v3 + continue-on-error: true + with: + name: Reports - ${{ matrix.php-version }} + path: build/ diff --git a/Makefile b/Makefile index bf2fb09..75f3ac2 100644 --- a/Makefile +++ b/Makefile @@ -24,6 +24,14 @@ build: ##@Project Install all 3rd party dependencies @make create-symlink +build-phar-issue: + $(call title,"Building PHAR") + $(call download_phar,$(BOX_PHAR),"box") + rm -f ./build/composer-diff.phar || true + $(PHP_BIN) ./vendor/bin/box.phar compile -v + $(PHP_BIN) ./build/composer-diff.phar diff --help + + update: ##@Project Install/Update all 3rd party dependencies $(call title,"Install/Update all 3rd party dependencies") @composer update --optimize-autoloader --no-progress diff --git a/composer-diff.php b/composer-diff.php index d9e05bc..3eb351d 100644 --- a/composer-diff.php +++ b/composer-diff.php @@ -18,8 +18,6 @@ use JBZoo\Cli\CliApplication; -const PATH_ROOT = __DIR__; - $cwd = isset($_SERVER['PWD']) && \is_dir($_SERVER['PWD']) ? $_SERVER['PWD'] : \getcwd(); // See https://getcomposer.org/doc/articles/vendor-binaries.md#finding-the-composer-autoloader-from-a-binary From d0c145590acbd2ba3b3027ade672bce388ff2840 Mon Sep 17 00:00:00 2001 From: Denis Smet Date: Sun, 9 Jul 2023 17:21:56 +0400 Subject: [PATCH 03/14] New autoload method with $_composer_autoload_path --- .github/workflows/box-project-issue.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/box-project-issue.yml b/.github/workflows/box-project-issue.yml index 3818570..0807de7 100644 --- a/.github/workflows/box-project-issue.yml +++ b/.github/workflows/box-project-issue.yml @@ -10,7 +10,7 @@ # @see https://github.com/JBZoo/Composer-Diff # -name: CI +name: Box Project Issue on: pull_request: From a4e2e9a23d36047f41e47b413c00fae1cc090e23 Mon Sep 17 00:00:00 2001 From: Denis Smet Date: Sun, 9 Jul 2023 17:23:34 +0400 Subject: [PATCH 04/14] New autoload method with $_composer_autoload_path --- .github/workflows/box-project-issue.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/box-project-issue.yml b/.github/workflows/box-project-issue.yml index 0807de7..735c026 100644 --- a/.github/workflows/box-project-issue.yml +++ b/.github/workflows/box-project-issue.yml @@ -46,7 +46,10 @@ jobs: coverage: none tools: composer - - name: Build the project + - name: Download dependencies + run: make build + + - name: Build Phar file run: make build-phar-issue - name: Trying to use the phar file From 8e6be8c1c2259ea96c373987c29c86f0e1fe2069 Mon Sep 17 00:00:00 2001 From: Denis Smet Date: Sun, 9 Jul 2023 17:25:22 +0400 Subject: [PATCH 05/14] New autoload method with $_composer_autoload_path --- .github/workflows/box-project-issue.yml | 7 +------ Makefile | 1 + 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/box-project-issue.yml b/.github/workflows/box-project-issue.yml index 735c026..4cb5c0d 100644 --- a/.github/workflows/box-project-issue.yml +++ b/.github/workflows/box-project-issue.yml @@ -16,11 +16,6 @@ on: pull_request: branches: - "*" - push: - branches: - - 'master' - schedule: - - cron: '39 */8 * * *' env: COLUMNS: 120 @@ -47,7 +42,7 @@ jobs: tools: composer - name: Download dependencies - run: make build + run: make update - name: Build Phar file run: make build-phar-issue diff --git a/Makefile b/Makefile index 75f3ac2..5b8c7b5 100644 --- a/Makefile +++ b/Makefile @@ -28,6 +28,7 @@ build-phar-issue: $(call title,"Building PHAR") $(call download_phar,$(BOX_PHAR),"box") rm -f ./build/composer-diff.phar || true + composer --version $(PHP_BIN) ./vendor/bin/box.phar compile -v $(PHP_BIN) ./build/composer-diff.phar diff --help From c8580fb4467eeed6bbf4a0a8a8f70162fb078618 Mon Sep 17 00:00:00 2001 From: Denis Smet Date: Sun, 9 Jul 2023 17:32:21 +0400 Subject: [PATCH 06/14] New autoload method with $_composer_autoload_path --- .github/workflows/box-project-issue.yml | 3 --- Makefile | 12 ++++++++++-- composer.lock | 8 ++++---- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/.github/workflows/box-project-issue.yml b/.github/workflows/box-project-issue.yml index 4cb5c0d..cf24bc4 100644 --- a/.github/workflows/box-project-issue.yml +++ b/.github/workflows/box-project-issue.yml @@ -41,9 +41,6 @@ jobs: coverage: none tools: composer - - name: Download dependencies - run: make update - - name: Build Phar file run: make build-phar-issue diff --git a/Makefile b/Makefile index 5b8c7b5..36fb0bb 100644 --- a/Makefile +++ b/Makefile @@ -25,11 +25,19 @@ build: ##@Project Install all 3rd party dependencies build-phar-issue: - $(call title,"Building PHAR") + $(call title,"Download dependencies") + make update $(call download_phar,$(BOX_PHAR),"box") - rm -f ./build/composer-diff.phar || true + $(call title,"Current versions") + php -v composer --version + /usr/local/bin/composer --version + which composer + echo $BOX_PHAR + $(PHP_BIN) ./vendor/bin/box.phar --version + $(call title,"Compiling phar-file") $(PHP_BIN) ./vendor/bin/box.phar compile -v + $(call title,"Try to execute the phar-file") $(PHP_BIN) ./build/composer-diff.phar diff --help diff --git a/composer.lock b/composer.lock index 735c444..3d2f16b 100644 --- a/composer.lock +++ b/composer.lock @@ -3094,12 +3094,12 @@ "source": { "type": "git", "url": "https://github.com/JBZoo/Codestyle.git", - "reference": "c68ba65f96407a5f1f6d0aa7e8943e2c9d710f4b" + "reference": "999f41d3d23f0a5c174ac7fa22e79e57341f8d06" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/JBZoo/Codestyle/zipball/c68ba65f96407a5f1f6d0aa7e8943e2c9d710f4b", - "reference": "c68ba65f96407a5f1f6d0aa7e8943e2c9d710f4b", + "url": "https://api.github.com/repos/JBZoo/Codestyle/zipball/999f41d3d23f0a5c174ac7fa22e79e57341f8d06", + "reference": "999f41d3d23f0a5c174ac7fa22e79e57341f8d06", "shasum": "" }, "require": { @@ -3174,7 +3174,7 @@ "issues": "https://github.com/JBZoo/Codestyle/issues", "source": "https://github.com/JBZoo/Codestyle/tree/master" }, - "time": "2023-07-08T10:54:53+00:00" + "time": "2023-07-09T12:50:16+00:00" }, { "name": "jbzoo/jbdump", From c4771985abe8446dcc19fc789569bc8b432982ae Mon Sep 17 00:00:00 2001 From: Denis Smet Date: Sun, 9 Jul 2023 17:37:23 +0400 Subject: [PATCH 07/14] New autoload method with $_composer_autoload_path --- .github/workflows/box-project-issue.yml | 14 +++++++++++++- Makefile | 16 ++-------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/box-project-issue.yml b/.github/workflows/box-project-issue.yml index cf24bc4..e3303b5 100644 --- a/.github/workflows/box-project-issue.yml +++ b/.github/workflows/box-project-issue.yml @@ -41,8 +41,20 @@ jobs: coverage: none tools: composer + - name: Download Dependencies + run: make download-deps + + - name: Show versions of tools + run: | + which php + php -v + which composer + composer --version + /usr/local/bin/composer --version + php ./vendor/bin/box.phar --version + - name: Build Phar file - run: make build-phar-issue + run: php ./vendor/bin/box.phar compile -v - name: Trying to use the phar file run: ./build/composer-diff.phar diff --help diff --git a/Makefile b/Makefile index 36fb0bb..707513f 100644 --- a/Makefile +++ b/Makefile @@ -24,21 +24,9 @@ build: ##@Project Install all 3rd party dependencies @make create-symlink -build-phar-issue: - $(call title,"Download dependencies") - make update +download-deps: + composer update --optimize-autoloader --no-progress $(call download_phar,$(BOX_PHAR),"box") - $(call title,"Current versions") - php -v - composer --version - /usr/local/bin/composer --version - which composer - echo $BOX_PHAR - $(PHP_BIN) ./vendor/bin/box.phar --version - $(call title,"Compiling phar-file") - $(PHP_BIN) ./vendor/bin/box.phar compile -v - $(call title,"Try to execute the phar-file") - $(PHP_BIN) ./build/composer-diff.phar diff --help update: ##@Project Install/Update all 3rd party dependencies From 525ade3d4c8381e0bbb6ef137254929a258645ee Mon Sep 17 00:00:00 2001 From: Denis Smet Date: Sun, 9 Jul 2023 17:40:47 +0400 Subject: [PATCH 08/14] New autoload method with $_composer_autoload_path --- .github/workflows/box-project-issue.yml | 6 ++++++ Makefile | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/box-project-issue.yml b/.github/workflows/box-project-issue.yml index e3303b5..6655782 100644 --- a/.github/workflows/box-project-issue.yml +++ b/.github/workflows/box-project-issue.yml @@ -46,11 +46,17 @@ jobs: - name: Show versions of tools run: | + echo '1. -------' which php + echo '2. -------' php -v + echo '3. -------' which composer + echo '4. -------' composer --version + echo '5. -------' /usr/local/bin/composer --version + echo '6. -------' php ./vendor/bin/box.phar --version - name: Build Phar file diff --git a/Makefile b/Makefile index 707513f..bc4b3cd 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,8 @@ build: ##@Project Install all 3rd party dependencies download-deps: - composer update --optimize-autoloader --no-progress + @composer update --optimize-autoloader --no-progress + @echo $(BOX_PHAR) $(call download_phar,$(BOX_PHAR),"box") From 8b1faac00d141b2ab7464a052232f7eaece7e538 Mon Sep 17 00:00:00 2001 From: Denis Smet Date: Sun, 9 Jul 2023 17:44:17 +0400 Subject: [PATCH 09/14] New autoload method with $_composer_autoload_path --- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index bc4b3cd..df6f4e2 100644 --- a/Makefile +++ b/Makefile @@ -26,8 +26,9 @@ build: ##@Project Install all 3rd party dependencies download-deps: @composer update --optimize-autoloader --no-progress - @echo $(BOX_PHAR) - $(call download_phar,$(BOX_PHAR),"box") + curl $(BOX_PHAR) --output "$(PATH_ROOT)/vendor/bin/box.phar" \ + --connect-timeout 5 --max-time 10 --retry 5 --retry-delay 1 --retry-max-time 40 \ + --location --fail --silent --show-error update: ##@Project Install/Update all 3rd party dependencies From 8f2d49e1f713da3e75da41e8b4b88be17cc2f3bd Mon Sep 17 00:00:00 2001 From: Denis Smet Date: Sun, 9 Jul 2023 17:44:23 +0400 Subject: [PATCH 10/14] New autoload method with $_composer_autoload_path --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index df6f4e2..8ca8db9 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,7 @@ build: ##@Project Install all 3rd party dependencies download-deps: - @composer update --optimize-autoloader --no-progress + composer update --optimize-autoloader --no-progress curl $(BOX_PHAR) --output "$(PATH_ROOT)/vendor/bin/box.phar" \ --connect-timeout 5 --max-time 10 --retry 5 --retry-delay 1 --retry-max-time 40 \ --location --fail --silent --show-error From 886f28fc9cf5af87688e2f004763ce853d2141f2 Mon Sep 17 00:00:00 2001 From: Denis Smet Date: Sun, 9 Jul 2023 17:45:35 +0400 Subject: [PATCH 11/14] New autoload method with $_composer_autoload_path --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 8ca8db9..ffdff00 100644 --- a/Makefile +++ b/Makefile @@ -26,9 +26,9 @@ build: ##@Project Install all 3rd party dependencies download-deps: composer update --optimize-autoloader --no-progress - curl $(BOX_PHAR) --output "$(PATH_ROOT)/vendor/bin/box.phar" \ - --connect-timeout 5 --max-time 10 --retry 5 --retry-delay 1 --retry-max-time 40 \ - --location --fail --silent --show-error + curl https://github.com/box-project/box/releases/latest/download/box.phar \ + --output "$(PATH_ROOT)/vendor/bin/box.phar" + update: ##@Project Install/Update all 3rd party dependencies From 951b535555f684e1812525fdb791657c58b01127 Mon Sep 17 00:00:00 2001 From: Denis Smet Date: Sun, 9 Jul 2023 17:46:40 +0400 Subject: [PATCH 12/14] New autoload method with $_composer_autoload_path --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ffdff00..4af342e 100644 --- a/Makefile +++ b/Makefile @@ -27,7 +27,7 @@ build: ##@Project Install all 3rd party dependencies download-deps: composer update --optimize-autoloader --no-progress curl https://github.com/box-project/box/releases/latest/download/box.phar \ - --output "$(PATH_ROOT)/vendor/bin/box.phar" + --output ./vendor/bin/box.phar From 45ffd92a0a9d8275689b7eaa2bd76e679d6467c8 Mon Sep 17 00:00:00 2001 From: Denis Smet Date: Sun, 9 Jul 2023 17:50:41 +0400 Subject: [PATCH 13/14] New autoload method with $_composer_autoload_path --- Makefile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 4af342e..540b9df 100644 --- a/Makefile +++ b/Makefile @@ -27,8 +27,10 @@ build: ##@Project Install all 3rd party dependencies download-deps: composer update --optimize-autoloader --no-progress curl https://github.com/box-project/box/releases/latest/download/box.phar \ - --output ./vendor/bin/box.phar - + --output ./vendor/bin/box.phar \ + --connect-timeout 5 --max-time 10 --retry 5 --retry-delay 1 --retry-max-time 40 \ + --location --fail --silent --show-error + chmod +x ./vendor/bin/box.phar update: ##@Project Install/Update all 3rd party dependencies From 0f9750b54d4df305c7a6ec7f28c8a0bdda9757f0 Mon Sep 17 00:00:00 2001 From: Denis Smet Date: Sun, 9 Jul 2023 17:53:27 +0400 Subject: [PATCH 14/14] New autoload method with $_composer_autoload_path --- .github/workflows/box-project-issue.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/box-project-issue.yml b/.github/workflows/box-project-issue.yml index 6655782..066c3fd 100644 --- a/.github/workflows/box-project-issue.yml +++ b/.github/workflows/box-project-issue.yml @@ -46,17 +46,17 @@ jobs: - name: Show versions of tools run: | - echo '1. -------' + echo '1. which php' which php - echo '2. -------' + echo '2. php -v' php -v - echo '3. -------' + echo '3. which composer' which composer - echo '4. -------' + echo '4. composer --version' composer --version - echo '5. -------' + echo '5. /usr/local/bin/composer --version' /usr/local/bin/composer --version - echo '6. -------' + echo '6. php ./vendor/bin/box.phar --version' php ./vendor/bin/box.phar --version - name: Build Phar file