Documentation
¶
Overview ¶
Package scaffold writes FACET into a project that does not have it: the record layout, the JSON schemas, the specification, the lint suite with its pinned dispatcher, an empty scan filter and the CI workflow.
Index ¶
Constants ¶
const (
DispatcherCopy = "tools/facet-lint/facet"
)
The published project workflow. A source tree that keeps the files it publishes in an overlay directory holds it there, and then its own .github/workflows/facet-lint.yml is that tree's CI rather than the one a project gets; a published tree holds it at the usual place.
const RecordsDir = "docs/facets"
RecordsDir is where the scaffold puts the record layout unless the caller names another directory. Payload paths below it are rewritten to the chosen directory when the files are written.
Variables ¶
var ErrTarget = errors.New("unusable target")
ErrTarget matches every TargetError.
var RecordSubdirs = []string{"features", "policies", "assumptions", "data-entities", "schema", "framework"}
RecordSubdirs are the record directories every scaffolded project gets, created even when they stay empty, in the order they are reported.
Functions ¶
func FindModuleRoot ¶
FindModuleRoot walks up from dir to the directory holding go.mod.
func Generate ¶
Generate builds the payload bundle from the source tree at root. The bundle is a txtar archive: a comment, then one '-- path --' line per file followed by its exact bytes.
func RegisterFile ¶
func RegisterFile(f File)
RegisterFile adds one file a linked product scaffolds beside the payload, from the product's init. The path is project-relative in the payload's own form, so a file under RecordsDir follows a chosen records directory the way the Core schemas do. Misuse is a build defect, so it panics at start-up rather than surfacing in some project's init.
Types ¶
type Options ¶
type Options struct {
// Root is the project directory. It is created when missing.
Root string
// RecordsDir is the record layout, relative to Root; empty means RecordsDir.
RecordsDir string
// DryRun reports what would be written and writes nothing.
DryRun bool
// Force replaces files the project already has.
Force bool
// Version, when set, is written as the dispatcher's pinned FACET_VERSION
// default, so a project scaffolded by a release build installs that
// release. Empty keeps the pin the payload carries.
Version string
// Out receives the report.
Out io.Writer
}
Options select where and how the scaffold writes.
type Result ¶
Result counts the outcome of a run.
func Run ¶
Run scaffolds Options.Root and reports each step to Options.Out. A file the project already has is kept unless Force is set; the report names every file written and every file kept. Nothing is written before the target has been checked, so an unusable target leaves the disk as it was.
@facet: delivery/distribution/project-scaffold @facet-role: primary
type Source ¶
type Source struct {
// Path is the destination relative to the project root, with the record
// layout under RecordsDir.
Path string
// From is the canonical file relative to the module root. Empty for a
// file whose content is Literal.
From string
// Strip removes the anchor declarations that bind the canonical file to a
// record of the FACET Core registry. A scaffolded project holds no such
// record, so a copied anchor would fail its very first lint.
Strip stripMode
// Literal is the content of a file that has no canonical source because
// its content is a decision about the project rather than a copy.
Literal []byte
}
Source is one file of the payload: where it lands in a project, and where its bytes come from in the FACET Core source tree.
type TargetError ¶
type TargetError struct{ Reason string }
TargetError is a target the scaffold cannot write into at all. Its message is the reason alone, ready to be shown to the person who named the target.
func (*TargetError) Error ¶
func (e *TargetError) Error() string
func (*TargetError) Is ¶
func (e *TargetError) Is(target error) bool