From 237e9ba266caa6c746b6506392eef98961375609 Mon Sep 17 00:00:00 2001 From: Achim Fritz Date: Thu, 23 May 2024 16:26:41 +0200 Subject: [PATCH] !!! [TASK] change requirements * drop TYPO3 10 Support * add TYPO3 13 Support * use CI --- .github/workflows/ci.yml | 55 +++++++++++++++++++++ .php-cs-fixer.php => Build/php-cs-fixer.php | 0 Build/phpstan.neon | 11 +++++ Build/phpstan11.neon | 12 +++++ Build/phpstan12.neon | 6 +++ Configuration/Services.yaml | 2 - Configuration/user.tsconfig | 3 ++ composer.json | 16 ++++-- ext_emconf.php | 2 +- ext_localconf.php | 22 ++++++++- ext_tables.php | 32 ++++++------ 11 files changed, 137 insertions(+), 24 deletions(-) create mode 100644 .github/workflows/ci.yml rename .php-cs-fixer.php => Build/php-cs-fixer.php (100%) create mode 100644 Build/phpstan.neon create mode 100644 Build/phpstan11.neon create mode 100644 Build/phpstan12.neon create mode 100644 Configuration/user.tsconfig diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..f920d3b --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,55 @@ +name: CI + +on: [push, pull_request] + +jobs: + testsuite: + + runs-on: ubuntu-latest + strategy: + matrix: + TYPO3: ['11' , '12', '13'] + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set up PHP Version + uses: shivammathur/setup-php@v2 + with: + php-version: 8.3 + tools: composer:v2 + + - name: Validate composer.json and composer.lock + run: composer validate + + - name: Cache dependencies + uses: actions/cache@v1 + with: + path: ~/.composer/cache + key: dependencies-composer-${{ hashFiles('composer.json') }} + + - name: Install composer dependencies TYPO3 13 + if: matrix.TYPO3 == '13' + run: | + composer install --no-progress --no-interaction + + - name: Install composer dependencies TYPO3 12 + if: matrix.TYPO3 == '12' + run: | + composer require typo3/cms-core:^12.4 --no-progress --no-interaction --dev -W + - name: Install composer dependencies TYPO3 11 + if: matrix.TYPO3 == '11' + run: | + composer require typo3/cms-core:^11.5 --no-progress --no-interaction --dev -W + - name: Phpstan 13 + if: matrix.TYPO3 == '13' + run: ./vendor/bin/phpstan analyze -c Build/phpstan.neon + - name: Phpstan 12 + if: matrix.TYPO3 == '12' + run: ./vendor/bin/phpstan analyze -c Build/phpstan12.neon + - name: Phpstan 11 + if: matrix.TYPO3 == '11' + run: ./vendor/bin/phpstan analyze -c Build/phpstan11.neon + - name: Phpcsfix + run: ./vendor/bin/php-cs-fixer fix --config=Build/php-cs-fixer.php --dry-run --stop-on-violation --using-cache=no diff --git a/.php-cs-fixer.php b/Build/php-cs-fixer.php similarity index 100% rename from .php-cs-fixer.php rename to Build/php-cs-fixer.php diff --git a/Build/phpstan.neon b/Build/phpstan.neon new file mode 100644 index 0000000..9be25ff --- /dev/null +++ b/Build/phpstan.neon @@ -0,0 +1,11 @@ +includes: + - ../vendor/saschaegerer/phpstan-typo3/extension.neon +parameters: + level: 5 + paths: + - %currentWorkingDirectory%/Classes + excludePaths: + - %currentWorkingDirectory%/Classes/TypoScript/Loader.php + ignoreErrors: + - '#.*unknown class TYPO3\\CMS\\Core\\Configuration\\Event\\ModifyLoadedPageTsConfigEvent.#' + - '#.*invalid type TYPO3\\CMS\\Core\\Configuration\\Event\\ModifyLoadedPageTsConfigEvent.#' diff --git a/Build/phpstan11.neon b/Build/phpstan11.neon new file mode 100644 index 0000000..066d764 --- /dev/null +++ b/Build/phpstan11.neon @@ -0,0 +1,12 @@ +includes: + - ../vendor/saschaegerer/phpstan-typo3/extension.neon +parameters: + level: 5 + paths: + - %currentWorkingDirectory%/Classes + + ignoreErrors: + - '#.*unknown class TYPO3\\CMS\\Core\\TypoScript\\IncludeTree\\Event\\ModifyLoadedPageTsConfigEvent.#' + - '#.*invalid type TYPO3\\CMS\\Core\\TypoScript\\IncludeTree\\Event\\ModifyLoadedPageTsConfigEvent.#' + - '#.*unknown class TYPO3\\CMS\\Core\\TypoScript\\IncludeTree\\Event\\AfterTemplatesHaveBeenDeterminedEvent.#' + - '#.*invalid type TYPO3\\CMS\\Core\\TypoScript\\IncludeTree\\Event\\AfterTemplatesHaveBeenDeterminedEvent.#' diff --git a/Build/phpstan12.neon b/Build/phpstan12.neon new file mode 100644 index 0000000..793a614 --- /dev/null +++ b/Build/phpstan12.neon @@ -0,0 +1,6 @@ +includes: + - ../vendor/saschaegerer/phpstan-typo3/extension.neon +parameters: + level: 5 + paths: + - %currentWorkingDirectory%/Classes diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml index 27fa946..cbc1727 100644 --- a/Configuration/Services.yaml +++ b/Configuration/Services.yaml @@ -32,5 +32,3 @@ services: tags: - name: event.listener identifier: 'b13-bolt/add-typoscript-from-site-extension' - # for v10 compat, optional since v11 - event: TYPO3\CMS\Core\TypoScript\IncludeTree\Event\AfterTemplatesHaveBeenDeterminedEvent diff --git a/Configuration/user.tsconfig b/Configuration/user.tsconfig new file mode 100644 index 0000000..729738c --- /dev/null +++ b/Configuration/user.tsconfig @@ -0,0 +1,3 @@ +# default user ts config for v13 +# Hide tstemplate "Edit TypoScript record" and "Constant Editor" in core v12 +options.hideModules := addToList(web_typoscript_infomodify, web_typoscript_constanteditor) diff --git a/composer.json b/composer.json index 8fa512c..1770320 100644 --- a/composer.json +++ b/composer.json @@ -6,8 +6,9 @@ "license": "GPL-2.0-or-later", "keywords": ["TYPO3 CMS", "Integrators", "Site Extension", "Site Package", "TypoScript"], "require": { - "php": "^7.2 || ^8.0", - "typo3/cms-core": "^10.4 || ^11.0 || ^12.0" + "php": "^7.4 || ^8.0", + "typo3/cms-core": "^11.0 || ^12.0 || ^13.1", + "typo3/cms-backend": "^11.0 || ^12.0 || ^13.1" }, "replace": { "cmsexperts/bolt": "*", @@ -24,13 +25,18 @@ } }, "require-dev": { - "typo3/coding-standards": "^0.4.0", + "saschaegerer/phpstan-typo3": "^1.8", + "typo3/coding-standards": "^0.5.5", "typo3/tailor": "^1.1" }, "config": { - "sort-packages": true + "sort-packages": true, + "allow-plugins": { + "typo3/cms-composer-installers": true, + "typo3/class-alias-loader": true + } }, "scripts": { - "php:cs": "@composer exec php-cs-fixer fix" + "php:cs": "@composer exec 'php-cs-fixer fix --config=Build/php-cs-fixer.php'" } } diff --git a/ext_emconf.php b/ext_emconf.php index 3691fa5..13c9a30 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -12,7 +12,7 @@ 'author_company' => 'b13 GmbH', 'constraints' => [ 'depends' => [ - 'typo3' => '10.4.0-12.99.99', + 'typo3' => '11.5.0-13.99.99', ], ], ]; diff --git a/ext_localconf.php b/ext_localconf.php index 3f8cbc0..844be2f 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -2,5 +2,23 @@ defined('TYPO3') or die(); -// Register autoloading for TypoScript for TYPO3 v10 and v11 -$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['Core/TypoScript/TemplateService']['runThroughTemplatesPostProcessing']['bolt'] = \B13\Bolt\TypoScript\Loader::class . '->addSiteConfiguration'; +(function() { + // Register autoloading for TypoScript for TYPO3 v11 + $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['Core/TypoScript/TemplateService']['runThroughTemplatesPostProcessing']['bolt'] = \B13\Bolt\TypoScript\Loader::class . '->addSiteConfiguration'; + + // v13 Page TS + $pageTs = ' +# Disable adding new sys_template records in list module +mod.web_list.deniedNewTables := addToList(sys_template) + +# Hide TSconfig and tsconfig_includes fields when editing pages +TCEFORM.pages.TSconfig.disabled=1 +TCEFORM.pages.tsconfig_includes.disabled=1 +'; + + if (isset($GLOBALS['TYPO3_CONF_VARS']['BE']['defaultPageTSconfig'])) { + $GLOBALS['TYPO3_CONF_VARS']['BE']['defaultPageTSconfig'] .= $pageTs; + } else { + $GLOBALS['TYPO3_CONF_VARS']['BE']['defaultPageTSconfig'] = $pageTs; + } +})(); diff --git a/ext_tables.php b/ext_tables.php index 54ebe7e..4d6ff5f 100644 --- a/ext_tables.php +++ b/ext_tables.php @@ -2,20 +2,24 @@ defined('TYPO3') or die(); -\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig(' - # Disable adding new sys_template records in list module - mod.web_list.deniedNewTables := addToList(sys_template) +if ((\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Information\Typo3Version::class))->getMajorVersion() < 12) { + // $GLOBALS['TYPO3_CONF_VARS']['BE']['defaultPageTSconfig'] is used for v13 + \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig(' +# Disable adding new sys_template records in list module +mod.web_list.deniedNewTables := addToList(sys_template) - # Hide tstemplate "Info/Modify" and "Constant Editor" in core v10 & v11 - mod.web_ts.menu.function.TYPO3\CMS\Tstemplate\Controller\TypoScriptTemplateConstantEditorModuleFunctionController = 0 - mod.web_ts.menu.function.TYPO3\CMS\Tstemplate\Controller\TypoScriptTemplateInformationModuleFunctionController = 0 +# Hide tstemplate "Info/Modify" and "Constant Editor" in core v11 +mod.web_ts.menu.function.TYPO3\CMS\Tstemplate\Controller\TypoScriptTemplateConstantEditorModuleFunctionController = 0 +mod.web_ts.menu.function.TYPO3\CMS\Tstemplate\Controller\TypoScriptTemplateInformationModuleFunctionController = 0 - # Hide TSconfig and tsconfig_includes fields when editing pages - TCEFORM.pages.TSconfig.disabled=1 - TCEFORM.pages.tsconfig_includes.disabled=1 -'); +# Hide TSconfig and tsconfig_includes fields when editing pages +TCEFORM.pages.TSconfig.disabled=1 +TCEFORM.pages.tsconfig_includes.disabled=1 + '); -\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addUserTSConfig(' - # Hide tstemplate "Edit TypoScript record" and "Constant Editor" in core v12 - options.hideModules := addToList(web_typoscript_infomodify, web_typoscript_constanteditor) -'); + // Configuration/user.tsconfig is used for v13 + \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addUserTSConfig(' +# Hide tstemplate "Edit TypoScript record" and "Constant Editor" in core v12 +options.hideModules := addToList(web_typoscript_infomodify, web_typoscript_constanteditor) + '); +};