dependencycheck

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GetDependencyCheckerFn = func() DependencyChecker {
	return defaultDependencyChecker
}

GetDependencyCheckerFn allows overriding the getter function for testing.

View Source
var RegisterDependencyCheckerFn = func(dc DependencyChecker) {
	defaultDependencyChecker = dc
}

RegisterDependencyCheckerFn allows overriding the registration function for testing.

Functions

func Register

func Register(cfg *Config)

Register initializes the dependency checker plugin with the given configuration.

func ResetDependencyChecker

func ResetDependencyChecker()

ResetDependencyChecker clears the registered dependency checker (for testing).

func Unregister

func Unregister()

Unregister removes the dependency checker plugin.

Types

type Config

type Config struct {
	// Enabled controls whether the plugin is active.
	Enabled bool

	// AutoSync automatically syncs versions after bumps.
	AutoSync bool

	// Files lists the files to check and sync.
	Files []FileConfig
}

Config holds configuration for the dependency checker plugin.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns the default dependency checker configuration.

type DependencyChecker

type DependencyChecker interface {
	Name() string
	Description() string
	Version() string

	// CheckConsistency validates all configured files match the current version.
	CheckConsistency(currentVersion string) ([]Inconsistency, error)

	// SyncVersions updates all configured files to the new version.
	SyncVersions(newVersion string) error

	// IsEnabled returns whether the plugin is active.
	IsEnabled() bool

	// GetConfig returns the plugin configuration.
	GetConfig() *Config
}

DependencyChecker defines the interface for dependency version checking.

type DependencyCheckerPlugin

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

DependencyCheckerPlugin implements the DependencyChecker interface.

func NewDependencyChecker

func NewDependencyChecker(cfg *Config) *DependencyCheckerPlugin

NewDependencyChecker creates a new dependency checker plugin with the given configuration.

func (*DependencyCheckerPlugin) CheckConsistency

func (p *DependencyCheckerPlugin) CheckConsistency(currentVersion string) ([]Inconsistency, error)

CheckConsistency validates all configured files match the current version.

func (*DependencyCheckerPlugin) Description

func (p *DependencyCheckerPlugin) Description() string

func (*DependencyCheckerPlugin) GetConfig

func (p *DependencyCheckerPlugin) GetConfig() *Config

GetConfig returns the plugin configuration.

func (*DependencyCheckerPlugin) IsEnabled

func (p *DependencyCheckerPlugin) IsEnabled() bool

IsEnabled returns whether the plugin is active.

func (*DependencyCheckerPlugin) Name

func (p *DependencyCheckerPlugin) Name() string

func (*DependencyCheckerPlugin) SyncVersions

func (p *DependencyCheckerPlugin) SyncVersions(newVersion string) error

SyncVersions updates all configured files to the new version.

func (*DependencyCheckerPlugin) Version

func (p *DependencyCheckerPlugin) Version() string

type FileConfig

type FileConfig struct {
	// Path is the file path relative to repository root.
	Path string

	// Field is the dot-notation path to the version field (for JSON/YAML/TOML).
	// Example: "version", "tool.poetry.version", "metadata.version"
	Field string

	// Format specifies the file format: json, yaml, toml, raw, regex
	Format string

	// Pattern is the regex pattern for "regex" format.
	// Use capturing group for version: e.g., `version = "(.*?)"`
	Pattern string
}

FileConfig defines a single file to check/sync.

type Inconsistency

type Inconsistency struct {
	Path     string
	Expected string
	Found    string
	Format   string
}

Inconsistency represents a version mismatch in a file.

func (Inconsistency) String

func (i Inconsistency) String() string

String returns a formatted string representation of the inconsistency.

Jump to

Keyboard shortcuts

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