mirror of
https://github.com/nix-community/dream2nix.git
synced 2024-09-11 14:35:30 +03:00
fix: crates-io-simple indexer
This commit is contained in:
parent
bc454bfe9d
commit
3caf3a8a67
@ -13,6 +13,10 @@
|
||||
number = 5;
|
||||
};
|
||||
crates-io = {};
|
||||
crates-io-simple = {
|
||||
sortBy = "name";
|
||||
maxPages = 1;
|
||||
};
|
||||
};
|
||||
packageOverrides = {
|
||||
"^.*$".disable-build = {
|
||||
|
@ -4,10 +4,11 @@
|
||||
coreutils,
|
||||
curl,
|
||||
jq,
|
||||
python3,
|
||||
...
|
||||
}:
|
||||
utils.writePureShellScript
|
||||
[coreutils curl jq]
|
||||
[coreutils curl jq python3]
|
||||
''
|
||||
input=''${1:?"please provide an input as a JSON file"}
|
||||
|
||||
@ -19,9 +20,8 @@
|
||||
maxPages=$(jq '.maxPages' -c -r $input)
|
||||
|
||||
for currentPage in $(seq 1 $maxPages); do
|
||||
jqQuery="$(jq '.' -c -r "$tmpFile") + (.crates | map(\"crates-io:\" + .name + \"\/\" + .max_stable_version))"
|
||||
url="https://crates.io/api/v1/crates?page=$currentPage&per_page=100&sort=$sortBy"
|
||||
curl -k "$url" | jq "$jqQuery" -r > "$tmpFile"
|
||||
curl -k "$url" | python3 ${./process-result.py} > "$tmpFile"
|
||||
done
|
||||
|
||||
mv "$tmpFile" "$(realpath $outFile)"
|
||||
|
13
src/indexers/crates-io-simple/process-result.py
Normal file
13
src/indexers/crates-io-simple/process-result.py
Normal file
@ -0,0 +1,13 @@
|
||||
import json
|
||||
import sys
|
||||
|
||||
input = json.load(sys.stdin)
|
||||
projects = []
|
||||
for package in input['crates']:
|
||||
projects.append(dict(
|
||||
id=f"{package['name']}-{package['max_stable_version']}",
|
||||
name=package['name'],
|
||||
version=package['max_stable_version'],
|
||||
translator='crates-io',
|
||||
))
|
||||
print(json.dumps(projects, indent=2))
|
Loading…
Reference in New Issue
Block a user