Skip to content

Commit

Permalink
Merge pull request #104 from neos/task/standalone-package
Browse files Browse the repository at this point in the history
TASK: Standalone rector package
  • Loading branch information
ahaeslich authored Dec 18, 2024
2 parents 76037c3 + 547bdd0 commit 33bb8cb
Show file tree
Hide file tree
Showing 81 changed files with 4,705 additions and 338 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php-versions: ['8.1', '8.2']
php-versions: ['8.2', '8.3']

runs-on: ubuntu-latest

Expand Down
30 changes: 23 additions & 7 deletions embed-fusion-and-afx-parsers.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,39 @@
#!/usr/bin/env bash

export FUSION_PARSER_TARGETPATH=src/Core/FusionProcessing/FusionParser
export FUSION_TARGETPATH=src/Core/FusionProcessing/Fusion
export AFX_PARSER_TARGETPATH=src/Core/FusionProcessing/AfxParser

rm -Rf $FUSION_PARSER_TARGETPATH
cp -R ../../../Neos/Neos.Fusion/Classes/Core/ObjectTreeParser $FUSION_PARSER_TARGETPATH
grep -rl 'Neos\\Fusion\\Core\\ObjectTreeParser' $FUSION_PARSER_TARGETPATH | xargs sed -i '' 's/Neos\\Fusion\\Core\\ObjectTreeParser/Neos\\Rector\\Core\\FusionProcessing\\FusionParser/g'
if [[ "$OSTYPE" == "darwin"* ]]; then
SEDOPTION="-i ''"
else
SEDOPTION="-i "
fi

# To create the patch file for Neos.Fusion.Afx, do:
# cd Packages/Neos
# patch -p1 < ../Libraries/neos/rector/scripts/fusion-object-parser.patch
## Now, do your modifications as needed.
# git diff -- Neos.Fusion/ > ../../rector/scripts/fusion-object-parser.patch
# git restore -- Neos.Fusion/

rm -Rf $FUSION_TARGETPATH
cp -R ../Packages/Neos/Neos.Fusion/Classes/Core $FUSION_TARGETPATH
pushd $FUSION_TARGETPATH
patch -p4 < ../../../../scripts/fusion-object-parser.patch
popd
grep -rl 'Neos\\Fusion\\Core' $FUSION_TARGETPATH | xargs sed $SEDOPTION 's/Neos\\Fusion\\Core/Neos\\Rector\\Core\\FusionProcessing\\Fusion/g'
grep -rl 'Fusion\\Core' $FUSION_TARGETPATH | xargs sed $SEDOPTION 's/Fusion\\Core/\\Neos\\Rector\\Core\\FusionProcessing\\Fusion/g'

# To create the patch file for Neos.Fusion.Afx, do:
# cd Packages/Neos
# patch -p1 < ../Libraries/neos/rector/scripts/afx-eel-positions.patch
## Now, do your modifications as needed.
# git diff -- Neos.Fusion.Afx/ > ../Libraries/neos/rector/scripts/afx-eel-positions.patch
# git diff -- Neos.Fusion.Afx/ > ../../rector/scripts/afx-eel-positions.patch
# git restore -- Neos.Fusion.Afx/

rm -Rf $AFX_PARSER_TARGETPATH
cp -R ../../../Neos/Neos.Fusion.Afx/Classes/Parser $AFX_PARSER_TARGETPATH
cp -R ../Packages/Neos/Neos.Fusion.Afx/Classes/Parser $AFX_PARSER_TARGETPATH
pushd $AFX_PARSER_TARGETPATH
patch -p4 < ../../../../scripts/afx-eel-positions.patch
popd
grep -rl 'Neos\\Fusion\\Afx\\Parser' $AFX_PARSER_TARGETPATH | xargs sed -i '' 's/Neos\\Fusion\\Afx\\Parser/Neos\\Rector\\Core\\FusionProcessing\\AfxParser/g'
grep -rl 'Neos\\Fusion\\Afx\\Parser' $AFX_PARSER_TARGETPATH | xargs sed $SEDOPTION 's/Neos\\Fusion\\Afx\\Parser/Neos\\Rector\\Core\\FusionProcessing\\AfxParser/g'
13 changes: 13 additions & 0 deletions scripts/fusion-object-parser.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/Neos.Fusion/Classes/Core/ObjectTreeParser/ObjectTreeParser.php b/Neos.Fusion/Classes/Core/ObjectTreeParser/ObjectTreeParser.php
index 06a31eb69c..eca9848de7 100644
--- a/Neos.Fusion/Classes/Core/ObjectTreeParser/ObjectTreeParser.php
+++ b/Neos.Fusion/Classes/Core/ObjectTreeParser/ObjectTreeParser.php
@@ -55,7 +55,7 @@ class ObjectTreeParser

protected ?string $contextPathAndFilename;

- private function __construct(Lexer $lexer, ?string $contextPathAndFilename)
+ public function __construct(Lexer $lexer, ?string $contextPathAndFilename)
{
$this->lexer = $lexer;
$this->contextPathAndFilename = $contextPathAndFilename;
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@
use Neos\Rector\Core\FusionProcessing\AfxParser\AfxParserException;
use Neos\Rector\Core\FusionProcessing\AfxParser\Lexer;

/**
* Class Node
* @package Neos\Rector\Core\FusionProcessing\AfxParser\Expression
*/
class Node
class AfxNode
{
/**
* @param Lexer $lexer
Expand Down Expand Up @@ -85,7 +81,7 @@ public static function parse(Lexer $lexer): array
throw new AfxParserException(sprintf('Tag "%s" did not end with closing bracket.', $identifier), 1557860573);
}

$children = NodeList::parse($lexer);
$children = AfxNodeList::parse($lexer);

if ($lexer->isOpeningBracket()) {
$lexer->consume();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@
use Neos\Rector\Core\FusionProcessing\AfxParser\AfxParserException;
use Neos\Rector\Core\FusionProcessing\AfxParser\Lexer;

/**
* Class NodeList
* @package Neos\Rector\Core\FusionProcessing\AfxParser\Expression
*/
class NodeList
class AfxNodeList
{
/**
* @param Lexer $lexer
Expand Down Expand Up @@ -56,7 +52,7 @@ public static function parse(Lexer $lexer): array
$lexer->rewind();
$contents[] = [
'type' => 'node',
'payload' => Node::parse($lexer)
'payload' => AfxNode::parse($lexer)
];
$currentText = '';
continue;
Expand Down
2 changes: 1 addition & 1 deletion src/Core/FusionProcessing/AfxParser/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ public function __construct($string)
*/
public function parse(): array
{
return Expression\NodeList::parse($this->lexer);
return Expression\AfxNodeList::parse($this->lexer);
}
}
2 changes: 1 addition & 1 deletion src/Core/FusionProcessing/EelExpressionTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Closure;
use Neos\Rector\Core\FusionProcessing\AfxParser\AfxParserException;
use Neos\Rector\Core\FusionProcessing\FusionParser\Exception\ParserException;
use Neos\Rector\Core\FusionProcessing\Fusion\ObjectTreeParser\Exception\ParserException;
use Neos\Rector\Core\FusionProcessing\Helper\CustomObjectTreeParser;
use Neos\Rector\Core\FusionProcessing\Helper\EelExpressionPosition;
use Neos\Rector\Core\FusionProcessing\Helper\EelExpressionPositions;
Expand Down
Loading

0 comments on commit 33bb8cb

Please sign in to comment.