Repository navigation
Expand file tree
/
Copy pathphp.lua
More file actions
92 lines (79 loc) · 2.3 KB
/
Copy pathphp.lua
File metadata and controls
92 lines (79 loc) · 2.3 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
84
85
86
87
88
89
90
91
92
--[[
PHP support for VMR.
Conda-forge packages plus the official Windows release archives.
https://windows.php.net/downloads/releases/archives/
--]]
local C = dofile(__vmr_plugin_dir .. "/_vmr_common.lua")
-- global variables
plugin_name = "php"
sdk_name = "php"
plugin_version = "0.1"
homepage = "https://www.php.net/"
-- installer config
ic = C.installer({
flag_files = {
windows = { "php.exe", "lib" },
linux = { "bin", "lib" },
darwin = { "bin", "lib" },
},
binary_dirs = {
linux = { { "bin" } },
darwin = { { "bin" } },
},
})
-- spider
local ARCHIVE_BASE = "https://windows.php.net/downloads/releases/archives"
local function parseVersion(dUrl)
local v = vmrRegexpFindString("-\\d+(\\.\\d+){2}-", dUrl)
return vmrTrim(v, "-")
end
local function fileFilter(text)
if not vmrHasSuffix(text, "zip") then
return false
end
if vmrContains(text, "-nts-") then
return false
end
if not vmrContains(text, "x64") then
return false
end
if vmrContains(text, "-devel-") or vmrContains(text, "-test-") or vmrContains(text, "-debug-") then
return false
end
return true
end
function crawl()
local vl = C.pixi("php")
local headers = {}
headers["User-Agent"] =
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36"
local resp = vmrGetResponse(ARCHIVE_BASE .. "/", 600, headers)
local anchors = vmrInitSelection(resp, "a")
vmrEach(anchors, function(_, ss)
local text = vmrTrimSpace(vmrText(ss))
if not fileFilter(text) then
return
end
local href = vmrAttr(ss, "href")
if href == "" then
return
end
local versionStr = parseVersion(href)
if versionStr == "" or vmrHasPrefix(versionStr, "5.") then
return
end
local item = {}
if vmrHasPrefix(href, "http") then
item["url"] = href
else
item["url"] = vmrUrlJoin(ARCHIVE_BASE, href)
end
item["arch"] = "amd64"
item["os"] = "windows"
item["installer"] = vmrInstallerUnarchiver
item["size"] = 0
item["lts"] = ""
vmrAddItem(vl, versionStr, item)
end)
return vl
end