core

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2025 License: MIT Imports: 24 Imported by: 0

Documentation

Overview

Package core implements the core pipeline functions for dodot. It provides the main execution flow from pack discovery through to filesystem operations.

Index

Constants

This section is empty.

Variables

View Source
var DefaultIgnorePatterns = []string{
	".git",
	".svn",
	".hg",
	"node_modules",
	".DS_Store",
	"*.swp",
	"*~",
	"#*#",
}

DefaultIgnorePatterns contains patterns for directories to ignore

Functions

func CalculateActionChecksum

func CalculateActionChecksum(action types.Action) (string, error)

CalculateActionChecksum calculates the checksum for an action's source file. This is used to update the checksum metadata for run-once actions.

func ConvertAction

func ConvertAction(action types.Action) ([]types.Operation, error)

ConvertAction converts a single action to one or more operations

func ConvertActionWithContext

func ConvertActionWithContext(action types.Action, ctx *ExecutionContext) ([]types.Operation, error)

ConvertActionWithContext converts a single action to one or more operations with execution context

func DeployPacks

func DeployPacks(opts DeployPacksOptions) (*types.ExecutionResult, error)

DeployPacks runs the deployment logic for the specified packs. This executes power-ups with RunModeMany.

func FillPack

func FillPack(opts FillPackOptions) (*types.FillResult, error)

FillPack adds placeholder files for power-ups to an existing pack.

func FilterRunOnceActions

func FilterRunOnceActions(actions []types.Action, force bool) ([]types.Action, error)

FilterRunOnceActions filters a list of actions based on their run-once status. It removes actions that have already been executed with the same checksum, unless the force flag is set.

func GetActions

func GetActions(matches []types.TriggerMatch) ([]types.Action, error)

GetActions converts trigger matches into concrete actions to perform

func GetFileOperations

func GetFileOperations(actions []types.Action) ([]types.Operation, error)

GetFileOperations converts actions into file system operations

func GetFileOperationsWithContext

func GetFileOperationsWithContext(actions []types.Action, ctx *ExecutionContext) ([]types.Operation, error)

GetFileOperationsWithContext converts actions into file system operations with execution context

func GetFiringTriggers

func GetFiringTriggers(packs []types.Pack) ([]types.TriggerMatch, error)

GetFiringTriggers processes packs and returns all triggers that match files

func GetPackCandidates

func GetPackCandidates(dotfilesRoot string) ([]string, error)

GetPackCandidates returns all potential pack directories in the dotfiles root

func GetPacks

func GetPacks(candidates []string) ([]types.Pack, error)

GetPacks validates and creates Pack instances from candidate paths

func InitPack

func InitPack(opts InitPackOptions) (*types.InitResult, error)

InitPack creates a new pack directory with template files and configuration.

func InstallPacks

func InstallPacks(opts InstallPacksOptions) (*types.ExecutionResult, error)

InstallPacks runs the installation and deployment logic for the specified packs. It first executes power-ups with RunModeOnce, then those with RunModeMany.

func ListPacks

func ListPacks(opts ListPacksOptions) (*types.ListPacksResult, error)

ListPacks finds all available packs in the dotfiles root.

func ProcessMatch

func ProcessMatch(match types.TriggerMatch) ([]types.Action, error)

ProcessMatch processes a single trigger match into actions Deprecated: Use ProcessMatchGroup for batch processing

func ProcessMatchGroup

func ProcessMatchGroup(matches []types.TriggerMatch) ([]types.Action, error)

ProcessMatchGroup processes a group of related matches with the same power-up

func ProcessPackTriggers

func ProcessPackTriggers(pack types.Pack) ([]types.TriggerMatch, error)

ProcessPackTriggers processes triggers for a single pack

func SelectPacks

func SelectPacks(allPacks []types.Pack, selectedNames []string) ([]types.Pack, error)

SelectPacks filters a list of packs by name

func ShouldRunOnceAction

func ShouldRunOnceAction(action types.Action, force bool) (bool, error)

ShouldRunOnceAction checks if a run-once action should be executed based on its sentinel file and checksum. Returns true if the action should run, false if it has already run with the same checksum.

func StatusPacks

func StatusPacks(opts StatusPacksOptions) (*types.PackStatusResult, error)

StatusPacks checks the deployment status of the specified packs.

func ValidatePack

func ValidatePack(packPath string) error

ValidatePack checks if a directory is a valid pack

Types

type DeployPacksOptions

type DeployPacksOptions struct {
	// DotfilesRoot is the path to the root of the dotfiles directory.
	DotfilesRoot string
	// PackNames is a list of specific packs to deploy. If empty, all packs are deployed.
	PackNames []string
	// DryRun specifies whether to perform a dry run without making changes.
	DryRun bool
}

DeployPacksOptions defines the options for the DeployPacks command.

type ExecutionContext

type ExecutionContext struct {
	ChecksumResults map[string]string // Maps file path to checksum
	// contains filtered or unexported fields
}

ExecutionContext holds results from operation execution

func NewExecutionContext

func NewExecutionContext() *ExecutionContext

NewExecutionContext creates a new execution context

func (*ExecutionContext) ExecuteChecksumOperations

func (ctx *ExecutionContext) ExecuteChecksumOperations(operations []types.Operation) ([]OperationResult, error)

ExecuteChecksumOperations executes only checksum operations and stores results

func (*ExecutionContext) GetChecksum

func (ctx *ExecutionContext) GetChecksum(filePath string) (string, bool)

GetChecksum returns the stored checksum for a file path

type FillPackOptions

type FillPackOptions struct {
	// DotfilesRoot is the path to the root of the dotfiles directory.
	DotfilesRoot string
	// PackName is the name of the pack to fill with template files.
	PackName string
}

FillPackOptions defines the options for the FillPack command.

type InitPackOptions

type InitPackOptions struct {
	// DotfilesRoot is the path to the root of the dotfiles directory.
	DotfilesRoot string
	// PackName is the name of the new pack to create.
	PackName string
}

InitPackOptions defines the options for the InitPack command.

type InstallPacksOptions

type InstallPacksOptions struct {
	// DotfilesRoot is the path to the root of the dotfiles directory.
	DotfilesRoot string
	// PackNames is a list of specific packs to install. If empty, all packs are installed.
	PackNames []string
	// DryRun specifies whether to perform a dry run without making changes.
	DryRun bool
	// Force re-runs power-ups that normally only run once.
	Force bool
}

InstallPacksOptions defines the options for the InstallPacks command.

type ListPacksOptions

type ListPacksOptions struct {
	// DotfilesRoot is the path to the root of the dotfiles directory.
	DotfilesRoot string
}

ListPacksOptions defines the options for the ListPacks command.

type OperationResult

type OperationResult struct {
	Operation types.Operation
	Success   bool
	Result    interface{} // For checksum operations, this contains the checksum string
	Error     error
}

OperationResult represents the result of executing an operation

type RunOnceStatus

type RunOnceStatus struct {
	Executed   bool
	ExecutedAt time.Time
	Checksum   string
	Changed    bool // True if the source file has changed since execution
}

RunOnceStatus represents the execution status of a run-once power-up

func GetRunOnceStatus

func GetRunOnceStatus(packPath, powerUpName string) (*RunOnceStatus, error)

GetRunOnceStatus checks the status of a run-once power-up for a specific pack

type StatusPacksOptions

type StatusPacksOptions struct {
	// DotfilesRoot is the path to the root of the dotfiles directory.
	DotfilesRoot string
	// PackNames is a list of specific packs to check status for. If empty, all packs are checked.
	PackNames []string
}

StatusPacksOptions defines the options for the StatusPacks command.

type SynthfsExecutor

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

SynthfsExecutor executes dodot operations using synthfs

func NewSynthfsExecutor

func NewSynthfsExecutor(dryRun bool) *SynthfsExecutor

NewSynthfsExecutor creates a new synthfs-based executor

func NewSynthfsExecutorWithPaths

func NewSynthfsExecutorWithPaths(dryRun bool, p *paths.Paths) *SynthfsExecutor

NewSynthfsExecutorWithPaths creates a new synthfs-based executor with custom paths

func (e *SynthfsExecutor) EnableHomeSymlinks(backup bool) *SynthfsExecutor

EnableHomeSymlinks allows the executor to create symlinks in the user's home directory This should be used with caution and only for SymlinkPowerUp

func (*SynthfsExecutor) ExecuteOperations

func (e *SynthfsExecutor) ExecuteOperations(ops []types.Operation) error

ExecuteOperations executes a list of operations using synthfs

Jump to

Keyboard shortcuts

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