Skip to main content

Crate bynk_driver

Crate bynk_driver 

Source
Expand description

bynk-driver — the front-end of the bynk CLI (#521).

Both binaries expose fmt and check with identical semantics; before this crate each re-implemented the command bodies (and the project-failure flattening layer, and the project-rooting rule) as by-hand copies pinned only by comments and a skip-able parity test. The single implementation lives here, parameterised by the program name that prefixes messages.

Re-exports§

pub use compile_cmd::BuildArgs;
pub use compile_cmd::CliPlatform;
pub use compile_cmd::CliProfile;
pub use compile_cmd::CliTarget;
pub use compile_cmd::CompileArgs;
pub use compile_cmd::EmitFormat;
pub use compile_cmd::profile_contracts;
pub use compile_cmd::project_contracts;
pub use compile_cmd::refuse_release_contracts;
pub use compile_cmd::refuse_undeployable_project;
pub use compile_cmd::run_build;
pub use compile_cmd::run_compile;
pub use output::write_document;
pub use output::write_modules;
pub use output::write_modules_for_node;
pub use output::write_output;

Modules§

colour
When the driver’s human output is coloured, and the few styles it uses.
compile_cmd
The compile command body, run by bynk compile (D2/E1, #2998): before this, only bynk had it, so bynk compile had to start a bynk process. Parameterised by the program name that prefixes messages, like crate::run_check and crate::run_fmt.
contracts_lock
Reading and atomically writing bynk.contracts.lock (#2554): the driver’s side of CompileOptions::contracts_lock, beside crate::schema_lock and sharing its read and write.
coverage
bynk test --coverage — remap V8 line coverage onto .bynk source.
dev_run
#2138 (end-to-end testing track §3.5): bynk test --against dev, the system suites run against a local bynk dev the runner starts itself.
discovery
Walking a directory tree for .bynk files and reading them — the driver’s side of CompileOptions.sources (#1077, R2.3/T0.7 residue).
doc_examples
Doc-comment examples (#2461): a fenced bynk block in a doc comment is checked by bynk test, so an example cannot silently fall out of step with the code it documents. One marked bynk test also runs.
eval
bynk eval (#3585): evaluate a snippet in a project’s context and report the value it ends in.
fix
#2642: check --fix — apply the machine-applicable suggestions of a file or project from the command line.
mutate
bynk test --mutate (#3069): check that the suites would notice a small change to the code.
npm_install
Installing the npm packages a generated build directory lists, with the package manager the user already has (#3350).
output
Writing a compiled project’s output to disk.
probe
The shared detection probe: presence + version + provenance.
progress
#3100: per-context build progress, printed to stderr.
project
Multi-file project compilation (v0.3 §3.2 and §3.3, v0.4 §3.5).
remote
#2138 (end-to-end testing track §3.5, §3.7, §3.8): test --against, a run of the system suites against a real runtime.
render
Bynk’s shared diagnostic-rendering layer.
schema_lock
Reading and atomically writing bynk.schema.lock — the driver’s side of CompileOptions::schema_registry (#1078, R2.3/T0.7 residue).
smoke
bynk test --smoke (#2658): a system suite per context, derived from its from http services, so every declared route is exercised on a real runtime without a test written for it.
snapshots
#2842: the driver’s half of snapshot testing.
source_overlay
#2471: an in-memory overlay of unsaved editor buffers for a build.
strip
The project-level strip: rewrite a compiled ProjectOutput from TypeScript into a JavaScript artefact (the in-browser track’s first-class JS output, ADR 0137).
test_filter
bynk test --case / --suite (#2273): the set of tests one run executes.
test_json
v0.59: the bynk test --format json result model, plus the parser that folds the runner’s NDJSON event stream into it.
test_runner
bynk test’s shared command body (Wave 5 §5.4, findings #40/#72/#20/#21 remainder): compile the project’s test declarations, write them, and run them via tsc → node (falling back to tsx), folding the result into the pinned crate::test_json::TestRun document in --format json mode. Moved down from the old bynkc crate.
test_stream
bynk test --format ndjson (#2267, Slice D stage 1): the supported result stream.
tools
Back-half paydown 1D.5b (#4003, Decision F): the spawning of the external tools the driver runs, in one place: tsc, tsx, node, git, and the npm, pnpm, bun and yarn installs.
tsc_report
#3068: report a tsc failure on generated TypeScript as a Bynk diagnostic, bynk.codegen.tsc_failed, at the Bynk source the failing line came from.

Macros§

emsg
eprintln! for a message with an error:, warning: or note: label, coloured as colour::message does when stderr is.

Structs§

FmtArgs
The fmt subcommand’s arguments, flattened by bynk::cli so the two spell one contract rather than two copies of it (the test_runner::TestArgs pattern, findings #40/#72). Field docs here are the CLI help text for both commands’ flags.

Enums§

IndentKind
How --indent spells the two IndentStyle variants. The words match the [fmt] indent key in bynk.toml, which the language server already reads, so a project states the same choice the same way in either place.
ProjectOptionsError
Why try_project_options could not produce a usable CompileOptions: either the manifest itself is unreadable (ProjectPathsError), or a well-formed manifest names a project tree that can’t be walked (discovery::DiscoveryError) — #1081 review.

Functions§

display_path
#1772: the path a diagnostic names, as a user would type it from the working directory: the build’s root as the caller spelled it, joined with the file’s identity path (relative to that root). A relative root is already relative to the working directory; an absolute one (bynk dev resolves the project root) is shown relative to the working directory when it lies inside it. This matches the path fmt reports for the same file, so a problem matcher resolving against the working directory finds it. Separators print as / on every platform.
member_dir
#2207: a member’s directory as the command names it: root (as the user typed it) joined with the member’s relative path, without . components, so a run at . names packages/money, not ./packages/money.
member_header
#2207 (decision C): the line that heads one member’s report in a workspace run, ── packages/money ──, its path as typed from the working directory.
print_project_check
Render every diagnostic from a project::ProjectCheck (finding #64) with the same per-file ariadne context print_project_failure gives its own, errors-only list. Unlike that renderer, a ProjectCheck’s list can legitimately mix both severities — the unattributed fallback line names its actual severity (crate::render::severity_word) rather than print_project_failure’s bare [category]: message (silently correct only because that list is errors-only by construction).
print_project_check_short
print_project_check via project_check_short_lines.
print_project_failure
Render a project build failure with per-file ariadne context, exactly as single-file mode had rich rendering. Unattributed (project-level) errors keep the plain form.
print_project_failure_short
The project-failure analogue of crate::render::print_errors_short: each attributed error is positioned against its file’s snapshot; an unattributed (project-level) error falls back to <severity>[<category>]: <message>.
print_project_warnings
v0.89 (ADR 0117): print a successful build’s non-failing warnings, with real per-file ariadne context now that a successful build’s snapshots (mirroring ProjectFailure::snapshots) make that possible. A warning whose source isn’t attributable (or doesn’t fit the snapshot) falls back to the plain warning[<category>]: <message> form.
print_project_warnings_short
print_project_warnings’s --format short analogue: one path:line:col: warning[category]: message line per warning, falling back to warning[category]: message when unattributed. Strictly one line per warning throughout (like crate::render::render_errors_short, this mirrors the VS Code problem-matcher’s contract), so — unlike print_project_warnings — finding #47 doesn’t reach this one.
project_check_short_lines
print_project_check’s --format short analogue, mirroring project_failure_short_lines.
project_failure_short_lines
The string form of print_project_failure_short: one path:line:col: severity[category]: message line per attributed error (an unattributed project-level error falls back to severity[category]: message). Backs both the printer above and the bynk test --format json compile-error document, whose diagnostics the VS Code bynk problem-matcher re-parses — each Vec entry is exactly one line by that contract, so unlike the other renderers in this file this one deliberately does not grow note/label continuation lines (finding #47): doing so would break a machine consumer that re-parses every entry as a single diagnostic line.
project_options
Root a directory project the way every project command should (#46): a bynk.toml or a src/ subdir selects project mode, whose flat [paths] include/exclude layout (v0.113, DECISION S) defaults to the conventional roots that exist (src, tests) or the project root itself; otherwise the legacy single-tree where <dir> is itself the root. check, compile, test, and dev all route through this so the conventional layout works the same from any of them.
project_source_files
The .bynk files try_project_options reads for the directory input, sorted: what check, test and compile see. #1753: fmt expands a directory argument through this, so fmt --check <dir> and check <dir> cover the same files.
run_check
The check command body run by bynk check: a directory routes through project::check_project (finding #64 — non-bailing, so a structural error anywhere does not hide diagnostics elsewhere the way compile_project’s bail-fast Mode::Build would), a single file through bynk_emit::check_with_warnings. short selects the one-line --format short rendering. prog prefixes messages (bynk: …).
run_fmt
The fmt command body run by bynk fmt: each input is formatted and rewritten only when it changes; --check reports non-canonical files without writing; - reads stdin and writes the formatted result to stdout. prog prefixes messages (bynk fmt: …).
try_project_options
project_options, but a malformed bynk.toml is an error rather than a silent fall-back to the conventional layout — the one input a user hand-edits that the compiler otherwise reads without checking, after which a cascade of bynk.uses.unknown_target errors points at units that plainly exist on disk.
workspace_at
#2207: if input is a workspace root (a directory whose bynk.toml holds [workspace]), the workspace it loads to, or why it doesn’t.
workspace_at_each
#3274: workspace_at, or, with each, the workspace --each stands for: