From d85b851af4bb4fc7287902b18ffe0ffe843f8f65 Mon Sep 17 00:00:00 2001 From: Florian Engelhardt Date: Mon, 19 Apr 2021 13:55:43 +0200 Subject: [PATCH] Update to latest base module --- .github/workflows/CI.yml | 51 +++++++++++++++++++++++++++++++++++ .github/workflows/CI.yml.dist | 45 +++++++++++++++++++++++++++++++ .php_cs.dist | 36 +++++++++---------------- .travis.yml | 29 -------------------- .travis.yml.dist | 28 ------------------- composer.json | 10 ++----- packages.json | 2 +- src/Installer.php | 15 ++++++----- 8 files changed, 120 insertions(+), 96 deletions(-) create mode 100644 .github/workflows/CI.yml create mode 100644 .github/workflows/CI.yml.dist delete mode 100644 .travis.yml delete mode 100644 .travis.yml.dist diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 0000000..2f21882 --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,51 @@ +name: CI + +on: [push, pull_request] + +jobs: + build: + runs-on: Ubuntu-20.04 + strategy: + matrix: + php: ['7.1', '7.2', '7.3', '7.4'] + DEPENDENCIES: ['', '--prefer-lowest'] + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + + - name: Get composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache dependencies + uses: actions/cache@v2 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Create project + run: composer create-project oxid-esales/graphql-module --repository packages.json --remove-vcs -n --no-plugins + + - name: Syntax Test + run: composer test:syntax + working-directory: ./graphql-module + + - name: Lint Test + run: composer test:lint + working-directory: ./graphql-module + + - name: Static Analyzer + run: composer test:static + working-directory: ./graphql-module + + - name: Unit Tests + run: composer test:unit + working-directory: ./graphql-module diff --git a/.github/workflows/CI.yml.dist b/.github/workflows/CI.yml.dist new file mode 100644 index 0000000..279ba9e --- /dev/null +++ b/.github/workflows/CI.yml.dist @@ -0,0 +1,45 @@ +name: CI + +on: [push, pull_request] + +jobs: + build: + runs-on: Ubuntu-20.04 + strategy: + matrix: + php: ['7.1', '7.2', '7.3', '7.4'] + DEPENDENCIES: ['', '--prefer-lowest'] + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + + - name: Get composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache dependencies + uses: actions/cache@v2 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Install + run: composer install -n --no-plugins $DEPENDENCIES + + - name: Syntax Test + run: composer test:syntax + + - name: Lint Test + run: composer test:lint + + - name: Static Analyzer + run: composer test:static + + - name: Unit Tests + run: composer test:unit diff --git a/.php_cs.dist b/.php_cs.dist index 5fe6903..be3de8d 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -3,40 +3,21 @@ declare(strict_types=1); $header = <<<'EOF' -Copyright © __Vendor__. All rights reserved. +Copyright © __Vender__. All rights reserved. See LICENSE file for license details. EOF; $finder = PhpCsFixer\Finder::create() ->exclude('Codeception/_support/_generated/') ->in(__DIR__ . '/src') - ->in(__DIR__ . '/tests/'); + ->in(__DIR__ . '/tests/') + ->name('*.stub'); return PhpCsFixer\Config::create() ->setFinder($finder) ->setRiskyAllowed(true) ->setRules([ - '@PSR2' => true, - 'blank_line_after_opening_tag' => true, - 'compact_nullable_typehint' => true, - 'declare_equal_normalize' => [ - 'space' => 'none' - ], - 'function_typehint_space' => true, - 'final_class' => true, - 'method_argument_space' => [ - 'on_multiline' => 'ensure_fully_multiline', - ], - 'new_with_braces' => true, - 'no_empty_statement' => true, - 'no_leading_import_slash' => true, - 'no_leading_namespace_whitespace' => true, - 'no_whitespace_in_blank_line' => true, - 'return_type_declaration' => [ - 'space_before' => 'none' - ], - 'single_trait_insert_per_statement' => true, - + '@PSR12' => true, 'align_multiline_comment' => [ 'comment_type' => 'all_multiline' ], @@ -91,6 +72,15 @@ return PhpCsFixer\Config::create() ], 'declare_strict_types' => true, 'dir_constant' => true, + 'final_internal_class' => [ + 'annotation-white-list' => [], + 'consider-absent-docblock-as-internal-class' => true, + 'annotation-black-list' => [ + '@eshopExtension', + '@dataType-extension', + '@extendable-dataType' + ], + ], 'global_namespace_import' => [ 'import_classes' => true, 'import_constants' => true, diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 97a6978..0000000 --- a/.travis.yml +++ /dev/null @@ -1,29 +0,0 @@ -language: php - -dist: bionic - -notifications: - email: false - -php: - - "7.1" - - "7.2" - - "7.3" - - "7.4" - -cache: - directories: - - $HOME/.composer/cache/files - -matrix: - fast_finish: true - -before_script: - - composer create-project oxid-esales/graphql-module --repository packages.json --remove-vcs -n - -script: - - cd graphql-module - - composer test:syntax - - composer test:lint - - composer test:static - - composer test:unit diff --git a/.travis.yml.dist b/.travis.yml.dist deleted file mode 100644 index e481963..0000000 --- a/.travis.yml.dist +++ /dev/null @@ -1,28 +0,0 @@ -language: php - -dist: bionic - -notifications: - email: false - -php: - - "7.1" - - "7.2" - - "7.3" - - "7.4" - -cache: - directories: - - $HOME/.composer/cache/files - -matrix: - fast_finish: true - -before_script: - - composer install --prefer-dist - -script: - - composer test:syntax - - composer test:lint - - composer test:static - - composer test:unit diff --git a/composer.json b/composer.json index beab275..49ed208 100644 --- a/composer.json +++ b/composer.json @@ -11,11 +11,11 @@ }, "require": { "php": "^7.1", - "oxid-esales/graphql-base": "^3.1.3" + "oxid-esales/graphql-base": "^5.1.1" }, "require-dev": { "phpunit/phpunit": "^7.5.20|^8.5|^9", - "friendsofphp/php-cs-fixer": "^2.16.4", + "friendsofphp/php-cs-fixer": "^2.18.2", "php-parallel-lint/php-parallel-lint": "^1.1", "phpstan/phpstan": "^0.12.26", "oxid-esales/oxideshop-ce": "^6.5", @@ -28,12 +28,6 @@ } }, "scripts": { - "pre-install-cmd": [ - "OxidEsales\\GraphQL\\Skeleton\\Installer::preInstall" - ], - "pre-update-cmd": [ - "OxidEsales\\GraphQL\\Skeleton\\Installer::preInstall" - ], "post-create-project-cmd": [ "OxidEsales\\GraphQL\\Skeleton\\Installer::postInstall", "composer update", diff --git a/packages.json b/packages.json index 9db7709..c70ad87 100644 --- a/packages.json +++ b/packages.json @@ -5,7 +5,7 @@ "source": { "url": "./", "type": "git", - "reference": "master" + "reference": "master-upgrade-to-latests-base" } } } diff --git a/src/Installer.php b/src/Installer.php index 37854ad..5470335 100644 --- a/src/Installer.php +++ b/src/Installer.php @@ -15,6 +15,10 @@ class Installer private static $packageName; public static function preInstall(Event $event): void + { + } + + public static function postInstall(Event $event = null): void { $io = $event->getIO(); $vendor = self::ask($io, 'What is the vendor?', 'MyVendor'); @@ -26,10 +30,9 @@ class Installer // Update composer definition $json->write($composerDefinition); $io->write("composer.json for {$composerDefinition['name']} is created.\n"); - } - public static function postInstall(Event $event = null): void - { + + unset($event); list($vendor, $package, $packageFull) = self::$packageName; $skeletonRoot = dirname(__DIR__); @@ -37,10 +40,9 @@ class Installer // remove installer files unlink($skeletonRoot.'/README.md'); unlink($skeletonRoot.'/LICENSE'); - unlink($skeletonRoot.'/.travis.yml'); unlink($skeletonRoot.'/packages.json'); rename($skeletonRoot.'/README.md.dist', $skeletonRoot.'/README.md'); - rename($skeletonRoot.'/.travis.yml.dist', $skeletonRoot.'/.travis.yml'); + rename($skeletonRoot.'/.github/workflows/CI.yml.dist', $skeletonRoot.'/.github/workflows/CI.yml'); unlink(__FILE__); } @@ -74,8 +76,7 @@ class Installer unset( $composerDefinition['autoload']['files'], $composerDefinition['scripts']['pre-install-cmd'], - $composerDefinition['scripts']['pre-update-cmd'], - $composerDefinition['scripts']['post-create-project-cmd'], + $composerDefinition['scripts']['post-install-cmd'], $composerDefinition['homepage'] );