mirror of
https://github.com/kaboomserver/server.git
synced 2025-07-23 06:13:41 +00:00
Rewrite server update script (#148)
* refactor!: rewrite update script * refactor: split common URL logic into download_with_args * feat: add skip_404 arg to url/zip download type
This commit is contained in:
parent
1f1deda15c
commit
c4ca438600
11 changed files with 373 additions and 69 deletions
52
scripts/_parser.jq
Normal file
52
scripts/_parser.jq
Normal file
|
@ -0,0 +1,52 @@
|
|||
# Apply $filter to input
|
||||
# <- downloads.json | evaluate_filter("plugins")
|
||||
# -> [["internal", "plugins/Extras.jar", "type"], "zip"]
|
||||
# -> [["internal", "plugins/Extras.jar", "url"], "..."]
|
||||
# -> [["internal", "plugins/Extras.jar", "url"]]
|
||||
# -> [["internal", "plugins/Extras.jar"]]
|
||||
# -> [["internal"]]
|
||||
def evaluate_filter($filter):
|
||||
$filter | indices("/") | length
|
||||
| truncate_stream(
|
||||
inputs
|
||||
| select(
|
||||
.[0] as $key
|
||||
| $key | join("/")
|
||||
| startswith($filter)));
|
||||
|
||||
# Flatten stream structure, stripping everything but the download
|
||||
# path and it's properties
|
||||
# <- [["internal", "plugins/Extras.jar", "type"], "zip"]
|
||||
# <- [["internal", "plugins/Extras.jar", "url"], "..."]
|
||||
# <- [["internal", "plugins/Extras.jar"]]
|
||||
# <- [["internal"]]
|
||||
# -> [["plugins/Extras.jar", "type"], "zip"]
|
||||
# -> [["plugins/Extras.jar", "url"], "..."]
|
||||
def get_downloads_obj:
|
||||
select(length == 2)
|
||||
| del(.[0][:-2]);
|
||||
|
||||
# Reduce flattened stream to an object
|
||||
# <- [["plugins/Extras.jar", "type"], "zip"]
|
||||
# <- [["plugins/Extras.jar", "url"], "..."]
|
||||
# -> { "plugins/Extras.jar": {"type": "zip", "url": "..."} }
|
||||
def reduce_to_object(stream):
|
||||
reduce stream as $in ({};
|
||||
setpath($in[0]; $in[1]));
|
||||
|
||||
# Turn object into a bash-readable string
|
||||
# <- { "plugins/Extras.jar": {"type": "zip"} }
|
||||
# -> plugins/Extras.jar
|
||||
# zip
|
||||
# { "url": ... }
|
||||
def print_bash:
|
||||
to_entries[]
|
||||
| (.value | del(.type)) as $args
|
||||
| "\(.key)\n\(.value.type)\n\($args)";
|
||||
|
||||
reduce_to_object(
|
||||
if $arg1 == ""
|
||||
then inputs
|
||||
else evaluate_filter($arg1) end
|
||||
| get_downloads_obj)
|
||||
| print_bash
|
Loading…
Add table
Add a link
Reference in a new issue