version

package
v0.7.10 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultCheckInterval = 24 * time.Hour

DefaultCheckInterval 是两次联网检查之间的最小间隔。GitHub 匿名 API 限流 60 req/h,且发版节奏是天级,更频繁的检查只有打扰没有收益。

View Source
const DefaultRepo = "voocel/ainovel-cli"

DefaultRepo 是版本检查与自更新默认指向的上游仓库。

Variables

This section is empty.

Functions

func Normalize

func Normalize(v string) string

func Print

func Print(w io.Writer, info Info)

Types

type CheckOptions added in v0.7.8

type CheckOptions struct {
	Repo           string
	CurrentVersion string
	Client         *http.Client
	CachePath      string        // 空 = 不落盘,每次调用都联网
	MaxAge         time.Duration // 缓存有效期;<=0 取 DefaultCheckInterval
}

CheckOptions 是一次版本检查的输入。CachePath 由调用方传入(通常为 配置目录下的 update-check.json);本包不依赖 bootstrap,保持 version 作为叶子包的依赖方向。

type CheckResult added in v0.7.8

type CheckResult struct {
	Latest          string
	Current         string
	Notes           string
	UpdateAvailable bool
	FromCache       bool
}

CheckResult 是版本检查的结论。Notes 携带 release 原文(markdown), 调用方展示前必须按自身输出介质清理;升级与否由用户决定。

func CheckUpdate added in v0.7.8

func CheckUpdate(ctx context.Context, opts CheckOptions) (*CheckResult, error)

CheckUpdate 查询上游最新 release 并判断是否需要提醒升级。只读不写任何 二进制;是否升级、何时升级完全由用户经 `ainovel-cli update` 决定。 缓存或网络失败均通过 error 暴露;缓存写入失败时仍返回已经取得的检查结果。

type Info

type Info struct {
	Version string
	Commit  string
	Date    string
}

func Resolve

func Resolve(raw Info) Info

type UpdateOptions

type UpdateOptions struct {
	Repo           string
	BinaryName     string
	TargetVersion  string
	CurrentVersion string
	Client         *http.Client
}

type UpdateResult

type UpdateResult struct {
	Version string
	Path    string
	Updated bool
}

func Update

func Update(ctx context.Context, opts UpdateOptions) (*UpdateResult, error)

Jump to

Keyboard shortcuts

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