Documentation
¶
Overview ¶
Package scaffold handles file generation and scaffolding for WebKit projects.
It provides a Generator interface for creating files from templates, JSON, YAML, and raw bytes with support for scaffold mode (don't overwrite) and generate mode (always overwrite). All generated files are tracked in the manifest for drift detection.
Index ¶
- Constants
- type FileGenerator
- func (f FileGenerator) Bytes(path string, data []byte, opts ...Option) error
- func (f FileGenerator) Code(path string, content string, opts ...Option) error
- func (f FileGenerator) Copy(from, to string, opts ...Option) error
- func (f FileGenerator) CopyFromEmbed(efs embed.FS, from, to string, opts ...Option) error
- func (f FileGenerator) JSON(path string, content any, opts ...Option) error
- func (f FileGenerator) Template(path string, tpl *template.Template, data any, opts ...Option) error
- func (f FileGenerator) YAML(path string, content any, opts ...Option) error
- type Generator
- type Option
- type WriteMode
Constants ¶
const WebKitNotice = "Code generated by webkit; DO NOT EDIT."
WebKitNotice is the notice outputted to all generated files within WebKit.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileGenerator ¶
FileGenerator handles file generation on a given filesystem.
func (FileGenerator) Bytes ¶
func (f FileGenerator) Bytes(path string, data []byte, opts ...Option) error
Bytes writes bytes to the filesystem and ensure directories exist.
func (FileGenerator) Code ¶ added in v0.0.3
func (f FileGenerator) Code(path string, content string, opts ...Option) error
Code writes Go code to a file with the given mode. The content should be valid Go code and will have the WebKit notice prepended.
func (FileGenerator) Copy ¶
func (f FileGenerator) Copy(from, to string, opts ...Option) error
Copy simply copies a file to the destination using the scaffolder.
func (FileGenerator) CopyFromEmbed ¶
CopyFromEmbed copies a file from an embedded FS to the generator's FS.
func (FileGenerator) JSON ¶
func (f FileGenerator) JSON(path string, content any, opts ...Option) error
JSON writes JSON content with the given mode.
type Generator ¶
type Generator interface {
Bytes(path string, data []byte, opts ...Option) error
Copy(from, to string, opts ...Option) error
CopyFromEmbed(efs embed.FS, from, to string, opts ...Option) error
Template(path string, tpl *template.Template, data any, opts ...Option) error
JSON(path string, content any, opts ...Option) error
YAML(path string, content any, opts ...Option) error
Code(path string, content string, opts ...Option) error
}
Generator is used for scaffolding files to a WebKit project.
type Option ¶
type Option func(*writeOptions)
Option is a function that configures write options
func WithScaffoldMode ¶
func WithScaffoldMode() Option
WithScaffoldMode sets the write mode for the operation
func WithTracking ¶
WithTracking adds generators and sources to each file so it can be tracked in the manifest.
func WithoutNotice ¶
func WithoutNotice() Option
WithoutNotice disables the standard "Generated by WebKit" notice.