version

package
v0.0.0-...-6d85b5a Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidVersion = errors.New("invalid version")

	SemverExpression        = regexp.MustCompile("(?P<major>0|[1-9]\\d*)\\.(?P<minor>0|[1-9]\\d*)\\.(?P<patch>0|[1-9]\\d*)(?:-(?P<prerelease>(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?")
	SemverExpressionPartial = regexp.MustCompile("(?P<versiob>(?P<major>0|[1-9]\\d*)\\.(?P<minor>0|[1-9]\\d*)\\.(?P<patch>0|[1-9]\\d*)(?:-(?P<prerelease>(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*)))?")
	SemverExpressionFull    = regexp.MustCompile("^" + SemverExpression.String() + "$")
)
View Source
var (
	ErrNoVersion = errors.New("no version found")
)
View Source
var (
	Getters = []Getter{}
)
View Source
var (
	Setters = []Setter{}
)

Functions

func Replace

func Replace(p string, v Version) string

func ReplaceExpression

func ReplaceExpression(text string) *regexp.Regexp

func Set

func Set(v Version) error

Types

type ExpressionStrategy

type ExpressionStrategy struct {
	Directories []string `json:"directories"`
	Pattern     string   `json:"pattern"`
	Expression  string   `json:"expression"`
	Replacement string   `json:"replacement"`
}

func (*ExpressionStrategy) Get

func (es *ExpressionStrategy) Get() ([]Version, error)

func (*ExpressionStrategy) GetExpression

func (es *ExpressionStrategy) GetExpression() *regexp.Regexp

func (*ExpressionStrategy) Log

func (es *ExpressionStrategy) Log() string

func (*ExpressionStrategy) Set

func (es *ExpressionStrategy) Set(v Version) error

type Getter

type Getter interface {
	Get() ([]Version, error)
	Log() string
}

type NpmStrategy

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

func NewNpmStrategy

func NewNpmStrategy(directory string) *NpmStrategy

func (*NpmStrategy) Get

func (ns *NpmStrategy) Get() ([]Version, error)

func (*NpmStrategy) Log

func (ns *NpmStrategy) Log() string

func (*NpmStrategy) Set

func (ns *NpmStrategy) Set(v Version) error

type Setter

type Setter interface {
	Set(Version) error
	Log() string
}

type Version

type Version struct {
	Major uint64
	Minor uint64

	Patch      uint64
	Prerelease []string
	Build      []string
}

func Get

func Get() (Version, error)

func MustParse

func MustParse(text string) Version

func Parse

func Parse[T string | []byte](text T) (Version, error)

func (Version) Compare

func (v Version) Compare(v2 Version) int

func (Version) MarshalJSON

func (v Version) MarshalJSON() ([]byte, error)

func (Version) String

func (v Version) String() string

func (*Version) UnmarshalJSON

func (v *Version) UnmarshalJSON(bytes []byte) error

type VersionStrategy

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

func NewVersionStrategy

func NewVersionStrategy(directory string) *VersionStrategy

func (*VersionStrategy) Get

func (vs *VersionStrategy) Get() ([]Version, error)

func (*VersionStrategy) Log

func (vs *VersionStrategy) Log() string

func (*VersionStrategy) Set

func (vs *VersionStrategy) Set(v Version) error

Jump to

Keyboard shortcuts

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