diff --git a/.github/workflows/box-project-issue.yml b/.github/workflows/box-project-issue.yml new file mode 100644 index 0000000..066c3fd --- /dev/null +++ b/.github/workflows/box-project-issue.yml @@ -0,0 +1,73 @@ +# +# 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: Box Project Issue + +on: + pull_request: + branches: + - "*" + +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: Download Dependencies + run: make download-deps + + - name: Show versions of tools + run: | + echo '1. which php' + which php + echo '2. php -v' + php -v + echo '3. which composer' + which composer + echo '4. composer --version' + composer --version + echo '5. /usr/local/bin/composer --version' + /usr/local/bin/composer --version + echo '6. php ./vendor/bin/box.phar --version' + php ./vendor/bin/box.phar --version + + - name: Build Phar file + run: php ./vendor/bin/box.phar compile -v + + - 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..540b9df 100644 --- a/Makefile +++ b/Makefile @@ -24,6 +24,15 @@ build: ##@Project Install all 3rd party dependencies @make create-symlink +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 \ + --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 $(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 e7c116c..3eb351d 100644 --- a/composer-diff.php +++ b/composer-diff.php @@ -18,19 +18,17 @@ use JBZoo\Cli\CliApplication; -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 +36,5 @@ $application = new CliApplication('JBZoo/Composer-Diff', '@git-version@'); $application->registerCommandsByPath(__DIR__ . '/src/Commands', __NAMESPACE__); $application->setDefaultCommand('diff'); + $application->run(); 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",