Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TypoScript support #85

Merged
merged 9 commits into from
Jun 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"composer-plugin-api": "^2.0",
"ergebnis/json-printer": "^3.5",
"eta-orionis/composer-json-manipulator": "^1.0",
"helmich/typo3-typoscript-parser": "^2.6",
"nette/utils": "^4.0",
"phpstan/phpstan": "^1.10.9",
"sebastian/diff": "^5.0",
Expand Down Expand Up @@ -46,6 +47,7 @@
"a9f/fractor-extension-installer": "self.version",
"a9f/fractor-fluid": "self.version",
"a9f/fractor-phpstan-rules": "self.version",
"a9f/fractor-typoscript": "self.version",
"a9f/fractor-xml": "self.version",
"a9f/fractor-yaml": "self.version",
"a9f/typo3-fractor": "self.version"
Expand All @@ -62,6 +64,7 @@
"a9f\\FractorFluid\\": "packages/fractor-fluid/src/",
"a9f\\FractorMonorepo\\": "src",
"a9f\\FractorPhpStanRules\\": "packages/fractor-phpstan-rules/src/",
"a9f\\FractorTypoScript\\": "packages/fractor-typoscript/src/",
"a9f\\FractorXml\\": "packages/fractor-xml/src/",
"a9f\\FractorYaml\\": "packages/fractor-yaml/src/",
"a9f\\Fractor\\": "packages/fractor/src/",
Expand All @@ -81,6 +84,7 @@
"a9f\\FractorDocGenerator\\Tests\\": "packages/fractor-doc-generator/tests/",
"a9f\\FractorFluid\\Tests\\": "packages/fractor-fluid/tests/",
"a9f\\FractorPhpStanRules\\Tests\\": "packages/fractor-phpstan-rules/tests/",
"a9f\\FractorTypoScript\\Tests\\": "packages/fractor-typoscript/tests/",
"a9f\\FractorXml\\Tests\\": "packages/fractor-xml/tests/",
"a9f\\FractorYaml\\Tests\\": "packages/fractor-yaml/tests/",
"a9f\\Fractor\\Tests\\": "packages/fractor/tests/",
Expand Down Expand Up @@ -139,6 +143,7 @@
"@composer normalize --dry-run packages/fractor-composer-json/composer.json",
"@composer normalize --dry-run packages/fractor-doc-generator/composer.json",
"@composer normalize --dry-run packages/fractor-fluid/composer.json",
"@composer normalize --dry-run packages/fractor-typoscript/composer.json",
"@composer normalize --dry-run packages/fractor-xml/composer.json",
"@composer normalize --dry-run packages/fractor-yaml/composer.json",
"@composer normalize --dry-run packages/typo3-fractor/composer.json"
Expand All @@ -151,6 +156,7 @@
"@composer normalize --no-check-lock packages/fractor-composer-json/composer.json",
"@composer normalize --no-check-lock packages/fractor-doc-generator/composer.json",
"@composer normalize --no-check-lock packages/fractor-fluid/composer.json",
"@composer normalize --no-check-lock packages/fractor-typoscript/composer.json",
"@composer normalize --no-check-lock packages/fractor-xml/composer.json",
"@composer normalize --no-check-lock packages/fractor-yaml/composer.json",
"@composer normalize --no-check-lock packages/typo3-fractor/composer.json"
Expand Down
3 changes: 2 additions & 1 deletion e2e/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/composer.lock
/vendor/

/*/output/
/*/output/
/*/output.txt
51 changes: 39 additions & 12 deletions e2e/run-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,42 @@ cd $TESTS_BASE_DIR
rm -r composer.lock vendor || true
composer install

TEST_DIR=typo3-yaml

cd $TEST_DIR

[[ -d ./output/ ]] && rm -rf ./output/
cp -r fixtures/ output/

cd $TESTS_BASE_DIR
./vendor/bin/fractor process --quiet -c $TESTS_BASE_DIR/$TEST_DIR/fractor.php

# TODO remove -b once we keep the output format when re-writing the file
diff -rub $TEST_DIR/expected-output/ $TEST_DIR/output/
for TEST_DIR in typo3-yaml typo3-typoscript
do
set +x
echo
echo "############################################################"
echo "#"
echo "# Running test in $TEST_DIR/"
echo "#"
echo "############################################################"
echo
set -x

# remove output from a previous run, if any
[[ -f $TEST_DIR/output.txt ]] && rm $TEST_DIR/output.txt
[[ -d $TEST_DIR/result/ ]] && rm -rf $TEST_DIR/result/
# copy over our fixture to the path that Fractor will run in
cp -r $TEST_DIR/fixtures/ $TEST_DIR/result/

./vendor/bin/fractor process -c $TESTS_BASE_DIR/$TEST_DIR/fractor.php > $TEST_DIR/output.txt

set +x
echo
echo "############################################################"
echo "# Comparing Fractor result against expected result"
echo
set -x

# TODO remove -b once we keep the output format when re-writing the file
diff -rub --color=auto $TEST_DIR/expected-result/ $TEST_DIR/result/

set +x
echo
echo "############################################################"
echo "# Comparing Fractor CLI output against expected output"
echo
set -x

diff -u --color=auto $TEST_DIR/expected-output.txt $TEST_DIR/output.txt
done
17 changes: 17 additions & 0 deletions e2e/typo3-typoscript/expected-output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---------- begin diff ----------
@@ @@
page.10.value = Link to page 23
page.10.typolink {
parameter = 23
- useCacheHash = 1
}

page.20 = TEXT
page.20.value = Link to page 42
page.20.typolink.parameter = 42
-page.20.typolink.useCacheHash = 1
----------- end diff -----------

Applied rules:
RemoveUseCacheHashFromTypolinkTypoScriptFractor (https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/10.0/Deprecation-88406-SetCacheHashnoCacheHashOptionsInViewHelpersAndUriBuilder.html)

10 changes: 10 additions & 0 deletions e2e/typo3-typoscript/expected-result/cache-hash.typoscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
page = PAGE
page.10 = TEXT
page.10.value = Link to page 23
page.10.typolink {
parameter = 23
}

page.20 = TEXT
page.20.value = Link to page 42
page.20.typolink.parameter = 42
12 changes: 12 additions & 0 deletions e2e/typo3-typoscript/fixtures/cache-hash.typoscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
page = PAGE
page.10 = TEXT
page.10.value = Link to page 23
page.10.typolink {
parameter = 23
useCacheHash = 1
}

page.20 = TEXT
page.20.value = Link to page 42
page.20.typolink.parameter = 42
page.20.typolink.useCacheHash = 1
10 changes: 10 additions & 0 deletions e2e/typo3-typoscript/fractor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

declare(strict_types=1);

use a9f\Fractor\Configuration\FractorConfiguration;
use a9f\Typo3Fractor\Set\Typo3LevelSetList;

return FractorConfiguration::configure()
->withPaths([__DIR__ . '/result/'])
->withSets([Typo3LevelSetList::UP_TO_TYPO3_13]);
10 changes: 10 additions & 0 deletions e2e/typo3-typoscript/result/cache-hash.typoscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
page = PAGE
page.10 = TEXT
page.10.value = Link to page 23
page.10.typolink {
parameter = 23
}

page.20 = TEXT
page.20.value = Link to page 42
page.20.typolink.parameter = 42
68 changes: 68 additions & 0 deletions e2e/typo3-yaml/expected-output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---------- begin diff ----------
@@ @@
-
options:
recipients:
- [email protected]: 'Bar'
+ [email protected]: Bar
+ [email protected]: Bar
subject: 'Kontaktanfrage von Website'
- recipientAddress: [email protected]
- recipientName: Bar
- replyToAddress: [email protected]
senderAddress: '{email}'
senderName: '{lastName}'
- carbonCopyAddress: [email protected]
- blindCarbonCopyAddress: [email protected]
format: html
attachUploads: true
+ replyToRecipients:
+ - [email protected]
+ carbonCopyRecipients:
+ - [email protected]
+ blindCarbonCopyRecipients:
+ - [email protected]
identifier: EmailToReceiver
-
options:
recipients:
- [email protected]: 'Bar'
+ [email protected]: Bar
+ [email protected]: Bar
subject: 'Kontaktanfrage von Website'
- recipientAddress: [email protected]
- recipientName: Bar
- replyToAddress: [email protected]
senderAddress: '{email}'
senderName: '{lastName}'
- carbonCopyAddress: [email protected]
- blindCarbonCopyAddress: [email protected]
format: html
attachUploads: true
+ replyToRecipients:
+ - [email protected]
+ carbonCopyRecipients:
+ - [email protected]
+ blindCarbonCopyRecipients:
+ - [email protected]
identifier: EmailToSender
variants:
-
@@ @@
identifier: EmailToReceiver
options:
subject: 'Example Subject'
- recipientAddress: [email protected]
- recipientName: 'Example Recipient'
senderAddress: [email protected]
senderName: '{text-2} {text-1}'
- replyToAddress: '{email}'
+ replyToRecipients:
+ - '{email}'
+ recipients:
+ [email protected]: 'Example Recipient'
----------- end diff -----------

Applied rules:
EmailFinisherYamlFractor (https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/10.0/Feature-80420-AllowMultipleRecipientsInEmailFinisher.html)

2 changes: 1 addition & 1 deletion e2e/typo3-yaml/fractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
use a9f\Typo3Fractor\Set\Typo3LevelSetList;

return FractorConfiguration::configure()
->withPaths([__DIR__ . '/output/'])
->withPaths([__DIR__ . '/result/'])
->withSets([Typo3LevelSetList::UP_TO_TYPO3_13]);
50 changes: 50 additions & 0 deletions e2e/typo3-yaml/result/my_form.form.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
finishers:
-
options:
recipients:
[email protected]: Bar
[email protected]: Bar
subject: 'Kontaktanfrage von Website'
senderAddress: '{email}'
senderName: '{lastName}'
format: html
attachUploads: true
replyToRecipients:
- [email protected]
carbonCopyRecipients:
- [email protected]
blindCarbonCopyRecipients:
- [email protected]
identifier: EmailToReceiver
-
options:
recipients:
[email protected]: Bar
[email protected]: Bar
subject: 'Kontaktanfrage von Website'
senderAddress: '{email}'
senderName: '{lastName}'
format: html
attachUploads: true
replyToRecipients:
- [email protected]
carbonCopyRecipients:
- [email protected]
blindCarbonCopyRecipients:
- [email protected]
identifier: EmailToSender
variants:
-
identifier: variant-1
condition: 'formValues["foo"] == "bar"'
finishers:
-
identifier: EmailToReceiver
options:
subject: 'Example Subject'
senderAddress: [email protected]
senderName: '{text-2} {text-1}'
replyToRecipients:
- '{email}'
recipients:
[email protected]: 'Example Recipient'
6 changes: 6 additions & 0 deletions packages/fractor-typoscript/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
tests export-ignore
rules-tests export-ignore
.gitattributes export-ignore
.gitignore export-ignore
phpunit.xml export-ignore
README.md export-ignore
3 changes: 3 additions & 0 deletions packages/fractor-typoscript/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/vendor/
/composer.lock
.phpunit.cache
9 changes: 9 additions & 0 deletions packages/fractor-typoscript/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Fractor for TypoScript files

FileProcessor for TYPO3 TypoScript files.

## Installation

```bash
composer require a9f/fractor-typoscript --dev
```
62 changes: 62 additions & 0 deletions packages/fractor-typoscript/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"name": "a9f/fractor-typoscript",
"description": "TypoScript extension for the File Read-Analyse-Change Tool. Allows modifying TYPO3 TypoScript configuration files",
"license": "MIT",
"type": "fractor-extension",
"authors": [
{
"name": "Andreas Wolf",
"email": "[email protected]",
"role": "Lead Developer"
}
],
"require": {
"php": "^8.2",
"a9f/fractor": "^0.2",
"a9f/fractor-extension-installer": "^0.2",
"helmich/typo3-typoscript-parser": "^2.6",
"webmozart/assert": "^1.11"
},
"require-dev": {
"ergebnis/composer-normalize": "^2.42",
"phpstan/phpstan": "^1.10.9",
"phpunit/phpunit": "^10.5",
"rector/rector": "^1.0",
"symplify/easy-coding-standard": "^12.1"
},
"repositories": {
"fractor": {
"type": "path",
"url": "../*"
}
},
"autoload": {
"psr-4": {
"a9f\\FractorTypoScript\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"a9f\\FractorTypoScript\\Tests\\": "tests/"
}
},
"config": {
"allow-plugins": {
"a9f/fractor-extension-installer": true,
"ergebnis/composer-normalize": true
},
"sort-packages": true
},
"extra": {
"branch-alias": {
"dev-main": "0.2-dev"
}
},
"scripts": {
"analyze:php": "phpstan analyze",
"rector": "rector",
"style:php:check": "ecs",
"style:php:fix": "ecs --fix",
"test:php": "phpunit"
}
}
Loading