[feat] PkgVersion

This commit is contained in:
what 2024-11-22 15:43:05 +08:00
parent 4e99e723c9
commit fefaa09793
2 changed files with 36 additions and 5 deletions

View File

@ -7,10 +7,40 @@ type PkgVersion struct {
FileName string `db:"filename"` FileName string `db:"filename"`
SourceMapFileName string `db:"sourcemapFileName"` SourceMapFileName string `db:"sourcemapFileName"`
Imports []string `db:"imports"` Imports []string `db:"imports"`
VersionAt string `db:"version_at"` Platform string `db:"platform"`
ReleaseAt string `db:"release_at"`
UpdatedAt string `db:"updated_at"`
CreatedAt string `db:"created_at"`
} }
func (this PkgVersion) GetFile() []byte func (this PkgVersion) GetFile() []byte
func (this PkgVersion) GetSourceMap() []byte func (this PkgVersion) GetSourceMap() []byte
type GetPkgVersion func(pkg string) (PkgVersion, bool) type GetPkgVersion func(pkg string, opts ...PkgOption) (PkgVersion, bool)
// 筛选选项
type PkgOption func(option *PkgOptions)
type PkgOptions struct {
platform string
hash string
}
func (this PkgOptions) Platform() string {
return this.platform
}
func (this PkgOptions) Hash() string {
return this.hash
}
func PkgPlatform(value string) PkgOption {
return func(option *PkgOptions) {
option.platform = value
}
}
func PkgHash(value string) PkgOption {
return func(option *PkgOptions) {
option.hash = value
}
}

View File

@ -116,9 +116,10 @@ var (
ErrPkgInvalid = &Errno{Code: 20702, Msg: "pkg invalid"} ErrPkgInvalid = &Errno{Code: 20702, Msg: "pkg invalid"}
ErrPkgPlatformInvalid = &Errno{Code: 20703, Msg: "pkg platform invalid"} ErrPkgPlatformInvalid = &Errno{Code: 20703, Msg: "pkg platform invalid"}
ErrPkgUpgrade = &Errno{Code: 20704, Msg: "pkg upgrade fail"} ErrPkgUpgrade = &Errno{Code: 20704, Msg: "pkg upgrade fail"}
ErrPkgDownload = &Errno{Code: 20705, Msg: "pkg download fail"} ErrPkgRollback = &Errno{Code: 20705, Msg: "pkg version rollback fail"}
ErrPkgUpload = &Errno{Code: 20706, Msg: "pkg upload fail"} ErrPkgDownload = &Errno{Code: 20706, Msg: "pkg download fail"}
ErrPkgBuild = &Errno{Code: 20707, Msg: "pkg build fail"} ErrPkgUpload = &Errno{Code: 20707, Msg: "pkg upload fail"}
ErrPkgBuild = &Errno{Code: 20708, Msg: "pkg build fail"}
) )
// 使用 错误码 和 error 创建新的 错误 // 使用 错误码 和 error 创建新的 错误