Use NDJSON for metadata files

Kirby

Well-known member
Licensed customer
Currently XenForo creates one _metadata.json file for every Add-on data type (option, permissions, etc.)
Those metadata files contain mostly hashes as one big JSON object, but also version information for phrases and templates.

If development is done in multiple branches / by multiple developers those metadata files can easily create merge conflicts even is there is in fact no real conflict (eg. different phrases were added in different branches).

By changing the format to NDJSON / JSONL such merge conflicts could be avoided:

Instead of
Code:
{
    "admin/my_addon_template_1.html": {
        "version_id": 1000070,
        "version_string": "1.0.0",
        "hash": "0eac25b65a1268dee1e666b8c26bab47"
    },
    "admin/my_addon_template_2.html": {
        "version_id": 1000070,
        "version_string": "1.0.0",
        "hash": "33d554df65d90678ed583b583f67ad2e"
    }
}

the file _metadata.jsonl would now look like

Code:
{"file":"admin/my_addon_template_1.html","version_id":1000070,"version_string":"1.0.0","hash":"0eac25b65a1268dee1e666b8c26bab47"}
["file":"admin/my_addon_template_2.html","version_id":1000070,"version_string":"1.0.0","hash":"33d554df65d90678ed583b583f67ad2e"}

This makes the file slightly larger, but shouldn't take much effort to support and easily avoid merge conflicts.
 
Last edited:
Upvote 0
Back
Top Bottom