I've written a Fusion debugger

Hello, folks,

I had the big problem that I often sat kind of helpless in front of strange rendering errors and just didn’t understand why that was happening. Especially in older projects that I did not develop but now have to maintain this happened a whole lot of times.
Normally this means for me that I can click my way through different Fusion files from different repositories to hopefully find the section I overlooked before. Of course this is very time-consuming and absolutely not efficient.

To counteract this I have now written a Fusion debugger plugin for Neos, because something like that doesn’t exist yet as far as I know.
The package is still work in progress, but contains enough functions to be useful already I think.
Therefore it is available in an alpha version on Packagist and ready to install.
I would really appreciate your feedback and suggestions.

Little overview

The package involves the following commands in the Flow CLI:

  • fusion:debugprototype [--no-color] [--not-flat] <prototypeName>

    Reads the definition of the requested prototype from the __prototypes key in the parsed object tree and resolves the contained prototype chain very carefully so that the result contains all properties, either inherited or explictely defined.
    For better readability, this command also includes something similar to syntax highlighting as several parts of the built tree are colored (such as eel expressions, further prototype names or just plain strings). Furthermore it flattens the resulting data by removing empty properties and combining the internal properties for e.g. plain values (as these are stored with three properties but could be displayed directly without an array structure).
    These additional behaviour can be suppressed by specifying the options --no-color or --not-flat if it corrupts the resulting data or your terminal does not support ANSI colors.

  • fusion:showobjecttree

    Builds the object tree from all Fusion files and displays it in an ASCII tree structure (excluding the __prototypes key as we got the above command for that).

  • fusion:lint

    Checks all Fusion files individually for syntax errors and lists the incorrect files with their associated package and file path.
    This command was intended to programmatically check the correctness of the Fusion source code and is in fact still an experiment but listed for the sake of completeness.

  • `fusion:listprototypes

    List all known Fusion prototypes by their names.

Thank you for your attention and thanks in advance for your feedback.
Greetings, Max

10 Likes

I didn‘t get around checking it out yet, but this sounds very promising. Thanks a lot for sharing!

1 Like