2023-08-26 18:57:00 -03:00
|
|
|
#!/usr/bin/env nu
|
|
|
|
|
|
|
|
export def "listMods" [] {
|
|
|
|
open all.json | reject body
|
|
|
|
}
|
|
|
|
|
|
|
|
export def "removeMods" [...slugs: string] {
|
|
|
|
(
|
|
|
|
open all.json |
|
|
|
|
where slug not-in $slugs |
|
|
|
|
save all.json -f
|
|
|
|
)
|
|
|
|
updateMods
|
|
|
|
}
|
|
|
|
|
|
|
|
export def "searchMods" [term: string] {
|
|
|
|
(
|
|
|
|
open all.json |
|
|
|
|
where slug =~ $term or title =~ $term |
|
|
|
|
select slug title description kind
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export def "addMods" [...slugs: string] {
|
|
|
|
(
|
|
|
|
open all.json |
|
|
|
|
append ($slugs | each { getMod }) |
|
|
|
|
uniq-by slug |
|
|
|
|
save all.json -f
|
|
|
|
)
|
|
|
|
updateMods
|
|
|
|
}
|
|
|
|
|
|
|
|
export def "updateMods" [] {
|
|
|
|
(
|
|
|
|
open all.json |
|
|
|
|
upsert kind {
|
|
|
|
kindOf client_side, server_side
|
|
|
|
} |
|
|
|
|
upsert link {|row|
|
|
|
|
$"https://modrinth.com/mod/($row.slug)"
|
|
|
|
} |
|
|
|
|
group-by kind |
|
|
|
|
items {| k, v |
|
|
|
|
$v | save $"out/($k).json" -f
|
|
|
|
}
|
|
|
|
)
|
|
|
|
open all.json
|
|
|
|
}
|
|
|
|
|
|
|
|
def kindOf [client_side: string, server_side: string] string {
|
|
|
|
if $in.client_side == "required" and $in.server_side == "required" {
|
|
|
|
"required"
|
|
|
|
} else if $in.client_side == "optional" and $in.server_side == "optional" {
|
|
|
|
"optional"
|
|
|
|
} else if $in.server_side == "unsupported" {
|
|
|
|
"clientside"
|
|
|
|
} else if $in.client_side == "unsupported" {
|
|
|
|
"serverside"
|
|
|
|
} else if $in.client_side == "optional" and $in.server_side == "required" {
|
|
|
|
"client-optional"
|
|
|
|
} else if $in.client_side == "required" and $in.server_side == "optional" {
|
|
|
|
"server-optional"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-31 12:16:43 -03:00
|
|
|
export def review [...review: string] {
|
|
|
|
(
|
|
|
|
open all.json |
|
|
|
|
upsert review {
|
|
|
|
if $in.slug in $review {
|
|
|
|
true
|
|
|
|
}
|
|
|
|
} |
|
|
|
|
save all.json -f
|
|
|
|
)
|
|
|
|
updateMods
|
|
|
|
}
|
|
|
|
|
2023-08-26 18:57:00 -03:00
|
|
|
export def conflicts [mod: string, ...conflicts: string] {
|
|
|
|
(
|
|
|
|
open all.json |
|
|
|
|
upsert conflicts {
|
|
|
|
if $in.slug == $mod {
|
|
|
|
$conflicts
|
|
|
|
} else if $in.slug in $conflicts {
|
|
|
|
if ("conflicts" in $in) {
|
|
|
|
$in.conflicts | append $mod | uniq
|
|
|
|
} else {
|
|
|
|
[$mod]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} |
|
|
|
|
save all.json -f
|
|
|
|
)
|
|
|
|
updateMods
|
|
|
|
}
|
|
|
|
|
|
|
|
export def getMods [] {
|
|
|
|
let list = $in | each { |v| $"\"($v)\"" } | str join , | $"[($in)]"
|
|
|
|
(
|
|
|
|
http get $"https://api.modrinth.com/v2/projects?ids=($list)" |
|
|
|
|
select slug project_type title description body client_side server_side categories additional_categories gallery |
|
|
|
|
update gallery {
|
|
|
|
get url
|
|
|
|
} |
|
|
|
|
insert kind {
|
|
|
|
kindOf client_side, server_side
|
|
|
|
} |
|
|
|
|
insert link {|row|
|
|
|
|
$"https://modrinth.com/mod/($row.slug)"
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export def getMod [] {
|
|
|
|
(
|
|
|
|
http get $"https://api.modrinth.com/v2/project/($in)" |
|
|
|
|
select slug project_type title description body client_side server_side categories additional_categories gallery |
|
|
|
|
update gallery {
|
|
|
|
get url
|
|
|
|
} |
|
|
|
|
insert kind {
|
|
|
|
kindOf client_side, server_side
|
|
|
|
} |
|
|
|
|
insert link {|row|
|
|
|
|
$"https://modrinth.com/mod/($row.slug)"
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|