manifest

package
v0.6.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PopulateMissingMetadata

func PopulateMissingMetadata(m *Manifest, defaultTargetDir, defaultPackageDir string)

PopulateMissingMetadata fills in TargetDir and PackageDir for packages that were created before these fields existed. This ensures backward compatibility with older manifest files.

Types

type ContentHasher

type ContentHasher struct {
	// contains filtered or unexported fields
}

ContentHasher computes content hashes for packages

func NewContentHasher

func NewContentHasher(fs domain.FS) *ContentHasher

NewContentHasher creates a new content hasher

func (*ContentHasher) HashPackage

func (h *ContentHasher) HashPackage(ctx context.Context, pkgPath domain.PackagePath) (string, error)

HashPackage computes content hash for entire package Hash is deterministic and based on file contents and paths

type DoctorState

type DoctorState struct {
	IgnoredLinks    map[string]IgnoredLink `json:"ignored_links,omitempty"`
	IgnoredPatterns []string               `json:"ignored_patterns,omitempty"`
}

DoctorState tracks ignored symlinks and patterns for doctor diagnostics.

type FSManifestStore

type FSManifestStore struct {
	// contains filtered or unexported fields
}

FSManifestStore implements ManifestStore using filesystem

func NewFSManifestStore

func NewFSManifestStore(fs domain.FS) *FSManifestStore

NewFSManifestStore creates filesystem-based manifest store. Manifest is stored in the target directory for backward compatibility.

func NewFSManifestStoreWithDir

func NewFSManifestStoreWithDir(fs domain.FS, manifestDir string) *FSManifestStore

NewFSManifestStoreWithDir creates filesystem-based manifest store with custom directory. Manifest is stored in the specified manifestDir instead of target directory.

func (*FSManifestStore) Load

Load retrieves manifest from configured directory

func (*FSManifestStore) Save

func (s *FSManifestStore) Save(ctx context.Context, targetDir domain.TargetPath, manifest Manifest) error

Save persists manifest to configured directory

type IgnoredLink struct {
	Target         string    `json:"target"`
	TargetHash     string    `json:"target_hash"` // SHA256 of target path for change detection
	AcknowledgedAt time.Time `json:"acknowledged_at"`
	Reason         string    `json:"reason,omitempty"`
}

IgnoredLink represents a symlink that user has acknowledged and wants to ignore.

type IssueType

type IssueType int

IssueType categorizes validation problems

const (
	IssueBrokenLink IssueType = iota
	IssueMissingLink
	IssueExtraLink
	IssueWrongTarget
	IssueNotSymlink
)

type Manifest

type Manifest struct {
	Version    string                 `json:"version"`
	UpdatedAt  time.Time              `json:"updated_at"`
	Packages   map[string]PackageInfo `json:"packages"`
	Hashes     map[string]string      `json:"hashes"`
	Repository *RepositoryInfo        `json:"repository,omitempty"`
	Doctor     *DoctorState           `json:"doctor,omitempty"`
}

Manifest tracks installed package state

func New

func New() Manifest

New creates a new empty manifest

func (m *Manifest) AddIgnoredLink(path, target, reason string)

AddIgnoredLink adds a symlink to the ignore list.

func (*Manifest) AddIgnoredPattern

func (m *Manifest) AddIgnoredPattern(pattern string)

AddIgnoredPattern adds a glob pattern to the ignore list.

func (*Manifest) AddPackage

func (m *Manifest) AddPackage(pkg PackageInfo)

AddPackage adds or updates package information

func (*Manifest) ClearRepository

func (m *Manifest) ClearRepository()

ClearRepository removes the repository information from the manifest.

func (*Manifest) EnsureDoctorState

func (m *Manifest) EnsureDoctorState()

EnsureDoctorState initializes the doctor state if it doesn't exist.

func (*Manifest) GetHash

func (m *Manifest) GetHash(name string) (string, bool)

GetHash retrieves content hash for package

func (*Manifest) GetPackage

func (m *Manifest) GetPackage(name string) (PackageInfo, bool)

GetPackage retrieves package information

func (*Manifest) GetRepository

func (m *Manifest) GetRepository() (RepositoryInfo, bool)

GetRepository retrieves the repository information. Returns the repository info and true if set, or empty info and false if not set.

func (*Manifest) PackageList

func (m *Manifest) PackageList() []PackageInfo

PackageList returns all packages as slice

func (m *Manifest) RemoveIgnoredLink(path string) bool

RemoveIgnoredLink removes a symlink from the ignore list. Returns true if the link was found and removed, false otherwise.

func (*Manifest) RemovePackage

func (m *Manifest) RemovePackage(name string) bool

RemovePackage removes package from manifest

func (*Manifest) SetHash

func (m *Manifest) SetHash(name, hash string)

SetHash updates content hash for package

func (*Manifest) SetRepository

func (m *Manifest) SetRepository(info RepositoryInfo)

SetRepository sets the repository information for the manifest.

type ManifestStore

type ManifestStore interface {
	// Load retrieves manifest from target directory
	// Returns empty manifest if file doesn't exist
	Load(ctx context.Context, targetDir domain.TargetPath) domain.Result[Manifest]

	// Save persists manifest to target directory
	// Write is atomic via temp file and rename
	Save(ctx context.Context, targetDir domain.TargetPath, manifest Manifest) error
}

ManifestStore provides persistence for manifests

type PackageInfo

type PackageInfo struct {
	Name        string            `json:"name"`
	InstalledAt time.Time         `json:"installed_at"`
	LinkCount   int               `json:"link_count"`
	Links       []string          `json:"links"`
	Backups     map[string]string `json:"backups,omitempty"`     // target path -> backup path
	Source      PackageSource     `json:"source,omitempty"`      // How package was installed (adopted vs managed)
	TargetDir   string            `json:"target_dir,omitempty"`  // Target directory where symlinks are created
	PackageDir  string            `json:"package_dir,omitempty"` // Package directory containing source files
}

PackageInfo contains installation metadata for a package

type PackageSource

type PackageSource string

PackageSource indicates how a package was installed

const (
	// SourceManaged indicates package was installed via manage command
	SourceManaged PackageSource = "managed"
	// SourceAdopted indicates package was created via adopt command
	SourceAdopted PackageSource = "adopted"
)

type RepositoryInfo

type RepositoryInfo struct {
	// URL is the git repository URL.
	URL string `json:"url"`

	// Branch is the cloned branch name.
	Branch string `json:"branch"`

	// ClonedAt is the timestamp when the repository was cloned.
	ClonedAt time.Time `json:"cloned_at"`

	// CommitSHA is the commit hash at clone time (optional).
	CommitSHA string `json:"commit_sha,omitempty"`
}

RepositoryInfo contains metadata about the cloned repository.

type ValidationIssue

type ValidationIssue struct {
	Type        IssueType
	Path        string
	Package     string
	Description string
}

ValidationIssue describes a specific problem found

type ValidationResult

type ValidationResult struct {
	IsValid bool
	Issues  []ValidationIssue
}

ValidationResult contains validation outcome and issues

type Validator

type Validator struct {
	// contains filtered or unexported fields
}

Validator checks manifest consistency with filesystem

func NewValidator

func NewValidator(fs domain.FS) *Validator

NewValidator creates a new manifest validator

func (*Validator) Validate

func (v *Validator) Validate(ctx context.Context, targetDir domain.TargetPath, manifest Manifest) ValidationResult

Validate checks manifest consistency with filesystem

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL