aboutsummaryrefslogtreecommitdiffstats
path: root/make-feed.lua
diff options
context:
space:
mode:
authorgarret <garret@airmail.cc>2022-11-20 06:48:33 +0000
committergarret <garret@airmail.cc>2022-11-20 06:48:33 +0000
commite33f4763fcbebfa509c5cc725d5ecb92f3dfc5cb (patch)
tree02f57f3ec8fcb1980f16814eb7802b209b8a3aab /make-feed.lua
parent20f4d8b86f47e59a8bd392ec2c37e4dd4c7b5e5e (diff)
downloaddepctrl-feedmaker-e33f4763fcbebfa509c5cc725d5ecb92f3dfc5cb.tar.gz
depctrl-feedmaker-e33f4763fcbebfa509c5cc725d5ecb92f3dfc5cb.tar.bz2
depctrl-feedmaker-e33f4763fcbebfa509c5cc725d5ecb92f3dfc5cb.zip
feedmaker: actual feed-making capabilities
Diffstat (limited to 'make-feed.lua')
-rwxr-xr-xmake-feed.lua45
1 files changed, 43 insertions, 2 deletions
diff --git a/make-feed.lua b/make-feed.lua
index 639e74f..fd132a3 100755
--- a/make-feed.lua
+++ b/make-feed.lua
@@ -100,14 +100,55 @@ local function get_metadata(file)
return meta
end
+local function clean_depctrl(depctrl)
+ local required = {}
+ for _, mod in ipairs(depctrl) do
+ if type(mod[1]) == "string" then
+ mod["moduleName"] = mod[1]
+ mod[1] = nil
+ else
+ mod[1]["moduleName"] = mod[1][1]
+ mod[1][1] = nil
+ end
+ table.insert(required, mod)
+ end
+ return required
+end
+
+local function make_feed(macros)
+ local feed = {
+ dependencyControlFeedFormatVersion = "0.3.0",
+ name = config.name,
+ description = config.description,
+ knownFeeds = {},
+ baseUrl = config.baseUrl,
+ url = config.url,
+ maintainer = config.maintainer,
+ fileBaseUrl = config.fileBaseUrl,
+ macros = {}
+ }
+ for _, script in ipairs(macros) do
+ local macro = {url = config.scriptUrl, author = script.author, name = script.name, description = script.description, channels = {}}
+ local channel_info = {version = script.version, released = script.release, default = true, files = {}}
+ channel_info.requiredModules = clean_depctrl(script.depctrl)
+ channel_info.files[".lua"] = {name = ".lua", url = config.fileUrl, sha1 = script.sha1}
+ macro.channels[config.channel] = channel_info
+ feed.macros[script.namespace] = macro
+ end
+ return json.encode(feed)
+end
+
local function main()
local files = get_files(args.macro_dir)
- print(inspect(files))
local meta = {}
for _, file in ipairs(files) do
table.insert(meta, get_metadata(file))
end
- print(inspect(meta))
+ local feed = make_feed(meta)
+
+ local out = output_writer(args.output)
+ out:write(feed)
+ out:close()
end
main()