Documentation
¶
Index ¶
- Constants
- func GetFileDiff(oldContent, newContent []byte) string
- func HashFile(path string) (string, error)
- type FileRecord
- type FileStatus
- type LockFile
- func (l *LockFile) AddFile(relativePath, templateVersion string, content []byte)
- func (l *LockFile) AddFileFromDisk(baseDir, relativePath, templateVersion string) error
- func (l *LockFile) CheckAllFiles(baseDir string) map[string]FileStatus
- func (l *LockFile) CheckFile(baseDir, relativePath string) FileStatus
- func (l *LockFile) GetModifiedFiles(baseDir string) []string
- func (l *LockFile) GetUnchangedFiles(baseDir string) []string
- func (l *LockFile) Save(dir string) error
- type ProjectInfo
- type TemplateFile
- type UpdateOptions
- type UpdateResult
- type Updater
Constants ¶
const LockFileName = ".pdfforge.lock"
Variables ¶
This section is empty.
Functions ¶
func GetFileDiff ¶
GetFileDiff returns a simple diff between old and new content
Types ¶
type FileRecord ¶
type FileRecord struct {
Hash string `yaml:"hash"`
TemplateVersion string `yaml:"template_version"`
}
FileRecord tracks a generated file
type FileStatus ¶
type FileStatus int
GetFileStatus returns the status of a file compared to the lock
const ( FileStatusUnknown FileStatus = iota // Not in lock file FileStatusUnchanged // Matches lock file hash FileStatusModified // Different from lock file hash FileStatusDeleted // In lock but not on disk FileStatusNew // On disk but not in lock )
func (FileStatus) String ¶
func (s FileStatus) String() string
type LockFile ¶
type LockFile struct {
Version string `yaml:"version"`
GeneratedAt time.Time `yaml:"generated_at"`
Files map[string]FileRecord `yaml:"files"`
}
LockFile represents the .pdfforge.lock file structure
func LoadLockFile ¶
LoadLockFile loads a lock file from the given directory
func (*LockFile) AddFileFromDisk ¶
AddFileFromDisk adds a file record by reading from disk
func (*LockFile) CheckAllFiles ¶
func (l *LockFile) CheckAllFiles(baseDir string) map[string]FileStatus
CheckAllFiles checks all files in the lock against disk
func (*LockFile) CheckFile ¶
func (l *LockFile) CheckFile(baseDir, relativePath string) FileStatus
CheckFile checks if a file has been modified since generation
func (*LockFile) GetModifiedFiles ¶
GetModifiedFiles returns a list of files that have been modified
func (*LockFile) GetUnchangedFiles ¶
GetUnchangedFiles returns a list of files that are unchanged
type ProjectInfo ¶
type ProjectInfo struct {
Path string
IsProject bool
HasLockFile bool
CurrentVersion string
LockFile *LockFile
GeneratedFiles []string
ModifiedFiles []string
UnchangedFiles []string
}
ProjectInfo contains information about a detected project
func DetectProject ¶
func DetectProject(dir string) *ProjectInfo
DetectProject analyzes a directory to determine if it's a pdf-forge project
func (*ProjectInfo) HasModifications ¶
func (p *ProjectInfo) HasModifications() bool
HasModifications checks if any generated files have been modified
func (*ProjectInfo) NeedsUpdate ¶
func (p *ProjectInfo) NeedsUpdate(latestVersion string) bool
NeedsUpdate checks if the project needs an update
type TemplateFile ¶
type TemplateFile struct {
TemplateName string
OutputPath string
Optional bool // If true, don't fail if template is missing
}
TemplateFile maps a template to an output file
type UpdateOptions ¶
type UpdateOptions struct {
BackupModified bool // Backup modified files before overwriting
SkipModified bool // Skip modified files entirely
ForceOverwrite bool // Overwrite everything without backup
FilesToUpdate map[string]bool // If set, only update these files
}
UpdateOptions configures how the update should behave
type UpdateResult ¶
type UpdateResult struct {
FilesUpdated []string
FilesSkipped []string
FilesBackedUp []string
FilesCreated []string
Errors []error
}
UpdateResult represents the result of an update operation
type Updater ¶
type Updater struct {
// contains filtered or unexported fields
}
Updater handles project updates
func NewUpdater ¶
func NewUpdater(projectDir string, data templates.Data, version string, opts UpdateOptions) *Updater
NewUpdater creates a new updater for a project
func (*Updater) Update ¶
func (u *Updater) Update() (*UpdateResult, error)
Update performs the update operation