Expand description
Project-mode scaffolding framework + bock.project config-table parsing.
This module is the foundation for project-mode output (spec §20.6.2). It provides two things:
-
Config parsing + validation.
ScaffoldConfig::from_project_tomlparses the per-target[targets.<T>](deep) and[targets.<T>.scaffolding](shallow) tables inbock.project, and validates every supplied value against the v1-supported variant matrix in §20.6.2. An unknown value is aScaffoldErrorthat names the documented options for that target. Fields left unset stayNone— target-appropriate defaults are applied later (by S6 per-target scaffolders), not here. -
The
Scaffolderabstraction. AScaffoldertakes the parsed per-targetTargetScaffoldConfigplus the already-emitted module tree and produces additionalOutputFiles — manifests, README first-contact instructions, formatter/linter configs, transpiled test files.scaffolder_forreturns the per-target implementation.
Mode gating lives in the build driver, not here. bock build runs the
scaffolder only in the default (project) mode, never under
--source-only (spec §20.6.2: source mode emits “no manifests,
scaffolding, or entry-point wiring”).
§Scope (S5 framework → S6a manifests → S6b enrichment)
S5 shipped the framework + config plumbing + mode gating; S6a relocated
the minimal run-affordance manifests here. S6b (this stage) fills each
per-target Scaffolder body with the full project-mode scaffolding:
- a rich manifest referencing the selected/default test framework
(
package.json+tsconfig.json;pyproject.toml;Cargo.toml;go.mod), - a formatter config where applicable (Prettier for js/ts unless
formatter=none; Black/Ruff inpyproject.toml; rustfmt/gofmt are universal/always-on, no config), - an opt-in linter config (shallow — emitted ONLY when
[targets.<T>.scaffolding].linteris set), - a README first-contact honoring the package-manager hint.
Unset fields take the §20.6.2 target-appropriate defaults: js/ts → Vitest + Prettier + npm; python → pytest + Black + pip; rust → cargo test + rustfmt; go → stdlib testing + gofmt.
Deferred to S7 (NOT done here): the transpiled @test files
(Vitest/Jest/pytest/cargo test/go test test code) and the formatter-clean
--check release gate. S6b only sets up manifests/configs that reference
the framework.
The v1-supported variant matrix (§20.6.2):
| Target | Test framework | Formatter | Linter | Package manager |
|---|---|---|---|---|
| js | vitest (def), jest | prettier (def), none | eslint | npm (def), pnpm, yarn |
| ts | vitest (def), jest | prettier (def), none | eslint | npm (def), pnpm, yarn |
| python | pytest (def), unittest | black (def), ruff, none | ruff, pylint | pip (def), poetry, uv |
| rust | (cargo test, universal) | (rustfmt, universal) | clippy | (cargo only) |
| go | (stdlib, universal) | (gofmt, universal) | golangci-lint | (go mod only) |
Rust/Go formatters and test frameworks are universal and always-on, so
test_framework/formatter are not user-selectable for those targets;
supplying them is a validation error.
Structs§
- Scaffold
Config - Validated scaffolding configuration for all five built-in targets.
- Scaffold
Context - Context handed to a
Scaffolder: the validated per-target config plus the module tree already emitted by codegen. - Target
Scaffold Config - Typed, validated per-target scaffolding configuration.
Enums§
- Scaffold
Error - An error parsing or validating the
bock.projectscaffolding config.
Constants§
- SCAFFOLD_
TARGETS - Canonical target ids the config tables key on, matching
crate::profile::TargetProfileids andbock buildtarget selection.
Traits§
- Scaffolder
- Produces project-mode scaffolding files for one target.
Functions§
- effective_
test_ framework - The effective test framework for
targetgiven its validated config, applying the §20.6.2 target-appropriate default for any unset choice. - run_
scaffolder - Run the per-target scaffolder and return its files, dropping any that collide with paths the codegen tree already emitted.
- scaffolder_
for - Returns the
Scaffolderfortarget, orNonefor an unknown target id.