core

package
v0.1.12 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const AppCodeName = "pho"
View Source
const AppDescription = "AppImage Manager"
View Source
const AppExecutableName = "pho"
View Source
const AppGithubOwner = "zyrouge"
View Source
const AppGithubRepo = "pho"
View Source
const AppName = "Pho"
View Source
const AppVersion = "0.1.12"

Variables

View Source
var GithubRepoUrlRegex = regexp.MustCompile(`^([^\/]+)\/([^\/]+)$`)

Functions

func ConstructAppId

func ConstructAppId(appName string) string

func GetAppConfigPath added in v0.1.3

func GetAppConfigPath(config *Config, appId string) string

func GetConfigPath

func GetConfigPath() (string, error)

func GetTransactionsPath

func GetTransactionsPath() (string, error)

func GithubApiFetchReleases

func GithubApiFetchReleases(username string, reponame string) (*[]GithubApiRelease, error)

func InstallDesktopFile added in v0.1.0

func InstallDesktopFile(paths *AppPaths, content string) error

func ParseGithubRepoUrl

func ParseGithubRepoUrl(url string) (bool, string, string)

func ReadSourceConfig

func ReadSourceConfig(sourceId SourceId, sourcePath string) (any, error)

func RequestGithubApi

func RequestGithubApi[T any](method string, route string) (*T, error)

func SaveAppConfig

func SaveAppConfig(configPath string, config *AppConfig) error

func SaveConfig

func SaveConfig(config *Config) error

func SaveSourceConfig

func SaveSourceConfig[T any](configPath string, config T) error

func SaveTransactions

func SaveTransactions(transactions *Transactions) error

func UninstallDesktopFile

func UninstallDesktopFile(desktopFilePath string) error

func UpdateTransactions

func UpdateTransactions(performer UpdateTransactionFunc) error

Types

type AppConfig

type AppConfig struct {
	Id      string   `json:"Id"`
	Version string   `json:"Version"`
	Source  SourceId `json:"Source"`
	Paths   AppPaths `json:"Paths"`
}

func ReadAppConfig

func ReadAppConfig(configPath string) (*AppConfig, error)

type AppImageAssetMatch

type AppImageAssetMatch int
const (
	AppImageAssetNoMatch AppImageAssetMatch = iota
	AppImageAssetPartialMatch
	AppImageAssetExactMatch
)

func ChooseAptAppImageAsset

func ChooseAptAppImageAsset[T any](assets []T, assetNameFunc func(*T) string) (AppImageAssetMatch, *T)

type AppPaths

type AppPaths struct {
	Dir          string `json:"Dir"`
	Config       string `json:"Config"`
	SourceConfig string `json:"SourceConfig"`
	AppImage     string `json:"AppImage"`
	Icon         string `json:"Icon"`
	Desktop      string `json:"Desktop"`
	Symlink      string `json:"Symlink"`
}

func ConstructAppPaths added in v0.1.0

func ConstructAppPaths(config *Config, appId string, options *ConstructAppPathsOptions) *AppPaths

type Asset

type Asset struct {
	Source   string
	Size     int64
	Download AssetDownloadFunc
}

type AssetDownloadFunc

type AssetDownloadFunc func() (io.ReadCloser, error)

func LocalAssetDownload

func LocalAssetDownload(name string) AssetDownloadFunc

func NetworkAssetDownload

func NetworkAssetDownload(url string) AssetDownloadFunc

type Config

type Config struct {
	AppsDir                 string            `json:"AppsDir"`
	DesktopDir              string            `json:"DesktopDir"`
	Installed               map[string]string `json:"Installed"`
	EnableIntegrationPrompt bool              `json:"EnableIntegrationPrompt"`
	SymlinksDir             string            `json:"SymlinksDir"`
}

func GetConfig

func GetConfig() (*Config, error)

func ReadConfig

func ReadConfig() (*Config, error)

type ConstructAppPathsOptions added in v0.1.7

type ConstructAppPathsOptions struct {
	Symlink bool
}

type DeflatedAppImage

type DeflatedAppImage struct {
	AppImagePath string
	ParentDir    string
	AppDir       string
}

func DeflateAppImage

func DeflateAppImage(appImagePath string, parentDir string) (*DeflatedAppImage, error)

func (*DeflatedAppImage) ExtractExecName

func (deflated *DeflatedAppImage) ExtractExecName() (string, error)

func (*DeflatedAppImage) ExtractMetadata

func (deflated *DeflatedAppImage) ExtractMetadata() (*DeflatedAppImageMetadata, error)

type DeflatedAppImageMetadata

type DeflatedAppImageMetadata struct {
	*DeflatedAppImage
	ExecName    string
	IconPath    string
	DesktopPath string
}

func (*DeflatedAppImageMetadata) CopyIconFile

func (metadata *DeflatedAppImageMetadata) CopyIconFile(paths *AppPaths) error

func (*DeflatedAppImageMetadata) InstallDesktopFile

func (metadata *DeflatedAppImageMetadata) InstallDesktopFile(paths *AppPaths) error
func (metadata *DeflatedAppImageMetadata) Symlink(paths *AppPaths) error

type GithubApiRelease

type GithubApiRelease struct {
	ApiUrl     string                  `json:"url"`
	HtmlUrl    string                  `json:"html_url"`
	TagName    string                  `json:"tag_name"`
	Draft      bool                    `json:"draft"`
	PreRelease bool                    `json:"prerelease"`
	Assets     []GithubApiReleaseAsset `json:"assets"`
}

func GithubApiFetchLatestAny added in v0.1.3

func GithubApiFetchLatestAny(username string, reponame string) (*GithubApiRelease, error)

func GithubApiFetchLatestPreRelease

func GithubApiFetchLatestPreRelease(username string, reponame string) (*GithubApiRelease, error)

func GithubApiFetchLatestRelease

func GithubApiFetchLatestRelease(username string, reponame string) (*GithubApiRelease, error)

func GithubApiFetchTaggedRelease

func GithubApiFetchTaggedRelease(username string, reponame string, tag string) (*GithubApiRelease, error)

func (*GithubApiRelease) ChooseAptAsset

func (release *GithubApiRelease) ChooseAptAsset() (AppImageAssetMatch, *GithubApiReleaseAsset)

type GithubApiReleaseAsset

type GithubApiReleaseAsset struct {
	ApiUrl      string `json:"url"`
	DownloadUrl string `json:"browser_download_url"`
	Name        string `json:"name"`
	Size        int64  `json:"size"`
}

func (*GithubApiReleaseAsset) ToAsset

func (asset *GithubApiReleaseAsset) ToAsset() *Asset

type GithubSource

type GithubSource struct {
	UserName string              `json:"UserName"`
	RepoName string              `json:"RepoName"`
	Release  GithubSourceRelease `json:"Release"`
	TagName  string              `json:"TagName"`
}

func ReadGithubSourceConfig

func ReadGithubSourceConfig(configPath string) (*GithubSource, error)

func (*GithubSource) CheckUpdate

func (source *GithubSource) CheckUpdate(app *AppConfig, reinstall bool) (*SourceUpdate, error)

func (*GithubSource) FetchAptLatestRelease

func (source *GithubSource) FetchAptLatestRelease() (*GithubApiRelease, error)

func (*GithubSource) FetchAptRelease

func (source *GithubSource) FetchAptRelease() (*GithubApiRelease, error)

func (*GithubSource) SupportUpdates

func (source *GithubSource) SupportUpdates() bool

type GithubSourceRelease added in v0.1.3

type GithubSourceRelease string
const (
	GithubSourceReleaseLatest     GithubSourceRelease = "latest"
	GithubSourceReleasePreRelease GithubSourceRelease = "prerelease"
	GithubSourceReleaseTagged     GithubSourceRelease = "tag"
	GithubSourceReleaseAny        GithubSourceRelease = "any"
)

type HttpSource

type HttpSource struct{}

func ReadHttpSourceConfig

func ReadHttpSourceConfig(configPath string) (*HttpSource, error)

func (*HttpSource) CheckUpdate

func (*HttpSource) CheckUpdate(app *AppConfig, reinstall bool) (*SourceUpdate, error)

func (*HttpSource) SupportsUpdates

func (*HttpSource) SupportsUpdates() bool

type LocalSource

type LocalSource struct{}

func ReadLocalSourceConfig

func ReadLocalSourceConfig(configPath string) (*LocalSource, error)

func (*LocalSource) CheckUpdate

func (*LocalSource) CheckUpdate(app *AppConfig, reinstall bool) (*SourceUpdate, error)

func (*LocalSource) SupportUpdates

func (*LocalSource) SupportUpdates() bool

type NetworkAssetMetadata

type NetworkAssetMetadata struct {
	Size int64
}

func ExtractNetworkAssetMetadata

func ExtractNetworkAssetMetadata(url string) (*NetworkAssetMetadata, error)

type PendingInstallation

type PendingInstallation struct {
	InvolvedDirs  []string
	InvolvedFiles []string
}

type Source

type Source interface {
	SupportUpdates() bool
	CheckUpdate(app *AppConfig, reinstall bool) (*SourceUpdate, error)
}

func CastSourceConfigAsSource

func CastSourceConfigAsSource(config any) (Source, error)

type SourceId

type SourceId string
const GithubSourceId SourceId = "github"
const HttpSourceId SourceId = "http"
const LocalSourceId SourceId = "local"

type SourceUpdate

type SourceUpdate struct {
	Version    string
	MatchScore AppImageAssetMatch
	*Asset
}

type Transactions

type Transactions struct {
	PendingInstallations map[string]PendingInstallation
}

func GetTransactions

func GetTransactions() (*Transactions, error)

type UpdateTransactionFunc

type UpdateTransactionFunc func(transactions *Transactions) error

Jump to

Keyboard shortcuts

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