Skip to content

Commit

Permalink
update filter
Browse files Browse the repository at this point in the history
  • Loading branch information
moqsien committed Mar 5, 2024
1 parent ab59d7f commit a53c029
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 38 deletions.
30 changes: 16 additions & 14 deletions pkgs/versions/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,22 @@ func filterByUrl(dUrl string) bool {
".txt",
".d.ts",
"src.tar.gz",
"-baseline.zip", // for bun
"-profile.zip", // for bun
"denort-", // for deno
"-unknown-linux-musl.tar.gz", // for fd.
"-pc-windows-gnu.zip", // for fd.
"linux-gnueabihf", // for fd
"linux-musleabihf", // for fd
"-musl-x86_64", // for julia -- untested
"-win64.tar.gz", // for julia
"-win32.tar.gz", // for julia
"kotlin-compiler-", // for kotlin
"Miniconda2-latest-", // for miniconda
"Miniconda-latest-", // for miniconda
// nodejs
"-baseline.zip", // for bun
"-profile.zip", // for bun
"denort-", // for deno
"-unknown-linux-musl.tar.gz", // for fd.
"-pc-windows-gnu.zip", // for fd.
"linux-gnueabihf", // for fd
"linux-musleabihf", // for fd
"kotlin-compiler-", // for kotlin
"unknown-linux-gnueabihf.", // for ripgrep
"unknown-linux-musleabi.", // for ripgrep
"unknown-linux-musleabihf.", // for ripgrep
"pc-windows-gnu.zip", // for ripgrep
"arm-unknown-linux-gnueabihf", // for typst-lsp
"typst-lsp-x86_64-unknown-linux-musl", // for typst-lsp
"-unknown-linux-musleabi.", // for typst
"wasm32-wasi.", // for zls
}
for _, s := range excludeList {
if strings.Contains(dUrl, s) {
Expand Down
20 changes: 19 additions & 1 deletion pkgs/versions/installers.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,21 @@ func (i *Installer) GetVSCode() {
}
}

func filterMinicondaByFName(fname string) bool {
r := false
toBunList := []string{
".pkg",
"Miniconda2-latest-", // for miniconda
"Miniconda-latest-", // for miniconda
}
for _, b := range toBunList {
if strings.Contains(fname, b) {
return true
}
}
return r
}

func (i *Installer) GetMiniconda() {
// https://repo.anaconda.com/miniconda/
i.homepage = "https://repo.anaconda.com/miniconda/"
Expand All @@ -271,7 +286,10 @@ func (i *Installer) GetMiniconda() {
return
}
fName := s.Find("td").Eq(0).Find("a").Text()
if strings.HasSuffix(fName, ".pkg") {
// if strings.HasSuffix(fName, ".pkg") {
// return
// }
if filterMinicondaByFName(fName) {
return
}
sha256Str := s.Find("td").Eq(3).Text()
Expand Down
62 changes: 41 additions & 21 deletions pkgs/versions/julia.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import (
"time"

"github.com/gogf/gf/v2/util/gconv"
"github.com/gvcgo/goutils/pkgs/gtea/gprint"
"github.com/gvcgo/goutils/pkgs/request"
"github.com/gvcgo/collector/pkgs/confs"
"github.com/gvcgo/collector/pkgs/upload"
"github.com/gvcgo/collector/pkgs/utils"
"github.com/gvcgo/goutils/pkgs/gtea/gprint"
"github.com/gvcgo/goutils/pkgs/request"
)

const (
Expand Down Expand Up @@ -69,6 +69,22 @@ func NewJulia(cnf *confs.CollectorConf) (j *Julia) {
return
}

func filterJuliaByUrl(jUrl string) bool {
r := false
toBunList := []string{
"-musl-x86_64", // for julia -- untested
"-win64.tar.gz", // for julia
"-win32.tar.gz", // for julia
".dmg",
}
for _, b := range toBunList {
if strings.Contains(jUrl, b) {
return true
}
}
return r
}

func (j *Julia) GetVersions() {
j.fetcher.SetUrl(j.homepage)
j.fetcher.Timeout = 180 * time.Second
Expand All @@ -87,26 +103,30 @@ func (j *Julia) GetVersions() {
extraStr = "stable"
}
for _, jFile := range fList.Files {
if jFile.Kind == "archive" && !strings.HasSuffix(jFile.Url, ".dmg") {
archStr := utils.ParseArch(jFile.Arch)
platform := utils.ParsePlatform(jFile.Os)
if archStr == "" || platform == "" {
continue
}
ver := &VFile{}
ver.Url = jFile.Url
ver.Arch = archStr
ver.Os = platform
ver.Sum = jFile.Sum
if ver.Sum != "" {
ver.SumType = "sha256"
}
ver.Extra = extraStr
if vlist, ok := j.versions[vName]; !ok || vlist == nil {
j.versions[vName] = []*VFile{}
}
j.versions[vName] = append(j.versions[vName], ver)
if jFile.Kind != "archive" {
continue
}
if filterJuliaByUrl(jFile.Url) {
continue
}
archStr := utils.ParseArch(jFile.Arch)
platform := utils.ParsePlatform(jFile.Os)
if archStr == "" || platform == "" {
continue
}
ver := &VFile{}
ver.Url = jFile.Url
ver.Arch = archStr
ver.Os = platform
ver.Sum = jFile.Sum
if ver.Sum != "" {
ver.SumType = "sha256"
}
ver.Extra = extraStr
if vlist, ok := j.versions[vName]; !ok || vlist == nil {
j.versions[vName] = []*VFile{}
}
j.versions[vName] = append(j.versions[vName], ver)
}
}
}
Expand Down
8 changes: 6 additions & 2 deletions pkgs/versions/nodejs.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import (
"time"

"github.com/gogf/gf/v2/util/gconv"
"github.com/gvcgo/goutils/pkgs/gtea/gprint"
"github.com/gvcgo/goutils/pkgs/request"
"github.com/gvcgo/collector/pkgs/confs"
"github.com/gvcgo/collector/pkgs/upload"
"github.com/gvcgo/collector/pkgs/utils"
"github.com/gvcgo/goutils/pkgs/gtea/gprint"
"github.com/gvcgo/goutils/pkgs/request"
)

const (
Expand Down Expand Up @@ -83,6 +83,10 @@ func (n *Nodejs) getVersion(vItem *Item) {
uList := strings.Split(strings.TrimSpace(line), " ")
if len(uList) >= 2 {
fName := strings.TrimSpace(uList[len(uList)-1])
// filter
if strings.Contains(fName, "node_pdb.zip") {
continue
}
archStr := utils.ParseArch(fName)
osStr := utils.ParsePlatform(fName)
if archStr != "" && osStr != "" {
Expand Down
4 changes: 4 additions & 0 deletions pkgs/versions/php.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ func (p *PhP) GetWindowsVersions() {
}
ver := &VFile{}
u := s.AttrOr("href", "")
// filter: discard Non-safe-thread version for Windows Server.
if strings.Contains(u, "nts-Win32") {
return
}
if !strings.HasPrefix(u, "https://") {
u, _ = url.JoinPath(baseUrl, u)
}
Expand Down

0 comments on commit a53c029

Please sign in to comment.