Skip to main content

Module tooling

Module tooling 

Source
Expand description

Lifecycle phases — a repo’s build/dev commands as configurable DATA, not hard-coded match arms (#880).

A fixed, extensible vocabulary of phase names (Phase) — setup, format, lint, test, check, clean — each mapped to a single command. The mapping is resolved:

  1. the repo’s [lifecycle] table in .newt/config.toml (project-local, tracked — the repo declares its own just clean / just test / …), published once via set_lifecycle_override;
  2. else the matching tooling packs — per-ecosystem defaults as data (built-in + ~/.newt/tooling/*.toml drop-ins), the sibling of the language-pack model. A polyglot repo matches SEVERAL; an unknown one NONE.

The crew consumes format (its normalize-before-commit step) today; the other phases are declared-and-available for newt lifecycle <phase> and future wiring. Adding/removing a phase name is a small, deliberate code change — the set is intentionally hard-coded (a stable vocabulary), while the commands are data.

Structs§

PhaseCommands
A per-phase command map — used both as a pack’s default commands ([phases]) and as the repo’s [lifecycle] override. Every field optional (an unset phase falls through to the next source).
ToolingPack
A toolchain’s lifecycle commands, as data. Selected for a repo when ANY of its detect marker files exists at the repo root.

Enums§

Phase
The fixed lifecycle-phase vocabulary. Extend deliberately in a future build.

Functions§

builtin_tooling_packs
The built-in tooling packs — worked examples a contributor copies into a ~/.newt/tooling/<name>.toml drop-in. Override any by name; add new ones.
load_tooling_packs_from_dir
Load tooling packs from a drop-in dir (<dir>/*.toml, one per file). Malformed files are skipped with a warning; a missing dir → []. (The tolerant drop-in contract shared with the language-pack / [backends] dirs.)
merge_tooling_packs
Merge pack layers by name — later layers win (built-ins < drop-in dir).
phase_commands_from_packs
Every phase command from the packs whose detect markers exist in repo_dir, in pack order. None matching → empty; several → each matching toolchain’s command (a polyglot repo). Pure.
resolved_phase_commands
The resolved commands for phase in repo_dir: the repo [lifecycle].<phase> override (a single command) wins; else every matching tooling pack’s default (built-in merged under ~/.newt/tooling/). Configuration over Convention; empty = nothing declared for this phase.
set_lifecycle_override
Publish the repo [lifecycle] table (from Config::resolve), once.