Documentation
¶
Overview ¶
Package manifest tracks WebKit-generated files for drift detection and cleanup.
It maintains a manifest of all generated files with their source, generator, and content hashes. This enables detecting manual changes (drift) and removing orphaned files when configuration changes.
Index ¶
- Variables
- func Cleanup(fs afero.Fs, old, new *Manifest, console *printer.Console) error
- func HashContent(data []byte) string
- func SourceApp(name string) string
- func SourceProject() string
- func SourceResource(name string) string
- type CallerInfo
- type DriftEntry
- type DriftReason
- type FileEntry
- type Manifest
- type Tracker
Constants ¶
This section is empty.
Variables ¶
var ErrNoManifest = fmt.Errorf("no manifest found")
ErrNoManifest is returned by Load() when there hasen't been a manifest generated yet.
var Path = filepath.Join(".webkit", "manifest.json")
Path defines the filepath where the manifest resides.
Functions ¶
func Cleanup ¶
Cleanup removes files that are no longer needed by WebKit by comparing the old and new manifests.
func HashContent ¶
HashContent generates a SHA256 hash of the provided data. Used to detect if file contents have changed since generation.
func SourceApp ¶
SourceApp returns a namespaced identifier for application sources. Format: "app:<name>"
func SourceProject ¶
func SourceProject() string
SourceProject returns the identifier string for the project-level manifest source. Used for base files with nothing attached.
func SourceResource ¶
SourceResource returns a namespaced identifier for resource sources. Format: "resource:<name>".
Types ¶
type CallerInfo ¶
type CallerInfo struct {
Package string // e.g. "env"
Function string // e.g. "Scaffold"
File string // e.g. "/path/to/env.go"
Line int // e.g. 42
}
CallerInfo holds metadata about the detected caller.
func Caller ¶
func Caller() CallerInfo
Caller returns information about the first exported (public) function in the call stack outside of runtime/scaffold packages.
type DriftEntry ¶
type DriftEntry struct {
Path string // File path
Type DriftReason // Type of drift
Source string // What in app.json caused this
Generator string // Which generator created it
}
DriftEntry contains information about a single drifted file
func DetectDrift ¶
func DetectDrift(actualFS, expectedFS afero.Fs) ([]DriftEntry, error)
DetectDrift compares actual files on disk against what should be generated. It detects both manual modifications and source drift (app.json changes).
actualFS: The real filesystem expectedFS: In-memory filesystem with freshly generated files from current app.json
Returns all drift: manual edits, outdated files, missing files, and orphaned files.
type DriftReason ¶
type DriftReason int
DriftReason represents the kind of drift detected
const ( DriftReasonModified DriftReason = iota // File was manually edited DriftReasonDeleted // File should be removed DriftReasonOutdated // app.json changed, needs regen DriftReasonNew // File should exist but doesn't )
DriftReason constants.
func (DriftReason) FilterEntries ¶
func (d DriftReason) FilterEntries(filtered []DriftEntry) []DriftEntry
FilterEntries plucks entries by the selected DriftReason.
func (DriftReason) String ¶
func (d DriftReason) String() string
String implements fmt.Stringer on the DriftReason.
type FileEntry ¶
type FileEntry struct {
Path string `json:"path"` // Relative path to the generated file
Generator string `json:"generator"` // e.g. "cicd.BackupWorkflow", "files.PackageJSON"
Source string `json:"source"` // What in app.json caused this? e.g., "resource:postgres-prod"
Hash string `json:"hash"` // SHA256 of content for drift detection
ScaffoldMode bool `json:"scaffolded"` // Whether file was created in scaffold mode (won't overwrite)
GeneratedAt time.Time `json:"generated_at"` // When this file entry was created/updated
}
FileEntry represents a single generated file and its metadata. Used to track what generated the file, what caused it to be generated, and whether its content has changed since generation.
type Manifest ¶
type Manifest struct {
Version string `json:"version"` // Webkit CLI version
GeneratedAt time.Time `json:"generated_at"`
Files map[string]FileEntry `json:"files"` // Filepath to Entry
}
Manifest tracks all files generated by WebKit, including their source and content hashes for drift detection.
type Tracker ¶
type Tracker struct {
// contains filtered or unexported fields
}
Tracker maintains a collection of generated files and their metadata. Used to track which files were created by webkit and from which source.
func NewTracker ¶
func NewTracker() *Tracker
NewTracker creates a tracker with an initialized file map. If a previous manifest is provided, it will be used to preserve timestamps for files that haven't changed.
func (*Tracker) Add ¶
Add stores a file entry in the tracker, keyed by its path. If an entry with the same path exists, it will be overwritten. If the previous manifest contains the same file with the same hash, the GeneratedAt timestamp will be preserved.
func (*Tracker) Save ¶
Save writes the tracker's files to a manifest JSON file. Creates parent directories if they don't exist. If a previous manifest was provided and no files have changed, the manifest's GeneratedAt timestamp will be preserved.
func (*Tracker) WithPreviousManifest ¶ added in v0.0.5
WithPreviousManifest sets the previous manifest for timestamp preservation.