gpkg

package module
v0.0.0-...-8427bbe Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2023 License: MIT Imports: 31 Imported by: 0

README

gpkg

CI

A package manager written in Go. (Currently in development 🔨)

Getting started

Installation
Add a package
[[packages]]
from = "ghr"
repo = "junegunn/fzf"
Load packages

Installed plugins can be loaded using load.

eval $(gpkg load)

License

MIT License (© 2023 Ryota Kota)

Documentation

Index

Constants

View Source
const Version = "v0.1.0"

Variables

This section is empty.

Functions

func CreateConfigFile

func CreateConfigFile(cfgPath string) error

func DecoderConfigOption

func DecoderConfigOption(cfg *Config) func(*mapstructure.DecoderConfig)

func Pick

func Pick(root, expr string) error

func ReconcilePackage

func ReconcilePackage(packagesDir string, states *StateData, spec PackageSpec, ch chan<- *Event, w io.Writer) error

func SpecEqual

func SpecEqual(a, b PackageSpec) bool

Types

type CommonSpec

type CommonSpec struct {
	From string `json:"from"`
	Pick string `json:"pick,omitempty"`
	Ref  string `json:"ref,omitempty"`
	ID   string `json:"id,omitempty"`
	// contains filtered or unexported fields
}

func (*CommonSpec) Common

func (s *CommonSpec) Common() *CommonSpec

func (*CommonSpec) DisplayName

func (s *CommonSpec) DisplayName() string

func (*CommonSpec) Validate

func (s *CommonSpec) Validate() error

type Config

type Config struct {
	CachePath string        `json:"cache_path"`
	Specs     []PackageSpec `json:"packages"`
}

func (*Config) GetPackagesPath

func (c *Config) GetPackagesPath() string

type Downloader

type Downloader interface {
	io.ReadCloser
	GetAssetName() string
	GetContentLength() int64
}

type Event

type Event struct {
	Type EventType
	Spec PackageSpec
	Data interface{}
}

type EventBuilder

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

type EventDataDownload

type EventDataDownload struct {
	ContentLength int64
	CurrentRef    string
	NextRef       string
}

type EventDataSkipped

type EventDataSkipped struct {
	CurrentRef string
}

type EventType

type EventType uint8
const (
	EventStarted EventType = iota
	EventCompleted
	EventDownloadStarted
	EventDownloadCompleted
	EventPickStarted
	EventSkipped
)

type GitHubRelease

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

func NewGitHubRelease

func NewGitHubRelease(name, ref string, client releaseGetter) (*GitHubRelease, error)

func (*GitHubRelease) GetDownloader

func (ghr *GitHubRelease) GetDownloader() (Downloader, error)

func (*GitHubRelease) ShouldUpdate

func (ghr *GitHubRelease) ShouldUpdate(currentRef string) (bool, string, error)

type GitHubReleaseSpec

type GitHubReleaseSpec struct {
	*CommonSpec
	Repo string `json:"repo"`
}

func (*GitHubReleaseSpec) DisplayName

func (s *GitHubReleaseSpec) DisplayName() string

func (*GitHubReleaseSpec) PackagePath

func (s *GitHubReleaseSpec) PackagePath() string

func (*GitHubReleaseSpec) Unique

func (s *GitHubReleaseSpec) Unique() string

func (*GitHubReleaseSpec) Validate

func (s *GitHubReleaseSpec) Validate() error

type HTTPDownloader

type HTTPDownloader struct {
	io.ReadCloser
	// contains filtered or unexported fields
}

func NewHTTPDownloader

func NewHTTPDownloader(name, url string) (*HTTPDownloader, error)

func (*HTTPDownloader) GetAssetName

func (dl *HTTPDownloader) GetAssetName() string

func (*HTTPDownloader) GetContentLength

func (dl *HTTPDownloader) GetContentLength() int64

type NopSpec

type NopSpec struct {
	*CommonSpec
}

NopSpec implements PackageSpec interface and its methods do nothing. You can use this struct in test code.

func NewNopSpec

func NewNopSpec(id string) *NopSpec

func (*NopSpec) PackagePath

func (s *NopSpec) PackagePath() string

func (*NopSpec) Unique

func (s *NopSpec) Unique() string

type PackageSpec

type PackageSpec interface {
	Common() *CommonSpec
	Validate() error
	DisplayName() string
	PackagePath() string
	Unique() string
}

type Source

type Source interface {
	GetDownloader() (Downloader, error)
	ShouldUpdate(string) (bool, string, error)
}

type State

type State struct {
	Spec PackageSpec `json:"spec"`
	Path string      `json:"path"`
	Ref  string      `json:"ref"`
}

type StateData

type StateData struct {
	States []State `json:"states"`
}

func DecodeStateData

func DecodeStateData(r io.Reader) (*StateData, error)

func LoadStateDataFromFile

func LoadStateDataFromFile(path string) (*StateData, error)

func (*StateData) FindState

func (sd *StateData) FindState(spec PackageSpec) (int, *State, error)

func (*StateData) Save

func (sd *StateData) Save(w io.Writer) error

func (*StateData) SaveToFile

func (sd *StateData) SaveToFile(path string) error

func (*StateData) Upsert

func (sd *StateData) Upsert(spec PackageSpec, ref string)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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