diff options
author | V1K1NGbg <victor@ilchev.com> | 2024-08-22 17:49:07 -0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2024-10-21 13:30:51 -0300 |
commit | 20488302b00fed7675c65280c84db078c64ee36f (patch) | |
tree | 50555b48e0cbe0fe4c1eb7f7dbcc8d847b924800 | |
parent | 0e3779ab9df1e36ab3933591cfe50d173df8ec8a (diff) | |
download | luarocks-20488302b00fed7675c65280c84db078c64ee36f.tar.gz luarocks-20488302b00fed7675c65280c84db078c64ee36f.tar.bz2 luarocks-20488302b00fed7675c65280c84db078c64ee36f.zip |
Teal: convert luarocks.admin.index
-rw-r--r-- | src/luarocks/admin/index.tl (renamed from src/luarocks/admin/index.lua) | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/src/luarocks/admin/index.lua b/src/luarocks/admin/index.tl index 64c8c1eb..2cd47baf 100644 --- a/src/luarocks/admin/index.lua +++ b/src/luarocks/admin/index.tl | |||
@@ -1,6 +1,7 @@ | |||
1 | 1 | ||
2 | --- Module which builds the index.html page to be used in rocks servers. | 2 | --- Module which builds the index.html page to be used in rocks servers. |
3 | local index = {} | 3 | local record index |
4 | end | ||
4 | 5 | ||
5 | local util = require("luarocks.util") | 6 | local util = require("luarocks.util") |
6 | local fs = require("luarocks.fs") | 7 | local fs = require("luarocks.fs") |
@@ -9,6 +10,10 @@ local persist = require("luarocks.persist") | |||
9 | local dir = require("luarocks.dir") | 10 | local dir = require("luarocks.dir") |
10 | local manif = require("luarocks.manif") | 11 | local manif = require("luarocks.manif") |
11 | 12 | ||
13 | local type Rockspec = require("luarocks.core.types.rockspec").Rockspec | ||
14 | |||
15 | local type Entry = require("luarocks.core.types.manifest").Manifest.Entry | ||
16 | |||
12 | local ext_url_target = ' target="_blank"' | 17 | local ext_url_target = ' target="_blank"' |
13 | 18 | ||
14 | local index_header = [[ | 19 | local index_header = [[ |
@@ -95,17 +100,17 @@ local index_footer_end = [[ | |||
95 | </html> | 100 | </html> |
96 | ]] | 101 | ]] |
97 | 102 | ||
98 | function index.format_external_dependencies(rockspec) | 103 | function index.format_external_dependencies(rockspec: Rockspec): string |
99 | if rockspec.external_dependencies then | 104 | if rockspec.external_dependencies then |
100 | local deplist = {} | 105 | local deplist = {} |
101 | local listed_set = {} | 106 | local listed_set: {string: boolean} = {} |
102 | local plats = nil | 107 | local plats: {string : {string: string}} = nil |
103 | for name, desc in util.sortedpairs(rockspec.external_dependencies) do | 108 | for name, desc in util.sortedpairs(rockspec.external_dependencies) do |
104 | if name ~= "platforms" then | 109 | if name ~= "platforms" then |
105 | table.insert(deplist, name:lower()) | 110 | table.insert(deplist, name:lower()) |
106 | listed_set[name] = true | 111 | listed_set[name] = true |
107 | else | 112 | else |
108 | plats = desc | 113 | plats = desc as {string : {string: string}} |
109 | end | 114 | end |
110 | end | 115 | end |
111 | if plats then | 116 | if plats then |
@@ -123,7 +128,7 @@ function index.format_external_dependencies(rockspec) | |||
123 | end | 128 | end |
124 | end | 129 | end |
125 | 130 | ||
126 | function index.make_index(repo) | 131 | function index.make_index(repo: string): boolean, string |
127 | if not fs.is_dir(repo) then | 132 | if not fs.is_dir(repo) then |
128 | return nil, "Cannot access repository at "..repo | 133 | return nil, "Cannot access repository at "..repo |
129 | end | 134 | end |
@@ -132,14 +137,14 @@ function index.make_index(repo) | |||
132 | 137 | ||
133 | out:write(index_header) | 138 | out:write(index_header) |
134 | for package, version_list in util.sortedpairs(manifest.repository) do | 139 | for package, version_list in util.sortedpairs(manifest.repository) do |
135 | local latest_rockspec = nil | 140 | local latest_rockspec: string = nil |
136 | local output = index_package_begin | 141 | local output = index_package_begin |
137 | for version, data in util.sortedpairs(version_list, vers.compare_versions) do | 142 | for version, data in util.sortedpairs(version_list, vers.compare_versions) do |
138 | local versions = {} | 143 | local versions = {} |
139 | output = output..version..': ' | 144 | output = output..version..': ' |
140 | table.sort(data, function(a,b) return a.arch < b.arch end) | 145 | table.sort(data, function(a: Entry,b: Entry): boolean return a.arch < b.arch end) |
141 | for _, item in ipairs(data) do | 146 | for _, item in ipairs(data) do |
142 | local file | 147 | local file: string |
143 | if item.arch == 'rockspec' then | 148 | if item.arch == 'rockspec' then |
144 | file = ("%s-%s.rockspec"):format(package, version) | 149 | file = ("%s-%s.rockspec"):format(package, version) |
145 | if not latest_rockspec then latest_rockspec = file end | 150 | if not latest_rockspec then latest_rockspec = file end |
@@ -152,7 +157,7 @@ function index.make_index(repo) | |||
152 | end | 157 | end |
153 | output = output .. index_package_end | 158 | output = output .. index_package_end |
154 | if latest_rockspec then | 159 | if latest_rockspec then |
155 | local rockspec = persist.load_into_table(dir.path(repo, latest_rockspec)) | 160 | local rockspec = persist.load_into_table(dir.path(repo, latest_rockspec)) as Rockspec |
156 | local descript = rockspec.description or {} | 161 | local descript = rockspec.description or {} |
157 | local vars = { | 162 | local vars = { |
158 | anchor = package, | 163 | anchor = package, |