Skip to content

The Generator (yarn gen / yarn del) ​

Why generators? ​

Consistency. Every feature, action, and task looks identical. No hand-crafting.

Plan the schema, actions, tasks, and wiring and get sign-off before any scaffold or edit, whether creating or modifying a feature.

Generator operations are fail-safe: feature/action/task/mailer names are validated before writes; an existing source, mailer folder, or matching generated test aborts the whole operation before parent directories are created; new source/test/template files use exclusive creation and are never truncated. Action/task indexes are rebuilt from source files, deduplicated, and alphabetized.

Generate a feature ​

bash
yarn gen Order

Creates the full feature folder:

  • app/Order/model.js
  • app/Order/controller.js
  • app/Order/routes.js
  • app/Order/worker.js
  • app/Order/helper.js
  • app/Order/error.js
  • app/Order/actions/index.js + V1Example.js
  • app/Order/tasks/index.js + V1ExampleTask.js
  • app/Order/languages/en.js
  • app/Order/tests/integration/ + tests/tasks/

Also updates database/sequence.js. Root routes.js, models.js, worker.js, and services/error.js auto-discover feature files.

Remove the placeholder files immediately ​

bash
yarn del Order -a V1Example
yarn del Order -t V1ExampleTask

Keep tests/helper.test.js; it is part of every complete feature structure.

Generate an action ​

bash
yarn gen Order -a V1Create

Creates app/Order/actions/V1Create.js + test file. Updates actions/index.js automatically.

If either file already exists, nothing is written. Names must follow V{version}{Action}[By{Role}][On{Device}]; do not pass .js.

Generate a task ​

bash
yarn gen Order -t V1ProcessTask

Creates the task and matching test exclusively and deterministically rebuilds tasks/index.js. Existing source/test files abort before any write. Task names must contain the Task suffix.

Generate a mailer ​

bash
yarn gen Order -m OrderConfirmation

Mailer names are PascalCase. The feature prefix is added only when absent. An existing mailer folder/template aborts before any write.

Delete commands ​

bash
yarn del Order -a V1Create        # removes action + test + index.js entry
yarn del Order -t V1ProcessTask
yarn del Order -m OrderConfirmation
yarn del Order                    # removes entire feature

Always use yarn del, never rm — del updates aggregator files, rm leaves broken exports.

Repair missing standard structure ​

Preview first, then apply:

bash
yarn repair Order --dry-run
yarn repair Order

Repair uses the generator templates and never overwrites existing files. It creates missing standard files, README markers for otherwise-empty actions/, tasks/, mailers/, tests/integration/, and tests/tasks/, missing action/task tests, and missing deterministic indexes. Existing index conflicts and ambiguous route/controller/worker wiring are reported for manual resolution.

Every app/<Feature> must have the complete standard structure; model-only/table-only exceptions are not allowed. Extra domain files are allowed.

Check conventions ​

bash
yarn conventions:check

The dependency-free checker validates full structure, naming, sequence, indexes, source/test counterparts, wiring, and essential action/route/model formatting. Untouched scaffold markers and required action/task tests disabled with skip/todo APIs fail. yarn test runs this check first; finish non-trivial work with the mandatory review-conventions self-audit.

yarn lang ​

Compile i18n after editing languages/ files.

bash
yarn lang