Repository navigation
Expand file tree
/
Copy pathdlang.lua
More file actions
83 lines (71 loc) · 2.36 KB
/
Copy pathdlang.lua
File metadata and controls
83 lines (71 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
-- dlang: live HTML crawl of the D release archive
-- (ported from vcollector official/dlang.go).
local C = dofile(__vmr_plugin_dir .. "/_vmr_common.lua")
plugin_name = "dlang"
sdk_name = "dlang"
plugin_version = "0.1"
homepage = "https://dlang.org/"
ic = C.installer({
flag_files = {
windows = { "windows" },
darwin = { "osx" },
linux = { "linux" },
},
binary_dirs = {
windows = { { "windows", "bin" } },
darwin = { { "osx", "bin" } },
linux = { { "linux", "bin64" } },
},
})
local HOST = "https://downloads.dlang.org"
local DOWNLOAD_URL = "https://downloads.dlang.org/releases/2.x/"
local function get_version(vl, vname, vhref)
local durl = vmrUrlJoin(HOST, vhref)
local resp = vmrGetResponse(durl, 180, {})
vmrEach(vmrInitSelection(resp, "div#content li a"), function(_, anchor)
local href = vmrAttr(anchor, "href")
local url, arch, os_name = "", "", ""
if vmrHasSuffix(href, ".windows.zip") then
url, arch, os_name = vmrUrlJoin(HOST, href), "amd64", "windows"
elseif vmrHasSuffix(href, ".osx.zip") then
url, arch, os_name = vmrUrlJoin(HOST, href), "amd64", "darwin"
elseif vmrHasSuffix(href, ".linux.zip") then
url, arch, os_name = vmrUrlJoin(HOST, href), "amd64", "linux"
end
if url ~= "" then
vmrAddItem(vl, vname, {
url = url,
arch = arch,
os = os_name,
sum = "",
sum_type = "",
size = 0,
installer = vmrInstallerUnarchiver,
lts = "",
extra = "",
})
end
end)
end
function crawl()
local vl = vmrNewVersionList()
local resp = vmrGetResponse(DOWNLOAD_URL, 180, {})
vmrEach(vmrInitSelection(resp, "div#content li a"), function(_, anchor)
local vname = vmrText(anchor)
local vhref = vmrAttr(anchor, "href")
if vhref == "" then
return
end
local parts, n = vmrSplit(vname, ".")
if n < 3 then
return
end
-- Only releases newer than 2.065.0 are published as archives with this layout.
local minor = tonumber(parts[2] or "") or 0
if minor < 65 then
return
end
get_version(vl, vname, vhref)
end)
return vl
end