Implemented 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 1
This suggestion has been implemented. Votes are no longer accepted.
This is implemented in 2.3.14.

JSON:
{"_file":"about.txt","global_cache":false,"hash":"8f7f4c1ce7a4f933663d10543562b096","version_id":1000015,"version_string":"1.0.0 Alpha 5"}
{"_file":"about_you.txt","global_cache":false,"hash":"4f21e071e8d83b9a8115913b265bf763","version_id":2000010,"version_string":"2.0.0 Alpha"}
{"_file":"accent.txt","global_cache":false,"hash":"c900e1bd8e22771d610bd2a5861b544f","version_id":2000010,"version_string":"2.0.0 Alpha"}

XF will still consume _metadata.json but for existing add-ons we recommend you migrate to _metadata.jsonl. You can do that with the following CLI command:

Code:
xf-dev:metadata-migrate --addon Your/AddOnId

Some points that may or may not be relevant to some developers:
  • Metadata writes keep the format a type directory already uses so if an existing directory contains _metadata.json it will continue to use that unless you convert with the above command. This is recommended if you intend to develop/build add-ons for older versions.
  • New add-ons and directories by default will utilise _metadata.jsonl unless you set "legacy_metadata": true in addon.json.
  • If a directory contains both _metadata.json and _metadata.jsonl then the .jsonl file takes precedent and the .json file is ignored.
  • If you migrate an add-on to using modern metadata, you can revert it with the migrate command above and the --to-legacy option.
  • We plan to deprecate legacy metadata in XF 2.4 with its removal scheduled for XF 2.5 or XF 3.0 (whichever comes first).
  • For designer mode users, the xf-designer:metadata-migrate command acts as the designer mode equivalent of the command above.
 
Back
Top Bottom