projectid

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Mix = ProjectID(iota + 10)
	Python
	Go
	Node
	Flutter
	Rust
	MaxProjectID
)

Variables

View Source
var RustVersionRE = regexp.MustCompile(`\s*version\s*=\s*"(.+)"`)

Functions

func Pwd

func Pwd() string

Pwd returns the current working directory

Types

type FlutterProject added in v0.2.1

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

func (*FlutterProject) GetVersion added in v0.2.1

func (p *FlutterProject) GetVersion() (*version.Version, error)

func (*FlutterProject) ID added in v0.2.1

func (p *FlutterProject) ID() ProjectID

func (*FlutterProject) IsMe added in v0.2.1

func (p *FlutterProject) IsMe(workdir string) bool

func (*FlutterProject) SetVersion added in v0.2.1

func (p *FlutterProject) SetVersion(v *version.Version) error

func (*FlutterProject) WorkDir added in v0.2.1

func (p *FlutterProject) WorkDir() string

type GoProject

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

GoProject represents a Go project with versioning capabilities Because Go projects do not have a standard version file, we flow the rules below:

  • lookup the project by checking the existence of "version.txt"
  • this file can be embedded to a go variable use `go:embed` directive
  • the file content should be like `x.y.z`

func (*GoProject) GetVersion

func (p *GoProject) GetVersion() (*version.Version, error)

func (*GoProject) ID

func (p *GoProject) ID() ProjectID

func (*GoProject) IsMe

func (p *GoProject) IsMe(workdir string) bool

func (*GoProject) SetVersion

func (p *GoProject) SetVersion(v *version.Version) error

func (*GoProject) WorkDir

func (p *GoProject) WorkDir() string

type MixProject added in v0.2.1

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

func (*MixProject) GetVersion added in v0.2.1

func (p *MixProject) GetVersion() (*version.Version, error)

func (*MixProject) ID added in v0.2.1

func (p *MixProject) ID() ProjectID

func (*MixProject) IsMe added in v0.2.1

func (p *MixProject) IsMe(workdir string) bool

func (*MixProject) SetVersion added in v0.2.1

func (p *MixProject) SetVersion(v *version.Version) error

func (*MixProject) WorkDir added in v0.2.1

func (p *MixProject) WorkDir() string

type NodeProject

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

func (*NodeProject) GetVersion

func (p *NodeProject) GetVersion() (*version.Version, error)

func (*NodeProject) ID

func (p *NodeProject) ID() ProjectID

func (*NodeProject) IsMe

func (p *NodeProject) IsMe(workdir string) bool

func (*NodeProject) SetVersion

func (p *NodeProject) SetVersion(v *version.Version) error

func (*NodeProject) WorkDir

func (p *NodeProject) WorkDir() string

type Project

type Project interface {
	// Test if the project is of the specified type
	IsMe(workdir string) bool
	// Get the project ID
	ID() ProjectID
	// Get the working directory of the project
	WorkDir() string
	// Get the current version of the project
	GetVersion() (*version.Version, error)
	// Set a new version for the project
	SetVersion(v *version.Version) error
}

Project represents a generic project with versioning capabilities

type ProjectID

type ProjectID int

func ParseProjectID

func ParseProjectID(s string) ProjectID

func Which

func Which(workdir string) ProjectID

Which returns the type of project in current directory

func (ProjectID) Project

func (p ProjectID) Project(workdir string) Project

func (ProjectID) String

func (p ProjectID) String() string

type PythonProject

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

func (*PythonProject) GetVersion

func (p *PythonProject) GetVersion() (*version.Version, error)

func (*PythonProject) ID

func (p *PythonProject) ID() ProjectID

func (*PythonProject) IsMe

func (p *PythonProject) IsMe(workdir string) bool

func (*PythonProject) SetVersion

func (p *PythonProject) SetVersion(v *version.Version) error

func (*PythonProject) WorkDir

func (p *PythonProject) WorkDir() string

type RustProject

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

func (*RustProject) GetVersion

func (p *RustProject) GetVersion() (*version.Version, error)

func (*RustProject) ID

func (p *RustProject) ID() ProjectID

func (*RustProject) IsMe

func (p *RustProject) IsMe(workdir string) bool

func (*RustProject) SetVersion

func (p *RustProject) SetVersion(v *version.Version) error

func (*RustProject) WorkDir

func (p *RustProject) WorkDir() string

Jump to

Keyboard shortcuts

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