Expand description
Opt-in execution of root composer.json scripts.
Composer only ever runs scripts from the root package (never from
dependencies), so they’re the project author’s own commands — not a
supply-chain hazard. bougie keeps execution opt-in / off by default; this
crate is the engine that runs them when the user turns it on.
The crate is intentionally FS/PHP-agnostic: it parses
and classifies the scripts table into Entry values and
dispatches a named event, given a host-injected ScriptContext
(resolved PHP binary, env, callback registry). Everything that needs to
know about bougie’s path/PHP/service-env machinery lives in the caller —
mirroring how bougie-installers isolates declarative-plugin logic.
Scope: the non-internal entry forms (@php, @composer, @putenv,
@<alias>, plain shell). PHP-callback entries (Class::method) reach into
Composer internals in-process; bougie does not host them. They are
warn-and-skipped, except for a small allowlist the host registers natively
(e.g. Laravel’s clearCompiled).
Structs§
- Callback
Registry - A curated allowlist of PHP callbacks bougie reproduces natively, mapping
"Class::method"→ handler. This is not a general callback runner: only the host-registered entries run; every other callback warn-skips. - Script
Context - Everything
dispatchneeds from the host, injected by the caller so the crate stays FS/PHP-agnostic and testable. - Scripts
- A parsed root
scriptstable: ordered event/alias name → ordered entries.
Enums§
- Entry
- A single listener entry within a
scripts.<event>list, classified by Composer’s entry grammar. - Entry
Outcome - What happened to one entry during a dispatch.
Functions§
- dispatch
- Dispatch a named event, running its entries in order. Returns one outcome
per entry (recursing into aliases inline). A non-zero process exit or an
alias cycle is an
Errthat aborts the event and the surrounding command.
Type Aliases§
- Callback
Handler - A native handler standing in for a PHP-callback entry. Returns
Errto abort the event (same as a non-zero process exit).