Documentation
¶
Overview ¶
Package version provides utilities for semantic versioning
Index ¶
- Constants
- func IsPluginVersionCompatible(pluginVersion, minFrameworkVersion, maxFrameworkVersion string) (bool, error)
- type Dependency
- type DependencyGraph
- func (g *DependencyGraph) AddDependency(parentID string, dependency *Dependency)
- func (g *DependencyGraph) GetAllDependencies(id string) []*Dependency
- func (g *DependencyGraph) GetDependencies(parentID string) []*Dependency
- func (g *DependencyGraph) GetDependency(id string) (*Dependency, bool)
- func (g *DependencyGraph) GetImpactedDependencies(id string) []*Dependency
- func (g *DependencyGraph) GetReverseDependencies(id string) []*Dependency
- func (g *DependencyGraph) HasCircularDependency() (bool, string)
- type DependencyType
- type DiffItem
- type DiffOptions
- type DiffResult
- type DiffSummary
- type DiffType
- type FrameworkInfo
- type SemVersion
- func (v *SemVersion) Compare(other *SemVersion) int
- func (v *SemVersion) Equal(other *SemVersion) bool
- func (v *SemVersion) GreaterThan(other *SemVersion) bool
- func (v *SemVersion) IncrementMajor() *SemVersion
- func (v *SemVersion) IncrementMinor() *SemVersion
- func (v *SemVersion) IncrementPatch() *SemVersion
- func (v *SemVersion) IsBackwardsCompatible(other *SemVersion) bool
- func (v *SemVersion) IsCompatible(other *SemVersion) bool
- func (v *SemVersion) LessThan(other *SemVersion) bool
- func (v *SemVersion) String() string
- func (v *SemVersion) WithBuild(build string) *SemVersion
- func (v *SemVersion) WithPrerelease(prerelease string) *SemVersion
- type VersionInfo
- func (v *VersionInfo) GetVersionString() string
- func (v *VersionInfo) IncrementMajor()
- func (v *VersionInfo) IncrementMinor()
- func (v *VersionInfo) IncrementPatch()
- func (v *VersionInfo) IsBackwardsCompatible(other *VersionInfo) bool
- func (v *VersionInfo) IsCompatible(other *VersionInfo) bool
- func (v *VersionInfo) UpdateVersion(version string) error
- func (v *VersionInfo) WithMetadata(key string, value interface{}) *VersionInfo
- func (v *VersionInfo) WithTag(tag string) *VersionInfo
Constants ¶
const FrameworkVersion = "0.1.0"
FrameworkVersion is the current version of the framework
Variables ¶
This section is empty.
Functions ¶
func IsPluginVersionCompatible ¶
func IsPluginVersionCompatible(pluginVersion, minFrameworkVersion, maxFrameworkVersion string) (bool, error)
IsPluginVersionCompatible checks if a plugin version is compatible with the framework
Types ¶
type Dependency ¶
type Dependency struct {
// ID is the unique identifier for the dependency
ID string
// Type is the type of dependency
Type DependencyType
// MinVersion is the minimum required version
MinVersion *SemVersion
// MaxVersion is the maximum allowed version
MaxVersion *SemVersion
// Optional indicates if the dependency is optional
Optional bool
// Path is the path to the dependency
Path string
}
Dependency represents a dependency on another template, module, or plugin
func NewDependency ¶
func NewDependency(id string, depType DependencyType, minVersion string, optional bool) (*Dependency, error)
NewDependency creates a new dependency
func (*Dependency) IsCompatible ¶
func (d *Dependency) IsCompatible(version *SemVersion) bool
IsCompatible checks if a version is compatible with the dependency
func (*Dependency) WithMaxVersion ¶
func (d *Dependency) WithMaxVersion(maxVersion string) (*Dependency, error)
WithMaxVersion sets the maximum version for the dependency
func (*Dependency) WithPath ¶
func (d *Dependency) WithPath(path string) *Dependency
WithPath sets the path for the dependency
type DependencyGraph ¶
type DependencyGraph struct {
// Dependencies is a map of dependencies by ID
Dependencies map[string]*Dependency
// DependencyTree is a map of dependencies by parent ID
DependencyTree map[string][]string
// ReverseDependencies is a map of reverse dependencies by ID
ReverseDependencies map[string][]string
// contains filtered or unexported fields
}
DependencyGraph represents a graph of dependencies
func NewDependencyGraph ¶
func NewDependencyGraph() *DependencyGraph
NewDependencyGraph creates a new dependency graph
func (*DependencyGraph) AddDependency ¶
func (g *DependencyGraph) AddDependency(parentID string, dependency *Dependency)
AddDependency adds a dependency to the graph
func (*DependencyGraph) GetAllDependencies ¶
func (g *DependencyGraph) GetAllDependencies(id string) []*Dependency
GetAllDependencies gets all dependencies recursively
func (*DependencyGraph) GetDependencies ¶
func (g *DependencyGraph) GetDependencies(parentID string) []*Dependency
GetDependencies gets all dependencies for a parent ID
func (*DependencyGraph) GetDependency ¶
func (g *DependencyGraph) GetDependency(id string) (*Dependency, bool)
GetDependency gets a dependency by ID
func (*DependencyGraph) GetImpactedDependencies ¶
func (g *DependencyGraph) GetImpactedDependencies(id string) []*Dependency
GetImpactedDependencies gets all dependencies impacted by a change to the given ID
func (*DependencyGraph) GetReverseDependencies ¶
func (g *DependencyGraph) GetReverseDependencies(id string) []*Dependency
GetReverseDependencies gets all reverse dependencies for an ID
func (*DependencyGraph) HasCircularDependency ¶
func (g *DependencyGraph) HasCircularDependency() (bool, string)
HasCircularDependency checks if there is a circular dependency
type DependencyType ¶
type DependencyType string
DependencyType represents the type of dependency
const ( // TemplateDependency represents a template dependency TemplateDependency DependencyType = "template" // ModuleDependency represents a module dependency ModuleDependency DependencyType = "module" // PluginDependency represents a plugin dependency PluginDependency DependencyType = "plugin" // LibraryDependency represents a library dependency LibraryDependency DependencyType = "library" )
type DiffItem ¶
type DiffItem struct {
// Type is the type of difference
Type DiffType
// Path is the path to the item
Path string
// OldContent is the old content
OldContent string
// NewContent is the new content
NewContent string
// LineNumber is the line number of the difference
LineNumber int
// LineCount is the number of lines affected
LineCount int
// Metadata is additional metadata for the difference
Metadata map[string]interface{}
}
DiffItem represents a difference item
func NewDiffItem ¶
func NewDiffItem(diffType DiffType, path string, oldContent, newContent string, lineNumber, lineCount int) *DiffItem
NewDiffItem creates a new diff item
func (*DiffItem) WithMetadata ¶
WithMetadata adds metadata to the diff item
type DiffOptions ¶
type DiffOptions struct {
// IgnoreWhitespace determines if whitespace should be ignored
IgnoreWhitespace bool
// IgnoreCase determines if case should be ignored
IgnoreCase bool
// IgnoreComments determines if comments should be ignored
IgnoreComments bool
// IgnoreFormatting determines if formatting should be ignored
IgnoreFormatting bool
// IncludeUnchanged determines if unchanged items should be included
IncludeUnchanged bool
}
DiffOptions represents options for diffing
func DefaultDiffOptions ¶
func DefaultDiffOptions() *DiffOptions
DefaultDiffOptions returns the default diff options
type DiffResult ¶
type DiffResult struct {
// LocalVersion is the local version
LocalVersion *VersionInfo
// RemoteVersion is the remote version
RemoteVersion *VersionInfo
// Items is the list of diff items
Items []*DiffItem
// Summary is a summary of the differences
Summary *DiffSummary
// DiffTime is the time the diff was performed
DiffTime time.Time
}
DiffResult represents the result of a diff operation
func NewDiffResult ¶
func NewDiffResult(localVersion, remoteVersion *VersionInfo) *DiffResult
NewDiffResult creates a new diff result
func (*DiffResult) AddItem ¶
func (r *DiffResult) AddItem(item *DiffItem)
AddItem adds a diff item to the result
func (*DiffResult) GetAddedItems ¶
func (r *DiffResult) GetAddedItems() []*DiffItem
GetAddedItems returns all added items
func (*DiffResult) GetModifiedItems ¶
func (r *DiffResult) GetModifiedItems() []*DiffItem
GetModifiedItems returns all modified items
func (*DiffResult) GetRemovedItems ¶
func (r *DiffResult) GetRemovedItems() []*DiffItem
GetRemovedItems returns all removed items
func (*DiffResult) GetUnchangedItems ¶
func (r *DiffResult) GetUnchangedItems() []*DiffItem
GetUnchangedItems returns all unchanged items
func (*DiffResult) HasDifferences ¶
func (r *DiffResult) HasDifferences() bool
HasDifferences returns true if there are differences
type DiffSummary ¶
type DiffSummary struct {
// Added is the number of added items
Added int
// Removed is the number of removed items
Removed int
// Modified is the number of modified items
Modified int
// Unchanged is the number of unchanged items
Unchanged int
// Total is the total number of items
Total int
}
DiffSummary represents a summary of differences
func (*DiffSummary) String ¶
func (s *DiffSummary) String() string
String returns a string representation of the diff summary
type DiffType ¶
type DiffType string
DiffType represents the type of difference
const ( // AddedDiff represents an added item AddedDiff DiffType = "added" // RemovedDiff represents a removed item RemovedDiff DiffType = "removed" // ModifiedDiff represents a modified item ModifiedDiff DiffType = "modified" // UnchangedDiff represents an unchanged item UnchangedDiff DiffType = "unchanged" )
type FrameworkInfo ¶
type FrameworkInfo struct {
// Version is the current version of the framework
Version string
// MinPluginVersion is the minimum plugin version supported
MinPluginVersion string
// MaxPluginVersion is the maximum plugin version supported
MaxPluginVersion string
}
FrameworkInfo contains information about the framework
func GetFrameworkInfo ¶
func GetFrameworkInfo() *FrameworkInfo
GetFrameworkInfo returns information about the framework
type SemVersion ¶
type SemVersion struct {
// Major version number
Major int
// Minor version number
Minor int
// Patch version number
Patch int
// Prerelease identifiers (e.g., "alpha.1", "beta.2")
Prerelease string
// Build metadata (e.g., "build.123")
Build string
}
SemVersion represents a semantic version
func MustParse ¶
func MustParse(version string) *SemVersion
MustParse parses a version string into a SemVersion object It panics if the version string is invalid
func Parse ¶
func Parse(version string) (*SemVersion, error)
Parse parses a version string into a SemVersion object
func (*SemVersion) Compare ¶
func (v *SemVersion) Compare(other *SemVersion) int
Compare compares two versions Returns -1 if v < other, 0 if v == other, 1 if v > other
func (*SemVersion) Equal ¶
func (v *SemVersion) Equal(other *SemVersion) bool
Equal returns true if v == other
func (*SemVersion) GreaterThan ¶
func (v *SemVersion) GreaterThan(other *SemVersion) bool
GreaterThan returns true if v > other
func (*SemVersion) IncrementMajor ¶
func (v *SemVersion) IncrementMajor() *SemVersion
IncrementMajor increments the major version and resets minor and patch to 0
func (*SemVersion) IncrementMinor ¶
func (v *SemVersion) IncrementMinor() *SemVersion
IncrementMinor increments the minor version and resets patch to 0
func (*SemVersion) IncrementPatch ¶
func (v *SemVersion) IncrementPatch() *SemVersion
IncrementPatch increments the patch version
func (*SemVersion) IsBackwardsCompatible ¶
func (v *SemVersion) IsBackwardsCompatible(other *SemVersion) bool
IsBackwardsCompatible checks if the version is backwards compatible with the given version using semantic versioning rules (major version must match and be >= the other version)
func (*SemVersion) IsCompatible ¶
func (v *SemVersion) IsCompatible(other *SemVersion) bool
IsCompatible checks if the version is compatible with the given version using semantic versioning rules (major version must match)
func (*SemVersion) LessThan ¶
func (v *SemVersion) LessThan(other *SemVersion) bool
LessThan returns true if v < other
func (*SemVersion) String ¶
func (v *SemVersion) String() string
String returns the string representation of a version
func (*SemVersion) WithBuild ¶
func (v *SemVersion) WithBuild(build string) *SemVersion
WithBuild returns a new version with the given build string
func (*SemVersion) WithPrerelease ¶
func (v *SemVersion) WithPrerelease(prerelease string) *SemVersion
WithPrerelease returns a new version with the given prerelease string
type VersionInfo ¶
type VersionInfo struct {
// ID is the unique identifier for the template or module
ID string
// Version is the semantic version
Version *SemVersion
// CreatedAt is the creation timestamp
CreatedAt time.Time
// UpdatedAt is the last update timestamp
UpdatedAt time.Time
// Author is the author of the template or module
Author string
// Description is a description of the template or module
Description string
// Tags are tags associated with the template or module
Tags []string
// Metadata is additional metadata for the template or module
Metadata map[string]interface{}
}
VersionInfo represents version information for a template or module
func NewVersionInfo ¶
func NewVersionInfo(id string, version string, author string, description string) (*VersionInfo, error)
NewVersionInfo creates a new version info object
func (*VersionInfo) GetVersionString ¶
func (v *VersionInfo) GetVersionString() string
GetVersionString returns the string representation of the version
func (*VersionInfo) IncrementMajor ¶
func (v *VersionInfo) IncrementMajor()
IncrementMajor increments the major version
func (*VersionInfo) IncrementMinor ¶
func (v *VersionInfo) IncrementMinor()
IncrementMinor increments the minor version
func (*VersionInfo) IncrementPatch ¶
func (v *VersionInfo) IncrementPatch()
IncrementPatch increments the patch version
func (*VersionInfo) IsBackwardsCompatible ¶
func (v *VersionInfo) IsBackwardsCompatible(other *VersionInfo) bool
IsBackwardsCompatible checks if the version info is backwards compatible with another version info
func (*VersionInfo) IsCompatible ¶
func (v *VersionInfo) IsCompatible(other *VersionInfo) bool
IsCompatible checks if the version info is compatible with another version info
func (*VersionInfo) UpdateVersion ¶
func (v *VersionInfo) UpdateVersion(version string) error
UpdateVersion updates the version and sets the updated timestamp
func (*VersionInfo) WithMetadata ¶
func (v *VersionInfo) WithMetadata(key string, value interface{}) *VersionInfo
WithMetadata adds metadata to the version info
func (*VersionInfo) WithTag ¶
func (v *VersionInfo) WithTag(tag string) *VersionInfo
WithTag adds a tag to the version info