mirror of
https://github.com/logos-messaging/packages.git
synced 2026-01-05 15:43:13 +00:00
Merge pull request #169 from fenekku/package_scanner_fix
improved(?) package_scanner!
This commit is contained in:
commit
0087aeb61f
@ -4,11 +4,12 @@
|
|||||||
# Scans the package list from this repository.
|
# Scans the package list from this repository.
|
||||||
#
|
#
|
||||||
# Check the packages for:
|
# Check the packages for:
|
||||||
# * Missing/unknown license
|
|
||||||
# * Missing description
|
|
||||||
# * Missing name
|
# * Missing name
|
||||||
# * Missing/unknown method
|
# * Missing/unknown method
|
||||||
# * Missing/unreachable repository
|
# * Missing/unreachable repository
|
||||||
|
# * Missing tags
|
||||||
|
# * Missing description
|
||||||
|
# * Missing/unknown license
|
||||||
#
|
#
|
||||||
# Usage: nim c -d:ssl -r package_scanner.nim
|
# Usage: nim c -d:ssl -r package_scanner.nim
|
||||||
#
|
#
|
||||||
@ -41,24 +42,44 @@ const
|
|||||||
|
|
||||||
VCS_TYPES = @["git", "hg"]
|
VCS_TYPES = @["git", "hg"]
|
||||||
|
|
||||||
|
proc canFetchNimbleRepository(name: string, urlJson: JsonNode): bool =
|
||||||
|
# The fetch is a lie!
|
||||||
|
# TODO: Make this check the actual repo url and check if there is a
|
||||||
|
# nimble file in it
|
||||||
|
result = true
|
||||||
|
var url: string
|
||||||
|
|
||||||
|
if not urlJson.isNil:
|
||||||
|
url = urlJson.str
|
||||||
|
|
||||||
|
try:
|
||||||
|
discard getContent(url, timeout=1000)
|
||||||
|
except HttpRequestError, TimeoutError:
|
||||||
|
echo "E: ", name, ": unable to fetch repository ", url, " ",
|
||||||
|
getCurrentExceptionMsg()
|
||||||
|
result = false
|
||||||
|
except AssertionError:
|
||||||
|
echo "W: ", name, ": httpclient failed ", url, " ",
|
||||||
|
getCurrentExceptionMsg()
|
||||||
|
|
||||||
|
|
||||||
proc check(): int =
|
proc check(): int =
|
||||||
var
|
var
|
||||||
name: string
|
name: string
|
||||||
url: string
|
|
||||||
|
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
let
|
let
|
||||||
pkg_list = parseJson(readFile(getCurrentDir() / "packages.json"))
|
pkg_list = parseJson(readFile(getCurrentDir() / "packages.json"))
|
||||||
|
|
||||||
for pdata in pkg_list:
|
for pdata in pkg_list:
|
||||||
if not pdata.hasKey("name"):
|
name = if pdata.hasKey("name"): pdata["name"].str else: nil
|
||||||
|
|
||||||
|
if name.isNil:
|
||||||
echo "E: missing package name"
|
echo "E: missing package name"
|
||||||
result.inc()
|
result.inc()
|
||||||
continue
|
|
||||||
|
|
||||||
name = pdata["name"].str
|
elif not pdata.hasKey("method"):
|
||||||
if not pdata.hasKey("method"):
|
|
||||||
echo "E: ", name, " has no method"
|
echo "E: ", name, " has no method"
|
||||||
result.inc()
|
result.inc()
|
||||||
|
|
||||||
@ -66,36 +87,34 @@ proc check(): int =
|
|||||||
echo "E: ", name, " has an unknown method: ", pdata["method"].str
|
echo "E: ", name, " has an unknown method: ", pdata["method"].str
|
||||||
result.inc()
|
result.inc()
|
||||||
|
|
||||||
if not pdata.hasKey("license"):
|
elif not pdata.hasKey("url"):
|
||||||
echo "E: ", name, " has no license"
|
echo "E: ", name, " has no URL"
|
||||||
result.inc()
|
result.inc()
|
||||||
elif not (pdata["license"].str in LICENSES):
|
|
||||||
echo "W: ", name, " has an unexpected license: ", pdata["license"]
|
|
||||||
|
|
||||||
if not pdata.hasKey("description"):
|
elif not canFetchNimbleRepository(name, pdata["web"]):
|
||||||
|
result.inc()
|
||||||
|
|
||||||
|
elif not pdata.hasKey("tags"):
|
||||||
|
echo "E: ", name, " has no tags"
|
||||||
|
result.inc()
|
||||||
|
|
||||||
|
elif not pdata.hasKey("description"):
|
||||||
echo "E: ", name, " has no description"
|
echo "E: ", name, " has no description"
|
||||||
result.inc()
|
result.inc()
|
||||||
|
|
||||||
if not pdata.hasKey("url"):
|
elif not pdata.hasKey("license"):
|
||||||
echo "E: ", name, " has no URL"
|
echo "E: ", name, " has no license"
|
||||||
result.inc()
|
result.inc()
|
||||||
continue
|
|
||||||
|
|
||||||
for pdata in pkg_list:
|
else:
|
||||||
if pdata.hasKey("name") and pdata.hasKey("web"):
|
# Other warnings should go here
|
||||||
name = pdata["name"].str
|
if not (pdata["license"].str in LICENSES):
|
||||||
url = pdata["web"].str
|
echo "W: ", name, " has an unexpected license: ", pdata["license"]
|
||||||
try:
|
|
||||||
discard getContent(url, timeout=1000)
|
|
||||||
|
|
||||||
except HttpRequestError, TimeoutError:
|
|
||||||
echo "E: ", name, ": unable to fetch repository ", url, " ", getCurrentExceptionMsg()
|
|
||||||
result.inc()
|
|
||||||
except AssertionError:
|
|
||||||
echo "W: ", name, ": httpclient failed ", url, " ", getCurrentExceptionMsg()
|
|
||||||
|
|
||||||
echo "Error count: ", result
|
echo ""
|
||||||
return
|
echo "Problematic packages count: ", result
|
||||||
|
|
||||||
|
|
||||||
when isMainModule:
|
when isMainModule:
|
||||||
quit(check())
|
quit(check())
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user