Documentation
¶
Overview ¶
Package scaffold plans and applies the files a template set generates into a codebase, honoring each file's policy (written once, regenerated, or regenerated above a preserve marker).
Index ¶
Constants ¶
const PreserveMarker = "scaffold:preserve"
PreserveMarker marks the line from which a PolicyPreserve file keeps its existing content.
Variables ¶
This section is empty.
Functions ¶
func Apply ¶
func Apply( ctx context.Context, write func(path string, data []byte) error, plan types.FilePlan, dryRun bool, ) error
Apply writes plan's FileCreate and FileUpdate entries through write, or nothing under dryRun. A plan with a FileConflict writes nothing and is CodeConflict, naming each conflicting file. Applying a plan made after a previous Apply writes nothing.
func Plan ¶
func Plan( ctx context.Context, tmpl iofs.FS, data any, policy func(path string) types.FilePolicy, cb interfaces.Codebase, ) (types.FilePlan, error)
Plan renders every file of tmpl with data (paths are templates too, and a `.tmpl` suffix is dropped) and decides each one's action against cb under policy. An entry is FileCreate when cb lacks the file, FileKeep when the result equals it (and always under PolicyOnce), FileUpdate otherwise, and FileConflict when a PolicyPreserve file or its template lacks the preserve marker.
Types ¶
This section is empty.