From 1541f4f8ecedface159bd1c9d14cb401048e00d7 Mon Sep 17 00:00:00 2001 From: Eike Starkmann Date: Wed, 31 Jul 2024 11:22:31 +0200 Subject: [PATCH 1/4] [FEATURE] One command to fix them all Fixes #1386 --- Build/Scripts/runTests.sh | 11 +++++++++++ composer.json | 1 + 2 files changed, 12 insertions(+) diff --git a/Build/Scripts/runTests.sh b/Build/Scripts/runTests.sh index 99b6a60..5964e46 100755 --- a/Build/Scripts/runTests.sh +++ b/Build/Scripts/runTests.sh @@ -540,6 +540,17 @@ case ${TEST_SUITE} in ${CONTAINER_BIN} run ${CONTAINER_INTERACTIVE} --rm --pull always ${USERSET} -v "${ROOT_DIR}":/project ${IMAGE_DOCS} --config=Documentation --fail-on-log SUITE_EXIT_CODE=$? ;; + fix) + COMMAND="composer fix" + ${CONTAINER_BIN} run ${CONTAINER_COMMON_PARAMS} --name composer-command-${SUFFIX} -e COMPOSER_CACHE_DIR=.cache/composer -e COMPOSER_ROOT_VERSION=${COMPOSER_ROOT_VERSION} ${IMAGE_PHP} /bin/sh -c "${COMMAND}" + COMMAND="composer normalize" + ${CONTAINER_BIN} run ${CONTAINER_COMMON_PARAMS} --name composer-command-${SUFFIX} -e COMPOSER_CACHE_DIR=.cache/composer -e COMPOSER_ROOT_VERSION=${COMPOSER_ROOT_VERSION} ${IMAGE_PHP} /bin/sh -c "${COMMAND}" + COMMAND="echo ${HELP_TEXT_NPM_CI}; npm ci --silent || { echo ${HELP_TEXT_NPM_FAILURE}; exit 1; } && npm run fix:lint:js" + ${CONTAINER_BIN} run ${CONTAINER_COMMON_PARAMS} --name npm-command-${SUFFIX} ${IMAGE_NODE} /bin/sh -c "${COMMAND}" + COMMAND="echo ${HELP_TEXT_NPM_CI}; npm ci --silent || { echo ${HELP_TEXT_NPM_FAILURE}; exit 1; } && npm run fix:lint:css" + ${CONTAINER_BIN} run ${CONTAINER_COMMON_PARAMS} --name npm-command-${SUFFIX} ${IMAGE_NODE} /bin/sh -c "${COMMAND}" + SUITE_EXIT_CODE=$? + ;; shellcheck) ${CONTAINER_BIN} run ${CONTAINER_INTERACTIVE} --rm --pull always ${USERSET} -v "${ROOT_DIR}":/project:ro -e SHELLCHECK_OPTS="-e SC2086" ${IMAGE_SHELLCHECK} /project/Build/Scripts/runTests.sh SUITE_EXIT_CODE=$? diff --git a/composer.json b/composer.json index 4502904..03b417d 100644 --- a/composer.json +++ b/composer.json @@ -172,6 +172,7 @@ "ci:yaml:lint": "find . ! -path '*.Build/*' ! -path '*node_modules/*' \\( -name '*.yaml' -o -name '*.yml' \\) | xargs -r php ./.Build/bin/yaml-lint", "coverage:create-directories": "mkdir -p build/coverage build/logs", "docs:generate": "docker run --rm --pull always -v $(pwd):/project -it ghcr.io/typo3-documentation/render-guides:latest --config=Documentation", + "fix": "@fix:php", "fix:composer:normalize": "@composer normalize --no-check-lock", "fix:php": [ "@fix:php:cs", From 5fc8cf25a0f0997dfb54fbe01d8fba1cf5765ca6 Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Tue, 17 Sep 2024 14:04:22 +0200 Subject: [PATCH 2/4] Add help text for the `fix` command --- Build/Scripts/runTests.sh | 1 + composer.json | 1 + 2 files changed, 2 insertions(+) diff --git a/Build/Scripts/runTests.sh b/Build/Scripts/runTests.sh index 5964e46..51484a2 100755 --- a/Build/Scripts/runTests.sh +++ b/Build/Scripts/runTests.sh @@ -154,6 +154,7 @@ Options: - composerUpdateMax: "composer update", with no platform.php config. - composerUpdateMin: "composer update --prefer-lowest", with platform.php set to PHP version x.x.0. - docsGenerate: Renders the extension ReST documentation. + - fix: Runs all automatic code style fixes. - functional: PHP functional tests - lintCss: CSS file linting. Set -n for dry-run. - lintJs: JavaScript file linting. Set -n for dry-run. diff --git a/composer.json b/composer.json index 03b417d..3876efc 100644 --- a/composer.json +++ b/composer.json @@ -230,6 +230,7 @@ "ci:yaml:lint": "Lints the YAML files.", "coverage:create-directories": "Creates the directories needed for recording and merging the code coverage reports.", "docs:generate": "Renders the extension ReST documentation.", + "fix": "Runs all automatic code style fixes.", "fix:composer:normalize": "Normalizes composer.json file content.", "fix:php": "Runs all fixers for the PHP code.", "fix:php:cs": "Fixes the code style with PHP-CS-Fixer.", From 86f057b0ae7f4c11c526bc32912a6b187ef71ac8 Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Tue, 17 Sep 2024 14:14:10 +0200 Subject: [PATCH 3/4] Include `composer normalize` in the `fix` command --- Build/Scripts/runTests.sh | 2 -- composer.json | 5 ++++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Build/Scripts/runTests.sh b/Build/Scripts/runTests.sh index 51484a2..5a6f740 100755 --- a/Build/Scripts/runTests.sh +++ b/Build/Scripts/runTests.sh @@ -544,8 +544,6 @@ case ${TEST_SUITE} in fix) COMMAND="composer fix" ${CONTAINER_BIN} run ${CONTAINER_COMMON_PARAMS} --name composer-command-${SUFFIX} -e COMPOSER_CACHE_DIR=.cache/composer -e COMPOSER_ROOT_VERSION=${COMPOSER_ROOT_VERSION} ${IMAGE_PHP} /bin/sh -c "${COMMAND}" - COMMAND="composer normalize" - ${CONTAINER_BIN} run ${CONTAINER_COMMON_PARAMS} --name composer-command-${SUFFIX} -e COMPOSER_CACHE_DIR=.cache/composer -e COMPOSER_ROOT_VERSION=${COMPOSER_ROOT_VERSION} ${IMAGE_PHP} /bin/sh -c "${COMMAND}" COMMAND="echo ${HELP_TEXT_NPM_CI}; npm ci --silent || { echo ${HELP_TEXT_NPM_FAILURE}; exit 1; } && npm run fix:lint:js" ${CONTAINER_BIN} run ${CONTAINER_COMMON_PARAMS} --name npm-command-${SUFFIX} ${IMAGE_NODE} /bin/sh -c "${COMMAND}" COMMAND="echo ${HELP_TEXT_NPM_CI}; npm ci --silent || { echo ${HELP_TEXT_NPM_FAILURE}; exit 1; } && npm run fix:lint:css" diff --git a/composer.json b/composer.json index 3876efc..30ec722 100644 --- a/composer.json +++ b/composer.json @@ -172,7 +172,10 @@ "ci:yaml:lint": "find . ! -path '*.Build/*' ! -path '*node_modules/*' \\( -name '*.yaml' -o -name '*.yml' \\) | xargs -r php ./.Build/bin/yaml-lint", "coverage:create-directories": "mkdir -p build/coverage build/logs", "docs:generate": "docker run --rm --pull always -v $(pwd):/project -it ghcr.io/typo3-documentation/render-guides:latest --config=Documentation", - "fix": "@fix:php", + "fix": [ + "@fix:composer:normalize", + "@fix:php" + ], "fix:composer:normalize": "@composer normalize --no-check-lock", "fix:php": [ "@fix:php:cs", From baa0f9790166acddbca61f27ee129a768ea81c5a Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Tue, 17 Sep 2024 14:43:28 +0200 Subject: [PATCH 4/4] Document the new `fix` Composer script in the manual --- Documentation/Running.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Documentation/Running.rst b/Documentation/Running.rst index 718ec01..b3e96c9 100644 --- a/Documentation/Running.rst +++ b/Documentation/Running.rst @@ -106,6 +106,13 @@ Lints the TypoScript files. Lints the YAML files. +.. index:: Commands; composer fix +.. code-block:: bash + + composer fix + +Runs all fixers (except for the ones that need JavaScript). + .. index:: Commands; composer fix:php .. code-block:: bash