mix proto_rune. gen. lexicons
(proto_rune v0.5.2)
Copy Markdown
Generates Peri schema modules from ATProto lexicon JSON files.
This task reads lexicon definitions from a directory (default:
priv/lexicons) and generates corresponding Elixir modules with Peri
schemas in an output directory (default: lib/proto_rune/lexicon/).
Host applications can point the task at their own lexicons and pass the
generated schemas to ProtoRune.Atproto.Repo.create_record/3 and
put_record/3 via the :schema option.
Usage
$ mix proto_rune.gen.lexicons
Options
--path- Directory containing lexicon JSON files (default: priv/lexicons)--output- Directory where generated modules will be written (default: lib/proto_rune/lexicon/)--recursive- Recursively search for lexicon files in subdirectories (default: true)--force- Force regeneration even if output files exist (default: false)
The legacy --lexicons-dir and --output-dir flags are still accepted and
take precedence over --path and --output when both are given.
Examples
# Generate all lexicons with default settings
$ mix proto_rune.gen.lexicons
# Specify custom directories
$ mix proto_rune.gen.lexicons --path custom/lexicons --output custom/output
# Force regeneration
$ mix proto_rune.gen.lexicons --forceGenerated Files
For each lexicon file app.bsky.feed.post.json, this task will generate:
lib/proto_rune/lexicon/app/bsky/feed/post.ex
Each generated module will contain:
- Module documentation from the lexicon description
- Peri
defschemadefinitions for all defs in the lexicon - Helper functions for validation
Notes
- Generated files should be committed to git for version control
- If lexicon files are updated, re-run this task to regenerate modules
- Generated modules are not meant to be edited manually