How do I generate a codegen entity?

Table of Contents

For background on profiles (facets) and metatypes, see ores.codegen.

Question

How do I regenerate all codegen output for an entity?

Answer

Run compass codegen entity generate <name-or-id> from the project root:

./compass.sh codegen entity generate country

The entity resolves by name or org-roam UUID prefix. All applicable leaf facets are run automatically (e.g. domain, repository, service, sql, qt, protocol, …):

Generating country (domain_entity, refdata) — 12 profile(s): domain, generator,
  nats-eventing, nats-handler, non-temporal-domain, non-temporal-repository,
  non-temporal-sql, protocol, qt, repository, service, sql

Restrict to one facet with --profile:

./compass.sh codegen entity generate country --profile sql
./compass.sh codegen entity generate country --profile domain
./compass.sh codegen entity generate country --profile qt

Preview paths without writing with --dry-run:

./compass.sh codegen entity generate country --dry-run

Preview as a unified diff (generate to temp, compare to disk) with --diff:

./compass.sh codegen entity generate country --diff
./compass.sh codegen entity generate country --profile sql --diff

--dry-run and --diff are mutually exclusive.

After generating, review changes with:

./compass.sh codegen entity diff country

Script

compass codegen entity generate (alias gen) is the _cmd_generate handler in projects/ores.compass/src/compass_codegen_entity.py. It calls _generate_single from codegen.generate directly (no subprocess to codegen.sh).

Tested by

Run ./compass.sh codegen entity generate country --dry-run and verify 36 output paths are printed across 12 profiles. Run without --dry-run and verify the stale files are updated (entity show should then show ✅).

See also

Emacs 29.1 (Org mode 9.6.6)