[feat] PkgVersion

This commit is contained in:
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"`
SourceMapFileName string `db:"sourcemapFileName"`
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) 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
}
}