project

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const LockFileName = ".pdfforge.lock"

Variables

This section is empty.

Functions

func GetFileDiff

func GetFileDiff(oldContent, newContent []byte) string

GetFileDiff returns a simple diff between old and new content

func HashFile

func HashFile(path string) (string, error)

HashFile returns SHA256 hash of a file

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

func LoadLockFile(dir string) (*LockFile, error)

LoadLockFile loads a lock file from the given directory

func NewLockFile

func NewLockFile(version string) *LockFile

NewLockFile creates a new lock file

func (*LockFile) AddFile

func (l *LockFile) AddFile(relativePath, templateVersion string, content []byte)

AddFile adds a file record to the lock file

func (*LockFile) AddFileFromDisk

func (l *LockFile) AddFileFromDisk(baseDir, relativePath, templateVersion string) error

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

func (l *LockFile) GetModifiedFiles(baseDir string) []string

GetModifiedFiles returns a list of files that have been modified

func (*LockFile) GetUnchangedFiles

func (l *LockFile) GetUnchangedFiles(baseDir string) []string

GetUnchangedFiles returns a list of files that are unchanged

func (*LockFile) Save

func (l *LockFile) Save(dir string) error

Save writes the lock file to the given directory

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

Jump to

Keyboard shortcuts

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