Documentation
¶
Overview ¶
Package version provides utilities for semantic versioning
Index ¶
- Constants
- func ComputeHash(content []byte) string
- func GetFileExtension(path string) string
- func IsBinaryFile(path string) bool
- func IsCodeFile(path string) bool
- func IsConfigFile(path string) bool
- func IsPluginVersionCompatible(pluginVersion, minFrameworkVersion, maxFrameworkVersion string) (bool, error)
- func IsTextFile(path string) bool
- func ReadFileContent(reader io.Reader, maxSize int64) ([]byte, error)
- type AnalysisResult
- type Analyzer
- type AnalyzerOptions
- 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 Diff
- type DiffItem
- type DiffOptions
- type DiffResult
- type DiffSummary
- type DiffType
- type FileInfo
- type FrameworkInfo
- type SemVersion
- func (v *SemVersion) Compare(other *SemVersion) int
- func (v *SemVersion) Equal(other *SemVersion) bool
- func (v *SemVersion) GetChangeType(other *SemVersion) VersionChangeType
- 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 Version
- type VersionChangeType
- 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 ComputeHash ¶
ComputeHash computes a hash for the given content
func GetFileExtension ¶
GetFileExtension gets the extension of a file
func IsBinaryFile ¶
IsBinaryFile checks if a file is a binary file based on its extension
func IsCodeFile ¶
IsCodeFile checks if a file is a code file based on its extension
func IsConfigFile ¶
IsConfigFile checks if a file is a configuration file based on its extension
func IsPluginVersionCompatible ¶
func IsPluginVersionCompatible(pluginVersion, minFrameworkVersion, maxFrameworkVersion string) (bool, error)
IsPluginVersionCompatible checks if a plugin version is compatible with the framework
func IsTextFile ¶
IsTextFile checks if a file is a text file based on its extension
Types ¶
type AnalysisResult ¶
type AnalysisResult struct {
// LocalVersion is the local version
LocalVersion *VersionInfo
// RemoteVersion is the remote version
RemoteVersion *VersionInfo
// Diff is the difference between local and remote versions
Diff *DiffResult
// DependencyGraph is the dependency graph
DependencyGraph *DependencyGraph
// UpdateRequired indicates if an update is required
UpdateRequired bool
// ImpactedItems are the items impacted by the update
ImpactedItems []string
// AnalysisTime is the time the analysis was performed
AnalysisTime time.Time
}
AnalysisResult represents the result of a version analysis
type Analyzer ¶
type Analyzer struct {
// Options are the analyzer options
Options *AnalyzerOptions
// LocalRepo is the local repository
LocalRepo interfaces.Repository
// RemoteRepo is the remote repository
RemoteRepo interfaces.Repository
// DependencyGraph is the dependency graph
DependencyGraph *DependencyGraph
}
Analyzer analyzes template and module versions
func NewAnalyzer ¶
func NewAnalyzer(localRepo, remoteRepo interfaces.Repository, options *AnalyzerOptions) *Analyzer
NewAnalyzer creates a new version analyzer
func (*Analyzer) AnalyzeAll ¶
AnalyzeAll analyzes all templates and modules
func (*Analyzer) AnalyzeModule ¶
AnalyzeModule analyzes a module
func (*Analyzer) AnalyzeTemplate ¶
func (a *Analyzer) AnalyzeTemplate(ctx context.Context, templatePath string) (*AnalysisResult, error)
AnalyzeTemplate analyzes a template
type AnalyzerOptions ¶
type AnalyzerOptions struct {
// DiffOptions are the options for file diffing
DiffOptions *DiffOptions
// IncludeDependencies determines if dependencies should be analyzed
IncludeDependencies bool
// MaxConcurrentOperations is the maximum number of concurrent operations
MaxConcurrentOperations int
// Timeout is the timeout for operations
Timeout time.Duration
// TemplatePatterns are the patterns for template files
TemplatePatterns []string
// ModulePatterns are the patterns for module files
ModulePatterns []string
}
AnalyzerOptions represents options for the version analyzer
func DefaultAnalyzerOptions ¶
func DefaultAnalyzerOptions() *AnalyzerOptions
DefaultAnalyzerOptions returns the default analyzer options
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 Diff ¶
type Diff struct {
OldFiles []*FileInfo
NewFiles []*FileInfo
OldVersion *SemVersion
NewVersion *SemVersion
}
Diff represents the differences between two sets of files
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
// MaxContentSize is the maximum content size to read (in bytes)
MaxContentSize int64
}
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 DiffFiles ¶
func DiffFiles(oldFiles, newFiles []*FileInfo, options *DiffOptions) *DiffResult
DiffFiles creates a diff between two sets of files
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) GetChangeType ¶
func (v *SemVersion) GetChangeType(other *SemVersion) VersionChangeType
GetChangeType determines the type of change between two versions
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 Version ¶
type Version = SemVersion
Version is an alias for SemVersion for compatibility
func ParseVersion ¶
ParseVersion parses a version string into a Version struct
type VersionChangeType ¶
type VersionChangeType string
VersionChangeType represents the type of version change
const ( MajorChange VersionChangeType = "major" MinorChange VersionChangeType = "minor" PatchChange VersionChangeType = "patch" PreReleaseChange VersionChangeType = "prerelease" BuildChange VersionChangeType = "build" NoChange VersionChangeType = "none" )
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
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package version provides utilities for semantic versioning
|
Package version provides utilities for semantic versioning |
|
Package version provides utilities for semantic versioning
|
Package version provides utilities for semantic versioning |